equal
deleted
inserted
replaced
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Service_WindowsAzure |
16 * @package Zend_Service_WindowsAzure |
17 * @subpackage Storage |
17 * @subpackage Storage |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: Batch.php 23167 2010-10-19 17:53:31Z mabe $ |
20 * @version $Id: Batch.php 24593 2012-01-05 20:35:02Z matthew $ |
21 */ |
21 */ |
22 |
22 |
23 /** |
|
24 * @see Zend_Service_WindowsAzure_Exception |
|
25 */ |
|
26 require_once 'Zend/Service/WindowsAzure/Exception.php'; |
|
27 |
|
28 /** |
|
29 * @see Zend_Service_WindowsAzure_Storage_BatchStorageAbstract |
|
30 */ |
|
31 require_once 'Zend/Service/WindowsAzure/Storage/BatchStorageAbstract.php'; |
|
32 |
23 |
33 /** |
24 /** |
34 * @category Zend |
25 * @category Zend |
35 * @package Zend_Service_WindowsAzure |
26 * @package Zend_Service_WindowsAzure |
36 * @subpackage Storage |
27 * @subpackage Storage |
37 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
28 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
38 * @license http://framework.zend.com/license/new-bsd New BSD License |
29 * @license http://framework.zend.com/license/new-bsd New BSD License |
39 */ |
30 */ |
40 class Zend_Service_WindowsAzure_Storage_Batch |
31 class Zend_Service_WindowsAzure_Storage_Batch |
41 { |
32 { |
42 /** |
33 /** |
136 } |
127 } |
137 |
128 |
138 // Set _isSingleSelect |
129 // Set _isSingleSelect |
139 if ($httpVerb == Zend_Http_Client::GET) { |
130 if ($httpVerb == Zend_Http_Client::GET) { |
140 if (count($this->_operations) > 0) { |
131 if (count($this->_operations) > 0) { |
|
132 require_once 'Zend/Service/WindowsAzure/Exception.php'; |
141 throw new Zend_Service_WindowsAzure_Exception("Select operations can only be performed in an empty batch transaction."); |
133 throw new Zend_Service_WindowsAzure_Exception("Select operations can only be performed in an empty batch transaction."); |
142 } |
134 } |
143 $this->_isSingleSelect = true; |
135 $this->_isSingleSelect = true; |
144 } |
136 } |
145 |
137 |
147 if (strpos($path, '/') !== 0) { |
139 if (strpos($path, '/') !== 0) { |
148 $path = '/' . $path; |
140 $path = '/' . $path; |
149 } |
141 } |
150 |
142 |
151 // Clean headers |
143 // Clean headers |
152 if ($headers === null) { |
144 if (is_null($headers)) { |
153 $headers = array(); |
145 $headers = array(); |
154 } |
146 } |
155 |
147 |
156 // URL encoding |
148 // URL encoding |
157 $path = Zend_Service_WindowsAzure_Storage::urlencode($path); |
149 $path = Zend_Service_WindowsAzure_Storage::urlencode($path); |
159 |
151 |
160 // Generate URL |
152 // Generate URL |
161 $requestUrl = $this->getBaseUrl() . $path . $queryString; |
153 $requestUrl = $this->getBaseUrl() . $path . $queryString; |
162 |
154 |
163 // Generate $rawData |
155 // Generate $rawData |
164 if ($rawData === null) { |
156 if (is_null($rawData)) { |
165 $rawData = ''; |
157 $rawData = ''; |
166 } |
158 } |
167 |
159 |
168 // Add headers |
160 // Add headers |
169 if ($httpVerb != Zend_Http_Client::GET) { |
161 if ($httpVerb != Zend_Http_Client::GET) { |
195 * |
187 * |
196 * @return Zend_Http_Response |
188 * @return Zend_Http_Response |
197 * @throws Zend_Service_WindowsAzure_Exception |
189 * @throws Zend_Service_WindowsAzure_Exception |
198 */ |
190 */ |
199 public function commit() |
191 public function commit() |
200 { |
192 { |
201 // Perform batch |
193 // Perform batch |
202 $response = $this->_storageClient->performBatch($this->_operations, $this->_forTableStorage, $this->_isSingleSelect); |
194 $response = $this->_storageClient->performBatch($this->_operations, $this->_forTableStorage, $this->_isSingleSelect); |
203 |
195 |
204 // Dispose |
196 // Dispose |
205 $this->_clean(); |
197 $this->_clean(); |
208 $errors = null; |
200 $errors = null; |
209 preg_match_all('/<message (.*)>(.*)<\/message>/', $response->getBody(), $errors); |
201 preg_match_all('/<message (.*)>(.*)<\/message>/', $response->getBody(), $errors); |
210 |
202 |
211 // Error? |
203 // Error? |
212 if (count($errors[2]) > 0) { |
204 if (count($errors[2]) > 0) { |
|
205 require_once 'Zend/Service/WindowsAzure/Exception.php'; |
213 throw new Zend_Service_WindowsAzure_Exception('An error has occured while committing a batch: ' . $errors[2][0]); |
206 throw new Zend_Service_WindowsAzure_Exception('An error has occured while committing a batch: ' . $errors[2][0]); |
214 } |
207 } |
215 |
208 |
216 // Return |
209 // Return |
217 return $response; |
210 return $response; |