Ejemplo n.º 1
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct("Invalid accepte content type sent for this endpoint/method");
 }
Ejemplo n.º 2
0
 private function setupRequest($objectName, $sourceId, $agent)
 {
     $db = ZitDBAdapter::getDBAdapter();
     $dom = $this->dom;
     $providerId = null;
     if ($sourceId != null) {
         $agent = new Agent($sourceId);
         $providerId = $agent->agentId;
     } else {
         $providerId = DataObject::getProviderId($objectName);
     }
     if ($providerId == 0) {
         RequestError::invalidProvider($this->originalSourceId, $this->originalMsgId);
     } else {
         $error = false;
         $sifMessageNode = $dom->getElementsByTagName('SIF_Message')->item(0);
         $eventXML = $dom->saveXML($sifMessageNode);
         $eventXML = str_replace('xmlns:sif="http://www.sifinfo.org/infrastructure/2.x" ', '', $eventXML);
         $eventXML = str_replace('xmlns="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="http://www.sifinfo.org/infrastructure/1.x" ', '', $eventXML);
         $eventXML = str_replace('xmlns="http://www.sifinfo.org/uk/infrastructure/2.x" ', '', $eventXML);
         $eventXML = str_replace('xmlns="http://www.sifinfo.org/au/infrastructure/2.x" ', '', $eventXML);
         $eventXML = str_replace('xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ', '', $eventXML);
         $messageId = $dom->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
         $bufferSize = $dom->getElementsByTagName('SIF_MaxBufferSize')->item(0)->nodeValue;
         /*
         PUSH all messages to the ZONE Version:
         DO NOT Check Message Version:
         */
         $version = $_SESSION['ZONE_VERSION'];
         $query = "select\r\n                            agent_registered.sif_version,\r\n                            agent_registered.maxbuffersize,\r\n                            agent_registered.agent_mode_id,\r\n                            agent.source_id\r\n                      from " . DBConvertor::convertCase('agent_registered') . " \r\n                      inner join " . DBConvertor::convertCase('agent') . " on agent.agent_id = agent_registered.agent_id\r\n                      where agent_registered.agent_id = {$providerId} and agent_registered.unregister_timestamp is null\r\n                      and   agent_registered.zone_id = " . $_SESSION["ZONE_ID"] . "\r\n                      and   agent_registered.context_id = " . $_SESSION["CONTEXT_ID"];
         $result = $db->fetchAll($query);
         switch (DB_TYPE) {
             case 'mysql':
                 $agentModeId = $result[0]->agent_mode_id;
                 $maxbuffersize = intval($result[0]->maxbuffersize);
                 $source_id = $result[0]->source_id;
                 $sif_version = $result[0]->sif_version;
                 break;
             case 'oci8':
                 $agentModeId = $result[0]->AGENT_MODE_ID;
                 $maxbuffersize = intval($result[0]->MAXBUFFERSIZE);
                 $source_id = $result[0]->SOURCE_ID;
                 $sif_version = $result[0]->SIF_VERSION;
                 break;
         }
         $messageSize = strlen($eventXML);
         if ($messageSize > $maxbuffersize) {
             $error = true;
             $header = $this->headerNode;
             SifLogEntry::CreateSifLogEvents($header, '4', '2', 'Buffer size of agent ' . $source_id . ' is too small to recieve this request [size : ' . $maxbuffersize . ']');
         }
         /*
                     if($version != '2.*') {
                         if($version != $sif_version) {
                             $header = $this->headerNode;
         					$error = true;
                             SifLogEntry::CreateSifLogEvents($header,
                                     '4',
                                     '4',
                                     'Version in request not supported by agent '.$source_id
                             );
                         }
                     } else {
         				$version = $_SESSION['ZONE_VERSION'];
         			}
         */
         if (!$error) {
             $dataObject = new DataObject($objectName);
             #				$request = new Requests($db);
             #                $data = array(
             #                        DBConvertor::convertCase('request_msg_id')      => $messageId,
             #                        DBConvertor::convertCase('request_timestamp')   => new Zend_Db_Expr(DBConvertor::convertCurrentTime()),
             #                        DBConvertor::convertCase('agent_id_requester')  => $agent->agentId,
             #                        DBConvertor::convertCase('agent_id_responder')  => intval($providerId),
             #                        DBConvertor::convertCase('request_data')        => $eventXML,
             #                        DBConvertor::convertCase('max_buffer_size')     => $bufferSize,
             #                        DBConvertor::convertCase('version')				=> $version,
             #                        DBConvertor::convertCase('agent_mode_id')		=> intval($agentModeId),
             #                        DBConvertor::convertCase('zone_id')         	=> $_SESSION["ZONE_ID"],
             #                        DBConvertor::convertCase('context_id')			=> $_SESSION["CONTEXT_ID"]
             #                );
             #                $request->insert($data);
             $messagequeue = new MessageQueues($db);
             $data = null;
             $data = array(DBConvertor::convertCase('msg_id') => $messageId, DBConvertor::convertCase('msg_type') => 1, DBConvertor::convertCase('status_id') => 1, DBConvertor::convertCase('insert_timestamp') => new Zend_Db_Expr(DBConvertor::convertCurrentTime()), DBConvertor::convertCase('agt_id_in') => intval($agent->agentId), DBConvertor::convertCase('agt_id_out') => intval($providerId), DBConvertor::convertCase('data') => $eventXML, DBConvertor::convertCase('maxbuffersize') => intval($bufferSize), DBConvertor::convertCase('version') => $version, DBConvertor::convertCase('agt_mode_id') => intval($agentModeId), DBConvertor::convertCase('zone_id') => $_SESSION["ZONE_ID"], DBConvertor::convertCase('context_id') => $_SESSION["CONTEXT_ID"]);
             $messagequeue->insert($data);
         }
         $timestamp = Utility::createTimestamp();
         $msgId = Utility::createMessageId();
         $sifMessageNode = $dom->getElementsByTagName('SIF_Message')->item(0);
         XmlHelper::buildSuccessMessage($msgId, $timestamp, $this->originalSourceId, $this->originalMsgId, 0, $originalMsg = null, $desc = null);
     }
     //invalid provider check
 }
