private function _setKey(SSLKey &$key, $insertMode = FALSE) { $method = "PUT"; $url = E3_PROV_URL_KEY . "/" . rawurlencode($key->getId()); if ($insertMode) { $method = "POST"; $url = E3_PROV_URL_KEY; } /** * Send the XML payload the the Provisioning Backend */ $xmlKey = $key->toXML(); LoggerInterface::log(($insertMode ? "Creating" : "Updating") . " SSLKey: {$xml}\nEndpoint: ({$method}) {$url}", LoggerInterface::INFO); $reply = $this->restClient->makeCall($url, $method, $xmlKey); $xml = simplexml_load_string($reply->getPayload()); // TODO: figure out why successful adds sometime return code 100 if ($reply->getHTTPCode() === "200" || $reply->getHTTPCode() === "100") { if ($insertMode) { if ($key->getId() == NULL) { $key->setId((string) $xml->id); } } return $key; } else { throw new Exception(!empty($xml->error) ? $xml->error->errorText : UNDEFINED_ERROR_TEXT); } }