Example #1
0
 private function processProvideObjects($objectNode)
 {
     $objects = $objectNode->getElementsByTagName('SIF_Object');
     foreach ($objects as $object) {
         $objectName = $object->getAttribute('ObjectName');
         $contexts = $object->getElementsByTagName('SIF_Context');
         if (!DataObject::objectExists($objectName)) {
             ProvisionError::invalidObject($this->originalSourceId, $this->originalMsgId, $objectName);
             if (CODELEVEL != 3) {
                 exit;
             } else {
                 return false;
             }
         } else {
             if ($contexts->length != 0) {
                 foreach ($contexts as $context) {
                     $contextId = Context::getContextId($context->nodeValue);
                     if (DataObject::alreadyProvided($this->agent->agentId, $objectName, $contextId)) {
                         ProvisionError::alreadyProvided($this->originalSourceId, $this->originalMsgId, $objectName);
                         if (CODELEVEL != 3) {
                             exit;
                         } else {
                             return false;
                         }
                     } else {
                         if (!DataObject::allowedToProvide($this->agent->agentId, $objectName, $contextId)) {
                             ProvisionError::invalidPermissionToProvide($this->originalSourceId, $this->originalMsgId, $objectName);
                             if (CODELEVEL != 3) {
                                 exit;
                             } else {
                                 return false;
                             }
                         } else {
                             $dataObject = new DataObject($objectName);
                             $dataObject->contextId = $contextId;
                             array_push($this->provideObjects, $dataObject);
                         }
                         //check if allowed to provide
                     }
                     //check if already provided
                 }
             } else {
                 if (DataObject::alreadyProvided($this->agent->agentId, $objectName)) {
                     ProvisionError::alreadyProvided($this->originalSourceId, $this->originalMsgId, $objectName);
                     if (CODELEVEL != 3) {
                         exit;
                     } else {
                         return false;
                     }
                 } else {
                     if (!DataObject::allowedToProvide($this->agent->agentId, $objectName)) {
                         ProvisionError::invalidPermissionToProvide($this->originalSourceId, $this->originalMsgId, $objectName);
                         if (CODELEVEL != 3) {
                             exit;
                         } else {
                             return false;
                         }
                     } else {
                         $dataObject = new DataObject($objectName);
                         array_push($this->provideObjects, $dataObject);
                     }
                     //check if allowed to provide
                 }
                 //check if already provided
             }
             //check if there are contexts
         }
         //check if object exist
     }
     //loop through objects
 }
Example #2
0
 private function processUnProvide()
 {
     $dom = $this->dom;
     $headerNode = $dom->getElementsByTagName('SIF_Header')->item(0);
     $originalMsgId = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
     $originalSourceId = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
     $originalTimestamp = $headerNode->getElementsByTagName('SIF_Timestamp')->item(0)->nodeValue;
     $this->originalSourceId = $originalSourceId;
     $this->originalMsgId = $originalMsgId;
     $validSourceId = Agent::checkSourceId($originalSourceId);
     if (!$validSourceId) {
         ProvisionError::invalidSourceId($originalSourceId, $originalMsgId);
         exit;
     } else {
         $agent = new Agent($originalSourceId);
         $this->agent = $agent;
         if (!$this->agent->isRegistered()) {
             RegisterError::notRegisteredError($originalSourceId, $originalMsgId);
             exit;
         } else {
             $objects = $dom->getElementsByTagName('SIF_Object');
             foreach ($objects as $object) {
                 $objectName = $object->getAttribute('ObjectName');
                 $contexts = $object->getElementsByTagName('SIF_Context');
                 if (!DataObject::objectExists($objectName)) {
                     ProvisionError::invalidObject($originalSourceId, $originalMsgId, $objectName);
                     exit;
                 } else {
                     if ($contexts->length != 0) {
                         foreach ($contexts as $context) {
                             if (Context::isValidContext($context->nodeValue)) {
                                 $contextId = Context::getContextId($context->nodeValue);
                                 if (DataObject::alreadyProvided($agent->agentId, $objectName, $contextId)) {
                                     ProvisionError::alreadyProvided($originalSourceId, $originalMsgId, $objectName);
                                     exit;
                                 } else {
                                     if (!DataObject::allowedToProvide($agent->agentId, $objectName, $contextId)) {
                                         ProvisionError::invalidPermissionToProvide($originalSourceId, $originalMsgId, $objectName);
                                         exit;
                                     } else {
                                         $dataObject = new DataObject($objectName);
                                         $dataObject->contextId = $contextId;
                                         array_push($this->unProvideObjects, $dataObject);
                                     }
                                     //check if allowed to provide
                                 }
                                 //check if already provided
                             } else {
                                 ProvisionError::contextNotSupportedError($originalSourceId, $originalMsgId);
                                 exit;
                             }
                         }
                         //loop through contexts
                     } else {
                         if (DataObject::alreadyProvided($agent->agentId, $objectName)) {
                             ProvisionError::alreadyProvided($originalSourceId, $originalMsgId, $objectName);
                             exit;
                         } else {
                             if (!DataObject::allowedToProvide($agent->agentId, $objectName)) {
                                 ProvisionError::invalidPermissionToProvide($originalSourceId, $originalMsgId, $objectName);
                                 exit;
                             } else {
                                 $dataObject = new DataObject($objectName);
                                 array_push($this->unProvideObjects, $dataObject);
                             }
                             //check if allowed to provide
                         }
                         //check if already provided
                     }
                     //check for contexts
                 }
                 //check if object is valid
             }
             //loop through objects
         }
         //check if registered
     }
     //check sourceId
 }