Add progress bars for rollback, trash and their www methods.

This commit is contained in:
Colin Kuskie 2009-06-24 22:30:41 +00:00
parent ef4afdb9c8
commit 7b5cf7518c
6 changed files with 141 additions and 25 deletions

View file

@ -7,6 +7,8 @@
- fixed: Add the user's first day of week data to getWebguiProperties and get rid of some inline javascript in the Data and DateTime forms.
- fixed #10544: AssetVersioning: child assets versions under uncommitted parent
- fixed #10549: EMS import
- fixed #10561: pb: purge
- fixed #10563: pb: rollback version tag
7.7.11
- Fixed a bug where empty version tags were not deleted. (Martin Kamerbeek / Oqapi)

View file

@ -119,15 +119,22 @@ A hash refernece containing options that change the behavior of this method.
A boolean that, if true, will skip dealing with exported files.
=head4 outputSub
A subroutine used to report the status of the purge, most likely used by WebGUI::ProgressBar->update.
=cut
sub purge {
my $self = shift;
my $options = shift;
my $session = $self->session;
my $self = shift;
my $options = shift;
my $session = $self->session;
my $outputSub = $options->{outputSub} || sub {};
my $i18n = WebGUI::International->new($session, 'Asset');
# can't delete if it's one of these things
if ($self->getId eq $session->setting->get("defaultPage") || $self->getId eq $session->setting->get("notFoundPage") || $self->get("isSystem")) {
$outputSub->(sprintf $i18n->get('Trying to delete system page %s. Aborting purge'), $self->getTitle);
$session->errorHandler->security("delete a system protected page (".$self->getId.")");
return 0;
}
@ -143,26 +150,30 @@ sub purge {
if (defined $kid) {
unless ($kid->purge) {
$self->errorHandler->security("delete one of (".$self->getId.")'s children which is a system protected page");
$outputSub->(sprintf $i18n->get('Trying to delete system page %s. Aborting purge'), $self->getTitle);
return 0;
}
}
else {
$outputSub->($i18n->get('Undefined child'));
$session->errorHandler->error("getLineage returned an undefined object in the AssetTrash->purge method. Unable to purge asset.");
}
}
# Delete shortcuts to this asset
# Also publish any shortcuts to this asset that are in the trash
$outputSub->($i18n->get('Purging shortcuts'));
my $shortcuts
= WebGUI::Asset::Shortcut->getShortcutsForAssetId($self->session, $self->getId, {
returnObjects => 1,
});
for my $shortcut ( @$shortcuts ) {
$shortcut->purge;
$shortcut->purge({ outputSub => $outputSub, });
}
# gotta delete stuff we've exported
unless ($options->{skipExported}) {
$outputSub->($i18n->get('Deleting exported files'));
$self->_invokeWorkflowOnExportedFiles($self->session->setting->get('purgeWorkflow'), 1);
}
@ -170,16 +181,20 @@ sub purge {
my $tagId = $self->get("tagId");
# clean up keywords
$outputSub->($i18n->get('Deleting keywords'));
WebGUI::Keyword->new($session)->deleteKeywordsForAsset($self);
# clean up search engine
$outputSub->($i18n->get('Clearing search index'));
WebGUI::Search::Index->new($self)->delete;
# clean up cache
$outputSub->($i18n->get('Clearing cache'));
WebGUI::Cache->new($session)->deleteChunk(["asset",$self->getId]);
$self->purgeCache;
# delete stuff out of the asset tables
$outputSub->($i18n->get('Clearing asset tables'));
$session->db->beginTransaction;
$session->db->write("delete from metaData_values where assetId = ?",[$self->getId]);
foreach my $definition (@{$self->definition($session)}) {
@ -382,16 +397,27 @@ Purges a piece of content, including all it's revisions, from the system permane
=cut
sub www_purgeList {
my $self = shift;
foreach my $id ($self->session->form->param("assetId")) {
my $asset = WebGUI::Asset->newPending($self->session,$id);
$asset->purge if $asset->canEdit;
my $self = shift;
my $session = $self->session;
my $pb = WebGUI::ProgressBar->new($session);
my $i18n = WebGUI::International->new($session, 'Asset');
$pb->start($i18n->get('purge'), $session->url->extras('adminConsole/assets.gif'));
ASSETID: foreach my $id ($session->form->param("assetId")) {
my $asset = eval { WebGUI::Asset->newPending($session,$id); };
if ($@) {
$pb->update(sprintf $i18n->get('Error getting asset with assetId %s'), $id);
next ASSETID;
}
if ($self->session->form->process("proceed") ne "") {
my $method = "www_".$self->session->form->process("proceed");
return $self->$method();
if (! $asset->canEdit) {
$pb->update(sprintf $i18n->get('You cannot edit the asset %s, skipping purge'), $asset->getTitle);
}
return $self->www_manageTrash();
else {
$asset->purge({outputSub => sub { $pb->update(@_); } });
}
}
my $method = ($session->form->process("proceed")) ? $session->form->process('proceed') : 'manageTrash';
$pb->finish($self->getUrl('func='.$method));
}
#-------------------------------------------------------------------

View file

@ -850,14 +850,16 @@ sub www_rollbackVersionTag {
return $session->privilege->adminOnly() unless canView($session);
my $tagId = $session->form->process("tagId");
return $session->privilege->vitalComponent() if ($tagId eq "pbversion0000000000001");
my $pb = WebGUI::ProgressBar->new($session);
my $i18n = WebGUI::International->new($session, 'VersionTag');
$pb->start($i18n->get('rollback version tag'), $session->url->extras('adminConsole/versionTags.gif'));
if ($tagId) {
my $tag = WebGUI::VersionTag->new($session, $tagId);
$tag->rollback if defined $tag;
$tag->rollback({ outputSub => sub { $pb->update(@_) }, }) if defined $tag;
}
if ($session->form->process("proceed") eq "manageCommittedVersions") {
return www_manageCommittedVersions($session);
}
return www_manageVersions($session);
my $method = $session->form->process("proceed");
$method = $method eq "manageCommittedVersions" ? $method : 'manageVersions';
$pb->finish(WebGUI::Asset->getDefault($session)->getUrl('op='.$method));
}

View file

@ -579,25 +579,39 @@ sub requestCommit {
#-------------------------------------------------------------------
=head2 rollback ( )
=head2 rollback ( [ $options ] )
Eliminates all revisions of all assets created under a specific version tag. Also removes the version tag.
=head3 options
A hashref of options for this method
=head4 outputSub
A subroutine for reporting the status of the rollback. Typically used by WebGUI::ProgressBar
=cut
sub rollback {
my $self = shift;
my $tagId = $self->getId;
my $self = shift;
my $session = $self->session;
my $options = shift || {};
my $outputSub = exists $options->{outputSub} ? $options->{outputSub} : sub {};
my $tagId = $self->getId;
if ($tagId eq "pbversion0000000000001") {
$self->session->errorHandler->warn("You cannot rollback a tag that is required for the system to operate.");
$session->errorHandler->warn("You cannot rollback a tag that is required for the system to operate.");
return 0;
}
my $sth = $self->session->db->read("select asset.className, asset.assetId, assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId = ? order by asset.lineage desc, assetData.revisionDate desc", [ $tagId ]);
while (my ($class, $id, $revisionDate) = $sth->array) {
my $revision = WebGUI::Asset->new($self->session,$id, $class, $revisionDate);
my $sth = $session->db->read("select asset.className, asset.assetId, assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId = ? order by asset.lineage desc, assetData.revisionDate desc", [ $tagId ]);
my $i18n = WebGUI::International->new($session, 'VersionTag');
REVISION: while (my ($class, $id, $revisionDate) = $sth->array) {
my $revision = WebGUI::Asset->new($session,$id, $class, $revisionDate);
next REVISION unless $revision;
$outputSub->(sprintf $i18n->get('Rolling back %s'), $revision->getTitle);
$revision->purgeRevision;
}
$self->session->db->write("delete from assetVersionTag where tagId=?", [$tagId]);
$session->db->write("delete from assetVersionTag where tagId=?", [$tagId]);
$self->clearWorking;
return 1;
}

View file

@ -1298,6 +1298,72 @@ Couldn't open %-s because %-s <br />
context => q{Description of asset property},
},
'Error getting asset with assetId %s' => {
message => q{Error getting asset with assetId %s},
lastUpdated => 0,
context => q{Generic error when an asset cannot be looked up by assetId},
},
'You cannot edit the asset %s, skipping purge' => {
message => q{You cannot edit the asset %s, skipping purge},
lastUpdated => 0,
context => q{Generic error when an asset cannot be deleted},
},
'Purging %s' => {
message => q{Purging %s},
lastUpdated => 0,
context => q{},
},
'Trying to delete system page %s. Aborting purge' => {
message => q{Trying to delete system page %s. Aborting purge},
lastUpdated => 0,
context => q{},
},
'Undefined child' => {
message => q{Trying to delete system page %s. Aborting purge},
lastUpdated => 0,
context => q{},
},
'Purging shortcuts' => {
message => q{Purging shortcuts},
lastUpdated => 0,
context => q{},
},
'Deleting exported files' => {
message => q{Deleting exported files},
lastUpdated => 0,
context => q{},
},
'Deleting keywords' => {
message => q{Deleting keywords},
lastUpdated => 0,
context => q{},
},
'Clearing search index' => {
message => q{Clearing search index},
lastUpdated => 0,
context => q{},
},
'Clearing cache' => {
message => q{Clearing cache},
lastUpdated => 0,
context => q{},
},
'Clearing asset tables' => {
message => q{Clearing asset tables},
lastUpdated => 0,
context => q{},
},
};
1;

View file

@ -477,6 +477,12 @@ our $I18N = {
context => q{Explanation of Permission Denied message},
},
"Rolling back %s" => {
message => q{Rolling back %s},
lastUpdated => 0,
context => q{},
},
};
1;