Merge branch 'fork'
This commit is contained in:
commit
7219e21f86
28 changed files with 2399 additions and 251 deletions
74
lib/WebGUI/Operation/Fork.pm
Normal file
74
lib/WebGUI/Operation/Fork.pm
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
package WebGUI::Operation::Fork;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use WebGUI::Fork;
|
||||
use WebGUI::Pluggable;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WebGUI::Operation::Fork
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
URL dispatching for WebGUI::Fork monitoring
|
||||
|
||||
=head1 SUBROUTINES
|
||||
|
||||
These subroutines are available from this package:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_fork ( session )
|
||||
|
||||
Dispatches to the proper module based on the module form parameter if op is
|
||||
fork. Returns insufficient privilege page if the user doesn't pass canView on
|
||||
the process before dispatching.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_fork {
|
||||
my $session = shift;
|
||||
my $form = $session->form;
|
||||
my $module = $form->get('module') || 'Status';
|
||||
my $pid = $form->get('pid') || return undef;
|
||||
|
||||
my $process = WebGUI::Fork->new( $session, $pid );
|
||||
|
||||
return $session->privilege->insufficient unless $process->canView;
|
||||
|
||||
my $log = $session->log;
|
||||
|
||||
unless ($process) {
|
||||
$log->error("Tried to get info for nonexistent process $pid");
|
||||
return undef;
|
||||
}
|
||||
|
||||
my $output = eval { WebGUI::Pluggable::run( "WebGUI::Fork::$module", 'handler', [$process] ); };
|
||||
|
||||
if ($@) {
|
||||
$log->error($@);
|
||||
return undef;
|
||||
}
|
||||
|
||||
return $output;
|
||||
} ## end sub www_fork
|
||||
|
||||
1;
|
||||
|
|
@ -21,6 +21,9 @@ use WebGUI::International;
|
|||
use WebGUI::VersionTag;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Fork;
|
||||
use Monkey::Patch;
|
||||
use JSON;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -137,6 +140,50 @@ sub getVersionTagOptions {
|
|||
return %tag;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 rollbackInFork ($process, $tagId)
|
||||
|
||||
WebGUI::Fork method called by www_rollbackVersionTag
|
||||
|
||||
=cut
|
||||
|
||||
sub rollbackInFork {
|
||||
my ( $process, $tagId ) = @_;
|
||||
my $session = $process->session;
|
||||
my $tag = WebGUI::VersionTag->new( $session, $tagId );
|
||||
my %status = (
|
||||
finished => 0,
|
||||
total => $process->session->db->quickScalar( 'SELECT count(*) FROM assetData WHERE tagId = ?', [$tagId] ),
|
||||
message => '',
|
||||
);
|
||||
my $update = sub {
|
||||
$process->update( sub { JSON::encode_json( \%status ) } );
|
||||
};
|
||||
my $patch = Monkey::Patch::patch_class(
|
||||
'WebGUI::Asset',
|
||||
'purgeRevision',
|
||||
sub {
|
||||
my $purgeRevision = shift;
|
||||
my $self = shift;
|
||||
$self->$purgeRevision(@_);
|
||||
$status{finished}++;
|
||||
$update->();
|
||||
}
|
||||
);
|
||||
$tag->rollback( {
|
||||
outputSub => sub {
|
||||
$status{message} = shift;
|
||||
$update->();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
# need to get at least one of these in for the degenerate case of no
|
||||
# revisions in tag
|
||||
$update->();
|
||||
} ## end sub rollbackInFork
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_approveVersionTag ( session )
|
||||
|
|
@ -853,16 +900,27 @@ 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({ outputSub => sub { $pb->update(@_) }, }) if defined $tag;
|
||||
}
|
||||
|
||||
my $process = WebGUI::Fork->start(
|
||||
$session, 'WebGUI::Operation::VersionTag', 'rollbackInFork', $tagId
|
||||
);
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'VersionTag');
|
||||
my $method = $session->form->process("proceed");
|
||||
$method = $method eq "manageCommittedVersions" ? $method : 'manageVersions';
|
||||
$pb->finish(WebGUI::Asset->getDefault($session)->getUrl('op='.$method));
|
||||
my $redir = WebGUI::Asset->getDefault($session)->getUrl("op=$method");
|
||||
$session->http->setRedirect(
|
||||
$session->url->page(
|
||||
$process->contentPairs(
|
||||
'ProgressBar', {
|
||||
icon => 'versions',
|
||||
title => $i18n->get('rollback version tag'),
|
||||
proceed => $redir,
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
return 'redirect';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue