package importing fixes

This commit is contained in:
Graham Knop 2008-02-08 00:00:13 +00:00
parent 93b5ca16e4
commit f22646625b
9 changed files with 36 additions and 46 deletions

View file

@ -35,7 +35,8 @@
- fix: Make the Owner in editBranch to be the same as addEdit, allowing - fix: Make the Owner in editBranch to be the same as addEdit, allowing
any user to be selected (perlDreamer Consulting, LLC.) any user to be selected (perlDreamer Consulting, LLC.)
- Added a simple SMTPD for use in testing (t/smtpd.pl) - Added a simple SMTPD for use in testing (t/smtpd.pl)
- importPackage can now skip autocommit functions in the site settings - autocommit for packages is handled by web method, not API method
- fix: importing packages generates orphaned duplicates of all attached storage locations
7.5.0 7.5.0
- rfe: Search Asset returns URLs - rfe: Search Asset returns URLs

View file

@ -48,7 +48,7 @@ sub addPackage {
$storage->addFileFromFilesystem( $file ); $storage->addFileFromFilesystem( $file );
# Import the package into the import node # Import the package into the import node
my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage, { skipAutoCommit => 1 } ); my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage );
# Make the package not a package anymore # Make the package not a package anymore
$package->update({ isPackage => 0 }); $package->update({ isPackage => 0 });

View file

@ -536,7 +536,7 @@ sub addPackage {
$storage->addFileFromFilesystem( $file ); $storage->addFileFromFilesystem( $file );
# Import the package into the import node # Import the package into the import node
my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage, { skipAutoCommit => 0 } ); my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage );
# Make the package not a package anymore # Make the package not a package anymore
$package->update({ isPackage => 0 }); $package->update({ isPackage => 0 });

View file

@ -69,7 +69,7 @@ sub addPackage {
$storage->addFileFromFilesystem( $file ); $storage->addFileFromFilesystem( $file );
# Import the package into the import node # Import the package into the import node
my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage, { skipAutoCommit => 0 } ); my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage );
# Make the package not a package anymore # Make the package not a package anymore
$package->update({ isPackage => 0 }); $package->update({ isPackage => 0 });

View file

@ -56,15 +56,13 @@ Override the default method in order to deal with attachments.
sub addRevision { sub addRevision {
my $self = shift; my $self = shift;
my $properties = shift; my $newSelf = $self->SUPER::addRevision(@_);
if ($self->get("storageId") ne "") { if ($self->getRevisionCount > 1 && $self->get("storageId")) {
my $newStorage = $self->getStorageClass->get($self->session,$self->get("storageId"))->copy; my $newStorage = $self->getStorageClass->get($self->session,$self->get("storageId"))->copy;
$properties->{storageId} = $newStorage->getId; $newSelf->update({storageId => $newStorage->getId});
} }
my $newSelf = $self->SUPER::addRevision($properties, @_);
return $newSelf; return $newSelf;
} }

View file