Ejemplo n.º 3
0
 private function processResponse($m)
 {
     $dom = $m->dom;
     $headerNode = $m->headerNode;
     $originalMsgId = $m->msgId;
     $this->originalMsgId = $m->msgId;
     $originalSourceId = $m->sourceId;
     $version = $m->version;
     $this->originalSourceId = $originalSourceId;
     $this->originalMsgId = $originalMsgId;
     $validSourceId = Agent::checkSourceId($originalSourceId);
     if (!$validSourceId) {
         RegisterError::invalidSourceId($agent->sourceId, $originalMsgId);
         exit;
     } else {
         $agent = new Agent($originalSourceId);
         if (!$agent->isRegistered()) {
             RegisterError::notRegisteredError($originalSourceId, $originalMsgId);
             exit;
         } else {
             $msgId = $dom->getElementsByTagName('SIF_RequestMsgId')->item(0)->nodeValue;
             if (!RequestObject::validRequestMsgId($msgId)) {
                 RequestError::invalidMsgId($originalSourceId, $originalMsgId);
             } else {
                 $requestObject = new RequestObject($msgId);
                 $sifResponseNode = $dom->getElementsByTagName('SIF_Response')->item(0);
                 $size = strlen($dom->saveXML($sifResponseNode));
                 if (!$requestObject->compareBufferSize($size)) {
                     $categoryCode = "8";
                     $sifCode = "11";
                     $shortDesc = "Response Error";
                     $longDesc = "SIF_Response is larger than requested SIF_MaxBufferSize";
                     $this->createResponseError($agent, $msgId, $categoryCode, $sifCode, $shortDesc, $longDesc);
                     SifLogEntry::CreateSifLogEvents($dom->saveXml($headerNode), 4, 2, 'Invalid buffersize for response to agent ' . $agent->sourceId . ' request');
                     RequestError::invalidBufferSize($originalSourceId, $originalMsgId);
                 } else {
                     $destinationId = $dom->getElementsByTagName('SIF_DestinationId')->item(0)->nodeValue;
                     if (!$requestObject->compareDestinationId($destinationId)) {
                         $categoryCode = "8";
                         $sifCode = "14";
                         $shortDesc = "Response Error";
                         $longDesc = "SIF_DestinationId does not match SIF_SourceId from SIF_Request";
                         $this->createResponseError($agent, $msgId, $categoryCode, $sifCode, $shortDesc, $longDesc);
                         SifLogEntry::CreateSifLogEvents($dom->saveXml($headerNode), 4, 1, 'Invalid destinationId for response to agent ' . $agent->sourceId . ' request');
                         RequestError::invalidDestination($originalSourceId, $originalMsgId);
                     } else {
                         if (RequestObject::validMessageVersion($msgId, $version)) {
                             if (ResponseObject::responseExist($msgId)) {
                                 $responseObject = new ResponseObject($msgId);
                                 $packetNum = $dom->getElementsByTagName('SIF_PacketNumber')->item(0)->nodeValue;
                                 if ($packetNum != $responseObject->nextPacketNum) {
                                     $categoryCode = "8";
                                     $sifCode = "12";
                                     $shortDesc = "SIF_PacketNumber is invalid in SIF_Response";
                                     $longDesc = 'Invalid packet number of ' . $packetNum . ' was expecting ' . $responseObject->nextPacketNum . 'for response to agent ' . $agent->sourceId . ' request';
                                     //$this->createResponseError($agent, $msgId, $categoryCode, $sifCode, $shortDesc, $longDesc);
                                     RequestError::invalidPacketNum($originalSourceId, $originalMsgId, $longDesc);
                                 } else {
                                     $this->setupResponseOld($agent, $msgId, $responseObject);
                                 }
                             } else {
                                 $packetNum = $dom->getElementsByTagName('SIF_PacketNumber')->item(0)->nodeValue;
                                 if ($packetNum != 1) {
                                     $categoryCode = "8";
                                     $sifCode = "12";
                                     $shortDesc = "Response Error";
                                     $longDesc = 'Invalid packet number of ' . $packetNum . ' was expecting 1 for response to agent ' . $agent->sourceId . ' request';
                                     RequestError::invalidPacketNum($originalSourceId, $originalMsgId, $longDesc);
                                 } else {
                                     $this->setupResponseNew($agent, $msgId, $m);
                                 }
                                 //check if packetnum is 1
                             }
                             //check if response with more packets
                         } else {
                             $categoryCode = "8";
                             $sifCode = "13";
                             $shortDesc = "Response Error";
                             $longDesc = "SIF_Response does not match any SIF_Version from SIF_Request.";
                             $this->createResponseError($agent, $msgId, $categoryCode, $sifCode, $shortDesc, $longDesc);
                             RequestError::invalidVersion($originalSourceId, $originalMsgId);
                         }
                         //check if version is valid
                     }
                     // check if valid destination
                 }
                 //check if valid buffer
             }
             //check if valid request message id
         }
         //check if registered
     }
     //check sourceId
 }
Ejemplo n.º 4
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct("The resource could not be found");
 }
Ejemplo n.º 5
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct("Invalid combination for method/endpoint");
 }
Ejemplo n.º 6
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct("Your authentication credentials were rejected");
 }
Ejemplo n.º 7
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct("Please contact sales or support");
 }
Ejemplo n.º 8
0
 /**
  * Constructor.
  *
  * @param PortaText\Command\Descriptor $descriptor The Command descriptor.
  * @param PortaText\Command\Result $result Request result.
  */
 public function __construct($descriptor = null, $result = null)
 {
     parent::__construct("There was an error with how the request was sent", $descriptor, $result);
 }
Ejemplo n.º 9
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct("Internal server error, please contact support");
 }