From: Roland Häder Date: Thu, 17 May 2012 13:42:21 +0000 (+0000) Subject: While self-connect is running, it might be already announced which is fine X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e10aa2b808ead315a4b8924f7b2ec2cc349ff414;p=hub.git While self-connect is running, it might be already announced which is fine --- 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]