]> git.mxchange.org Git - hub.git/commitdiff
Development of 'hub' project continued:
authorRoland Häder <roland@mxchange.org>
Sat, 18 Aug 2012 21:08:38 +0000 (21:08 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 18 Aug 2012 21:08:38 +0000 (21:08 +0000)
- Added helper for receiving node list
- Added XML for above helper (unfinished)
- Added template engine ("frontend class") for above XML
- Added more missing configuration entries

17 files changed:
.gitattributes
application/hub/config.php
application/hub/main/discovery/package/class_PackageRecipientDiscovery.php
application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php
application/hub/main/handler/answer-status/class_
application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php
application/hub/main/handler/class_BaseDataHandler.php [new file with mode: 0644]
application/hub/main/handler/message-types/class_BaseMessageHandler.php
application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php
application/hub/main/helper/hub/requests/.htaccess [new file with mode: 0644]
application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php [new file with mode: 0644]
application/hub/main/package/class_NetworkPackage.php
application/hub/main/template/class_
application/hub/main/template/requests/.htaccess [new file with mode: 0644]
application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php [new file with mode: 0644]
application/hub/templates/xml/requests/.htaccess [new file with mode: 0644]
application/hub/templates/xml/requests/node_request_node_list.xml [new file with mode: 0644]

index ad47d6d8dbfcca36f9ad7ef9eaaa530da69dfe83..fbcdc8f469207275085a518470fd2e2031eb72c9 100644 (file)
@@ -313,6 +313,7 @@ application/hub/main/handler/answer-status/class_BaseAnserStatusHandler.php svne
 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
+application/hub/main/handler/class_BaseDataHandler.php svneol=native#text/plain
 application/hub/main/handler/class_BaseHandler.php svneol=native#text/plain
 application/hub/main/handler/message-types/.htaccess -text svneol=unset#text/plain
 application/hub/main/handler/message-types/anouncement/.htaccess -text svneol=unset#text/plain
@@ -353,6 +354,8 @@ application/hub/main/helper/hub/class_ svneol=native#text/plain
 application/hub/main/helper/hub/class_BaseHubHelper.php svneol=native#text/plain
 application/hub/main/helper/hub/connection/.htaccess -text svneol=unset#text/plain
 application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php svneol=native#text/plain
+application/hub/main/helper/hub/requests/.htaccess -text svneol=unset#text/plain
+application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php svneol=native#text/plain
 application/hub/main/helper/messages/.htaccess svneol=native#text/plain
 application/hub/main/helper/messages/class_BaseMessageHelper.php svneol=native#text/plain
 application/hub/main/helper/messages/crypto/.htaccess svneol=native#text/plain
@@ -578,6 +581,7 @@ application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php
 application/hub/main/template/producer/.htaccess svneol=native#text/plain
 application/hub/main/template/producer/test_units/.htaccess svneol=native#text/plain
 application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php svneol=native#text/plain
+application/hub/main/template/requests/.htaccess -text svneol=unset#text/plain
 application/hub/main/template/work_units/.htaccess svneol=native#text/plain
 application/hub/main/tools/.htaccess -text svneol=unset#text/plain
 application/hub/main/tools/class_HubTools.php svneol=native#text/plain
@@ -613,6 +617,8 @@ application/hub/templates/xml/node/.htaccess -text svneol=unset#text/plain
 application/hub/templates/xml/node/node_status.xml svneol=native#text/plain
 application/hub/templates/xml/object_registry/.htaccess -text svneol=unset#text/plain
 application/hub/templates/xml/object_registry/object_registry.xml svneol=native#text/plain
+application/hub/templates/xml/requests/.htaccess -text svneol=unset#text/plain
+application/hub/templates/xml/requests/node_request_node_list.xml svneol=native#text/plain
 application/hub/templates/xml/self_connect/.htaccess -text svneol=unset#text/plain
 application/hub/templates/xml/self_connect/self_connect.xml svneol=native#text/plain
 db/.htaccess -text svneol=unset#text/plain
index 35215b2650fe0d7aa4855b34fbbff70c86b8dd39..169e8ff82e30e33a0a58646e2a8f3274db38f80f 100644 (file)
@@ -222,6 +222,9 @@ $cfg->setConfigEntry('message_type_self_connect_handler_class', 'NodeMessageSelf
 // CFG: NODE-ANSWER-MESSAGE-ANNOUNCEMENT-HELPER-CLASS
 $cfg->setConfigEntry('node_answer_message_announcement_helper_class', 'NodeAnnouncementMessageAnswerHelper');
 
+// CFG: NODE-NEXT-ANNOUNCEMENT-ANSWER-OKAY-HELPER-CLASS
+$cfg->setConfigEntry('node_next_announcement_answer_okay_helper_class', 'NodeRequestNodeListHelper');
+
 // CFG: NEWS-READER-CLASS
 $cfg->setConfigEntry('news_reader_class', 'ConsoleNewsReader');
 
@@ -231,6 +234,9 @@ $cfg->setConfigEntry('node_announcement_template_class', 'XmlAnnouncementTemplat
 // CFG: NODE-ANNOUNCEMENT-ANSWER-TEMPLATE-CLASS
 $cfg->setConfigEntry('node_announcement_answer_template_class', 'XmlAnnouncementAnswerTemplateEngine');
 
+// CFG: NODE-REQUEST-NODE-LIST-TEMPLATE-CLASS
+$cfg->setConfigEntry('node_request_node_list_template_class', 'XmlRequestNodeListTemplateEngine');
+
 // CFG: NODE-MESSAGE-TEMPLATE-EXTENSION
 $cfg->setConfigEntry('node_message_template_extension', '.xml');
 
@@ -255,9 +261,15 @@ $cfg->setConfigEntry('node_self_connect_template_class', 'XmlSelfConnectTemplate
 // CFG: NODE-SELF-CONNECT-TEMPLATE-TYPE
 $cfg->setConfigEntry('node_self_connect_template_type', 'xml/self_connect');
 
+// CFG: NODE-REQUEST-NODE-LIST-TEMPLATE-TYPE
+$cfg->setConfigEntry('node_request_node_list_template_type', 'xml/requests');
+
 // CFG: NODE-SELF-CONNECT-STACKER-CLASS
 $cfg->setConfigEntry('node_self_connect_stacker_class', 'FiLoStacker');
 
+// CFG: NODE-REQUEST-NODE_LIST-STACKER-CLASS
+$cfg->setConfigEntry('node_request_node_list_stacker_class', 'FiLoStacker');
+
 // CFG: NODE-OBJECT-REGISTRY-TEMPLATE-CLASS
 $cfg->setConfigEntry('node_object_registry_template_class', 'XmlObjectRegistryTemplateEngine');
 
@@ -300,6 +312,9 @@ $cfg->setConfigEntry('stacker_announcement_answer_max_size', 20);
 // CFG: STACKER-SELF-CONNECT-MAX-SIZE
 $cfg->setConfigEntry('stacker_self_connect_max_size', 10);
 
+// CFG: STACKER-NODE-REQUEST-NODE-LIST-MAX_SIZE
+$cfg->setConfigEntry('stacker_node_request_node_list_max_size', 10);
+
 // CFG: STACKER-UNDECLARED-MAX-SIZE
 $cfg->setConfigEntry('stacker_package_undeclared_max_size', 10000);
 
index 3ebcbe30f89ba2398ad09205f25399c811f29dae..4deb44a3788354eb25e7a73acce6a8419c257fe0 100644 (file)
@@ -62,7 +62,7 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
                // We do some rudimentary checks but this might be a bit ugly
                switch ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]) {
                        // All upper hubs, these are currently the bootstrap nodes and later on prepended list-nodes
-                       case NetworkPackage::NETWORK_TARGET_UPPER_HUBS:
+                       case NetworkPackage::NETWORK_TARGET_UPPER_NODES:
                                // Get all bootstrap nodes
                                foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $node) {
                                        // Is maximum reached?
index 461b61b332499b8c1e76f7b664128dbf66a55def..c14b6c3302e75f77245a14311f4956e68fc79318 100644 (file)
@@ -32,7 +32,7 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha
                parent::__construct(__CLASS__);
 
                // Set handler name
-               $this->setHandlerName('answer_okay');
+               $this->setHandlerName('announcement_answer_okay');
        }
 
        /**
@@ -93,6 +93,27 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha
                // Prepare next message
                $this->prepareNextMessage($messageData, $packageInstance);
        }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               $this->partialStub('messageData=' . print_r($messageData, true));
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               $this->partialStub('messageData=' . print_r($messageData, true));
+       }
 }
 
 // [EOF]
index 89f501dfb218af6e3c6fea2dce9136622a2d3097..af4f1d8839b7543fca522f4aebbf42253c88ae0c 100644 (file)
@@ -32,7 +32,7 @@ class ???Handler extends BaseAnserStatusHandler implements HandleableAnswerStatu
                parent::__construct(__CLASS__);
 
                // Set handler name
-               $this->setHandlerName('answer_===');
+               $this->setHandlerName('|||_answer_===');
        }
 
        /**
index 4d5d1219503cd34e09d245d37e2dd98d9aa6d2d1..f5d6ff1abb8f621caef44ffae17bcbd3bcaf21e0 100644 (file)
  * 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;
-
+abstract class BaseAnserStatusHandler extends BaseDataHandler {
        /**
         * Protected constructor
         *
@@ -49,15 +44,6 @@ class BaseAnserStatusHandler extends BaseHandler {
                parent::__construct($className);
        }
 
-       /**
-        * Getter for last exception
-        *
-        * @return      $lastException  Last thrown exception
-        */
-       protected final function getLastException () {
-               return $this->lastException;
-       }
-
        /**
         * Adds all required elements from given array into data set instance
         *
@@ -70,47 +56,6 @@ class BaseAnserStatusHandler extends BaseHandler {
                $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $messageData[XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_ANSWER_STATUS]);
                $dataSetInstance->addCriteria(NodeListDatabaseWrapper::DB_COLUMN_MESSAGE_TYPE , $messageData[NetworkPackage::MESSAGE_ARRAY_TYPE]);
        }
-
-       /**
-        * Prepares the next message
-        *
-        * @param       $messageData            An array with all message data
-        * @param       $packageInstance        An instance of a Deliverable instance
-        * @return      void
-        */
-       protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) {
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send next message ...');
-
-               // Get a helper instance based on this handler's name
-               $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData));
-
-               // Load descriptor XML
-               $helperInstance->loadDescriptorXml();
-
-               /*
-                * Set missing (temporary) configuration data, mostly it needs to be
-                * copied from message data array.
-                */
-               $this->initMessageConfigurationData($messageData);
-
-               // Compile any configuration variables
-               $helperInstance->getTemplateInstance()->compileConfigInVariables();
-
-               // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
-
-               // Deliver the package
-               $helperInstance->sendPackage($nodeInstance);
-
-               /*
-                * Remove temporary configuration
-                */
-               $this->removeMessageConfigurationData($messageData);
-
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Next message has been prepared.');
-       }
 }
 
 // [EOF]
