]> git.mxchange.org Git - hub.git/commitdiff
Added missing but not yet fully implemented class
authorRoland Häder <roland@mxchange.org>
Wed, 30 Jan 2013 22:37:04 +0000 (22:37 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 30 Jan 2013 22:37:04 +0000 (22:37 +0000)
.gitattributes
application/hub/config.php
application/hub/main/handler/answer-status/requests/.htaccess [new file with mode: 0644]
application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php [new file with mode: 0644]
application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php

index 2f0b2e8b5a9ddd6982799c9828da922f1acea97e..bfed6fb7b8faffcf7ffe3c21f2b4b64c3aee4842 100644 (file)
@@ -356,6 +356,8 @@ application/hub/main/handler/answer-status/announcement/.htaccess -text svneol=u
 application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php svneol=native#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/answer-status/requests/.htaccess -text svneol=unset#text/plain
+application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.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 7a81eaf1fca0c1df68d1c6b70f10c955b0529576..a49c07018139a2d9df57db583805f6adc891cc57 100644 (file)
@@ -748,6 +748,9 @@ $cfg->setConfigEntry('peer_no_route_to_host_state_class', 'NoRouteToHostPeerStat
 // CFG: ANNOUNCEMENT-ANSWER-STATUS-OKAY-HANDLER-CLASS
 $cfg->setConfigEntry('announcement_answer_status_okay_handler_class', 'AnnouncementAnswerOkayHandler');
 
+// CFG: REQUEST-NODE-LIST-ANSWER-STATUS-OKAY-HANDLER-CLASS
+$cfg->setConfigEntry('request_node_list_answer_status_okay_handler_class', 'RequestNodeListAnswerOkayHandler');
+
 ///////////////////////////////////////////////////////////////////////////////
 //                        Cruncher configuration
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/application/hub/main/handler/answer-status/requests/.htaccess b/application/hub/main/handler/answer-status/requests/.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/requests/class_RequestNodeListAnswerOkayHandler.php b/application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php
new file mode 100644 (file)
index 0000000..0d4fd9b
--- /dev/null
@@ -0,0 +1,124 @@
+<?php
+/**
+ * A RequestNodeListAnswerOkay 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 RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('request_node_list_answer_okay');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createRequestNodeListAnswerOkayHandler () {
+               // Get new instance
+               $handlerInstance = new RequestNodeListAnswerOkayHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles given message data array
+        *
+        * @param       $messageData            An array of message data
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        * @throws      NodeSessionIdVerficationException       If the provided session id is not matching
+        * @todo        Do some more here: Handle karma, et cetera?
+        */
+       public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) {
+               // Get a database wrapper instance
+               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_list_db_wrapper_class');
+
+               // Get also a search criteria instance
+               $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+               // Lookup external session id/external IP/port
+               $searchInstance->addCriteria('node_session_id' , $messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID]);
+
+               // Only one entry is fine
+               $searchInstance->setLimit(1);
+
+               // Run the query
+               $resultInstance = $wrapperInstance->doSelectByCriteria($searchInstance);
+
+               // Is there an try?
+               if (!$resultInstance->next()) {
+                       // This is fatal, caused by "stolen" session id and/or not matching IP number/port combination
+                       throw new NodeSessionIdVerficationException(array($this, $messageData), BaseHubSystem::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING);
+               } // END - if
+
+               // Get the node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Change state
+               $nodeInstance->getStateInstance()->nodeRequestNodeListSuccessful();
+
+               // Prepare next message ("hello" message to all returned nodes)
+               $this->prepareNextMessage($messageData, $packageInstance);
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * The following array is being handled over:
+        *
+        *   session-id    => aaabbbcccdddeeefff123456789
+        *   node-list     => aabb:ccdd:eeff
+        *   answer-status => OKAY
+        *   message_type  => request_node_list_answer
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @todo        0% done
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration. For content of $messageData see method comment above.
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @todo        0% done
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
index 75a4880b2e19626fc201707d319738b9ad45fd82..87939508dcfb0974189561716ee1460af4b594b1 100644 (file)
@@ -60,7 +60,7 @@ class NodeRequestNodeListHelper extends BaseHubHelper implements HelpableHub {
         */
        public function loadDescriptorXml (NodeHelper $nodeInstance) {
                // Debug message
-               self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to request node list...');
+               self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to request: node-list...');
 
                // Get a XML template instance
                $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_template_class');