]> git.mxchange.org Git - hub.git/commitdiff
Added 'base' classes for answer-status handlers
authorRoland Häder <roland@mxchange.org>
Tue, 7 Aug 2012 20:38:39 +0000 (20:38 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 7 Aug 2012 20:38:39 +0000 (20:38 +0000)
.gitattributes
application/hub/config.php
application/hub/main/handler/answer-status/.htaccess [new file with mode: 0644]
application/hub/main/handler/answer-status/announcement/.htaccess [new file with mode: 0644]
application/hub/main/handler/answer-status/class_ [new file with mode: 0644]
application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php [new file with mode: 0644]
application/hub/main/nodes/class_BaseHubNode.php

index a9033d5e440f69801da9d85ff3da3936ed3b8393..da449391ac518313c4dd5c34147681fb36aa1f9d 100644 (file)
@@ -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
index 9422ef935514ab828905c7d189c441bd0d500c63..5df512833e9e4b6e72b4463f9dd0f6f2534467d5 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..ae82444
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * A ??? handler
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..4c1a6ef
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * A general answer-status handler. So called "answer-status handler" are
+ * classes which handles a message field 'answer-status' which is, alongside
+ * many other node-relevant data, the main part of the answer message. These
+ * answer messages, by the way, are never sent unrequested. This, however,
+ * sounds logical because the answer is a reply from a node that has responded
+ * on a message.
+ *
+ * The answer-status field gives information back to the requesting node if the
+ * receiving node could handle the message properly (all verfication steps are
+ * passed, message type was understood, correct receiver, et cetera) and how
+ * it handles it. Some messages may be rejected, e.g. when the requesting node
+ * is blacklisted or its behavour has changed.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index 2eae02a2b7d3caa5731824439311909781ae0231..3a2be5ce3366e64acba669cff1d7b0713d62c3f0 100644 (file)
@@ -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);
        }
 }