diff --git a/docs/gotcha.txt b/docs/gotcha.txt index a2e013337..73ed0b0fc 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -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 diff --git a/lib/Spectre/Workflow.pm b/lib/Spectre/Workflow.pm index 64660d7ff..ebc82c2eb 100644 --- a/lib/Spectre/Workflow.pm +++ b/lib/Spectre/Workflow.pm @@ -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); diff --git a/lib/WebGUI/Operation.pm b/lib/WebGUI/Operation.pm index e03b4230b..108aaf5c6 100644 --- a/lib/WebGUI/Operation.pm +++ b/lib/WebGUI/Operation.pm @@ -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', diff --git a/lib/WebGUI/Operation/Spectre.pm b/lib/WebGUI/Operation/Spectre.pm deleted file mode 100644 index 4d573a82c..000000000 --- a/lib/WebGUI/Operation/Spectre.pm +++ /dev/null @@ -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; diff --git a/lib/WebGUI/Operation/VersionTag.pm b/lib/WebGUI/Operation/VersionTag.pm index 3c1a753ac..d4717e21f 100644 --- a/lib/WebGUI/Operation/VersionTag.pm +++ b/lib/WebGUI/Operation/VersionTag.pm @@ -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( diff --git a/lib/WebGUI/Operation/Workflow.pm b/lib/WebGUI/Operation/Workflow.pm index ef87d082c..7a5d62416 100644 --- a/lib/WebGUI/Operation/Workflow.pm +++ b/lib/WebGUI/Operation/Workflow.pm @@ -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; diff --git a/lib/WebGUI/VersionTag.pm b/lib/WebGUI/VersionTag.pm index 5fcc33acb..37aa01cab 100644 --- a/lib/WebGUI/VersionTag.pm +++ b/lib/WebGUI/VersionTag.pm @@ -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", diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index 2101d445c..45dc17cd6 100644 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -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);