mostly working workflow
This commit is contained in:
parent
46c8e25e3a
commit
11cc18a5c3
8 changed files with 31 additions and 66 deletions
|
|
@ -39,7 +39,6 @@ save you many hours of grief.
|
|||
POE
|
||||
POE::Component::IKC::Server
|
||||
POE::Component::Client::UserAgent
|
||||
Crypt::Blowfish
|
||||
Net::Subnets
|
||||
|
||||
* The upgrade script is going to convert your WebGUI config files
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ package Spectre::Workflow;
|
|||
=cut
|
||||
|
||||
use strict;
|
||||
use Crypt::Blowfish;
|
||||
use JSON;
|
||||
use HTTP::Request::Common;
|
||||
use POE;
|
||||
use POE::Component::Client::UserAgent;
|
||||
|
||||
|
|
@ -76,7 +75,7 @@ A hash reference containing a row of data from the WorkflowInstance table.
|
|||
|
||||
sub addJob {
|
||||
my ($self, $config, $job) = @_[OBJECT, ARG0, ARG1];
|
||||
$self->debug->("Adding workflow instance ".$job->{instanceId}." from ".$config." to job queue at priority ".$job->{priority}.".");
|
||||
$self->debug("Adding workflow instance ".$job->{instanceId}." from ".$config." to job queue at priority ".$job->{priority}.".");
|
||||
# job list
|
||||
$self->{_jobs}{$job->{instanceId}} = {
|
||||
instanceId=>$job->{instanceId},
|
||||
|
|
@ -262,12 +261,7 @@ sub runWorker {
|
|||
my $url = $job->{sitename}.'/'.$job->{gateway};
|
||||
$url =~ s/\/\//\//g;
|
||||
$url = "http://".$url."?op=spectre;instanceId=".$job->{instanceId};
|
||||
my $payload = {
|
||||
'do'=>'runWorkflow',
|
||||
instanceId=>$job->{instanceId},
|
||||
};
|
||||
my $cipher = Crypt::Blowfish->new($self->config->get("cryptoKey"));
|
||||
my $request = HTTP::Request->new(POST => $url, Content => { op=>"spectre", payload=>$cipher->encrypt(objToJson($payload)) });
|
||||
my $request = POST $url, [op=>"runWorkflow", instanceId=>$job->{instanceId}];
|
||||
my $cookie = $self->{_cookies}{$job->{sitename}};
|
||||
$request->header("Cookie","wgSession=".$cookie) if (defined $cookie);
|
||||
$request->header("User-Agent","Spectre");
|
||||
|
|
@ -324,9 +318,7 @@ sub workerResponse {
|
|||
$cookie =~ s/wgSession=([a-zA-Z0-9\_\-]{22})/$1/;
|
||||
$self->{_cookies}{$self->{_jobs}{$jobId}{sitename}} = $cookie;
|
||||
}
|
||||
my $cipher = Crypt::Blowfish->new($self->config->get("cryptoKey"));
|
||||
my $payload = jsonToObj($cipher->decrypt($response->content));
|
||||
my $state = $payload->{state};
|
||||
my $state = $response->content;
|
||||
if ($state eq "waiting") {
|
||||
$self->debug("Was told to wait on $jobId because we're still waiting on some external event.");
|
||||
$self->suspendJob($jobId);
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ sub getOperations {
|
|||
'setWorkingVersionTag' => 'WebGUI::Operation::VersionTag',
|
||||
'addWorkflow' => 'WebGUI::Operation::Workflow',
|
||||
'deleteWorkflow' => 'WebGUI::Operation::Workflow',
|
||||
'runWorkflow' => 'WebGUI::Operation::Workflow',
|
||||
'editWorkflowActivity' => 'WebGUI::Operation::Workflow',
|
||||
'editWorkflowActivitySave' => 'WebGUI::Operation::Workflow',
|
||||
'deleteWorkflowActivity' => 'WebGUI::Operation::Workflow',
|
||||
|
|
@ -99,7 +100,6 @@ sub getOperations {
|
|||
'editCronJob' => 'WebGUI::Operation::Cron',
|
||||
'editCronJobSave' => 'WebGUI::Operation::Cron',
|
||||
'deleteCronJob' => 'WebGUI::Operation::Cron',
|
||||
'spectre' => 'WebGUI::Operation::Spectre',
|
||||
'adminConsole' => 'WebGUI::Operation::Admin',
|
||||
'switchOffAdmin' => 'WebGUI::Operation::Admin',
|
||||
'switchOnAdmin' => 'WebGUI::Operation::Admin',
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
package WebGUI::Operation::Spectre;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use Crypt::Blowfish;
|
||||
use JSON;
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Operation::Spectre
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Operation handler for Spectre functions.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_spectre ( )
|
||||
|
||||
Checks to ensure the requestor is who we think it is, and then executes a spectre function, and returns a data packet.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_spectre {
|
||||
my $session = shift;
|
||||
return $session->privilege->insufficient unless (isInSubnet($session->env->get("REMOTE_ADDR"), $session->config->get("spectreSubnets")));
|
||||
my $cipher = Crypt::Blowfish->new($session->config->get("spectreCryptoKey"));
|
||||
my $payload = jsonToObj($cipher->decrypt($session->form->get("payload")));
|
||||
my $out = {};
|
||||
if ($payload->{do} eq "runWorkflow") {
|
||||
# do workflow stuff
|
||||
}
|
||||
return $cipher->encrypt(objToJson($out));
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
@ -208,6 +208,7 @@ sub www_commitVersionTagConfirm {
|
|||
if (defined $tag && $session->user->isInGroup($tag->get("groupToUse"))) {
|
||||
$tag->set({comments=>$session->form->process("comments", "textarea")});
|
||||
$tag->commit;
|
||||
#$tag->requestCommit;
|
||||
my $i18n = WebGUI::International->new($session, "VersionTag");
|
||||
my $ac = WebGUI::AdminConsole->new($session,"versions");
|
||||
return $ac->render(
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ use WebGUI::HTMLForm;
|
|||
use WebGUI::International;
|
||||
use WebGUI::Workflow;
|
||||
use WebGUI::Workflow::Activity;
|
||||
use WebGUI::Workflow::Instance;
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -297,4 +299,26 @@ sub www_manageWorkflows {
|
|||
return $ac->render($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_runWorkflow ( )
|
||||
|
||||
Checks to ensure the requestor is who we think it is, and then executes a workflow and returns the results.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_runWorkflow {
|
||||
my $session = shift;
|
||||
$session->http->setMimeType("text/plain");
|
||||
return "error" unless (isInSubnet($session->env->get("REMOTE_ADDR"), $session->config->get("spectreSubnets")));
|
||||
my $instanceId = $session->form->param("instanceId");
|
||||
if ($instanceId) {
|
||||
my $instance = WebGUI::Workflow::Instance->new($session, $instanceId);
|
||||
if (defined $instance) {
|
||||
return $instance->run;
|
||||
}
|
||||
}
|
||||
return "error";
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ Locks the version tag and then kicks off the approval/commit workflow for it.
|
|||
sub requestCommit {
|
||||
my $self = shift;
|
||||
$self->lock;
|
||||
my $instance = WebGUI::Workflow::Instance->new($self->session, {
|
||||
my $instance = WebGUI::Workflow::Instance->create($self->session, {
|
||||
workflowId=>$self->get("workflowId"),
|
||||
className=>"WebGUI::VersionTag",
|
||||
method=>"new",
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ checkModule("Parse::PlainConfig",1.1);
|
|||
checkModule("XML::RSSLite",0.11);
|
||||
checkModule("JSON",0.991);
|
||||
checkModule("Net::Subnets",0.21);
|
||||
checkModule("Crypt::Blowfish",2.10);
|
||||
checkModule("Finance::Quote",1.08);
|
||||
checkModule("POE",0.3202);
|
||||
checkModule("POE::Component::IKC::Server",0.18);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue