fix: Import Package does nothing when re-importing trashed package

This commit is contained in:
Doug Bell 2007-12-13 16:19:59 +00:00
parent 607fdd25a2
commit d0a97d0bff
3 changed files with 42 additions and 21 deletions

View file

@ -9,6 +9,9 @@
(Diona Kidd, Knowmad Technologies) (Diona Kidd, Knowmad Technologies)
- rfe: Add menuTitle to folder template (perlDreamer Consulting, LLC) - rfe: Add menuTitle to folder template (perlDreamer Consulting, LLC)
7.4.19
- fix: Import Package does nothing when re-importing trashed package
7.4.18 7.4.18
- fix: Graph draws black triangle covering half the image - fix: Graph draws black triangle covering half the image
- fix: upgrade.pl willing to upgrade from versions prior to 7.3.22 - fix: upgrade.pl willing to upgrade from versions prior to 7.3.22

View file

@ -125,18 +125,18 @@ A hash reference containing the exported data.
=cut =cut
sub importAssetData { sub importAssetData {
my $self = shift; my $self = shift;
my $data = shift; my $data = shift;
my $error = $self->session->errorHandler; my $error = $self->session->errorHandler;
my $id = $data->{properties}{assetId}; my $id = $data->{properties}{assetId};
my $class = $data->{properties}{className}; my $class = $data->{properties}{className};
my $version = $data->{properties}{revisionDate}; my $version = $data->{properties}{revisionDate};
my $asset; my $asset;
my $assetExists = WebGUI::Asset->assetExists($self->session, $id, $class, $version); my $assetExists = WebGUI::Asset->assetExists($self->session, $id, $class, $version);
if ($assetExists) { # update an existing revision if ($assetExists) { # update an existing revision
$asset = WebGUI::Asset->new($self->session, $id, $class, $version); $asset = WebGUI::Asset->new($self->session, $id, $class, $version);
$error->info("Updating an existing revision of asset $id"); $error->info("Updating an existing revision of asset $id");
$asset->update($data->{properties}); $asset->update($data->{properties});
##Pending assets are assigned a new version tag ##Pending assets are assigned a new version tag
if ($data->{properties}->{status} eq 'pending') { if ($data->{properties}->{status} eq 'pending') {
$self->session->db->write( $self->session->db->write(
@ -144,19 +144,25 @@ sub importAssetData {
[WebGUI::VersionTag->getWorking($self->session)->getId, $data->{properties}->{assetId}] [WebGUI::VersionTag->getWorking($self->session)->getId, $data->{properties}->{assetId}]
); );
} }
} }
else { else {
$asset = WebGUI::Asset->new($self->session, $id, $class); $asset = WebGUI::Asset->new($self->session, $id, $class);
if (defined $asset) { # create a new revision of an existing asset if (defined $asset) { # create a new revision of an existing asset
$error->info("Creating a new revision of asset $id"); $error->info("Creating a new revision of asset $id");
$asset = $asset->addRevision($data->{properties}, $version, {skipAutoCommitWorkflows => 1}); $asset = $asset->addRevision($data->{properties}, $version, {skipAutoCommitWorkflows => 1});
} }
else { # add an entirely new asset else { # add an entirely new asset
$error->info("Adding $id that didn't previously exist."); $error->info("Adding $id that didn't previously exist.");
$asset = $self->addChild($data->{properties}, $id, $version, {skipAutoCommitWorkflows => 1}); $asset = $self->addChild($data->{properties}, $id, $version, {skipAutoCommitWorkflows => 1});
} }
} }
return $asset;
# If the asset is in the trash, re-publish it
if ( $asset->isInTrash ) {
$asset->publish;
}
return $asset;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -90,6 +90,18 @@ sub getAssetsInTrash {
return \@assets; return \@assets;
} }
#----------------------------------------------------------------------------
=head2 isInTrash ( )
Returns true if the asset is in the trash.
=cut
sub isInTrash {
my $self = shift;
return $self->get("state") eq "trash";
}
#------------------------------------------------------------------- #-------------------------------------------------------------------