From 9c0fdb85ab002a371b303e3e0c4dfecb7ef70662 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 7 Aug 2012 20:38:39 +0000 Subject: [PATCH] Added 'base' classes for answer-status handlers --- .gitattributes | 4 ++ application/hub/config.php | 7 +++ .../hub/main/handler/answer-status/.htaccess | 1 + .../answer-status/announcement/.htaccess | 1 + .../hub/main/handler/answer-status/class_ | 53 ++++++++++++++++ .../class_BaseAnserStatusHandler.php | 63 +++++++++++++++++++ .../hub/main/nodes/class_BaseHubNode.php | 10 ++- 7 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 application/hub/main/handler/answer-status/.htaccess create mode 100644 application/hub/main/handler/answer-status/announcement/.htaccess create mode 100644 application/hub/main/handler/answer-status/class_ create mode 100644 application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php diff --git a/.gitattributes b/.gitattributes index a9033d5e4..da449391a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -300,6 +300,10 @@ application/hub/main/filter/task/cruncher/class_CruncherTaskHandlerInitializerFi application/hub/main/filter/task/node/.htaccess svneol=native#text/plain application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php svneol=native#text/plain application/hub/main/handler/.htaccess -text svneol=unset#text/plain +application/hub/main/handler/answer-status/.htaccess -text svneol=unset#text/plain +application/hub/main/handler/answer-status/announcement/.htaccess -text svneol=unset#text/plain +application/hub/main/handler/answer-status/class_ svneol=native#text/plain +application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php svneol=native#text/plain application/hub/main/handler/chunks/.htaccess -text svneol=unset#text/plain application/hub/main/handler/chunks/class_ChunkHandler.php svneol=native#text/plain application/hub/main/handler/class_ svneol=native#text/plain diff --git a/application/hub/config.php b/application/hub/config.php index 9422ef935..5df512833 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -684,6 +684,13 @@ $cfg->setConfigEntry('peer_operation_already_progress_state_class', 'OperationAl // CFG: PEER-NO-ROUTE-TO-HOST-STATE-CLASS $cfg->setConfigEntry('peer_no_route_to_host_state_class', 'NoRouteToHostPeerState'); +/////////////////////////////////////////////////////////////////////////////// +// Message answer-status handler +/////////////////////////////////////////////////////////////////////////////// + +// CFG: ANNOUNCEMENT-ANSWER-STATUS-OKAY-HANDLER-CLASS +$cfg->setConfigEntry('announcement_answer_status_okay_handler_class', 'AnnouncementAnswerOkayHandler'); + /////////////////////////////////////////////////////////////////////////////// // Cruncher configuration /////////////////////////////////////////////////////////////////////////////// diff --git a/application/hub/main/handler/answer-status/.htaccess b/application/hub/main/handler/answer-status/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/handler/answer-status/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/handler/answer-status/announcement/.htaccess b/application/hub/main/handler/answer-status/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/handler/answer-status/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/handler/answer-status/class_ b/application/hub/main/handler/answer-status/class_ new file mode 100644 index 000000000..ae8244434 --- /dev/null +++ b/application/hub/main/handler/answer-status/class_ @@ -0,0 +1,53 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ???Handler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set handler name + $this->setHandlerName('answer_==='); + } + + /** + * Creates an instance of this class + * + * @return $handlerInstance An instance of a HandleableMessage class + */ + public final static function create???Handler () { + // Get new instance + $handlerInstance = new ???Handler(); + + // Return the prepared instance + return $handlerInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php b/application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php new file mode 100644 index 000000000..4c1a6efb5 --- /dev/null +++ b/application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php @@ -0,0 +1,63 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseAnserStatusHandler extends BaseHandler { + /** + * Last exception instance from database layer or NULL (default) + */ + private $lastException = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Getter for last exception + * + * @return $lastException Last thrown exception + */ + protected final function getLastException () { + return $this->lastException; + } +} + +// [EOF] +?> diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 2eae02a2b..3a2be5ce3 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -767,9 +767,17 @@ class BaseHubNode extends BaseHubSystem implements Updateable { * * @param $messageData A valid answer message data array * @return void + * @todo Handle thrown exception */ public function handleAnswerStatusByMessageData (array $messageData) { - exit('messageData=' . print_r($messageData, true)); + // Construct configuration entry for handling class' name + $classConfigEntry = strtolower($messageData[NetworkPackage::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_ANSWER_STATUS]) . '_handler_class'; + + // Try to get a class + $handlerInstance = ObjectFactory::createObjectByConfiguredName($classConfigEntry); + + // Handle it there + $handlerInstance->handleAnswerMessageData($messageData); } } -- 2.39.5