* object types except the node by given session id.
*
* @param $messageData An array with message data from a node_list request
+ * @param $excludeKey Array key which should be excluded
+ * @param $andKey Array of $separator-separated list of elements which all must match
+ * @param $separator Sepator char (1st parameter for explode() call)
* @return $nodeList An array with all found nodes
*/
- function queryLocalNodeListExceptByMessageData (array $messageData);
+ function queryLocalNodeListExceptByMessageData (array $messageData, $excludeKey, $andKey, $separator);
}
// [EOF]
* object types except the node by given session id.
*
* @param $messageData An array with message data from a node_list request
+ * @param $excludeKey Array key which should be excluded
+ * @param $andKey Array of $separator-separated list of elements which all must match
+ * @param $separator Sepator char (1st parameter for explode() call)
* @return $nodeList An array with all found nodes
- * @todo Implement exclusion/choise-inclusion criteria
*/
- public function queryLocalNodeListExceptByMessageData (array $messageData) {
- // Get a search criteria class
- $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+ public function queryLocalNodeListExceptByMessageData (array $messageData, $excludeKey, $andKey, $separator) {
+ // Make sure both keys are there
+ assert((isset($messageData[$excludeKey])) && (isset($messageData[$andKey])));
// Debug message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: messageData=' . print_r($messageData, true));
+ // Get a search criteria class
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Add all keys
+ foreach (explode($separator, $messageData[$andKey]) as $criteria) {
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: andKey=' . $andKey . ',criteria=' . $criteria);
+
+ // Add it and leave any 'my-' prefix out
+ $searchInstance->addChoiceCriteria(str_replace('my-', '', $andKey), $criteria);
+ } // END - foreach
+
+ // Add exclusion key
+ $searchInstance->addExcludeCriteria(str_replace('my-', '', $excludeKey), $messageData[$excludeKey]);
+
// Only X entries are fine
$searchInstance->setLimit($this->getConfigInstance()->getConfigEntry('node_dht_list_limit'));
$this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
} // END - foreach
- // Query local DHT for nodes except given session id
- $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData($messageData);
- die('nodeList='.print_r($nodeList, true));
-
// Translate last exception into a status code
$statusCode = $this->getTranslatedStatusFromLastException();
// Set it in configuration (temporarily)
$this->getConfigInstance()->setConfigEntry('answer_status', $statusCode);
+
+ // Query local DHT for nodes except given session id
+ $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData($messageData, XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID, XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, ',');
+ die('nodeList='.print_r($nodeList, true));
}
/**