From 77913e956bf494b6169abef0025c9be17d31e1b1 Mon Sep 17 00:00:00 2001 From: Kaleb Murphy Date: Tue, 21 Oct 2008 16:54:00 +0000 Subject: [PATCH] RFE 549 commits now check for spectre connectivity before commiting and a new macro for showing spectre status. --- docs/changelog/7.x.x.txt | 1 + etc/WebGUI.conf.original | 1 + lib/WebGUI/Macro/SpectreCheck.pm | 15 ++++++++------- lib/WebGUI/Operation/Spectre.pm | 14 ++++++++++++++ lib/WebGUI/Operation/VersionTag.pm | 7 +++++++ lib/WebGUI/VersionTag.pm | 3 +++ lib/WebGUI/i18n/English/Macro_SpectreCheck.pm | 10 ++++++++-- 7 files changed, 42 insertions(+), 9 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 2ff550edc..723c0285b 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -14,6 +14,7 @@ - added: ldaps and ldapi are now supported when working with LDAP authentication - rfe #740: Thingy Pre-Text (SDH Consulting Group) - rfe #746: use the menu title in asset manager + - rfe #549: New macro for checking spectre status. VersionTag::RequestCommit and Operation::VestionTag::www_commitVertionTag now both check for spectre status before trying to commit. 7.6.1 - changed: the list of extensions for the export system to pass through unmodified has been moved to the configuration file under the diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 33ad5c905..e959452a0 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -688,6 +688,7 @@ "RootTitle" : "RootTitle", "r" : "r_printable", "Spacer" : "Spacer", + "SpectreCheck" : "SpectreCheck", "Thumbnail" : "Thumbnail", "User" : "User", "u" : "u_companyUrl", diff --git a/lib/WebGUI/Macro/SpectreCheck.pm b/lib/WebGUI/Macro/SpectreCheck.pm index 379593eaf..b3a97a4ed 100644 --- a/lib/WebGUI/Macro/SpectreCheck.pm +++ b/lib/WebGUI/Macro/SpectreCheck.pm @@ -16,15 +16,14 @@ use WebGUI::International; =head1 NAME -Package WebGUI::Macro::SessionId +Package WebGUI::Macro:SpectreCheck: =head1 DESCRIPTION -A macro to return the ID of the user's current session. +A macro to return the status of Spectre. =head2 process( ) -Really just a wrapper around $session->getId; =cut @@ -32,13 +31,15 @@ Really just a wrapper around $session->getId; #------------------------------------------------------------------- sub process { my $session = shift; - my $remote = WebGUI::Operation::Spectre::getASpectre($session); + my $status = WebGUI::Operation::Spectre::spectreTest($session); my $i18n = WebGUI::International->new($session, "Macro_SpectreCheck"); - if (defined $remote) { - return $i18n->get('spectre ok'); + if (defined $status) { + return $i18n->get('success') if($status eq 'success'); + return $i18n->get('subnet') if($status eq 'subnet'); + return $i18n->get('spectre') if($status eq 'spectre'); } else { - return $i18n->get('spectre is down'); + return $i18n->get('spectre'); } } diff --git a/lib/WebGUI/Operation/Spectre.pm b/lib/WebGUI/Operation/Spectre.pm index ec1a5cca2..5a35b789f 100644 --- a/lib/WebGUI/Operation/Spectre.pm +++ b/lib/WebGUI/Operation/Spectre.pm @@ -172,7 +172,21 @@ sub www_spectreTest { my $session = shift; $session->http->setMimeType("text/plain"); $session->http->setCacheControl("none"); + return WebGUI::Operation::Spectre::spectreTest($session); +} + +#------------------------------------------------------------------- + +=head2 spectreTest ( ) + +Spectre executes this function to see if WebGUI connectivity is working. + +=cut + +sub spectreTest{ + my $session = shift; my $subnets = $session->config->get("spectreSubnets"); + if (!defined $subnets) { $subnets = []; } diff --git a/lib/WebGUI/Operation/VersionTag.pm b/lib/WebGUI/Operation/VersionTag.pm index 06e41bfb0..125e22f80 100644 --- a/lib/WebGUI/Operation/VersionTag.pm +++ b/lib/WebGUI/Operation/VersionTag.pm @@ -307,6 +307,13 @@ sub www_commitVersionTag { my $session = shift; my $tagId = $session->form->param("tagId"); + my $spectreTest = WebGUI::Operation::Spectre::spectreTest($session); + if($spectreTest ne "success"){ + my $i18n = WebGUI::International->new($session, "Macro_SpectreCheck")->get($spectreTest); + my $ac = WebGUI::AdminConsole->new($session,"versions"); + return $ac->render( $i18n ); + } + if ( !$tagId ) { return www_manageVersions( $session ); } diff --git a/lib/WebGUI/VersionTag.pm b/lib/WebGUI/VersionTag.pm index 4b515d912..11ea69681 100644 --- a/lib/WebGUI/VersionTag.pm +++ b/lib/WebGUI/VersionTag.pm @@ -407,6 +407,9 @@ fails. sub requestCommit { my $self = shift; + + return "Failure" if(WebGUI::Operation::Spectre::spectreTest($self->session) ne "success"); + $self->lock; my $instance = WebGUI::Workflow::Instance->create($self->session, { workflowId=>$self->get("workflowId"), diff --git a/lib/WebGUI/i18n/English/Macro_SpectreCheck.pm b/lib/WebGUI/i18n/English/Macro_SpectreCheck.pm index f9706c5d4..f1b0319e2 100644 --- a/lib/WebGUI/i18n/English/Macro_SpectreCheck.pm +++ b/lib/WebGUI/i18n/English/Macro_SpectreCheck.pm @@ -3,13 +3,19 @@ package WebGUI::i18n::English::Macro_SpectreCheck; use strict; our $I18N = { - 'spectre ok' => { + 'spectre' => { message => q|Spectre is OK|, lastUpdated => 1202771219, context => q|Message saying that Spectre is doing okay.| }, - 'spectre is down' => { + 'subnet' => { + message => q|There is a problem with Spectre's subnet setting.|, + lastUpdated => 1202771219, + context => q|Message saying that Spectre has a problem with its subnet setting.| + }, + + 'spectre' => { message => q|Spectre is down|, lastUpdated => 1202771224, context => q|Message saying that Spectre is unable to be contacted.|