diff --git a/application/hub/main/handler/class_BaseDataHandler.php b/application/hub/main/handler/class_BaseDataHandler.php
new file mode 100644 (file)
index 0000000..8fd0b41
--- /dev/null
@@ -0,0 +1,182 @@
+<?php
+/**
+ * A general data 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/>.
+ */
+abstract class BaseDataHandler extends BaseHandler {
+       /**
+        * Last exception instance from database layer or NULL (default)
+        */
+       private $lastException = NULL;
+
+       /**
+        * Array with search criteria elements
+        */
+       protected $searchData = array();
+
+       /**
+        * Array with all data XML nodes (which hold the actual data) and their values
+        */
+       protected $messageDataElements = array();
+
+       /**
+        * Array for translating message data elements (other node's data mostly)
+        * into configuration elements.
+        */
+       protected $messageToConfig = array();
+
+       /**
+        * Array for copying configuration entries
+        */
+       protected $configCopy = array();
+
+       /**
+        * 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;
+       }
+
+       /**
+        * Setter for last exception
+        *
+        * @param       $lastException  Last thrown exception
+        * @return      void
+        */
+       protected final function setLastException (FrameworkException $exceptionInstance = NULL) {
+               $this->lastException = $exceptionInstance;
+       }
+
+       /**
+        * Prepares a message as answer for given message data for delivery.
+        *
+        * @param       $messageData            An array with all message data
+        * @param       $packageInstance        An instance of a Deliverable instance
+        * @return      void
+        */
+       protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) {
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send an answer message ...');
+
+               // Get a helper instance based on this handler's name
+               $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData));
+
+               // Load descriptor XML
+               $helperInstance->loadDescriptorXml();
+
+               /*
+                * Set missing (temporary) configuration data, mostly it needs to be
+                * copied from message data array.
+                */
+               $this->initMessageConfigurationData($messageData);
+
+               // Compile any configuration variables
+               $helperInstance->getTemplateInstance()->compileConfigInVariables();
+
+               // Get node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Deliver the package
+               $helperInstance->sendPackage($nodeInstance);
+
+               /*
+                * Remove temporary configuration
+                */
+               $this->removeMessageConfigurationData($messageData);
+
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Answer message has been prepared.');
+       }
+
+       /**
+        * Prepares the next message
+        *
+        * @param       $messageData            An array with all message data
+        * @param       $packageInstance        An instance of a Deliverable instance
+        * @return      void
+        */
+       protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) {
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send next message ...');
+
+               // Get a helper instance based on this handler's name
+               $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData));
+
+               // Load descriptor XML
+               $helperInstance->loadDescriptorXml();
+
+               /*
+                * Set missing (temporary) configuration data, mostly it needs to be
+                * copied from message data array.
+                */
+               $this->initMessageConfigurationData($messageData);
+
+               // Compile any configuration variables
+               $helperInstance->getTemplateInstance()->compileConfigInVariables();
+
+               // Get node instance
+               $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+               // Deliver the package
+               $helperInstance->sendPackage($nodeInstance);
+
+               /*
+                * Remove temporary configuration
+                */
+               $this->removeMessageConfigurationData($messageData);
+
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Next message has been prepared.');
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       abstract protected function initMessageConfigurationData (array $messageData);
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       abstract protected function removeMessageConfigurationData (array $messageData);
+}
+
+// [EOF]
+?>
index b20a8ab3bab15e40845262c06d6a358a274b36b0..adf44452169ebf51b0b7788c28b1c8b1592df2a8 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-abstract class BaseMessageHandler extends BaseHandler {
-       /**
-        * Array with search criteria elements
-        */
-       protected $searchData = array();
-
-       /**
-        * Array with all data XML nodes (which hold the actual data) and their values
-        */
-       protected $messageDataElements = array();
-
-       /**
-        * Array for translating message data elements (other node's data mostly)
-        * into configuration elements.
-        */
-       protected $messageToConfig = array();
-
-       /**
-        * Array for copying configuration entries
-        */
-       protected $configCopy = array();
-
-       /**
-        * Last exception instance from database layer or NULL (default)
-        */
-       private $lastException = NULL;
-
+abstract class BaseMessageHandler extends BaseDataHandler {
        /**
         * Protected constructor
         *
@@ -60,15 +34,6 @@ abstract class BaseMessageHandler extends BaseHandler {
                parent::__construct($className);
        }
 
-       /**
-        * Getter for last exception
-        *
-        * @return      $lastException  Last thrown exception
-        */
-       protected final function getLastException () {
-               return $this->lastException;
-       }
-
        /**
         * "Getter" for a translated last exception as a status code
         *
@@ -79,9 +44,9 @@ abstract class BaseMessageHandler extends BaseHandler {
                $statusCode = self::MESSAGE_STATUS_CODE_OKAY;
 
                // Is the last exception not NULL?
-               if ($this->lastException instanceof FrameworkException) {
+               if ($this->getLastException() instanceof FrameworkException) {
                        // "Determine" the right status code (may differ from exception to exception)
-                       $this->debugInstance('lastException=' . $this->lastException->__toString() . ',message=' . $this->lastException->getMessage() . ' is not finished!');
+                       $this->debugInstance('lastException=' . $this->getLastException()->__toString() . ',message=' . $this->getLastException()->getMessage() . ' is not finished!');
                } // END - if
 
                // Return the status code
@@ -132,66 +97,8 @@ abstract class BaseMessageHandler extends BaseHandler {
                }
 
                // Save last exception
-               $this->lastException = $wrapperInstance->getLastException();
-       }
-
-       /**
-        * Prepares a message as answer for given message data for delivery.
-        *
-        * @param       $messageData            An array with all message data
-        * @param       $packageInstance        An instance of a Deliverable instance
-        * @return      void
-        */
-       protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) {
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Going to send an answer message ...');
-
-               // Get a helper instance based on this handler's name
-               $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData));
-
-               // Load descriptor XML
-               $helperInstance->loadDescriptorXml();
-
-               /*
-                * Set missing (temporary) configuration data, mostly it needs to be
-                * copied from message data array.
-                */
-               $this->initMessageConfigurationData($messageData);
-
-               // Compile any configuration variables
-               $helperInstance->getTemplateInstance()->compileConfigInVariables();
-
-               // Get node instance
-               $nodeInstance = Registry::getRegistry()->getInstance('node');
-
-               // Deliver the package
-               $helperInstance->sendPackage($nodeInstance);
-
-               /*
-                * Remove temporary configuration
-                */
-               $this->removeMessageConfigurationData($messageData);
-
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('MESSAGE-HANDLER[' . $this->__toString() . ']: Answer message has been prepared.');
+               $this->setLastException($wrapperInstance->getLastException());
        }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       abstract protected function initMessageConfigurationData (array $messageData);
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       abstract protected function removeMessageConfigurationData (array $messageData);
 }
 
 // [EOF]