@ -64,7 +64,7 @@ Override the default method in order to deal with attachments.
sub addRevision { sub addRevision {
my $self = shift; my $self = shift;
my $newSelf = $self->SUPER::addRevision(@_); my $newSelf = $self->SUPER::addRevision(@_);
if ($self->get("storageId")) { if ($newSelf->getRevisionCount > 1 && $self->get("storageId")) {
my $newStorage = WebGUI::Storage->get($self->session,$self->get("storageId"))->copy; my $newStorage = WebGUI::Storage->get($self->session,$self->get("storageId"))->copy;
$newSelf->update({storageId=>$newStorage->getId}); $newSelf->update({storageId=>$newStorage->getId});
} }

View file

@ -72,7 +72,7 @@ Override the default method in order to deal with attachments.
sub addRevision { sub addRevision {
my $self = shift; my $self = shift;
my $newSelf = $self->SUPER::addRevision(@_); my $newSelf = $self->SUPER::addRevision(@_);
if ($self->get("storageId")) { if ($newSelf->getRevisionCount > 1 && $self->get("storageId")) {
my $newStorage = WebGUI::Storage->get($self->session,$self->get("storageId"))->copy; my $newStorage = WebGUI::Storage->get($self->session,$self->get("storageId"))->copy;
$newSelf->update({storageId=>$newStorage->getId}); $newSelf->update({storageId=>$newStorage->getId});
} }

View file

@ -46,13 +46,15 @@ Override the default method in order to deal with attachments.
sub addRevision { sub addRevision {
my $self = shift; my $self = shift;
my $newSelf = $self->SUPER::addRevision(@_); my $newSelf = $self->SUPER::addRevision(@_);
foreach my $field (qw(image1 image2 image3 brochure manual warranty)) { if ($newSelf->getRevisionCount > 1) {
if ($self->get($field)) { foreach my $field (qw(image1 image2 image3 brochure manual warranty)) {
my $newStorage = WebGUI::Storage->get($self->session,$self->get($field))->copy; if ($self->get($field)) {
$newSelf->update({$field=>$newStorage->getId}); my $newStorage = WebGUI::Storage->get($self->session,$self->get($field))->copy;
} $newSelf->update({$field=>$newStorage->getId});
} }
return $newSelf; }
}
return $newSelf;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -116,13 +116,9 @@ sub getPackageList {
=head2 importAssetData ( hashRef ) =head2 importAssetData ( hashRef )
Imports the data exported by the exportAssetData method. If the asset Imports the data exported by the exportAssetData method. If the asset already exists, a new revision will be created with these properties. If it doesn't exist then a child will be added to the current asset. Returns a reference to the created asset.
already exists, a new revision will be created with these properties. If it
doesn't exist then a child will be added to the current asset.
Returns a reference to the created asset. =head3 hashRef
=head3 assetData
A hash reference containing the exported data. A hash reference containing the exported data.
@ -191,7 +187,7 @@ sub importAssetCollateralData {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 importPackage ( storageLocation [, options] ) =head2 importPackage ( storageLocation )
Imports the data from a webgui package file. Imports the data from a webgui package file.
@ -199,19 +195,11 @@ Imports the data from a webgui package file.
A reference to a WebGUI::Storage object that contains a webgui package file. A reference to a WebGUI::Storage object that contains a webgui package file.
=head3 options
An optional hashref of options with the following possible keys:
skipAutoCommit : If true, will skip any automatic commit in
the site's settings.
=cut =cut
sub importPackage { sub importPackage {
my $self = shift; my $self = shift;
my $storage = shift; my $storage = shift;
my $options = shift;
my $decompressed = $storage->untar($storage->getFiles->[0]); my $decompressed = $storage->untar($storage->getFiles->[0]);
my %assets = (); # All the assets we've imported my %assets = (); # All the assets we've imported
my $package = undef; # The asset package my $package = undef; # The asset package
@ -243,16 +231,6 @@ sub importPackage {
} }
} }
# Handle autocommit workflows
if (!$options->{skipAutoCommit} && $self->session->setting->get("autoRequestCommit")) {
if ($self->session->setting->get("skipCommitComments")) {
WebGUI::VersionTag->getWorking($self->session)->requestCommit;
}
else {
$self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId));
return undef;
}
}
return $package; return $package;
} }
@ -329,7 +307,18 @@ sub www_importPackage {
my $i18n = WebGUI::International->new($self->session, "Asset"); my $i18n = WebGUI::International->new($self->session, "Asset");
return $self->session->style->userStyle($i18n->get("package corrupt")); return $self->session->style->userStyle($i18n->get("package corrupt"));
} }
return $self->www_manageAssets(); # Handle autocommit workflows
if ($self->session->setting->get("autoRequestCommit")) {
if ($self->session->setting->get("skipCommitComments")) {
WebGUI::VersionTag->getWorking($self->session)->requestCommit;
}
else {
$self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId));
return undef;
}
}
return $self->www_manageAssets();
} }
1; 1;