From e10aa2b808ead315a4b8924f7b2ec2cc349ff414 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 17 May 2012 13:42:21 +0000 Subject: [PATCH] While self-connect is running, it might be already announced which is fine --- .../hub/connection/class_HubSelfConnectHelper.php | 2 +- .../hub/main/states/node/class_BaseNodeState.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php b/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php index 6e999537a..1f210fba2 100644 --- a/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php +++ b/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php @@ -84,7 +84,7 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub { */ public function sendPackage (NodeHelper $nodeInstance) { // Sanity check: Is the node in the approx. state? (active) - $nodeInstance->getStateInstance()->validateNodeStateIsActive(); + $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrAnnounced(); // Compile the template, this inserts the loaded node data into the gaps. $this->getTemplateInstance()->compileTemplate(); diff --git a/application/hub/main/states/node/class_BaseNodeState.php b/application/hub/main/states/node/class_BaseNodeState.php index 99ee452b7..d7a1bf962 100644 --- a/application/hub/main/states/node/class_BaseNodeState.php +++ b/application/hub/main/states/node/class_BaseNodeState.php @@ -47,6 +47,21 @@ class BaseNodeState extends BaseState { throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE); } // END - if } + + /** + * Validates whether the state is 'active' or 'announced' or throws an + * exception if it is every other state. + * + * @return void + * @throws InvalidStateException If the state is not 'active' + */ + public function validateNodeStateIsActiveOrAnnounced () { + // Just compare it... + if ((!$this instanceof NodeActiveState) && (!$this instanceof NodeAnnouncedState) { + // Throw the exception + throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE); + } // END - if + } } // [EOF] -- 2.39.2