chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lgr...@apache.org
Subject svn commit: r1592473 - /chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserObjectService.m
Date Mon, 05 May 2014 10:06:43 GMT
Author: lgross
Date: Mon May  5 10:06:43 2014
New Revision: 1592473

URL: http://svn.apache.org/r1592473
Log:
CMIS-797: Browser Binding: Create Document fails when no input stream is set

Modified:
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserObjectService.m

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserObjectService.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserObjectService.m?rev=1592473&r1=1592472&r2=1592473&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserObjectService.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserObjectService.m
Mon May  5 10:06:43 2014
@@ -431,31 +431,42 @@
     
     CMISRequest *cmisRequest = [[CMISRequest alloc] init];
     
+    void (^responseHandlingBlock) (CMISHttpResponse*, NSError*) = ^(CMISHttpResponse *httpResponse,
NSError *error) {
+        if ((httpResponse.statusCode == 200 || httpResponse.statusCode == 201) &&
httpResponse.data) {
+            CMISBrowserTypeCache *typeCache = [[CMISBrowserTypeCache alloc] initWithRepositoryId:self.bindingSession.repositoryId
bindingService:self];
+            [CMISBrowserUtil objectDataFromJSONData:httpResponse.data typeCache:typeCache
completionBlock:^(CMISObjectData *objectData, NSError *error) {
+                if (error) {
+                    completionBlock(nil, error);
+                } else {
+                    completionBlock(objectData.identifier, nil);
+                }
+            }];
+        } else {
+            completionBlock(nil, error);
+        }
+    };
+    
     // send
-    [self.bindingSession.networkProvider invoke:[NSURL URLWithString:folderObjectUrl]
-                                     httpMethod:HTTP_POST
-                                        session:self.bindingSession
-                                    inputStream:inputStream
-                                        headers:formData.headers
-                                  bytesExpected:bytesExpected
-                                    cmisRequest:cmisRequest
-                                      startData:formData.startData
-                                        endData:formData.endData
-                                completionBlock:^(CMISHttpResponse *httpResponse, NSError
*error) {
-                                    if ((httpResponse.statusCode == 200 || httpResponse.statusCode
== 201) && httpResponse.data) {
-                                        CMISBrowserTypeCache *typeCache = [[CMISBrowserTypeCache
alloc] initWithRepositoryId:self.bindingSession.repositoryId bindingService:self];
-                                        [CMISBrowserUtil objectDataFromJSONData:httpResponse.data
typeCache:typeCache completionBlock:^(CMISObjectData *objectData, NSError *error) {
-                                            if (error) {
-                                                completionBlock(nil, error);
-                                            } else {
-                                                completionBlock(objectData.identifier, nil);
-                                            }
-                                        }];
-                                    } else {
-                                        completionBlock(nil, error);
-                                    }
-                                }
-                                  progressBlock:progressBlock];
+    if (inputStream) {
+        [self.bindingSession.networkProvider invoke:[NSURL URLWithString:folderObjectUrl]
+                                         httpMethod:HTTP_POST
+                                            session:self.bindingSession
+                                        inputStream:inputStream
+                                            headers:formData.headers
+                                      bytesExpected:bytesExpected
+                                        cmisRequest:cmisRequest
+                                          startData:formData.startData
+                                            endData:formData.endData
+                                    completionBlock:responseHandlingBlock
+                                      progressBlock:progressBlock];
+    } else {
+        [self.bindingSession.networkProvider invokePOST:[NSURL URLWithString:folderObjectUrl]
+                                                session:self.bindingSession
+                                                   body:formData.body
+                                                headers:formData.headers
+                                            cmisRequest:cmisRequest
+                                        completionBlock:responseHandlingBlock];
+    }
     return cmisRequest;
 }
 



Mime
View raw message