index 722a5f43efe1ded883cd8a6cd3643009f1d4a267..a250ed0d0cd1ab2df5f654a8123d00f237df21d0 100644 (file)
@@ -38,7 +38,7 @@ class HubAnnouncementHelper extends BaseHubHelper implements HelpableHub {
                parent::__construct(__CLASS__);
 
                // Set recipient type
-               $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_HUBS);
+               $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES);
        }
 
        /**
diff --git a/application/hub/main/helper/hub/requests/.htaccess b/application/hub/main/helper/hub/requests/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php b/application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php
new file mode 100644 (file)
index 0000000..900352b
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+/**
+ * A ??? hub helper class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ * @todo               Find an interface for hub helper
+ *
+ * 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 NodeRequestNodeListHelper extends BaseHubHelper implements HelpableHub {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set recipient type
+               $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES);
+       }
+
+       /**
+        * Creates the helper class
+        *
+        * @return      $helperInstance         A prepared instance of this helper
+        */
+       public final static function createNodeRequestNodeListHelper () {
+               // Get new instance
+               $helperInstance = new NodeRequestNodeListHelper();
+
+               // Return the prepared instance
+               return $helperInstance;
+       }
+
+       /**
+        * Loads the descriptor XML file
+        *
+        * @return      void
+        */
+       public function loadDescriptorXml () {
+               // Debug message
+               self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to request node list...');
+
+               // Get a XML template instance
+               $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_template_class');
+
+               // Set it for later use
+               $this->setTemplateInstance($templateInstance);
+
+               // Read the XML descriptor
+               $this->getTemplateInstance()->loadRequestNodeListTemplate();
+
+               // Render the XML content
+               $this->getTemplateInstance()->renderXmlContent();
+       }
+
+       /**
+        * Do the helped attempt by delivering a package to ourselfs
+        *
+        * @param       $nodeInstance   An instance of a NodeHelper class
+        * @return      void
+        */
+       public function sendPackage (NodeHelper $nodeInstance) {
+               // Sanity check: Is the node in the approx. state? (active)
+               $nodeInstance->getStateInstance()->validateNodeStateIsActive();
+
+               // Compile the template, this inserts the loaded node data into the gaps.
+               $this->getTemplateInstance()->compileTemplate();
+
+               // Get a singleton network package instance
+               $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
+
+               // Next, feed the content in. The network package class is a pipe-through class.
+               $packageInstance->enqueueRawDataFromTemplate($this);
+       }
+}
+
+// [EOF]
+?>
index 5d4f11bd85d929f57aadcaed0a8a1f897fcb04f4..e060c32f9238c09f7145a067fb9d75f5e0c4ed19 100644 (file)
@@ -132,9 +132,9 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
        const PACKAGE_RECIPIENT_SEPARATOR = ':';
 
        /**
-        * Network target (alias): 'upper hubs'
+        * Network target (alias): 'upper nodes'
         */
