Example #1
0
 /**
  *
  * Insert/Update an AuthIdsType on the database
  * @param AuthIdsType $bucket
  * @throws Exception
  */
 public function setAuthIdsType($policyId, AuthIdsType &$bucket, $insertMode = FALSE)
 {
     $method = "PUT";
     $url = E3_PROV_URL_POLICY . "/" . rawurlencode($policyId) . "/quotaRLBuckets/" . rawurlencode($bucket->getId());
     if ($insertMode) {
         $method = "POST";
         $url = E3_PROV_URL_POLICY . "/" . rawurlencode($policyId) . "/quotaRLBuckets/";
     }
     /**
      * Send the XML payload the the Provisioning Backend
      */
     $restClient = new RestClient();
     $reply = $restClient->makeCall($url, $method, $bucket->toXML());
     if ($insertMode) {
         $bucket = new AuthIdsType();
         if ($bucket->getId() == NULL) {
             $xml = simplexml_load_string($reply->getPayload());
             $bucket->setId((string) $xml->id);
         }
     }
 }
Example #2
0
 public static function fromXML(SimpleXMLElement $xml)
 {
     $policy = new Policy();
     $policy->id = (string) $xml->id;
     if ($xml->apiIds->apiId) {
         foreach ($xml->apiIds->apiId as $apiId) {
             $policy->apiIds[] = current($apiId);
         }
     }
     if ($xml->authIds->quotaRLBucket) {
         foreach ($xml->authIds->quotaRLBucket as $bucket) {
             $policy->authIds[] = AuthIdsType::fromXML($bucket);
         }
     }
     if ($xml->contexts->context) {
         foreach ($xml->contexts->context as $contextXML) {
             $policy->contexts[] = Context::fromXML($contextXML);
         }
     }
     $policy->tdrOnLimitReached = (string) $xml->tdrOnLimitReached['type'];
     $policy->tdr = $xml->tdr ? TdrData::fromXML($xml->tdr) : new TdrData();
     if ($xml->properties && $xml->properties->property) {
         foreach ($xml->properties->property as $prop) {
             $policy->properties[(string) $prop['name']] = (string) $prop;
         }
     }
     if (!empty($policy->properties)) {
         ksort($policy->properties);
     }
     if ($xml->headerTransformations && $xml->headerTransformations->headerTransformation) {
         foreach ($xml->headerTransformations->headerTransformation as $transform) {
             $policy->headerTransformations[] = HeaderTransformation::fromXML($transform);
         }
     }
     return $policy;
 }
Example #3
0
             $validationErrors[$quotaName] = PolicyController::displayNameForField($quotaName) . $translator->translate(" Threshold must be a positive integer if you want to include this Quota. ");
             $success = false;
         } elseif (!$validate_int->isValid($warning) || !$validate_gte_0->isValid($warning)) {
             $validationErrors[$quotaName] = PolicyController::displayNameForField($quotaName) . $translator->translate(" Warning must be a non-negative integer. ");
             $success = false;
         } elseif (Zend_Validate::is($warning, 'GreaterThan', array('min' => $threshold))) {
             $validationErrors[$quotaName] = PolicyController::displayNameForField($quotaName) . $translator->translate(" Warning may not be greater than the Threshold. ");
             $success = false;
         }
     }
     return $success;
 }
 /**
  * Creates and returns a new Context value for use with a Policy.  Assigns default
  * values to the Id and Status fields.
  *
  * @return Context  A new Context object with default values
  */