Microsoft_WindowsAzure
[ class tree: Microsoft_WindowsAzure ] [ index: Microsoft_WindowsAzure ] [ all elements ]

Source for file Queue.php

Documentation is available at Queue.php

  1. <?php
  2. /**
  3.  * Copyright (c) 2009 - 2011, RealDolmen
  4.  * All rights reserved.
  5.  *
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted provided that the following conditions are met:
  8.  *     * Redistributions of source code must retain the above copyright
  9.  *       notice, this list of conditions and the following disclaimer.
  10.  *     * Redistributions in binary form must reproduce the above copyright
  11.  *       notice, this list of conditions and the following disclaimer in the
  12.  *       documentation and/or other materials provided with the distribution.
  13.  *     * Neither the name of RealDolmen nor the
  14.  *       names of its contributors may be used to endorse or promote products
  15.  *       derived from this software without specific prior written permission.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
  18.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20.  * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
  21.  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  26.  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  *
  28.  * @category   Microsoft
  29.  * @package    Microsoft_WindowsAzure
  30.  * @subpackage Storage
  31.  * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
  32.  * @license    http://todo     name_todo
  33.  * @version    $Id: Blob.php 24241 2009-07-22 09:43:13Z unknown $
  34.  */
  35.  
  36. /**
  37.  * @see Microsoft_AutoLoader
  38.  */
  39. require_once dirname(__FILE__'/../../AutoLoader.php';
  40.  
  41.  
  42. /**
  43.  * @category   Microsoft
  44.  * @package    Microsoft_WindowsAzure
  45.  * @subpackage Storage
  46.  * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
  47.  * @license    http://phpazure.codeplex.com/license
  48.  */
  49. {
  50.     /**
  51.      * Maximal message size (in bytes)
  52.      */
  53.     const MAX_MESSAGE_SIZE = 8388608;
  54.     
  55.     /**
  56.      * Maximal message ttl (in seconds)
  57.      */
  58.     const MAX_MESSAGE_TTL = 604800;
  59.     
  60.     /**
  61.      * Creates a new Microsoft_WindowsAzure_Storage_Queue instance
  62.      *
  63.      * @param string $host Storage host name
  64.      * @param string $accountName Account name for Windows Azure
  65.      * @param string $accountKey Account key for Windows Azure
  66.      * @param boolean $usePathStyleUri Use path-style URI's
  67.      * @param Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
  68.      */
  69.     public function __construct($host Microsoft_WindowsAzure_Storage::URL_DEV_QUEUE$accountName Microsoft_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_ACCOUNT$accountKey Microsoft_WindowsAzure_Credentials_CredentialsAbstract::DEVSTORE_KEY$usePathStyleUri falseMicrosoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy null)
  70.     {
  71.         parent::__construct($host$accountName$accountKey$usePathStyleUri$retryPolicy);
  72.         
  73.         // API version
  74.         $this->_apiVersion = '2009-09-19';
  75.     }
  76.     
  77.     /**
  78.      * Check if a queue exists
  79.      * 
  80.      * @param string $queueName Queue name
  81.      * @return boolean 
  82.      */
  83.     public function queueExists($queueName '')
  84.     {
  85.         if ($queueName === ''{
  86.             throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
  87.         }
  88.         if (!self::isValidQueueName($queueName)) {
  89.             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.');
  90.         }
  91.             
  92.         // List queues
  93.         $queues $this->listQueues($queueName1);
  94.         foreach ($queues as $queue{
  95.             if ($queue->Name == $queueName{
  96.                 return true;
  97.             }
  98.         }
  99.         
  100.         return false;
  101.     }
  102.     
  103.     /**
  104.      * Create queue
  105.      *
  106.      * @param string $queueName Queue name
  107.      * @param array  $metadata  Key/value pairs of meta data
  108.      * @return object Queue properties
  109.      * @throws Microsoft_WindowsAzure_Exception
  110.      */
  111.     public function createQueue($queueName ''$metadata array())
  112.     {
  113.         if ($queueName === ''{
  114.             throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
  115.         }
  116.         if (!self::isValidQueueName($queueName)) {
  117.             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.');
  118.         }
  119.             
  120.         // Create metadata headers
  121.         $headers array();
  122.         $headers array_merge($headers$this->_generateMetadataHeaders($metadata))
  123.         
  124.         // Perform request
  125.         $response $this->_performRequest($queueName''Microsoft_Http_Client::PUT$headers);    
  126.         if ($response->isSuccessful()) {
  127.             return new Microsoft_WindowsAzure_Storage_QueueInstance(
  128.                 $queueName,
  129.                 $metadata
  130.             );
  131.         else {
  132.             throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response'Resource could not be accessed.'));
  133.         }
  134.     }
  135.     
  136.     /**
  137.      * Create queue if it does not exist
  138.      *
  139.      * @param string $queueName Queue name
  140.      * @param array  $metadata  Key/value pairs of meta data
  141.      * @throws Microsoft_WindowsAzure_Exception
  142.      */
  143.     public function createQueueIfNotExists($queueName ''$metadata array())
  144.     {
  145.         if (!$this->queueExists($queueName)) {
  146.             $this->createQueue($queueName$metadata);
  147.         }
  148.     }
  149.     
  150.     /**
  151.      * Get queue
  152.      * 
  153.      * @param string $queueName  Queue name
  154.      * @return Microsoft_WindowsAzure_Storage_QueueInstance 
  155.      * @throws Microsoft_WindowsAzure_Exception
  156.      */
  157.     public function getQueue($queueName '')
  158.     {
  159.         if ($queueName === ''{
  160.             throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
  161.         }
  162.         if (!self::isValidQueueName($queueName)) {
  163.             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.');
  164.         }
  165.             
  166.         // Perform request
  167.         $response $this->_performRequest($queueName'?comp=metadata'Microsoft_Http_Client::GET);    
  168.         if ($response->isSuccessful()) {
  169.             // Parse metadata
  170.             $metadata $this->_parseMetadataHeaders($response->getHeaders());
  171.  
  172.             // Return queue
  173.             $queue new Microsoft_WindowsAzure_Storage_QueueInstance(
  174.                 $queueName,
  175.                 $metadata
  176.             );
  177.             $queue->ApproximateMessageCount intval($response->getHeader('x-ms-approximate-message-count'));
  178.             return $queue;
  179.         else {
  180.             throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response'Resource could not be accessed.'));
  181.         }
  182.     }
  183.     
  184.     /**
  185.      * Get queue metadata
  186.      * 
  187.      * @param string $queueName  Queue name
  188.      * @return array Key/value pairs of meta data
  189.      * @throws Microsoft_WindowsAzure_Exception
  190.      */
  191.     public function getQueueMetadata($queueName '')
  192.     {
  193.         if ($queueName === ''{
  194.             throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
  195.         }
  196.         if (!self::isValidQueueName($queueName)) {
  197.             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.');
  198.         }
  199.             
  200.         return $this->getQueue($queueName)->Metadata;
  201.     }
  202.     
  203.     /**
  204.      * Set queue metadata
  205.      * 
  206.      * 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.
  207.      *
  208.      * @param string $queueName  Queue name
  209.      * @param array  $metadata       Key/value pairs of meta data
  210.      * @throws Microsoft_WindowsAzure_Exception
  211.      */
  212.     public function setQueueMetadata($queueName ''$metadata array())
  213.     {
  214.         if ($queueName === ''{
  215.             throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
  216.         }
  217.         if (!self::isValidQueueName($queueName)) {
  218.             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.');
  219.         }
  220.         if (count($metadata== 0{
  221.             return;
  222.         }
  223.             
  224.         // Create metadata headers
  225.         $headers array();
  226.         $headers array_merge($headers$this->_generateMetadataHeaders($metadata))
  227.         
  228.         // Perform request
  229.         $response $this->_performRequest($queueName'?comp=metadata'Microsoft_Http_Client::PUT$headers);
  230.  
  231.         if (!$response->isSuccessful()) {
  232.             throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response'Resource could not be accessed.'));
  233.         }
  234.     }
  235.     
  236.     /**
  237.      * Delete queue
  238.      *
  239.      * @param string $queueName Queue name
  240.      * @throws Microsoft_WindowsAzure_Exception
  241.      */
  242.     public function deleteQueue($queueName '')
  243.     {
  244.         if ($queueName === ''{
  245.             throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
  246.         }
  247.         if (!self::isValidQueueName($queueName)) {
  248.             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.');
  249.         }
  250.             
  251.         // Perform request
  252.         $response $this->_performRequest($queueName''Microsoft_Http_Client::DELETE);
  253.         if (!$response->isSuccessful()) {
  254.             throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response'Resource could not be accessed.'));
  255.         }
  256.     }
  257.     
  258.     /**
  259.      * List queues
  260.      *
  261.      * @param string $prefix     Optional. Filters the results to return only queues whose name begins with the specified prefix.
  262.      * @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)
  263.      * @param string $marker     Optional string value that identifies the portion of the list to be returned with the next list operation.
  264.      * @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')
  265.      * @param int    $currentResultCount Current result count (internal use)
  266.      * @return array 
  267.      * @throws Microsoft_WindowsAzure_Exception
  268.      */
  269.     public function listQueues($prefix null$maxResults null$marker null$include null$currentResultCount 0)
  270.     {
  271.         // Build query string
  272.         $queryString array('comp=list');
  273.         if (!is_null($prefix)) {
  274.             $queryString['prefix=' $prefix;
  275.         }
  276.         if (!is_null($maxResults)) {
  277.             $queryString['maxresults=' $maxResults;
  278.         }
  279.         if (!is_null($marker)) {
  280.             $queryString['marker=' $marker;
  281.         }
  282.         if (!is_null($include)) {
  283.             $queryString['include=' $include;
  284.         }
  285.         $queryString self::createQueryStringFromArray($queryString);
  286.             
  287.         // Perform request
  288.         $response $this->_performRequest(''$queryStringMicrosoft_Http_Client::GET);    
  289.         if ($response->isSuccessful()) {
  290.             $xmlQueues $this->_parseResponse($response)->Queues->Queue;
  291.             $xmlMarker = (string)$this->_parseResponse($response)->NextMarker;
  292.  
  293.             $queues array();
  294.             if (!is_null($xmlQueues)) {
  295.                 for ($i 0$i count($xmlQueues)$i++{
  296.                     $queues[new Microsoft_WindowsAzure_Storage_QueueInstance(
  297.                         (string)$xmlQueues[$i]->Name,
  298.                         $this->_parseMetadataElement($xmlQueues[$i])
  299.                     );
  300.                 }
  301.             }
  302.             $currentResultCount $currentResultCount count($queues);
  303.             if (!is_null($maxResults&& $currentResultCount $maxResults{
  304.                 if (!is_null($xmlMarker&& $xmlMarker != ''{
  305.                     $queues array_merge($queues$this->listQueues($prefix$maxResults$xmlMarker$include$currentResultCount));
  306.                 }
  307.             }
  308.             if (!is_null($maxResults&& count($queues$maxResults{
  309.                 $queues array_slice($queues0$maxResults);
  310.             }
  311.                 
  312.             return $queues;
  313.         else {
  314.             throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response'Resource could not be accessed.'));
  315.         }
  316.     }
  317.     
  318.     /**
  319.      * Put message into queue
  320.      *
  321.      * @param string $queueName  Queue name
  322.      * @param string $message    Message
  323.      * @param int    $ttl        Message Time-To-Live (in seconds). Defaults to 7 days if the parameter is omitted.
  324.      * @throws Microsoft_WindowsAzure_Exception
  325.      */
  326.     public function putMessage($queueName ''$message ''$ttl null)
  327.     {
  328.         if ($queueName === ''{
  329.             throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
  330.         }
  331.         if (!self::isValidQueueName($queueName)) {
  332.             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.');
  333.         }
  334.         if (strlen($messageself::MAX_MESSAGE_SIZE{
  335.             throw new Microsoft_WindowsAzure_Exception('Message is too big. Message content should be < 8KB.');
  336.         }
  337.         if ($message == ''{
  338.             throw new Microsoft_WindowsAzure_Exception('Message is not specified.');
  339.         }
  340.         if (!is_null($ttl&& ($ttl <= || $ttl self::MAX_MESSAGE_SIZE)) {
  341.             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.');
  342.         }
  343.             
  344.         // Build query string
  345.         $queryString array();
  346.         if (!is_null($ttl)) {
  347.             $queryString['messagettl=' $ttl;
  348.         }
  349.         $queryString self::createQueryStringFromArray($queryString);
  350.             
  351.         // Build body
  352.         $rawData '';
  353.         $rawData .= '<QueueMessage>';
  354.         $rawData .= '    <MessageText>' base64_encode($message'</MessageText>';
  355.         $rawData .= '</QueueMessage>';
  356.             
  357.         // Perform request
  358.         $response $this->_performRequest($queueName '/messages'$queryStringMicrosoft_Http_Client::POSTarray()false$rawData);
  359.  
  360.         if (!$response->isSuccessful()) {
  361.             throw new Microsoft_WindowsAzure_Exception('Error putting message into queue.');
  362.         }
  363.     }
  364.     
  365.     /**
  366.      * Get queue messages
  367.      *
  368.      * @param string $queueName         Queue name
  369.      * @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.
  370.      * @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.
  371.      * @param string $peek              Peek only?
  372.      * @return array 
  373.      * @throws Microsoft_WindowsAzure_Exception
  374.      */
  375.     public function getMessages($queueName ''$numOfMessages 1$visibilityTimeout null$peek false)
  376.     {
  377.         if ($queueName === ''{
  378.             throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
  379.         }
  380.         if (!self::isValidQueueName($queueName)) {
  381.             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.');
  382.         }
  383.         if ($numOfMessages || $numOfMessages 32 || intval($numOfMessages!= $numOfMessages{
  384.             throw new Microsoft_WindowsAzure_Exception('Invalid number of messages to retrieve.');
  385.         }
  386.         if (!is_null($visibilityTimeout&& ($visibilityTimeout <= || $visibilityTimeout 7200)) {
  387.             throw new Microsoft_WindowsAzure_Exception('Visibility timeout is invalid. Maximum value is 2 hours (7200 seconds) and should be greater than zero.');
  388.         }
  389.             
  390.         // Build query string
  391.         $queryString array();
  392.         if ($peek{
  393.             $queryString['peekonly=true';
  394.         }
  395.         if ($numOfMessages 1{
  396.             $queryString['numofmessages=' $numOfMessages;
  397.         }
  398.         if (!$peek && !is_null($visibilityTimeout)) {
  399.             $queryString['visibilitytimeout=' $visibilityTimeout;
  400.         }   
  401.         $queryString self::createQueryStringFromArray($queryString);
  402.             
  403.         // Perform request
  404.         $response $this->_performRequest($queueName '/messages'$queryStringMicrosoft_Http_Client::GET);    
  405.         if ($response->isSuccessful()) {
  406.             // Parse results
  407.             $result $this->_parseResponse($response);
  408.             if (!$result{
  409.                 return array();
  410.             }
  411.  
  412.             $xmlMessages null;
  413.             if (count($result->QueueMessage1{
  414.                 $xmlMessages $result->QueueMessage;
  415.             else {
  416.                 $xmlMessages array($result->QueueMessage);
  417.             }
  418.  
  419.             $messages array();
  420.             for ($i 0$i count($xmlMessages)$i++{
  421.                 $messages[new Microsoft_WindowsAzure_Storage_QueueMessage(
  422.                     (string)$xmlMessages[$i]->MessageId,
  423.                     (string)$xmlMessages[$i]->InsertionTime,
  424.                     (string)$xmlMessages[$i]->ExpirationTime,
  425.                     ($peek '' : (string)$xmlMessages[$i]->PopReceipt),
  426.                     ($peek '' : (string)$xmlMessages[$i]->TimeNextVisible),
  427.                     (string)$xmlMessages[$i]->DequeueCount,
  428.                     base64_decode((string)$xmlMessages[$i]->MessageText)
  429.                 );
  430.             }
  431.                 
  432.             return $messages;
  433.         else {
  434.             throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response'Resource could not be accessed.'));
  435.         }
  436.     }
  437.     
  438.     /**
  439.      * Peek queue messages
  440.      *
  441.      * @param string $queueName         Queue name
  442.      * @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.
  443.      * @return array 
  444.      * @throws Microsoft_WindowsAzure_Exception
  445.      */
  446.     public function peekMessages($queueName ''$numOfMessages 1)
  447.     {
  448.         return $this->getMessages($queueName$numOfMessagesnulltrue);
  449.     }
  450.     
  451.     /**
  452.      * Checks to see if a given queue has messages
  453.      *
  454.      * @param string $queueName         Queue name
  455.      * @return boolean 
  456.      * @throws Microsoft_WindowsAzure_Exception
  457.      */
  458.     public function hasMessages($queueName '')
  459.     {
  460.         return count($this->peekMessages($queueName)) 0;
  461.     }
  462.     
  463.     /**
  464.      * Clear queue messages
  465.      *
  466.      * @param string $queueName         Queue name
  467.      * @throws Microsoft_WindowsAzure_Exception
  468.      */
  469.     public function clearMessages($queueName '')
  470.     {
  471.         if ($queueName === ''{
  472.             throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
  473.         }
  474.         if (!self::isValidQueueName($queueName)) {
  475.             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.');
  476.         }
  477.  
  478.         // Perform request
  479.         $response $this->_performRequest($queueName '/messages'''Microsoft_Http_Client::DELETE);    
  480.         if (!$response->isSuccessful()) {
  481.             throw new Microsoft_WindowsAzure_Exception('Error clearing messages from queue.');
  482.         }
  483.     }
  484.     
  485.     /**
  486.      * Delete queue message
  487.      *
  488.      * @param string $queueName                             Queue name
  489.      * @param Microsoft_WindowsAzure_Storage_QueueMessage $message Message to delete from queue. A message retrieved using "peekMessages" can NOT be deleted!
  490.      * @throws Microsoft_WindowsAzure_Exception
  491.      */
  492.     public function deleteMessage($queueName ''Microsoft_WindowsAzure_Storage_QueueMessage $message)
  493.     {
  494.         if ($queueName === ''{
  495.             throw new Microsoft_WindowsAzure_Exception('Queue name is not specified.');
  496.         }
  497.         if (!self::isValidQueueName($queueName)) {
  498.             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.');
  499.         }
  500.         if ($message->PopReceipt == ''{
  501.             throw new Microsoft_WindowsAzure_Exception('A message retrieved using "peekMessages" can NOT be deleted! Use "getMessages" instead.');
  502.         }
  503.  
  504.         // Perform request
  505.         $response $this->_performRequest($queueName '/messages/' $message->MessageId'?popreceipt=' urlencode($message->PopReceipt)Microsoft_Http_Client::DELETE);    
  506.         if (!$response->isSuccessful()) {
  507.             throw new Microsoft_WindowsAzure_Exception($this->_getErrorMessage($response'Resource could not be accessed.'));
  508.         }
  509.     }
  510.     
  511.     /**
  512.      * Is valid queue name?
  513.      *
  514.      * @param string $queueName Queue name
  515.      * @return boolean 
  516.      */
  517.     public static function isValidQueueName($queueName '')
  518.     {
  519.         if (preg_match("/^[a-z0-9][a-z0-9-]*$/"$queueName=== 0{
  520.             return false;
  521.         }
  522.     
  523.         if (strpos($queueName'--'!== false{
  524.             return false;
  525.         }
  526.     
  527.         if (strtolower($queueName!= $queueName{
  528.             return false;
  529.         }
  530.     
  531.         if (strlen($queueName|| strlen($queueName63{
  532.             return false;
  533.         }
  534.             
  535.         if (substr($queueName-1== '-'{
  536.             return false;
  537.         }
  538.     
  539.         return true;
  540.     }
  541.     
  542.     /**
  543.      * Get error message from Microsoft_Http_Response
  544.      * 
  545.      * @param Microsoft_Http_Response $response Repsonse
  546.      * @param string $alternativeError Alternative error message
  547.      * @return string 
  548.      */
  549.     protected function _getErrorMessage(Microsoft_Http_Response $response$alternativeError 'Unknown error.')
  550.     {
  551.         $response $this->_parseResponse($response);
  552.         if ($response && $response->Message{
  553.             return (string)$response->Message;
  554.         else {
  555.             return $alternativeError;
  556.         }
  557.     }
  558. }

Documentation generated on Wed, 18 May 2011 12:06:45 +0200 by phpDocumentor 1.4.3