Source for file BatchStorageAbstract.php
Documentation is available at BatchStorageAbstract.php
* Copyright (c) 2009 - 2011, RealDolmen
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of RealDolmen nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @package Microsoft_WindowsAzure
* @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
* @license http://phpazure.codeplex.com/license
* @version $Id: Storage.php 21617 2009-06-12 10:46:31Z unknown $
* @see Microsoft_AutoLoader
require_once dirname(__FILE__ ) . '/../../AutoLoader.php';
* @package Microsoft_WindowsAzure
* @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
* @license http://phpazure.codeplex.com/license
* @var Microsoft_WindowsAzure_Storage_Batch
* @param Microsoft_WindowsAzure_Storage_Batch $batch Current batch
* @throws Microsoft_WindowsAzure_Exception
public function setCurrentBatch(Microsoft_WindowsAzure_Storage_Batch $batch = null)
* @return Microsoft_WindowsAzure_Storage_Batch
* Is there a current batch?
* Starts a new batch operation set
* @return Microsoft_WindowsAzure_Storage_Batch
* @throws Microsoft_WindowsAzure_Exception
* 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)
// 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
$operation = $operations[0];
$rawData .= '--' . $batchBoundary . "\n";
$rawData .= 'Content-Type: application/http' . "\n";
$rawData .= 'Content-Transfer-Encoding: binary' . "\n\n";
$rawData .= '--' . $batchBoundary . '--';
$rawData .= '--' . $batchBoundary . "\n";
$rawData .= 'Content-Type: multipart/mixed; boundary=' . $changesetBoundary . "\n\n";
foreach ($operations as $operation)
$rawData .= '--' . $changesetBoundary . "\n";
$rawData .= 'Content-Type: application/http' . "\n";
$rawData .= 'Content-Transfer-Encoding: binary' . "\n\n";
$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);
|