@@ -127,10 +127,7 @@ angular.module("spring-data-rest").provider("SpringDataRestAdapter", function ()
127127 var processData = function processDataFunction ( promiseOrData , fetchLinkNames , recursive ) {
128128
129129 // convert the given promise or data to a $q promise
130- var promise = $injector . get ( "$q" ) . when ( promiseOrData ) ;
131- var deferred = $injector . get ( "$q" ) . defer ( ) ;
132-
133- promise . then ( function ( data ) {
130+ return $injector . get ( "$q" ) . when ( promiseOrData ) . then ( function ( data ) {
134131
135132 /**
136133 * Wraps the Angular $resource method and adds the ability to retrieve the available resources. If no
@@ -209,14 +206,12 @@ angular.module("spring-data-rest").provider("SpringDataRestAdapter", function ()
209206
210207 // throw an exception if given data parameter is not of type object
211208 if ( ! angular . isObject ( data ) || data instanceof Array ) {
212- deferred . reject ( "Given data '" + data + "' is not of type object." ) ;
213- return ;
209+ return $injector . get ( "$q" ) . reject ( "Given data '" + data + "' is not of type object." ) ;
214210 }
215211
216212 // throw an exception if given fetch links parameter is not of type array or string
217213 if ( fetchLinkNames && ! ( fetchLinkNames instanceof Array || typeof fetchLinkNames === "string" ) ) {
218- deferred . reject ( "Given fetch links '" + fetchLinkNames + "' is not of type array or string." ) ;
219- return ;
214+ return $injector . get ( "$q" ) . reject ( "Given fetch links '" + fetchLinkNames + "' is not of type array or string." ) ;
220215 }
221216
222217 var processedData = undefined ;
@@ -295,26 +290,13 @@ angular.module("spring-data-rest").provider("SpringDataRestAdapter", function ()
295290 } ) ;
296291 }
297292
298- $injector . get ( "$q" ) . all ( promisesArray ) . then ( function ( ) {
293+ return $injector . get ( "$q" ) . all ( promisesArray ) . then ( function ( ) {
299294
300295 // return the original data object if no processing is done
301- deferred . resolve ( processedData ? processedData : data ) ;
302- } , function ( error ) {
303- deferred . reject ( error ) ;
304-
305- // reject the error because we do not handle the error here
306- return $injector . get ( "$q" ) . reject ( error ) ;
296+ return processedData ? processedData : data ;
307297 } ) ;
308- } , function ( error ) {
309- deferred . reject ( error ) ;
310-
311- // reject the error because we do not handle the error here
312- return $injector . get ( "$q" ) . reject ( error ) ;
313298 } ) ;
314299
315- // return the promise
316- return deferred . promise ;
317-
318300 /**
319301 * Gets the processed URL of the given resource name form the given data object.
320302 * @param {object } data the given data object
0 commit comments