diff --git a/Drupal/source/resources/WebRole/resources/phpazure.zip b/Drupal/source/resources/WebRole/resources/phpazure.zip
new file mode 100644
index 0000000..87a8b9a
Binary files /dev/null and b/Drupal/source/resources/WebRole/resources/phpazure.zip differ
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/AutoLoader.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/AutoLoader.php
deleted file mode 100644
index b535734..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/AutoLoader.php
+++ /dev/null
@@ -1,74 +0,0 @@
- 5,
- 'strictredirects' => false,
- 'useragent' => 'Microsoft_Http_Client',
- 'timeout' => 10,
- 'adapter' => 'Microsoft_Http_Client_Adapter_Socket',
- 'httpversion' => self::HTTP_1,
- 'keepalive' => false,
- 'storeresponse' => true,
- 'strict' => true,
- 'output_stream' => false,
- );
-
- /**
- * The adapter used to preform the actual connection to the server
- *
- * @var Microsoft_Http_Client_Adapter_Interface
- */
- protected $adapter = null;
-
- /**
- * Request URI
- *
- * @var Microsoft_Uri_Http
- */
- protected $uri = null;
-
- /**
- * Associative array of request headers
- *
- * @var array
- */
- protected $headers = array();
-
- /**
- * HTTP request method
- *
- * @var string
- */
- protected $method = self::GET;
-
- /**
- * Associative array of GET parameters
- *
- * @var array
- */
- protected $paramsGet = array();
-
- /**
- * Assiciative array of POST parameters
- *
- * @var array
- */
- protected $paramsPost = array();
-
- /**
- * Request body content type (for POST requests)
- *
- * @var string
- */
- protected $enctype = null;
-
- /**
- * The raw post data to send. Could be set by setRawData($data, $enctype).
- *
- * @var string
- */
- protected $raw_post_data = null;
-
- /**
- * HTTP Authentication settings
- *
- * Expected to be an associative array with this structure:
- * $this->auth = array('user' => 'username', 'password' => 'password', 'type' => 'basic')
- * Where 'type' should be one of the supported authentication types (see the AUTH_*
- * constants), for example 'basic' or 'digest'.
- *
- * If null, no authentication will be used.
- *
- * @var array|null
- */
- protected $auth;
-
- /**
- * File upload arrays (used in POST requests)
- *
- * An associative array, where each element is of the format:
- * 'name' => array('filename.txt', 'text/plain', 'This is the actual file contents')
- *
- * @var array
- */
- protected $files = array();
-
- /**
- * The client's cookie jar
- *
- * @var Microsoft_Http_CookieJar
- */
- protected $cookiejar = null;
-
- /**
- * The last HTTP request sent by the client, as string
- *
- * @var string
- */
- protected $last_request = null;
-
- /**
- * The last HTTP response received by the client
- *
- * @var Microsoft_Http_Response
- */
- protected $last_response = null;
-
- /**
- * Redirection counter
- *
- * @var int
- */
- protected $redirectCounter = 0;
-
- /**
- * Fileinfo magic database resource
- *
- * This varaiable is populated the first time _detectFileMimeType is called
- * and is then reused on every call to this method
- *
- * @var resource
- */
- static protected $_fileInfoDb = null;
-
- /**
- * Contructor method. Will create a new HTTP client. Accepts the target
- * URL and optionally configuration array.
- *
- * @param Microsoft_Uri_Http|string $uri
- * @param array $config Configuration key-value pairs.
- */
- public function __construct($uri = null, $config = null)
- {
- if ($uri !== null) {
- $this->setUri($uri);
- }
- if ($config !== null) {
- $this->setConfig($config);
- }
- }
-
- /**
- * Set the URI for the next request
- *
- * @param Microsoft_Uri_Http|string $uri
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setUri($uri)
- {
- if (is_string($uri)) {
- $uri = Microsoft_Uri::factory($uri);
- }
-
- if (!$uri instanceof Microsoft_Uri_Http) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('Passed parameter is not a valid HTTP URI.');
- }
-
- // Set auth if username and password has been specified in the uri
- if ($uri->getUsername() && $uri->getPassword()) {
- $this->setAuth($uri->getUsername(), $uri->getPassword());
- }
-
- // We have no ports, set the defaults
- if (! $uri->getPort()) {
- $uri->setPort(($uri->getScheme() == 'https' ? 443 : 80));
- }
-
- $this->uri = $uri;
-
- return $this;
- }
-
- /**
- * Get the URI for the next request
- *
- * @param boolean $as_string If true, will return the URI as a string
- * @return Microsoft_Uri_Http|string
- */
- public function getUri($as_string = false)
- {
- if ($as_string && $this->uri instanceof Microsoft_Uri_Http) {
- return $this->uri->__toString();
- } else {
- return $this->uri;
- }
- }
-
- /**
- * Set configuration parameters for this HTTP client
- *
- * @param Microsoft_Config | array $config
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setConfig($config = array())
- {
- if ($config instanceof Microsoft_Config) {
- $config = $config->toArray();
-
- } elseif (! is_array($config)) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('Array expected, got ' . gettype($config));
- }
-
- foreach ($config as $k => $v) {
- $this->config[strtolower($k)] = $v;
- }
-
- // Pass configuration options to the adapter if it exists
- if ($this->adapter instanceof Microsoft_Http_Client_Adapter_Interface) {
- $this->adapter->setConfig($config);
- }
-
- return $this;
- }
-
- /**
- * Set the next request's method
- *
- * Validated the passed method and sets it. If we have files set for
- * POST requests, and the new method is not POST, the files are silently
- * dropped.
- *
- * @param string $method
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setMethod($method = self::GET)
- {
- if (! preg_match('/^[^\x00-\x1f\x7f-\xff\(\)<>@,;:\\\\"\/\[\]\?={}\s]+$/', $method)) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("'{$method}' is not a valid HTTP request method.");
- }
-
- if ($method == self::POST && $this->enctype === null) {
- $this->setEncType(self::ENC_URLENCODED);
- }
-
- $this->method = $method;
-
- return $this;
- }
-
- /**
- * Set one or more request headers
- *
- * This function can be used in several ways to set the client's request
- * headers:
- * 1. By providing two parameters: $name as the header to set (eg. 'Host')
- * and $value as it's value (eg. 'www.example.com').
- * 2. By providing a single header string as the only parameter
- * eg. 'Host: www.example.com'
- * 3. By providing an array of headers as the first parameter
- * eg. array('host' => 'www.example.com', 'x-foo: bar'). In This case
- * the function will call itself recursively for each array item.
- *
- * @param string|array $name Header name, full header string ('Header: value')
- * or an array of headers
- * @param mixed $value Header value or null
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setHeaders($name, $value = null)
- {
- // If we got an array, go recusive!
- if (is_array($name)) {
- foreach ($name as $k => $v) {
- if (is_string($k)) {
- $this->setHeaders($k, $v);
- } else {
- $this->setHeaders($v, null);
- }
- }
- } else {
- // Check if $name needs to be split
- if ($value === null && (strpos($name, ':') > 0)) {
- list($name, $value) = explode(':', $name, 2);
- }
-
- // Make sure the name is valid if we are in strict mode
- if ($this->config['strict'] && (! preg_match('/^[a-zA-Z0-9-]+$/', $name))) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("{$name} is not a valid HTTP header name");
- }
-
- $normalized_name = strtolower($name);
-
- // If $value is null or false, unset the header
- if ($value === null || $value === false) {
- unset($this->headers[$normalized_name]);
-
- // Else, set the header
- } else {
- // Header names are stored lowercase internally.
- if (is_string($value)) {
- $value = trim($value);
- }
- $this->headers[$normalized_name] = array($name, $value);
- }
- }
-
- return $this;
- }
-
- /**
- * Get the value of a specific header
- *
- * Note that if the header has more than one value, an array
- * will be returned.
- *
- * @param string $key
- * @return string|array|null The header value or null if it is not set
- */
- public function getHeader($key)
- {
- $key = strtolower($key);
- if (isset($this->headers[$key])) {
- return $this->headers[$key][1];
- } else {
- return null;
- }
- }
-
- /**
- * Set a GET parameter for the request. Wrapper around _setParameter
- *
- * @param string|array $name
- * @param string $value
- * @return Microsoft_Http_Client
- */
- public function setParameterGet($name, $value = null)
- {
- if (is_array($name)) {
- foreach ($name as $k => $v)
- $this->_setParameter('GET', $k, $v);
- } else {
- $this->_setParameter('GET', $name, $value);
- }
-
- return $this;
- }
-
- /**
- * Set a POST parameter for the request. Wrapper around _setParameter
- *
- * @param string|array $name
- * @param string $value
- * @return Microsoft_Http_Client
- */
- public function setParameterPost($name, $value = null)
- {
- if (is_array($name)) {
- foreach ($name as $k => $v)
- $this->_setParameter('POST', $k, $v);
- } else {
- $this->_setParameter('POST', $name, $value);
- }
-
- return $this;
- }
-
- /**
- * Set a GET or POST parameter - used by SetParameterGet and SetParameterPost
- *
- * @param string $type GET or POST
- * @param string $name
- * @param string $value
- * @return null
- */
- protected function _setParameter($type, $name, $value)
- {
- $parray = array();
- $type = strtolower($type);
- switch ($type) {
- case 'get':
- $parray = &$this->paramsGet;
- break;
- case 'post':
- $parray = &$this->paramsPost;
- break;
- }
-
- if ($value === null) {
- if (isset($parray[$name])) unset($parray[$name]);
- } else {
- $parray[$name] = $value;
- }
- }
-
- /**
- * Get the number of redirections done on the last request
- *
- * @return int
- */
- public function getRedirectionsCount()
- {
- return $this->redirectCounter;
- }
-
- /**
- * Set HTTP authentication parameters
- *
- * $type should be one of the supported types - see the self::AUTH_*
- * constants.
- *
- * To enable authentication:
- *
- * $this->setAuth('shahar', 'secret', Microsoft_Http_Client::AUTH_BASIC);
- *
- *
- * To disable authentication:
- *
- * $this->setAuth(false);
- *
- *
- * @see http://www.faqs.org/rfcs/rfc2617.html
- * @param string|false $user User name or false disable authentication
- * @param string $password Password
- * @param string $type Authentication type
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setAuth($user, $password = '', $type = self::AUTH_BASIC)
- {
- // If we got false or null, disable authentication
- if ($user === false || $user === null) {
- $this->auth = null;
-
- // Clear the auth information in the uri instance as well
- if ($this->uri instanceof Microsoft_Uri_Http) {
- $this->getUri()->setUsername('');
- $this->getUri()->setPassword('');
- }
- // Else, set up authentication
- } else {
- // Check we got a proper authentication type
- if (! defined('self::AUTH_' . strtoupper($type))) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("Invalid or not supported authentication type: '$type'");
- }
-
- $this->auth = array(
- 'user' => (string) $user,
- 'password' => (string) $password,
- 'type' => $type
- );
- }
-
- return $this;
- }
-
- /**
- * Set the HTTP client's cookie jar.
- *
- * A cookie jar is an object that holds and maintains cookies across HTTP requests
- * and responses.
- *
- * @param Microsoft_Http_CookieJar|boolean $cookiejar Existing cookiejar object, true to create a new one, false to disable
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setCookieJar($cookiejar = true)
- {
- if (! class_exists('Microsoft_Http_CookieJar')) {
- require_once 'Microsoft/Http/CookieJar.php';
- }
-
- if ($cookiejar instanceof Microsoft_Http_CookieJar) {
- $this->cookiejar = $cookiejar;
- } elseif ($cookiejar === true) {
- $this->cookiejar = new Microsoft_Http_CookieJar();
- } elseif (! $cookiejar) {
- $this->cookiejar = null;
- } else {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('Invalid parameter type passed as CookieJar');
- }
-
- return $this;
- }
-
- /**
- * Return the current cookie jar or null if none.
- *
- * @return Microsoft_Http_CookieJar|null
- */
- public function getCookieJar()
- {
- return $this->cookiejar;
- }
-
- /**
- * Add a cookie to the request. If the client has no Cookie Jar, the cookies
- * will be added directly to the headers array as "Cookie" headers.
- *
- * @param Microsoft_Http_Cookie|string $cookie
- * @param string|null $value If "cookie" is a string, this is the cookie value.
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setCookie($cookie, $value = null)
- {
- if (! class_exists('Microsoft_Http_Cookie')) {
- require_once 'Microsoft/Http/Cookie.php';
- }
-
- if (is_array($cookie)) {
- foreach ($cookie as $c => $v) {
- if (is_string($c)) {
- $this->setCookie($c, $v);
- } else {
- $this->setCookie($v);
- }
- }
-
- return $this;
- }
-
- if ($value !== null) {
- $value = urlencode($value);
- }
-
- if (isset($this->cookiejar)) {
- if ($cookie instanceof Microsoft_Http_Cookie) {
- $this->cookiejar->addCookie($cookie);
- } elseif (is_string($cookie) && $value !== null) {
- $cookie = Microsoft_Http_Cookie::fromString("{$cookie}={$value}", $this->uri);
- $this->cookiejar->addCookie($cookie);
- }
- } else {
- if ($cookie instanceof Microsoft_Http_Cookie) {
- $name = $cookie->getName();
- $value = $cookie->getValue();
- $cookie = $name;
- }
-
- if (preg_match("/[=,; \t\r\n\013\014]/", $cookie)) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("Cookie name cannot contain these characters: =,; \t\r\n\013\014 ({$cookie})");
- }
-
- $value = addslashes($value);
-
- if (! isset($this->headers['cookie'])) {
- $this->headers['cookie'] = array('Cookie', '');
- }
- $this->headers['cookie'][1] .= $cookie . '=' . $value . '; ';
- }
-
- return $this;
- }
-
- /**
- * Set a file to upload (using a POST request)
- *
- * Can be used in two ways:
- *
- * 1. $data is null (default): $filename is treated as the name if a local file which
- * will be read and sent. Will try to guess the content type using mime_content_type().
- * 2. $data is set - $filename is sent as the file name, but $data is sent as the file
- * contents and no file is read from the file system. In this case, you need to
- * manually set the Content-Type ($ctype) or it will default to
- * application/octet-stream.
- *
- * @param string $filename Name of file to upload, or name to save as
- * @param string $formname Name of form element to send as
- * @param string $data Data to send (if null, $filename is read and sent)
- * @param string $ctype Content type to use (if $data is set and $ctype is
- * null, will be application/octet-stream)
- * @return Microsoft_Http_Client
- * @throws Microsoft_Http_Client_Exception
- */
- public function setFileUpload($filename, $formname, $data = null, $ctype = null)
- {
- if ($data === null) {
- if (($data = @file_get_contents($filename)) === false) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("Unable to read file '{$filename}' for upload");
- }
-
- if (! $ctype) {
- $ctype = $this->_detectFileMimeType($filename);
- }
- }
-
- // Force enctype to multipart/form-data
- $this->setEncType(self::ENC_FORMDATA);
-
- $this->files[] = array(
- 'formname' => $formname,
- 'filename' => basename($filename),
- 'ctype' => $ctype,
- 'data' => $data
- );
-
- return $this;
- }
-
- /**
- * Set the encoding type for POST data
- *
- * @param string $enctype
- * @return Microsoft_Http_Client
- */
- public function setEncType($enctype = self::ENC_URLENCODED)
- {
- $this->enctype = $enctype;
-
- return $this;
- }
-
- /**
- * Set the raw (already encoded) POST data.
- *
- * This function is here for two reasons:
- * 1. For advanced user who would like to set their own data, already encoded
- * 2. For backwards compatibilty: If someone uses the old post($data) method.
- * this method will be used to set the encoded data.
- *
- * $data can also be stream (such as file) from which the data will be read.
- *
- * @param string|resource $data
- * @param string $enctype
- * @return Microsoft_Http_Client
- */
- public function setRawData($data, $enctype = null)
- {
- $this->raw_post_data = $data;
- $this->setEncType($enctype);
- if (is_resource($data)) {
- // We've got stream data
- $stat = @fstat($data);
- if($stat) {
- $this->setHeaders(self::CONTENT_LENGTH, $stat['size']);
- }
- }
- return $this;
- }
-
- /**
- * Clear all GET and POST parameters
- *
- * Should be used to reset the request parameters if the client is
- * used for several concurrent requests.
- *
- * clearAll parameter controls if we clean just parameters or also
- * headers and last_*
- *
- * @param bool $clearAll Should all data be cleared?
- * @return Microsoft_Http_Client
- */
- public function resetParameters($clearAll = false)
- {
- // Reset parameter data
- $this->paramsGet = array();
- $this->paramsPost = array();
- $this->files = array();
- $this->raw_post_data = null;
-
- if($clearAll) {
- $this->headers = array();
- $this->last_request = null;
- $this->last_response = null;
- } else {
- // Clear outdated headers
- if (isset($this->headers[strtolower(self::CONTENT_TYPE)])) {
- unset($this->headers[strtolower(self::CONTENT_TYPE)]);
- }
- if (isset($this->headers[strtolower(self::CONTENT_LENGTH)])) {
- unset($this->headers[strtolower(self::CONTENT_LENGTH)]);
- }
- }
-
- return $this;
- }
-
- /**
- * Get the last HTTP request as string
- *
- * @return string
- */
- public function getLastRequest()
- {
- return $this->last_request;
- }
-
- /**
- * Get the last HTTP response received by this client
- *
- * If $config['storeresponse'] is set to false, or no response was
- * stored yet, will return null
- *
- * @return Microsoft_Http_Response or null if none
- */
- public function getLastResponse()
- {
- return $this->last_response;
- }
-
- /**
- * Load the connection adapter
- *
- * While this method is not called more than one for a client, it is
- * seperated from ->request() to preserve logic and readability
- *
- * @param Microsoft_Http_Client_Adapter_Interface|string $adapter
- * @return null
- * @throws Microsoft_Http_Client_Exception
- */
- public function setAdapter($adapter)
- {
- if (is_string($adapter)) {
- if (!class_exists($adapter)) {
- @require_once( str_replace('_', '/', $adapter) . '.php' );
- }
-
- $adapter = new $adapter;
- }
-
- if (! $adapter instanceof Microsoft_Http_Client_Adapter_Interface) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('Passed adapter is not a HTTP connection adapter');
- }
-
- $this->adapter = $adapter;
- $config = $this->config;
- unset($config['adapter']);
- $this->adapter->setConfig($config);
- }
-
- /**
- * Load the connection adapter
- *
- * @return Microsoft_Http_Client_Adapter_Interface $adapter
- */
- public function getAdapter()
- {
- return $this->adapter;
- }
-
- /**
- * Set streaming for received data
- *
- * @param string|boolean $streamfile Stream file, true for temp file, false/null for no streaming
- * @return Microsoft_Http_Client
- */
- public function setStream($streamfile = true)
- {
- $this->setConfig(array("output_stream" => $streamfile));
- return $this;
- }
-
- /**
- * Get status of streaming for received data
- * @return boolean|string
- */
- public function getStream()
- {
- return $this->config["output_stream"];
- }
-
- /**
- * Create temporary stream
- *
- * @return resource
- */
- protected function _openTempStream()
- {
- $this->_stream_name = $this->config['output_stream'];
- if(!is_string($this->_stream_name)) {
- // If name is not given, create temp name
- $this->_stream_name = tempnam(isset($this->config['stream_tmp_dir'])?$this->config['stream_tmp_dir']:sys_get_temp_dir(),
- 'Microsoft_Http_Client');
- }
-
- $fp = fopen($this->_stream_name, "w+b");
- if(!$fp) {
- $this->close();
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("Could not open temp file $name");
-
- }
- return $fp;
- }
-
- /**
- * Send the HTTP request and return an HTTP response object
- *
- * @param string $method
- * @return Microsoft_Http_Response
- * @throws Microsoft_Http_Client_Exception
- */
- public function request($method = null)
- {
- if (! $this->uri instanceof Microsoft_Uri_Http) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('No valid URI has been passed to the client');
- }
-
- if ($method) {
- $this->setMethod($method);
- }
- $this->redirectCounter = 0;
- $response = null;
-
- // Make sure the adapter is loaded
- if ($this->adapter == null) {
- $this->setAdapter($this->config['adapter']);
- }
-
- // Send the first request. If redirected, continue.
- do {
- // Clone the URI and add the additional GET parameters to it
- $uri = clone $this->uri;
- if (! empty($this->paramsGet)) {
- $query = $uri->getQuery();
- if (! empty($query)) {
- $query .= '&';
- }
- $query .= http_build_query($this->paramsGet, null, '&');
-
- $uri->setQuery($query);
- }
-
- $body = $this->_prepareBody();
- $headers = $this->_prepareHeaders();
-
- // check that adapter supports streaming before using it
- if(is_resource($body) && !($this->adapter instanceof Microsoft_Http_Client_Adapter_Stream)) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('Adapter does not support streaming');
- }
-
- // Open the connection, send the request and read the response
- $this->adapter->connect($uri->getHost(), $uri->getPort(),
- ($uri->getScheme() == 'https' ? true : false));
-
- if($this->config['output_stream']) {
- if($this->adapter instanceof Microsoft_Http_Client_Adapter_Stream) {
- $stream = $this->_openTempStream();
- $this->adapter->setOutputStream($stream);
- } else {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('Adapter does not support streaming');
- }
- }
-
- $this->last_request = $this->adapter->write($this->method,
- $uri, $this->config['httpversion'], $headers, $body);
-
- $response = $this->adapter->read();
- if (! $response) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception('Unable to read response, or response is empty');
- }
-
- if($this->config['output_stream']) {
- rewind($stream);
- // cleanup the adapter
- $this->adapter->setOutputStream(null);
- $response = Microsoft_Http_Response_Stream::fromStream($response, $stream);
- $response->setStreamName($this->_stream_name);
- if(!is_string($this->config['output_stream'])) {
- // we used temp name, will need to clean up
- $response->setCleanup(true);
- }
- } else {
- $response = Microsoft_Http_Response::fromString($response);
- }
-
- if ($this->config['storeresponse']) {
- $this->last_response = $response;
- }
-
- // Load cookies into cookie jar
- if (isset($this->cookiejar)) {
- $this->cookiejar->addCookiesFromResponse($response, $uri);
- }
-
- // If we got redirected, look for the Location header
- if ($response->isRedirect() && ($location = $response->getHeader('location'))) {
-
- // Check whether we send the exact same request again, or drop the parameters
- // and send a GET request
- if ($response->getStatus() == 303 ||
- ((! $this->config['strictredirects']) && ($response->getStatus() == 302 ||
- $response->getStatus() == 301))) {
-
- $this->resetParameters();
- $this->setMethod(self::GET);
- }
-
- // If we got a well formed absolute URI
- if (Microsoft_Uri_Http::check($location)) {
- $this->setHeaders('host', null);
- $this->setUri($location);
-
- } else {
-
- // Split into path and query and set the query
- if (strpos($location, '?') !== false) {
- list($location, $query) = explode('?', $location, 2);
- } else {
- $query = '';
- }
- $this->uri->setQuery($query);
-
- // Else, if we got just an absolute path, set it
- if(strpos($location, '/') === 0) {
- $this->uri->setPath($location);
-
- // Else, assume we have a relative path
- } else {
- // Get the current path directory, removing any trailing slashes
- $path = $this->uri->getPath();
- $path = rtrim(substr($path, 0, strrpos($path, '/')), "/");
- $this->uri->setPath($path . '/' . $location);
- }
- }
- ++$this->redirectCounter;
-
- } else {
- // If we didn't get any location, stop redirecting
- break;
- }
-
- } while ($this->redirectCounter < $this->config['maxredirects']);
-
- return $response;
- }
-
- /**
- * Prepare the request headers
- *
- * @return array
- */
- protected function _prepareHeaders()
- {
- $headers = array();
-
- // Set the host header
- if (! isset($this->headers['host'])) {
- $host = $this->uri->getHost();
-
- // If the port is not default, add it
- if (! (($this->uri->getScheme() == 'http' && $this->uri->getPort() == 80) ||
- ($this->uri->getScheme() == 'https' && $this->uri->getPort() == 443))) {
- $host .= ':' . $this->uri->getPort();
- }
-
- $headers[] = "Host: {$host}";
- }
-
- // Set the connection header
- if (! isset($this->headers['connection'])) {
- if (! $this->config['keepalive']) {
- $headers[] = "Connection: close";
- }
- }
-
- // Set the Accept-encoding header if not set - depending on whether
- // zlib is available or not.
- if (! isset($this->headers['accept-encoding'])) {
- if (function_exists('gzinflate')) {
- $headers[] = 'Accept-encoding: gzip, deflate';
- } else {
- $headers[] = 'Accept-encoding: identity';
- }
- }
-
- // Set the Content-Type header
- if ($this->method == self::POST &&
- (! isset($this->headers[strtolower(self::CONTENT_TYPE)]) && isset($this->enctype))) {
-
- $headers[] = self::CONTENT_TYPE . ': ' . $this->enctype;
- }
-
- // Set the user agent header
- if (! isset($this->headers['user-agent']) && isset($this->config['useragent'])) {
- $headers[] = "User-Agent: {$this->config['useragent']}";
- }
-
- // Set HTTP authentication if needed
- if (is_array($this->auth)) {
- $auth = self::encodeAuthHeader($this->auth['user'], $this->auth['password'], $this->auth['type']);
- $headers[] = "Authorization: {$auth}";
- }
-
- // Load cookies from cookie jar
- if (isset($this->cookiejar)) {
- $cookstr = $this->cookiejar->getMatchingCookies($this->uri,
- true, Microsoft_Http_CookieJar::COOKIE_STRING_CONCAT);
-
- if ($cookstr) {
- $headers[] = "Cookie: {$cookstr}";
- }
- }
-
- // Add all other user defined headers
- foreach ($this->headers as $header) {
- list($name, $value) = $header;
- if (is_array($value)) {
- $value = implode(', ', $value);
- }
-
- $headers[] = "$name: $value";
- }
-
- return $headers;
- }
-
- /**
- * Prepare the request body (for POST and PUT requests)
- *
- * @return string
- * @throws Microsoft_Http_Client_Exception
- */
- protected function _prepareBody()
- {
- // According to RFC2616, a TRACE request should not have a body.
- if ($this->method == self::TRACE) {
- return '';
- }
-
- if (isset($this->raw_post_data) && is_resource($this->raw_post_data)) {
- return $this->raw_post_data;
- }
- // If mbstring overloads substr and strlen functions, we have to
- // override it's internal encoding
- if (function_exists('mb_internal_encoding') &&
- ((int) ini_get('mbstring.func_overload')) & 2) {
-
- $mbIntEnc = mb_internal_encoding();
- mb_internal_encoding('ASCII');
- }
-
- // If we have raw_post_data set, just use it as the body.
- if (isset($this->raw_post_data)) {
- $this->setHeaders(self::CONTENT_LENGTH, strlen($this->raw_post_data));
- if (isset($mbIntEnc)) {
- mb_internal_encoding($mbIntEnc);
- }
-
- return $this->raw_post_data;
- }
-
- $body = '';
-
- // If we have files to upload, force enctype to multipart/form-data
- if (count ($this->files) > 0) {
- $this->setEncType(self::ENC_FORMDATA);
- }
-
- // If we have POST parameters or files, encode and add them to the body
- if (count($this->paramsPost) > 0 || count($this->files) > 0) {
- switch($this->enctype) {
- case self::ENC_FORMDATA:
- // Encode body as multipart/form-data
- $boundary = '---ZENDHTTPCLIENT-' . md5(microtime());
- $this->setHeaders(self::CONTENT_TYPE, self::ENC_FORMDATA . "; boundary={$boundary}");
-
- // Get POST parameters and encode them
- $params = self::_flattenParametersArray($this->paramsPost);
- foreach ($params as $pp) {
- $body .= self::encodeFormData($boundary, $pp[0], $pp[1]);
- }
-
- // Encode files
- foreach ($this->files as $file) {
- $fhead = array(self::CONTENT_TYPE => $file['ctype']);
- $body .= self::encodeFormData($boundary, $file['formname'], $file['data'], $file['filename'], $fhead);
- }
-
- $body .= "--{$boundary}--\r\n";
- break;
-
- case self::ENC_URLENCODED:
- // Encode body as application/x-www-form-urlencoded
- $this->setHeaders(self::CONTENT_TYPE, self::ENC_URLENCODED);
- $body = http_build_query($this->paramsPost, '', '&');
- break;
-
- default:
- if (isset($mbIntEnc)) {
- mb_internal_encoding($mbIntEnc);
- }
-
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("Cannot handle content type '{$this->enctype}' automatically." .
- " Please use Microsoft_Http_Client::setRawData to send this kind of content.");
- break;
- }
- }
-
- // Set the Content-Length if we have a body or if request is POST/PUT
- if ($body || $this->method == self::POST || $this->method == self::PUT) {
- $this->setHeaders(self::CONTENT_LENGTH, strlen($body));
- }
-
- if (isset($mbIntEnc)) {
- mb_internal_encoding($mbIntEnc);
- }
-
- return $body;
- }
-
- /**
- * Helper method that gets a possibly multi-level parameters array (get or
- * post) and flattens it.
- *
- * The method returns an array of (key, value) pairs (because keys are not
- * necessarily unique. If one of the parameters in as array, it will also
- * add a [] suffix to the key.
- *
- * This method is deprecated since Zend Framework 1.9 in favour of
- * self::_flattenParametersArray() and will be dropped in 2.0
- *
- * @deprecated since 1.9
- *
- * @param array $parray The parameters array
- * @param bool $urlencode Whether to urlencode the name and value
- * @return array
- */
- protected function _getParametersRecursive($parray, $urlencode = false)
- {
- // Issue a deprecated notice
- trigger_error("The " . __METHOD__ . " method is deprecated and will be dropped in 2.0.",
- E_USER_NOTICE);
-
- if (! is_array($parray)) {
- return $parray;
- }
- $parameters = array();
-
- foreach ($parray as $name => $value) {
- if ($urlencode) {
- $name = urlencode($name);
- }
-
- // If $value is an array, iterate over it
- if (is_array($value)) {
- $name .= ($urlencode ? '%5B%5D' : '[]');
- foreach ($value as $subval) {
- if ($urlencode) {
- $subval = urlencode($subval);
- }
- $parameters[] = array($name, $subval);
- }
- } else {
- if ($urlencode) {
- $value = urlencode($value);
- }
- $parameters[] = array($name, $value);
- }
- }
-
- return $parameters;
- }
-
- /**
- * Attempt to detect the MIME type of a file using available extensions
- *
- * This method will try to detect the MIME type of a file. If the fileinfo
- * extension is available, it will be used. If not, the mime_magic
- * extension which is deprected but is still available in many PHP setups
- * will be tried.
- *
- * If neither extension is available, the default application/octet-stream
- * MIME type will be returned
- *
- * @param string $file File path
- * @return string MIME type
- */
- protected function _detectFileMimeType($file)
- {
- $type = null;
-
- // First try with fileinfo functions
- if (function_exists('finfo_open')) {
- if (self::$_fileInfoDb === null) {
- self::$_fileInfoDb = @finfo_open(FILEINFO_MIME);
- }
-
- if (self::$_fileInfoDb) {
- $type = finfo_file(self::$_fileInfoDb, $file);
- }
-
- } elseif (function_exists('mime_content_type')) {
- $type = mime_content_type($file);
- }
-
- // Fallback to the default application/octet-stream
- if (! $type) {
- $type = 'application/octet-stream';
- }
-
- return $type;
- }
-
- /**
- * Encode data to a multipart/form-data part suitable for a POST request.
- *
- * @param string $boundary
- * @param string $name
- * @param mixed $value
- * @param string $filename
- * @param array $headers Associative array of optional headers @example ("Content-Transfer-Encoding" => "binary")
- * @return string
- */
- public static function encodeFormData($boundary, $name, $value, $filename = null, $headers = array()) {
- $ret = "--{$boundary}\r\n" .
- 'Content-Disposition: form-data; name="' . $name .'"';
-
- if ($filename) {
- $ret .= '; filename="' . $filename . '"';
- }
- $ret .= "\r\n";
-
- foreach ($headers as $hname => $hvalue) {
- $ret .= "{$hname}: {$hvalue}\r\n";
- }
- $ret .= "\r\n";
-
- $ret .= "{$value}\r\n";
-
- return $ret;
- }
-
- /**
- * Create a HTTP authentication "Authorization:" header according to the
- * specified user, password and authentication method.
- *
- * @see http://www.faqs.org/rfcs/rfc2617.html
- * @param string $user
- * @param string $password
- * @param string $type
- * @return string
- * @throws Microsoft_Http_Client_Exception
- */
- public static function encodeAuthHeader($user, $password, $type = self::AUTH_BASIC)
- {
- $authHeader = null;
-
- switch ($type) {
- case self::AUTH_BASIC:
- // In basic authentication, the user name cannot contain ":"
- if (strpos($user, ':') !== false) {
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("The user name cannot contain ':' in 'Basic' HTTP authentication");
- }
-
- $authHeader = 'Basic ' . base64_encode($user . ':' . $password);
- break;
-
- //case self::AUTH_DIGEST:
- /**
- * @todo Implement digest authentication
- */
- // break;
-
- default:
- /** @see Microsoft_Http_Client_Exception */
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("Not a supported HTTP authentication type: '$type'");
- }
-
- return $authHeader;
- }
-
- /**
- * Convert an array of parameters into a flat array of (key, value) pairs
- *
- * Will flatten a potentially multi-dimentional array of parameters (such
- * as POST parameters) into a flat array of (key, value) paris. In case
- * of multi-dimentional arrays, square brackets ([]) will be added to the
- * key to indicate an array.
- *
- * @since 1.9
- *
- * @param array $parray
- * @param string $prefix
- * @return array
- */
- static protected function _flattenParametersArray($parray, $prefix = null)
- {
- if (! is_array($parray)) {
- return $parray;
- }
-
- $parameters = array();
-
- foreach($parray as $name => $value) {
-
- // Calculate array key
- if ($prefix) {
- if (is_int($name)) {
- $key = $prefix . '[]';
- } else {
- $key = $prefix . "[$name]";
- }
- } else {
- $key = $name;
- }
-
- if (is_array($value)) {
- $parameters = array_merge($parameters, self::_flattenParametersArray($value, $key));
-
- } else {
- $parameters[] = array($key, $value);
- }
- }
-
- return $parameters;
- }
-
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Curl.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Curl.php
deleted file mode 100644
index 8932543..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Curl.php
+++ /dev/null
@@ -1,498 +0,0 @@
-setCurlOption(CURLOPT_PROXYUSERPWD, $config['proxy_user'].":".$config['proxy_pass']);
- unset($config['proxy_user'], $config['proxy_pass']);
- }
-
- foreach ($config as $k => $v) {
- $option = strtolower($k);
- switch($option) {
- case 'proxy_host':
- $this->setCurlOption(CURLOPT_PROXY, $v);
- break;
- case 'proxy_port':
- $this->setCurlOption(CURLOPT_PROXYPORT, $v);
- break;
- default:
- $this->_config[$option] = $v;
- break;
- }
- }
-
- return $this;
- }
-
- /**
- * Retrieve the array of all configuration options
- *
- * @return array
- */
- public function getConfig()
- {
- return $this->_config;
- }
-
- /**
- * Direct setter for cURL adapter related options.
- *
- * @param string|int $option
- * @param mixed $value
- * @return Microsoft_Http_Adapter_Curl
- */
- public function setCurlOption($option, $value)
- {
- if (!isset($this->_config['curloptions'])) {
- $this->_config['curloptions'] = array();
- }
- $this->_config['curloptions'][$option] = $value;
- return $this;
- }
-
- /**
- * Initialize curl
- *
- * @param string $host
- * @param int $port
- * @param boolean $secure
- * @return void
- * @throws Microsoft_Http_Client_Adapter_Exception if unable to connect
- */
- public function connect($host, $port = 80, $secure = false)
- {
- // If we're already connected, disconnect first
- if ($this->_curl) {
- $this->close();
- }
-
- // If we are connected to a different server or port, disconnect first
- if ($this->_curl
- && is_array($this->_connected_to)
- && ($this->_connected_to[0] != $host
- || $this->_connected_to[1] != $port)
- ) {
- $this->close();
- }
-
- // Do the actual connection
- $this->_curl = curl_init();
- if ($port != 80) {
- curl_setopt($this->_curl, CURLOPT_PORT, intval($port));
- }
-
- // Set timeout
- curl_setopt($this->_curl, CURLOPT_CONNECTTIMEOUT, $this->_config['timeout']);
-
- // Set Max redirects
- curl_setopt($this->_curl, CURLOPT_MAXREDIRS, $this->_config['maxredirects']);
-
- if (!$this->_curl) {
- $this->close();
-
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception('Unable to Connect to ' . $host . ':' . $port);
- }
-
- if ($secure !== false) {
- // Behave the same like Microsoft_Http_Adapter_Socket on SSL options.
- if (isset($this->_config['sslcert'])) {
- curl_setopt($this->_curl, CURLOPT_SSLCERT, $this->_config['sslcert']);
- }
- if (isset($this->_config['sslpassphrase'])) {
- curl_setopt($this->_curl, CURLOPT_SSLCERTPASSWD, $this->_config['sslpassphrase']);
- }
- }
-
- // Update connected_to
- $this->_connected_to = array($host, $port);
- }
-
- /**
- * Send request to the remote server
- *
- * @param string $method
- * @param Microsoft_Uri_Http $uri
- * @param float $http_ver
- * @param array $headers
- * @param string $body
- * @return string $request
- * @throws Microsoft_Http_Client_Adapter_Exception If connection fails, connected to wrong host, no PUT file defined, unsupported method, or unsupported cURL option
- */
- public function write($method, $uri, $httpVersion = 1.1, $headers = array(), $body = '')
- {
- // Make sure we're properly connected
- if (!$this->_curl) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Trying to write but we are not connected");
- }
-
- if ($this->_connected_to[0] != $uri->getHost() || $this->_connected_to[1] != $uri->getPort()) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong host");
- }
-
- // set URL
- curl_setopt($this->_curl, CURLOPT_URL, $uri->__toString());
-
- // ensure correct curl call
- $curlValue = true;
- switch ($method) {
- case Microsoft_Http_Client::GET:
- $curlMethod = CURLOPT_HTTPGET;
- break;
-
- case Microsoft_Http_Client::POST:
- $curlMethod = CURLOPT_POST;
- break;
-
- case Microsoft_Http_Client::PUT:
- // There are two different types of PUT request, either a Raw Data string has been set
- // or CURLOPT_INFILE and CURLOPT_INFILESIZE are used.
- if(is_resource($body)) {
- $this->_config['curloptions'][CURLOPT_INFILE] = $body;
- }
- if (isset($this->_config['curloptions'][CURLOPT_INFILE])) {
- // Now we will probably already have Content-Length set, so that we have to delete it
- // from $headers at this point:
- foreach ($headers AS $k => $header) {
- if (preg_match('/Content-Length:\s*(\d+)/i', $header, $m)) {
- if(is_resource($body)) {
- $this->_config['curloptions'][CURLOPT_INFILESIZE] = (int)$m[1];
- }
- unset($headers[$k]);
- }
- }
-
- if (!isset($this->_config['curloptions'][CURLOPT_INFILESIZE])) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Cannot set a file-handle for cURL option CURLOPT_INFILE without also setting its size in CURLOPT_INFILESIZE.");
- }
-
- if(is_resource($body)) {
- $body = '';
- }
-
- $curlMethod = CURLOPT_PUT;
- } else {
- $curlMethod = CURLOPT_CUSTOMREQUEST;
- $curlValue = "PUT";
- }
- break;
-
- case Microsoft_Http_Client::DELETE:
- $curlMethod = CURLOPT_CUSTOMREQUEST;
- $curlValue = "DELETE";
- break;
-
- case Microsoft_Http_Client::OPTIONS:
- $curlMethod = CURLOPT_CUSTOMREQUEST;
- $curlValue = "OPTIONS";
- break;
-
- case Microsoft_Http_Client::TRACE:
- $curlMethod = CURLOPT_CUSTOMREQUEST;
- $curlValue = "TRACE";
- break;
-
- default:
- // For now, through an exception for unsupported request methods
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Method currently not supported");
- }
-
- if(is_resource($body) && $curlMethod != CURLOPT_PUT) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Streaming requests are allowed only with PUT");
- }
-
- // get http version to use
- $curlHttp = ($httpVersion == 1.1) ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0;
-
- // mark as HTTP request and set HTTP method
- curl_setopt($this->_curl, $curlHttp, true);
- curl_setopt($this->_curl, $curlMethod, $curlValue);
-
- if($this->out_stream) {
- // headers will be read into the response
- curl_setopt($this->_curl, CURLOPT_HEADER, false);
- curl_setopt($this->_curl, CURLOPT_HEADERFUNCTION, array($this, "readHeader"));
- // and data will be written into the file
- curl_setopt($this->_curl, CURLOPT_FILE, $this->out_stream);
- } else {
- // ensure headers are also returned
- curl_setopt($this->_curl, CURLOPT_HEADER, true);
-
- // ensure actual response is returned
- curl_setopt($this->_curl, CURLOPT_RETURNTRANSFER, true);
- }
-
- // set additional headers
- $headers['Accept'] = '';
- curl_setopt($this->_curl, CURLOPT_HTTPHEADER, $headers);
-
- /**
- * Make sure POSTFIELDS is set after $curlMethod is set:
- * @link http://de2.php.net/manual/en/function.curl-setopt.php#81161
- */
- if ($method == Microsoft_Http_Client::POST) {
- curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $body);
- } elseif ($curlMethod == CURLOPT_PUT) {
- // this covers a PUT by file-handle:
- // Make the setting of this options explicit (rather than setting it through the loop following a bit lower)
- // to group common functionality together.
- curl_setopt($this->_curl, CURLOPT_INFILE, $this->_config['curloptions'][CURLOPT_INFILE]);
- curl_setopt($this->_curl, CURLOPT_INFILESIZE, $this->_config['curloptions'][CURLOPT_INFILESIZE]);
- unset($this->_config['curloptions'][CURLOPT_INFILE]);
- unset($this->_config['curloptions'][CURLOPT_INFILESIZE]);
- } elseif ($method == Microsoft_Http_Client::PUT) {
- // This is a PUT by a setRawData string, not by file-handle
- curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $body);
- }
-
- // set additional curl options
- if (isset($this->_config['curloptions'])) {
- foreach ((array)$this->_config['curloptions'] as $k => $v) {
- if (!in_array($k, $this->_invalidOverwritableCurlOptions)) {
- if (curl_setopt($this->_curl, $k, $v) == false) {
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception(sprintf("Unknown or erroreous cURL option '%s' set", $k));
- }
- }
- }
- }
-
- // send the request
- $response = curl_exec($this->_curl);
-
- // if we used streaming, headers are already there
- if(!is_resource($this->out_stream)) {
- $this->_response = $response;
- }
-
- $request = curl_getinfo($this->_curl, CURLINFO_HEADER_OUT);
- $request .= $body;
-
- if (empty($this->_response)) {
- require_once 'Microsoft/Http/Client/Exception.php';
- throw new Microsoft_Http_Client_Exception("Error in cURL request: " . curl_error($this->_curl));
- }
-
- // cURL automatically decodes chunked-messages, this means we have to disallow the Microsoft_Http_Response to do it again
- if (stripos($this->_response, "Transfer-Encoding: chunked\r\n")) {
- $this->_response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $this->_response);
- }
-
- // Eliminate multiple HTTP responses.
- do {
- $parts = preg_split('|(?:\r?\n){2}|m', $this->_response, 2);
- $again = false;
-
- if (isset($parts[1]) && preg_match("|^HTTP/1\.[01](.*?)\r\n|mi", $parts[1])) {
- $this->_response = $parts[1];
- $again = true;
- }
- } while ($again);
-
- // cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string:
- if (stripos($this->_response, "HTTP/1.0 200 Connection established\r\n\r\n") !== false) {
- $this->_response = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $this->_response);
- }
-
- return $request;
- }
-
- /**
- * Return read response from server
- *
- * @return string
- */
- public function read()
- {
- return $this->_response;
- }
-
- /**
- * Close the connection to the server
- *
- */
- public function close()
- {
- if(is_resource($this->_curl)) {
- curl_close($this->_curl);
- }
- $this->_curl = null;
- $this->_connected_to = array(null, null);
- }
-
- /**
- * Get cUrl Handle
- *
- * @return resource
- */
- public function getHandle()
- {
- return $this->_curl;
- }
-
- /**
- * Set output stream for the response
- *
- * @param resource $stream
- * @return Microsoft_Http_Client_Adapter_Socket
- */
- public function setOutputStream($stream)
- {
- $this->out_stream = $stream;
- return $this;
- }
-
- /**
- * Header reader function for CURL
- *
- * @param resource $curl
- * @param string $header
- * @return int
- */
- public function readHeader($curl, $header)
- {
- $this->_response .= $header;
- return strlen($header);
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Exception.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Exception.php
deleted file mode 100644
index 22159da..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Exception.php
+++ /dev/null
@@ -1,38 +0,0 @@
- 'ssl',
- 'sslcert' => null,
- 'sslpassphrase' => null,
- 'proxy_host' => '',
- 'proxy_port' => 8080,
- 'proxy_user' => '',
- 'proxy_pass' => '',
- 'proxy_auth' => Microsoft_Http_Client::AUTH_BASIC,
- 'persistent' => false
- );
-
- /**
- * Whether HTTPS CONNECT was already negotiated with the proxy or not
- *
- * @var boolean
- */
- protected $negotiated = false;
-
- /**
- * Connect to the remote server
- *
- * Will try to connect to the proxy server. If no proxy was set, will
- * fall back to the target server (behave like regular Socket adapter)
- *
- * @param string $host
- * @param int $port
- * @param boolean $secure
- */
- public function connect($host, $port = 80, $secure = false)
- {
- // If no proxy is set, fall back to Socket adapter
- if (! $this->config['proxy_host']) {
- return parent::connect($host, $port, $secure);
- }
-
- // Connect (a non-secure connection) to the proxy server
- return parent::connect(
- $this->config['proxy_host'],
- $this->config['proxy_port'],
- false
- );
- }
-
- /**
- * Send request to the proxy server
- *
- * @param string $method
- * @param Microsoft_Uri_Http $uri
- * @param string $http_ver
- * @param array $headers
- * @param string $body
- * @return string Request as string
- */
- public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
- {
- // If no proxy is set, fall back to default Socket adapter
- if (! $this->config['proxy_host']) return parent::write($method, $uri, $http_ver, $headers, $body);
-
- // Make sure we're properly connected
- if (! $this->socket) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Trying to write but we are not connected");
- }
-
- $host = $this->config['proxy_host'];
- $port = $this->config['proxy_port'];
-
- if ($this->connected_to[0] != "tcp://$host" || $this->connected_to[1] != $port) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Trying to write but we are connected to the wrong proxy server");
- }
-
- // Add Proxy-Authorization header
- if ($this->config['proxy_user'] && ! isset($headers['proxy-authorization'])) {
- $headers['proxy-authorization'] = Microsoft_Http_Client::encodeAuthHeader(
- $this->config['proxy_user'], $this->config['proxy_pass'], $this->config['proxy_auth']
- );
- }
-
- // if we are proxying HTTPS, preform CONNECT handshake with the proxy
- if ($uri->getScheme() == 'https' && (! $this->negotiated)) {
- $this->connectHandshake($uri->getHost(), $uri->getPort(), $http_ver, $headers);
- $this->negotiated = true;
- }
-
- // Save request method for later
- $this->method = $method;
-
- // Build request headers
- if ($this->negotiated) {
- $path = $uri->getPath();
- if ($uri->getQuery()) {
- $path .= '?' . $uri->getQuery();
- }
- $request = "$method $path HTTP/$http_ver\r\n";
- } else {
- $request = "$method $uri HTTP/$http_ver\r\n";
- }
-
- // Add all headers to the request string
- foreach ($headers as $k => $v) {
- if (is_string($k)) $v = "$k: $v";
- $request .= "$v\r\n";
- }
-
- // Add the request body
- $request .= "\r\n" . $body;
-
- // Send the request
- if (! @fwrite($this->socket, $request)) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Error writing request to proxy server");
- }
-
- return $request;
- }
-
- /**
- * Preform handshaking with HTTPS proxy using CONNECT method
- *
- * @param string $host
- * @param integer $port
- * @param string $http_ver
- * @param array $headers
- */
- protected function connectHandshake($host, $port = 443, $http_ver = '1.1', array &$headers = array())
- {
- $request = "CONNECT $host:$port HTTP/$http_ver\r\n" .
- "Host: " . $this->config['proxy_host'] . "\r\n";
-
- // Add the user-agent header
- if (isset($this->config['useragent'])) {
- $request .= "User-agent: " . $this->config['useragent'] . "\r\n";
- }
-
- // If the proxy-authorization header is set, send it to proxy but remove
- // it from headers sent to target host
- if (isset($headers['proxy-authorization'])) {
- $request .= "Proxy-authorization: " . $headers['proxy-authorization'] . "\r\n";
- unset($headers['proxy-authorization']);
- }
-
- $request .= "\r\n";
-
- // Send the request
- if (! @fwrite($this->socket, $request)) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Error writing request to proxy server");
- }
-
- // Read response headers only
- $response = '';
- $gotStatus = false;
- while ($line = @fgets($this->socket)) {
- $gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
- if ($gotStatus) {
- $response .= $line;
- if (!chop($line)) break;
- }
- }
-
- // Check that the response from the proxy is 200
- if (Microsoft_Http_Response::extractCode($response) != 200) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Unable to connect to HTTPS proxy. Server response: " . $response);
- }
-
- // If all is good, switch socket to secure mode. We have to fall back
- // through the different modes
- $modes = array(
- STREAM_CRYPTO_METHOD_TLS_CLIENT,
- STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
- STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
- STREAM_CRYPTO_METHOD_SSLv2_CLIENT
- );
-
- $success = false;
- foreach($modes as $mode) {
- $success = stream_socket_enable_crypto($this->socket, true, $mode);
- if ($success) break;
- }
-
- if (! $success) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception("Unable to connect to" .
- " HTTPS server through proxy: could not negotiate secure connection.");
- }
- }
-
- /**
- * Close the connection to the server
- *
- */
- public function close()
- {
- parent::close();
- $this->negotiated = false;
- }
-
- /**
- * Destructor: make sure the socket is disconnected
- *
- */
- public function __destruct()
- {
- if ($this->socket) $this->close();
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Socket.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Socket.php
deleted file mode 100644
index 3ca2656..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Socket.php
+++ /dev/null
@@ -1,531 +0,0 @@
- false,
- 'ssltransport' => 'ssl',
- 'sslcert' => null,
- 'sslpassphrase' => null
- );
-
- /**
- * Request method - will be set by write() and might be used by read()
- *
- * @var string
- */
- protected $method = null;
-
- /**
- * Stream context
- *
- * @var resource
- */
- protected $_context = null;
-
- /**
- * Adapter constructor, currently empty. Config is set using setConfig()
- *
- */
- public function __construct()
- {
- }
-
- /**
- * Set the configuration array for the adapter
- *
- * @param array $config
- */
- public function setConfig($config = array())
- {
- if (! is_array($config)) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception(
- 'Array expected, got ' . gettype($config)
- );
- }
-
- foreach ($config as $k => $v) {
- $this->config[strtolower($k)] = $v;
- }
- }
-
- /**
- * Retrieve the array of all configuration options
- *
- * @return array
- */
- public function getConfig()
- {
- return $this->config;
- }
-
- /**
- * Set the stream context for the TCP connection to the server
- *
- * Can accept either a pre-existing stream context resource, or an array
- * of stream options, similar to the options array passed to the
- * stream_context_create() PHP function. In such case a new stream context
- * will be created using the passed options.
- *
- * @since Zend Framework 1.9
- *
- * @param mixed $context Stream context or array of context options
- * @return Microsoft_Http_Client_Adapter_Socket
- */
- public function setStreamContext($context)
- {
- if (is_resource($context) && get_resource_type($context) == 'stream-context') {
- $this->_context = $context;
-
- } elseif (is_array($context)) {
- $this->_context = stream_context_create($context);
-
- } else {
- // Invalid parameter
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception(
- "Expecting either a stream context resource or array, got " . gettype($context)
- );
- }
-
- return $this;
- }
-
- /**
- * Get the stream context for the TCP connection to the server.
- *
- * If no stream context is set, will create a default one.
- *
- * @return resource
- */
- public function getStreamContext()
- {
- if (! $this->_context) {
- $this->_context = stream_context_create();
- }
-
- return $this->_context;
- }
-
- /**
- * Connect to the remote server
- *
- * @param string $host
- * @param int $port
- * @param boolean $secure
- */
- public function connect($host, $port = 80, $secure = false)
- {
- // If the URI should be accessed via SSL, prepend the Hostname with ssl://
- $host = ($secure ? $this->config['ssltransport'] : 'tcp') . '://' . $host;
-
- // If we are connected to the wrong host, disconnect first
- if (($this->connected_to[0] != $host || $this->connected_to[1] != $port)) {
- if (is_resource($this->socket)) $this->close();
- }
-
- // Now, if we are not connected, connect
- if (! is_resource($this->socket) || ! $this->config['keepalive']) {
- $context = $this->getStreamContext();
- if ($secure) {
- if ($this->config['sslcert'] !== null) {
- if (! stream_context_set_option($context, 'ssl', 'local_cert',
- $this->config['sslcert'])) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception('Unable to set sslcert option');
- }
- }
- if ($this->config['sslpassphrase'] !== null) {
- if (! stream_context_set_option($context, 'ssl', 'passphrase',
- $this->config['sslpassphrase'])) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception('Unable to set sslpassphrase option');
- }
- }
- }
-
- $flags = STREAM_CLIENT_CONNECT;
- if ($this->config['persistent']) $flags |= STREAM_CLIENT_PERSISTENT;
-
- $this->socket = @stream_socket_client($host . ':' . $port,
- $errno,
- $errstr,
- (int) $this->config['timeout'],
- $flags,
- $context);
-
- if (! $this->socket) {
- $this->close();
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception(
- 'Unable to Connect to ' . $host . ':' . $port . '. Error #' . $errno . ': ' . $errstr);
- }
-
- // Set the stream timeout
- if (! stream_set_timeout($this->socket, (int) $this->config['timeout'])) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception('Unable to set the connection timeout');
- }
-
- // Update connected_to
- $this->connected_to = array($host, $port);
- }
- }
-
- /**
- * Send request to the remote server
- *
- * @param string $method
- * @param Microsoft_Uri_Http $uri
- * @param string $http_ver
- * @param array $headers
- * @param string $body
- * @return string Request as string
- */
- public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
- {
- // Make sure we're properly connected
- if (! $this->socket) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception('Trying to write but we are not connected');
- }
-
- $host = $uri->getHost();
- $host = (strtolower($uri->getScheme()) == 'https' ? $this->config['ssltransport'] : 'tcp') . '://' . $host;
- if ($this->connected_to[0] != $host || $this->connected_to[1] != $uri->getPort()) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception('Trying to write but we are connected to the wrong host');
- }
-
- // Save request method for later
- $this->method = $method;
-
- // Build request headers
- $path = $uri->getPath();
- if ($uri->getQuery()) $path .= '?' . $uri->getQuery();
- $request = "{$method} {$path} HTTP/{$http_ver}\r\n";
- foreach ($headers as $k => $v) {
- if (is_string($k)) $v = ucfirst($k) . ": $v";
- $request .= "$v\r\n";
- }
-
- if(is_resource($body)) {
- $request .= "\r\n";
- } else {
- // Add the request body
- $request .= "\r\n" . $body;
- }
-
- // Send the request
- if (! @fwrite($this->socket, $request)) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception('Error writing request to server');
- }
-
- if(is_resource($body)) {
- if(stream_copy_to_stream($body, $this->socket) == 0) {
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception('Error writing request to server');
- }
- }
-
- return $request;
- }
-
- /**
- * Read response from server
- *
- * @return string
- */
- public function read()
- {
- // First, read headers only
- $response = '';
- $gotStatus = false;
- $stream = !empty($this->config['stream']);
-
- while (($line = @fgets($this->socket)) !== false) {
- $gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
- if ($gotStatus) {
- $response .= $line;
- if (rtrim($line) === '') break;
- }
- }
-
- $this->_checkSocketReadTimeout();
-
- $statusCode = Microsoft_Http_Response::extractCode($response);
-
- // Handle 100 and 101 responses internally by restarting the read again
- if ($statusCode == 100 || $statusCode == 101) return $this->read();
-
- // Check headers to see what kind of connection / transfer encoding we have
- $headers = Microsoft_Http_Response::extractHeaders($response);
-
- /**
- * Responses to HEAD requests and 204 or 304 responses are not expected
- * to have a body - stop reading here
- */
- if ($statusCode == 304 || $statusCode == 204 ||
- $this->method == Microsoft_Http_Client::HEAD) {
-
- // Close the connection if requested to do so by the server
- if (isset($headers['connection']) && $headers['connection'] == 'close') {
- $this->close();
- }
- return $response;
- }
-
- // If we got a 'transfer-encoding: chunked' header
- if (isset($headers['transfer-encoding'])) {
-
- if (strtolower($headers['transfer-encoding']) == 'chunked') {
-
- do {
- $line = @fgets($this->socket);
- $this->_checkSocketReadTimeout();
-
- $chunk = $line;
-
- // Figure out the next chunk size
- $chunksize = trim($line);
- if (! ctype_xdigit($chunksize)) {
- $this->close();
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception('Invalid chunk size "' .
- $chunksize . '" unable to read chunked body');
- }
-
- // Convert the hexadecimal value to plain integer
- $chunksize = hexdec($chunksize);
-
- // Read next chunk
- $read_to = ftell($this->socket) + $chunksize;
-
- do {
- $current_pos = ftell($this->socket);
- if ($current_pos >= $read_to) break;
-
- if($this->out_stream) {
- if(stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) {
- $this->_checkSocketReadTimeout();
- break;
- }
- } else {
- $line = @fread($this->socket, $read_to - $current_pos);
- if ($line === false || strlen($line) === 0) {
- $this->_checkSocketReadTimeout();
- break;
- }
- $chunk .= $line;
- }
- } while (! feof($this->socket));
-
- $chunk .= @fgets($this->socket);
- $this->_checkSocketReadTimeout();
-
- if(!$this->out_stream) {
- $response .= $chunk;
- }
- } while ($chunksize > 0);
- } else {
- $this->close();
- throw new Microsoft_Http_Client_Adapter_Exception('Cannot handle "' .
- $headers['transfer-encoding'] . '" transfer encoding');
- }
-
- // We automatically decode chunked-messages when writing to a stream
- // this means we have to disallow the Microsoft_Http_Response to do it again
- if ($this->out_stream) {
- $response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $response);
- }
- // Else, if we got the content-length header, read this number of bytes
- } elseif (isset($headers['content-length'])) {
-
- $current_pos = ftell($this->socket);
- $chunk = '';
-
- for ($read_to = $current_pos + $headers['content-length'];
- $read_to > $current_pos;
- $current_pos = ftell($this->socket)) {
-
- if($this->out_stream) {
- if(@stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) {
- $this->_checkSocketReadTimeout();
- break;
- }
- } else {
- $chunk = @fread($this->socket, $read_to - $current_pos);
- if ($chunk === false || strlen($chunk) === 0) {
- $this->_checkSocketReadTimeout();
- break;
- }
-
- $response .= $chunk;
- }
-
- // Break if the connection ended prematurely
- if (feof($this->socket)) break;
- }
-
- // Fallback: just read the response until EOF
- } else {
-
- do {
- if($this->out_stream) {
- if(@stream_copy_to_stream($this->socket, $this->out_stream) == 0) {
- $this->_checkSocketReadTimeout();
- break;
- }
- } else {
- $buff = @fread($this->socket, 8192);
- if ($buff === false || strlen($buff) === 0) {
- $this->_checkSocketReadTimeout();
- break;
- } else {
- $response .= $buff;
- }
- }
-
- } while (feof($this->socket) === false);
-
- $this->close();
- }
-
- // Close the connection if requested to do so by the server
- if (isset($headers['connection']) && $headers['connection'] == 'close') {
- $this->close();
- }
-
- return $response;
- }
-
- /**
- * Close the connection to the server
- *
- */
- public function close()
- {
- if (is_resource($this->socket)) @fclose($this->socket);
- $this->socket = null;
- $this->connected_to = array(null, null);
- }
-
- /**
- * Check if the socket has timed out - if so close connection and throw
- * an exception
- *
- * @throws Microsoft_Http_Client_Adapter_Exception with READ_TIMEOUT code
- */
- protected function _checkSocketReadTimeout()
- {
- if ($this->socket) {
- $info = stream_get_meta_data($this->socket);
- $timedout = $info['timed_out'];
- if ($timedout) {
- $this->close();
- require_once 'Microsoft/Http/Client/Adapter/Exception.php';
- throw new Microsoft_Http_Client_Adapter_Exception(
- "Read timed out after {$this->config['timeout']} seconds",
- Microsoft_Http_Client_Adapter_Exception::READ_TIMEOUT
- );
- }
- }
- }
-
- /**
- * Set output stream for the response
- *
- * @param resource $stream
- * @return Microsoft_Http_Client_Adapter_Socket
- */
- public function setOutputStream($stream)
- {
- $this->out_stream = $stream;
- return $this;
- }
-
- /**
- * Destructor: make sure the socket is disconnected
- *
- * If we are in persistent TCP mode, will not close the connection
- *
- */
- public function __destruct()
- {
- if (! $this->config['persistent']) {
- if ($this->socket) $this->close();
- }
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Stream.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Stream.php
deleted file mode 100644
index af8b86e..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Client/Adapter/Stream.php
+++ /dev/null
@@ -1,46 +0,0 @@
-name = (string) $name) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception('Cookies must have a name');
- }
-
- if (! $this->domain = (string) $domain) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception('Cookies must have a domain');
- }
-
- $this->value = (string) $value;
- $this->expires = ($expires === null ? null : (int) $expires);
- $this->path = ($path ? $path : '/');
- $this->secure = $secure;
- }
-
- /**
- * Get Cookie name
- *
- * @return string
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Get cookie value
- *
- * @return string
- */
- public function getValue()
- {
- return $this->value;
- }
-
- /**
- * Get cookie domain
- *
- * @return string
- */
- public function getDomain()
- {
- return $this->domain;
- }
-
- /**
- * Get the cookie path
- *
- * @return string
- */
- public function getPath()
- {
- return $this->path;
- }
-
- /**
- * Get the expiry time of the cookie, or null if no expiry time is set
- *
- * @return int|null
- */
- public function getExpiryTime()
- {
- return $this->expires;
- }
-
- /**
- * Check whether the cookie should only be sent over secure connections
- *
- * @return boolean
- */
- public function isSecure()
- {
- return $this->secure;
- }
-
- /**
- * Check whether the cookie has expired
- *
- * Always returns false if the cookie is a session cookie (has no expiry time)
- *
- * @param int $now Timestamp to consider as "now"
- * @return boolean
- */
- public function isExpired($now = null)
- {
- if ($now === null) $now = time();
- if (is_int($this->expires) && $this->expires < $now) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Check whether the cookie is a session cookie (has no expiry time set)
- *
- * @return boolean
- */
- public function isSessionCookie()
- {
- return ($this->expires === null);
- }
-
- /**
- * Checks whether the cookie should be sent or not in a specific scenario
- *
- * @param string|Microsoft_Uri_Http $uri URI to check against (secure, domain, path)
- * @param boolean $matchSessionCookies Whether to send session cookies
- * @param int $now Override the current time when checking for expiry time
- * @return boolean
- */
- public function match($uri, $matchSessionCookies = true, $now = null)
- {
- if (is_string ($uri)) {
- $uri = Microsoft_Uri_Http::factory($uri);
- }
-
- // Make sure we have a valid Microsoft_Uri_Http object
- if (! ($uri->valid() && ($uri->getScheme() == 'http' || $uri->getScheme() =='https'))) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception('Passed URI is not a valid HTTP or HTTPS URI');
- }
-
- // Check that the cookie is secure (if required) and not expired
- if ($this->secure && $uri->getScheme() != 'https') return false;
- if ($this->isExpired($now)) return false;
- if ($this->isSessionCookie() && ! $matchSessionCookies) return false;
-
- // Check if the domain matches
- if (! self::matchCookieDomain($this->getDomain(), $uri->getHost())) {
- return false;
- }
-
- // Check that path matches using prefix match
- if (! self::matchCookiePath($this->getPath(), $uri->getPath())) {
- return false;
- }
-
- // If we didn't die until now, return true.
- return true;
- }
-
- /**
- * Get the cookie as a string, suitable for sending as a "Cookie" header in an
- * HTTP request
- *
- * @return string
- */
- public function __toString()
- {
- return $this->name . '=' . urlencode($this->value) . ';';
- }
-
- /**
- * Generate a new Cookie object from a cookie string
- * (for example the value of the Set-Cookie HTTP header)
- *
- * @param string $cookieStr
- * @param Microsoft_Uri_Http|string $ref_uri Reference URI for default values (domain, path)
- * @return Microsoft_Http_Cookie A new Microsoft_Http_Cookie object or false on failure.
- */
- public static function fromString($cookieStr, $ref_uri = null)
- {
- // Set default values
- if (is_string($ref_uri)) {
- $ref_uri = Microsoft_Uri_Http::factory($ref_uri);
- }
-
- $name = '';
- $value = '';
- $domain = '';
- $path = '';
- $expires = null;
- $secure = false;
- $parts = explode(';', $cookieStr);
-
- // If first part does not include '=', fail
- if (strpos($parts[0], '=') === false) return false;
-
- // Get the name and value of the cookie
- list($name, $value) = explode('=', trim(array_shift($parts)), 2);
- $name = trim($name);
- $value = urldecode(trim($value));
-
- // Set default domain and path
- if ($ref_uri instanceof Microsoft_Uri_Http) {
- $domain = $ref_uri->getHost();
- $path = $ref_uri->getPath();
- $path = substr($path, 0, strrpos($path, '/'));
- }
-
- // Set other cookie parameters
- foreach ($parts as $part) {
- $part = trim($part);
- if (strtolower($part) == 'secure') {
- $secure = true;
- continue;
- }
-
- $keyValue = explode('=', $part, 2);
- if (count($keyValue) == 2) {
- list($k, $v) = $keyValue;
- switch (strtolower($k)) {
- case 'expires':
- if(($expires = strtotime($v)) === false) {
- /**
- * The expiration is past Tue, 19 Jan 2038 03:14:07 UTC
- * the maximum for 32-bit signed integer. Microsoft_Date
- * can get around that limit.
- *
- * @see Microsoft_Date
- */
- require_once 'Microsoft/Date.php';
-
- $expireDate = new Microsoft_Date($v);
- $expires = $expireDate->getTimestamp();
- }
- break;
-
- case 'path':
- $path = $v;
- break;
-
- case 'domain':
- $domain = $v;
- break;
-
- default:
- break;
- }
- }
- }
-
- if ($name !== '') {
- return new self($name, $value, $domain, $expires, $path, $secure);
- } else {
- return false;
- }
- }
-
- /**
- * Check if a cookie's domain matches a host name.
- *
- * Used by Microsoft_Http_Cookie and Microsoft_Http_CookieJar for cookie matching
- *
- * @param string $cookieDomain
- * @param string $host
- *
- * @return boolean
- */
- public static function matchCookieDomain($cookieDomain, $host)
- {
- if (! $cookieDomain) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception("\$cookieDomain is expected to be a cookie domain");
- }
-
- if (! $host) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception("\$host is expected to be a host name");
- }
-
- $cookieDomain = strtolower($cookieDomain);
- $host = strtolower($host);
-
- if ($cookieDomain[0] == '.') {
- $cookieDomain = substr($cookieDomain, 1);
- }
-
- // Check for either exact match or suffix match
- return ($cookieDomain == $host ||
- preg_match("/\.$cookieDomain$/", $host));
- }
-
- /**
- * Check if a cookie's path matches a URL path
- *
- * Used by Microsoft_Http_Cookie and Microsoft_Http_CookieJar for cookie matching
- *
- * @param string $cookiePath
- * @param string $path
- * @return boolean
- */
- public static function matchCookiePath($cookiePath, $path)
- {
- if (! $cookiePath) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception("\$cookiePath is expected to be a cookie path");
- }
-
- if (! $path) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception("\$path is expected to be a host name");
- }
-
- return (strpos($path, $cookiePath) === 0);
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/CookieJar.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/CookieJar.php
deleted file mode 100644
index e8620ae..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/CookieJar.php
+++ /dev/null
@@ -1,403 +0,0 @@
-getDomain();
- $path = $cookie->getPath();
- if (! isset($this->cookies[$domain])) $this->cookies[$domain] = array();
- if (! isset($this->cookies[$domain][$path])) $this->cookies[$domain][$path] = array();
- $this->cookies[$domain][$path][$cookie->getName()] = $cookie;
- $this->_rawCookies[] = $cookie;
- } else {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception('Supplient argument is not a valid cookie string or object');
- }
- }
-
- /**
- * Parse an HTTP response, adding all the cookies set in that response
- * to the cookie jar.
- *
- * @param Microsoft_Http_Response $response
- * @param Microsoft_Uri_Http|string $ref_uri Requested URI
- */
- public function addCookiesFromResponse($response, $ref_uri)
- {
- if (! $response instanceof Microsoft_Http_Response) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception('$response is expected to be a Response object, ' .
- gettype($response) . ' was passed');
- }
-
- $cookie_hdrs = $response->getHeader('Set-Cookie');
-
- if (is_array($cookie_hdrs)) {
- foreach ($cookie_hdrs as $cookie) {
- $this->addCookie($cookie, $ref_uri);
- }
- } elseif (is_string($cookie_hdrs)) {
- $this->addCookie($cookie_hdrs, $ref_uri);
- }
- }
-
- /**
- * Get all cookies in the cookie jar as an array
- *
- * @param int $ret_as Whether to return cookies as objects of Microsoft_Http_Cookie or as strings
- * @return array|string
- */
- public function getAllCookies($ret_as = self::COOKIE_OBJECT)
- {
- $cookies = $this->_flattenCookiesArray($this->cookies, $ret_as);
- return $cookies;
- }
-
- /**
- * Return an array of all cookies matching a specific request according to the request URI,
- * whether session cookies should be sent or not, and the time to consider as "now" when
- * checking cookie expiry time.
- *
- * @param string|Microsoft_Uri_Http $uri URI to check against (secure, domain, path)
- * @param boolean $matchSessionCookies Whether to send session cookies
- * @param int $ret_as Whether to return cookies as objects of Microsoft_Http_Cookie or as strings
- * @param int $now Override the current time when checking for expiry time
- * @return array|string
- */
- public function getMatchingCookies($uri, $matchSessionCookies = true,
- $ret_as = self::COOKIE_OBJECT, $now = null)
- {
- if (is_string($uri)) $uri = Microsoft_Uri::factory($uri);
- if (! $uri instanceof Microsoft_Uri_Http) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception("Invalid URI string or object passed");
- }
-
- // First, reduce the array of cookies to only those matching domain and path
- $cookies = $this->_matchDomain($uri->getHost());
- $cookies = $this->_matchPath($cookies, $uri->getPath());
- $cookies = $this->_flattenCookiesArray($cookies, self::COOKIE_OBJECT);
-
- // Next, run Cookie->match on all cookies to check secure, time and session mathcing
- $ret = array();
- foreach ($cookies as $cookie)
- if ($cookie->match($uri, $matchSessionCookies, $now))
- $ret[] = $cookie;
-
- // Now, use self::_flattenCookiesArray again - only to convert to the return format ;)
- $ret = $this->_flattenCookiesArray($ret, $ret_as);
-
- return $ret;
- }
-
- /**
- * Get a specific cookie according to a URI and name
- *
- * @param Microsoft_Uri_Http|string $uri The uri (domain and path) to match
- * @param string $cookie_name The cookie's name
- * @param int $ret_as Whether to return cookies as objects of Microsoft_Http_Cookie or as strings
- * @return Microsoft_Http_Cookie|string
- */
- public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT)
- {
- if (is_string($uri)) {
- $uri = Microsoft_Uri::factory($uri);
- }
-
- if (! $uri instanceof Microsoft_Uri_Http) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception('Invalid URI specified');
- }
-
- // Get correct cookie path
- $path = $uri->getPath();
- $path = substr($path, 0, strrpos($path, '/'));
- if (! $path) $path = '/';
-
- if (isset($this->cookies[$uri->getHost()][$path][$cookie_name])) {
- $cookie = $this->cookies[$uri->getHost()][$path][$cookie_name];
-
- switch ($ret_as) {
- case self::COOKIE_OBJECT:
- return $cookie;
- break;
-
- case self::COOKIE_STRING_ARRAY:
- case self::COOKIE_STRING_CONCAT:
- return $cookie->__toString();
- break;
-
- default:
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception("Invalid value passed for \$ret_as: {$ret_as}");
- break;
- }
- } else {
- return false;
- }
- }
-
- /**
- * Helper function to recursivly flatten an array. Shoud be used when exporting the
- * cookies array (or parts of it)
- *
- * @param Microsoft_Http_Cookie|array $ptr
- * @param int $ret_as What value to return
- * @return array|string
- */
- protected function _flattenCookiesArray($ptr, $ret_as = self::COOKIE_OBJECT) {
- if (is_array($ptr)) {
- $ret = ($ret_as == self::COOKIE_STRING_CONCAT ? '' : array());
- foreach ($ptr as $item) {
- if ($ret_as == self::COOKIE_STRING_CONCAT) {
- $ret .= $this->_flattenCookiesArray($item, $ret_as);
- } else {
- $ret = array_merge($ret, $this->_flattenCookiesArray($item, $ret_as));
- }
- }
- return $ret;
- } elseif ($ptr instanceof Microsoft_Http_Cookie) {
- switch ($ret_as) {
- case self::COOKIE_STRING_ARRAY:
- return array($ptr->__toString());
- break;
-
- case self::COOKIE_STRING_CONCAT:
- return $ptr->__toString();
- break;
-
- case self::COOKIE_OBJECT:
- default:
- return array($ptr);
- break;
- }
- }
-
- return null;
- }
-
- /**
- * Return a subset of the cookies array matching a specific domain
- *
- * @param string $domain
- * @return array
- */
- protected function _matchDomain($domain)
- {
- $ret = array();
-
- foreach (array_keys($this->cookies) as $cdom) {
- if (Microsoft_Http_Cookie::matchCookieDomain($cdom, $domain)) {
- $ret[$cdom] = $this->cookies[$cdom];
- }
- }
-
- return $ret;
- }
-
- /**
- * Return a subset of a domain-matching cookies that also match a specified path
- *
- * @param array $dom_array
- * @param string $path
- * @return array
- */
- protected function _matchPath($domains, $path)
- {
- $ret = array();
-
- foreach ($domains as $dom => $paths_array) {
- foreach (array_keys($paths_array) as $cpath) {
- if (Microsoft_Http_Cookie::matchCookiePath($cpath, $path)) {
- if (! isset($ret[$dom])) {
- $ret[$dom] = array();
- }
-
- $ret[$dom][$cpath] = $paths_array[$cpath];
- }
- }
- }
-
- return $ret;
- }
-
- /**
- * Create a new CookieJar object and automatically load into it all the
- * cookies set in an Http_Response object. If $uri is set, it will be
- * considered as the requested URI for setting default domain and path
- * of the cookie.
- *
- * @param Microsoft_Http_Response $response HTTP Response object
- * @param Microsoft_Uri_Http|string $uri The requested URI
- * @return Microsoft_Http_CookieJar
- * @todo Add the $uri functionality.
- */
- public static function fromResponse(Microsoft_Http_Response $response, $ref_uri)
- {
- $jar = new self();
- $jar->addCookiesFromResponse($response, $ref_uri);
- return $jar;
- }
-
- /**
- * Required by Countable interface
- *
- * @return int
- */
- public function count()
- {
- return count($this->_rawCookies);
- }
-
- /**
- * Required by IteratorAggregate interface
- *
- * @return ArrayIterator
- */
- public function getIterator()
- {
- return new ArrayIterator($this->_rawCookies);
- }
-
- /**
- * Tells if the jar is empty of any cookie
- *
- * @return bool
- */
- public function isEmpty()
- {
- return count($this) == 0;
- }
-
- /**
- * Empties the cookieJar of any cookie
- *
- * @return Microsoft_Http_CookieJar
- */
- public function reset()
- {
- $this->cookies = $this->_rawCookies = array();
- return $this;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Exception.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Exception.php
deleted file mode 100644
index e9e26f4..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Exception.php
+++ /dev/null
@@ -1,48 +0,0 @@
- 'Continue',
- 101 => 'Switching Protocols',
-
- // Success 2xx
- 200 => 'OK',
- 201 => 'Created',
- 202 => 'Accepted',
- 203 => 'Non-Authoritative Information',
- 204 => 'No Content',
- 205 => 'Reset Content',
- 206 => 'Partial Content',
-
- // Redirection 3xx
- 300 => 'Multiple Choices',
- 301 => 'Moved Permanently',
- 302 => 'Found', // 1.1
- 303 => 'See Other',
- 304 => 'Not Modified',
- 305 => 'Use Proxy',
- // 306 is deprecated but reserved
- 307 => 'Temporary Redirect',
-
- // Client Error 4xx
- 400 => 'Bad Request',
- 401 => 'Unauthorized',
- 402 => 'Payment Required',
- 403 => 'Forbidden',
- 404 => 'Not Found',
- 405 => 'Method Not Allowed',
- 406 => 'Not Acceptable',
- 407 => 'Proxy Authentication Required',
- 408 => 'Request Timeout',
- 409 => 'Conflict',
- 410 => 'Gone',
- 411 => 'Length Required',
- 412 => 'Precondition Failed',
- 413 => 'Request Entity Too Large',
- 414 => 'Request-URI Too Long',
- 415 => 'Unsupported Media Type',
- 416 => 'Requested Range Not Satisfiable',
- 417 => 'Expectation Failed',
-
- // Server Error 5xx
- 500 => 'Internal Server Error',
- 501 => 'Not Implemented',
- 502 => 'Bad Gateway',
- 503 => 'Service Unavailable',
- 504 => 'Gateway Timeout',
- 505 => 'HTTP Version Not Supported',
- 509 => 'Bandwidth Limit Exceeded'
- );
-
- /**
- * The HTTP version (1.0, 1.1)
- *
- * @var string
- */
- protected $version;
-
- /**
- * The HTTP response code
- *
- * @var int
- */
- protected $code;
-
- /**
- * The HTTP response code as string
- * (e.g. 'Not Found' for 404 or 'Internal Server Error' for 500)
- *
- * @var string
- */
- protected $message;
-
- /**
- * The HTTP response headers array
- *
- * @var array
- */
- protected $headers = array();
-
- /**
- * The HTTP response body
- *
- * @var string
- */
- protected $body;
-
- /**
- * HTTP response constructor
- *
- * In most cases, you would use Microsoft_Http_Response::fromString to parse an HTTP
- * response string and create a new Microsoft_Http_Response object.
- *
- * NOTE: The constructor no longer accepts nulls or empty values for the code and
- * headers and will throw an exception if the passed values do not form a valid HTTP
- * responses.
- *
- * If no message is passed, the message will be guessed according to the response code.
- *
- * @param int $code Response code (200, 404, ...)
- * @param array $headers Headers array
- * @param string $body Response body
- * @param string $version HTTP version
- * @param string $message Response code as text
- * @throws Microsoft_Http_Exception
- */
- public function __construct($code, $headers, $body = null, $version = '1.1', $message = null)
- {
- // Make sure the response code is valid and set it
- if (self::responseCodeAsText($code) === null) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception("{$code} is not a valid HTTP response code");
- }
-
- $this->code = $code;
-
- // Make sure we got valid headers and set them
- if (! is_array($headers)) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception('No valid headers were passed');
- }
-
- foreach ($headers as $name => $value) {
- if (is_int($name))
- list($name, $value) = explode(": ", $value, 1);
-
- $this->headers[ucwords(strtolower($name))] = $value;
- }
-
- // Set the body
- $this->body = $body;
-
- // Set the HTTP version
- if (! preg_match('|^\d\.\d$|', $version)) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception("Invalid HTTP response version: $version");
- }
-
- $this->version = $version;
-
- // If we got the response message, set it. Else, set it according to
- // the response code
- if (is_string($message)) {
- $this->message = $message;
- } else {
- $this->message = self::responseCodeAsText($code);
- }
- }
-
- /**
- * Check whether the response is an error
- *
- * @return boolean
- */
- public function isError()
- {
- $restype = floor($this->code / 100);
- if ($restype == 4 || $restype == 5) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Check whether the response in successful
- *
- * @return boolean
- */
- public function isSuccessful()
- {
- $restype = floor($this->code / 100);
- if ($restype == 2 || $restype == 1) { // Shouldn't 3xx count as success as well ???
- return true;
- }
-
- return false;
- }
-
- /**
- * Check whether the response is a redirection
- *
- * @return boolean
- */
- public function isRedirect()
- {
- $restype = floor($this->code / 100);
- if ($restype == 3) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Get the response body as string
- *
- * This method returns the body of the HTTP response (the content), as it
- * should be in it's readable version - that is, after decoding it (if it
- * was decoded), deflating it (if it was gzip compressed), etc.
- *
- * If you want to get the raw body (as transfered on wire) use
- * $this->getRawBody() instead.
- *
- * @return string
- */
- public function getBody()
- {
- $body = '';
-
- // Decode the body if it was transfer-encoded
- switch (strtolower($this->getHeader('transfer-encoding'))) {
-
- // Handle chunked body
- case 'chunked':
- $body = self::decodeChunkedBody($this->body);
- break;
-
- // No transfer encoding, or unknown encoding extension:
- // return body as is
- default:
- $body = $this->body;
- break;
- }
-
- // Decode any content-encoding (gzip or deflate) if needed
- switch (strtolower($this->getHeader('content-encoding'))) {
-
- // Handle gzip encoding
- case 'gzip':
- $body = self::decodeGzip($body);
- break;
-
- // Handle deflate encoding
- case 'deflate':
- $body = self::decodeDeflate($body);
- break;
-
- default:
- break;
- }
-
- return $body;
- }
-
- /**
- * Get the raw response body (as transfered "on wire") as string
- *
- * If the body is encoded (with Transfer-Encoding, not content-encoding -
- * IE "chunked" body), gzip compressed, etc. it will not be decoded.
- *
- * @return string
- */
- public function getRawBody()
- {
- return $this->body;
- }
-
- /**
- * Get the HTTP version of the response
- *
- * @return string
- */
- public function getVersion()
- {
- return $this->version;
- }
-
- /**
- * Get the HTTP response status code
- *
- * @return int
- */
- public function getStatus()
- {
- return $this->code;
- }
-
- /**
- * Return a message describing the HTTP response code
- * (Eg. "OK", "Not Found", "Moved Permanently")
- *
- * @return string
- */
- public function getMessage()
- {
- return $this->message;
- }
-
- /**
- * Get the response headers
- *
- * @return array
- */
- public function getHeaders()
- {
- return $this->headers;
- }
-
- /**
- * Get a specific header as string, or null if it is not set
- *
- * @param string$header
- * @return string|array|null
- */
- public function getHeader($header)
- {
- $header = ucwords(strtolower($header));
- if (! is_string($header) || ! isset($this->headers[$header])) return null;
-
- return $this->headers[$header];
- }
-
- /**
- * Get all headers as string
- *
- * @param boolean $status_line Whether to return the first status line (IE "HTTP 200 OK")
- * @param string $br Line breaks (eg. "\n", "\r\n", "
")
- * @return string
- */
- public function getHeadersAsString($status_line = true, $br = "\n")
- {
- $str = '';
-
- if ($status_line) {
- $str = "HTTP/{$this->version} {$this->code} {$this->message}{$br}";
- }
-
- // Iterate over the headers and stringify them
- foreach ($this->headers as $name => $value)
- {
- if (is_string($value))
- $str .= "{$name}: {$value}{$br}";
-
- elseif (is_array($value)) {
- foreach ($value as $subval) {
- $str .= "{$name}: {$subval}{$br}";
- }
- }
- }
-
- return $str;
- }
-
- /**
- * Get the entire response as string
- *
- * @param string $br Line breaks (eg. "\n", "\r\n", "
")
- * @return string
- */
- public function asString($br = "\n")
- {
- return $this->getHeadersAsString(true, $br) . $br . $this->getRawBody();
- }
-
- /**
- * Implements magic __toString()
- *
- * @return string
- */
- public function __toString()
- {
- return $this->asString();
- }
-
- /**
- * A convenience function that returns a text representation of
- * HTTP response codes. Returns 'Unknown' for unknown codes.
- * Returns array of all codes, if $code is not specified.
- *
- * Conforms to HTTP/1.1 as defined in RFC 2616 (except for 'Unknown')
- * See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10 for reference
- *
- * @param int $code HTTP response code
- * @param boolean $http11 Use HTTP version 1.1
- * @return string
- */
- public static function responseCodeAsText($code = null, $http11 = true)
- {
- $messages = self::$messages;
- if (! $http11) $messages[302] = 'Moved Temporarily';
-
- if ($code === null) {
- return $messages;
- } elseif (isset($messages[$code])) {
- return $messages[$code];
- } else {
- return 'Unknown';
- }
- }
-
- /**
- * Extract the response code from a response string
- *
- * @param string $response_str
- * @return int
- */
- public static function extractCode($response_str)
- {
- preg_match("|^HTTP/[\d\.x]+ (\d+)|", $response_str, $m);
-
- if (isset($m[1])) {
- return (int) $m[1];
- } else {
- return false;
- }
- }
-
- /**
- * Extract the HTTP message from a response
- *
- * @param string $response_str
- * @return string
- */
- public static function extractMessage($response_str)
- {
- preg_match("|^HTTP/[\d\.x]+ \d+ ([^\r\n]+)|", $response_str, $m);
-
- if (isset($m[1])) {
- return $m[1];
- } else {
- return false;
- }
- }
-
- /**
- * Extract the HTTP version from a response
- *
- * @param string $response_str
- * @return string
- */
- public static function extractVersion($response_str)
- {
- preg_match("|^HTTP/([\d\.x]+) \d+|", $response_str, $m);
-
- if (isset($m[1])) {
- return $m[1];
- } else {
- return false;
- }
- }
-
- /**
- * Extract the headers from a response string
- *
- * @param string $response_str
- * @return array
- */
- public static function extractHeaders($response_str)
- {
- $headers = array();
-
- // First, split body and headers
- $parts = preg_split('|(?:\r?\n){2}|m', $response_str, 2);
- if (! $parts[0]) return $headers;
-
- // Split headers part to lines
- $lines = explode("\n", $parts[0]);
- unset($parts);
- $last_header = null;
-
- foreach($lines as $line) {
- $line = trim($line, "\r\n");
- if ($line == "") break;
-
- if (preg_match("|^([\w-]+):\s+(.+)|", $line, $m)) {
- unset($last_header);
- $h_name = strtolower($m[1]);
- $h_value = $m[2];
-
- if (isset($headers[$h_name])) {
- if (! is_array($headers[$h_name])) {
- $headers[$h_name] = array($headers[$h_name]);
- }
-
- $headers[$h_name][] = $h_value;
- } else {
- $headers[$h_name] = $h_value;
- }
- $last_header = $h_name;
- } elseif (preg_match("|^\s+(.+)$|", $line, $m) && $last_header !== null) {
- if (is_array($headers[$last_header])) {
- end($headers[$last_header]);
- $last_header_key = key($headers[$last_header]);
- $headers[$last_header][$last_header_key] .= $m[1];
- } else {
- $headers[$last_header] .= $m[1];
- }
- }
- }
-
- return $headers;
- }
-
- /**
- * Extract the body from a response string
- *
- * @param string $response_str
- * @return string
- */
- public static function extractBody($response_str)
- {
- $parts = preg_split('|(?:\r?\n){2}|m', $response_str, 2);
- if (isset($parts[1])) {
- return $parts[1];
- }
- return '';
- }
-
- /**
- * Decode a "chunked" transfer-encoded body and return the decoded text
- *
- * @param string $body
- * @return string
- */
- public static function decodeChunkedBody($body)
- {
- $decBody = '';
-
- // If mbstring overloads substr and strlen functions, we have to
- // override it's internal encoding
- if (function_exists('mb_internal_encoding') &&
- ((int) ini_get('mbstring.func_overload')) & 2) {
-
- $mbIntEnc = mb_internal_encoding();
- mb_internal_encoding('ASCII');
- }
-
- while (trim($body)) {
- if (! preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception("Error parsing body - doesn't seem to be a chunked message");
- }
-
- $length = hexdec(trim($m[1]));
- $cut = strlen($m[0]);
- $decBody .= substr($body, $cut, $length);
- $body = substr($body, $cut + $length + 2);
- }
-
- if (isset($mbIntEnc)) {
- mb_internal_encoding($mbIntEnc);
- }
-
- return $decBody;
- }
-
- /**
- * Decode a gzip encoded message (when Content-encoding = gzip)
- *
- * Currently requires PHP with zlib support
- *
- * @param string $body
- * @return string
- */
- public static function decodeGzip($body)
- {
- if (! function_exists('gzinflate')) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception(
- 'zlib extension is required in order to decode "gzip" encoding'
- );
- }
-
- return gzinflate(substr($body, 10));
- }
-
- /**
- * Decode a zlib deflated message (when Content-encoding = deflate)
- *
- * Currently requires PHP with zlib support
- *
- * @param string $body
- * @return string
- */
- public static function decodeDeflate($body)
- {
- if (! function_exists('gzuncompress')) {
- require_once 'Microsoft/Http/Exception.php';
- throw new Microsoft_Http_Exception(
- 'zlib extension is required in order to decode "deflate" encoding'
- );
- }
-
- /**
- * Some servers (IIS ?) send a broken deflate response, without the
- * RFC-required zlib header.
- *
- * We try to detect the zlib header, and if it does not exsit we
- * teat the body is plain DEFLATE content.
- *
- * This method was adapted from PEAR HTTP_Request2 by (c) Alexey Borzov
- *
- * @link http://framework.zend.com/issues/browse/ZF-6040
- */
- $zlibHeader = unpack('n', substr($body, 0, 2));
- if ($zlibHeader[1] % 31 == 0) {
- return gzuncompress($body);
- } else {
- return gzinflate($body);
- }
- }
-
- /**
- * Create a new Microsoft_Http_Response object from a string
- *
- * @param string $response_str
- * @return Microsoft_Http_Response
- */
- public static function fromString($response_str)
- {
- $code = self::extractCode($response_str);
- $headers = self::extractHeaders($response_str);
- $body = self::extractBody($response_str);
- $version = self::extractVersion($response_str);
- $message = self::extractMessage($response_str);
-
- return new Microsoft_Http_Response($code, $headers, $body, $version, $message);
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Response/Stream.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Response/Stream.php
deleted file mode 100644
index 63716cb..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Http/Response/Stream.php
+++ /dev/null
@@ -1,235 +0,0 @@
-stream;
- }
-
- /**
- * Set the response stream
- *
- * @param resourse $stream
- * @return Microsoft_Http_Response_Stream
- */
- public function setStream($stream)
- {
- $this->stream = $stream;
- return $this;
- }
-
- /**
- * Get the cleanup trigger
- *
- * @return boolean
- */
- public function getCleanup() {
- return $this->_cleanup;
- }
-
- /**
- * Set the cleanup trigger
- *
- * @param $cleanup Set cleanup trigger
- */
- public function setCleanup($cleanup = true) {
- $this->_cleanup = $cleanup;
- }
-
- /**
- * Get file name associated with the stream
- *
- * @return string
- */
- public function getStreamName() {
- return $this->stream_name;
- }
-
- /**
- * Set file name associated with the stream
- *
- * @param string $stream_name Name to set
- * @return Microsoft_Http_Response_Stream
- */
- public function setStreamName($stream_name) {
- $this->stream_name = $stream_name;
- return $this;
- }
-
-
- /**
- * HTTP response constructor
- *
- * In most cases, you would use Microsoft_Http_Response::fromString to parse an HTTP
- * response string and create a new Microsoft_Http_Response object.
- *
- * NOTE: The constructor no longer accepts nulls or empty values for the code and
- * headers and will throw an exception if the passed values do not form a valid HTTP
- * responses.
- *
- * If no message is passed, the message will be guessed according to the response code.
- *
- * @param int $code Response code (200, 404, ...)
- * @param array $headers Headers array
- * @param string $body Response body
- * @param string $version HTTP version
- * @param string $message Response code as text
- * @throws Microsoft_Http_Exception
- */
- public function __construct($code, $headers, $body = null, $version = '1.1', $message = null)
- {
-
- if(is_resource($body)) {
- $this->setStream($body);
- $body = '';
- }
- parent::__construct($code, $headers, $body, $version, $message);
- }
-
- /**
- * Create a new Microsoft_Http_Response_Stream object from a string
- *
- * @param string $response_str
- * @param resource $stream
- * @return Microsoft_Http_Response_Stream
- */
- public static function fromStream($response_str, $stream)
- {
- $code = self::extractCode($response_str);
- $headers = self::extractHeaders($response_str);
- $version = self::extractVersion($response_str);
- $message = self::extractMessage($response_str);
-
- return new self($code, $headers, $stream, $version, $message);
- }
-
- /**
- * Get the response body as string
- *
- * This method returns the body of the HTTP response (the content), as it
- * should be in it's readable version - that is, after decoding it (if it
- * was decoded), deflating it (if it was gzip compressed), etc.
- *
- * If you want to get the raw body (as transfered on wire) use
- * $this->getRawBody() instead.
- *
- * @return string
- */
- public function getBody()
- {
- if($this->stream != null) {
- $this->readStream();
- }
- return parent::getBody();
- }
-
- /**
- * Get the raw response body (as transfered "on wire") as string
- *
- * If the body is encoded (with Transfer-Encoding, not content-encoding -
- * IE "chunked" body), gzip compressed, etc. it will not be decoded.
- *
- * @return string
- */
- public function getRawBody()
- {
- if($this->stream) {
- $this->readStream();
- }
- return $this->body;
- }
-
- /**
- * Read stream content and return it as string
- *
- * Function reads the remainder of the body from the stream and closes the stream.
- *
- * @return string
- */
- protected function readStream()
- {
- if(!is_resource($this->stream)) {
- return '';
- }
-
- if(isset($headers['content-length'])) {
- $this->body = stream_get_contents($this->stream, $headers['content-length']);
- } else {
- $this->body = stream_get_contents($this->stream);
- }
- fclose($this->stream);
- $this->stream = null;
- }
-
- public function __destruct()
- {
- if(is_resource($this->stream)) {
- fclose($this->stream);
- $this->stream = null;
- }
- if($this->_cleanup) {
- @unlink($this->stream_name);
- }
- }
-
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log.php
deleted file mode 100644
index 1e0b02a..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log.php
+++ /dev/null
@@ -1,421 +0,0 @@
-_priorities = array_flip($r->getConstants());
-
- if ($writer !== null) {
- $this->addWriter($writer);
- }
- }
-
- /**
- * Factory to construct the logger and one or more writers
- * based on the configuration array
- *
- * @param array $config
- * @return Microsoft_Log
- */
- static public function factory($config = array())
- {
- if (!is_array($config) || empty($config)) {
- /** @see Microsoft_Log_Exception */
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception('Configuration must be an array');
- }
-
- $log = new Microsoft_Log;
-
- if (!is_array(current($config))) {
- $log->addWriter(current($config));
- } else {
- foreach($config as $writer) {
- $log->addWriter($writer);
- }
- }
-
- return $log;
- }
-
-
- /**
- * Construct a writer object based on a configuration array
- *
- * @param array $spec config array with writer spec
- * @return Microsoft_Log_Writer_Abstract
- */
- protected function _constructWriterFromConfig($config)
- {
- $writer = $this->_constructFromConfig('writer', $config, $this->_defaultWriterNamespace);
-
- if (!$writer instanceof Microsoft_Log_Writer_Abstract) {
- $writerName = is_object($writer)
- ? get_class($writer)
- : 'The specified writer';
- /** @see Microsoft_Log_Exception */
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception("{$writerName} does not extend Microsoft_Log_Writer_Abstract!");
- }
-
- if (isset($config['filterName'])) {
- $filter = $this->_constructFilterFromConfig($config);
- $writer->addFilter($filter);
- }
-
- return $writer;
- }
-
- /**
- * Construct filter object from configuration array or Microsoft_Config object
- *
- * @param array $config
- * @return Microsoft_Log_Filter_Interface
- */
- protected function _constructFilterFromConfig($config)
- {
- $filter = $this->_constructFromConfig('filter', $config, $this->_defaultFilterNamespace);
-
- if (!$filter instanceof Microsoft_Log_Filter_Interface) {
- $filterName = is_object($filter)
- ? get_class($filter)
- : 'The specified filter';
- /** @see Microsoft_Log_Exception */
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception("{$filterName} does not implement Microsoft_Log_Filter_Interface");
- }
-
- return $filter;
- }
-
- /**
- * Construct a filter or writer from config
- *
- * @param string $type 'writer' of 'filter'
- * @param array $config
- * @param string $namespace
- * @return object
- */
- protected function _constructFromConfig($type, $config, $namespace)
- {
- if (!is_array($config) || empty($config)) {
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception('Configuration must be an array');
- }
-
- $params = isset($config[ $type .'Params' ]) ? $config[ $type .'Params' ] : array();
- $className = $this->getClassName($config, $type, $namespace);
- if (!class_exists($className)) {
- require_once 'Microsoft/Loader.php';
- Microsoft_Loader::loadClass($className);
- }
-
- $reflection = new ReflectionClass($className);
- if (!$reflection->implementsInterface('Microsoft_Log_FactoryInterface')) {
- require_once 'Zend/Log/Exception.php';
- throw new Microsoft_Log_Exception(
- 'Driver does not implement Microsoft_Log_FactoryInterface and can not be constructed from config.'
- );
- }
-
- return call_user_func(array($className, 'factory'), $params);
- }
-
- /**
- * Get the writer or filter full classname
- *
- * @param array $config
- * @param string $type filter|writer
- * @param string $defaultNamespace
- * @return string full classname
- */
- protected function getClassName($config, $type, $defaultNamespace)
- {
- if (!isset($config[ $type . 'Name' ])) {
- require_once 'Zend/Log/Exception.php';
- throw new Microsoft_Log_Exception("Specify {$type}Name in the configuration array");
- }
- $className = $config[ $type . 'Name' ];
-
- $namespace = $defaultNamespace;
- if (isset($config[ $type . 'Namespace' ])) {
- $namespace = $config[ $type . 'Namespace' ];
- }
-
- $fullClassName = $namespace . '_' . $className;
- return $fullClassName;
- }
-
- /**
- * Class destructor. Shutdown log writers
- *
- * @return void
- */
- public function __destruct()
- {
- foreach($this->_writers as $writer) {
- $writer->shutdown();
- }
- }
-
- /**
- * Undefined method handler allows a shortcut:
- * $log->priorityName('message')
- * instead of
- * $log->log('message', Microsoft_Log::PRIORITY_NAME)
- *
- * @param string $method priority name
- * @param string $params message to log
- * @return void
- * @throws Microsoft_Log_Exception
- */
- public function __call($method, $params)
- {
- $priority = strtoupper($method);
- if (($priority = array_search($priority, $this->_priorities)) !== false) {
- switch (count($params)) {
- case 0:
- /** @see Microsoft_Log_Exception */
- require_once 'Microsoft_/Log/Exception.php';
- throw new Microsoft_Log_Exception('Missing log message');
- case 1:
- $message = array_shift($params);
- $extras = null;
- break;
- default:
- $message = array_shift($params);
- $extras = array_shift($params);
- break;
- }
- $this->log($message, $priority, $extras);
- } else {
- /** @see Microsoft_Log_Exception */
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception('Bad log priority');
- }
- }
-
- /**
- * Log a message at a priority
- *
- * @param string $message Message to log
- * @param integer $priority Priority of message
- * @param mixed $extras Extra information to log in event
- * @return void
- * @throws Microsoft_Log_Exception
- */
- public function log($message, $priority, $extras = null)
- {
- // sanity checks
- if (empty($this->_writers)) {
- /** @see Microsoft_Log_Exception */
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception('No writers were added');
- }
-
- if (! isset($this->_priorities[$priority])) {
- /** @see Microsoft_Log_Exception */
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception('Bad log priority');
- }
-
- // pack into event required by filters and writers
- $event = array_merge(array('timestamp' => date('c'),
- 'message' => $message,
- 'priority' => $priority,
- 'priorityName' => $this->_priorities[$priority]),
- $this->_extras);
-
- // Check to see if any extra information was passed
- if (!empty($extras)) {
- $info = array();
- if (is_array($extras)) {
- foreach ($extras as $key => $value) {
- if (is_string($key)) {
- $event[$key] = $value;
- } else {
- $info[] = $value;
- }
- }
- } else {
- $info = $extras;
- }
- if (!empty($info)) {
- $event['info'] = $info;
- }
- }
-
- // abort if rejected by the global filters
- foreach ($this->_filters as $filter) {
- if (! $filter->accept($event)) {
- return;
- }
- }
-
- // send to each writer
- foreach ($this->_writers as $writer) {
- $writer->write($event);
- }
- }
-
- /**
- * Add a custom priority
- *
- * @param string $name Name of priority
- * @param integer $priority Numeric priority
- */
- public function addPriority($name, $priority)
- {
- // Priority names must be uppercase for predictability.
- $name = strtoupper($name);
-
- if (isset($this->_priorities[$priority])
- || false !== array_search($name, $this->_priorities)) {
- /** @see Microsoft_Log_Exception */
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception('Existing priorities cannot be overwritten');
- }
-
- $this->_priorities[$priority] = $name;
- }
-
- /**
- * Add a filter that will be applied before all log writers.
- * Before a message will be received by any of the writers, it
- * must be accepted by all filters added with this method.
- *
- * @param int|Microsoft_Log_Filter_Interface $filter
- * @return void
- */
- public function addFilter($filter)
- {
- if (is_integer($filter)) {
- /** @see Microsoft_Log_Filter_Priority */
- require_once 'Microsoft/Log/Filter/Priority.php';
- $filter = new Microsoft_Log_Filter_Priority($filter);
-
- } elseif ($filter instanceof Microsoft_Config || is_array($filter)) {
- $filter = $this->_constructFilterFromConfig($filter);
-
- } elseif(! $filter instanceof Microsoft_Log_Filter_Interface) {
- /** @see Microsoft_Log_Exception */
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception('Invalid filter provided');
- }
-
- $this->_filters[] = $filter;
- }
-
- /**
- * Add a writer. A writer is responsible for taking a log
- * message and writing it out to storage.
- *
- * @param mixed $writer Microsoft_Log_Writer_Abstract or Config array
- * @return void
- */
- public function addWriter($writer)
- {
- if (is_array($writer)) {
- $writer = $this->_constructWriterFromConfig($writer);
- }
-
- if (!$writer instanceof Microsoft_Log_Writer_Abstract) {
- /** @see Microsoft_Log_Exception */
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception(
- 'Writer must be an instance of Microsoft_Log_Writer_Abstract'
- . ' or you should pass a configuration array'
- );
- }
-
- $this->_writers[] = $writer;
- }
-
- /**
- * Set an extra item to pass to the log writers.
- *
- * @param $name Name of the field
- * @param $value Value of the field
- * @return void
- */
- public function setEventItem($name, $value)
- {
- $this->_extras = array_merge($this->_extras, array($name => $value));
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Exception.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Exception.php
deleted file mode 100644
index 579babd..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Exception.php
+++ /dev/null
@@ -1,48 +0,0 @@
-_regexp = $regexp;
- }
-
- /**
- * Create a new instance of Microsoft_Log_Filter_Message
- *
- * @param array $config
- * @return Microsoft_Log_Filter_Message
- * @throws Microsoft_Log_Exception
- */
- static public function factory($config)
- {
- $config = self::_parseConfig($config);
- $config = array_merge(array(
- 'regexp' => null
- ), $config);
-
- return new self(
- $config['regexp']
- );
- }
-
- /**
- * Returns TRUE to accept the message, FALSE to block it.
- *
- * @param array $event event data
- * @return boolean accepted?
- */
- public function accept($event)
- {
- return preg_match($this->_regexp, $event['message']) > 0;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Filter/Priority.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Filter/Priority.php
deleted file mode 100644
index d9547f9..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Filter/Priority.php
+++ /dev/null
@@ -1,101 +0,0 @@
-_priority = $priority;
- $this->_operator = is_null($operator) ? '<=' : $operator;
- }
-
- /**
- * Create a new instance of Microsoft_Log_Filter_Priority
- *
- * @param array $config
- * @return Microsoft_Log_Filter_Priority
- * @throws Microsoft_Log_Exception
- */
- static public function factory($config)
- {
- $config = self::_parseConfig($config);
- $config = array_merge(array(
- 'priority' => null,
- 'operator' => null,
- ), $config);
-
- // Add support for constants
- if (!is_numeric($config['priority']) && isset($config['priority']) && defined($config['priority'])) {
- $config['priority'] = constant($config['priority']);
- }
-
- return new self(
- (int) $config['priority'],
- $config['operator']
- );
- }
-
- /**
- * Returns TRUE to accept the message, FALSE to block it.
- *
- * @param array $event event data
- * @return boolean accepted?
- */
- public function accept($event)
- {
- return version_compare($event['priority'], $this->_priority, $this->_operator);
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Filter/Suppress.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Filter/Suppress.php
deleted file mode 100644
index 64b4d99..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Filter/Suppress.php
+++ /dev/null
@@ -1,77 +0,0 @@
-_accept = (! $suppress);
- }
-
- /**
- * Returns TRUE to accept the message, FALSE to block it.
- *
- * @param array $event event data
- * @return boolean accepted?
- */
- public function accept($event)
- {
- return $this->_accept;
- }
-
- /**
- * Create a new instance of Microsoft_Log_Filter_Suppress
- *
- * @param array $config
- * @return Microsoft_Log_Filter_Suppress
- * @throws Microsoft_Log_Exception
- */
- static public function factory($config)
- {
- return new self();
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Formatter/Interface.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Formatter/Interface.php
deleted file mode 100644
index 12b38cb..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Log/Formatter/Interface.php
+++ /dev/null
@@ -1,41 +0,0 @@
-_filters[] = $filter;
- }
-
- /**
- * Log a message to this writer.
- *
- * @param array $event log data event
- * @return void
- */
- public function write($event)
- {
- foreach ($this->_filters as $filter) {
- if (! $filter->accept($event)) {
- return;
- }
- }
-
- // exception occurs on error
- $this->_write($event);
- }
-
- /**
- * Set a new formatter for this writer
- *
- * @param Microsoft_Log_Formatter_Interface $formatter
- * @return void
- */
- public function setFormatter(Microsoft_Log_Formatter_Interface $formatter)
- {
- $this->_formatter = $formatter;
- }
-
- /**
- * Perform shutdown activites such as closing open resources
- *
- * @return void
- */
- public function shutdown()
- {}
-
- /**
- * Write a message to the log.
- *
- * @param array $event log data event
- * @return void
- */
- abstract protected function _write($event);
-
- /**
- * Validate and optionally convert the config to array
- *
- * @param array $config
- * @return array
- * @throws Zend_Log_Exception
- */
- static protected function _parseConfig($config)
- {
- if (!is_array($config)) {
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception(
- 'Configuration must be an array'
- );
- }
-
- return $config;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Uri.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Uri.php
deleted file mode 100644
index 9ff7e1c..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Uri.php
+++ /dev/null
@@ -1,188 +0,0 @@
- false
- );
-
- /**
- * Return a string representation of this URI.
- *
- * @see getUri()
- * @return string
- */
- public function __toString()
- {
- return $this->getUri();
- }
-
- /**
- * Convenience function, checks that a $uri string is well-formed
- * by validating it but not returning an object. Returns TRUE if
- * $uri is a well-formed URI, or FALSE otherwise.
- *
- * @param string $uri The URI to check
- * @return boolean
- */
- public static function check($uri)
- {
- try {
- $uri = self::factory($uri);
- } catch (Exception $e) {
- return false;
- }
-
- return $uri->valid();
- }
-
- /**
- * Create a new Microsoft_Uri object for a URI. If building a new URI, then $uri should contain
- * only the scheme (http, ftp, etc). Otherwise, supply $uri with the complete URI.
- *
- * @param string $uri The URI form which a Microsoft_Uri instance is created
- * @throws Microsoft_Uri_Exception When an empty string was supplied for the scheme
- * @throws Microsoft_Uri_Exception When an illegal scheme is supplied
- * @throws Microsoft_Uri_Exception When the scheme is not supported
- * @return Microsoft_Uri
- * @link http://www.faqs.org/rfcs/rfc2396.html
- */
- public static function factory($uri = 'http')
- {
- // Separate the scheme from the scheme-specific parts
- $uri = explode(':', $uri, 2);
- $scheme = strtolower($uri[0]);
- $schemeSpecific = isset($uri[1]) === true ? $uri[1] : '';
-
- if (strlen($scheme) === 0) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('An empty string was supplied for the scheme');
- }
-
- // Security check: $scheme is used to load a class file, so only alphanumerics are allowed.
- if (ctype_alnum($scheme) === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted');
- }
-
- /**
- * Create a new Microsoft_Uri object for the $uri. If a subclass of Microsoft_Uri exists for the
- * scheme, return an instance of that class. Otherwise, a Microsoft_Uri_Exception is thrown.
- */
- switch ($scheme) {
- case 'http':
- // Break intentionally omitted
- case 'https':
- $className = 'Microsoft_Uri_Http';
- break;
-
- case 'mailto':
- // TODO
- default:
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception("Scheme \"$scheme\" is not supported");
- break;
- }
-
- if (!class_exists($className)) {
- require_once str_replace('_', '/', $className) . '.php';
- }
- $schemeHandler = new $className($scheme, $schemeSpecific);
-
- return $schemeHandler;
- }
-
- /**
- * Get the URI's scheme
- *
- * @return string|false Scheme or false if no scheme is set.
- */
- public function getScheme()
- {
- if (empty($this->_scheme) === false) {
- return $this->_scheme;
- } else {
- return false;
- }
- }
-
- /**
- * Set global configuration options
- *
- * @param Microsoft_Config|array $config
- */
- static public function setConfig($config)
- {
- if ($config instanceof Microsoft_Config) {
- $config = $config->toArray();
- } elseif (!is_array($config)) {
- throw new Microsoft_Uri_Exception("Config must be an array or an instance of Microsoft_Config.");
- }
-
- foreach ($config as $k => $v) {
- self::$_config[$k] = $v;
- }
- }
-
- /**
- * Microsoft_Uri and its subclasses cannot be instantiated directly.
- * Use Microsoft_Uri::factory() to return a new Microsoft_Uri object.
- *
- * @param string $scheme The scheme of the URI
- * @param string $schemeSpecific The scheme-specific part of the URI
- */
- abstract protected function __construct($scheme, $schemeSpecific = '');
-
- /**
- * Return a string representation of this URI.
- *
- * @return string
- */
- abstract public function getUri();
-
- /**
- * Returns TRUE if this URI is valid, or FALSE otherwise.
- *
- * @return boolean
- */
- abstract public function valid();
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Uri/Exception.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Uri/Exception.php
deleted file mode 100644
index 0ba9f1b..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/Uri/Exception.php
+++ /dev/null
@@ -1,37 +0,0 @@
-_scheme = $scheme;
-
- // Set up grammar rules for validation via regular expressions. These
- // are to be used with slash-delimited regular expression strings.
-
- // Escaped special characters (eg. '%25' for '%')
- $this->_regex['escaped'] = '%[[:xdigit:]]{2}';
-
- // Unreserved characters
- $this->_regex['unreserved'] = '[' . self::CHAR_ALNUM . self::CHAR_MARK . ']';
-
- // Segment can use escaped, unreserved or a set of additional chars
- $this->_regex['segment'] = '(?:' . $this->_regex['escaped'] . '|[' .
- self::CHAR_ALNUM . self::CHAR_MARK . self::CHAR_SEGMENT . '])*';
-
- // Path can be a series of segmets char strings seperated by '/'
- $this->_regex['path'] = '(?:\/(?:' . $this->_regex['segment'] . ')?)+';
-
- // URI characters can be escaped, alphanumeric, mark or reserved chars
- $this->_regex['uric'] = '(?:' . $this->_regex['escaped'] . '|[' .
- self::CHAR_ALNUM . self::CHAR_MARK . self::CHAR_RESERVED .
-
- // If unwise chars are allowed, add them to the URI chars class
- (self::$_config['allow_unwise'] ? self::CHAR_UNWISE : '') . '])';
-
- // If no scheme-specific part was supplied, the user intends to create
- // a new URI with this object. No further parsing is required.
- if (strlen($schemeSpecific) === 0) {
- return;
- }
-
- // Parse the scheme-specific URI parts into the instance variables.
- $this->_parseUri($schemeSpecific);
-
- // Validate the URI
- if ($this->valid() === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('Invalid URI supplied');
- }
- }
-
- /**
- * Creates a Microsoft_Uri_Http from the given string
- *
- * @param string $uri String to create URI from, must start with
- * 'http://' or 'https://'
- * @throws InvalidArgumentException When the given $uri is not a string or
- * does not start with http:// or https://
- * @throws Microsoft_Uri_Exception When the given $uri is invalid
- * @return Microsoft_Uri_Http
- */
- public static function fromString($uri)
- {
- if (is_string($uri) === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('$uri is not a string');
- }
-
- $uri = explode(':', $uri, 2);
- $scheme = strtolower($uri[0]);
- $schemeSpecific = isset($uri[1]) === true ? $uri[1] : '';
-
- if (in_array($scheme, array('http', 'https')) === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception("Invalid scheme: '$scheme'");
- }
-
- $schemeHandler = new Microsoft_Uri_Http($scheme, $schemeSpecific);
- return $schemeHandler;
- }
-
- /**
- * Parse the scheme-specific portion of the URI and place its parts into instance variables.
- *
- * @param string $schemeSpecific The scheme-specific portion to parse
- * @throws Microsoft_Uri_Exception When scheme-specific decoposition fails
- * @throws Microsoft_Uri_Exception When authority decomposition fails
- * @return void
- */
- protected function _parseUri($schemeSpecific)
- {
- // High-level decomposition parser
- $pattern = '~^((//)([^/?#]*))([^?#]*)(\?([^#]*))?(#(.*))?$~';
- $status = @preg_match($pattern, $schemeSpecific, $matches);
- if ($status === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('Internal error: scheme-specific decomposition failed');
- }
-
- // Failed decomposition; no further processing needed
- if ($status === false) {
- return;
- }
-
- // Save URI components that need no further decomposition
- $this->_path = isset($matches[4]) === true ? $matches[4] : '';
- $this->_query = isset($matches[6]) === true ? $matches[6] : '';
- $this->_fragment = isset($matches[8]) === true ? $matches[8] : '';
-
- // Additional decomposition to get username, password, host, and port
- $combo = isset($matches[3]) === true ? $matches[3] : '';
- $pattern = '~^(([^:@]*)(:([^@]*))?@)?([^:]+)(:(.*))?$~';
- $status = @preg_match($pattern, $combo, $matches);
- if ($status === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('Internal error: authority decomposition failed');
- }
-
- // Failed decomposition; no further processing needed
- if ($status === false) {
- return;
- }
-
- // Save remaining URI components
- $this->_username = isset($matches[2]) === true ? $matches[2] : '';
- $this->_password = isset($matches[4]) === true ? $matches[4] : '';
- $this->_host = isset($matches[5]) === true ? $matches[5] : '';
- $this->_port = isset($matches[7]) === true ? $matches[7] : '';
-
- }
-
- /**
- * Returns a URI based on current values of the instance variables. If any
- * part of the URI does not pass validation, then an exception is thrown.
- *
- * @throws Microsoft_Uri_Exception When one or more parts of the URI are invalid
- * @return string
- */
- public function getUri()
- {
- if ($this->valid() === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('One or more parts of the URI are invalid');
- }
-
- $password = strlen($this->_password) > 0 ? ":$this->_password" : '';
- $auth = strlen($this->_username) > 0 ? "$this->_username$password@" : '';
- $port = strlen($this->_port) > 0 ? ":$this->_port" : '';
- $query = strlen($this->_query) > 0 ? "?$this->_query" : '';
- $fragment = strlen($this->_fragment) > 0 ? "#$this->_fragment" : '';
-
- return $this->_scheme
- . '://'
- . $auth
- . $this->_host
- . $port
- . $this->_path
- . $query
- . $fragment;
- }
-
- /**
- * Validate the current URI from the instance variables. Returns true if and only if all
- * parts pass validation.
- *
- * @return boolean
- */
- public function valid()
- {
- // Return true if and only if all parts of the URI have passed validation
- return $this->validateUsername()
- and $this->validatePassword()
- and $this->validateHost()
- and $this->validatePort()
- and $this->validatePath()
- and $this->validateQuery()
- and $this->validateFragment();
- }
-
- /**
- * Returns the username portion of the URL, or FALSE if none.
- *
- * @return string
- */
- public function getUsername()
- {
- return strlen($this->_username) > 0 ? $this->_username : false;
- }
-
- /**
- * Returns true if and only if the username passes validation. If no username is passed,
- * then the username contained in the instance variable is used.
- *
- * @param string $username The HTTP username
- * @throws Microsoft_Uri_Exception When username validation fails
- * @return boolean
- * @link http://www.faqs.org/rfcs/rfc2396.html
- */
- public function validateUsername($username = null)
- {
- if ($username === null) {
- $username = $this->_username;
- }
-
- // If the username is empty, then it is considered valid
- if (strlen($username) === 0) {
- return true;
- }
-
- // Check the username against the allowed values
- $status = @preg_match('/^(?:' . $this->_regex['escaped'] . '|[' .
- self::CHAR_ALNUM . self::CHAR_MARK . ';:&=+$,' . '])+$/', $username);
-
- if ($status === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('Internal error: username validation failed');
- }
-
- return $status === 1;
- }
-
- /**
- * Sets the username for the current URI, and returns the old username
- *
- * @param string $username The HTTP username
- * @throws Microsoft_Uri_Exception When $username is not a valid HTTP username
- * @return string
- */
- public function setUsername($username)
- {
- if ($this->validateUsername($username) === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception("Username \"$username\" is not a valid HTTP username");
- }
-
- $oldUsername = $this->_username;
- $this->_username = $username;
-
- return $oldUsername;
- }
-
- /**
- * Returns the password portion of the URL, or FALSE if none.
- *
- * @return string
- */
- public function getPassword()
- {
- return strlen($this->_password) > 0 ? $this->_password : false;
- }
-
- /**
- * Returns true if and only if the password passes validation. If no password is passed,
- * then the password contained in the instance variable is used.
- *
- * @param string $password The HTTP password
- * @throws Microsoft_Uri_Exception When password validation fails
- * @return boolean
- * @link http://www.faqs.org/rfcs/rfc2396.html
- */
- public function validatePassword($password = null)
- {
- if ($password === null) {
- $password = $this->_password;
- }
-
- // If the password is empty, then it is considered valid
- if (strlen($password) === 0) {
- return true;
- }
-
- // If the password is nonempty, but there is no username, then it is considered invalid
- if (strlen($password) > 0 and strlen($this->_username) === 0) {
- return false;
- }
-
- // Check the password against the allowed values
- $status = @preg_match('/^(?:' . $this->_regex['escaped'] . '|[' .
- self::CHAR_ALNUM . self::CHAR_MARK . ';:&=+$,' . '])+$/', $password);
-
- if ($status === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('Internal error: password validation failed.');
- }
-
- return $status == 1;
- }
-
- /**
- * Sets the password for the current URI, and returns the old password
- *
- * @param string $password The HTTP password
- * @throws Microsoft_Uri_Exception When $password is not a valid HTTP password
- * @return string
- */
- public function setPassword($password)
- {
- if ($this->validatePassword($password) === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception("Password \"$password\" is not a valid HTTP password.");
- }
-
- $oldPassword = $this->_password;
- $this->_password = $password;
-
- return $oldPassword;
- }
-
- /**
- * Returns the domain or host IP portion of the URL, or FALSE if none.
- *
- * @return string
- */
- public function getHost()
- {
- return strlen($this->_host) > 0 ? $this->_host : false;
- }
-
- /**
- * Returns true if and only if the host string passes validation. If no host is passed,
- * then the host contained in the instance variable is used.
- *
- * @param string $host The HTTP host
- * @return boolean
- * @uses Microsoft_Filter
- */
- public function validateHost($host = null)
- {
- if ($host === null) {
- $host = $this->_host;
- }
-
- // If the host is empty, then it is considered invalid
- if (strlen($host) === 0) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Sets the host for the current URI, and returns the old host
- *
- * @param string $host The HTTP host
- * @throws Microsoft_Uri_Exception When $host is nota valid HTTP host
- * @return string
- */
- public function setHost($host)
- {
- if ($this->validateHost($host) === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception("Host \"$host\" is not a valid HTTP host");
- }
-
- $oldHost = $this->_host;
- $this->_host = $host;
-
- return $oldHost;
- }
-
- /**
- * Returns the TCP port, or FALSE if none.
- *
- * @return string
- */
- public function getPort()
- {
- return strlen($this->_port) > 0 ? $this->_port : false;
- }
-
- /**
- * Returns true if and only if the TCP port string passes validation. If no port is passed,
- * then the port contained in the instance variable is used.
- *
- * @param string $port The HTTP port
- * @return boolean
- */
- public function validatePort($port = null)
- {
- if ($port === null) {
- $port = $this->_port;
- }
-
- // If the port is empty, then it is considered valid
- if (strlen($port) === 0) {
- return true;
- }
-
- // Check the port against the allowed values
- return ctype_digit((string) $port) and 1 <= $port and $port <= 65535;
- }
-
- /**
- * Sets the port for the current URI, and returns the old port
- *
- * @param string $port The HTTP port
- * @throws Microsoft_Uri_Exception When $port is not a valid HTTP port
- * @return string
- */
- public function setPort($port)
- {
- if ($this->validatePort($port) === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception("Port \"$port\" is not a valid HTTP port.");
- }
-
- $oldPort = $this->_port;
- $this->_port = $port;
-
- return $oldPort;
- }
-
- /**
- * Returns the path and filename portion of the URL, or FALSE if none.
- *
- * @return string
- */
- public function getPath()
- {
- return strlen($this->_path) > 0 ? $this->_path : '/';
- }
-
- /**
- * Returns true if and only if the path string passes validation. If no path is passed,
- * then the path contained in the instance variable is used.
- *
- * @param string $path The HTTP path
- * @throws Microsoft_Uri_Exception When path validation fails
- * @return boolean
- */
- public function validatePath($path = null)
- {
- if ($path === null) {
- $path = $this->_path;
- }
-
- // If the path is empty, then it is considered valid
- if (strlen($path) === 0) {
- return true;
- }
-
- // Determine whether the path is well-formed
- $pattern = '/^' . $this->_regex['path'] . '$/';
- $status = @preg_match($pattern, $path);
- if ($status === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('Internal error: path validation failed');
- }
-
- return (boolean) $status;
- }
-
- /**
- * Sets the path for the current URI, and returns the old path
- *
- * @param string $path The HTTP path
- * @throws Microsoft_Uri_Exception When $path is not a valid HTTP path
- * @return string
- */
- public function setPath($path)
- {
- if ($this->validatePath($path) === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception("Path \"$path\" is not a valid HTTP path");
- }
-
- $oldPath = $this->_path;
- $this->_path = $path;
-
- return $oldPath;
- }
-
- /**
- * Returns the query portion of the URL (after ?), or FALSE if none.
- *
- * @return string
- */
- public function getQuery()
- {
- return strlen($this->_query) > 0 ? $this->_query : false;
- }
-
- /**
- * Returns the query portion of the URL (after ?) as a
- * key-value-array. If the query is empty an empty array
- * is returned
- *
- * @return array
- */
- public function getQueryAsArray()
- {
- $query = $this->getQuery();
- $querryArray = array();
- if ($query !== false) {
- parse_str($query, $querryArray);
- }
- return $querryArray;
- }
-
- /**
- * Returns true if and only if the query string passes validation. If no query is passed,
- * then the query string contained in the instance variable is used.
- *
- * @param string $query The query to validate
- * @throws Microsoft_Uri_Exception When query validation fails
- * @return boolean
- * @link http://www.faqs.org/rfcs/rfc2396.html
- */
- public function validateQuery($query = null)
- {
- if ($query === null) {
- $query = $this->_query;
- }
-
- // If query is empty, it is considered to be valid
- if (strlen($query) === 0) {
- return true;
- }
-
- // Determine whether the query is well-formed
- $pattern = '/^' . $this->_regex['uric'] . '*$/';
- $status = @preg_match($pattern, $query);
- if ($status === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('Internal error: query validation failed');
- }
-
- return $status == 1;
- }
-
- /**
- * Add or replace params in the query string for the current URI, and
- * return the old query.
- *
- * @param array $queryParams
- * @return string Old query string
- */
- public function addReplaceQueryParameters(array $queryParams)
- {
- $queryParams = array_merge($this->getQueryAsArray(), $queryParams);
- return $this->setQuery($queryParams);
- }
-
- /**
- * Remove params in the query string for the current URI, and
- * return the old query.
- *
- * @param array $queryParamKeys
- * @return string Old query string
- */
- public function removeQueryParameters(array $queryParamKeys)
- {
- $queryParams = array_diff_key($this->getQueryAsArray(), array_fill_keys($queryParamKeys, 0));
- return $this->setQuery($queryParams);
- }
-
- /**
- * Set the query string for the current URI, and return the old query
- * string This method accepts both strings and arrays.
- *
- * @param string|array $query The query string or array
- * @throws Microsoft_Uri_Exception When $query is not a valid query string
- * @return string Old query string
- */
- public function setQuery($query)
- {
- $oldQuery = $this->_query;
-
- // If query is empty, set an empty string
- if (empty($query) === true) {
- $this->_query = '';
- return $oldQuery;
- }
-
- // If query is an array, make a string out of it
- if (is_array($query) === true) {
- $query = http_build_query($query, '', '&');
- } else {
- // If it is a string, make sure it is valid. If not parse and encode it
- $query = (string) $query;
- if ($this->validateQuery($query) === false) {
- parse_str($query, $queryArray);
- $query = http_build_query($queryArray, '', '&');
- }
- }
-
- // Make sure the query is valid, and set it
- if ($this->validateQuery($query) === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception("'$query' is not a valid query string");
- }
-
- $this->_query = $query;
-
- return $oldQuery;
- }
-
- /**
- * Returns the fragment portion of the URL (after #), or FALSE if none.
- *
- * @return string|false
- */
- public function getFragment()
- {
- return strlen($this->_fragment) > 0 ? $this->_fragment : false;
- }
-
- /**
- * Returns true if and only if the fragment passes validation. If no fragment is passed,
- * then the fragment contained in the instance variable is used.
- *
- * @param string $fragment Fragment of an URI
- * @throws Microsoft_Uri_Exception When fragment validation fails
- * @return boolean
- * @link http://www.faqs.org/rfcs/rfc2396.html
- */
- public function validateFragment($fragment = null)
- {
- if ($fragment === null) {
- $fragment = $this->_fragment;
- }
-
- // If fragment is empty, it is considered to be valid
- if (strlen($fragment) === 0) {
- return true;
- }
-
- // Determine whether the fragment is well-formed
- $pattern = '/^' . $this->_regex['uric'] . '*$/';
- $status = @preg_match($pattern, $fragment);
- if ($status === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception('Internal error: fragment validation failed');
- }
-
- return (boolean) $status;
- }
-
- /**
- * Sets the fragment for the current URI, and returns the old fragment
- *
- * @param string $fragment Fragment of the current URI
- * @throws Microsoft_Uri_Exception When $fragment is not a valid HTTP fragment
- * @return string
- */
- public function setFragment($fragment)
- {
- if ($this->validateFragment($fragment) === false) {
- require_once 'Microsoft/Uri/Exception.php';
- throw new Microsoft_Uri_Exception("Fragment \"$fragment\" is not a valid HTTP fragment");
- }
-
- $oldFragment = $this->_fragment;
- $this->_fragment = $fragment;
-
- return $oldFragment;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/CredentialsAbstract.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/CredentialsAbstract.php
deleted file mode 100644
index d9d3cca..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/CredentialsAbstract.php
+++ /dev/null
@@ -1,257 +0,0 @@
-_accountName = $accountName;
- $this->_accountKey = base64_decode($accountKey);
- $this->_usePathStyleUri = $usePathStyleUri;
- }
-
- /**
- * Set account name for Windows Azure
- *
- * @param string $value
- * @return Microsoft_WindowsAzure_Credentials_CredentialsAbstract
- */
- public function setAccountName($value = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_ACCOUNT)
- {
- $this->_accountName = $value;
- return $this;
- }
-
- /**
- * Set account key for Windows Azure
- *
- * @param string $value
- * @return Microsoft_WindowsAzure_Credentials_CredentialsAbstract
- */
- public function setAccountkey($value = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_KEY)
- {
- $this->_accountKey = base64_decode($value);
- return $this;
- }
-
- /**
- * Set use path-style URI's
- *
- * @param boolean $value
- * @return Microsoft_WindowsAzure_Credentials_CredentialsAbstract
- */
- public function setUsePathStyleUri($value = false)
- {
- $this->_usePathStyleUri = $value;
- return $this;
- }
-
- /**
- * Sign request URL with credentials
- *
- * @param string $requestUrl Request URL
- * @param string $resourceType Resource type
- * @param string $requiredPermission Required permission
- * @return string Signed request URL
- */
- abstract public function signRequestUrl(
- $requestUrl = '',
- $resourceType = Microsoft_WindowsAzure_Storage::RESOURCE_UNKNOWN,
- $requiredPermission = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ
- );
-
- /**
- * Sign request headers with credentials
- *
- * @param string $httpVerb HTTP verb the request will use
- * @param string $path Path for the request
- * @param string $queryString Query string for the request
- * @param array $headers x-ms headers to add
- * @param boolean $forTableStorage Is the request for table storage?
- * @param string $resourceType Resource type
- * @param string $requiredPermission Required permission
- * @param mixed $rawData Raw post data
- * @return array Array of headers
- */
- abstract public function signRequestHeaders(
- $httpVerb = Microsoft_Http_Client::GET,
- $path = '/',
- $queryString = '',
- $headers = null,
- $forTableStorage = false,
- $resourceType = Microsoft_WindowsAzure_Storage::RESOURCE_UNKNOWN,
- $requiredPermission = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ,
- $rawData = null
- );
-
-
- /**
- * Prepare query string for signing
- *
- * @param string $value Original query string
- * @return string Query string for signing
- */
- protected function _prepareQueryStringForSigning($value)
- {
- // Return value
- $returnValue = array();
-
- // Prepare query string
- $queryParts = $this->_makeArrayOfQueryString($value);
- foreach ($queryParts as $key => $value) {
- $returnValue[] = $key . '=' . $value;
- }
-
- // Return
- if (count($returnValue) > 0) {
- return '?' . implode('&', $returnValue);
- } else {
- return '';
- }
- }
-
- /**
- * Make array of query string
- *
- * @param string $value Query string
- * @return array Array of key/value pairs
- */
- protected function _makeArrayOfQueryString($value)
- {
- // Returnvalue
- $returnValue = array();
-
- // Remove front ?
- if (strlen($value) > 0 && strpos($value, '?') === 0) {
- $value = substr($value, 1);
- }
-
- // Split parts
- $queryParts = explode('&', $value);
- foreach ($queryParts as $queryPart) {
- $queryPart = explode('=', $queryPart, 2);
-
- if ($queryPart[0] != '') {
- $returnValue[ $queryPart[0] ] = isset($queryPart[1]) ? $queryPart[1] : '';
- }
- }
-
- // Sort
- ksort($returnValue);
-
- // Return
- return $returnValue;
- }
-
- /**
- * Returns an array value if the key is set, otherwide returns $valueIfNotSet
- *
- * @param array $array
- * @param mixed $key
- * @param mixed $valueIfNotSet
- * @return mixed
- */
- protected function _issetOr($array, $key, $valueIfNotSet)
- {
- return isset($array[$key]) ? $array[$key] : $valueIfNotSet;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/Exception.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/Exception.php
deleted file mode 100644
index 541c11f..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/Exception.php
+++ /dev/null
@@ -1,48 +0,0 @@
-_permissionSet = $permissionSet;
- }
-
- /**
- * Get permission set
- *
- * @return array
- */
- public function getPermissionSet()
- {
- return $this->_permissionSet;
- }
-
- /**
- * Set permisison set
- *
- * Warning: fine-grained permissions should be added prior to coarse-grained permissions.
- * For example: first add blob permissions, end with container-wide permissions.
- *
- * Warning: the signed access signature URL must match the account name of the
- * Microsoft_WindowsAzure_Credentials_Microsoft_WindowsAzure_Credentials_SharedAccessSignature instance
- *
- * @param array $value Permission set
- * @return void
- */
- public function setPermissionSet($value = array())
- {
- foreach ($value as $url) {
- if (strpos($url, $this->_accountName) === false) {
- throw new Microsoft_WindowsAzure_Exception('The permission set can only contain URLs for the account name specified in the Microsoft_WindowsAzure_Credentials_SharedAccessSignature instance.');
- }
- }
- $this->_permissionSet = $value;
- }
-
- /**
- * Create signature
- *
- * @param string $path Path for the request
- * @param string $resource Signed resource - container (c) - blob (b)
- * @param string $permissions Signed permissions - read (r), write (w), delete (d) and list (l)
- * @param string $start The time at which the Shared Access Signature becomes valid.
- * @param string $expiry The time at which the Shared Access Signature becomes invalid.
- * @param string $identifier Signed identifier
- * @return string
- */
- public function createSignature(
- $path = '/',
- $resource = 'b',
- $permissions = 'r',
- $start = '',
- $expiry = '',
- $identifier = ''
- ) {
- // Determine path
- if ($this->_usePathStyleUri) {
- $path = substr($path, strpos($path, '/'));
- }
-
- // Add trailing slash to $path
- if (substr($path, 0, 1) !== '/') {
- $path = '/' . $path;
- }
-
- // Build canonicalized resource string
- $canonicalizedResource = '/' . $this->_accountName;
- /*if ($this->_usePathStyleUri) {
- $canonicalizedResource .= '/' . $this->_accountName;
- }*/
- $canonicalizedResource .= $path;
-
- // Create string to sign
- $stringToSign = array();
- $stringToSign[] = $permissions;
- $stringToSign[] = $start;
- $stringToSign[] = $expiry;
- $stringToSign[] = $canonicalizedResource;
- $stringToSign[] = $identifier;
-
- $stringToSign = implode("\n", $stringToSign);
- $signature = base64_encode(hash_hmac('sha256', $stringToSign, $this->_accountKey, true));
-
- return $signature;
- }
-
- /**
- * Create signed query string
- *
- * @param string $path Path for the request
- * @param string $queryString Query string for the request
- * @param string $resource Signed resource - container (c) - blob (b)
- * @param string $permissions Signed permissions - read (r), write (w), delete (d) and list (l)
- * @param string $start The time at which the Shared Access Signature becomes valid.
- * @param string $expiry The time at which the Shared Access Signature becomes invalid.
- * @param string $identifier Signed identifier
- * @return string
- */
- public function createSignedQueryString(
- $path = '/',
- $queryString = '',
- $resource = 'b',
- $permissions = 'r',
- $start = '',
- $expiry = '',
- $identifier = ''
- ) {
- // Parts
- $parts = array();
- if ($start !== '') {
- $parts[] = 'st=' . urlencode($start);
- }
- $parts[] = 'se=' . urlencode($expiry);
- $parts[] = 'sr=' . $resource;
- $parts[] = 'sp=' . $permissions;
- if ($identifier !== '') {
- $parts[] = 'si=' . urlencode($identifier);
- }
- $parts[] = 'sig=' . urlencode($this->createSignature($path, $resource, $permissions, $start, $expiry, $identifier));
-
- // Assemble parts and query string
- if ($queryString != '') {
- $queryString .= '&';
- }
- $queryString .= implode('&', $parts);
-
- return $queryString;
- }
-
- /**
- * Permission matches request?
- *
- * @param string $permissionUrl Permission URL
- * @param string $requestUrl Request URL
- * @param string $resourceType Resource type
- * @param string $requiredPermission Required permission
- * @return string Signed request URL
- */
- public function permissionMatchesRequest(
- $permissionUrl = '',
- $requestUrl = '',
- $resourceType = Microsoft_WindowsAzure_Storage::RESOURCE_UNKNOWN,
- $requiredPermission = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ
- ) {
- // Build requirements
- $requiredResourceType = $resourceType;
- if ($requiredResourceType == Microsoft_WindowsAzure_Storage::RESOURCE_BLOB) {
- $requiredResourceType .= Microsoft_WindowsAzure_Storage::RESOURCE_CONTAINER;
- }
-
- // Parse permission url
- $parsedPermissionUrl = parse_url($permissionUrl);
-
- // Parse permission properties
- $permissionParts = explode('&', $parsedPermissionUrl['query']);
-
- // Parse request url
- $parsedRequestUrl = parse_url($requestUrl);
-
- // Check if permission matches request
- $matches = true;
- foreach ($permissionParts as $part) {
- list($property, $value) = explode('=', $part, 2);
-
- if ($property == 'sr') {
- $matches = $matches && (strpbrk($value, $requiredResourceType) !== false);
- }
-
- if ($property == 'sp') {
- $matches = $matches && (strpbrk($value, $requiredPermission) !== false);
- }
- }
-
- // Ok, but... does the resource match?
- $matches = $matches && (strpos($parsedRequestUrl['path'], $parsedPermissionUrl['path']) !== false);
-
- // Return
- return $matches;
- }
-
- /**
- * Sign request URL with credentials
- *
- * @param string $requestUrl Request URL
- * @param string $resourceType Resource type
- * @param string $requiredPermission Required permission
- * @return string Signed request URL
- */
- public function signRequestUrl(
- $requestUrl = '',
- $resourceType = Microsoft_WindowsAzure_Storage::RESOURCE_UNKNOWN,
- $requiredPermission = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ
- ) {
- // Look for a matching permission
- foreach ($this->getPermissionSet() as $permittedUrl) {
- if ($this->permissionMatchesRequest($permittedUrl, $requestUrl, $resourceType, $requiredPermission)) {
- // This matches, append signature data
- $parsedPermittedUrl = parse_url($permittedUrl);
-
- if (strpos($requestUrl, '?') === false) {
- $requestUrl .= '?';
- } else {
- $requestUrl .= '&';
- }
-
- $requestUrl .= $parsedPermittedUrl['query'];
-
- // Return url
- return $requestUrl;
- }
- }
-
- // Return url, will be unsigned...
- return $requestUrl;
- }
-
- /**
- * Sign request with credentials
- *
- * @param string $httpVerb HTTP verb the request will use
- * @param string $path Path for the request
- * @param string $queryString Query string for the request
- * @param array $headers x-ms headers to add
- * @param boolean $forTableStorage Is the request for table storage?
- * @param string $resourceType Resource type
- * @param string $requiredPermission Required permission
- * @param mixed $rawData Raw post data
- * @return array Array of headers
- */
- public function signRequestHeaders(
- $httpVerb = Microsoft_Http_Client::GET,
- $path = '/',
- $queryString = '',
- $headers = null,
- $forTableStorage = false,
- $resourceType = Microsoft_WindowsAzure_Storage::RESOURCE_UNKNOWN,
- $requiredPermission = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ,
- $rawData = null
- ) {
- return $headers;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/SharedKey.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/SharedKey.php
deleted file mode 100644
index 7f55570..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/SharedKey.php
+++ /dev/null
@@ -1,200 +0,0 @@
-_usePathStyleUri) {
- $path = substr($path, strpos($path, '/'));
- }
-
- // Determine query
- $queryString = $this->_prepareQueryStringForSigning($queryString);
-
- // Canonicalized headers
- $canonicalizedHeaders = array();
-
- // Request date
- $requestDate = '';
- if (isset($headers[Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER . 'date'])) {
- $requestDate = $headers[Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER . 'date'];
- } else {
- $requestDate = gmdate('D, d M Y H:i:s', time()) . ' GMT'; // RFC 1123
- $canonicalizedHeaders[] = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER . 'date:' . $requestDate;
- }
-
- // Build canonicalized headers
- if (!is_null($headers)) {
- foreach ($headers as $header => $value) {
- if (is_bool($value)) {
- $value = $value === true ? 'True' : 'False';
- }
-
- $headers[$header] = $value;
- if (substr($header, 0, strlen(Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER)) == Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER) {
- $canonicalizedHeaders[] = strtolower($header) . ':' . $value;
- }
- }
- }
- sort($canonicalizedHeaders);
-
- // Build canonicalized resource string
- $canonicalizedResource = '/' . $this->_accountName;
- if ($this->_usePathStyleUri) {
- $canonicalizedResource .= '/' . $this->_accountName;
- }
- $canonicalizedResource .= $path;
- if ($queryString !== '') {
- $queryStringItems = $this->_makeArrayOfQueryString($queryString);
- foreach ($queryStringItems as $key => $value) {
- $canonicalizedResource .= "\n" . strtolower($key) . ':' . $value;
- }
- }
-
- // Content-Length header
- $contentLength = '';
- if (strtoupper($httpVerb) != Microsoft_Http_Client::GET
- && strtoupper($httpVerb) != Microsoft_Http_Client::DELETE
- && strtoupper($httpVerb) != Microsoft_Http_Client::HEAD) {
- $contentLength = 0;
-
- if (!is_null($rawData)) {
- $contentLength = strlen($rawData);
- }
- }
-
- // Create string to sign
- $stringToSign = array();
- $stringToSign[] = strtoupper($httpVerb); // VERB
- $stringToSign[] = $this->_issetOr($headers, 'Content-Encoding', ''); // Content-Encoding
- $stringToSign[] = $this->_issetOr($headers, 'Content-Language', ''); // Content-Language
- $stringToSign[] = $contentLength; // Content-Length
- $stringToSign[] = $this->_issetOr($headers, 'Content-MD5', ''); // Content-MD5
- $stringToSign[] = $this->_issetOr($headers, 'Content-Type', ''); // Content-Type
- $stringToSign[] = ""; // Date
- $stringToSign[] = $this->_issetOr($headers, 'If-Modified-Since', ''); // If-Modified-Since
- $stringToSign[] = $this->_issetOr($headers, 'If-Match', ''); // If-Match
- $stringToSign[] = $this->_issetOr($headers, 'If-None-Match', ''); // If-None-Match
- $stringToSign[] = $this->_issetOr($headers, 'If-Unmodified-Since', ''); // If-Unmodified-Since
- $stringToSign[] = $this->_issetOr($headers, 'Range', ''); // Range
-
- if (!$forTableStorage && count($canonicalizedHeaders) > 0) {
- $stringToSign[] = implode("\n", $canonicalizedHeaders); // Canonicalized headers
- }
-
- $stringToSign[] = $canonicalizedResource; // Canonicalized resource
- $stringToSign = implode("\n", $stringToSign);
- $signString = base64_encode(hash_hmac('sha256', $stringToSign, $this->_accountKey, true));
-
- // Sign request
- $headers[Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER . 'date'] = $requestDate;
- $headers['Authorization'] = 'SharedKey ' . $this->_accountName . ':' . $signString;
-
- // Return headers
- return $headers;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/SharedKeyLite.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/SharedKeyLite.php
deleted file mode 100644
index fefa59a..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Credentials/SharedKeyLite.php
+++ /dev/null
@@ -1,179 +0,0 @@
-_usePathStyleUri) {
- $path = substr($path, strpos($path, '/'));
- }
-
- // Determine query
- $queryString = $this->_prepareQueryStringForSigning($queryString);
-
- // Build canonicalized resource string
- $canonicalizedResource = '/' . $this->_accountName;
- if ($this->_usePathStyleUri) {
- $canonicalizedResource .= '/' . $this->_accountName;
- }
- $canonicalizedResource .= $path;
- if ($queryString !== '') {
- $canonicalizedResource .= $queryString;
- }
-
- // Request date
- $requestDate = '';
- if (isset($headers[Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER . 'date'])) {
- $requestDate = $headers[Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER . 'date'];
- } else {
- $requestDate = gmdate('D, d M Y H:i:s', time()) . ' GMT'; // RFC 1123
- }
-
- // Create string to sign
- $stringToSign = array();
- $stringToSign[] = $requestDate; // Date
- $stringToSign[] = $canonicalizedResource; // Canonicalized resource
- $stringToSign = implode("\n", $stringToSign);
- $signString = base64_encode(hash_hmac('sha256', $stringToSign, $this->_accountKey, true));
-
- // Sign request
- $headers[Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PREFIX_STORAGE_HEADER . 'date'] = $requestDate;
- $headers['Authorization'] = 'SharedKeyLite ' . $this->_accountName . ':' . $signString;
-
- // Return headers
- return $headers;
- }
-
- /**
- * Prepare query string for signing
- *
- * @param string $value Original query string
- * @return string Query string for signing
- */
- protected function _prepareQueryStringForSigning($value)
- {
- // Check for 'comp='
- if (strpos($value, 'comp=') === false) {
- // If not found, no query string needed
- return '';
- } else {
- // If found, make sure it is the only parameter being used
- if (strlen($value) > 0 && strpos($value, '?') === 0) {
- $value = substr($value, 1);
- }
-
- // Split parts
- $queryParts = explode('&', $value);
- foreach ($queryParts as $queryPart) {
- if (strpos($queryPart, 'comp=') !== false) {
- return '?' . $queryPart;
- }
- }
-
- // Should never happen...
- return '';
- }
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationDataSources.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationDataSources.php
deleted file mode 100644
index 5e05650..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationDataSources.php
+++ /dev/null
@@ -1,104 +0,0 @@
-_data = array(
- 'overallquotainmb' => $overallQuotaInMB,
- 'logs' => new Microsoft_WindowsAzure_Diagnostics_ConfigurationLogs(),
- 'diagnosticinfrastructurelogs' => new Microsoft_WindowsAzure_Diagnostics_ConfigurationDiagnosticInfrastructureLogs(),
- 'performancecounters' => new Microsoft_WindowsAzure_Diagnostics_ConfigurationPerformanceCounters(),
- 'windowseventlog' => new Microsoft_WindowsAzure_Diagnostics_ConfigurationWindowsEventLog(),
- 'directories' => new Microsoft_WindowsAzure_Diagnostics_ConfigurationDirectories()
- );
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationDiagnosticInfrastructureLogs.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationDiagnosticInfrastructureLogs.php
deleted file mode 100644
index a8d00f7..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationDiagnosticInfrastructureLogs.php
+++ /dev/null
@@ -1,80 +0,0 @@
-_data = array(
- 'bufferquotainmb' => $bufferQuotaInMB,
- 'scheduledtransferperiodinminutes' => $scheduledTransferPeriodInMinutes,
- 'scheduledtransferloglevelfilter' => $scheduledTransferLogLevelFilter
- );
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationDirectories.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationDirectories.php
deleted file mode 100644
index 5df862a..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationDirectories.php
+++ /dev/null
@@ -1,103 +0,0 @@
-_data = array(
- 'bufferquotainmb' => $bufferQuotaInMB,
- 'scheduledtransferperiodinminutes' => $scheduledTransferPeriodInMinutes,
- 'subscriptions' => array()
- );
- }
-
- /**
- * Add subscription
- *
- * @param string $path Path
- * @param string $container Container
- * @param int $directoryQuotaInMB Directory quota in MB
- */
- public function addSubscription($path, $container, $directoryQuotaInMB = 1024)
- {
- $this->_data['subscriptions'][$path] = new Microsoft_WindowsAzure_Diagnostics_DirectoryConfigurationSubscription($path, $container, $directoryQuotaInMB);
- }
-
- /**
- * Remove subscription
- *
- * @param string $path Path
- */
- public function removeSubscription($path)
- {
- if (isset($this->_data['subscriptions'][$path])) {
- unset($this->_data['subscriptions'][$path]);
- }
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationInstance.php
deleted file mode 100644
index b1999cc..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationInstance.php
+++ /dev/null
@@ -1,235 +0,0 @@
-_data = array(
- 'datasources' => new Microsoft_WindowsAzure_Diagnostics_ConfigurationDataSources()
- );
- }
-
- /**
- * Load configuration XML
- *
- * @param string $configurationXml Configuration XML
- */
- public function loadXml($configurationXml)
- {
- // Convert to SimpleXMLElement
- $configurationXml = simplexml_load_string($configurationXml);
-
- // Assign general settings
- $this->DataSources->OverallQuotaInMB = (int)$configurationXml->DataSources->OverallQuotaInMB;
-
- // Assign Logs settings
- $this->DataSources->Logs->BufferQuotaInMB = (int)$configurationXml->DataSources->Logs->BufferQuotaInMB;
- $this->DataSources->Logs->ScheduledTransferPeriodInMinutes = (int)$configurationXml->DataSources->Logs->ScheduledTransferPeriodInMinutes;
- $this->DataSources->Logs->ScheduledTransferLogLevelFilter = (string)$configurationXml->DataSources->Logs->ScheduledTransferLogLevelFilter;
-
- // Assign DiagnosticInfrastructureLogs settings
- $this->DataSources->DiagnosticInfrastructureLogs->BufferQuotaInMB = (int)$configurationXml->DataSources->DiagnosticInfrastructureLogs->BufferQuotaInMB;
- $this->DataSources->DiagnosticInfrastructureLogs->ScheduledTransferPeriodInMinutes = (int)$configurationXml->DataSources->DiagnosticInfrastructureLogs->ScheduledTransferPeriodInMinutes;
- $this->DataSources->DiagnosticInfrastructureLogs->ScheduledTransferLogLevelFilter = (string)$configurationXml->DataSources->DiagnosticInfrastructureLogs->ScheduledTransferLogLevelFilter;
-
- // Assign PerformanceCounters settings
- $this->DataSources->PerformanceCounters->BufferQuotaInMB = (int)$configurationXml->DataSources->PerformanceCounters->BufferQuotaInMB;
- $this->DataSources->PerformanceCounters->ScheduledTransferPeriodInMinutes = (int)$configurationXml->DataSources->PerformanceCounters->ScheduledTransferPeriodInMinutes;
- if ($configurationXml->DataSources->PerformanceCounters->Subscriptions
- && $configurationXml->DataSources->PerformanceCounters->Subscriptions->PerformanceCounterConfiguration) {
- $subscriptions = $configurationXml->DataSources->PerformanceCounters->Subscriptions;
- if (count($subscriptions->PerformanceCounterConfiguration) > 1) {
- $subscriptions = $subscriptions->PerformanceCounterConfiguration;
- } else {
- $subscriptions = array($subscriptions->PerformanceCounterConfiguration);
- }
- foreach ($subscriptions as $subscription) {
- $this->DataSources->PerformanceCounters->addSubscription((string)$subscription->CounterSpecifier, (int)$subscription->SampleRateInSeconds);
- }
- }
-
- // Assign WindowsEventLog settings
- $this->DataSources->WindowsEventLog->BufferQuotaInMB = (int)$configurationXml->DataSources->WindowsEventLog->BufferQuotaInMB;
- $this->DataSources->WindowsEventLog->ScheduledTransferPeriodInMinutes = (int)$configurationXml->DataSources->WindowsEventLog->ScheduledTransferPeriodInMinutes;
- $this->DataSources->WindowsEventLog->ScheduledTransferLogLevelFilter = (string)$configurationXml->DataSources->WindowsEventLog->ScheduledTransferLogLevelFilter;
- if ($configurationXml->DataSources->WindowsEventLog->Subscriptions
- && $configurationXml->DataSources->WindowsEventLog->Subscriptions->string) {
- $subscriptions = $configurationXml->DataSources->WindowsEventLog->Subscriptions;
- if (count($subscriptions->string) > 1) {
- $subscriptions = $subscriptions->string;
- } else {
- $subscriptions = array($subscriptions->string);
- }
- foreach ($subscriptions as $subscription) {
- $this->DataSources->WindowsEventLog->addSubscription((string)$subscription);
- }
- }
-
- // Assign Directories settings
- $this->DataSources->Directories->BufferQuotaInMB = (int)$configurationXml->DataSources->Directories->BufferQuotaInMB;
- $this->DataSources->Directories->ScheduledTransferPeriodInMinutes = (int)$configurationXml->DataSources->Directories->ScheduledTransferPeriodInMinutes;
-
- if ($configurationXml->DataSources->Directories->Subscriptions
- && $configurationXml->DataSources->Directories->Subscriptions->DirectoryConfiguration) {
- $subscriptions = $configurationXml->DataSources->Directories->Subscriptions;
- if (count($subscriptions->DirectoryConfiguration) > 1) {
- $subscriptions = $subscriptions->DirectoryConfiguration;
- } else {
- $subscriptions = array($subscriptions->DirectoryConfiguration);
- }
- foreach ($subscriptions as $subscription) {
- $this->DataSources->Directories->addSubscription((string)$subscription->Path, (string)$subscription->Container, (int)$subscription->DirectoryQuotaInMB);
- }
- }
- }
-
- /**
- * Create configuration XML
- *
- * @return string
- */
- public function toXml()
- {
- // Return value
- $returnValue = array();
-
- // Build XML
- $returnValue[] = '';
- $returnValue[] = '';
-
- // Add data sources
- $returnValue[] = ' ';
-
- $returnValue[] = ' ' . $this->DataSources->OverallQuotaInMB . '';
-
- $returnValue[] = ' ';
- $returnValue[] = ' ' . $this->DataSources->Logs->BufferQuotaInMB . '';
- $returnValue[] = ' ' . $this->DataSources->Logs->ScheduledTransferPeriodInMinutes . '';
- $returnValue[] = ' ' . $this->DataSources->Logs->ScheduledTransferLogLevelFilter . '';
- $returnValue[] = ' ';
-
- $returnValue[] = ' ';
- $returnValue[] = ' ' . $this->DataSources->DiagnosticInfrastructureLogs->BufferQuotaInMB . '';
- $returnValue[] = ' ' . $this->DataSources->DiagnosticInfrastructureLogs->ScheduledTransferPeriodInMinutes . '';
- $returnValue[] = ' ' . $this->DataSources->DiagnosticInfrastructureLogs->ScheduledTransferLogLevelFilter . '';
- $returnValue[] = ' ';
-
- $returnValue[] = ' ';
- $returnValue[] = ' ' . $this->DataSources->PerformanceCounters->BufferQuotaInMB . '';
- $returnValue[] = ' ' . $this->DataSources->PerformanceCounters->ScheduledTransferPeriodInMinutes . '';
- if (count($this->DataSources->PerformanceCounters->Subscriptions) == 0) {
- $returnValue[] = ' ';
- } else {
- $returnValue[] = ' ';
- foreach ($this->DataSources->PerformanceCounters->Subscriptions as $subscription) {
- $returnValue[] = ' ';
- $returnValue[] = ' ' . $subscription->CounterSpecifier . '';
- $returnValue[] = ' ' . $subscription->SampleRateInSeconds . '';
- $returnValue[] = ' ';
- }
- $returnValue[] = ' ';
- }
- $returnValue[] = ' ';
-
- $returnValue[] = ' ';
- $returnValue[] = ' ' . $this->DataSources->WindowsEventLog->BufferQuotaInMB . '';
- $returnValue[] = ' ' . $this->DataSources->WindowsEventLog->ScheduledTransferPeriodInMinutes . '';
- if (count($this->DataSources->WindowsEventLog->Subscriptions) == 0) {
- $returnValue[] = ' ';
- } else {
- $returnValue[] = ' ';
- foreach ($this->DataSources->WindowsEventLog->Subscriptions as $subscription) {
- $returnValue[] = ' ' . $subscription . '';
- }
- $returnValue[] = ' ';
- }
- $returnValue[] = ' ' . $this->DataSources->WindowsEventLog->ScheduledTransferLogLevelFilter . '';
- $returnValue[] = ' ';
-
- $returnValue[] = ' ';
- $returnValue[] = ' ' . $this->DataSources->Directories->BufferQuotaInMB . '';
- $returnValue[] = ' ' . $this->DataSources->Directories->ScheduledTransferPeriodInMinutes . '';
- if (count($this->DataSources->Directories->Subscriptions) == 0) {
- $returnValue[] = ' ';
- } else {
- $returnValue[] = ' ';
- foreach ($this->DataSources->Directories->Subscriptions as $subscription) {
- $returnValue[] = ' ';
- $returnValue[] = ' ' . $subscription->Path . '';
- $returnValue[] = ' ' . $subscription->Container . '';
- $returnValue[] = ' ' . $subscription->DirectoryQuotaInMB . '';
- $returnValue[] = ' ';
- }
- $returnValue[] = ' ';
- }
- $returnValue[] = ' ';
-
- $returnValue[] = ' ';
- $returnValue[] = ' false';
- $returnValue[] = '';
-
- // Return
- return implode("\r\n", $returnValue);
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationLogs.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationLogs.php
deleted file mode 100644
index 8fa9e3a..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationLogs.php
+++ /dev/null
@@ -1,80 +0,0 @@
-_data = array(
- 'bufferquotainmb' => $bufferQuotaInMB,
- 'scheduledtransferperiodinminutes' => $scheduledTransferPeriodInMinutes,
- 'scheduledtransferloglevelfilter' => $scheduledTransferLogLevelFilter
- );
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationObjectBaseAbstract.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationObjectBaseAbstract.php
deleted file mode 100644
index 8f38210..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationObjectBaseAbstract.php
+++ /dev/null
@@ -1,84 +0,0 @@
-_data)) {
- $this->_data[strtolower($name)] = $value;
- return;
- }
-
- throw new Microsoft_WindowsAzure_Diagnostics_Exception("Unknown property: " . $name);
- }
-
- /**
- * Magic overload for getting properties
- *
- * @param string $name Name of the property
- */
- public function __get($name) {
- if (array_key_exists(strtolower($name), $this->_data)) {
- return $this->_data[strtolower($name)];
- }
-
- throw new Microsoft_WindowsAzure_Diagnostics_Exception("Unknown property: " . $name);
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationPerformanceCounters.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationPerformanceCounters.php
deleted file mode 100644
index 680198b..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationPerformanceCounters.php
+++ /dev/null
@@ -1,102 +0,0 @@
-_data = array(
- 'bufferquotainmb' => $bufferQuotaInMB,
- 'scheduledtransferperiodinminutes' => $scheduledTransferPeriodInMinutes,
- 'subscriptions' => array()
- );
- }
-
- /**
- * Add subscription
- *
- * @param string $counterSpecifier Counter specifier
- * @param int $sampleRateInSeconds Sample rate in seconds
- */
- public function addSubscription($counterSpecifier, $sampleRateInSeconds = 1)
- {
- $this->_data['subscriptions'][$counterSpecifier] = new Microsoft_WindowsAzure_Diagnostics_PerformanceCounterSubscription($counterSpecifier, $sampleRateInSeconds);
- }
-
- /**
- * Remove subscription
- *
- * @param string $counterSpecifier Counter specifier
- */
- public function removeSubscription($counterSpecifier)
- {
- if (isset($this->_data['subscriptions'][$counterSpecifier])) {
- unset($this->_data['subscriptions'][$counterSpecifier]);
- }
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationWindowsEventLog.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationWindowsEventLog.php
deleted file mode 100644
index 4259d07..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/ConfigurationWindowsEventLog.php
+++ /dev/null
@@ -1,104 +0,0 @@
-_data = array(
- 'bufferquotainmb' => $bufferQuotaInMB,
- 'scheduledtransferperiodinminutes' => $scheduledTransferPeriodInMinutes,
- 'scheduledtransferloglevelfilter' => $scheduledTransferLogLevelFilter,
- 'subscriptions' => array()
- );
- }
-
- /**
- * Add subscription
- *
- * @param string $filter Event log filter
- */
- public function addSubscription($filter)
- {
- $this->_data['subscriptions'][$filter] = $filter;
- }
-
- /**
- * Remove subscription
- *
- * @param string $filter Event log filter
- */
- public function removeSubscription($filter)
- {
- if (isset($this->_data['subscriptions'][$filter])) {
- unset($this->_data['subscriptions'][$filter]);
- }
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/DirectoryConfigurationSubscription.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/DirectoryConfigurationSubscription.php
deleted file mode 100644
index 5bb66f0..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/DirectoryConfigurationSubscription.php
+++ /dev/null
@@ -1,75 +0,0 @@
-_data = array(
- 'path' => $path,
- 'container' => $container,
- 'directoryquotainmb' => $directoryQuotaInMB
- );
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/Exception.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/Exception.php
deleted file mode 100644
index f825b24..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/Exception.php
+++ /dev/null
@@ -1,51 +0,0 @@
-_blobStorageClient = $blobStorageClient;
- $this->_controlContainer = $controlContainer;
-
- $this->_ensureStorageInitialized();
- }
-
- /**
- * Ensure storage has been initialized
- */
- protected function _ensureStorageInitialized()
- {
- if (!$this->_blobStorageClient->containerExists($this->_controlContainer)) {
- $this->_blobStorageClient->createContainer($this->_controlContainer);
- }
- }
-
- /**
- * Get default configuration values
- *
- * @return Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance
- */
- public function getDefaultConfiguration()
- {
- return new Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance();
- }
-
- /**
- * Checks if a configuration for a specific role instance exists.
- *
- * @param string $roleInstance Role instance name, can be found in $_SERVER['RdRoleId'] when hosted on Windows Azure.
- * @return boolean
- * @throws Microsoft_WindowsAzure_Diagnostics_Exception
- */
- public function configurationForRoleInstanceExists($roleInstance = null)
- {
- if (is_null($roleInstance)) {
- throw new Microsoft_WindowsAzure_Diagnostics_Exception('Role instance should be specified. Try reading $_SERVER[\'RdRoleId\'] for this information if the application is hosted on Windows Azure Fabric or Development Fabric.');
- }
-
- return $this->_blobStorageClient->blobExists($this->_controlContainer, $roleInstance);
- }
-
- /**
- * Checks if a configuration for current role instance exists. Only works on Development Fabric or Windows Azure Fabric.
- *
- * @return boolean
- * @throws Microsoft_WindowsAzure_Diagnostics_Exception
- */
- public function configurationForCurrentRoleInstanceExists()
- {
- if (!isset($_SERVER['RdRoleId'])) {
- throw new Microsoft_WindowsAzure_Diagnostics_Exception('Server variable \'RdRoleId\' is unknown. Please verify the application is running in Development Fabric or Windows Azure Fabric.');
- }
-
- return $this->_blobStorageClient->blobExists($this->_controlContainer, $this->_getCurrentRoleInstanceId());
- }
-
- /**
- * Get configuration for current role instance. Only works on Development Fabric or Windows Azure Fabric.
- *
- * @return Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance
- * @throws Microsoft_WindowsAzure_Diagnostics_Exception
- */
- public function getConfigurationForCurrentRoleInstance()
- {
- if (!isset($_SERVER['RdRoleId'])) {
- throw new Microsoft_WindowsAzure_Diagnostics_Exception('Server variable \'RdRoleId\' is unknown. Please verify the application is running in Development Fabric or Windows Azure Fabric.');
- }
- return $this->getConfigurationForRoleInstance($this->_getCurrentRoleInstanceId());
- }
-
- /**
- * Get the current role instance ID. Only works on Development Fabric or Windows Azure Fabric.
- *
- * @return string
- * @throws Microsoft_WindowsAzure_Diagnostics_Exception
- */
- protected function _getCurrentRoleInstanceId()
- {
- if (!isset($_SERVER['RdRoleId'])) {
- throw new Microsoft_WindowsAzure_Diagnostics_Exception('Server variable \'RdRoleId\' is unknown. Please verify the application is running in Development Fabric or Windows Azure Fabric.');
- }
-
- if (strpos($_SERVER['RdRoleId'], 'deployment(') === false) {
- return $_SERVER['RdRoleId'];
- } else {
- $roleIdParts = explode('.', $_SERVER['RdRoleId']);
- return $roleIdParts[0] . '/' . $roleIdParts[2] . '/' . $_SERVER['RdRoleId'];
- }
-
- if (!isset($_SERVER['RoleDeploymentID']) && !isset($_SERVER['RoleInstanceID']) && !isset($_SERVER['RoleName'])) {
- throw new Exception('Server variables \'RoleDeploymentID\', \'RoleInstanceID\' and \'RoleName\' are unknown. Please verify the application is running in Development Fabric or Windows Azure Fabric.');
- }
-
- if (strpos($_SERVER['RdRoleId'], 'deployment(') === false) {
- return $_SERVER['RdRoleId'];
- } else {
- return $_SERVER['RoleDeploymentID'] . '/' . $_SERVER['RoleInstanceID'] . '/' . $_SERVER['RoleName'];
- }
- }
-
- /**
- * Set configuration for current role instance. Only works on Development Fabric or Windows Azure Fabric.
- *
- * @param Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance $configuration Configuration to apply
- * @throws Microsoft_WindowsAzure_Diagnostics_Exception
- */
- public function setConfigurationForCurrentRoleInstance(Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance $configuration)
- {
- if (!isset($_SERVER['RdRoleId'])) {
- throw new Microsoft_WindowsAzure_Diagnostics_Exception('Server variable \'RdRoleId\' is unknown. Please verify the application is running in Development Fabric or Windows Azure Fabric.');
- }
-
- $this->setConfigurationForRoleInstance($this->_getCurrentRoleInstanceId(), $configuration);
- }
-
- /**
- * Get configuration for a specific role instance
- *
- * @param string $roleInstance Role instance name, can be found in $_SERVER['RdRoleId'] when hosted on Windows Azure.
- * @return Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance
- * @throws Microsoft_WindowsAzure_Diagnostics_Exception
- */
- public function getConfigurationForRoleInstance($roleInstance = null)
- {
- if (is_null($roleInstance)) {
- throw new Microsoft_WindowsAzure_Diagnostics_Exception('Role instance should be specified. Try reading $_SERVER[\'RdRoleId\'] for this information if the application is hosted on Windows Azure Fabric or Development Fabric.');
- }
-
- if ($this->_blobStorageClient->blobExists($this->_controlContainer, $roleInstance)) {
- $configurationInstance = new Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance();
- $configurationInstance->loadXml( $this->_blobStorageClient->getBlobData($this->_controlContainer, $roleInstance) );
- return $configurationInstance;
- }
-
- return new Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance();
- }
-
- /**
- * Set configuration for a specific role instance
- *
- * @param string $roleInstance Role instance name, can be found in $_SERVER['RdRoleId'] when hosted on Windows Azure.
- * @param Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance $configuration Configuration to apply
- * @throws Microsoft_WindowsAzure_Diagnostics_Exception
- */
- public function setConfigurationForRoleInstance($roleInstance = null, Microsoft_WindowsAzure_Diagnostics_ConfigurationInstance $configuration)
- {
- if (is_null($roleInstance)) {
- throw new Microsoft_WindowsAzure_Diagnostics_Exception('Role instance should be specified. Try reading $_SERVER[\'RdRoleId\'] for this information if the application is hosted on Windows Azure Fabric or Development Fabric.');
- }
-
- $this->_blobStorageClient->putBlobData($this->_controlContainer, $roleInstance, $configuration->toXml(), array(), null, array('Content-Type' => 'text/xml'));
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/PerformanceCounterSubscription.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/PerformanceCounterSubscription.php
deleted file mode 100644
index de4943f..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Diagnostics/PerformanceCounterSubscription.php
+++ /dev/null
@@ -1,72 +0,0 @@
-_data = array(
- 'counterspecifier' => $counterSpecifier,
- 'samplerateinseconds' => $sampleRateInSeconds
- );
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Exception.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Exception.php
deleted file mode 100644
index a0b3086..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Exception.php
+++ /dev/null
@@ -1,48 +0,0 @@
- $value) {
- if ((is_object($value) && !method_exists($value,'__toString'))
- || is_array($value)) {
-
- $value = gettype($value);
- }
-
- $logEntity->{$key} = $value;
- }
-
- return $logEntity;
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Log/Writer/WindowsAzure.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Log/Writer/WindowsAzure.php
deleted file mode 100644
index 5a6cbe9..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Log/Writer/WindowsAzure.php
+++ /dev/null
@@ -1,185 +0,0 @@
-_tableStorageConnection = $tableStorageConnection;
- $this->_tableName = $tableName;
-
- // create the logging table if it does not exist. It will add some overhead, so it's optional
- if ($createTable) {
- $this->_tableStorageConnection->createTableIfNotExists($this->_tableName);
- }
-
- // keep messages to be logged in an internal buffer and only send them over the wire when
- // the script execution ends
- if ($bufferMessages) {
- $this->_bufferMessages = $bufferMessages;
- }
-
- $this->_formatter = new Microsoft_WindowsAzure_Log_Formatter_WindowsAzure();
- }
-
- /**
- * If the log messages have been stored in the internal buffer, just send them
- * to table storage.
- */
- public function shutdown() {
- parent::shutdown();
- if ($this->_bufferMessages) {
- $this->_tableStorageConnection->startBatch();
- foreach ($this->_messageBuffer as $logEntity) {
- $this->_tableStorageConnection->insertEntity($this->_tableName, $logEntity);
- }
- $this->_tableStorageConnection->commit();
- }
- }
-
- /**
- * Create a new instance of Microsoft_Log_Writer_WindowsAzure
- *
- * @param array $config
- * @return Microsoft_Log_Writer_WindowsAzure
- * @throws Microsoft_Log_Exception
- */
- static public function factory($config)
- {
- $config = self::_parseConfig($config);
- $config = array_merge(array(
- 'connection' => null,
- 'tableName' => null,
- 'createTable' => true,
- ), $config);
-
- return new self(
- $config['connection'],
- $config['tableName'],
- $config['createTable']
- );
- }
-
- /**
- * The only formatter accepted is already loaded in the constructor
- *
- * @todo enable custom formatters using the WindowsAzure_Storage_DynamicTableEntity class
- */
- public function setFormatter(Microsoft_Log_Formatter_Interface $formatter)
- {
- require_once 'Microsoft/Log/Exception.php';
- throw new Microsoft_Log_Exception(get_class($this) . ' does not support formatting');
- }
-
- /**
- * Write a message to the table storage. If buffering is activated, then messages will just be
- * added to an internal buffer.
- *
- * @param array $event
- * @return void
- * @todo format the event using a formatted, not in this method
- */
- protected function _write($event)
- {
- $logEntity = $this->_formatter->format($event);
-
- if ($this->_bufferMessages) {
- $this->_messageBuffer[] = $logEntity;
- } else {
- $this->_tableStorageConnection->insertEntity($this->_tableName, $logEntity);
- }
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/AffinityGroupInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/AffinityGroupInstance.php
deleted file mode 100644
index a30c073..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/AffinityGroupInstance.php
+++ /dev/null
@@ -1,84 +0,0 @@
-_data = array(
- 'name' => $name,
- 'label' => base64_decode($label),
- 'description' => $description,
- 'location' => $location,
- 'hostedservices' => $hostedServices,
- 'storageservices' => $storageServices
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/CertificateInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/CertificateInstance.php
deleted file mode 100644
index 1e21c42..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/CertificateInstance.php
+++ /dev/null
@@ -1,78 +0,0 @@
-_data = array(
- 'certificateurl' => $certificateUrl,
- 'thumbprint' => $thumbprint,
- 'thumbprintalgorithm' => $thumbprintAlgorithm,
- 'data' => base64_decode($data)
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/Client.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/Client.php
deleted file mode 100644
index 5ff63c8..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/Client.php
+++ /dev/null
@@ -1,2203 +0,0 @@
-_subscriptionId = $subscriptionId;
- $this->_certificatePath = $certificatePath;
- $this->_certificatePassphrase = $certificatePassphrase;
-
- $this->_retryPolicy = $retryPolicy;
- if (is_null($this->_retryPolicy)) {
- $this->_retryPolicy = Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract::noRetry();
- }
-
- // Setup default Microsoft_Http_Client channel
- $options = array(
- 'adapter' => 'Microsoft_Http_Client_Adapter_Socket',
- 'ssltransport' => 'ssl',
- 'sslcert' => $this->_certificatePath,
- 'sslpassphrase' => $this->_certificatePassphrase,
- 'sslusecontext' => true,
- );
- if (function_exists('curl_init')) {
- // Set cURL options if cURL is used afterwards
- $options['curloptions'] = array(
- CURLOPT_FOLLOWLOCATION => true,
- CURLOPT_TIMEOUT => 120,
- );
- }
- $this->_httpClientChannel = new Microsoft_Http_Client(null, $options);
- }
-
- /**
- * Set the HTTP client channel to use
- *
- * @param Microsoft_Http_Client_Adapter_Interface|string $adapterInstance Adapter instance or adapter class name.
- */
- public function setHttpClientChannel($adapterInstance = 'Microsoft_Http_Client_Adapter_Socket')
- {
- $this->_httpClientChannel->setAdapter($adapterInstance);
- }
-
- /**
- * Retrieve HTTP client channel
- *
- * @return Microsoft_Http_Client_Adapter_Interface
- */
- public function getHttpClientChannel()
- {
- return $this->_httpClientChannel;
- }
-
- /**
- * Returns the Windows Azure subscription ID
- *
- * @return string
- */
- public function getSubscriptionId()
- {
- return $this->_subscriptionId;
- }
-
- /**
- * Returns the last request ID.
- *
- * @return string
- */
- public function getLastRequestId()
- {
- return $this->_lastRequestId;
- }
-
- /**
- * Get base URL for creating requests
- *
- * @return string
- */
- public function getBaseUrl()
- {
- return self::URL_MANAGEMENT . '/' . $this->_subscriptionId;
- }
-
- /**
- * Perform request using Microsoft_Http_Client channel
- *
- * @param string $path Path
- * @param string $queryString Query string
- * @param string $httpVerb HTTP verb the request will use
- * @param array $headers x-ms headers to add
- * @param mixed $rawData Optional RAW HTTP data to be sent over the wire
- * @return Microsoft_Http_Response
- */
- protected function _performRequest(
- $path = '/',
- $queryString = '',
- $httpVerb = Microsoft_Http_Client::GET,
- $headers = array(),
- $rawData = null
- ) {
- // Clean path
- if (strpos($path, '/') !== 0) {
- $path = '/' . $path;
- }
-
- // Clean headers
- if (is_null($headers)) {
- $headers = array();
- }
-
- // Ensure cUrl will also work correctly:
- // - disable Content-Type if required
- // - disable Expect: 100 Continue
- if (!isset($headers["Content-Type"])) {
- $headers["Content-Type"] = '';
- }
- //$headers["Expect"] = '';
-
- // Add version header
- $headers['x-ms-version'] = $this->_apiVersion;
-
- // URL encoding
- $path = self::urlencode($path);
- $queryString = self::urlencode($queryString);
-
- // Generate URL and sign request
- $requestUrl = $this->getBaseUrl() . $path . $queryString;
- $requestHeaders = $headers;
-
- // Prepare request
- $this->_httpClientChannel->resetParameters(true);
- $this->_httpClientChannel->setUri($requestUrl);
- $this->_httpClientChannel->setHeaders($requestHeaders);
- $this->_httpClientChannel->setRawData($rawData);
-
- // Execute request
- $response = $this->_retryPolicy->execute(
- array($this->_httpClientChannel, 'request'),
- array($httpVerb)
- );
-
- // Store request id
- $this->_lastRequestId = $response->getHeader('x-ms-request-id');
-
- return $response;
- }
-
- /**
- * Parse result from Microsoft_Http_Response
- *
- * @param Microsoft_Http_Response $response Response from HTTP call
- * @return object
- * @throws Microsoft_WindowsAzure_Exception
- */
- protected function _parseResponse(Microsoft_Http_Response $response = null)
- {
- if (is_null($response)) {
- throw new Microsoft_WindowsAzure_Exception('Response should not be null.');
- }
-
- $xml = @simplexml_load_string($response->getBody());
-
- if ($xml !== false) {
- // Fetch all namespaces
- $namespaces = array_merge($xml->getNamespaces(true), $xml->getDocNamespaces(true));
-
- // Register all namespace prefixes
- foreach ($namespaces as $prefix => $ns) {
- if ($prefix != '') {
- $xml->registerXPathNamespace($prefix, $ns);
- }
- }
- }
-
- return $xml;
- }
-
- /**
- * URL encode function
- *
- * @param string $value Value to encode
- * @return string Encoded value
- */
- public static function urlencode($value)
- {
- return str_replace(' ', '%20', $value);
- }
-
- /**
- * Builds a query string from an array of elements
- *
- * @param array Array of elements
- * @return string Assembled query string
- */
- public static function createQueryStringFromArray($queryString)
- {
- return count($queryString) > 0 ? '?' . implode('&', $queryString) : '';
- }
-
- /**
- * Get error message from Microsoft_Http_Response
- *
- * @param Microsoft_Http_Response $response Repsonse
- * @param string $alternativeError Alternative error message
- * @return string
- */
- protected function _getErrorMessage(Microsoft_Http_Response $response, $alternativeError = 'Unknown error.')
- {
- $response = $this->_parseResponse($response);
- if ($response && $response->Message) {
- return (string)$response->Message;
- } else {
- return $alternativeError;
- }
- }
-
- /**
- * The Get Operation Status operation returns the status of the specified operation.
- * After calling an asynchronous operation, you can call Get Operation Status to
- * determine whether the operation has succeed, failed, or is still in progress.
- *
- * @param string $requestId The request ID. If omitted, the last request ID will be used.
- * @return Microsoft_WindowsAzure_Management_OperationStatusInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function getOperationStatus($requestId = '')
- {
- if ($requestId == '') {
- $requestId = $this->getLastRequestId();
- }
-
- $response = $this->_performRequest(self::OP_OPERATIONS . '/' . $requestId);
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
-
- if (!is_null($result)) {
- return new Microsoft_WindowsAzure_Management_OperationStatusInstance(
- (string)$result->ID,
- (string)$result->Status,
- ($result->Error ? (string)$result->Error->Code : ''),
- ($result->Error ? (string)$result->Error->Message : '')
- );
- }
- return null;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
-
-
- /**
- * The List Subscription Operations operation returns a list of create, update,
- * and delete operations that were performed on a subscription during the specified timeframe.
- * Documentation on the parameters can be found at http://msdn.microsoft.com/en-us/library/gg715318.aspx.
- *
- * @param string $startTime The start of the timeframe to begin listing subscription operations in UTC format. This parameter and the $endTime parameter indicate the timeframe to retrieve subscription operations. This parameter cannot indicate a start date of more than 90 days in the past.
- * @param string $endTime The end of the timeframe to begin listing subscription operations in UTC format. This parameter and the $startTime parameter indicate the timeframe to retrieve subscription operations.
- * @param string $objectIdFilter Returns subscription operations only for the specified object type and object ID.
- * @param string $operationResultFilter Returns subscription operations only for the specified result status, either Succeeded, Failed, or InProgress.
- * @param string $continuationToken Internal usage.
- * @return array Array of Microsoft_WindowsAzure_Management_SubscriptionOperationInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function listSubscriptionOperations($startTime, $endTime, $objectIdFilter = null, $operationResultFilter = null, $continuationToken = null)
- {
- if ($startTime == '' || is_null($startTime)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Start time should be specified.');
- }
- if ($endTime == '' || is_null($endTime)) {
- throw new Microsoft_WindowsAzure_Management_Exception('End time should be specified.');
- }
- if ($operationResultFilter != '' && !is_null($operationResultFilter)) {
- $operationResultFilter = strtolower($operationResultFilter);
- if ($operationResultFilter != 'succeeded' && $operationResultFilter != 'failed' && $operationResultFilter != 'inprogress') {
- throw new Microsoft_WindowsAzure_Management_Exception('OperationResultFilter should be succeeded|failed|inprogress.');
- }
- }
-
- $parameters = array();
- $parameters[] = 'StartTime=' . $startTime;
- $parameters[] = 'EndTime=' . $endTime;
- if ($objectIdFilter != '' && !is_null($objectIdFilter)) {
- $parameters[] = 'ObjectIdFilter=' . $objectIdFilter;
- }
- if ($operationResultFilter != '' && !is_null($operationResultFilter)) {
- $parameters[] = 'OperationResultFilter=' . ucfirst($operationResultFilter);
- }
- if ($continuationToken != '' && !is_null($continuationToken)) {
- $parameters[] = 'ContinuationToken=' . $continuationToken;
- }
-
- $response = $this->_performRequest(self::OP_OPERATIONS, '?' . implode('&', $parameters));
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
- $namespaces = $result->getDocNamespaces();
- $result->registerXPathNamespace('__empty_ns', $namespaces['']);
-
- $xmlOperations = $result->xpath('//__empty_ns:SubscriptionOperation');
-
- // Create return value
- $returnValue = array();
- foreach ($xmlOperations as $xmlOperation) {
- // Create operation instance
- $operation = new Microsoft_WindowsAzure_Management_SubscriptionOperationInstance(
- $xmlOperation->OperationId,
- $xmlOperation->OperationObjectId,
- $xmlOperation->OperationName,
- array(),
- (array)$xmlOperation->OperationCaller,
- (array)$xmlOperation->OperationStatus
- );
-
- // Parse parameters
- $xmlOperation->registerXPathNamespace('__empty_ns', $namespaces['']);
- $xmlParameters = $xmlOperation->xpath('.//__empty_ns:OperationParameter');
- foreach ($xmlParameters as $xmlParameter) {
- $xmlParameterDetails = $xmlParameter->children('http://schemas.datacontract.org/2004/07/Microsoft.Samples.WindowsAzure.ServiceManagement');
- $operation->addOperationParameter((string)$xmlParameterDetails->Name, (string)$xmlParameterDetails->Value);
- }
-
- // Add to result
- $returnValue[] = $operation;
- }
-
- // More data?
- if (!is_null($result->ContinuationToken) && $result->ContinuationToken != '') {
- $returnValue = array_merge($returnValue, $this->listSubscriptionOperations($startTime, $endTime, $objectIdFilter, $operationResultFilter, (string)$result->ContinuationToken));
- }
-
- // Return
- return $returnValue;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Wait for an operation to complete
- *
- * @param string $requestId The request ID. If omitted, the last request ID will be used.
- * @param int $sleepInterval Sleep interval in milliseconds.
- * @return Microsoft_WindowsAzure_Management_OperationStatusInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function waitForOperation($requestId = '', $sleepInterval = 250)
- {
- if ($requestId == '') {
- $requestId = $this->getLastRequestId();
- }
- if ($requestId == '' || is_null($requestId)) {
- return null;
- }
-
- $status = $this->getOperationStatus($requestId);
- while ($status->Status == 'InProgress') {
- $status = $this->getOperationStatus($requestId);
- usleep($sleepInterval);
- }
-
- return $status;
- }
-
- /**
- * Creates a new Microsoft_WindowsAzure_Storage_Blob instance for the current account
- *
- * @param string $serviceName the service name to create a storage client for.
- * @param Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
- * @return Microsoft_WindowsAzure_Storage_Blob
- */
- public function createBlobClientForService($serviceName, Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy = null)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
-
- $storageKeys = $this->getStorageAccountKeys($serviceName);
-
- return new Microsoft_WindowsAzure_Storage_Blob(
- Microsoft_WindowsAzure_Storage::URL_CLOUD_BLOB,
- $serviceName,
- $storageKeys[0],
- false,
- $retryPolicy
- );
- }
-
- /**
- * Creates a new Microsoft_WindowsAzure_Storage_Table instance for the current account
- *
- * @param string $serviceName the service name to create a storage client for.
- * @param Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
- * @return Microsoft_WindowsAzure_Storage_Table
- */
- public function createTableClientForService($serviceName, Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy = null)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
-
- $storageKeys = $this->getStorageAccountKeys($serviceName);
-
- return new Microsoft_WindowsAzure_Storage_Table(
- Microsoft_WindowsAzure_Storage::URL_CLOUD_TABLE,
- $serviceName,
- $storageKeys[0],
- false,
- $retryPolicy
- );
- }
-
- /**
- * Creates a new Microsoft_WindowsAzure_Storage_Queue instance for the current account
- *
- * @param string $serviceName the service name to create a storage client for.
- * @param Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
- * @return Microsoft_WindowsAzure_Storage_Queue
- */
- public function createQueueClientForService($serviceName, Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy = null)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
-
- $storageKeys = $this->getStorageAccountKeys($serviceName);
-
- return new Microsoft_WindowsAzure_Storage_Queue(
- Microsoft_WindowsAzure_Storage::URL_CLOUD_QUEUE,
- $serviceName,
- $storageKeys[0],
- false,
- $retryPolicy
- );
- }
-
- /**
- * The List Storage Accounts operation lists the storage accounts available under
- * the current subscription.
- *
- * @return array An array of Microsoft_WindowsAzure_Management_StorageServiceInstance
- */
- public function listStorageAccounts()
- {
- $response = $this->_performRequest(self::OP_STORAGE_ACCOUNTS);
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
- if (count($result->StorageService) > 1) {
- $xmlServices = $result->StorageService;
- } else {
- $xmlServices = array($result->StorageService);
- }
-
- $services = array();
- if (!is_null($xmlServices)) {
- for ($i = 0; $i < count($xmlServices); $i++) {
- $services[] = new Microsoft_WindowsAzure_Management_StorageServiceInstance(
- (string)$xmlServices[$i]->Url,
- (string)$xmlServices[$i]->ServiceName
- );
- }
- }
- return $services;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Get Storage Account Properties operation returns the system properties for the
- * specified storage account. These properties include: the address, description, and
- * label of the storage account; and the name of the affinity group to which the service
- * belongs, or its geo-location if it is not part of an affinity group.
- *
- * @param string $serviceName The name of your service.
- * @return Microsoft_WindowsAzure_Management_StorageServiceInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function getStorageAccountProperties($serviceName)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
-
- $response = $this->_performRequest(self::OP_STORAGE_ACCOUNTS . '/' . $serviceName);
-
- if ($response->isSuccessful()) {
- $xmlService = $this->_parseResponse($response);
-
- if (!is_null($xmlService)) {
- return new Microsoft_WindowsAzure_Management_StorageServiceInstance(
- (string)$xmlService->Url,
- (string)$xmlService->ServiceName,
- (string)$xmlService->StorageServiceProperties->Description,
- (string)$xmlService->StorageServiceProperties->AffinityGroup,
- (string)$xmlService->StorageServiceProperties->Location,
- (string)$xmlService->StorageServiceProperties->Label
- );
- }
- return null;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Get Storage Keys operation returns the primary
- * and secondary access keys for the specified storage account.
- *
- * @param string $serviceName The name of your service.
- * @return array An array of strings
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function getStorageAccountKeys($serviceName)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
-
- $response = $this->_performRequest(self::OP_STORAGE_ACCOUNTS . '/' . $serviceName . '/keys');
-
- if ($response->isSuccessful()) {
- $xmlService = $this->_parseResponse($response);
-
- if (!is_null($xmlService)) {
- return array(
- (string)$xmlService->StorageServiceKeys->Primary,
- (string)$xmlService->StorageServiceKeys->Secondary
- );
- }
- return array();
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Regenerate Keys operation regenerates the primary
- * or secondary access key for the specified storage account.
- *
- * @param string $serviceName The name of your service.
- * @param string $key The key to regenerate (primary or secondary)
- * @return array An array of strings
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function regenerateStorageAccountKey($serviceName, $key = 'primary')
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $key = strtolower($key);
- if ($key != 'primary' && $key != 'secondary') {
- throw new Microsoft_WindowsAzure_Management_Exception('Key identifier should be primary|secondary.');
- }
-
- $response = $this->_performRequest(
- self::OP_STORAGE_ACCOUNTS . '/' . $serviceName . '/keys', '?action=regenerate',
- Microsoft_Http_Client::POST,
- array('Content-Type' => 'application/xml'),
- '
-
- ' . ucfirst($key) . '
- ');
-
- if ($response->isSuccessful()) {
- $xmlService = $this->_parseResponse($response);
-
- if (!is_null($xmlService)) {
- return array(
- (string)$xmlService->StorageServiceKeys->Primary,
- (string)$xmlService->StorageServiceKeys->Secondary
- );
- }
- return array();
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The List Hosted Services operation lists the hosted services available
- * under the current subscription.
- *
- * @return array An array of Microsoft_WindowsAzure_Management_HostedServiceInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function listHostedServices()
- {
- $response = $this->_performRequest(self::OP_HOSTED_SERVICES);
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
- if (count($result->HostedService) > 1) {
- $xmlServices = $result->HostedService;
- } else {
- $xmlServices = array($result->HostedService);
- }
-
- $services = array();
- if (!is_null($xmlServices)) {
- for ($i = 0; $i < count($xmlServices); $i++) {
- $services[] = new Microsoft_WindowsAzure_Management_HostedServiceInstance(
- (string)$xmlServices[$i]->Url,
- (string)$xmlServices[$i]->ServiceName
- );
- }
- }
- return $services;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Create Hosted Service operation creates a new hosted service in Windows Azure.
- *
- * @param string $serviceName A name for the hosted service that is unique to the subscription.
- * @param string $label A label for the hosted service. The label may be up to 100 characters in length.
- * @param string $description A description for the hosted service. The description may be up to 1024 characters in length.
- * @param string $location Required if AffinityGroup is not specified. The location where the hosted service will be created.
- * @param string $affinityGroup Required if Location is not specified. The name of an existing affinity group associated with this subscription.
- */
- public function createHostedService($serviceName, $label, $description = '', $location = null, $affinityGroup = null)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($label == '' || is_null($label)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label should be specified.');
- }
- if (strlen($label) > 100) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label is too long. The maximum length is 100 characters.');
- }
- if (strlen($description) > 1024) {
- throw new Microsoft_WindowsAzure_Management_Exception('Description is too long. The maximum length is 1024 characters.');
- }
- if ( (is_null($location) && is_null($affinityGroup)) || (!is_null($location) && !is_null($affinityGroup)) ) {
- throw new Microsoft_WindowsAzure_Management_Exception('Please specify a location -or- an affinity group for the service.');
- }
-
- $locationOrAffinityGroup = is_null($location)
- ? '' . $affinityGroup . ''
- : '' . $location . '';
-
- $response = $this->_performRequest(self::OP_HOSTED_SERVICES, '',
- Microsoft_Http_Client::POST,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . $serviceName . '' . $description . '' . $locationOrAffinityGroup . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Update Hosted Service operation updates the label and/or the description for a hosted service in Windows Azure.
- *
- * @param string $serviceName A name for the hosted service that is unique to the subscription.
- * @param string $label A label for the hosted service. The label may be up to 100 characters in length.
- * @param string $description A description for the hosted service. The description may be up to 1024 characters in length.
- */
- public function updateHostedService($serviceName, $label, $description = '')
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($label == '' || is_null($label)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label should be specified.');
- }
- if (strlen($label) > 100) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label is too long. The maximum length is 100 characters.');
- }
-
- $response = $this->_performRequest(self::OP_HOSTED_SERVICES . '/' . $serviceName, '',
- Microsoft_Http_Client::PUT,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . $description . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Delete Hosted Service operation deletes the specified hosted service in Windows Azure.
- *
- * @param string $serviceName A name for the hosted service that is unique to the subscription.
- */
- public function deleteHostedService($serviceName)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
-
- $response = $this->_performRequest(self::OP_HOSTED_SERVICES . '/' . $serviceName, '', Microsoft_Http_Client::DELETE);
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Get Hosted Service Properties operation retrieves system properties
- * for the specified hosted service. These properties include the service
- * name and service type; the name of the affinity group to which the service
- * belongs, or its location if it is not part of an affinity group; and
- * optionally, information on the service's deployments.
- *
- * @param string $serviceName The name of your service.
- * @return Microsoft_WindowsAzure_Management_HostedServiceInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function getHostedServiceProperties($serviceName)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
-
- $response = $this->_performRequest(self::OP_HOSTED_SERVICES . '/' . $serviceName, '?embed-detail=true');
-
- if ($response->isSuccessful()) {
- $xmlService = $this->_parseResponse($response);
-
- if (!is_null($xmlService)) {
- $returnValue = new Microsoft_WindowsAzure_Management_HostedServiceInstance(
- (string)$xmlService->Url,
- (string)$xmlService->ServiceName,
- (string)$xmlService->HostedServiceProperties->Description,
- (string)$xmlService->HostedServiceProperties->AffinityGroup,
- (string)$xmlService->HostedServiceProperties->Location,
- (string)$xmlService->HostedServiceProperties->Label
- );
-
- // Deployments
- if (count($xmlService->Deployments->Deployment) > 1) {
- $xmlServices = $xmlService->Deployments->Deployment;
- } else {
- $xmlServices = array($xmlService->Deployments->Deployment);
- }
-
- $deployments = array();
- foreach ($xmlServices as $xmlDeployment) {
- $deployments[] = $this->_convertXmlElementToDeploymentInstance($xmlDeployment);
- }
- $returnValue->Deployments = $deployments;
-
- return $returnValue;
- }
- return null;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Create Deployment operation uploads a new service package
- * and creates a new deployment on staging or production.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @param string $name The name for the deployment. The deployment ID as listed on the Windows Azure management portal must be unique among other deployments for the hosted service.
- * @param string $label A URL that refers to the location of the service package in the Blob service. The service package must be located in a storage account beneath the same subscription.
- * @param string $packageUrl The service configuration file for the deployment.
- * @param string $configuration A label for this deployment, up to 100 characters in length.
- * @param boolean $startDeployment Indicates whether to start the deployment immediately after it is created.
- * @param boolean $treatWarningsAsErrors Indicates whether to treat package validation warnings as errors.
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function createDeployment($serviceName, $deploymentSlot, $name, $label, $packageUrl, $configuration, $startDeployment = false, $treatWarningsAsErrors = false)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $deploymentSlot = strtolower($deploymentSlot);
- if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment slot should be production|staging.');
- }
- if ($name == '' || is_null($name)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Name should be specified.');
- }
- if ($label == '' || is_null($label)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label should be specified.');
- }
- if (strlen($label) > 100) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label is too long. The maximum length is 100 characters.');
- }
- if ($packageUrl == '' || is_null($packageUrl)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Package URL should be specified.');
- }
- if ($configuration == '' || is_null($configuration)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Configuration should be specified.');
- }
-
- if (@file_exists($configuration)) {
- $configuration = utf8_decode(file_get_contents($configuration));
- }
-
- // Clean up the configuration
- $conformingConfiguration = $this->_cleanConfiguration($configuration);
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
- $response = $this->_performRequest($operationUrl, '',
- Microsoft_Http_Client::POST,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . $name . '' . $packageUrl . '' . base64_encode($conformingConfiguration) . '' . ($startDeployment ? 'true' : 'false') . '' . ($treatWarningsAsErrors ? 'true' : 'false') . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Get Deployment operation returns configuration information, status,
- * and system properties for the specified deployment.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @return Microsoft_WindowsAzure_Management_DeploymentInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function getDeploymentBySlot($serviceName, $deploymentSlot)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $deploymentSlot = strtolower($deploymentSlot);
- if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment slot should be production|staging.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
- return $this->_getDeployment($operationUrl);
- }
-
- /**
- * The Get Deployment operation returns configuration information, status,
- * and system properties for the specified deployment.
- *
- * @param string $serviceName The service name
- * @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
- * @return Microsoft_WindowsAzure_Management_DeploymentInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function getDeploymentByDeploymentId($serviceName, $deploymentId)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($deploymentId == '' || is_null($deploymentId)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment ID should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
- return $this->_getDeployment($operationUrl);
- }
-
- /**
- * The Get Deployment operation returns configuration information, status,
- * and system properties for the specified deployment.
- *
- * @param string $operationUrl The operation url
- * @return Microsoft_WindowsAzure_Management_DeploymentInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- protected function _getDeployment($operationUrl)
- {
- $response = $this->_performRequest($operationUrl);
-
- if ($response->isSuccessful()) {
- $xmlService = $this->_parseResponse($response);
-
- return $this->_convertXmlElementToDeploymentInstance($xmlService);
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Swap Deployment operation initiates a virtual IP swap between
- * the staging and production deployment environments for a service.
- * If the service is currently running in the staging environment,
- * it will be swapped to the production environment. If it is running
- * in the production environment, it will be swapped to staging.
- *
- * @param string $serviceName The service name.
- * @param string $productionDeploymentName The name of the production deployment.
- * @param string $sourceDeploymentName The name of the source deployment.
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function swapDeployment($serviceName, $productionDeploymentName, $sourceDeploymentName)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($productionDeploymentName == '' || is_null($productionDeploymentName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Production Deployment ID should be specified.');
- }
- if ($sourceDeploymentName == '' || is_null($sourceDeploymentName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Source Deployment ID should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName;
- $response = $this->_performRequest($operationUrl, '',
- Microsoft_Http_Client::POST,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . $productionDeploymentName . '' . $sourceDeploymentName . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Delete Deployment operation deletes the specified deployment.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function deleteDeploymentBySlot($serviceName, $deploymentSlot)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $deploymentSlot = strtolower($deploymentSlot);
- if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment slot should be production|staging.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
- return $this->_deleteDeployment($operationUrl);
- }
-
- /**
- * The Delete Deployment operation deletes the specified deployment.
- *
- * @param string $serviceName The service name
- * @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function deleteDeploymentByDeploymentId($serviceName, $deploymentId)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($deploymentId == '' || is_null($deploymentId)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment ID should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
- return $this->_deleteDeployment($operationUrl);
- }
-
- /**
- * The Delete Deployment operation deletes the specified deployment.
- *
- * @param string $operationUrl The operation url
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- protected function _deleteDeployment($operationUrl)
- {
- $response = $this->_performRequest($operationUrl, '', Microsoft_Http_Client::DELETE);
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Update Deployment Status operation initiates a change in deployment status.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @param string $status The deployment status (running|suspended)
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function updateDeploymentStatusBySlot($serviceName, $deploymentSlot, $status = 'running')
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $deploymentSlot = strtolower($deploymentSlot);
- if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment slot should be production|staging.');
- }
- $status = strtolower($status);
- if ($status != 'running' && $status != 'suspended') {
- throw new Microsoft_WindowsAzure_Management_Exception('Status should be running|suspended.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
- return $this->_updateDeploymentStatus($operationUrl, $status);
- }
-
- /**
- * The Update Deployment Status operation initiates a change in deployment status.
- *
- * @param string $serviceName The service name
- * @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
- * @param string $status The deployment status (running|suspended)
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function updateDeploymentStatusByDeploymentId($serviceName, $deploymentId, $status = 'running')
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($deploymentId == '' || is_null($deploymentId)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment ID should be specified.');
- }
- $status = strtolower($status);
- if ($status != 'running' && $status != 'suspended') {
- throw new Microsoft_WindowsAzure_Management_Exception('Status should be running|suspended.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
- return $this->_updateDeploymentStatus($operationUrl, $status);
- }
-
- /**
- * The Update Deployment Status operation initiates a change in deployment status.
- *
- * @param string $operationUrl The operation url
- * @param string $status The deployment status (running|suspended)
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- protected function _updateDeploymentStatus($operationUrl, $status = 'running')
- {
- $response = $this->_performRequest($operationUrl . '/', '?comp=status',
- Microsoft_Http_Client::POST,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . ucfirst($status) . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Converts an XmlElement into a Microsoft_WindowsAzure_Management_DeploymentInstance
- *
- * @param object $xmlService The XML Element
- * @return Microsoft_WindowsAzure_Management_DeploymentInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- protected function _convertXmlElementToDeploymentInstance($xmlService)
- {
- if (!is_null($xmlService)) {
- $returnValue = new Microsoft_WindowsAzure_Management_DeploymentInstance(
- (string)$xmlService->Name,
- (string)$xmlService->DeploymentSlot,
- (string)$xmlService->PrivateID,
- (string)$xmlService->Label,
- (string)$xmlService->Url,
- (string)$xmlService->Configuration,
- (string)$xmlService->Status,
- (string)$xmlService->UpgradeStatus,
- (string)$xmlService->UpgradeType,
- (string)$xmlService->CurrentUpgradeDomainState,
- (string)$xmlService->CurrentUpgradeDomain,
- (string)$xmlService->UpgradeDomainCount
- );
-
- // Append role instances
- $xmlRoleInstances = $xmlService->RoleInstanceList->RoleInstance;
- if (count($xmlService->RoleInstanceList->RoleInstance) == 1) {
- $xmlRoleInstances = array($xmlService->RoleInstanceList->RoleInstance);
- }
-
- $roleInstances = array();
- if (!is_null($xmlRoleInstances)) {
- for ($i = 0; $i < count($xmlRoleInstances); $i++) {
- $roleInstances[] = array(
- 'rolename' => (string)$xmlRoleInstances[$i]->RoleName,
- 'instancename' => (string)$xmlRoleInstances[$i]->InstanceName,
- 'instancestatus' => (string)$xmlRoleInstances[$i]->InstanceStatus
- );
- }
- }
-
- $returnValue->RoleInstanceList = $roleInstances;
-
- // Append roles
- $xmlRoles = $xmlService->RoleList->Role;
- if (count($xmlService->RoleList->Role) == 1) {
- $xmlRoles = array($xmlService->RoleList->Role);
- }
-
- $roles = array();
- if (!is_null($xmlRoles)) {
- for ($i = 0; $i < count($xmlRoles); $i++) {
- $roles[] = array(
- 'rolename' => (string)$xmlRoles[$i]->RoleName,
- 'osversion' => (!is_null($xmlRoles[$i]->OsVersion) ? (string)$xmlRoles[$i]->OsVersion : (string)$xmlRoles[$i]->OperatingSystemVersion)
- );
- }
- }
- $returnValue->RoleList = $roles;
-
- return $returnValue;
- }
- return null;
- }
-
- /**
- * Updates a deployment's role instance count.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @param string|array $roleName The role name
- * @param string|array $instanceCount The instance count
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function setInstanceCountBySlot($serviceName, $deploymentSlot, $roleName, $instanceCount) {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $deploymentSlot = strtolower($deploymentSlot);
- if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment slot should be production|staging.');
- }
- if ($roleName == '' || is_null($roleName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Role name name should be specified.');
- }
-
- // Get configuration
- $deployment = $this->getDeploymentBySlot($serviceName, $deploymentSlot);
- $configuration = $deployment->Configuration;
- $configuration = $this->_updateInstanceCountInConfiguration($roleName, $instanceCount, $configuration);
-
- // Update configuration
- $this->configureDeploymentBySlot($serviceName, $deploymentSlot, $configuration);
- }
-
- /**
- * Updates a deployment's role instance count.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @param string|array $roleName The role name
- * @param string|array $instanceCount The instance count
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function setInstanceCountByDeploymentId($serviceName, $deploymentId, $roleName, $instanceCount)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($deploymentId == '' || is_null($deploymentId)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment ID should be specified.');
- }
- if ($roleName == '' || is_null($roleName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Role name name should be specified.');
- }
-
- // Get configuration
- $deployment = $this->getDeploymentByDeploymentId($serviceName, $deploymentId);
- $configuration = $deployment->Configuration;
- $configuration = $this->_updateInstanceCountInConfiguration($roleName, $instanceCount, $configuration);
-
- // Update configuration
- $this->configureDeploymentByDeploymentId($serviceName, $deploymentId, $configuration);
- }
-
- /**
- * Updates instance count in configuration XML.
- *
- * @param string|array $roleName The role name
- * @param string|array $instanceCount The instance count
- * @param string $configuration XML configuration represented as a string
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- protected function _updateInstanceCountInConfiguration($roleName, $instanceCount, $configuration) {
- // Change variables
- if (!is_array($roleName)) {
- $roleName = array($roleName);
- }
- if (!is_array($instanceCount)) {
- $instanceCount = array($instanceCount);
- }
-
- $configuration = preg_replace('/(<\?xml[^?]+?)utf-16/i', '$1utf-8', $configuration);
- //$configuration = '' . substr($configuration, strpos($configuration, '>') + 2);
-
- $xml = simplexml_load_string($configuration);
-
- // http://www.php.net/manual/en/simplexmlelement.xpath.php#97818
- $namespaces = $xml->getDocNamespaces();
- $xml->registerXPathNamespace('__empty_ns', $namespaces['']);
-
- for ($i = 0; $i < count($roleName); $i++) {
- $elements = $xml->xpath('//__empty_ns:Role[@name="' . $roleName[$i] . '"]/__empty_ns:Instances');
-
- if (count($elements) == 1) {
- $element = $elements[0];
- $element['count'] = $instanceCount[$i];
- }
- }
-
- $configuration = $xml->asXML();
- //$configuration = preg_replace('/(<\?xml[^?]+?)utf-8/i', '$1utf-16', $configuration);
-
- return $configuration;
- }
-
- /**
- * The Change Deployment Configuration request may be specified as follows.
- * Note that you can change a deployment's configuration either by specifying the deployment
- * environment (staging or production), or by specifying the deployment's unique name.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @param string $configuration XML configuration represented as a string
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function configureDeploymentBySlot($serviceName, $deploymentSlot, $configuration)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $deploymentSlot = strtolower($deploymentSlot);
- if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment slot should be production|staging.');
- }
- if ($configuration == '' || is_null($configuration)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Configuration name should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
- return $this->_configureDeployment($operationUrl, $configuration);
- }
-
- /**
- * The Change Deployment Configuration request may be specified as follows.
- * Note that you can change a deployment's configuration either by specifying the deployment
- * environment (staging or production), or by specifying the deployment's unique name.
- *
- * @param string $serviceName The service name
- * @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
- * @param string $configuration XML configuration represented as a string
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function configureDeploymentByDeploymentId($serviceName, $deploymentId, $configuration)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($deploymentId == '' || is_null($deploymentId)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment ID should be specified.');
- }
- if ($configuration == '' || is_null($configuration)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Configuration name should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
- return $this->_configureDeployment($operationUrl, $configuration);
- }
-
- /**
- * The Change Deployment Configuration request may be specified as follows.
- * Note that you can change a deployment's configuration either by specifying the deployment
- * environment (staging or production), or by specifying the deployment's unique name.
- *
- * @param string $operationUrl The operation url
- * @param string $configuration XML configuration represented as a string
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- protected function _configureDeployment($operationUrl, $configuration)
- {
- // Clean up the configuration
- $conformingConfiguration = $this->_cleanConfiguration($configuration);
-
- $response = $this->_performRequest($operationUrl . '/', '?comp=config',
- Microsoft_Http_Client::POST,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . base64_encode($conformingConfiguration) . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Upgrade Deployment operation initiates an upgrade.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @param string $label A URL that refers to the location of the service package in the Blob service. The service package must be located in a storage account beneath the same subscription.
- * @param string $packageUrl The service configuration file for the deployment.
- * @param string $configuration A label for this deployment, up to 100 characters in length.
- * @param string $mode The type of upgrade to initiate. Possible values are Auto or Manual.
- * @param string $roleToUpgrade The name of the specific role to upgrade.
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function upgradeDeploymentBySlot($serviceName, $deploymentSlot, $label, $packageUrl, $configuration, $mode = 'auto', $roleToUpgrade = null)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $deploymentSlot = strtolower($deploymentSlot);
- if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment slot should be production|staging.');
- }
- if ($label == '' || is_null($label)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label should be specified.');
- }
- if (strlen($label) > 100) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label is too long. The maximum length is 100 characters.');
- }
- if ($packageUrl == '' || is_null($packageUrl)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Package URL should be specified.');
- }
- if ($configuration == '' || is_null($configuration)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Configuration should be specified.');
- }
- $mode = strtolower($mode);
- if ($mode != 'auto' && $mode != 'manual') {
- throw new Microsoft_WindowsAzure_Management_Exception('Mode should be auto|manual.');
- }
-
- if (@file_exists($configuration)) {
- $configuration = utf8_decode(file_get_contents($configuration));
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
- return $this->_upgradeDeployment($operationUrl, $label, $packageUrl, $configuration, $mode, $roleToUpgrade);
- }
-
- /**
- * The Upgrade Deployment operation initiates an upgrade.
- *
- * @param string $serviceName The service name
- * @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
- * @param string $label A URL that refers to the location of the service package in the Blob service. The service package must be located in a storage account beneath the same subscription.
- * @param string $packageUrl The service configuration file for the deployment.
- * @param string $configuration A label for this deployment, up to 100 characters in length.
- * @param string $mode The type of upgrade to initiate. Possible values are Auto or Manual.
- * @param string $roleToUpgrade The name of the specific role to upgrade.
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function upgradeDeploymentByDeploymentId($serviceName, $deploymentId, $label, $packageUrl, $configuration, $mode = 'auto', $roleToUpgrade = null)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($deploymentId == '' || is_null($deploymentId)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment ID should be specified.');
- }
- if ($label == '' || is_null($label)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label should be specified.');
- }
- if (strlen($label) > 100) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label is too long. The maximum length is 100 characters.');
- }
- if ($packageUrl == '' || is_null($packageUrl)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Package URL should be specified.');
- }
- if ($configuration == '' || is_null($configuration)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Configuration should be specified.');
- }
- $mode = strtolower($mode);
- if ($mode != 'auto' && $mode != 'manual') {
- throw new Microsoft_WindowsAzure_Management_Exception('Mode should be auto|manual.');
- }
-
- if (@file_exists($configuration)) {
- $configuration = utf8_decode(file_get_contents($configuration));
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
- return $this->_upgradeDeployment($operationUrl, $label, $packageUrl, $configuration, $mode, $roleToUpgrade);
- }
-
-
- /**
- * The Upgrade Deployment operation initiates an upgrade.
- *
- * @param string $operationUrl The operation url
- * @param string $label A URL that refers to the location of the service package in the Blob service. The service package must be located in a storage account beneath the same subscription.
- * @param string $packageUrl The service configuration file for the deployment.
- * @param string $configuration A label for this deployment, up to 100 characters in length.
- * @param string $mode The type of upgrade to initiate. Possible values are Auto or Manual.
- * @param string $roleToUpgrade The name of the specific role to upgrade.
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- protected function _upgradeDeployment($operationUrl, $label, $packageUrl, $configuration, $mode, $roleToUpgrade)
- {
- // Clean up the configuration
- $conformingConfiguration = $this->_cleanConfiguration($configuration);
-
- $response = $this->_performRequest($operationUrl . '/', '?comp=upgrade',
- Microsoft_Http_Client::POST,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . ucfirst($mode) . '' . $packageUrl . '' . base64_encode($conformingConfiguration) . '' . (!is_null($roleToUpgrade) ? '' . $roleToUpgrade . '' : '') . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Walk Upgrade Domain operation specifies the next upgrade domain to be walked during an in-place upgrade.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @param int $upgradeDomain An integer value that identifies the upgrade domain to walk. Upgrade domains are identified with a zero-based index: the first upgrade domain has an ID of 0, the second has an ID of 1, and so on.
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function walkUpgradeDomainBySlot($serviceName, $deploymentSlot, $upgradeDomain = 0)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $deploymentSlot = strtolower($deploymentSlot);
- if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment slot should be production|staging.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
- return $this->_walkUpgradeDomain($operationUrl, $upgradeDomain);
- }
-
- /**
- * The Walk Upgrade Domain operation specifies the next upgrade domain to be walked during an in-place upgrade.
- *
- * @param string $serviceName The service name
- * @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
- * @param int $upgradeDomain An integer value that identifies the upgrade domain to walk. Upgrade domains are identified with a zero-based index: the first upgrade domain has an ID of 0, the second has an ID of 1, and so on.
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function walkUpgradeDomainByDeploymentId($serviceName, $deploymentId, $upgradeDomain = 0)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($deploymentId == '' || is_null($deploymentId)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment ID should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
- return $this->_walkUpgradeDomain($operationUrl, $upgradeDomain);
- }
-
-
- /**
- * The Walk Upgrade Domain operation specifies the next upgrade domain to be walked during an in-place upgrade.
- *
- * @param string $operationUrl The operation url
- * @param int $upgradeDomain An integer value that identifies the upgrade domain to walk. Upgrade domains are identified with a zero-based index: the first upgrade domain has an ID of 0, the second has an ID of 1, and so on.
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- protected function _walkUpgradeDomain($operationUrl, $upgradeDomain = 0)
- {
- // Clean up the configuration
- $conformingConfiguration = $this->_cleanConfiguration($configuration);
-
- $response = $this->_performRequest($operationUrl . '/', '?comp=walkupgradedomain',
- Microsoft_Http_Client::POST,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . $upgradeDomain . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Reboot Role Instance operation requests a reboot of a role instance
- * that is running in a deployment.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @param string $roleInstanceName The role instance name
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function rebootRoleInstanceBySlot($serviceName, $deploymentSlot, $roleInstanceName)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $deploymentSlot = strtolower($deploymentSlot);
- if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment slot should be production|staging.');
- }
- if ($roleInstanceName == '' || is_null($roleInstanceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Role instance name should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot . '/roleinstances/' . $roleInstanceName;
- return $this->_rebootOrReimageRoleInstance($operationUrl, 'reboot');
- }
-
- /**
- * The Reboot Role Instance operation requests a reboot of a role instance
- * that is running in a deployment.
- *
- * @param string $serviceName The service name
- * @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
- * @param string $roleInstanceName The role instance name
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function rebootRoleInstanceByDeploymentId($serviceName, $deploymentId, $roleInstanceName)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($deploymentId == '' || is_null($deploymentId)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment ID should be specified.');
- }
- if ($roleInstanceName == '' || is_null($roleInstanceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Role instance name should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId . '/roleinstances/' . $roleInstanceName;
- return $this->_rebootOrReimageRoleInstance($operationUrl, 'reboot');
- }
-
- /**
- * The Reimage Role Instance operation requests a reimage of a role instance
- * that is running in a deployment.
- *
- * @param string $serviceName The service name
- * @param string $deploymentSlot The deployment slot (production or staging)
- * @param string $roleInstanceName The role instance name
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function reimageRoleInstanceBySlot($serviceName, $deploymentSlot, $roleInstanceName)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- $deploymentSlot = strtolower($deploymentSlot);
- if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment slot should be production|staging.');
- }
- if ($roleInstanceName == '' || is_null($roleInstanceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Role instance name should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot . '/roleinstances/' . $roleInstanceName;
- return $this->_rebootOrReimageRoleInstance($operationUrl, 'reimage');
- }
-
- /**
- * The Reimage Role Instance operation requests a reimage of a role instance
- * that is running in a deployment.
- *
- * @param string $serviceName The service name
- * @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
- * @param string $roleInstanceName The role instance name
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function reimageRoleInstanceByDeploymentId($serviceName, $deploymentId, $roleInstanceName)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($deploymentId == '' || is_null($deploymentId)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Deployment ID should be specified.');
- }
- if ($roleInstanceName == '' || is_null($roleInstanceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Role instance name should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId . '/roleinstances/' . $roleInstanceName;
- return $this->_rebootOrReimageRoleInstance($operationUrl, 'reimage');
- }
-
- /**
- * Reboots or reimages a role instance.
- *
- * @param string $operationUrl The operation url
- * @param string $operation The operation (reboot|reimage)
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- protected function _rebootOrReimageRoleInstance($operationUrl, $operation = 'reboot')
- {
- $response = $this->_performRequest($operationUrl, '?comp=' . $operation, Microsoft_Http_Client::POST);
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The List Certificates operation lists all certificates associated with
- * the specified hosted service.
- *
- * @param string $serviceName The service name
- * @return array Array of Microsoft_WindowsAzure_Management_CertificateInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function listCertificates($serviceName)
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/certificates';
- $response = $this->_performRequest($operationUrl);
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
-
- if (count($result->Certificate) > 1) {
- $xmlServices = $result->Certificate;
- } else {
- $xmlServices = array($result->Certificate);
- }
-
- $services = array();
- if (!is_null($xmlServices)) {
- for ($i = 0; $i < count($xmlServices); $i++) {
- $services[] = new Microsoft_WindowsAzure_Management_CertificateInstance(
- (string)$xmlServices[$i]->CertificateUrl,
- (string)$xmlServices[$i]->Thumbprint,
- (string)$xmlServices[$i]->ThumbprintAlgorithm,
- (string)$xmlServices[$i]->Data
- );
- }
- }
- return $services;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Get Certificate operation returns the public data for the specified certificate.
- *
- * @param string $serviceName|$certificateUrl The service name -or- the certificate URL
- * @param string $algorithm Algorithm
- * @param string $thumbprint Thumbprint
- * @return Microsoft_WindowsAzure_Management_CertificateInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function getCertificate($serviceName, $algorithm = '', $thumbprint = '')
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name or certificate URL should be specified.');
- }
- if (strpos($serviceName, 'https') === false && ($algorithm == '' || is_null($algorithm)) && ($thumbprint == '' || is_null($thumbprint))) {
- throw new Microsoft_WindowsAzure_Management_Exception('Algorithm and thumbprint should be specified.');
- }
-
- $operationUrl = str_replace($this->getBaseUrl(), '', $serviceName);
- if (strpos($serviceName, 'https') === false) {
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/certificates/' . $algorithm . '-' . strtoupper($thumbprint);
- }
-
- $response = $this->_performRequest($operationUrl);
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
-
- return new Microsoft_WindowsAzure_Management_CertificateInstance(
- $this->getBaseUrl() . $operationUrl,
- $algorithm,
- $thumbprint,
- (string)$result->Data
- );
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Add Certificate operation adds a certificate to the subscription.
- *
- * @param string $serviceName The service name
- * @param string $certificateData Certificate data
- * @param string $certificatePassword The certificate password
- * @param string $certificateFormat The certificate format. Currently, only 'pfx' is supported.
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function addCertificate($serviceName, $certificateData, $certificatePassword, $certificateFormat = 'pfx')
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name should be specified.');
- }
- if ($certificateData == '' || is_null($certificateData)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Certificate data should be specified.');
- }
- if ($certificatePassword == '' || is_null($certificatePassword)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Certificate password should be specified.');
- }
- if ($certificateFormat != 'pfx') {
- throw new Microsoft_WindowsAzure_Management_Exception('Certificate format should be "pfx".');
- }
-
- if (@file_exists($certificateData)) {
- $certificateData = file_get_contents($certificateData);
- }
-
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/certificates';
- $response = $this->_performRequest($operationUrl, '',
- Microsoft_Http_Client::POST,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . base64_encode($certificateData) . '' . $certificateFormat . '' . $certificatePassword . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Delete Certificate operation deletes a certificate from the subscription's certificate store.
- *
- * @param string $serviceName|$certificateUrl The service name -or- the certificate URL
- * @param string $algorithm Algorithm
- * @param string $thumbprint Thumbprint
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function deleteCertificate($serviceName, $algorithm = '', $thumbprint = '')
- {
- if ($serviceName == '' || is_null($serviceName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Service name or certificate URL should be specified.');
- }
- if (strpos($serviceName, 'https') === false && ($algorithm == '' || is_null($algorithm)) && ($thumbprint == '' || is_null($thumbprint))) {
- throw new Microsoft_WindowsAzure_Management_Exception('Algorithm and thumbprint should be specified.');
- }
-
- $operationUrl = str_replace($this->getBaseUrl(), '', $serviceName);
- if (strpos($serviceName, 'https') === false) {
- $operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/certificates/' . $algorithm . '-' . strtoupper($thumbprint);
- }
-
- $response = $this->_performRequest($operationUrl, '', Microsoft_Http_Client::DELETE);
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The List Affinity Groups operation lists the affinity groups associated with
- * the specified subscription.
- *
- * @return array Array of Microsoft_WindowsAzure_Management_AffinityGroupInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function listAffinityGroups()
- {
- $response = $this->_performRequest(self::OP_AFFINITYGROUPS);
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
-
- if (count($result->AffinityGroup) > 1) {
- $xmlServices = $result->AffinityGroup;
- } else {
- $xmlServices = array($result->AffinityGroup);
- }
-
- $services = array();
- if (!is_null($xmlServices)) {
- for ($i = 0; $i < count($xmlServices); $i++) {
- $services[] = new Microsoft_WindowsAzure_Management_AffinityGroupInstance(
- (string)$xmlServices[$i]->Name,
- (string)$xmlServices[$i]->Label,
- (string)$xmlServices[$i]->Description,
- (string)$xmlServices[$i]->Location
- );
- }
- }
- return $services;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Create Affinity Group operation creates a new affinity group for the specified subscription.
- *
- * @param string $name A name for the affinity group that is unique to the subscription.
- * @param string $label A label for the affinity group. The label may be up to 100 characters in length.
- * @param string $description A description for the affinity group. The description may be up to 1024 characters in length.
- * @param string $location The location where the affinity group will be created. To list available locations, use the List Locations operation.
- */
- public function createAffinityGroup($name, $label, $description = '', $location = '')
- {
- if ($name == '' || is_null($name)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Affinity group name should be specified.');
- }
- if ($label == '' || is_null($label)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label should be specified.');
- }
- if (strlen($label) > 100) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label is too long. The maximum length is 100 characters.');
- }
- if (strlen($description) > 1024) {
- throw new Microsoft_WindowsAzure_Management_Exception('Description is too long. The maximum length is 1024 characters.');
- }
- if ($location == '' || is_null($location)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Location should be specified.');
- }
-
- $response = $this->_performRequest(self::OP_AFFINITYGROUPS, '',
- Microsoft_Http_Client::POST,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . $name . '' . $description . '' . $location . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Update Affinity Group operation updates the label and/or the description for an affinity group for the specified subscription.
- *
- * @param string $name The name for the affinity group that should be updated.
- * @param string $label A label for the affinity group. The label may be up to 100 characters in length.
- * @param string $description A description for the affinity group. The description may be up to 1024 characters in length.
- */
- public function updateAffinityGroup($name, $label, $description = '')
- {
- if ($name == '' || is_null($name)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Affinity group name should be specified.');
- }
- if ($label == '' || is_null($label)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label should be specified.');
- }
- if (strlen($label) > 100) {
- throw new Microsoft_WindowsAzure_Management_Exception('Label is too long. The maximum length is 100 characters.');
- }
- if (strlen($description) > 1024) {
- throw new Microsoft_WindowsAzure_Management_Exception('Description is too long. The maximum length is 1024 characters.');
- }
-
- $response = $this->_performRequest(self::OP_AFFINITYGROUPS . '/' . $name, '',
- Microsoft_Http_Client::PUT,
- array('Content-Type' => 'application/xml; charset=utf-8'),
- '' . $description . '');
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Delete Affinity Group operation deletes an affinity group in the specified subscription.
- *
- * @param string $name The name for the affinity group that should be deleted.
- */
- public function deleteAffinityGroup($name)
- {
- if ($name == '' || is_null($name)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Affinity group name should be specified.');
- }
-
- $response = $this->_performRequest(self::OP_AFFINITYGROUPS . '/' . $name, '',
- Microsoft_Http_Client::DELETE);
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The Get Affinity Group Properties operation returns the
- * system properties associated with the specified affinity group.
- *
- * @param string $affinityGroupName The affinity group name.
- * @return Microsoft_WindowsAzure_Management_AffinityGroupInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function getAffinityGroupProperties($affinityGroupName)
- {
- if ($affinityGroupName == '' || is_null($affinityGroupName)) {
- throw new Microsoft_WindowsAzure_Management_Exception('Affinity group name should be specified.');
- }
-
- $response = $this->_performRequest(self::OP_AFFINITYGROUPS . '/' . $affinityGroupName);
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
-
- $affinityGroup = new Microsoft_WindowsAzure_Management_AffinityGroupInstance(
- $affinityGroupName,
- (string)$result->Label,
- (string)$result->Description,
- (string)$result->Location
- );
-
- // Hosted services
- if (count($result->HostedServices->HostedService) > 1) {
- $xmlService = $result->HostedServices->HostedService;
- } else {
- $xmlService = array($result->HostedServices->HostedService);
- }
-
- $services = array();
- if (!is_null($xmlService)) {
- for ($i = 0; $i < count($xmlService); $i++) {
- $services[] = array(
- 'url' => (string)$xmlService[$i]->Url,
- 'name' => (string)$xmlService[$i]->ServiceName
- );
- }
- }
- $affinityGroup->HostedServices = $services;
-
- // Storage services
- if (count($result->StorageServices->StorageService) > 1) {
- $xmlService = $result->StorageServices->StorageService;
- } else {
- $xmlService = array($result->StorageServices->StorageService);
- }
-
- $services = array();
- if (!is_null($xmlService)) {
- for ($i = 0; $i < count($xmlService); $i++) {
- $services[] = array(
- 'url' => (string)$xmlService[$i]->Url,
- 'name' => (string)$xmlService[$i]->ServiceName
- );
- }
- }
- $affinityGroup->StorageServices = $services;
-
- return $affinityGroup;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The List Locations operation lists all of the data center locations
- * that are valid for your subscription.
- *
- * @return array Array of Microsoft_WindowsAzure_Management_LocationInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function listLocations()
- {
- $response = $this->_performRequest(self::OP_LOCATIONS);
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
-
- if (count($result->Location) > 1) {
- $xmlServices = $result->Location;
- } else {
- $xmlServices = array($result->Location);
- }
-
- $services = array();
- if (!is_null($xmlServices)) {
- for ($i = 0; $i < count($xmlServices); $i++) {
- $services[] = new Microsoft_WindowsAzure_Management_LocationInstance(
- (string)$xmlServices[$i]->Name
- );
- }
- }
- return $services;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The List Operating Systems operation lists the versions of the guest operating system
- * that are currently available in Windows Azure. The 2010-10-28 version of List Operating
- * Systems also indicates what family an operating system version belongs to.
- * Currently Windows Azure supports two operating system families: the Windows Azure guest
- * operating system that is substantially compatible with Windows Server 2008 SP2,
- * and the Windows Azure guest operating system that is substantially compatible with
- * Windows Server 2008 R2.
- *
- * @return array Array of Microsoft_WindowsAzure_Management_OperatingSystemInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function listOperatingSystems()
- {
- $response = $this->_performRequest(self::OP_OPERATINGSYSTEMS);
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
-
- if (count($result->OperatingSystem) > 1) {
- $xmlServices = $result->OperatingSystem;
- } else {
- $xmlServices = array($result->OperatingSystem);
- }
-
- $services = array();
- if (!is_null($xmlServices)) {
- for ($i = 0; $i < count($xmlServices); $i++) {
- $services[] = new Microsoft_WindowsAzure_Management_OperatingSystemInstance(
- (string)$xmlServices[$i]->Version,
- (string)$xmlServices[$i]->Label,
- ((string)$xmlServices[$i]->IsDefault == 'true'),
- ((string)$xmlServices[$i]->IsActive == 'true'),
- (string)$xmlServices[$i]->Family,
- (string)$xmlServices[$i]->FamilyLabel
- );
- }
- }
- return $services;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * The List OS Families operation lists the guest operating system families
- * available in Windows Azure, and also lists the operating system versions
- * available for each family. Currently Windows Azure supports two operating
- * system families: the Windows Azure guest operating system that is
- * substantially compatible with Windows Server 2008 SP2, and the Windows
- * Azure guest operating system that is substantially compatible with
- * Windows Server 2008 R2.
- *
- * @return array Array of Microsoft_WindowsAzure_Management_OperatingSystemFamilyInstance
- * @throws Microsoft_WindowsAzure_Management_Exception
- */
- public function listOperatingSystemFamilies()
- {
- $response = $this->_performRequest(self::OP_OPERATINGSYSTEMFAMILIES);
-
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
-
- if (count($result->OperatingSystemFamily) > 1) {
- $xmlServices = $result->OperatingSystemFamily;
- } else {
- $xmlServices = array($result->OperatingSystemFamily);
- }
-
- $services = array();
- if (!is_null($xmlServices)) {
- for ($i = 0; $i < count($xmlServices); $i++) {
- $services[] = new Microsoft_WindowsAzure_Management_OperatingSystemFamilyInstance(
- (string)$xmlServices[$i]->Name,
- (string)$xmlServices[$i]->Label
- );
-
- if (count($xmlServices[$i]->OperatingSystems->OperatingSystem) > 1) {
- $xmlOperatingSystems = $xmlServices[$i]->OperatingSystems->OperatingSystem;
- } else {
- $xmlOperatingSystems = array($xmlServices[$i]->OperatingSystems->OperatingSystem);
- }
-
- $operatingSystems = array();
- if (!is_null($xmlOperatingSystems)) {
- for ($i = 0; $i < count($xmlOperatingSystems); $i++) {
- $operatingSystems[] = new Microsoft_WindowsAzure_Management_OperatingSystemInstance(
- (string)$xmlOperatingSystems[$i]->Version,
- (string)$xmlOperatingSystems[$i]->Label,
- ((string)$xmlOperatingSystems[$i]->IsDefault == 'true'),
- ((string)$xmlOperatingSystems[$i]->IsActive == 'true'),
- (string)$xmlServices[$i]->Name,
- (string)$xmlServices[$i]->Label
- );
- }
- }
- $services[ count($services) - 1 ]->OperatingSystems = $operatingSystems;
- }
- }
- return $services;
- } else {
- throw new Microsoft_WindowsAzure_Management_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Clean configuration
- *
- * @param string $configuration Configuration to clean.
- * @return string
- */
- public function _cleanConfiguration($configuration) {
- $configuration = str_replace('?', '', $configuration);
- $configuration = str_replace("\r", "", $configuration);
- $configuration = str_replace("\n", "", $configuration);
-
- return $configuration;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/DeploymentInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/DeploymentInstance.php
deleted file mode 100644
index 3daf475..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/DeploymentInstance.php
+++ /dev/null
@@ -1,108 +0,0 @@
-_data = array(
- 'name' => $name,
- 'deploymentslot' => $deploymentSlot,
- 'privateid' => $privateID,
- 'label' => base64_decode($label),
- 'url' => $url,
- 'configuration' => base64_decode($configuration),
- 'status' => $status,
- 'upgradestatus' => $upgradeStatus,
- 'upgradetype' => $upgradeType,
- 'currentupgradedomainstate' => $currentUpgradeDomainState,
- 'currentupgradedomain' => $currentUpgradeDomain,
- 'upgradedomaincount' => $upgradeDomainCount,
- 'roleinstancelist' => $roleInstanceList,
- 'rolelist' => $roleList
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/Exception.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/Exception.php
deleted file mode 100644
index 0520b9a..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/Exception.php
+++ /dev/null
@@ -1,51 +0,0 @@
-_data = array(
- 'url' => $url,
- 'servicename' => $serviceName,
- 'description' => $description,
- 'affinitygroup' => $affinityGroup,
- 'location' => $location,
- 'label' => base64_decode($label),
- 'deployments' => $deployments
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/LocationInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/LocationInstance.php
deleted file mode 100644
index e5b4dbd..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/LocationInstance.php
+++ /dev/null
@@ -1,69 +0,0 @@
-_data = array(
- 'name' => $name
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/OperatingSystemFamilyInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/OperatingSystemFamilyInstance.php
deleted file mode 100644
index 6d41998..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/OperatingSystemFamilyInstance.php
+++ /dev/null
@@ -1,75 +0,0 @@
-_data = array(
- 'name' => $name,
- 'label' => base64_decode($label),
- 'operatingsystems' => $operatingSystems
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/OperatingSystemInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/OperatingSystemInstance.php
deleted file mode 100644
index 873c0a3..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/OperatingSystemInstance.php
+++ /dev/null
@@ -1,84 +0,0 @@
-_data = array(
- 'version' => $version,
- 'label' => base64_decode($label),
- 'isdefault' => $isDefault,
- 'isactive' => $isActive,
- 'family' => $family,
- 'familylabel' => base64_decode($familyLabel)
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/OperationStatusInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/OperationStatusInstance.php
deleted file mode 100644
index 5ed1011..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/OperationStatusInstance.php
+++ /dev/null
@@ -1,78 +0,0 @@
-_data = array(
- 'id' => $id,
- 'status' => $status,
- 'errorcode' => $errorCode,
- 'errormessage' => $errorMessage
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/ServiceEntityAbstract.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/ServiceEntityAbstract.php
deleted file mode 100644
index 05cd616..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/ServiceEntityAbstract.php
+++ /dev/null
@@ -1,84 +0,0 @@
-_data)) {
- $this->_data[strtolower($name)] = $value;
- return;
- }
-
- throw new Microsoft_WindowsAzure_Management_Exception("Unknown property: " . $name);
- }
-
- /**
- * Magic overload for getting properties
- *
- * @param string $name Name of the property
- */
- public function __get($name) {
- if (array_key_exists(strtolower($name), $this->_data)) {
- return $this->_data[strtolower($name)];
- }
-
- throw new Microsoft_WindowsAzure_Management_Exception("Unknown property: " . $name);
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/StorageServiceInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/StorageServiceInstance.php
deleted file mode 100644
index fc795bd..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/StorageServiceInstance.php
+++ /dev/null
@@ -1,84 +0,0 @@
-_data = array(
- 'url' => $url,
- 'servicename' => $serviceName,
- 'description' => $description,
- 'affinitygroup' => $affinityGroup,
- 'location' => $location,
- 'label' => base64_decode($label)
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/SubscriptionOperationInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/SubscriptionOperationInstance.php
deleted file mode 100644
index 9dbbb97..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Management/SubscriptionOperationInstance.php
+++ /dev/null
@@ -1,95 +0,0 @@
-_data = array(
- 'operationid' => $operationId,
- 'operationobjectid' => $operationObjectId,
- 'operationname' => $operationName,
- 'operationparameters' => $operationParameters,
- 'operationcaller' => $operationCaller,
- 'operationstatus' => $operationStatus
- );
- }
-
- /**
- * Add operation parameter
- *
- * @param string $name Name
- * @param string $value Value
- */
- public function addOperationParameter($name, $value)
- {
- $this->_data['operationparameters'][$name] = $value;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/RetryPolicy/Exception.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/RetryPolicy/Exception.php
deleted file mode 100644
index f7cb8c9..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/RetryPolicy/Exception.php
+++ /dev/null
@@ -1,49 +0,0 @@
-_retryCount = $count;
- $this->_retryInterval = $intervalBetweenRetries;
- }
-
- /**
- * Execute function under retry policy
- *
- * @param string|array $function Function to execute
- * @param array $parameters Parameters for function call
- * @return mixed
- */
- public function execute($function, $parameters = array())
- {
- $returnValue = null;
-
- for ($retriesLeft = $this->_retryCount; $retriesLeft >= 0; --$retriesLeft) {
- try {
- $returnValue = call_user_func_array($function, $parameters);
- return $returnValue;
- } catch (Exception $ex) {
- if ($retriesLeft == 1) {
- throw new Microsoft_WindowsAzure_RetryPolicy_Exception("Exceeded retry count of " . $this->_retryCount . ". " . $ex->getMessage());
- }
-
- usleep($this->_retryInterval * 1000);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/RetryPolicy/RetryPolicyAbstract.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/RetryPolicy/RetryPolicyAbstract.php
deleted file mode 100644
index 014b0b1..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/RetryPolicy/RetryPolicyAbstract.php
+++ /dev/null
@@ -1,90 +0,0 @@
-_storage = $storage;
- $this->_storageType = $storageType;
- $this->_sessionContainer = $sessionContainer;
- $this->_sessionContainerPartition = $sessionContainerPartition;
- }
-
- /**
- * Registers the current session handler as PHP's session handler
- *
- * @return boolean
- */
- public function register()
- {
- return session_set_save_handler(array($this, 'open'),
- array($this, 'close'),
- array($this, 'read'),
- array($this, 'write'),
- array($this, 'destroy'),
- array($this, 'gc')
- );
- }
-
- /**
- * Open the session store
- *
- * @return bool
- */
- public function open()
- {
- // Make sure storage container exists
- if ($this->_storageType == self::STORAGE_TYPE_TABLE) {
- $this->_storage->createTableIfNotExists($this->_sessionContainer);
- } else if ($this->_storageType == self::STORAGE_TYPE_BLOB) {
- $this->_storage->createContainerIfNotExists($this->_sessionContainer);
- }
-
- // Ok!
- return true;
- }
-
- /**
- * Close the session store
- *
- * @return bool
- */
- public function close()
- {
- return true;
- }
-
- /**
- * Read a specific session
- *
- * @param int $id Session Id
- * @return string
- */
- public function read($id)
- {
- // Read data
- if ($this->_storageType == self::STORAGE_TYPE_TABLE) {
- // In table storage
- try
- {
- $sessionRecord = $this->_storage->retrieveEntityById(
- $this->_sessionContainer,
- $this->_sessionContainerPartition,
- $id
- );
- return base64_decode($sessionRecord->serializedData);
- }
- catch (Microsoft_WindowsAzure_Exception $ex)
- {
- return '';
- }
- } else if ($this->_storageType == self::STORAGE_TYPE_BLOB) {
- // In blob storage
- try
- {
- $data = $this->_storage->getBlobData(
- $this->_sessionContainer,
- $this->_sessionContainerPartition . '/' . $id
- );
- return base64_decode($data);
- }
- catch (Microsoft_WindowsAzure_Exception $ex)
- {
- return false;
- }
- }
- }
-
- /**
- * Write a specific session
- *
- * @param int $id Session Id
- * @param string $serializedData Serialized PHP object
- * @throws Exception
- */
- public function write($id, $serializedData)
- {
- // Encode data
- $serializedData = base64_encode($serializedData);
- if (strlen($serializedData) >= self::MAX_TS_PROPERTY_SIZE && $this->_storageType == self::STORAGE_TYPE_TABLE) {
- throw new Microsoft_WindowsAzure_Exception('Session data exceeds the maximum allowed size of ' . self::MAX_TS_PROPERTY_SIZE . ' bytes that can be stored using table storage. Consider switching to a blob storage back-end or try reducing session data size.');
- }
-
- // Store data
- if ($this->_storageType == self::STORAGE_TYPE_TABLE) {
- // In table storage
- $sessionRecord = new Microsoft_WindowsAzure_Storage_DynamicTableEntity($this->_sessionContainerPartition, $id);
- $sessionRecord->sessionExpires = time();
- $sessionRecord->serializedData = $serializedData;
-
- $sessionRecord->setAzurePropertyType('sessionExpires', 'Edm.Int32');
-
- try
- {
- $this->_storage->updateEntity($this->_sessionContainer, $sessionRecord);
- }
- catch (Microsoft_WindowsAzure_Exception $unknownRecord)
- {
- $this->_storage->insertEntity($this->_sessionContainer, $sessionRecord);
- }
- } else if ($this->_storageType == self::STORAGE_TYPE_BLOB) {
- // In blob storage
- $this->_storage->putBlobData(
- $this->_sessionContainer,
- $this->_sessionContainerPartition . '/' . $id,
- $serializedData,
- array('sessionexpires' => time())
- );
- }
- }
-
- /**
- * Destroy a specific session
- *
- * @param int $id Session Id
- * @return boolean
- */
- public function destroy($id)
- {
- // Destroy data
- if ($this->_storageType == self::STORAGE_TYPE_TABLE) {
- // In table storage
- try
- {
- $sessionRecord = $this->_storage->retrieveEntityById(
- $this->_sessionContainer,
- $this->_sessionContainerPartition,
- $id
- );
- $this->_storage->deleteEntity($this->_sessionContainer, $sessionRecord);
-
- return true;
- }
- catch (Microsoft_WindowsAzure_Exception $ex)
- {
- return false;
- }
- } else if ($this->_storageType == self::STORAGE_TYPE_BLOB) {
- // In blob storage
- try
- {
- $this->_storage->deleteBlob(
- $this->_sessionContainer,
- $this->_sessionContainerPartition . '/' . $id
- );
-
- return true;
- }
- catch (Microsoft_WindowsAzure_Exception $ex)
- {
- return false;
- }
- }
- }
-
- /**
- * Garbage collector
- *
- * @param int $lifeTime Session maximal lifetime
- * @see session.gc_divisor 100
- * @see session.gc_maxlifetime 1440
- * @see session.gc_probability 1
- * @usage Execution rate 1/100 (session.gc_probability/session.gc_divisor)
- * @return boolean
- */
- public function gc($lifeTime)
- {
- if ($this->_storageType == self::STORAGE_TYPE_TABLE) {
- // In table storage
- try
- {
- $result = $this->_storage->retrieveEntities($this->_sessionContainer, 'PartitionKey eq \'' . $this->_sessionContainerPartition . '\' and sessionExpires lt ' . (time() - $lifeTime));
- foreach ($result as $sessionRecord)
- {
- $this->_storage->deleteEntity($this->_sessionContainer, $sessionRecord);
- }
- return true;
- }
- catch (Microsoft_WindowsAzure_exception $ex)
- {
- return false;
- }
- } else if ($this->_storageType == self::STORAGE_TYPE_BLOB) {
- // In blob storage
- try
- {
- $result = $this->_storage->listBlobs($this->_sessionContainer, $this->_sessionContainerPartition, '', null, null, 'metadata');
- foreach ($result as $sessionRecord)
- {
- if ($sessionRecord->Metadata['sessionexpires'] < (time() - $lifeTime)) {
- $this->_storage->deleteBlob($this->_sessionContainer, $sessionRecord->Name);
- }
- }
- return true;
- }
- catch (Microsoft_WindowsAzure_exception $ex)
- {
- return false;
- }
- }
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage.php
deleted file mode 100644
index c3050dc..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage.php
+++ /dev/null
@@ -1,586 +0,0 @@
-_host = $host;
- $this->_accountName = $accountName;
- $this->_accountKey = $accountKey;
- $this->_usePathStyleUri = $usePathStyleUri;
-
- // Using local storage?
- if (!$this->_usePathStyleUri
- && ($this->_host == self::URL_DEV_BLOB
- || $this->_host == self::URL_DEV_QUEUE
- || $this->_host == self::URL_DEV_TABLE)
- ) {
- // Local storage
- $this->_usePathStyleUri = true;
- }
-
- if (is_null($this->_credentials)) {
- $this->_credentials = new Microsoft_WindowsAzure_Credentials_SharedKey(
- $this->_accountName, $this->_accountKey, $this->_usePathStyleUri);
- }
-
- $this->_retryPolicy = $retryPolicy;
- if (is_null($this->_retryPolicy)) {
- $this->_retryPolicy = Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract::noRetry();
- }
-
- // Setup default Microsoft_Http_Client channel
- $options = array(
- 'adapter' => 'Microsoft_Http_Client_Adapter_Proxy'
- );
- if (function_exists('curl_init')) {
- // Set cURL options if cURL is used afterwards
- $options['curloptions'] = array(
- CURLOPT_FOLLOWLOCATION => true,
- CURLOPT_TIMEOUT => 120,
- );
- }
- $this->_httpClientChannel = new Microsoft_Http_Client(null, $options);
- }
-
- /**
- * Set the HTTP client channel to use
- *
- * @param Microsoft_Http_Client_Adapter_Interface|string $adapterInstance Adapter instance or adapter class name.
- */
- public function setHttpClientChannel($adapterInstance = 'Microsoft_Http_Client_Adapter_Proxy')
- {
- $this->_httpClientChannel->setAdapter($adapterInstance);
- }
-
- /**
- * Retrieve HTTP client channel
- *
- * @return Microsoft_Http_Client_Adapter_Interface
- */
- public function getHttpClientChannel()
- {
- return $this->_httpClientChannel;
- }
-
- /**
- * Set retry policy to use when making requests
- *
- * @param Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
- */
- public function setRetryPolicy(Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy = null)
- {
- $this->_retryPolicy = $retryPolicy;
- if (is_null($this->_retryPolicy)) {
- $this->_retryPolicy = Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract::noRetry();
- }
- }
-
- /**
- * Set proxy
- *
- * @param boolean $useProxy Use proxy?
- * @param string $proxyUrl Proxy URL
- * @param int $proxyPort Proxy port
- * @param string $proxyCredentials Proxy credentials
- */
- public function setProxy($useProxy = false, $proxyUrl = '', $proxyPort = 80, $proxyCredentials = '')
- {
- $this->_useProxy = $useProxy;
- $this->_proxyUrl = $proxyUrl;
- $this->_proxyPort = $proxyPort;
- $this->_proxyCredentials = $proxyCredentials;
-
- if ($this->_useProxy) {
- $credentials = explode(':', $this->_proxyCredentials);
-
- $this->_httpClientChannel->setConfig(array(
- 'proxy_host' => $this->_proxyUrl,
- 'proxy_port' => $this->_proxyPort,
- 'proxy_user' => $credentials[0],
- 'proxy_pass' => $credentials[1],
- ));
- } else {
- $this->_httpClientChannel->setConfig(array(
- 'proxy_host' => '',
- 'proxy_port' => 8080,
- 'proxy_user' => '',
- 'proxy_pass' => '',
- ));
- }
- }
-
- /**
- * Returns the Windows Azure account name
- *
- * @return string
- */
- public function getAccountName()
- {
- return $this->_accountName;
- }
-
- /**
- * Get base URL for creating requests
- *
- * @return string
- */
- public function getBaseUrl()
- {
- if ($this->_usePathStyleUri) {
- return 'http://' . $this->_host . '/' . $this->_accountName;
- } else {
- return 'http://' . $this->_accountName . '.' . $this->_host;
- }
- }
-
- /**
- * Set Microsoft_WindowsAzure_Credentials_CredentialsAbstract instance
- *
- * @param Microsoft_WindowsAzure_Credentials_CredentialsAbstract $credentials Microsoft_WindowsAzure_Credentials_CredentialsAbstract instance to use for request signing.
- */
- public function setCredentials(Microsoft_WindowsAzure_Credentials_CredentialsAbstract $credentials)
- {
- $this->_credentials = $credentials;
- $this->_credentials->setAccountName($this->_accountName);
- $this->_credentials->setAccountkey($this->_accountKey);
- $this->_credentials->setUsePathStyleUri($this->_usePathStyleUri);
- }
-
- /**
- * Get Microsoft_WindowsAzure_Credentials_CredentialsAbstract instance
- *
- * @return Microsoft_WindowsAzure_Credentials_CredentialsAbstract
- */
- public function getCredentials()
- {
- return $this->_credentials;
- }
-
- /**
- * Perform request using Microsoft_Http_Client channel
- *
- * @param string $path Path
- * @param string $queryString Query string
- * @param string $httpVerb HTTP verb the request will use
- * @param array $headers x-ms headers to add
- * @param boolean $forTableStorage Is the request for table storage?
- * @param mixed $rawData Optional RAW HTTP data to be sent over the wire
- * @param string $resourceType Resource type
- * @param string $requiredPermission Required permission
- * @return Microsoft_Http_Response
- */
- protected function _performRequest(
- $path = '/',
- $queryString = '',
- $httpVerb = Microsoft_Http_Client::GET,
- $headers = array(),
- $forTableStorage = false,
- $rawData = null,
- $resourceType = Microsoft_WindowsAzure_Storage::RESOURCE_UNKNOWN,
- $requiredPermission = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ
- ) {
- // Clean path
- if (strpos($path, '/') !== 0) {
- $path = '/' . $path;
- }
-
- // Clean headers
- if (is_null($headers)) {
- $headers = array();
- }
-
- // Ensure cUrl will also work correctly:
- // - disable Content-Type if required
- // - disable Expect: 100 Continue
- if (!isset($headers["Content-Type"])) {
- $headers["Content-Type"] = '';
- }
- $headers["Expect"]= '';
-
- // Add version header
- $headers['x-ms-version'] = $this->_apiVersion;
-
- // URL encoding
- $path = self::urlencode($path);
- $queryString = self::urlencode($queryString);
-
- // Generate URL and sign request
- $requestUrl = $this->_credentials
- ->signRequestUrl($this->getBaseUrl() . $path . $queryString, $resourceType, $requiredPermission);
- $requestHeaders = $this->_credentials
- ->signRequestHeaders($httpVerb, $path, $queryString, $headers, $forTableStorage, $resourceType, $requiredPermission, $rawData);
-
- // Prepare request
- $this->_httpClientChannel->resetParameters(true);
- $this->_httpClientChannel->setUri($requestUrl);
- $this->_httpClientChannel->setHeaders($requestHeaders);
- $this->_httpClientChannel->setRawData($rawData);
-
- // Execute request
- $response = $this->_retryPolicy->execute(
- array($this->_httpClientChannel, 'request'),
- array($httpVerb)
- );
-
- return $response;
- }
-
- /**
- * Parse result from Microsoft_Http_Response
- *
- * @param Microsoft_Http_Response $response Response from HTTP call
- * @return object
- * @throws Microsoft_WindowsAzure_Exception
- */
- protected function _parseResponse(Microsoft_Http_Response $response = null)
- {
- if (is_null($response)) {
- throw new Microsoft_WindowsAzure_Exception('Response should not be null.');
- }
-
- $xml = @simplexml_load_string($response->getBody());
-
- if ($xml !== false) {
- // Fetch all namespaces
- $namespaces = array_merge($xml->getNamespaces(true), $xml->getDocNamespaces(true));
-
- // Register all namespace prefixes
- foreach ($namespaces as $prefix => $ns) {
- if ($prefix != '') {
- $xml->registerXPathNamespace($prefix, $ns);
- }
- }
- }
-
- return $xml;
- }
-
- /**
- * Generate metadata headers
- *
- * @param array $metadata
- * @return HTTP headers containing metadata
- */
- protected function _generateMetadataHeaders($metadata = array())
- {
- // Validate
- if (!is_array($metadata)) {
- return array();
- }
-
- // Return headers
- $headers = array();
- foreach ($metadata as $key => $value) {
- if (strpos($value, "\r") !== false || strpos($value, "\n") !== false) {
- throw new Microsoft_WindowsAzure_Exception('Metadata cannot contain newline characters.');
- }
-
- if (!self::isValidMetadataName($key)) {
- throw new Microsoft_WindowsAzure_Exception('Metadata name does not adhere to metadata naming conventions. See http://msdn.microsoft.com/en-us/library/aa664670(VS.71).aspx for more information.');
- }
-
- $headers["x-ms-meta-" . strtolower($key)] = $value;
- }
- return $headers;
- }
-
- /**
- * Parse metadata headers
- *
- * @param array $headers HTTP headers containing metadata
- * @return array
- */
- protected function _parseMetadataHeaders($headers = array())
- {
- // Validate
- if (!is_array($headers)) {
- return array();
- }
-
- // Return metadata
- $metadata = array();
- foreach ($headers as $key => $value) {
- if (substr(strtolower($key), 0, 10) == "x-ms-meta-") {
- $metadata[str_replace("x-ms-meta-", '', strtolower($key))] = $value;
- }
- }
- return $metadata;
- }
-
- /**
- * Parse metadata XML
- *
- * @param SimpleXMLElement $parentElement Element containing the Metadata element.
- * @return array
- */
- protected function _parseMetadataElement($element = null)
- {
- // Metadata present?
- if (!is_null($element) && isset($element->Metadata) && !is_null($element->Metadata)) {
- return get_object_vars($element->Metadata);
- }
-
- return array();
- }
-
- /**
- * Generate ISO 8601 compliant date string in UTC time zone
- *
- * @param int $timestamp
- * @return string
- */
- public function isoDate($timestamp = null)
- {
- $tz = @date_default_timezone_get();
- @date_default_timezone_set('UTC');
-
- if (is_null($timestamp)) {
- $timestamp = time();
- }
-
- $returnValue = str_replace('+00:00', '.0000000Z', @date('c', $timestamp));
- @date_default_timezone_set($tz);
- return $returnValue;
- }
-
- /**
- * URL encode function
- *
- * @param string $value Value to encode
- * @return string Encoded value
- */
- public static function urlencode($value)
- {
- return str_replace(' ', '%20', $value);
- }
-
- /**
- * Is valid metadata name?
- *
- * @param string $metadataName Metadata name
- * @return boolean
- */
- public static function isValidMetadataName($metadataName = '')
- {
- if (preg_match("/^[a-zA-Z0-9_@][a-zA-Z0-9_]*$/", $metadataName) === 0) {
- return false;
- }
-
- if ($metadataName == '') {
- return false;
- }
-
- return true;
- }
-
- /**
- * Builds a query string from an array of elements
- *
- * @param array Array of elements
- * @return string Assembled query string
- */
- public static function createQueryStringFromArray($queryString)
- {
- return count($queryString) > 0 ? '?' . implode('&', $queryString) : '';
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Batch.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Batch.php
deleted file mode 100644
index f40c3a8..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Batch.php
+++ /dev/null
@@ -1,261 +0,0 @@
-_storageClient = $storageClient;
- $this->_baseUrl = $baseUrl;
- $this->_beginBatch();
- }
-
- /**
- * Get base URL for creating requests
- *
- * @return string
- */
- public function getBaseUrl()
- {
- return $this->_baseUrl;
- }
-
- /**
- * Starts a new batch operation set
- *
- * @throws Microsoft_WindowsAzure_Exception
- */
- protected function _beginBatch()
- {
- $this->_storageClient->setCurrentBatch($this);
- }
-
- /**
- * Cleanup current batch
- */
- protected function _clean()
- {
- unset($this->_operations);
- $this->_storageClient->setCurrentBatch(null);
- $this->_storageClient = null;
- unset($this);
- }
-
- /**
- * Enlist operation in current batch
- *
- * @param string $path Path
- * @param string $queryString Query string
- * @param string $httpVerb HTTP verb the request will use
- * @param array $headers x-ms headers to add
- * @param boolean $forTableStorage Is the request for table storage?
- * @param mixed $rawData Optional RAW HTTP data to be sent over the wire
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function enlistOperation($path = '/', $queryString = '', $httpVerb = Microsoft_Http_Client::GET, $headers = array(), $forTableStorage = false, $rawData = null)
- {
- // Set _forTableStorage
- if ($forTableStorage) {
- $this->_forTableStorage = true;
- }
-
- // Set _isSingleSelect
- if ($httpVerb == Microsoft_Http_Client::GET) {
- if (count($this->_operations) > 0) {
- throw new Microsoft_WindowsAzure_Exception("Select operations can only be performed in an empty batch transaction.");
- }
- $this->_isSingleSelect = true;
- }
-
- // Clean path
- if (strpos($path, '/') !== 0) {
- $path = '/' . $path;
- }
-
- // Clean headers
- if (is_null($headers)) {
- $headers = array();
- }
-
- // URL encoding
- $path = Microsoft_WindowsAzure_Storage::urlencode($path);
- $queryString = Microsoft_WindowsAzure_Storage::urlencode($queryString);
-
- // Generate URL
- $requestUrl = $this->getBaseUrl() . $path . $queryString;
-
- // Generate $rawData
- if (is_null($rawData)) {
- $rawData = '';
- }
-
- // Add headers
- if ($httpVerb != Microsoft_Http_Client::GET) {
- $headers['Content-ID'] = count($this->_operations) + 1;
- if ($httpVerb != Microsoft_Http_Client::DELETE) {
- $headers['Content-Type'] = 'application/atom+xml;type=entry';
- }
- $headers['Content-Length'] = strlen($rawData);
- }
-
- // Generate $operation
- $operation = '';
- $operation .= $httpVerb . ' ' . $requestUrl . ' HTTP/1.1' . "\n";
- foreach ($headers as $key => $value)
- {
- $operation .= $key . ': ' . $value . "\n";
- }
- $operation .= "\n";
-
- // Add data
- $operation .= $rawData;
-
- // Store operation
- $this->_operations[] = $operation;
- }
-
- /**
- * Commit current batch
- *
- * @return Microsoft_Http_Response
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function commit()
- {
- // Perform batch
- $response = $this->_storageClient->performBatch($this->_operations, $this->_forTableStorage, $this->_isSingleSelect);
-
- // Dispose
- $this->_clean();
-
- // Parse response
- $errors = null;
- preg_match_all('/(.*)<\/message>/', $response->getBody(), $errors);
-
- // Error?
- if (count($errors[2]) > 0) {
- throw new Microsoft_WindowsAzure_Exception('An error has occured while committing a batch: ' . $errors[2][0]);
- }
-
- // Return
- return $response;
- }
-
- /**
- * Rollback current batch
- */
- public function rollback()
- {
- // Dispose
- $this->_clean();
- }
-
- /**
- * Get operation count
- *
- * @return integer
- */
- public function getOperationCount()
- {
- return count($this->_operations);
- }
-
- /**
- * Is single select?
- *
- * @return boolean
- */
- public function isSingleSelect()
- {
- return $this->_isSingleSelect;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/BatchStorageAbstract.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/BatchStorageAbstract.php
deleted file mode 100644
index fbd913b..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/BatchStorageAbstract.php
+++ /dev/null
@@ -1,210 +0,0 @@
-isInBatch()) {
- throw new Microsoft_WindowsAzure_Exception('Only one batch can be active at a time.');
- }
- $this->_currentBatch = $batch;
- }
-
- /**
- * Get current batch
- *
- * @return Microsoft_WindowsAzure_Storage_Batch
- */
- public function getCurrentBatch()
- {
- return $this->_currentBatch;
- }
-
- /**
- * Is there a current batch?
- *
- * @return boolean
- */
- public function isInBatch()
- {
- return !is_null($this->_currentBatch);
- }
-
- /**
- * Starts a new batch operation set
- *
- * @return Microsoft_WindowsAzure_Storage_Batch
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function startBatch()
- {
- return new Microsoft_WindowsAzure_Storage_Batch($this, $this->getBaseUrl());
- }
-
- /**
- * Perform batch using Microsoft_Http_Client channel, combining all batch operations into one request
- *
- * @param array $operations Operations in batch
- * @param boolean $forTableStorage Is the request for table storage?
- * @param boolean $isSingleSelect Is the request a single select statement?
- * @param string $resourceType Resource type
- * @param string $requiredPermission Required permission
- * @return Microsoft_Http_Response
- */
- public function performBatch($operations = array(), $forTableStorage = false, $isSingleSelect = false, $resourceType = Microsoft_WindowsAzure_Storage::RESOURCE_UNKNOWN, $requiredPermission = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ)
- {
- // Generate boundaries
- $batchBoundary = 'batch_' . md5(time() . microtime());
- $changesetBoundary = 'changeset_' . md5(time() . microtime());
-
- // Set headers
- $headers = array();
-
- // Add version header
- $headers['x-ms-version'] = $this->_apiVersion;
-
- // Add dataservice headers
- $headers['DataServiceVersion'] = '1.0;NetFx';
- $headers['MaxDataServiceVersion'] = '1.0;NetFx';
-
- // Add content-type header
- $headers['Content-Type'] = 'multipart/mixed; boundary=' . $batchBoundary;
-
- // Set path and query string
- $path = '/$batch';
- $queryString = '';
-
- // Set verb
- $httpVerb = Microsoft_Http_Client::POST;
-
- // Generate raw data
- $rawData = '';
-
- // Single select?
- if ($isSingleSelect) {
- $operation = $operations[0];
- $rawData .= '--' . $batchBoundary . "\n";
- $rawData .= 'Content-Type: application/http' . "\n";
- $rawData .= 'Content-Transfer-Encoding: binary' . "\n\n";
- $rawData .= $operation;
- $rawData .= '--' . $batchBoundary . '--';
- } else {
- $rawData .= '--' . $batchBoundary . "\n";
- $rawData .= 'Content-Type: multipart/mixed; boundary=' . $changesetBoundary . "\n\n";
-
- // Add operations
- foreach ($operations as $operation)
- {
- $rawData .= '--' . $changesetBoundary . "\n";
- $rawData .= 'Content-Type: application/http' . "\n";
- $rawData .= 'Content-Transfer-Encoding: binary' . "\n\n";
- $rawData .= $operation;
- }
- $rawData .= '--' . $changesetBoundary . '--' . "\n";
-
- $rawData .= '--' . $batchBoundary . '--';
- }
-
- // Generate URL and sign request
- $requestUrl = $this->_credentials->signRequestUrl($this->getBaseUrl() . $path . $queryString, $resourceType, $requiredPermission);
- $requestHeaders = $this->_credentials->signRequestHeaders($httpVerb, $path, $queryString, $headers, $forTableStorage, $resourceType, $requiredPermission);
-
- // Prepare request
- $this->_httpClientChannel->resetParameters(true);
- $this->_httpClientChannel->setUri($requestUrl);
- $this->_httpClientChannel->setHeaders($requestHeaders);
- $this->_httpClientChannel->setRawData($rawData);
-
- // Execute request
- $response = $this->_retryPolicy->execute(
- array($this->_httpClientChannel, 'request'),
- array($httpVerb)
- );
-
- return $response;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Blob.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Blob.php
deleted file mode 100644
index fd39deb..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Blob.php
+++ /dev/null
@@ -1,2029 +0,0 @@
-_apiVersion = '2009-09-19';
-
- // SharedAccessSignature credentials
- $this->_sharedAccessSignatureCredentials = new Microsoft_WindowsAzure_Credentials_SharedAccessSignature($accountName, $accountKey, $usePathStyleUri);
- }
-
- /**
- * Check if a blob exists
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $snapshotId Snapshot identifier
- * @return boolean
- */
- public function blobExists($containerName = '', $blobName = '', $snapshotId = null)
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
-
- // Get blob instance
- try {
- $this->getBlobInstance($containerName, $blobName, $snapshotId);
- } catch (Microsoft_WindowsAzure_Exception $e) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Check if a container exists
- *
- * @param string $containerName Container name
- * @return boolean
- */
- public function containerExists($containerName = '')
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
-
- // List containers
- $containers = $this->listContainers($containerName, 1);
- foreach ($containers as $container) {
- if ($container->Name == $containerName) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Create container
- *
- * @param string $containerName Container name
- * @param array $metadata Key/value pairs of meta data
- * @return object Container properties
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function createContainer($containerName = '', $metadata = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if (!is_array($metadata)) {
- throw new Microsoft_WindowsAzure_Exception('Meta data should be an array of key and value pairs.');
- }
-
- // Create metadata headers
- $headers = array();
- $headers = array_merge($headers, $this->_generateMetadataHeaders($metadata));
-
- // Perform request
- $response = $this->_performRequest($containerName, '?restype=container', Microsoft_Http_Client::PUT, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_CONTAINER, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if ($response->isSuccessful()) {
- return new Microsoft_WindowsAzure_Storage_BlobContainer(
- $containerName,
- $response->getHeader('Etag'),
- $response->getHeader('Last-modified'),
- $metadata
- );
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Create container if it does not exist
- *
- * @param string $containerName Container name
- * @param array $metadata Key/value pairs of meta data
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function createContainerIfNotExists($containerName = '', $metadata = array())
- {
- if (!$this->containerExists($containerName)) {
- $this->createContainer($containerName, $metadata);
- }
- }
-
- /**
- * Get container ACL
- *
- * @param string $containerName Container name
- * @param bool $signedIdentifiers Display only private/blob/container or display signed identifiers?
- * @return string Acl, to be compared with Microsoft_WindowsAzure_Storage_Blob::ACL_*
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getContainerAcl($containerName = '', $signedIdentifiers = false)
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
-
- // Perform request
- $response = $this->_performRequest($containerName, '?restype=container&comp=acl', Microsoft_Http_Client::GET, array(), false, null, Microsoft_WindowsAzure_Storage::RESOURCE_CONTAINER, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ);
- if ($response->isSuccessful()) {
- if ($signedIdentifiers == false) {
- // Only private/blob/container
- $accessType = $response->getHeader(Microsoft_WindowsAzure_Storage::PREFIX_STORAGE_HEADER . 'blob-public-access');
- if (strtolower($accessType) == 'true') {
- $accessType = self::ACL_PUBLIC_CONTAINER;
- }
- return $accessType;
- } else {
- // Parse result
- $result = $this->_parseResponse($response);
- if (!$result) {
- return array();
- }
-
- $entries = null;
- if ($result->SignedIdentifier) {
- if (count($result->SignedIdentifier) > 1) {
- $entries = $result->SignedIdentifier;
- } else {
- $entries = array($result->SignedIdentifier);
- }
- }
-
- // Return value
- $returnValue = array();
- foreach ($entries as $entry) {
- $returnValue[] = new Microsoft_WindowsAzure_Storage_SignedIdentifier(
- $entry->Id,
- $entry->AccessPolicy ? $entry->AccessPolicy->Start ? $entry->AccessPolicy->Start : '' : '',
- $entry->AccessPolicy ? $entry->AccessPolicy->Expiry ? $entry->AccessPolicy->Expiry : '' : '',
- $entry->AccessPolicy ? $entry->AccessPolicy->Permission ? $entry->AccessPolicy->Permission : '' : ''
- );
- }
-
- // Return
- return $returnValue;
- }
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Set container ACL
- *
- * @param string $containerName Container name
- * @param bool $acl Microsoft_WindowsAzure_Storage_Blob::ACL_*
- * @param array $signedIdentifiers Signed identifiers
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function setContainerAcl($containerName = '', $acl = self::ACL_PRIVATE, $signedIdentifiers = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
-
- // Headers
- $headers = array();
-
- // Acl specified?
- if ($acl != self::ACL_PRIVATE && !is_null($acl) && $acl != '') {
- $headers[Microsoft_WindowsAzure_Storage::PREFIX_STORAGE_HEADER . 'blob-public-access'] = $acl;
- }
-
- // Policies
- $policies = null;
- if (is_array($signedIdentifiers) && count($signedIdentifiers) > 0) {
- $policies = '';
- $policies .= '' . "\r\n";
- $policies .= '' . "\r\n";
- foreach ($signedIdentifiers as $signedIdentifier) {
- $policies .= ' ' . "\r\n";
- $policies .= ' ' . $signedIdentifier->Id . '' . "\r\n";
- $policies .= ' ' . "\r\n";
- if ($signedIdentifier->Start != '')
- $policies .= ' ' . $signedIdentifier->Start . '' . "\r\n";
- if ($signedIdentifier->Expiry != '')
- $policies .= ' ' . $signedIdentifier->Expiry . '' . "\r\n";
- if ($signedIdentifier->Permissions != '')
- $policies .= ' ' . $signedIdentifier->Permissions . '' . "\r\n";
- $policies .= ' ' . "\r\n";
- $policies .= ' ' . "\r\n";
- }
- $policies .= '' . "\r\n";
- }
-
- // Perform request
- $response = $this->_performRequest($containerName, '?restype=container&comp=acl', Microsoft_Http_Client::PUT, $headers, false, $policies, Microsoft_WindowsAzure_Storage::RESOURCE_CONTAINER, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Get container
- *
- * @param string $containerName Container name
- * @return Microsoft_WindowsAzure_Storage_BlobContainer
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getContainer($containerName = '')
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
-
- // Perform request
- $response = $this->_performRequest($containerName, '?restype=container', Microsoft_Http_Client::GET, array(), false, null, Microsoft_WindowsAzure_Storage::RESOURCE_CONTAINER, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ);
- if ($response->isSuccessful()) {
- // Parse metadata
- $metadata = $this->_parseMetadataHeaders($response->getHeaders());
-
- // Return container
- return new Microsoft_WindowsAzure_Storage_BlobContainer(
- $containerName,
- $response->getHeader('Etag'),
- $response->getHeader('Last-modified'),
- $metadata
- );
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Get container metadata
- *
- * @param string $containerName Container name
- * @return array Key/value pairs of meta data
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getContainerMetadata($containerName = '')
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
-
- return $this->getContainer($containerName)->Metadata;
- }
-
- /**
- * Set container metadata
- *
- * Calling the Set Container Metadata operation overwrites all existing metadata that is associated with the container. It's not possible to modify an individual name/value pair.
- *
- * @param string $containerName Container name
- * @param array $metadata Key/value pairs of meta data
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function setContainerMetadata($containerName = '', $metadata = array(), $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if (!is_array($metadata)) {
- throw new Microsoft_WindowsAzure_Exception('Meta data should be an array of key and value pairs.');
- }
- if (count($metadata) == 0) {
- return;
- }
-
- // Create metadata headers
- $headers = array();
- $headers = array_merge($headers, $this->_generateMetadataHeaders($metadata));
-
- // Additional headers?
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Perform request
- $response = $this->_performRequest($containerName, '?restype=container&comp=metadata', Microsoft_Http_Client::PUT, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_CONTAINER, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Delete container
- *
- * @param string $containerName Container name
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function deleteContainer($containerName = '', $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
-
- // Additional headers?
- $headers = array();
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Perform request
- $response = $this->_performRequest($containerName, '?restype=container', Microsoft_Http_Client::DELETE, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_CONTAINER, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * List containers
- *
- * @param string $prefix Optional. Filters the results to return only containers whose name begins with the specified prefix.
- * @param int $maxResults Optional. Specifies the maximum number of containers to return per call to Azure storage. This does NOT affect list size returned by this function. (maximum: 5000)
- * @param string $marker Optional string value that identifies the portion of the list to be returned with the next list operation.
- * @param string $include Optional. Include this parameter to specify that the container's metadata be returned as part of the response body. (allowed values: '', 'metadata')
- * @param int $currentResultCount Current result count (internal use)
- * @return array
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function listContainers($prefix = null, $maxResults = null, $marker = null, $include = null, $currentResultCount = 0)
- {
- // Build query string
- $queryString = array('comp=list');
- if (!is_null($prefix)) {
- $queryString[] = 'prefix=' . $prefix;
- }
- if (!is_null($maxResults)) {
- $queryString[] = 'maxresults=' . $maxResults;
- }
- if (!is_null($marker)) {
- $queryString[] = 'marker=' . $marker;
- }
- if (!is_null($include)) {
- $queryString[] = 'include=' . $include;
- }
- $queryString = self::createQueryStringFromArray($queryString);
-
- // Perform request
- $response = $this->_performRequest('', $queryString, Microsoft_Http_Client::GET, array(), false, null, Microsoft_WindowsAzure_Storage::RESOURCE_CONTAINER, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_LIST);
- if ($response->isSuccessful()) {
- $xmlContainers = $this->_parseResponse($response)->Containers->Container;
- $xmlMarker = (string)$this->_parseResponse($response)->NextMarker;
-
- $containers = array();
- if (!is_null($xmlContainers)) {
- for ($i = 0; $i < count($xmlContainers); $i++) {
- $containers[] = new Microsoft_WindowsAzure_Storage_BlobContainer(
- (string)$xmlContainers[$i]->Name,
- (string)$xmlContainers[$i]->Etag,
- (string)$xmlContainers[$i]->LastModified,
- $this->_parseMetadataElement($xmlContainers[$i])
- );
- }
- }
- $currentResultCount = $currentResultCount + count($containers);
- if (!is_null($maxResults) && $currentResultCount < $maxResults) {
- if (!is_null($xmlMarker) && $xmlMarker != '') {
- $containers = array_merge($containers, $this->listContainers($prefix, $maxResults, $xmlMarker, $include, $currentResultCount));
- }
- }
- if (!is_null($maxResults) && count($containers) > $maxResults) {
- $containers = array_slice($containers, 0, $maxResults);
- }
-
- return $containers;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Put blob
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $localFileName Local file name to be uploaded
- * @param array $metadata Key/value pairs of meta data
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @return object Partial blob properties
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function putBlob($containerName = '', $blobName = '', $localFileName = '', $metadata = array(), $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($localFileName === '') {
- throw new Microsoft_WindowsAzure_Exception('Local file name is not specified.');
- }
- if (!file_exists($localFileName)) {
- throw new Microsoft_WindowsAzure_Exception('Local file not found.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- // Check file size
- if (filesize($localFileName) >= self::MAX_BLOB_SIZE) {
- return $this->putLargeBlob($containerName, $blobName, $localFileName, $metadata, $leaseId, $additionalHeaders);
- }
-
- // Put the data to Windows Azure Storage
- return $this->putBlobData($containerName, $blobName, file_get_contents($localFileName), $metadata, $leaseId, $additionalHeaders);
- }
-
- /**
- * Put blob data
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param mixed $data Data to store
- * @param array $metadata Key/value pairs of meta data
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @return object Partial blob properties
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function putBlobData($containerName = '', $blobName = '', $data = '', $metadata = array(), $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- // Create metadata headers
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
- $headers = array_merge($headers, $this->_generateMetadataHeaders($metadata));
-
- // Additional headers?
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Specify blob type
- $headers[Microsoft_WindowsAzure_Storage::PREFIX_STORAGE_HEADER . 'blob-type'] = self::BLOBTYPE_BLOCK;
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, '', Microsoft_Http_Client::PUT, $headers, false, $data, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if ($response->isSuccessful()) {
- return new Microsoft_WindowsAzure_Storage_BlobInstance(
- $containerName,
- $blobName,
- null,
- $response->getHeader('Etag'),
- $response->getHeader('Last-modified'),
- $this->getBaseUrl() . '/' . $containerName . '/' . $blobName,
- strlen($data),
- '',
- '',
- '',
- false,
- $metadata
- );
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Put large blob (> 64 MB)
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $localFileName Local file name to be uploaded
- * @param array $metadata Key/value pairs of meta data
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @return object Partial blob properties
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function putLargeBlob($containerName = '', $blobName = '', $localFileName = '', $metadata = array(), $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($localFileName === '') {
- throw new Microsoft_WindowsAzure_Exception('Local file name is not specified.');
- }
- if (!file_exists($localFileName)) {
- throw new Microsoft_WindowsAzure_Exception('Local file not found.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- // Check file size
- if (filesize($localFileName) < self::MAX_BLOB_SIZE) {
- return $this->putBlob($containerName, $blobName, $localFileName, $metadata, $leaseId, $additionalHeaders);
- }
-
- // Determine number of parts
- $numberOfParts = ceil( filesize($localFileName) / self::MAX_BLOB_TRANSFER_SIZE );
-
- // Generate block id's
- $blockIdentifiers = array();
- for ($i = 0; $i < $numberOfParts; $i++) {
- $blockIdentifiers[] = $this->_generateBlockId($i);
- }
-
- // Open file
- $fp = fopen($localFileName, 'r');
- if ($fp === false) {
- throw new Microsoft_WindowsAzure_Exception('Could not open local file.');
- }
-
- // Upload parts
- for ($i = 0; $i < $numberOfParts; $i++) {
- // Seek position in file
- fseek($fp, $i * self::MAX_BLOB_TRANSFER_SIZE);
-
- // Read contents
- $fileContents = fread($fp, self::MAX_BLOB_TRANSFER_SIZE);
-
- // Put block
- $this->putBlock($containerName, $blobName, $blockIdentifiers[$i], $fileContents, $leaseId);
-
- // Dispose file contents
- $fileContents = null;
- unset($fileContents);
- }
-
- // Close file
- fclose($fp);
-
- // Put block list
- $this->putBlockList($containerName, $blobName, $blockIdentifiers, $metadata, $leaseId, $additionalHeaders);
-
- // Return information of the blob
- return $this->getBlobInstance($containerName, $blobName, null, $leaseId);
- }
-
- /**
- * Put large blob block
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $identifier Block ID
- * @param array $contents Contents of the block
- * @param string $leaseId Lease identifier
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function putBlock($containerName = '', $blobName = '', $identifier = '', $contents = '', $leaseId = null)
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($identifier === '') {
- throw new Microsoft_WindowsAzure_Exception('Block identifier is not specified.');
- }
- if (strlen($contents) > self::MAX_BLOB_TRANSFER_SIZE) {
- throw new Microsoft_WindowsAzure_Exception('Block size is too big.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- // Headers
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Upload
- $response = $this->_performRequest($resourceName, '?comp=block&blockid=' . base64_encode($identifier), Microsoft_Http_Client::PUT, $headers, false, $contents, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Put block list
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param array $blockList Array of block identifiers
- * @param array $metadata Key/value pairs of meta data
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function putBlockList($containerName = '', $blobName = '', $blockList = array(), $metadata = array(), $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if (count($blockList) == 0) {
- throw new Microsoft_WindowsAzure_Exception('Block list does not contain any elements.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- // Generate block list
- $blocks = '';
- foreach ($blockList as $block) {
- $blocks .= ' ' . base64_encode($block) . '' . "\n";
- }
-
- // Generate block list request
- $fileContents = utf8_encode(implode("\n", array(
- '',
- '',
- $blocks,
- ''
- )));
-
- // Create metadata headers
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
- $headers = array_merge($headers, $this->_generateMetadataHeaders($metadata));
-
- // Additional headers?
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, '?comp=blocklist', Microsoft_Http_Client::PUT, $headers, false, $fileContents, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Get block list
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $snapshotId Snapshot identifier
- * @param string $leaseId Lease identifier
- * @param integer $type Type of block list to retrieve. 0 = all, 1 = committed, 2 = uncommitted
- * @return array
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getBlockList($containerName = '', $blobName = '', $snapshotId = null, $leaseId = null, $type = 0)
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($type < 0 || $type > 2) {
- throw new Microsoft_WindowsAzure_Exception('Invalid type of block list to retrieve.');
- }
-
- // Set $blockListType
- $blockListType = 'all';
- if ($type == 1) {
- $blockListType = 'committed';
- }
- if ($type == 2) {
- $blockListType = 'uncommitted';
- }
-
- // Headers
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
-
- // Build query string
- $queryString = array('comp=blocklist', 'blocklisttype=' . $blockListType);
- if (!is_null($snapshotId)) {
- $queryString[] = 'snapshot=' . $snapshotId;
- }
- $queryString = self::createQueryStringFromArray($queryString);
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, $queryString, Microsoft_Http_Client::GET, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ);
- if ($response->isSuccessful()) {
- // Parse response
- $blockList = $this->_parseResponse($response);
-
- // Create return value
- $returnValue = array();
- if ($blockList->CommittedBlocks) {
- foreach ($blockList->CommittedBlocks->Block as $block) {
- $returnValue['CommittedBlocks'][] = (object)array(
- 'Name' => (string)$block->Name,
- 'Size' => (string)$block->Size
- );
- }
- }
- if ($blockList->UncommittedBlocks) {
- foreach ($blockList->UncommittedBlocks->Block as $block) {
- $returnValue['UncommittedBlocks'][] = (object)array(
- 'Name' => (string)$block->Name,
- 'Size' => (string)$block->Size
- );
- }
- }
-
- return $returnValue;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Create page blob
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param int $size Size of the page blob in bytes
- * @param array $metadata Key/value pairs of meta data
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @return object Partial blob properties
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function createPageBlob($containerName = '', $blobName = '', $size = 0, $metadata = array(), $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
- if ($size <= 0) {
- throw new Microsoft_WindowsAzure_Exception('Page blob size must be specified.');
- }
-
- // Create metadata headers
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
- $headers = array_merge($headers, $this->_generateMetadataHeaders($metadata));
-
- // Additional headers?
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Specify blob type & blob length
- $headers[Microsoft_WindowsAzure_Storage::PREFIX_STORAGE_HEADER . 'blob-type'] = self::BLOBTYPE_PAGE;
- $headers[Microsoft_WindowsAzure_Storage::PREFIX_STORAGE_HEADER . 'blob-content-length'] = $size;
- $headers['Content-Length'] = 0;
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, '', Microsoft_Http_Client::PUT, $headers, false, '', Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if ($response->isSuccessful()) {
- return new Microsoft_WindowsAzure_Storage_BlobInstance(
- $containerName,
- $blobName,
- null,
- $response->getHeader('Etag'),
- $response->getHeader('Last-modified'),
- $this->getBaseUrl() . '/' . $containerName . '/' . $blobName,
- $size,
- '',
- '',
- '',
- false,
- $metadata
- );
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Put page in page blob
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param int $startByteOffset Start byte offset
- * @param int $endByteOffset End byte offset
- * @param mixed $contents Page contents
- * @param string $writeMethod Write method (Microsoft_WindowsAzure_Storage_Blob::PAGE_WRITE_*)
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function putPage($containerName = '', $blobName = '', $startByteOffset = 0, $endByteOffset = 0, $contents = '', $writeMethod = self::PAGE_WRITE_UPDATE, $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
- if ($startByteOffset % 512 != 0) {
- throw new Microsoft_WindowsAzure_Exception('Start byte offset must be a modulus of 512.');
- }
- if (($endByteOffset + 1) % 512 != 0) {
- throw new Microsoft_WindowsAzure_Exception('End byte offset must be a modulus of 512 minus 1.');
- }
-
- // Determine size
- $size = strlen($contents);
- if ($size >= self::MAX_BLOB_TRANSFER_SIZE) {
- throw new Microsoft_WindowsAzure_Exception('Page blob size must not be larger than ' + self::MAX_BLOB_TRANSFER_SIZE . ' bytes.');
- }
-
- // Create metadata headers
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
-
- // Additional headers?
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Specify range
- $headers['Range'] = 'bytes=' . $startByteOffset . '-' . $endByteOffset;
-
- // Write method
- $headers[Microsoft_WindowsAzure_Storage::PREFIX_STORAGE_HEADER . 'page-write'] = $writeMethod;
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, '?comp=page', Microsoft_Http_Client::PUT, $headers, false, $contents, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Put page in page blob
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param int $startByteOffset Start byte offset
- * @param int $endByteOffset End byte offset
- * @param string $leaseId Lease identifier
- * @return array Array of page ranges
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getPageRegions($containerName = '', $blobName = '', $startByteOffset = 0, $endByteOffset = 0, $leaseId = null)
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
- if ($startByteOffset % 512 != 0) {
- throw new Microsoft_WindowsAzure_Exception('Start byte offset must be a modulus of 512.');
- }
- if ($endByteOffset > 0 && ($endByteOffset + 1) % 512 != 0) {
- throw new Microsoft_WindowsAzure_Exception('End byte offset must be a modulus of 512 minus 1.');
- }
-
- // Create metadata headers
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
-
- // Specify range?
- if ($endByteOffset > 0) {
- $headers['Range'] = 'bytes=' . $startByteOffset . '-' . $endByteOffset;
- }
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, '?comp=pagelist', Microsoft_Http_Client::GET, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if ($response->isSuccessful()) {
- $result = $this->_parseResponse($response);
- $xmlRanges = null;
- if (count($result->PageRange) > 1) {
- $xmlRanges = $result->PageRange;
- } else {
- $xmlRanges = array($result->PageRange);
- }
-
- $ranges = array();
- for ($i = 0; $i < count($xmlRanges); $i++) {
- $ranges[] = new Microsoft_WindowsAzure_Storage_PageRegionInstance(
- (int)$xmlRanges[$i]->Start,
- (int)$xmlRanges[$i]->End
- );
- }
-
- return $ranges;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Copy blob
- *
- * @param string $sourceContainerName Source container name
- * @param string $sourceBlobName Source blob name
- * @param string $destinationContainerName Destination container name
- * @param string $destinationBlobName Destination blob name
- * @param array $metadata Key/value pairs of meta data
- * @param string $sourceSnapshotId Source snapshot identifier
- * @param string $destinationLeaseId Destination lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd894037.aspx for more information.
- * @return object Partial blob properties
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function copyBlob($sourceContainerName = '', $sourceBlobName = '', $destinationContainerName = '', $destinationBlobName = '', $metadata = array(), $sourceSnapshotId = null, $destinationLeaseId = null, $additionalHeaders = array())
- {
- if ($sourceContainerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Source container name is not specified.');
- }
- if (!self::isValidContainerName($sourceContainerName)) {
- throw new Microsoft_WindowsAzure_Exception('Source container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($sourceBlobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Source blob name is not specified.');
- }
- if ($destinationContainerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Destination container name is not specified.');
- }
- if (!self::isValidContainerName($destinationContainerName)) {
- throw new Microsoft_WindowsAzure_Exception('Destination container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($destinationBlobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Destination blob name is not specified.');
- }
- if ($sourceContainerName === '$root' && strpos($sourceBlobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
- if ($destinationContainerName === '$root' && strpos($destinationBlobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- // Create metadata headers
- $headers = array();
- if (!is_null($destinationLeaseId)) {
- $headers['x-ms-lease-id'] = $destinationLeaseId;
- }
- $headers = array_merge($headers, $this->_generateMetadataHeaders($metadata));
-
- // Additional headers?
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Resource names
- $sourceResourceName = self::createResourceName($sourceContainerName, $sourceBlobName);
- if (!is_null($sourceSnapshotId)) {
- $sourceResourceName .= '?snapshot=' . $sourceSnapshotId;
- }
- $destinationResourceName = self::createResourceName($destinationContainerName, $destinationBlobName);
-
- // Set source blob
- $headers["x-ms-copy-source"] = '/' . $this->_accountName . '/' . $sourceResourceName;
-
- // Perform request
- $response = $this->_performRequest($destinationResourceName, '', Microsoft_Http_Client::PUT, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if ($response->isSuccessful()) {
- return new Microsoft_WindowsAzure_Storage_BlobInstance(
- $destinationContainerName,
- $destinationBlobName,
- null,
- $response->getHeader('Etag'),
- $response->getHeader('Last-modified'),
- $this->getBaseUrl() . '/' . $destinationContainerName . '/' . $destinationBlobName,
- 0,
- '',
- '',
- '',
- false,
- $metadata
- );
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Get blob
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $localFileName Local file name to store downloaded blob
- * @param string $snapshotId Snapshot identifier
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getBlob($containerName = '', $blobName = '', $localFileName = '', $snapshotId = null, $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($localFileName === '') {
- throw new Microsoft_WindowsAzure_Exception('Local file name is not specified.');
- }
-
- // Fetch data
- file_put_contents($localFileName, $this->getBlobData($containerName, $blobName, $snapshotId, $leaseId, $additionalHeaders));
- }
-
- /**
- * Get blob data
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $snapshotId Snapshot identifier
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @return mixed Blob contents
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getBlobData($containerName = '', $blobName = '', $snapshotId = null, $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
-
- // Build query string
- $queryString = array();
- if (!is_null($snapshotId)) {
- $queryString[] = 'snapshot=' . $snapshotId;
- }
- $queryString = self::createQueryStringFromArray($queryString);
-
- // Additional headers?
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, $queryString, Microsoft_Http_Client::GET, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ);
- if ($response->isSuccessful()) {
- return $response->getBody();
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Get blob instance
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $snapshotId Snapshot identifier
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @return Microsoft_WindowsAzure_Storage_BlobInstance
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getBlobInstance($containerName = '', $blobName = '', $snapshotId = null, $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- // Build query string
- $queryString = array();
- if (!is_null($snapshotId)) {
- $queryString[] = 'snapshot=' . $snapshotId;
- }
- $queryString = self::createQueryStringFromArray($queryString);
-
- // Additional headers?
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, $queryString, Microsoft_Http_Client::HEAD, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ);
- if ($response->isSuccessful()) {
- // Parse metadata
- $metadata = $this->_parseMetadataHeaders($response->getHeaders());
-
- // Return blob
- return new Microsoft_WindowsAzure_Storage_BlobInstance(
- $containerName,
- $blobName,
- $snapshotId,
- $response->getHeader('Etag'),
- $response->getHeader('Last-modified'),
- $this->getBaseUrl() . '/' . $containerName . '/' . $blobName,
- $response->getHeader('Content-Length'),
- $response->getHeader('Content-Type'),
- $response->getHeader('Content-Encoding'),
- $response->getHeader('Content-Language'),
- $response->getHeader('Cache-Control'),
- $response->getHeader('x-ms-blob-type'),
- $response->getHeader('x-ms-lease-status'),
- false,
- $metadata
- );
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Get blob metadata
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $snapshotId Snapshot identifier
- * @param string $leaseId Lease identifier
- * @return array Key/value pairs of meta data
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getBlobMetadata($containerName = '', $blobName = '', $snapshotId = null, $leaseId = null)
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- return $this->getBlobInstance($containerName, $blobName, $snapshotId, $leaseId)->Metadata;
- }
-
- /**
- * Set blob metadata
- *
- * Calling the Set Blob Metadata operation overwrites all existing metadata that is associated with the blob. It's not possible to modify an individual name/value pair.
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param array $metadata Key/value pairs of meta data
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function setBlobMetadata($containerName = '', $blobName = '', $metadata = array(), $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
- if (count($metadata) == 0) {
- return;
- }
-
- // Create metadata headers
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
- $headers = array_merge($headers, $this->_generateMetadataHeaders($metadata));
-
- // Additional headers?
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Perform request
- $response = $this->_performRequest($containerName . '/' . $blobName, '?comp=metadata', Microsoft_Http_Client::PUT, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Set blob properties
- *
- * All available properties are listed at http://msdn.microsoft.com/en-us/library/ee691966.aspx and should be provided in the $additionalHeaders parameter.
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function setBlobProperties($containerName = '', $blobName = '', $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
- if (count($additionalHeaders) == 0) {
- throw new Microsoft_WindowsAzure_Exception('No additional headers are specified.');
- }
-
- // Create headers
- $headers = array();
-
- // Lease set?
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
-
- // Additional headers?
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Perform request
- $response = $this->_performRequest($containerName . '/' . $blobName, '?comp=properties', Microsoft_Http_Client::PUT, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Get blob properties
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $snapshotId Snapshot identifier
- * @param string $leaseId Lease identifier
- * @return Microsoft_WindowsAzure_Storage_BlobInstance
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getBlobProperties($containerName = '', $blobName = '', $snapshotId = null, $leaseId = null)
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- return $this->getBlobInstance($containerName, $blobName, $snapshotId, $leaseId);
- }
-
- /**
- * Delete blob
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $snapshotId Snapshot identifier
- * @param string $leaseId Lease identifier
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function deleteBlob($containerName = '', $blobName = '', $snapshotId = null, $leaseId = null, $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- // Build query string
- $queryString = array();
- if (!is_null($snapshotId)) {
- $queryString[] = 'snapshot=' . $snapshotId;
- }
- $queryString = self::createQueryStringFromArray($queryString);
-
- // Additional headers?
- $headers = array();
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, $queryString, Microsoft_Http_Client::DELETE, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Snapshot blob
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param array $metadata Key/value pairs of meta data
- * @param array $additionalHeaders Additional headers. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
- * @return string Date/Time value representing the snapshot identifier.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function snapshotBlob($containerName = '', $blobName = '', $metadata = array(), $additionalHeaders = array())
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- // Additional headers?
- $headers = array();
- foreach ($additionalHeaders as $key => $value) {
- $headers[$key] = $value;
- }
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, '?comp=snapshot', Microsoft_Http_Client::PUT, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if ($response->isSuccessful()) {
- return $response->getHeader('x-ms-snapshot');
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Lease blob - See (http://msdn.microsoft.com/en-us/library/ee691972.aspx)
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $leaseAction Lease action (Microsoft_WindowsAzure_Storage_Blob::LEASE_*)
- * @param string $leaseId Lease identifier, required to renew the lease or to release the lease.
- * @return Microsoft_WindowsAzure_Storage_LeaseInstance Lease instance
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function leaseBlob($containerName = '', $blobName = '', $leaseAction = self::LEASE_ACQUIRE, $leaseId = null)
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
- if ($blobName === '') {
- throw new Microsoft_WindowsAzure_Exception('Blob name is not specified.');
- }
- if ($containerName === '$root' && strpos($blobName, '/') !== false) {
- throw new Microsoft_WindowsAzure_Exception('Blobs stored in the root container can not have a name containing a forward slash (/).');
- }
-
- // Additional headers?
- $headers = array();
- $headers['x-ms-lease-action'] = strtolower($leaseAction);
- if (!is_null($leaseId)) {
- $headers['x-ms-lease-id'] = $leaseId;
- }
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Perform request
- $response = $this->_performRequest($resourceName, '?comp=lease', Microsoft_Http_Client::PUT, $headers, false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_WRITE);
- if ($response->isSuccessful()) {
- return new Microsoft_WindowsAzure_Storage_LeaseInstance(
- $containerName,
- $blobName,
- $response->getHeader('x-ms-lease-id'),
- $response->getHeader('x-ms-lease-time'));
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * List blobs
- *
- * @param string $containerName Container name
- * @param string $prefix Optional. Filters the results to return only blobs whose name begins with the specified prefix.
- * @param string $delimiter Optional. Delimiter, i.e. '/', for specifying folder hierarchy
- * @param int $maxResults Optional. Specifies the maximum number of blobs to return per call to Azure storage. This does NOT affect list size returned by this function. (maximum: 5000)
- * @param string $marker Optional string value that identifies the portion of the list to be returned with the next list operation.
- * @param string $include Optional. Specifies that the response should include one or more of the following subsets: '', 'metadata', 'snapshots', 'uncommittedblobs'). Multiple values can be added separated with a comma (,)
- * @param int $currentResultCount Current result count (internal use)
- * @return array
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function listBlobs($containerName = '', $prefix = '', $delimiter = '', $maxResults = null, $marker = null, $include = null, $currentResultCount = 0)
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
-
- // Build query string
- $queryString = array('restype=container', 'comp=list');
- if (!is_null($prefix)) {
- $queryString[] = 'prefix=' . $prefix;
- }
- if ($delimiter !== '') {
- $queryString[] = 'delimiter=' . $delimiter;
- }
- if (!is_null($maxResults)) {
- $queryString[] = 'maxresults=' . $maxResults;
- }
- if (!is_null($marker)) {
- $queryString[] = 'marker=' . $marker;
- }
- if (!is_null($include)) {
- $queryString[] = 'include=' . $include;
- }
- $queryString = self::createQueryStringFromArray($queryString);
-
- // Perform request
- $response = $this->_performRequest($containerName, $queryString, Microsoft_Http_Client::GET, array(), false, null, Microsoft_WindowsAzure_Storage::RESOURCE_BLOB, Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_LIST);
- if ($response->isSuccessful()) {
- // Return value
- $blobs = array();
-
- // Blobs
- $xmlBlobs = $this->_parseResponse($response)->Blobs->Blob;
- if (!is_null($xmlBlobs)) {
- for ($i = 0; $i < count($xmlBlobs); $i++) {
- $properties = (array)$xmlBlobs[$i]->Properties;
-
- $blobs[] = new Microsoft_WindowsAzure_Storage_BlobInstance(
- $containerName,
- (string)$xmlBlobs[$i]->Name,
- (string)$xmlBlobs[$i]->Snapshot,
- (string)$properties['Etag'],
- (string)$properties['Last-Modified'],
- (string)$xmlBlobs[$i]->Url,
- (string)$properties['Content-Length'],
- (string)$properties['Content-Type'],
- (string)$properties['Content-Encoding'],
- (string)$properties['Content-Language'],
- (string)$properties['Cache-Control'],
- (string)$properties['BlobType'],
- (string)$properties['LeaseStatus'],
- false,
- $this->_parseMetadataElement($xmlBlobs[$i])
- );
- }
- }
-
- // Blob prefixes (folders)
- $xmlBlobs = $this->_parseResponse($response)->Blobs->BlobPrefix;
-
- if (!is_null($xmlBlobs)) {
- for ($i = 0; $i < count($xmlBlobs); $i++) {
- $blobs[] = new Microsoft_WindowsAzure_Storage_BlobInstance(
- $containerName,
- (string)$xmlBlobs[$i]->Name,
- null,
- '',
- '',
- '',
- 0,
- '',
- '',
- '',
- '',
- '',
- '',
- true,
- $this->_parseMetadataElement($xmlBlobs[$i])
- );
- }
- }
-
- // More blobs?
- $xmlMarker = (string)$this->_parseResponse($response)->NextMarker;
- $currentResultCount = $currentResultCount + count($blobs);
- if (!is_null($maxResults) && $currentResultCount < $maxResults) {
- if (!is_null($xmlMarker) && $xmlMarker != '') {
- $blobs = array_merge($blobs, $this->listBlobs($containerName, $prefix, $delimiter, $maxResults, $marker, $include, $currentResultCount));
- }
- }
- if (!is_null($maxResults) && count($blobs) > $maxResults) {
- $blobs = array_slice($blobs, 0, $maxResults);
- }
-
- return $blobs;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Generate shared access URL
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @param string $resource Signed resource - container (c) - blob (b)
- * @param string $permissions Signed permissions - read (r), write (w), delete (d) and list (l)
- * @param string $start The time at which the Shared Access Signature becomes valid.
- * @param string $expiry The time at which the Shared Access Signature becomes invalid.
- * @param string $identifier Signed identifier
- * @return string
- */
- public function generateSharedAccessUrl($containerName = '', $blobName = '', $resource = 'b', $permissions = 'r', $start = '', $expiry = '', $identifier = '')
- {
- if ($containerName === '') {
- throw new Microsoft_WindowsAzure_Exception('Container name is not specified.');
- }
- if (!self::isValidContainerName($containerName)) {
- throw new Microsoft_WindowsAzure_Exception('Container name does not adhere to container naming conventions. See http://msdn.microsoft.com/en-us/library/dd135715.aspx for more information.');
- }
-
- // Resource name
- $resourceName = self::createResourceName($containerName , $blobName);
-
- // Generate URL
- return $this->getBaseUrl() . '/' . $resourceName . '?' .
- $this->_sharedAccessSignatureCredentials->createSignedQueryString(
- $resourceName,
- '',
- $resource,
- $permissions,
- $start,
- $expiry,
- $identifier);
- }
-
- /**
- * Register this object as stream wrapper client
- *
- * @param string $name Protocol name
- * @return Microsoft_WindowsAzure_Storage_Blob
- */
- public function registerAsClient($name)
- {
- self::$_wrapperClients[$name] = $this;
- return $this;
- }
-
- /**
- * Unregister this object as stream wrapper client
- *
- * @param string $name Protocol name
- * @return Microsoft_WindowsAzure_Storage_Blob
- */
- public function unregisterAsClient($name)
- {
- unset(self::$_wrapperClients[$name]);
- return $this;
- }
-
- /**
- * Get wrapper client for stream type
- *
- * @param string $name Protocol name
- * @return Microsoft_WindowsAzure_Storage_Blob
- */
- public static function getWrapperClient($name)
- {
- return self::$_wrapperClients[$name];
- }
-
- /**
- * Register this object as stream wrapper
- *
- * @param string $name Protocol name
- */
- public function registerStreamWrapper($name = 'azure')
- {
- /**
- * @see Microsoft_WindowsAzure_Storage_Blob_Stream
- */
- require_once 'Microsoft/WindowsAzure/Storage/Blob/Stream.php';
-
- stream_register_wrapper($name, 'Microsoft_WindowsAzure_Storage_Blob_Stream');
- $this->registerAsClient($name);
- }
-
- /**
- * Unregister this object as stream wrapper
- *
- * @param string $name Protocol name
- * @return Microsoft_WindowsAzure_Storage_Blob
- */
- public function unregisterStreamWrapper($name = 'azure')
- {
- stream_wrapper_unregister($name);
- $this->unregisterAsClient($name);
- }
-
- /**
- * Create resource name
- *
- * @param string $containerName Container name
- * @param string $blobName Blob name
- * @return string
- */
- public static function createResourceName($containerName = '', $blobName = '')
- {
- // Resource name
- $resourceName = $containerName . '/' . $blobName;
- if ($containerName === '' || $containerName === '$root') {
- $resourceName = $blobName;
- }
- if ($blobName === '') {
- $resourceName = $containerName;
- }
-
- return $resourceName;
- }
-
- /**
- * Is valid container name?
- *
- * @param string $containerName Container name
- * @return boolean
- */
- public static function isValidContainerName($containerName = '')
- {
- if ($containerName == '$root') {
- return true;
- }
-
- if (preg_match("/^[a-z0-9][a-z0-9-]*$/", $containerName) === 0) {
- return false;
- }
-
- if (strpos($containerName, '--') !== false) {
- return false;
- }
-
- if (strtolower($containerName) != $containerName) {
- return false;
- }
-
- if (strlen($containerName) < 3 || strlen($containerName) > 63) {
- return false;
- }
-
- if (substr($containerName, -1) == '-') {
- return false;
- }
-
- return true;
- }
-
- /**
- * Get error message from Microsoft_Http_Response
- *
- * @param Microsoft_Http_Response $response Repsonse
- * @param string $alternativeError Alternative error message
- * @return string
- */
- protected function _getErrorMessage(Microsoft_Http_Response $response, $alternativeError = 'Unknown error.')
- {
- $response = $this->_parseResponse($response);
- if ($response && $response->Message) {
- return (string)$response->Message;
- } else {
- return $alternativeError;
- }
- }
-
- /**
- * Generate block id
- *
- * @param int $part Block number
- * @return string Windows Azure Blob Storage block number
- */
- protected function _generateBlockId($part = 0)
- {
- $returnValue = $part;
- while (strlen($returnValue) < 64) {
- $returnValue = '0' . $returnValue;
- }
-
- return $returnValue;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Blob/Stream.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Blob/Stream.php
deleted file mode 100644
index aeac31a..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Blob/Stream.php
+++ /dev/null
@@ -1,568 +0,0 @@
-_storageClient)) {
- $url = explode(':', $path);
- if (!$url) {
- throw new Microsoft_WindowsAzure_Exception('Could not parse path "' . $path . '".');
- }
-
- $this->_storageClient = Microsoft_WindowsAzure_Storage_Blob::getWrapperClient($url[0]);
- if (!$this->_storageClient) {
- throw new Microsoft_WindowsAzure_Exception('No storage client registered for stream type "' . $url[0] . '://".');
- }
- }
-
- return $this->_storageClient;
- }
-
- /**
- * Extract container name
- *
- * @param string $path
- * @return string
- */
- protected function _getContainerName($path)
- {
- $url = parse_url($path);
- if ($url['host']) {
- return $url['host'];
- }
-
- return '';
- }
-
- /**
- * Extract file name
- *
- * @param string $path
- * @return string
- */
- protected function _getFileName($path)
- {
- $url = parse_url($path);
- if ($url['host']) {
- $fileName = isset($url['path']) ? $url['path'] : $url['host'];
- if (strpos($fileName, '/') === 0) {
- $fileName = substr($fileName, 1);
- }
- return $fileName;
- }
-
- return '';
- }
-
- /**
- * Open the stream
- *
- * @param string $path
- * @param string $mode
- * @param integer $options
- * @param string $opened_path
- * @return boolean
- */
- public function stream_open($path, $mode, $options, &$opened_path)
- {
- $this->_fileName = $path;
- $this->_temporaryFileName = tempnam(sys_get_temp_dir(), 'azure');
-
- // Check the file can be opened
- $fh = @fopen($this->_temporaryFileName, $mode);
- if ($fh === false) {
- return false;
- }
- fclose($fh);
-
- // Write mode?
- if (strpbrk($mode, 'wax+')) {
- $this->_writeMode = true;
- } else {
- $this->_writeMode = false;
- }
-
- // If read/append, fetch the file
- if (!$this->_writeMode || strpbrk($mode, 'ra+')) {
- $this->_getStorageClient($this->_fileName)->getBlob(
- $this->_getContainerName($this->_fileName),
- $this->_getFileName($this->_fileName),
- $this->_temporaryFileName
- );
- }
-
- // Open temporary file handle
- $this->_temporaryFileHandle = fopen($this->_temporaryFileName, $mode);
-
- // Ok!
- return true;
- }
-
- /**
- * Close the stream
- *
- * @return void
- */
- public function stream_close()
- {
- @fclose($this->_temporaryFileHandle);
-
- // Upload the file?
- if ($this->_writeMode) {
- // Make sure the container exists
- $containerExists = $this->_getStorageClient($this->_fileName)->containerExists(
- $this->_getContainerName($this->_fileName)
- );
- if (!$containerExists) {
- $this->_getStorageClient($this->_fileName)->createContainer(
- $this->_getContainerName($this->_fileName)
- );
- }
-
- // Upload the file
- try {
- $this->_getStorageClient($this->_fileName)->putBlob(
- $this->_getContainerName($this->_fileName),
- $this->_getFileName($this->_fileName),
- $this->_temporaryFileName
- );
- } catch (Microsoft_WindowsAzure_Exception $ex) {
- @unlink($this->_temporaryFileName);
- unset($this->_storageClient);
-
- throw $ex;
- }
- }
-
- @unlink($this->_temporaryFileName);
- unset($this->_storageClient);
- }
-
- /**
- * Read from the stream
- *
- * @param integer $count
- * @return string
- */
- public function stream_read($count)
- {
- if (!$this->_temporaryFileHandle) {
- return false;
- }
-
- return fread($this->_temporaryFileHandle, $count);
- }
-
- /**
- * Write to the stream
- *
- * @param string $data
- * @return integer
- */
- public function stream_write($data)
- {
- if (!$this->_temporaryFileHandle) {
- return 0;
- }
-
- $len = strlen($data);
- fwrite($this->_temporaryFileHandle, $data, $len);
- return $len;
- }
-
- /**
- * End of the stream?
- *
- * @return boolean
- */
- public function stream_eof()
- {
- if (!$this->_temporaryFileHandle) {
- return true;
- }
-
- return feof($this->_temporaryFileHandle);
- }
-
- /**
- * What is the current read/write position of the stream?
- *
- * @return integer
- */
- public function stream_tell()
- {
- return ftell($this->_temporaryFileHandle);
- }
-
- /**
- * Update the read/write position of the stream
- *
- * @param integer $offset
- * @param integer $whence
- * @return boolean
- */
- public function stream_seek($offset, $whence)
- {
- if (!$this->_temporaryFileHandle) {
- return false;
- }
-
- return (fseek($this->_temporaryFileHandle, $offset, $whence) === 0);
- }
-
- /**
- * Flush current cached stream data to storage
- *
- * @return boolean
- */
- public function stream_flush()
- {
- $result = fflush($this->_temporaryFileHandle);
-
- // Upload the file?
- if ($this->_writeMode) {
- // Make sure the container exists
- $containerExists = $this->_getStorageClient($this->_fileName)->containerExists(
- $this->_getContainerName($this->_fileName)
- );
- if (!$containerExists) {
- $this->_getStorageClient($this->_fileName)->createContainer(
- $this->_getContainerName($this->_fileName)
- );
- }
-
- // Upload the file
- try {
- $this->_getStorageClient($this->_fileName)->putBlob(
- $this->_getContainerName($this->_fileName),
- $this->_getFileName($this->_fileName),
- $this->_temporaryFileName
- );
- } catch (Microsoft_WindowsAzure_Exception $ex) {
- @unlink($this->_temporaryFileName);
- unset($this->_storageClient);
-
- throw $ex;
- }
- }
-
- return $result;
- }
-
- /**
- * Returns data array of stream variables
- *
- * @return array
- */
- public function stream_stat()
- {
- if (!$this->_temporaryFileHandle) {
- return false;
- }
-
- return $this->url_stat($this->_fileName, 0);
- }
-
- /**
- * Attempt to delete the item
- *
- * @param string $path
- * @return boolean
- */
- public function unlink($path)
- {
- $this->_getStorageClient($path)->deleteBlob(
- $this->_getContainerName($path),
- $this->_getFileName($path)
- );
-
- // Clear the stat cache for this path.
- clearstatcache(true, $path);
- return true;
- }
-
- /**
- * Attempt to rename the item
- *
- * @param string $path_from
- * @param string $path_to
- * @return boolean False
- */
- public function rename($path_from, $path_to)
- {
- if ($this->_getContainerName($path_from) != $this->_getContainerName($path_to)) {
- throw new Microsoft_WindowsAzure_Exception('Container name can not be changed.');
- }
-
- if ($this->_getFileName($path_from) == $this->_getContainerName($path_to)) {
- return true;
- }
-
- $this->_getStorageClient($path_from)->copyBlob(
- $this->_getContainerName($path_from),
- $this->_getFileName($path_from),
- $this->_getContainerName($path_to),
- $this->_getFileName($path_to)
- );
- $this->_getStorageClient($path_from)->deleteBlob(
- $this->_getContainerName($path_from),
- $this->_getFileName($path_from)
- );
-
- // Clear the stat cache for the affected paths.
- clearstatcache(true, $path_from);
- clearstatcache(true, $path_to);
- return true;
- }
-
- /**
- * Return array of URL variables
- *
- * @param string $path
- * @param integer $flags
- * @return array
- */
- public function url_stat($path, $flags)
- {
- $stat = array();
- $stat['dev'] = 0;
- $stat['ino'] = 0;
- $stat['mode'] = 0;
- $stat['nlink'] = 0;
- $stat['uid'] = 0;
- $stat['gid'] = 0;
- $stat['rdev'] = 0;
- $stat['size'] = 0;
- $stat['atime'] = 0;
- $stat['mtime'] = 0;
- $stat['ctime'] = 0;
- $stat['blksize'] = 0;
- $stat['blocks'] = 0;
-
- $info = null;
- try {
- $info = $this->_getStorageClient($path)->getBlobInstance(
- $this->_getContainerName($path),
- $this->_getFileName($path)
- );
- $stat['size'] = $info->Size;
-
- // Set the modification time and last modified to the Last-Modified header.
- $lastmodified = strtotime($info->LastModified);
- $stat['mtime'] = $lastmodified;
- $stat['ctime'] = $lastmodified;
-
- // Entry is a regular file.
- $stat['mode'] = 0100000;
-
- return array_values($stat) + $stat;
- } catch (Microsoft_WindowsAzure_Exception $ex) {
- // Unexisting file...
- return false;
- }
- }
-
- /**
- * Create a new directory
- *
- * @param string $path
- * @param integer $mode
- * @param integer $options
- * @return boolean
- */
- public function mkdir($path, $mode, $options)
- {
- if ($this->_getContainerName($path) == $this->_getFileName($path)) {
- // Create container
- try {
- $this->_getStorageClient($path)->createContainer(
- $this->_getContainerName($path)
- );
- return true;
- } catch (Microsoft_WindowsAzure_Exception $ex) {
- return false;
- }
- } else {
- throw new Microsoft_WindowsAzure_Exception('mkdir() with multiple levels is not supported on Windows Azure Blob Storage.');
- }
- }
-
- /**
- * Remove a directory
- *
- * @param string $path
- * @param integer $options
- * @return boolean
- */
- public function rmdir($path, $options)
- {
- if ($this->_getContainerName($path) == $this->_getFileName($path)) {
- // Clear the stat cache so that affected paths are refreshed.
- clearstatcache();
-
- // Delete container
- try {
- $this->_getStorageClient($path)->deleteContainer(
- $this->_getContainerName($path)
- );
- return true;
- } catch (Microsoft_WindowsAzure_Exception $ex) {
- return false;
- }
- } else {
- throw new Microsoft_WindowsAzure_Exception('rmdir() with multiple levels is not supported on Windows Azure Blob Storage.');
- }
- }
-
- /**
- * Attempt to open a directory
- *
- * @param string $path
- * @param integer $options
- * @return boolean
- */
- public function dir_opendir($path, $options)
- {
- $this->_blobs = $this->_getStorageClient($path)->listBlobs(
- $this->_getContainerName($path)
- );
- return is_array($this->_blobs);
- }
-
- /**
- * Return the next filename in the directory
- *
- * @return string
- */
- public function dir_readdir()
- {
- $object = current($this->_blobs);
- if ($object !== false) {
- next($this->_blobs);
- return $object->Name;
- }
- return false;
- }
-
- /**
- * Reset the directory pointer
- *
- * @return boolean True
- */
- public function dir_rewinddir()
- {
- reset($this->_blobs);
- return true;
- }
-
- /**
- * Close a directory
- *
- * @return boolean True
- */
- public function dir_closedir()
- {
- $this->_blobs = null;
- return true;
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/BlobContainer.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/BlobContainer.php
deleted file mode 100644
index 616aa08..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/BlobContainer.php
+++ /dev/null
@@ -1,112 +0,0 @@
-_data = array(
- 'name' => $name,
- 'etag' => $etag,
- 'lastmodified' => $lastModified,
- 'metadata' => $metadata
- );
- }
-
- /**
- * Magic overload for setting properties
- *
- * @param string $name Name of the property
- * @param string $value Value to set
- */
- public function __set($name, $value) {
- if (array_key_exists(strtolower($name), $this->_data)) {
- $this->_data[strtolower($name)] = $value;
- return;
- }
-
- throw new Exception("Unknown property: " . $name);
- }
-
- /**
- * Magic overload for getting properties
- *
- * @param string $name Name of the property
- */
- public function __get($name) {
- if (array_key_exists(strtolower($name), $this->_data)) {
- return $this->_data[strtolower($name)];
- }
-
- throw new Exception("Unknown property: " . $name);
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/BlobInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/BlobInstance.php
deleted file mode 100644
index 334ba8f..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/BlobInstance.php
+++ /dev/null
@@ -1,111 +0,0 @@
-_data = array(
- 'container' => $containerName,
- 'name' => $name,
- 'snapshotid' => $snapshotId,
- 'etag' => $etag,
- 'lastmodified' => $lastModified,
- 'url' => $url,
- 'size' => $size,
- 'contenttype' => $contentType,
- 'contentencoding' => $contentEncoding,
- 'contentlanguage' => $contentLanguage,
- 'cachecontrol' => $cacheControl,
- 'blobtype' => $blobType,
- 'leasestatus' => $leaseStatus,
- 'isprefix' => $isPrefix,
- 'metadata' => $metadata
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/DynamicTableEntity.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/DynamicTableEntity.php
deleted file mode 100644
index 628ea65..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/DynamicTableEntity.php
+++ /dev/null
@@ -1,218 +0,0 @@
-setAzureProperty($name, $value, null);
- }
-
- /**
- * Magic overload for getting properties
- *
- * @param string $name Name of the property
- */
- public function __get($name) {
- return $this->getAzureProperty($name);
- }
-
- /**
- * Set an Azure property
- *
- * @param string $name Property name
- * @param mixed $value Property value
- * @param string $type Property type (Edm.xxxx)
- * @return Microsoft_WindowsAzure_Storage_DynamicTableEntity
- */
- public function setAzureProperty($name, $value = '', $type = null)
- {
- if (strtolower($name) == 'partitionkey') {
- $this->setPartitionKey($value);
- } else if (strtolower($name) == 'rowkey') {
- $this->setRowKey($value);
- } else if (strtolower($name) == 'etag') {
- $this->setEtag($value);
- } else {
- if (!array_key_exists(strtolower($name), $this->_dynamicProperties)) {
- // Determine type?
- if (is_null($type)) {
- $type = 'Edm.String';
- if (is_int($value)) {
- $type = 'Edm.Int32';
- } else if (is_float($value)) {
- $type = 'Edm.Double';
- } else if (is_bool($value)) {
- $type = 'Edm.Boolean';
- } else if ($value instanceof DateTime || $this->_convertToDateTime($value) !== false) {
- if (!$value instanceof DateTime) {
- $value = $this->_convertToDateTime($value);
- }
- $type = 'Edm.DateTime';
- }
- }
-
- // Set dynamic property
- $this->_dynamicProperties[strtolower($name)] = (object)array(
- 'Name' => $name,
- 'Type' => $type,
- 'Value' => $value,
- );
- }
-
- $this->_dynamicProperties[strtolower($name)]->Value = $value;
- }
- return $this;
- }
-
- /**
- * Set an Azure property type
- *
- * @param string $name Property name
- * @param string $type Property type (Edm.xxxx)
- * @return Microsoft_WindowsAzure_Storage_DynamicTableEntity
- */
- public function setAzurePropertyType($name, $type = 'Edm.String')
- {
- if (!array_key_exists(strtolower($name), $this->_dynamicProperties)) {
- $this->setAzureProperty($name, '', $type);
- } else {
- $this->_dynamicProperties[strtolower($name)]->Type = $type;
- }
- return $this;
- }
-
- /**
- * Get an Azure property
- *
- * @param string $name Property name
- * @param mixed $value Property value
- * @param string $type Property type (Edm.xxxx)
- * @return Microsoft_WindowsAzure_Storage_DynamicTableEntity
- */
- public function getAzureProperty($name)
- {
- if (strtolower($name) == 'partitionkey') {
- return $this->getPartitionKey();
- }
- if (strtolower($name) == 'rowkey') {
- return $this->getRowKey();
- }
- if (strtolower($name) == 'etag') {
- return $this->getEtag();
- }
-
- if (!array_key_exists(strtolower($name), $this->_dynamicProperties)) {
- $this->setAzureProperty($name);
- }
-
- return $this->_dynamicProperties[strtolower($name)]->Value;
- }
-
- /**
- * Get an Azure property type
- *
- * @param string $name Property name
- * @return string Property type (Edm.xxxx)
- */
- public function getAzurePropertyType($name)
- {
- if (!array_key_exists(strtolower($name), $this->_dynamicProperties)) {
- $this->setAzureProperty($name, '', $type);
- }
-
- return $this->_dynamicProperties[strtolower($name)]->Type;
- }
-
- /**
- * Get Azure values
- *
- * @return array
- */
- public function getAzureValues()
- {
- return array_merge(array_values($this->_dynamicProperties), parent::getAzureValues());
- }
-
- /**
- * Set Azure values
- *
- * @param array $values
- * @param boolean $throwOnError Throw Microsoft_WindowsAzure_Exception when a property is not specified in $values?
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function setAzureValues($values = array(), $throwOnError = false)
- {
- // Set parent values
- parent::setAzureValues($values, false);
-
- // Set current values
- foreach ($values as $key => $value)
- {
- $this->$key = $value;
- }
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/LeaseInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/LeaseInstance.php
deleted file mode 100644
index 9bd4467..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/LeaseInstance.php
+++ /dev/null
@@ -1,78 +0,0 @@
-_data = array(
- 'container' => $containerName,
- 'name' => $name,
- 'leaseid' => $leaseId,
- 'leasetime' => $leaseTime
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/PageRegionInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/PageRegionInstance.php
deleted file mode 100644
index dcd48af..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/PageRegionInstance.php
+++ /dev/null
@@ -1,72 +0,0 @@
-_data = array(
- 'start' => $start,
- 'end' => $end
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Queue.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Queue.php
deleted file mode 100644
index e2eb7b6..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Queue.php
+++ /dev/null
@@ -1,594 +0,0 @@
-_apiVersion = '2009-09-19';
- }
-
- /**
- * Check if a queue exists
- *
- * @param string $queueName Queue name
- * @return boolean
- */
- public function queueExists($queueName = '')
- {
- if ($queueName === '') {
- throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
- }
- if (!self::isValidQueueName($queueName)) {
- throw new Microsoft_WindowsAzure_Exception('Queue name does not adhere to queue naming conventions. See http://msdn.microsoft.com/en-us/library/dd179349.aspx for more information.');
- }
-
- // List queues
- $queues = $this->listQueues($queueName, 1);
- foreach ($queues as $queue) {
- if ($queue->Name == $queueName) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Create queue
- *
- * @param string $queueName Queue name
- * @param array $metadata Key/value pairs of meta data
- * @return object Queue properties
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function createQueue($queueName = '', $metadata = array())
- {
- if ($queueName === '') {
- throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
- }
- if (!self::isValidQueueName($queueName)) {
- throw new Microsoft_WindowsAzure_Exception('Queue name does not adhere to queue naming conventions. See http://msdn.microsoft.com/en-us/library/dd179349.aspx for more information.');
- }
-
- // Create metadata headers
- $headers = array();
- $headers = array_merge($headers, $this->_generateMetadataHeaders($metadata));
-
- // Perform request
- $response = $this->_performRequest($queueName, '', Microsoft_Http_Client::PUT, $headers);
- if ($response->isSuccessful()) {
- return new Microsoft_WindowsAzure_Storage_QueueInstance(
- $queueName,
- $metadata
- );
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Create queue if it does not exist
- *
- * @param string $queueName Queue name
- * @param array $metadata Key/value pairs of meta data
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function createQueueIfNotExists($queueName = '', $metadata = array())
- {
- if (!$this->queueExists($queueName)) {
- $this->createQueue($queueName, $metadata);
- }
- }
-
- /**
- * Get queue
- *
- * @param string $queueName Queue name
- * @return Microsoft_WindowsAzure_Storage_QueueInstance
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getQueue($queueName = '')
- {
- if ($queueName === '') {
- throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
- }
- if (!self::isValidQueueName($queueName)) {
- throw new Microsoft_WindowsAzure_Exception('Queue name does not adhere to queue naming conventions. See http://msdn.microsoft.com/en-us/library/dd179349.aspx for more information.');
- }
-
- // Perform request
- $response = $this->_performRequest($queueName, '?comp=metadata', Microsoft_Http_Client::GET);
- if ($response->isSuccessful()) {
- // Parse metadata
- $metadata = $this->_parseMetadataHeaders($response->getHeaders());
-
- // Return queue
- $queue = new Microsoft_WindowsAzure_Storage_QueueInstance(
- $queueName,
- $metadata
- );
- $queue->ApproximateMessageCount = intval($response->getHeader('x-ms-approximate-message-count'));
- return $queue;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Get queue metadata
- *
- * @param string $queueName Queue name
- * @return array Key/value pairs of meta data
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getQueueMetadata($queueName = '')
- {
- if ($queueName === '') {
- throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
- }
- if (!self::isValidQueueName($queueName)) {
- throw new Microsoft_WindowsAzure_Exception('Queue name does not adhere to queue naming conventions. See http://msdn.microsoft.com/en-us/library/dd179349.aspx for more information.');
- }
-
- return $this->getQueue($queueName)->Metadata;
- }
-
- /**
- * Set queue metadata
- *
- * Calling the Set Queue Metadata operation overwrites all existing metadata that is associated with the queue. It's not possible to modify an individual name/value pair.
- *
- * @param string $queueName Queue name
- * @param array $metadata Key/value pairs of meta data
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function setQueueMetadata($queueName = '', $metadata = array())
- {
- if ($queueName === '') {
- throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
- }
- if (!self::isValidQueueName($queueName)) {
- throw new Microsoft_WindowsAzure_Exception('Queue name does not adhere to queue naming conventions. See http://msdn.microsoft.com/en-us/library/dd179349.aspx for more information.');
- }
- if (count($metadata) == 0) {
- return;
- }
-
- // Create metadata headers
- $headers = array();
- $headers = array_merge($headers, $this->_generateMetadataHeaders($metadata));
-
- // Perform request
- $response = $this->_performRequest($queueName, '?comp=metadata', Microsoft_Http_Client::PUT, $headers);
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Delete queue
- *
- * @param string $queueName Queue name
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function deleteQueue($queueName = '')
- {
- if ($queueName === '') {
- throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
- }
- if (!self::isValidQueueName($queueName)) {
- throw new Microsoft_WindowsAzure_Exception('Queue name does not adhere to queue naming conventions. See http://msdn.microsoft.com/en-us/library/dd179349.aspx for more information.');
- }
-
- // Perform request
- $response = $this->_performRequest($queueName, '', Microsoft_Http_Client::DELETE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * List queues
- *
- * @param string $prefix Optional. Filters the results to return only queues whose name begins with the specified prefix.
- * @param int $maxResults Optional. Specifies the maximum number of queues to return per call to Azure storage. This does NOT affect list size returned by this function. (maximum: 5000)
- * @param string $marker Optional string value that identifies the portion of the list to be returned with the next list operation.
- * @param string $include Optional. Include this parameter to specify that the queue's metadata be returned as part of the response body. (allowed values: '', 'metadata')
- * @param int $currentResultCount Current result count (internal use)
- * @return array
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function listQueues($prefix = null, $maxResults = null, $marker = null, $include = null, $currentResultCount = 0)
- {
- // Build query string
- $queryString = array('comp=list');
- if (!is_null($prefix)) {
- $queryString[] = 'prefix=' . $prefix;
- }
- if (!is_null($maxResults)) {
- $queryString[] = 'maxresults=' . $maxResults;
- }
- if (!is_null($marker)) {
- $queryString[] = 'marker=' . $marker;
- }
- if (!is_null($include)) {
- $queryString[] = 'include=' . $include;
- }
- $queryString = self::createQueryStringFromArray($queryString);
-
- // Perform request
- $response = $this->_performRequest('', $queryString, Microsoft_Http_Client::GET);
- if ($response->isSuccessful()) {
- $xmlQueues = $this->_parseResponse($response)->Queues->Queue;
- $xmlMarker = (string)$this->_parseResponse($response)->NextMarker;
-
- $queues = array();
- if (!is_null($xmlQueues)) {
- for ($i = 0; $i < count($xmlQueues); $i++) {
- $queues[] = new Microsoft_WindowsAzure_Storage_QueueInstance(
- (string)$xmlQueues[$i]->Name,
- $this->_parseMetadataElement($xmlQueues[$i])
- );
- }
- }
- $currentResultCount = $currentResultCount + count($queues);
- if (!is_null($maxResults) && $currentResultCount < $maxResults) {
- if (!is_null($xmlMarker) && $xmlMarker != '') {
- $queues = array_merge($queues, $this->listQueues($prefix, $maxResults, $xmlMarker, $include, $currentResultCount));
- }
- }
- if (!is_null($maxResults) && count($queues) > $maxResults) {
- $queues = array_slice($queues, 0, $maxResults);
- }
-
- return $queues;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Put message into queue
- *
- * @param string $queueName Queue name
- * @param string $message Message
- * @param int $ttl Message Time-To-Live (in seconds). Defaults to 7 days if the parameter is omitted.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function putMessage($queueName = '', $message = '', $ttl = null)
- {
- if ($queueName === '') {
- throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
- }
- if (!self::isValidQueueName($queueName)) {
- throw new Microsoft_WindowsAzure_Exception('Queue name does not adhere to queue naming conventions. See http://msdn.microsoft.com/en-us/library/dd179349.aspx for more information.');
- }
- if (strlen($message) > self::MAX_MESSAGE_SIZE) {
- throw new Microsoft_WindowsAzure_Exception('Message is too big. Message content should be < 8KB.');
- }
- if ($message == '') {
- throw new Microsoft_WindowsAzure_Exception('Message is not specified.');
- }
- if (!is_null($ttl) && ($ttl <= 0 || $ttl > self::MAX_MESSAGE_SIZE)) {
- throw new Microsoft_WindowsAzure_Exception('Message TTL is invalid. Maximal TTL is 7 days (' . self::MAX_MESSAGE_SIZE . ' seconds) and should be greater than zero.');
- }
-
- // Build query string
- $queryString = array();
- if (!is_null($ttl)) {
- $queryString[] = 'messagettl=' . $ttl;
- }
- $queryString = self::createQueryStringFromArray($queryString);
-
- // Build body
- $rawData = '';
- $rawData .= '';
- $rawData .= ' ' . base64_encode($message) . '';
- $rawData .= '';
-
- // Perform request
- $response = $this->_performRequest($queueName . '/messages', $queryString, Microsoft_Http_Client::POST, array(), false, $rawData);
-
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception('Error putting message into queue.');
- }
- }
-
- /**
- * Get queue messages
- *
- * @param string $queueName Queue name
- * @param string $numOfMessages Optional. A nonzero integer value that specifies the number of messages to retrieve from the queue, up to a maximum of 32. By default, a single message is retrieved from the queue with this operation.
- * @param int $visibilityTimeout Optional. An integer value that specifies the message's visibility timeout in seconds. The maximum value is 2 hours. The default message visibility timeout is 30 seconds.
- * @param string $peek Peek only?
- * @return array
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function getMessages($queueName = '', $numOfMessages = 1, $visibilityTimeout = null, $peek = false)
- {
- if ($queueName === '') {
- throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
- }
- if (!self::isValidQueueName($queueName)) {
- throw new Microsoft_WindowsAzure_Exception('Queue name does not adhere to queue naming conventions. See http://msdn.microsoft.com/en-us/library/dd179349.aspx for more information.');
- }
- if ($numOfMessages < 1 || $numOfMessages > 32 || intval($numOfMessages) != $numOfMessages) {
- throw new Microsoft_WindowsAzure_Exception('Invalid number of messages to retrieve.');
- }
- if (!is_null($visibilityTimeout) && ($visibilityTimeout <= 0 || $visibilityTimeout > 7200)) {
- throw new Microsoft_WindowsAzure_Exception('Visibility timeout is invalid. Maximum value is 2 hours (7200 seconds) and should be greater than zero.');
- }
-
- // Build query string
- $queryString = array();
- if ($peek) {
- $queryString[] = 'peekonly=true';
- }
- if ($numOfMessages > 1) {
- $queryString[] = 'numofmessages=' . $numOfMessages;
- }
- if (!$peek && !is_null($visibilityTimeout)) {
- $queryString[] = 'visibilitytimeout=' . $visibilityTimeout;
- }
- $queryString = self::createQueryStringFromArray($queryString);
-
- // Perform request
- $response = $this->_performRequest($queueName . '/messages', $queryString, Microsoft_Http_Client::GET);
- if ($response->isSuccessful()) {
- // Parse results
- $result = $this->_parseResponse($response);
- if (!$result) {
- return array();
- }
-
- $xmlMessages = null;
- if (count($result->QueueMessage) > 1) {
- $xmlMessages = $result->QueueMessage;
- } else {
- $xmlMessages = array($result->QueueMessage);
- }
-
- $messages = array();
- for ($i = 0; $i < count($xmlMessages); $i++) {
- $messages[] = new Microsoft_WindowsAzure_Storage_QueueMessage(
- (string)$xmlMessages[$i]->MessageId,
- (string)$xmlMessages[$i]->InsertionTime,
- (string)$xmlMessages[$i]->ExpirationTime,
- ($peek ? '' : (string)$xmlMessages[$i]->PopReceipt),
- ($peek ? '' : (string)$xmlMessages[$i]->TimeNextVisible),
- (string)$xmlMessages[$i]->DequeueCount,
- base64_decode((string)$xmlMessages[$i]->MessageText)
- );
- }
-
- return $messages;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Peek queue messages
- *
- * @param string $queueName Queue name
- * @param string $numOfMessages Optional. A nonzero integer value that specifies the number of messages to retrieve from the queue, up to a maximum of 32. By default, a single message is retrieved from the queue with this operation.
- * @return array
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function peekMessages($queueName = '', $numOfMessages = 1)
- {
- return $this->getMessages($queueName, $numOfMessages, null, true);
- }
-
- /**
- * Checks to see if a given queue has messages
- *
- * @param string $queueName Queue name
- * @return boolean
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function hasMessages($queueName = '')
- {
- return count($this->peekMessages($queueName)) > 0;
- }
-
- /**
- * Clear queue messages
- *
- * @param string $queueName Queue name
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function clearMessages($queueName = '')
- {
- if ($queueName === '') {
- throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
- }
- if (!self::isValidQueueName($queueName)) {
- throw new Microsoft_WindowsAzure_Exception('Queue name does not adhere to queue naming conventions. See http://msdn.microsoft.com/en-us/library/dd179349.aspx for more information.');
- }
-
- // Perform request
- $response = $this->_performRequest($queueName . '/messages', '', Microsoft_Http_Client::DELETE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception('Error clearing messages from queue.');
- }
- }
-
- /**
- * Delete queue message
- *
- * @param string $queueName Queue name
- * @param Microsoft_WindowsAzure_Storage_QueueMessage $message Message to delete from queue. A message retrieved using "peekMessages" can NOT be deleted!
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function deleteMessage($queueName = '', Microsoft_WindowsAzure_Storage_QueueMessage $message)
- {
- if ($queueName === '') {
- throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
- }
- if (!self::isValidQueueName($queueName)) {
- throw new Microsoft_WindowsAzure_Exception('Queue name does not adhere to queue naming conventions. See http://msdn.microsoft.com/en-us/library/dd179349.aspx for more information.');
- }
- if ($message->PopReceipt == '') {
- throw new Microsoft_WindowsAzure_Exception('A message retrieved using "peekMessages" can NOT be deleted! Use "getMessages" instead.');
- }
-
- // Perform request
- $response = $this->_performRequest($queueName . '/messages/' . $message->MessageId, '?popreceipt=' . $message->PopReceipt, Microsoft_Http_Client::DELETE);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Is valid queue name?
- *
- * @param string $queueName Queue name
- * @return boolean
- */
- public static function isValidQueueName($queueName = '')
- {
- if (preg_match("/^[a-z0-9][a-z0-9-]*$/", $queueName) === 0) {
- return false;
- }
-
- if (strpos($queueName, '--') !== false) {
- return false;
- }
-
- if (strtolower($queueName) != $queueName) {
- return false;
- }
-
- if (strlen($queueName) < 3 || strlen($queueName) > 63) {
- return false;
- }
-
- if (substr($queueName, -1) == '-') {
- return false;
- }
-
- return true;
- }
-
- /**
- * Get error message from Microsoft_Http_Response
- *
- * @param Microsoft_Http_Response $response Repsonse
- * @param string $alternativeError Alternative error message
- * @return string
- */
- protected function _getErrorMessage(Microsoft_Http_Response $response, $alternativeError = 'Unknown error.')
- {
- $response = $this->_parseResponse($response);
- if ($response && $response->Message) {
- return (string)$response->Message;
- } else {
- return $alternativeError;
- }
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/QueueInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/QueueInstance.php
deleted file mode 100644
index 3d01ff7..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/QueueInstance.php
+++ /dev/null
@@ -1,74 +0,0 @@
-_data = array(
- 'name' => $name,
- 'metadata' => $metadata,
- 'approximatemessagecount' => 0
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/QueueMessage.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/QueueMessage.php
deleted file mode 100644
index bf73b8b..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/QueueMessage.php
+++ /dev/null
@@ -1,87 +0,0 @@
-_data = array(
- 'messageid' => $messageId,
- 'insertiontime' => $insertionTime,
- 'expirationtime' => $expirationTime,
- 'popreceipt' => $popReceipt,
- 'timenextvisible' => $timeNextVisible,
- 'dequeuecount' => $dequeueCount,
- 'messagetext' => $messageText
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/SignedIdentifier.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/SignedIdentifier.php
deleted file mode 100644
index f81703f..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/SignedIdentifier.php
+++ /dev/null
@@ -1,78 +0,0 @@
-_data = array(
- 'id' => $id,
- 'start' => $start,
- 'expiry' => $expiry,
- 'permissions' => $permissions
- );
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/StorageEntityAbstract.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/StorageEntityAbstract.php
deleted file mode 100644
index 357929f..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/StorageEntityAbstract.php
+++ /dev/null
@@ -1,86 +0,0 @@
-_data)) {
- $this->_data[strtolower($name)] = $value;
- return;
- }
-
- throw new Microsoft_WindowsAzure_Exception("Unknown property: " . $name);
- }
-
- /**
- * Magic overload for getting properties
- *
- * @param string $name Name of the property
- */
- public function __get($name) {
- if (array_key_exists(strtolower($name), $this->_data)) {
- return $this->_data[strtolower($name)];
- }
-
- throw new Microsoft_WindowsAzure_Exception("Unknown property: " . $name);
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Table.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Table.php
deleted file mode 100644
index e5d52a3..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/Table.php
+++ /dev/null
@@ -1,959 +0,0 @@
-_throwExceptionOnMissingData = $value;
- }
-
- /**
- * Throw Microsoft_WindowsAzure_Exception when a property is not specified in Windows Azure?
- */
- public function getThrowExceptionOnMissingData()
- {
- return $this->_throwExceptionOnMissingData;
- }
-
- /**
- * Creates a new Microsoft_WindowsAzure_Storage_Table instance
- *
- * @param string $host Storage host name
- * @param string $accountName Account name for Windows Azure
- * @param string $accountKey Account key for Windows Azure
- * @param boolean $usePathStyleUri Use path-style URI's
- * @param Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
- */
- public function __construct($host = Microsoft_WindowsAzure_Storage::URL_DEV_TABLE, $accountName = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_ACCOUNT, $accountKey = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_KEY, $usePathStyleUri = false, Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy = null)
- {
- parent::__construct($host, $accountName, $accountKey, $usePathStyleUri, $retryPolicy);
-
- // Always use SharedKeyLite authentication
- $this->_credentials = new Microsoft_WindowsAzure_Credentials_SharedKeyLite($accountName, $accountKey, $this->_usePathStyleUri);
-
- // API version
- $this->_apiVersion = '2009-09-19';
- }
-
- /**
- * Check if a table exists
- *
- * @param string $tableName Table name
- * @return boolean
- */
- public function tableExists($tableName = '')
- {
- if ($tableName === '') {
- throw new Microsoft_WindowsAzure_Exception('Table name is not specified.');
- }
-
- // List tables
- $tables = $this->listTables(); // 2009-09-19 does not support $this->listTables($tableName); all of a sudden...
- foreach ($tables as $table) {
- if ($table->Name == $tableName) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * List tables
- *
- * @param string $nextTableName Next table name, used for listing tables when total amount of tables is > 1000.
- * @return array
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function listTables($nextTableName = '')
- {
- // Build query string
- $queryString = array();
- if ($nextTableName != '') {
- $queryString[] = 'NextTableName=' . $nextTableName;
- }
- $queryString = self::createQueryStringFromArray($queryString);
-
- // Perform request
- $response = $this->_performRequest('Tables', $queryString, Microsoft_Http_Client::GET, null, true);
- if ($response->isSuccessful()) {
- // Parse result
- $result = $this->_parseResponse($response);
-
- if (!$result || !$result->entry) {
- return array();
- }
-
- $entries = null;
- if (count($result->entry) > 1) {
- $entries = $result->entry;
- } else {
- $entries = array($result->entry);
- }
-
- // Create return value
- $returnValue = array();
- foreach ($entries as $entry) {
- $tableName = $entry->xpath('.//m:properties/d:TableName');
- $tableName = (string)$tableName[0];
-
- $returnValue[] = new Microsoft_WindowsAzure_Storage_TableInstance(
- (string)$entry->id,
- $tableName,
- (string)$entry->link['href'],
- (string)$entry->updated
- );
- }
-
- // More tables?
- if (!is_null($response->getHeader('x-ms-continuation-NextTableName'))) {
- $returnValue = array_merge($returnValue, $this->listTables($response->getHeader('x-ms-continuation-NextTableName')));
- }
-
- return $returnValue;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Create table
- *
- * @param string $tableName Table name
- * @return Microsoft_WindowsAzure_Storage_TableInstance
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function createTable($tableName = '')
- {
- if ($tableName === '') {
- throw new Microsoft_WindowsAzure_Exception('Table name is not specified.');
- }
-
- // Generate request body
- $requestBody = '
-
-
- {tpl:Updated}
-
-
-
-
-
-
- {tpl:TableName}
-
-
- ';
-
- $requestBody = $this->_fillTemplate($requestBody, array(
- 'BaseUrl' => $this->getBaseUrl(),
- 'TableName' => htmlspecialchars($tableName),
- 'Updated' => $this->isoDate(),
- 'AccountName' => $this->_accountName
- ));
-
- // Add header information
- $headers = array();
- $headers['Content-Type'] = 'application/atom+xml';
- $headers['DataServiceVersion'] = '1.0;NetFx';
- $headers['MaxDataServiceVersion'] = '1.0;NetFx';
-
- // Perform request
- $response = $this->_performRequest('Tables', '', Microsoft_Http_Client::POST, $headers, true, $requestBody);
- if ($response->isSuccessful()) {
- // Parse response
- $entry = $this->_parseResponse($response);
-
- $tableName = $entry->xpath('.//m:properties/d:TableName');
- $tableName = (string)$tableName[0];
-
- return new Microsoft_WindowsAzure_Storage_TableInstance(
- (string)$entry->id,
- $tableName,
- (string)$entry->link['href'],
- (string)$entry->updated
- );
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Create table if it does not exist
- *
- * @param string $tableName Table name
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function createTableIfNotExists($tableName = '')
- {
- if (!$this->tableExists($tableName)) {
- $this->createTable($tableName);
- }
- }
-
- /**
- * Delete table
- *
- * @param string $tableName Table name
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function deleteTable($tableName = '')
- {
- if ($tableName === '') {
- throw new Microsoft_WindowsAzure_Exception('Table name is not specified.');
- }
-
- // Add header information
- $headers = array();
- $headers['Content-Type'] = 'application/atom+xml';
-
- // Perform request
- $response = $this->_performRequest('Tables(\'' . $tableName . '\')', '', Microsoft_Http_Client::DELETE, $headers, true, null);
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Insert entity into table
- *
- * @param string $tableName Table name
- * @param Microsoft_WindowsAzure_Storage_TableEntity $entity Entity to insert
- * @return Microsoft_WindowsAzure_Storage_TableEntity
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function insertEntity($tableName = '', Microsoft_WindowsAzure_Storage_TableEntity $entity = null)
- {
- if ($tableName === '') {
- throw new Microsoft_WindowsAzure_Exception('Table name is not specified.');
- }
- if (is_null($entity)) {
- throw new Microsoft_WindowsAzure_Exception('Entity is not specified.');
- }
-
- // Generate request body
- $requestBody = '
-
-
- {tpl:Updated}
-
-
-
-
-
-
- {tpl:Properties}
-
-
- ';
-
- $requestBody = $this->_fillTemplate($requestBody, array(
- 'Updated' => $this->isoDate(),
- 'Properties' => $this->_generateAzureRepresentation($entity)
- ));
-
- // Add header information
- $headers = array();
- $headers['Content-Type'] = 'application/atom+xml';
-
- // Perform request
- $response = null;
- if ($this->isInBatch()) {
- $this->getCurrentBatch()->enlistOperation($tableName, '', Microsoft_Http_Client::POST, $headers, true, $requestBody);
- return null;
- } else {
- $response = $this->_performRequest($tableName, '', Microsoft_Http_Client::POST, $headers, true, $requestBody);
- }
- if ($response->isSuccessful()) {
- // Parse result
- $result = $this->_parseResponse($response);
-
- $timestamp = $result->xpath('//m:properties/d:Timestamp');
- $timestamp = $this->_convertToDateTime( (string)$timestamp[0] );
-
- $etag = $result->attributes('http://schemas.microsoft.com/ado/2007/08/dataservices/metadata');
- $etag = (string)$etag['etag'];
-
- // Update properties
- $entity->setTimestamp($timestamp);
- $entity->setEtag($etag);
-
- return $entity;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Delete entity from table
- *
- * @param string $tableName Table name
- * @param Microsoft_WindowsAzure_Storage_TableEntity $entity Entity to delete
- * @param boolean $verifyEtag Verify etag of the entity (used for concurrency)
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function deleteEntity($tableName = '', Microsoft_WindowsAzure_Storage_TableEntity $entity = null, $verifyEtag = false)
- {
- if ($tableName === '') {
- throw new Microsoft_WindowsAzure_Exception('Table name is not specified.');
- }
- if (is_null($entity)) {
- throw new Microsoft_WindowsAzure_Exception('Entity is not specified.');
- }
-
- // Add header information
- $headers = array();
- if (!$this->isInBatch()) {
- // http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/9e255447-4dc7-458a-99d3-bdc04bdc5474/
- $headers['Content-Type'] = 'application/atom+xml';
- }
- $headers['Content-Length'] = 0;
- if (!$verifyEtag) {
- $headers['If-Match'] = '*';
- } else {
- $headers['If-Match'] = $entity->getEtag();
- }
-
- // Perform request
- $response = null;
- if ($this->isInBatch()) {
- $this->getCurrentBatch()->enlistOperation($tableName . '(PartitionKey=\'' . $entity->getPartitionKey() . '\', RowKey=\'' . $entity->getRowKey() . '\')', '', Microsoft_Http_Client::DELETE, $headers, true, null);
- return null;
- } else {
- $response = $this->_performRequest($tableName . '(PartitionKey=\'' . $entity->getPartitionKey() . '\', RowKey=\'' . $entity->getRowKey() . '\')', '', Microsoft_Http_Client::DELETE, $headers, true, null);
- }
- if (!$response->isSuccessful()) {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Retrieve entity from table, by id
- *
- * @param string $tableName Table name
- * @param string $partitionKey Partition key
- * @param string $rowKey Row key
- * @param string $entityClass Entity class name*
- * @return Microsoft_WindowsAzure_Storage_TableEntity
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function retrieveEntityById($tableName, $partitionKey, $rowKey, $entityClass = 'Microsoft_WindowsAzure_Storage_DynamicTableEntity')
- {
- if (is_null($tableName) || $tableName === '') {
- throw new Microsoft_WindowsAzure_Exception('Table name is not specified.');
- }
- if (is_null($partitionKey) || $partitionKey === '') {
- throw new Microsoft_WindowsAzure_Exception('Partition key is not specified.');
- }
- if (is_null($rowKey) || $rowKey === '') {
- throw new Microsoft_WindowsAzure_Exception('Row key is not specified.');
- }
- if (is_null($entityClass) || $entityClass === '') {
- throw new Microsoft_WindowsAzure_Exception('Entity class is not specified.');
- }
-
-
- // Check for combined size of partition key and row key
- // http://msdn.microsoft.com/en-us/library/dd179421.aspx
- if (strlen($partitionKey . $rowKey) >= 256) {
- // Start a batch if possible
- if ($this->isInBatch()) {
- throw new Microsoft_WindowsAzure_Exception('Entity cannot be retrieved. A transaction is required to retrieve the entity, but another transaction is already active.');
- }
-
- $this->startBatch();
- }
-
- // Fetch entities from Azure
- $result = $this->retrieveEntities(
- $this->select()
- ->from($tableName)
- ->wherePartitionKey($partitionKey)
- ->whereRowKey($rowKey),
- '',
- $entityClass
- );
-
- // Return
- if (count($result) == 1) {
- return $result[0];
- }
-
- return null;
- }
-
- /**
- * Create a new Microsoft_WindowsAzure_Storage_TableEntityQuery
- *
- * @return Microsoft_WindowsAzure_Storage_TableEntityQuery
- */
- public function select()
- {
- return new Microsoft_WindowsAzure_Storage_TableEntityQuery();
- }
-
- /**
- * Retrieve entities from table
- *
- * @param string $tableName|Microsoft_WindowsAzure_Storage_TableEntityQuery Table name -or- Microsoft_WindowsAzure_Storage_TableEntityQuery instance
- * @param string $filter Filter condition (not applied when $tableName is a Microsoft_WindowsAzure_Storage_TableEntityQuery instance)
- * @param string $entityClass Entity class name
- * @param string $nextPartitionKey Next partition key, used for listing entities when total amount of entities is > 1000.
- * @param string $nextRowKey Next row key, used for listing entities when total amount of entities is > 1000.
- * @return array Array of Microsoft_WindowsAzure_Storage_TableEntity
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function retrieveEntities($tableName = '', $filter = '', $entityClass = 'Microsoft_WindowsAzure_Storage_DynamicTableEntity', $nextPartitionKey = null, $nextRowKey = null)
- {
- if ($tableName === '') {
- throw new Microsoft_WindowsAzure_Exception('Table name is not specified.');
- }
- if ($entityClass === '') {
- throw new Microsoft_WindowsAzure_Exception('Entity class is not specified.');
- }
-
- // Convenience...
- if (class_exists($filter)) {
- $entityClass = $filter;
- $filter = '';
- }
-
- // Query string
- $queryString = '';
-
- // Determine query
- if (is_string($tableName)) {
- // Option 1: $tableName is a string
-
- // Append parentheses
- if (strpos($tableName, '()') === false) {
- $tableName .= '()';
- }
-
- // Build query
- $query = array();
-
- // Filter?
- if ($filter !== '') {
- $query[] = '$filter=' . Microsoft_WindowsAzure_Storage_TableEntityQuery::encodeQuery($filter);
- }
-
- // Build queryString
- if (count($query) > 0) {
- $queryString = '?' . implode('&', $query);
- }
- } else if (get_class($tableName) == 'Microsoft_WindowsAzure_Storage_TableEntityQuery') {
- // Option 2: $tableName is a Microsoft_WindowsAzure_Storage_TableEntityQuery instance
-
- // Build queryString
- $queryString = $tableName->assembleQueryString(true);
-
- // Change $tableName
- $tableName = $tableName->assembleFrom(true);
- } else {
- throw new Microsoft_WindowsAzure_Exception('Invalid argument: $tableName');
- }
-
- // Add continuation querystring parameters?
- if (!is_null($nextPartitionKey) && !is_null($nextRowKey)) {
- if ($queryString !== '') {
- $queryString .= '&';
- } else {
- $queryString .= '?';
- }
-
- $queryString .= 'NextPartitionKey=' . rawurlencode($nextPartitionKey) . '&NextRowKey=' . rawurlencode($nextRowKey);
- }
-
- // Perform request
- $response = null;
- if ($this->isInBatch() && $this->getCurrentBatch()->getOperationCount() == 0) {
- $this->getCurrentBatch()->enlistOperation($tableName, $queryString, Microsoft_Http_Client::GET, array(), true, null);
- $response = $this->getCurrentBatch()->commit();
-
- // Get inner response (multipart)
- $innerResponse = $response->getBody();
- $innerResponse = substr($innerResponse, strpos($innerResponse, 'HTTP/1.1 200 OK'));
- $innerResponse = substr($innerResponse, 0, strpos($innerResponse, '--batchresponse'));
- $response = Microsoft_Http_Response::fromString($innerResponse);
- } else {
- $response = $this->_performRequest($tableName, $queryString, Microsoft_Http_Client::GET, array(), true, null);
- }
-
- if ($response->isSuccessful()) {
- // Parse result
- $result = $this->_parseResponse($response);
- if (!$result) {
- return array();
- }
-
- $entries = null;
- if ($result->entry) {
- if (count($result->entry) > 1) {
- $entries = $result->entry;
- } else {
- $entries = array($result->entry);
- }
- } else {
- // This one is tricky... If we have properties defined, we have an entity.
- $properties = $result->xpath('//m:properties');
- if ($properties) {
- $entries = array($result);
- } else {
- return array();
- }
- }
-
- // Create return value
- $returnValue = array();
- foreach ($entries as $entry) {
- // Parse properties
- $properties = $entry->xpath('.//m:properties');
- $properties = $properties[0]->children('http://schemas.microsoft.com/ado/2007/08/dataservices');
-
- // Create entity
- $entity = new $entityClass('', '');
- $entity->setAzureValues((array)$properties, $this->_throwExceptionOnMissingData);
-
- // If we have a Microsoft_WindowsAzure_Storage_DynamicTableEntity, make sure all property types are OK
- if ($entity instanceof Microsoft_WindowsAzure_Storage_DynamicTableEntity) {
- foreach ($properties as $key => $value) {
- $attributes = $value->attributes('http://schemas.microsoft.com/ado/2007/08/dataservices/metadata');
- $type = (string)$attributes['type'];
- if ($type !== '') {
- $entity->setAzurePropertyType($key, $type);
- }
- }
- }
-
- // Update etag
- $etag = $entry->attributes('http://schemas.microsoft.com/ado/2007/08/dataservices/metadata');
- $etag = (string)$etag['etag'];
- $entity->setEtag($etag);
-
- // Add to result
- $returnValue[] = $entity;
- }
-
- // More entities?
- if (!is_null($response->getHeader('x-ms-continuation-NextPartitionKey')) && !is_null($response->getHeader('x-ms-continuation-NextRowKey'))) {
- if (strpos($queryString, '$top') === false) {
- $returnValue = array_merge($returnValue, $this->retrieveEntities($tableName, $filter, $entityClass, $response->getHeader('x-ms-continuation-NextPartitionKey'), $response->getHeader('x-ms-continuation-NextRowKey')));
- }
- }
-
- // Return
- return $returnValue;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Update entity by replacing it
- *
- * @param string $tableName Table name
- * @param Microsoft_WindowsAzure_Storage_TableEntity $entity Entity to update
- * @param boolean $verifyEtag Verify etag of the entity (used for concurrency)
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function updateEntity($tableName = '', Microsoft_WindowsAzure_Storage_TableEntity $entity = null, $verifyEtag = false)
- {
- return $this->_changeEntity(Microsoft_Http_Client::PUT, $tableName, $entity, $verifyEtag);
- }
-
- /**
- * Update entity by adding or updating properties
- *
- * @param string $tableName Table name
- * @param Microsoft_WindowsAzure_Storage_TableEntity $entity Entity to update
- * @param boolean $verifyEtag Verify etag of the entity (used for concurrency)
- * @param array $properties Properties to merge. All properties will be used when omitted.
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function mergeEntity($tableName = '', Microsoft_WindowsAzure_Storage_TableEntity $entity = null, $verifyEtag = false, $properties = array())
- {
- $mergeEntity = null;
- if (is_array($properties) && count($properties) > 0) {
- // Build a new object
- $mergeEntity = new Microsoft_WindowsAzure_Storage_DynamicTableEntity($entity->getPartitionKey(), $entity->getRowKey());
-
- // Keep only values mentioned in $properties
- $azureValues = $entity->getAzureValues();
- foreach ($azureValues as $key => $value) {
- if (in_array($value->Name, $properties)) {
- $mergeEntity->setAzureProperty($value->Name, $value->Value, $value->Type);
- }
- }
- } else {
- $mergeEntity = $entity;
- }
-
- // Ensure entity timestamp matches updated timestamp
- $entity->setTimestamp(new DateTime());
-
- return $this->_changeEntity(Microsoft_Http_Client::MERGE, $tableName, $mergeEntity, $verifyEtag);
- }
-
- /**
- * Get error message from Microsoft_Http_Response
- *
- * @param Microsoft_Http_Response $response Repsonse
- * @param string $alternativeError Alternative error message
- * @return string
- */
- protected function _getErrorMessage(Microsoft_Http_Response $response, $alternativeError = 'Unknown error.')
- {
- $response = $this->_parseResponse($response);
- if ($response && $response->message) {
- return (string)$response->message;
- } else {
- return $alternativeError;
- }
- }
-
- /**
- * Update entity / merge entity
- *
- * @param string $httpVerb HTTP verb to use (PUT = update, MERGE = merge)
- * @param string $tableName Table name
- * @param Microsoft_WindowsAzure_Storage_TableEntity $entity Entity to update
- * @param boolean $verifyEtag Verify etag of the entity (used for concurrency)
- * @throws Microsoft_WindowsAzure_Exception
- */
- protected function _changeEntity($httpVerb = Microsoft_Http_Client::PUT, $tableName = '', Microsoft_WindowsAzure_Storage_TableEntity $entity = null, $verifyEtag = false)
- {
- if ($tableName === '') {
- throw new Microsoft_WindowsAzure_Exception('Table name is not specified.');
- }
- if (is_null($entity)) {
- throw new Microsoft_WindowsAzure_Exception('Entity is not specified.');
- }
-
- // Add header information
- $headers = array();
- $headers['Content-Type'] = 'application/atom+xml';
- $headers['Content-Length'] = 0;
- if (!$verifyEtag) {
- $headers['If-Match'] = '*';
- } else {
- $headers['If-Match'] = $entity->getEtag();
- }
-
- // Generate request body
- $requestBody = '
-
-
- {tpl:Updated}
-
-
-
-
-
-
- {tpl:Properties}
-
-
- ';
-
- // Attempt to get timestamp from entity
- $timestamp = $entity->getTimestamp();
-
- $requestBody = $this->_fillTemplate($requestBody, array(
- 'Updated' => $this->_convertToEdmDateTime($timestamp),
- 'Properties' => $this->_generateAzureRepresentation($entity)
- ));
-
- // Add header information
- $headers = array();
- $headers['Content-Type'] = 'application/atom+xml';
- if (!$verifyEtag) {
- $headers['If-Match'] = '*';
- } else {
- $headers['If-Match'] = $entity->getEtag();
- }
-
- // Perform request
- $response = null;
- if ($this->isInBatch()) {
- $this->getCurrentBatch()->enlistOperation($tableName . '(PartitionKey=\'' . $entity->getPartitionKey() . '\', RowKey=\'' . $entity->getRowKey() . '\')', '', $httpVerb, $headers, true, $requestBody);
- return null;
- } else {
- $response = $this->_performRequest($tableName . '(PartitionKey=\'' . $entity->getPartitionKey() . '\', RowKey=\'' . $entity->getRowKey() . '\')', '', $httpVerb, $headers, true, $requestBody);
- }
- if ($response->isSuccessful()) {
- // Update properties
- $entity->setEtag($response->getHeader('Etag'));
- $entity->setTimestamp( $this->_convertToDateTime($response->getHeader('Last-modified')) );
-
- return $entity;
- } else {
- throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response, 'Resource could not be accessed.'));
- }
- }
-
- /**
- * Generate RFC 1123 compliant date string
- *
- * @return string
- */
- protected function _rfcDate()
- {
- return gmdate('D, d M Y H:i:s', time()) . ' GMT'; // RFC 1123
- }
-
- /**
- * Fill text template with variables from key/value array
- *
- * @param string $templateText Template text
- * @param array $variables Array containing key/value pairs
- * @return string
- */
- protected function _fillTemplate($templateText, $variables = array())
- {
- foreach ($variables as $key => $value) {
- $templateText = str_replace('{tpl:' . $key . '}', $value, $templateText);
- }
- return $templateText;
- }
-
- /**
- * Generate Azure representation from entity (creates atompub markup from properties)
- *
- * @param Microsoft_WindowsAzure_Storage_TableEntity $entity
- * @return string
- */
- protected function _generateAzureRepresentation(Microsoft_WindowsAzure_Storage_TableEntity $entity = null)
- {
- // Generate Azure representation from entity
- $azureRepresentation = array();
- $azureValues = $entity->getAzureValues();
- foreach ($azureValues as $azureValue) {
- $value = array();
- $value[] = 'Name;
- if ($azureValue->Type != '') {
- $value[] = ' m:type="' . $azureValue->Type . '"';
- }
- if (is_null($azureValue->Value)) {
- $value[] = ' m:null="true"';
- }
- $value[] = '>';
-
- if (!is_null($azureValue->Value)) {
- if (strtolower($azureValue->Type) == 'edm.boolean') {
- $value[] = ($azureValue->Value == true ? '1' : '0');
- } else if (strtolower($azureValue->Type) == 'edm.datetime') {
- $value[] = $this->_convertToEdmDateTime($azureValue->Value);
- } else {
- $value[] = htmlspecialchars($azureValue->Value);
- }
- }
-
- $value[] = 'Name . '>';
- $azureRepresentation[] = implode('', $value);
- }
-
- return implode('', $azureRepresentation);
- }
-
- /**
- * Perform request using Microsoft_Http_Client channel
- *
- * @param string $path Path
- * @param string $queryString Query string
- * @param string $httpVerb HTTP verb the request will use
- * @param array $headers x-ms headers to add
- * @param boolean $forTableStorage Is the request for table storage?
- * @param mixed $rawData Optional RAW HTTP data to be sent over the wire
- * @param string $resourceType Resource type
- * @param string $requiredPermission Required permission
- * @return Microsoft_Http_Response
- */
- protected function _performRequest(
- $path = '/',
- $queryString = '',
- $httpVerb = Microsoft_Http_Client::GET,
- $headers = array(),
- $forTableStorage = false,
- $rawData = null,
- $resourceType = Microsoft_WindowsAzure_Storage::RESOURCE_UNKNOWN,
- $requiredPermission = Microsoft_WindowsAzure_Credentials_CredentialsAbstract::PERMISSION_READ
- ) {
- // Add headers
- $headers['DataServiceVersion'] = '1.0;NetFx';
- $headers['MaxDataServiceVersion'] = '1.0;NetFx';
-
- // Perform request
- return parent::_performRequest(
- $path,
- $queryString,
- $httpVerb,
- $headers,
- $forTableStorage,
- $rawData,
- $resourceType,
- $requiredPermission
- );
- }
-
- /**
- * Converts a string to a DateTime object. Returns false on failure.
- *
- * @param string $value The string value to parse
- * @return DateTime|boolean
- */
- protected function _convertToDateTime($value = '')
- {
- if ($value instanceof DateTime) {
- return $value;
- }
-
- try {
- if (substr($value, -1) == 'Z') {
- $value = substr($value, 0, strlen($value) - 1);
- }
- return new DateTime($value, new DateTimeZone('UTC'));
- }
- catch (Exception $ex) {
- return false;
- }
- }
-
- /**
- * Converts a DateTime object into an Edm.DaeTime value in UTC timezone,
- * represented as a string.
- *
- * @param DateTime $value
- * @return string
- */
- protected function _convertToEdmDateTime(DateTime $value)
- {
- $cloned = clone $value;
- $cloned->setTimezone(new DateTimeZone('UTC'));
- return str_replace('+0000', 'Z', $cloned->format(DateTime::ISO8601));
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/TableEntity.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/TableEntity.php
deleted file mode 100644
index 24c335d..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/TableEntity.php
+++ /dev/null
@@ -1,364 +0,0 @@
-_partitionKey = $partitionKey;
- $this->_rowKey = $rowKey;
- }
-
- /**
- * Get partition key
- *
- * @azure PartitionKey
- * @return string
- */
- public function getPartitionKey()
- {
- return $this->_partitionKey;
- }
-
- /**
- * Set partition key
- *
- * @azure PartitionKey
- * @param string $value
- */
- public function setPartitionKey($value)
- {
- $this->_partitionKey = $value;
- }
-
- /**
- * Get row key
- *
- * @azure RowKey
- * @return string
- */
- public function getRowKey()
- {
- return $this->_rowKey;
- }
-
- /**
- * Set row key
- *
- * @azure RowKey
- * @param string $value
- */
- public function setRowKey($value)
- {
- $this->_rowKey = $value;
- }
-
- /**
- * Get timestamp
- *
- * @azure Timestamp Edm.DateTime
- * @return string
- */
- public function getTimestamp()
- {
- if (null === $this->_timestamp) {
- $this->setTimestamp(new DateTime());
- }
- return $this->_timestamp;
- }
-
- /**
- * Set timestamp
- *
- * @azure Timestamp Edm.DateTime
- * @param DateTime $value
- */
- public function setTimestamp(DateTime $value)
- {
- $this->_timestamp = $value;
- }
-
- /**
- * Get etag
- *
- * @return string
- */
- public function getEtag()
- {
- return $this->_etag;
- }
-
- /**
- * Set etag
- *
- * @param string $value
- */
- public function setEtag($value = '')
- {
- $this->_etag = $value;
- }
-
- /**
- * Get Azure values
- *
- * @return array
- */
- public function getAzureValues()
- {
- // Get accessors
- $accessors = self::getAzureAccessors(get_class($this));
-
- // Loop accessors and retrieve values
- $returnValue = array();
- foreach ($accessors as $accessor) {
- if ($accessor->EntityType == 'ReflectionProperty') {
- $property = $accessor->EntityAccessor;
- $returnValue[] = (object)array(
- 'Name' => $accessor->AzurePropertyName,
- 'Type' => $accessor->AzurePropertyType,
- 'Value' => $this->$property,
- );
- } else if ($accessor->EntityType == 'ReflectionMethod' && substr(strtolower($accessor->EntityAccessor), 0, 3) == 'get') {
- $method = $accessor->EntityAccessor;
- $returnValue[] = (object)array(
- 'Name' => $accessor->AzurePropertyName,
- 'Type' => $accessor->AzurePropertyType,
- 'Value' => $this->$method(),
- );
- }
- }
-
- // Return
- return $returnValue;
- }
-
- /**
- * Set Azure values
- *
- * @param array $values
- * @param boolean $throwOnError Throw Microsoft_WindowsAzure_Exception when a property is not specified in $values?
- * @throws Microsoft_WindowsAzure_Exception
- */
- public function setAzureValues($values = array(), $throwOnError = false)
- {
- // Get accessors
- $accessors = self::getAzureAccessors(get_class($this));
-
- // Loop accessors and set values
- $returnValue = array();
- foreach ($accessors as $accessor) {
- if (isset($values[$accessor->AzurePropertyName])) {
- // Cast to correct type
- if ($accessor->AzurePropertyType != '') {
- switch (strtolower($accessor->AzurePropertyType)) {
- case 'edm.int32':
- case 'edm.int64':
- $values[$accessor->AzurePropertyName] = intval($values[$accessor->AzurePropertyName]); break;
- case 'edm.boolean':
- if ($values[$accessor->AzurePropertyName] == 'true' || $values[$accessor->AzurePropertyName] == '1')
- $values[$accessor->AzurePropertyName] = true;
- else
- $values[$accessor->AzurePropertyName] = false;
- break;
- case 'edm.double':
- $values[$accessor->AzurePropertyName] = floatval($values[$accessor->AzurePropertyName]); break;
- case 'edm.datetime':
- $values[$accessor->AzurePropertyName] = $this->_convertToDateTime($values[$accessor->AzurePropertyName]); break;
- }
- }
-
- // Assign value
- if ($accessor->EntityType == 'ReflectionProperty') {
- $property = $accessor->EntityAccessor;
- $this->$property = $values[$accessor->AzurePropertyName];
- } else if ($accessor->EntityType == 'ReflectionMethod' && substr(strtolower($accessor->EntityAccessor), 0, 3) == 'set') {
- $method = $accessor->EntityAccessor;
- $this->$method($values[$accessor->AzurePropertyName]);
- }
- } else if ($throwOnError) {
- throw new Microsoft_WindowsAzure_Exception("Property '" . $accessor->AzurePropertyName . "' was not found in \$values array");
- }
- }
-
- // Return
- return $returnValue;
- }
-
- /**
- * Get Azure accessors from class
- *
- * @param string $className Class to get accessors for
- * @return array
- */
- public static function getAzureAccessors($className = '')
- {
- // List of accessors
- $azureAccessors = array();
-
- // Get all types
- $type = new ReflectionClass($className);
-
- // Loop all properties
- $properties = $type->getProperties();
- foreach ($properties as $property) {
- $accessor = self::getAzureAccessor($property);
- if (!is_null($accessor)) {
- $azureAccessors[] = $accessor;
- }
- }
-
- // Loop all methods
- $methods = $type->getMethods();
- foreach ($methods as $method) {
- $accessor = self::getAzureAccessor($method);
- if (!is_null($accessor)) {
- $azureAccessors[] = $accessor;
- }
- }
-
- // Return
- return $azureAccessors;
- }
-
- /**
- * Get Azure accessor from reflection member
- *
- * @param ReflectionProperty|ReflectionMethod $member
- * @return object
- */
- public static function getAzureAccessor($member)
- {
- // Get comment
- $docComment = $member->getDocComment();
-
- // Check for Azure comment
- if (strpos($docComment, '@azure') === false)
- {
- return null;
- }
-
- // Search for @azure contents
- $azureComment = '';
- $commentLines = explode("\n", $docComment);
- foreach ($commentLines as $commentLine) {
- if (strpos($commentLine, '@azure') !== false) {
- $azureComment = trim(substr($commentLine, strpos($commentLine, '@azure') + 6));
- while (strpos($azureComment, ' ') !== false) {
- $azureComment = str_replace(' ', ' ', $azureComment);
- }
- break;
- }
- }
-
- // Fetch @azure properties
- $azureProperties = explode(' ', $azureComment);
- return (object)array(
- 'EntityAccessor' => $member->getName(),
- 'EntityType' => get_class($member),
- 'AzurePropertyName' => $azureProperties[0],
- 'AzurePropertyType' => isset($azureProperties[1]) ? $azureProperties[1] : ''
- );
- }
-
- /**
- * Converts a string to a DateTime object. Returns false on failure.
- *
- * @param string $value The string value to parse
- * @return DateTime|boolean
- */
- protected function _convertToDateTime($value = '')
- {
- if ($value instanceof DateTime) {
- return $value;
- }
-
- try {
- if (substr($value, -1) == 'Z') {
- $value = substr($value, 0, strlen($value) - 1);
- }
- return new DateTime($value, new DateTimeZone('UTC'));
- }
- catch (Exception $ex) {
- return false;
- }
- }
-}
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/TableEntityQuery.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/TableEntityQuery.php
deleted file mode 100644
index 53d2f23..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/TableEntityQuery.php
+++ /dev/null
@@ -1,363 +0,0 @@
-_from = $name;
- return $this;
- }
-
- /**
- * Specify partition key
- *
- * @param string $value Partition key to query for
- * @return Microsoft_WindowsAzure_Storage_TableEntityQuery
- */
- public function wherePartitionKey($value = null)
- {
- $this->_partitionKey = $value;
- return $this;
- }
-
- /**
- * Specify row key
- *
- * @param string $value Row key to query for
- * @return Microsoft_WindowsAzure_Storage_TableEntityQuery
- */
- public function whereRowKey($value = null)
- {
- $this->_rowKey = $value;
- return $this;
- }
-
- /**
- * Add where clause
- *
- * @param string $condition Condition, can contain question mark(s) (?) for parameter insertion.
- * @param string|array $value Value(s) to insert in question mark (?) parameters.
- * @param string $cond Condition for the clause (and/or/not)
- * @return Microsoft_WindowsAzure_Storage_TableEntityQuery
- */
- public function where($condition, $value = null, $cond = '')
- {
- $condition = $this->_replaceOperators($condition);
-
- if (!is_null($value)) {
- $condition = $this->_quoteInto($condition, $value);
- }
-
- if (count($this->_where) == 0) {
- $cond = '';
- } else if ($cond !== '') {
- $cond = ' ' . strtolower(trim($cond)) . ' ';
- }
-
- $this->_where[] = $cond . $condition;
- return $this;
- }
-
- /**
- * Add where clause with AND condition
- *
- * @param string $condition Condition, can contain question mark(s) (?) for parameter insertion.
- * @param string|array $value Value(s) to insert in question mark (?) parameters.
- * @return Microsoft_WindowsAzure_Storage_TableEntityQuery
- */
- public function andWhere($condition, $value = null)
- {
- return $this->where($condition, $value, 'and');
- }
-
- /**
- * Add where clause with OR condition
- *
- * @param string $condition Condition, can contain question mark(s) (?) for parameter insertion.
- * @param string|array $value Value(s) to insert in question mark (?) parameters.
- * @return Microsoft_WindowsAzure_Storage_TableEntityQuery
- */
- public function orWhere($condition, $value = null)
- {
- return $this->where($condition, $value, 'or');
- }
-
- /**
- * OrderBy clause
- *
- * @param string $column Column to sort by
- * @param string $direction Direction to sort (asc/desc)
- * @return Microsoft_WindowsAzure_Storage_TableEntityQuery
- */
- public function orderBy($column, $direction = 'asc')
- {
- $this->_orderBy[] = $column . ' ' . $direction;
- return $this;
- }
-
- /**
- * Top clause
- *
- * @param int $top Top to fetch
- * @return Microsoft_WindowsAzure_Storage_TableEntityQuery
- */
- public function top($top = null)
- {
- $this->_top = (int)$top;
- return $this;
- }
-
- /**
- * Assembles the query string
- *
- * @param boolean $urlEncode Apply URL encoding to the query string
- * @return string
- */
- public function assembleQueryString($urlEncode = false)
- {
- $query = array();
- if (count($this->_where) != 0) {
- $filter = implode('', $this->_where);
- $query[] = '$filter=' . ($urlEncode ? self::encodeQuery($filter) : $filter);
- }
-
- if (count($this->_orderBy) != 0) {
- $orderBy = implode(',', $this->_orderBy);
- $query[] = '$orderby=' . ($urlEncode ? self::encodeQuery($orderBy) : $orderBy);
- }
-
- if (!is_null($this->_top)) {
- $query[] = '$top=' . $this->_top;
- }
-
- if (count($query) != 0) {
- return '?' . implode('&', $query);
- }
-
- return '';
- }
-
- /**
- * Assemble from
- *
- * @param boolean $includeParentheses Include parentheses? ()
- * @return string
- */
- public function assembleFrom($includeParentheses = true)
- {
- $identifier = '';
- if ($includeParentheses) {
- $identifier .= '(';
-
- if (!is_null($this->_partitionKey)) {
- $identifier .= 'PartitionKey=\'' . $this->_partitionKey . '\'';
- }
-
- if (!is_null($this->_partitionKey) && !is_null($this->_rowKey)) {
- $identifier .= ', ';
- }
-
- if (!is_null($this->_rowKey)) {
- $identifier .= 'RowKey=\'' . $this->_rowKey . '\'';
- }
-
- $identifier .= ')';
- }
- return $this->_from . $identifier;
- }
-
- /**
- * Assemble full query
- *
- * @return string
- */
- public function assembleQuery()
- {
- $assembledQuery = $this->assembleFrom();
-
- $queryString = $this->assembleQueryString();
- if ($queryString !== '') {
- $assembledQuery .= $queryString;
- }
-
- return $assembledQuery;
- }
-
- /**
- * Quotes a variable into a condition
- *
- * @param string $text Condition, can contain question mark(s) (?) for parameter insertion.
- * @param string|array $value Value(s) to insert in question mark (?) parameters.
- * @return string
- */
- protected function _quoteInto($text, $value = null)
- {
- if (!is_array($value)) {
- $text = str_replace('?', '\'' . addslashes($value) . '\'', $text);
- } else {
- $i = 0;
- while(strpos($text, '?') !== false) {
- if (is_numeric($value[$i])) {
- $text = substr_replace($text, $value[$i++], strpos($text, '?'), 1);
- } else {
- $text = substr_replace($text, '\'' . addslashes($value[$i++]) . '\'', strpos($text, '?'), 1);
- }
- }
- }
- return $text;
- }
-
- /**
- * Replace operators
- *
- * @param string $text
- * @return string
- */
- protected function _replaceOperators($text)
- {
- $text = str_replace('==', 'eq', $text);
- $text = str_replace('>', 'gt', $text);
- $text = str_replace('<', 'lt', $text);
- $text = str_replace('>=', 'ge', $text);
- $text = str_replace('<=', 'le', $text);
- $text = str_replace('!=', 'ne', $text);
-
- $text = str_replace('&&', 'and', $text);
- $text = str_replace('||', 'or', $text);
- $text = str_replace('!', 'not', $text);
-
- return $text;
- }
-
- /**
- * urlencode a query
- *
- * @param string $query Query to encode
- * @return string Encoded query
- */
- public static function encodeQuery($query)
- {
- $query = str_replace('/', '%2F', $query);
- $query = str_replace('?', '%3F', $query);
- $query = str_replace(':', '%3A', $query);
- $query = str_replace('@', '%40', $query);
- $query = str_replace('&', '%26', $query);
- $query = str_replace('=', '%3D', $query);
- $query = str_replace('+', '%2B', $query);
- $query = str_replace(',', '%2C', $query);
- $query = str_replace('$', '%24', $query);
-
-
- $query = str_replace(' ', '%20', $query);
-
- return $query;
- }
-
- /**
- * __toString overload
- *
- * @return string
- */
- public function __toString()
- {
- return $this->assembleQuery();
- }
-}
\ No newline at end of file
diff --git a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/TableInstance.php b/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/TableInstance.php
deleted file mode 100644
index 2791eb0..0000000
--- a/Drupal/source/resources/WebRole/sites/all/modules/azure/phpazure/library/Microsoft/WindowsAzure/Storage/TableInstance.php
+++ /dev/null
@@ -1,78 +0,0 @@
-_data = array(
- 'id' => $id,
- 'name' => $name,
- 'href' => $href,
- 'updated' => $updated
- );
- }
-}