From 4c18f79d1ddbc3c51b64fb7642ac44af65738556 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 9 Feb 2014 04:02:24 +0100 Subject: [PATCH] Some missing code added: - Updated interface NodeDhtWrapper - Added cleanup of non-public data from DHT entry array - Again 'core' has "changed" ??? Signed-off-by: Roland Haeder --- .../wrapper/class_NodeDhtWrapper.php | 52 +++++++++++++++++++ ...odeDistributedHashTableDatabaseWrapper.php | 14 +++++ .../class_NodeInformationDatabaseWrapper.php | 14 +++++ application/hub/main/dht/class_BaseDht.php | 3 ++ core | 2 +- 5 files changed, 84 insertions(+), 1 deletion(-) diff --git a/application/hub/interfaces/wrapper/class_NodeDhtWrapper.php b/application/hub/interfaces/wrapper/class_NodeDhtWrapper.php index e41ead812..64eea8695 100644 --- a/application/hub/interfaces/wrapper/class_NodeDhtWrapper.php +++ b/application/hub/interfaces/wrapper/class_NodeDhtWrapper.php @@ -22,6 +22,13 @@ * along with this program. If not, see . */ interface NodeDhtWrapper extends DatabaseWrapper { + /** + * Getter for result instance for unpublished entries + * + * @return $unpublishedEntriesInstance Result instance + */ + function getUnpublishedEntriesInstance (); + /** * Checks whether the local (*this*) node is registered in the DHT by * checking if the external ip/port is found. @@ -53,6 +60,25 @@ interface NodeDhtWrapper extends DatabaseWrapper { */ function findNodeLocalBySessionId ($sessionId); + /** + * Registeres a node by given message data. + * + * @param $messageData An array of all message data + * @param $handlerInstance An instance of a Handleable class + * @return void + */ + function registerNodeByMessageData (array $messageData, Handleable $handlerInstance); + + /** + * Updates an existing entry in node list + * + * @param $messageData An array of all message data + * @param $handlerInstance An instance of a Handleable class + * @param $searchInstance An instance of LocalSearchCriteria class + * @return void + */ + function updateNodeByMessageData (array $messageData, Handleable $handlerInstance, LocalSearchCriteria $searchInstance); + /** * Determines whether the given node data is already inserted in the DHT * @@ -81,6 +107,32 @@ interface NodeDhtWrapper extends DatabaseWrapper { * @throws NodeDataMissingException If the node's data is missing */ function updateNode (array $nodeData); + + /** + * Checks whether there are unpublished entries + * + * @return $hasUnpublished Whether there are unpublished entries + * @todo Add minimum/maximum age limitations + */ + function hasUnpublishedEntries (); + + /** + * Initializes publication of DHT entries. This does only prepare + * publication. The next step is to pickup such prepared entries and publish + * them by uploading to other (recently appeared) DHT members. + * + * @return void + * @todo Add timestamp to dataset instance + */ + function initEntryPublication (); + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + function removeNonPublicDataFromArray (array $data); } // [EOF] diff --git a/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php index 3cc15d8e4..b9035bd06 100644 --- a/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ b/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php @@ -491,6 +491,20 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem // Run the "UPDATE" query $this->queryUpdateDataSet($dataSetInstance); } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public function removeNonPublicDataFromArray(array $data) { + // Currently call only inner method + $data = parent::removeNonPublicDataFromArray($data); + + // Return cleaned data + return $data; + } } // [EOF] diff --git a/application/hub/main/database/wrapper/node/class_NodeInformationDatabaseWrapper.php b/application/hub/main/database/wrapper/node/class_NodeInformationDatabaseWrapper.php index 2b2f6b70d..307cbb3e5 100644 --- a/application/hub/main/database/wrapper/node/class_NodeInformationDatabaseWrapper.php +++ b/application/hub/main/database/wrapper/node/class_NodeInformationDatabaseWrapper.php @@ -163,6 +163,20 @@ class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements Node // Update database record $this->queryUpdateDataSet($dataSetInstance); } + + /** + * Removes non-public data from given array. + * + * @param $data An array with possible non-public data that needs to be removed. + * @return $data A cleaned up array with only public data. + */ + public function removeNonPublicDataFromArray(array $data) { + // Currently call only inner method + $data = parent::removeNonPublicDataFromArray($data); + + // Return cleaned data + return $data; + } } // [EOF] diff --git a/application/hub/main/dht/class_BaseDht.php b/application/hub/main/dht/class_BaseDht.php index e676653f4..f6b5396ed 100644 --- a/application/hub/main/dht/class_BaseDht.php +++ b/application/hub/main/dht/class_BaseDht.php @@ -208,6 +208,9 @@ abstract class BaseDht extends BaseHubSystem { // Some sanity-checks assert(is_array($entry)); + // Remove any non-public data the database layer desires + $entry = $this->getWrapperInstance()->removeNonPublicDataFromArray($entry); + // Inject variables $this->publishHelperInstance->getTemplateInstance()->injectConfigVariables($entry); diff --git a/core b/core index b287094dd..76c734026 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit b287094ddaed86f6d71c2d54f7b18d26a2312fd4 +Subproject commit 76c734026223c500bb37cc22539cbd1c6f006f83 -- 2.39.5