From a3b95090905346d051f57c17bc51ace18feb502e Mon Sep 17 00:00:00 2001 From: JT Smith Date: Mon, 15 May 2006 00:23:54 +0000 Subject: [PATCH] bug fixes to make webgui work with the wre demo system --- docs/changelog/6.x.x.txt | 3 ++- lib/Spectre/Admin.pm | 2 +- lib/Spectre/Cron.pm | 6 ++++-- lib/Spectre/Workflow.pm | 5 +++-- lib/WebGUI.pm | 3 ++- lib/WebGUI/Workflow/Cron.pm | 1 + lib/WebGUI/Workflow/Instance.pm | 2 +- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 01edb7eb5..bfea6da72 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,5 +1,6 @@ 6.99.1 - + - Bugfixes on dashboard to fix template errors. + - Bug fixes to make WebGUI work with the WRE demo system. 6.99.0 - Added a workflow system. diff --git a/lib/Spectre/Admin.pm b/lib/Spectre/Admin.pm index d4c5ca247..2fb4f7500 100644 --- a/lib/Spectre/Admin.pm +++ b/lib/Spectre/Admin.pm @@ -187,7 +187,7 @@ sub runTests { my $userAgent = new LWP::UserAgent; $userAgent->agent("Spectre"); $userAgent->timeout(30); - my $url = "http://".$configs->{$config}->get("sitename")->[0].":".$self->config->get("webguiPort")."/?op=spectreTest"; + my $url = "http://".$configs->{$config}->get("sitename")->[0].":".$self->config->get("webguiPort").$configs->{$config}->get("gateway")."?op=spectreTest"; my $request = new HTTP::Request (GET => $url); my $response = $userAgent->request($request); if ($response->is_error) { diff --git a/lib/Spectre/Cron.pm b/lib/Spectre/Cron.pm index 408d160a3..d25c8f151 100644 --- a/lib/Spectre/Cron.pm +++ b/lib/Spectre/Cron.pm @@ -140,6 +140,7 @@ sub addJob { $self->{_jobs}{$params->{config}}{$params->{taskId}} = { taskId=>$params->{taskId}, config=>$params->{config}, + gateway=>$params->{gateway}, sitename=>$params->{sitename}, schedule=>join(" ", $params->{minuteOfHour}, $params->{hourOfDay}, $params->{dayOfMonth}, $params->{monthOfYear}, $params->{dayOfWeek}), runOnce=>$params->{runOnce}, @@ -311,6 +312,7 @@ sub loadSchedule { my $params = JSON::jsonToObj($data->{parameters}); $data->{parameters} = $params->{parameters}; $data->{config} = $config; + $data->{gateway} = $session->config->get("gateway"); $data->{sitename} = $session->config->get("sitename")->[0]; $kernel->yield("addJob", $data); } @@ -373,7 +375,7 @@ sub runJob { $self->error("Warning: A scheduled task has corrupt information and is nat able to be run. Skipping execution."); $kernel->yield("deleteJob",{config=>$job->{config}, taskId=>$job->{taskId}}) if ($job->{config} ne "" && $job->{taskId} ne ""); } else { - my $url = "http://".$job->{sitename}.':'.$self->config->get("webguiPort").'/'; + my $url = "http://".$job->{sitename}.':'.$self->config->get("webguiPort").$job->{gateway}; my $request = POST $url, [op=>"runCronJob", taskId=>$job->{taskId}]; my $cookie = $self->{_cookies}{$job->{sitename}}; $request->header("Cookie","wgSession=".$cookie) if (defined $cookie); @@ -395,7 +397,7 @@ This method is called when the response from the runJob() method is received. =cut sub runJobResponse { - my ($self, $kernel) = @_[OBJECT, KERNEL]; + my ($self, $kernel) = @_[OBJECT, KERNEL]; $self->debug("Retrieving response from scheduled job."); my ($request, $response, $entry) = @{$_[ARG1]}; my $taskId = $request->header("X-taskId"); # got to figure out how to get this from the request, cuz the response may die diff --git a/lib/Spectre/Workflow.pm b/lib/Spectre/Workflow.pm index e598e71f7..b6fd5d22f 100644 --- a/lib/Spectre/Workflow.pm +++ b/lib/Spectre/Workflow.pm @@ -87,6 +87,7 @@ sub addInstance { $self->{_instances}{$params->{instanceId}} = { sitename=>$params->{sitename}, instanceId=>$params->{instanceId}, + gateway => $params->{gateway}, status=>"waiting", priority=>$params->{priority} }; @@ -261,7 +262,7 @@ sub loadWorkflows { my $session = WebGUI::Session->open($config->getWebguiRoot, $config->getFilename); my $result = $session->db->read("select instanceId,priority from WorkflowInstance"); while (my ($id, $priority) = $result->array) { - $kernel->yield("addInstance", {sitename=>$config->get("sitename")->[0], instanceId=>$id, priority=>$priority}); + $kernel->yield("addInstance", {gateway=>$config->get("gateway"), sitename=>$config->get("sitename")->[0], instanceId=>$id, priority=>$priority}); } $session->close; } @@ -333,7 +334,7 @@ sub runWorker { my ($kernel, $self, $instance, $session) = @_[KERNEL, OBJECT, ARG0, SESSION]; $self->debug("Preparing to run workflow instance ".$instance->{instanceId}."."); POE::Component::Client::UserAgent->new; - my $url = "http://".$instance->{sitename}.':'.$self->config->get("webguiPort").'/'; + my $url = "http://".$instance->{sitename}.':'.$self->config->get("webguiPort").$instance->{gateway}; my $request = POST $url, [op=>"runWorkflow", instanceId=>$instance->{instanceId}]; my $cookie = $self->{_cookies}{$instance->{sitename}}; $request->header("Cookie","wgSession=".$cookie) if (defined $cookie); diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index 055b1c27c..a47b478e4 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -45,8 +45,9 @@ The Apache2::RequestRec object passed in by Apache's mod_perl. sub handler { my $r = shift; + my $configFile = shift || $r->dir_config('WebguiConfig'); my $s = Apache2::ServerUtil->server; - my $config = WebGUI::Config->new($s->dir_config('WebguiRoot'),$r->dir_config('WebguiConfig')); + my $config = WebGUI::Config->new($s->dir_config('WebguiRoot'), $configFile); $r->push_handlers(PerlFixupHandler => \&fixupHandler) if (defined $config->get("passthruUrls")); foreach my $url ($config->get("extrasURL"), @{$config->get("passthruUrls")}) { return Apache2::Const::DECLINED if ($r->uri =~ m/^$url/); diff --git a/lib/WebGUI/Workflow/Cron.pm b/lib/WebGUI/Workflow/Cron.pm index bb3448e1b..2755e2929 100644 --- a/lib/WebGUI/Workflow/Cron.pm +++ b/lib/WebGUI/Workflow/Cron.pm @@ -288,6 +288,7 @@ sub set { $params{parameters} = $self->get("parameters"); $params{config} = $self->session->config->getFilename; $params{sitename} = $self->session->config->get("sitename")->[0]; + $params{gateway} = $self->session->config->get("gateway"); $spectre->notify("cron/addJob", \%params); } diff --git a/lib/WebGUI/Workflow/Instance.pm b/lib/WebGUI/Workflow/Instance.pm index d70dbea2f..374d9bf58 100644 --- a/lib/WebGUI/Workflow/Instance.pm +++ b/lib/WebGUI/Workflow/Instance.pm @@ -374,7 +374,7 @@ sub set { if ($properties->{notifySpectre}) { my $spectre = WebGUI::Workflow::Spectre->new($self->session); $spectre->notify("workflow/deleteInstance",$self->getId); - $spectre->notify("workflow/addInstance", {sitename=>$self->session->config->get("sitename")->[0], instanceId=>$self->getId, priority=>$self->{_data}{priority}}); + $spectre->notify("workflow/addInstance", {gateway=>$self->session->config->get("gateway"), sitename=>$self->session->config->get("sitename")->[0], instanceId=>$self->getId, priority=>$self->{_data}{priority}}); } }