16
16
*/
17
17
namespace GDS \Gateway ;
18
18
use GDS \Entity ;
19
+ use GDS \Exception \Contention ;
19
20
20
21
/**
21
22
* GoogleAPIClient Datastore Gateway
@@ -189,6 +190,8 @@ private function applyTransaction($obj_request) {
189
190
*
190
191
* @param \Google_Service_Datastore_Mutation $obj_mutation
191
192
* @return \Google_Service_Datastore_CommitResponse
193
+ * @throws Contention
194
+ * @throws \Google_Service_Exception
192
195
*/
193
196
private function commitMutation (\Google_Service_Datastore_Mutation $ obj_mutation )
194
197
{
@@ -198,11 +201,19 @@ private function commitMutation(\Google_Service_Datastore_Mutation $obj_mutation
198
201
} else {
199
202
$ obj_request ->setMode ('TRANSACTIONAL ' );
200
203
$ obj_request ->setTransaction ($ this ->str_next_transaction );
201
- $ this ->str_next_transaction = null ;
204
+ $ this ->str_next_transaction = NULL ;
202
205
}
203
206
$ obj_request ->setMutation ($ obj_mutation );
204
- $ this ->obj_last_response = $ this ->obj_datasets ->commit ($ this ->str_dataset_id , $ obj_request );
205
- return $ this ->obj_last_response ;
207
+ try {
208
+ $ this ->obj_last_response = $ this ->obj_datasets ->commit ($ this ->str_dataset_id , $ obj_request );
209
+ } catch (\Google_Service_Exception $ obj_exception ) {
210
+ $ this ->obj_last_response = NULL ;
211
+ if (409 == $ obj_exception ->getCode ()) {
212
+ throw new Contention ('Datastore contention ' , 409 , $ obj_exception );
213
+ } else {
214
+ throw $ obj_exception ;
215
+ }
216
+ }
206
217
}
207
218
208
219
/**
@@ -266,7 +277,7 @@ public function deleteMulti(array $arr_entities)
266
277
$ this ->applyNamespace ($ obj_key );
267
278
}
268
279
$ obj_mutation ->setDelete ($ arr_google_keys );
269
- $ this ->obj_last_response = $ this -> commitMutation ($ obj_mutation );
280
+ $ this ->commitMutation ($ obj_mutation );
270
281
$ this ->obj_schema = null ;
271
282
return TRUE ; // really?
272
283
}
0 commit comments