Пример #1
0
 /**
  *
  * Retrieve policy Datas
  * @param string $policyID
  * @param boolean $allDatas
  * @throws Exception
  * @return Policy
  */
 public function getPolicy($policyID)
 {
     $policy = new Policy();
     $policy->setId($policyID);
     $url = E3_PROV_URL_POLICY . "/" . rawurlencode($policy->getId());
     $policy = null;
     $xml = null;
     $reply = $this->restClient->makeCall($url, "GET");
     $xml = !empty($reply) ? simplexml_load_string($reply->getPayload()) : null;
     if ($reply->getHTTPCode() === "200") {
         $policy = Policy::fromXML($xml->policy);
     } else {
         $error = "Unable to retrieve policy with id: " . $policyID;
         // default error msg
         if ($xml != null) {
             $errorText = $xml->xpath('/response/error/errorText');
             // error msg from response
             if (count($errorText) > 0) {
                 $error = (string) $errorText[0];
             }
         }
         PolicyManager::error($error);
     }
     return $policy;
 }