-       const NETWORK_TARGET_UPPER_HUBS = 'upper';
+       const NETWORK_TARGET_UPPER_NODES = 'upper';
 
        /**
         * Network target (alias): 'self'
index 218e240a1d83cbc00ac283fb54159bef6aa1510e..8543d31e7f6957b7a999db81f80692605330a4b0 100644 (file)
@@ -115,7 +115,7 @@ class Xml???TemplateEngine extends BaseTemplateEngine implements CompileableTemp
         *                                              located in '!!!' by default
         * @return      void
         */
-       public function load???Template ($template) {
+       public function load???Template ($template = '!!!') {
                // Set template type
                $this->setTemplateType($this->getConfigInstance()->getConfigEntry('!!!_template_type'));
 
diff --git a/application/hub/main/template/requests/.htaccess b/application/hub/main/template/requests/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php b/application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php
new file mode 100644 (file)
index 0000000..968a5b9
--- /dev/null
@@ -0,0 +1,280 @@
+<?php
+/**
+ * An ??? template engine class for XML templates
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ * @todo               This template engine does not make use of setTemplateType()
+ *
+ * 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 XmlRequestNodeListTemplateEngine extends BaseTemplateEngine implements CompileableTemplate, Registerable {
+       /**
+        * Main nodes in the XML tree
+        */
+       private $mainNodes = array(
+               'node-request-node-list'
+       );
+
+       /**
+        * Sub nodes in the XML tree
+        */
+       private $subNodes = array(
+       );
+
+       /**
+        * Current main node
+        */
+       private $curr = array();
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of the class TemplateEngine and prepares it for usage
+        *
+        * @return      $templateInstance               An instance of TemplateEngine
+        * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
+        * @throws      InvalidBasePathStringException  If $templateBasePath is no string
+        * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
+        *                                                                                      directory or not found
+        * @throws      BasePathReadProtectedException  If $templateBasePath is
+        *                                                                                      read-protected
+        */
+       public static final function createXmlRequestNodeListTemplateEngine () {
+               // Get a new instance
+               $templateInstance = new XmlRequestNodeListTemplateEngine();
+
+               // Get application instance from registry
+               $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+               // Determine base path
+               $templateBasePath = $templateInstance->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/';
+
+               // Is the base path valid?
+               if (empty($templateBasePath)) {
+                       // Base path is empty
+                       throw new BasePathIsEmptyException($templateInstance, self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+               } elseif (!is_string($templateBasePath)) {
+                       // Is not a string
+                       throw new InvalidBasePathStringException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_STRING);
+               } elseif (!is_dir($templateBasePath)) {
+                       // Is not a path
+                       throw new BasePathIsNoDirectoryException(array($templateInstance, $templateBasePath), self::EXCEPTION_INVALID_PATH_NAME);
+               } elseif (!is_readable($templateBasePath)) {
+                       // Is not readable
+                       throw new BasePathReadProtectedException(array($templateInstance, $templateBasePath), self::EXCEPTION_READ_PROTECED_PATH);
+               }
+
+               // Set the base path
+               $templateInstance->setTemplateBasePath($templateBasePath);
+
+               // Set template extensions
+               $templateInstance->setRawTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('raw_template_extension'));
+               $templateInstance->setCodeTemplateExtension($templateInstance->getConfigInstance()->getConfigEntry('node_message_template_extension'));
+
+               // Absolute output path for compiled templates
+               $templateInstance->setCompileOutputPath($templateInstance->getConfigInstance()->getConfigEntry('base_path') . $templateInstance->getConfigInstance()->getConfigEntry('compile_output_path'));
+
+               // Init a variable stacker
+               $stackerInstance = ObjectFactory::createObjectByConfiguredName('node_request_node_list_stacker_class');
+
+               // Set it
+               $templateInstance->setStackerInstance($stackerInstance);
+
+               // Return the prepared instance
+               return $templateInstance;
+       }
+
+       /**
+        * Load a specified request_node_list template into the engine
+        *
+        * @param       $template       The request_node_list template we shall load which is
+        *                                              located in 'node_request_node_list' by default
+        * @return      void
+        */
+       public function loadRequestNodeListTemplate ($template = 'node_request_node_list') {
+               // Set template type
+               $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_request_node_list_template_type'));
+
+               // Load the special template
+               $this->loadTemplate($template);
+       }
+
+       /**
+        * Getter for current main node
+        *
+        * @return      $currMainNode   Current main node
+        */
+       public final function getCurrMainNode () {
+               return $this->curr['main_node'];
+       }
+
+       /**
+        * Setter for current main node
+        *
+        * @param       $element                Element name to set as current main node
+        * @return      $currMainNode   Current main node
+        */
+       private final function setCurrMainNode ($element) {
+               $this->curr['main_node'] = (string) $element;
+       }
+
+       /**
+        * Getter for main node array
+        *
+        * @return      $mainNodes      Array with valid main node names
+        */
+       public final function getMainNodes () {
+               return $this->mainNodes;
+       }
+
+       /**
+        * Getter for sub node array
+        *
+        * @return      $subNodes       Array with valid sub node names
+        */
+       public final function getSubNodes () {
+               return $this->subNodes;
+       }
+
+       /**
+        * Handles the start element of an XML resource
+        *
+        * @param       $resource               XML parser resource (currently ignored)
+        * @param       $element                The element we shall handle
+        * @param       $attributes             All attributes
+        * @return      void
+        * @throws      InvalidXmlNodeException         If an unknown/invalid XML node name was found
+        */
+       public function startElement ($resource, $element, array $attributes) {
+               // Initial method name which will never be called...
+               $methodName = 'initNodeRequestNodeList';
+
+               // Make the element name lower-case
+               $element = strtolower($element);
+
+               // Is the element a main node?
+               //* DEBUG: */ echo "START: &gt;".$element."&lt;<br />\n";
+               if (in_array($element, $this->getMainNodes())) {
+                       // Okay, main node found!
+                       $methodName = 'start' . $this->convertToClassName($element);
+
+                       // Set it
+                       $this->setCurrMainNode($element);
+               } elseif (in_array($element, $this->getSubNodes())) {
+                       // Sub node found
+                       $methodName = 'start' . $this->convertToClassName($element);
+               } else {
+                       // Invalid node name found
+                       throw new InvalidXmlNodeException(array($this, $element, $attributes), XmlParser::EXCEPTION_XML_NODE_UNKNOWN);
+               }
+
+               // Call method
+               call_user_func_array(array($this, $methodName), $attributes);
+       }
+
+       /**
+        * Ends the main or sub node by sending out the gathered data
+        *
+        * @param       $resource       An XML resource pointer (currently ignored)
+        * @param       $nodeName       Name of the node we want to finish
+        * @return      void
+        * @throws      XmlNodeMismatchException        If current main node mismatches the closing one
+        */
+       public function endElement ($resource, $nodeName) {
+               // Make all lower-case
+               $nodeName = strtolower($nodeName);
+
+               // Does this match with current main node?
+               //* DEBUG: */ echo "END: &gt;".$nodeName."&lt;<br />\n";
+               if (($nodeName != $this->getCurrMainNode()) && (in_array($nodeName, $this->getMainNodes()))) {
+                       // Did not match!
+                       throw new XmlNodeMismatchException (array($this, $nodeName, $this->getCurrMainNode()), XmlParser::EXCEPTION_XML_NODE_MISMATCH);
+               } // END - if
+
+               // Construct method name
+               $methodName = 'finish' . $this->convertToClassName($nodeName);
+
+               // Call the corresponding method
+               //* DEBUG: */ echo "call: ".$methodName."<br />\n";
+               call_user_func_array(array($this, $methodName), array());
+       }
+
+       /**
+        * Currently not used
+        *
+        * @param       $resource               XML parser resource (currently ignored)
+        * @param       $characters             Characters to handle
+        * @return      void
+        * @todo        Find something useful with this!
+        */
+       public function characterHandler ($resource, $characters) {
+               // Trim all spaces away
+               $characters = trim($characters);
+
+               // Is this string empty?
+               if (empty($characters)) {
+                       // Then skip it silently
+                       return false;
+               } // END - if
+
+               // Get current XML node name as an array index
+               $nodeName = $this->getStackerInstance()->getNamed('node_request_node_list');
+
+               $this->partialStub('TODO: Do something with the gathered data.');
+       }
+
+       /**
+        * Getter for cache file (FQFN)
+        *
+        * @return      $fqfn   Full-qualified file name of the menu cache
+        */
+       public function getNodeRequestNodeListCacheFqfn () {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Starts the node-request-node-list
+        *
+        * @return      void
+        */
+       private function startNodeRequestNodeList () {
+               // Push the node name on the stacker
+               $this->getStackerInstance()->pushNamed('node_request_node_list', 'node-request-node-list');
+       }
+
+       /**
+        * Finishes the node-request-node-list
+        *
+        * @return      void
+        */
+       private function finishNodeRequestNodeList () {
+               // Pop the last entry
+               $this->getStackerInstance()->popNamed('node_request_node_list');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/templates/xml/requests/.htaccess b/application/hub/templates/xml/requests/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/templates/xml/requests/node_request_node_list.xml b/application/hub/templates/xml/requests/node_request_node_list.xml
new file mode 100644 (file)
index 0000000..f219b49
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+An XML for requesting a node list, to specify which node data shall be
+transmitted.
+
+@author                Roland Haeder <webmaster@ship-simu.org>
+@version       0.0.0
+@copyright     Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 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/>
+//-->
+<node-request-node-list>
+</node-request-node-list>