private function publishEvent($agentId, $objectName, $objectAction, $version, $header) { $db = Zend_Registry::get('my_db'); $dom = $this->dom; $dataObject = new DataObject($objectName); $actionId = Event::getActionId($objectAction); $query = "select agent_subscriptions.agent_id,\r\n\t\t\t \t\t\t agent_registered.agent_mode_id,\r\n\t\t\t \t\t\t agent_registered.sif_version,\r\n\t\t\t \t\t\t agent_registered.maxbuffersize,\r\n\t\t \t\t\t agent.source_id\r\n\t\t \t\tfrom " . DBConvertor::convertCase('agent_subscriptions') . "\r\n\t\t \t\t\tinner join \r\n\t\t\t\t\t\t" . DBConvertor::convertCase('agent_registered') . " on agent_registered.agent_Id = agent_subscriptions.agent_id\r\n\t\t \t\t\tand agent_registered.unregister_timestamp is null\r\n\t\t \t\t\tinner join " . DBConvertor::convertCase('agent') . " on agent.agent_id = agent_subscriptions.agent_id\r\n\t\t \t\t\twhere agent_subscriptions.object_type_id = " . $dataObject->objectId . " \r\n\t\t \t\t\tand agent_subscriptions.context_id = " . $_SESSION["CONTEXT_ID"] . " \r\n\t\t \t\t\tand agent_subscriptions.zone_id = " . $_SESSION["ZONE_ID"] . "\r\n\t\t \t\t\tand agent_subscriptions.context_id = agent_registered.context_id \r\n\t\t \t\t\tand agent_subscriptions.zone_id = agent_registered.zone_id"; $result = $db->fetchAll($query); foreach ($result as $row) { $error = false; switch (DB_TYPE) { case 'mysql': $agent_id = intval($row->agent_id); $maxbuffersize = intval($row->maxbuffersize); $source_id = $row->source_id; $agent_mode_id = intval($row->agent_mode_id); $agent_version = $row->sif_version; break; case 'oci8': $agent_id = intval($row->AGENT_ID); $maxbuffersize = intval($row->MAXBUFFERSIZE); $source_id = $row->SOURCE_ID; $agent_mode_id = intval($row->AGENT_MODE_ID); $agent_version = $row->SIF_VERSION; break; } // $filterUtility = new FilterUtility(); // $filterUtility->FilterCommonElements($dataObject->objectId, $dom, $agent_id); $sifMessageNode = $dom->getElementsByTagName('SIF_Message')->item(0); $eventXML = $dom->saveXML($sifMessageNode); $eventXML = str_replace('xmlns="http://www.sifinfo.org/uk/infrastructure/2.x" ', '', $eventXML); $eventXML = str_replace('xmlns="http://www.sifinfo.org/infrastructure/2.x" ', '', $eventXML); $eventXML = str_replace('xmlns="http://www.sifinfo.org/infrastructure/1.x" ', '', $eventXML); $eventXML = str_replace('xmlns:sif="http://www.sifinfo.org/infrastructure/2.x" ', '', $eventXML); $eventXML = str_replace('xmlns:sif="http://www.sifinfo.org/infrastructure/1.x" ', '', $eventXML); $messageSize = strlen($eventXML); if ($messageSize > $maxbuffersize) { SifLogEntry::CreateSifLogEvents($header, '4', '2', 'Buffer size of agent ' . $row->source_id . ' is too small to recieve this event [size : ' . $row->maxbuffersize . ']'); $error = true; } if ($version != $agent_version) { SifLogEntry::CreateSifLogEvents($header, '4', '4', 'Version in event not supported by agent ' . $source_id); $error = true; } if (!$error) { $data = array(DBConvertor::convertCase('event_timestamp') => new Zend_Db_Expr(DBConvertor::convertCurrentTime()), DBConvertor::convertCase('agent_id_sender') => $agentId, DBConvertor::convertCase('agent_id_rec') => $agent_id, DBConvertor::convertCase('event_data') => $eventXML, DBConvertor::convertCase('object_id') => $dataObject->objectId, DBConvertor::convertCase('action_id') => $actionId, DBConvertor::convertCase('agent_mode_id') => $agent_mode_id, DBConvertor::convertCase('zone_id') => $_SESSION["ZONE_ID"], DBConvertor::convertCase('context_id') => $_SESSION["CONTEXT_ID"]); $db->insert(DBConvertor::convertCase('event'), $data); } } }
private function publishEvent($agentId, $objectName, $objectAction, $version, $m) { $db = Zend_Registry::get('my_db'); $dom = $m->dom; $event_destination_found = false; $headerNode = $m->headerNode; $originalMsgId = $m->msgId; $originalSourceId = $m->sourceId; $originalTimestamp = $headerNode->getElementsByTagName('SIF_Timestamp')->item(0)->nodeValue; $dataObject = new DataObject($objectName); $actionId = Event::getActionId($objectAction); $query = "select agent_subscriptions.agent_id,\r\n\t\t\t \t\t\t agent_registered.agent_mode_id,\r\n\t\t\t \t\t\t agent_registered.sif_version,\r\n\t\t\t \t\t\t agent_registered.maxbuffersize,\r\n\t\t \t\t\t agent.source_id\r\n\t\t \t\tfrom " . DBConvertor::convertCase('agent_subscriptions') . "\r\n\t\t \t\t\tinner join " . DBConvertor::convertCase('agent_registered') . " on agent_registered.agent_Id = agent_subscriptions.agent_id and agent_registered.unregister_timestamp is null\r\n\t\t \t\t\tinner join " . DBConvertor::convertCase('agent') . " on agent.agent_id = agent_subscriptions.agent_id\r\n\t\t \t\t\twhere agent_subscriptions.zone_id = " . $_SESSION["ZONE_ID"] . "\r\n\t\t\t\t\t\tand agent_subscriptions.object_type_id = " . $dataObject->objectId . "\r\n\t\t \t\t\tand agent_subscriptions.context_id = " . $_SESSION["CONTEXT_ID"] . "\r\n\t\t \t\t\tand agent_subscriptions.context_id = agent_registered.context_id \r\n\t\t \t\t\tand agent_subscriptions.zone_id = agent_registered.zone_id"; if ($m->destinationIdFound == true) { $query = $query . " and agent.source_id = '" . $m->destinationId . "'"; } $result = $db->fetchAll($query); foreach ($result as $row) { $error = false; $event_destination_found = true; switch (DB_TYPE) { case 'mysql': $agent_id = intval($row->agent_id); $maxbuffersize = intval($row->maxbuffersize); $source_id = $row->source_id; $agent_mode_id = intval($row->agent_mode_id); $agent_version = $row->sif_version; break; case 'oci8': $agent_id = intval($row->AGENT_ID); $maxbuffersize = intval($row->MAXBUFFERSIZE); $source_id = $row->SOURCE_ID; $agent_mode_id = intval($row->AGENT_MODE_ID); $agent_version = $row->SIF_VERSION; break; } $sifMessageNode = $dom->getElementsByTagName('SIF_Message')->item(0); $eventXML = $dom->saveXML($sifMessageNode); $eventXML = str_replace('xmlns="http://www.sifinfo.org/uk/infrastructure/2.x" ', '', $eventXML); $eventXML = str_replace('xmlns="http://www.sifinfo.org/infrastructure/2.x" ', '', $eventXML); $eventXML = str_replace('xmlns="http://www.sifinfo.org/infrastructure/1.x" ', '', $eventXML); $eventXML = str_replace('xmlns:sif="http://www.sifinfo.org/infrastructure/2.x" ', '', $eventXML); $eventXML = str_replace('xmlns:sif="http://www.sifinfo.org/infrastructure/1.x" ', '', $eventXML); $eventXML = str_replace('xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ', '', $eventXML); $messageSize = strlen($eventXML); if ($messageSize > $maxbuffersize) { SifLogEntry::CreateSifLogEvents($header, '4', '2', 'Buffer size of agent ' . $row->source_id . ' is too small to recieve this event [size : ' . $row->maxbuffersize . ']'); $error = true; } if ($version != $agent_version) { SifLogEntry::CreateSifLogEvents($header, '4', '4', 'Version in event not supported by agent ' . $source_id); $error = true; } if (!$error) { $data = array(DBConvertor::convertCase('insert_timestamp') => new Zend_Db_Expr(DBConvertor::convertCurrentTime()), DBConvertor::convertCase('msg_id') => $originalMsgId, DBConvertor::convertCase('agt_id_in') => $agentId, DBConvertor::convertCase('msg_type') => 3, DBConvertor::convertCase('status_id') => 1, DBConvertor::convertCase('agt_id_out') => $agent_id, DBConvertor::convertCase('data') => $eventXML, DBConvertor::convertCase('object_id') => $dataObject->objectId, DBConvertor::convertCase('action_id') => $actionId, DBConvertor::convertCase('agt_mode_id') => $agent_mode_id, DBConvertor::convertCase('zone_id') => $_SESSION["ZONE_ID"], DBConvertor::convertCase('context_id') => $_SESSION["CONTEXT_ID"]); $db->insert(DBConvertor::convertCase('messagequeue'), $data); } } if ($event_destination_found == false) { GeneralError::genericError($m, "11", "1", "Generic Error", "SIF DestinationId not found."); } }