chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gavincornw...@apache.org
Subject svn commit: r1583375 - in /chemistry/objectivecmis/trunk: ObjectiveCMIS/Client/CMISFolder.m ObjectiveCMIS/Client/CMISSession.m ObjectiveCMISTests/ObjectiveCMISTests.m
Date Mon, 31 Mar 2014 16:53:37 GMT
Author: gavincornwell
Date: Mon Mar 31 16:53:37 2014
New Revision: 1583375

URL: http://svn.apache.org/r1583375
Log:
Fixed other occurrences of the pattern that causes cancel requests to be ignored.

Modified:
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m
    chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.m?rev=1583375&r1=1583374&r2=1583375&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.m Mon Mar 31 16:53:37 2014
@@ -75,11 +75,11 @@
 
 - (CMISRequest*)retrieveChildrenWithOperationContext:(CMISOperationContext *)operationContext
completionBlock:(void (^)(CMISPagedResult *result, NSError *error))completionBlock
 {
-    __block CMISRequest *request = [[CMISRequest alloc] init];
+    CMISRequest *request = [[CMISRequest alloc] init];
     CMISFetchNextPageBlock fetchNextPageBlock = ^(int skipCount, int maxItems, CMISFetchNextPageBlockCompletionBlock
pageBlockCompletionBlock)
     {
         // Fetch results through navigationService
-        request = [self.binding.navigationService retrieveChildren:self.identifier
+        CMISRequest * childrenRequest = [self.binding.navigationService retrieveChildren:self.identifier
                                                  orderBy:operationContext.orderBy
                                                   filter:operationContext.filterString
                                            relationships:operationContext.relationships
@@ -103,6 +103,9 @@
                                                  }];
                                              }
                                          }];
+        
+        // set the underlying request object on the object returned to the original caller
+        request.httpRequest = childrenRequest.httpRequest;
     };
 
     [CMISPagedResult pagedResultUsingFetchBlock:fetchNextPageBlock
@@ -120,18 +123,21 @@
 
 - (CMISRequest*)createFolder:(NSDictionary *)properties completionBlock:(void (^)(NSString
*objectId, NSError *error))completionBlock
 {
-    __block CMISRequest *request = [[CMISRequest alloc] init];
+    CMISRequest *request = [[CMISRequest alloc] init];
     [self.session.objectConverter convertProperties:properties
                                     forObjectTypeId:[properties objectForKey:kCMISPropertyObjectTypeId]
                                     completionBlock:^(CMISProperties *properties, NSError
*error) {
                      if (error) {
                          completionBlock(nil, [CMISErrors cmisError:error cmisErrorCode:kCMISErrorCodeRuntime]);
                      } else {
-                         request = [self.binding.objectService createFolderInParentFolder:self.identifier
+                         CMISRequest *createRequest = [self.binding.objectService createFolderInParentFolder:self.identifier
                                                                      properties:properties
                                                                 completionBlock:^(NSString
*objectId, NSError *error) {
                                                                     completionBlock(objectId,
error);
                                                                 }];
+                         
+                         // set the underlying request object on the object returned to the
original caller
+                         request.httpRequest = createRequest.httpRequest;
                      }
                  }];
     return request;
@@ -143,7 +149,7 @@
                            completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
                              progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned
long long bytesTotal))progressBlock
 {
-    __block CMISRequest *request = [[CMISRequest alloc] init];
+    CMISRequest *request = [[CMISRequest alloc] init];
     [self.session.objectConverter convertProperties:properties
                                     forObjectTypeId:[properties objectForKey:kCMISPropertyObjectTypeId]
                                     completionBlock:^(CMISProperties *convertedProperties,
NSError *error) {
@@ -153,12 +159,15 @@
                 completionBlock(nil, [CMISErrors cmisError:error cmisErrorCode:kCMISErrorCodeRuntime]);
             }
         } else {
-            request = [self.binding.objectService createDocumentFromFilePath:filePath
+            CMISRequest *createRequest = [self.binding.objectService createDocumentFromFilePath:filePath
                                                           mimeType:mimeType
                                                         properties:convertedProperties
                                                           inFolder:self.identifier
                                                    completionBlock:completionBlock
                                                      progressBlock:progressBlock];
+            
+            // set the underlying request object on the object returned to the original caller
+            request.httpRequest = createRequest.httpRequest;
         }
     }];
     return request;
@@ -171,7 +180,7 @@
                               completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
                                 progressBlock:(void (^)(unsigned long long bytesUploaded,
unsigned long long bytesTotal))progressBlock
 {
-    __block CMISRequest *request = [[CMISRequest alloc] init];
+    CMISRequest *request = [[CMISRequest alloc] init];
     [self.session.objectConverter convertProperties:properties forObjectTypeId:kCMISPropertyObjectTypeIdValueDocument
completionBlock:^(CMISProperties *convertedProperties, NSError *error){
         if (nil == convertedProperties){
             CMISLogError(@"Could not convert properties: %@", error.description);
@@ -179,13 +188,16 @@
                 completionBlock(nil, [CMISErrors cmisError:error cmisErrorCode:kCMISErrorCodeRuntime]);
             }
         } else {
-            request = [self.binding.objectService createDocumentFromInputStream:inputStream
+            CMISRequest *createRequest = [self.binding.objectService createDocumentFromInputStream:inputStream
                                                              mimeType:mimeType
                                                            properties:convertedProperties
                                                              inFolder:self.identifier
                                                         bytesExpected:bytesExpected
                                                       completionBlock:completionBlock
                                                         progressBlock:progressBlock];
+            
+            // set the underlying request object on the object returned to the original caller
+            request.httpRequest = createRequest.httpRequest;
         }
     }];
     return request;

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m?rev=1583375&r1=1583374&r2=1583375&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m Mon Mar 31 16:53:37 2014
@@ -283,10 +283,10 @@
                                      operationContext:(CMISOperationContext *)operationContext
                                       completionBlock:(void (^)(CMISPagedResult *pagedResult,
NSError *error))completionBlock
 {
-    __block CMISRequest *request = [[CMISRequest alloc] init];
+    CMISRequest *request = [[CMISRequest alloc] init];
     CMISFetchNextPageBlock fetchNextPageBlock = ^(int skipCount, int maxItems, CMISFetchNextPageBlockCompletionBlock
pageBlockCompletionBlock){
         // Fetch results through discovery service
-       request = [self.binding.discoveryService query:statement
+       CMISRequest *queryRequest = [self.binding.discoveryService query:statement
                                                   searchAllVersions:searchAllVersion
                                                   relationships:operationContext.relationships
                                                   renditionFilter:operationContext.renditionFilterString
@@ -310,6 +310,9 @@
                                                           pageBlockCompletionBlock(result,
nil);
                                                       }
                                                   }];
+        
+        // set the underlying request object on the object returned to the original caller
+        request.httpRequest = queryRequest.httpRequest;
     };
 
     [CMISPagedResult pagedResultUsingFetchBlock:fetchNextPageBlock
@@ -351,13 +354,13 @@
         [statement appendFormat:@" ORDER BY %@", operationContext.orderBy];
     }
     
-    __block CMISRequest *request = [[CMISRequest alloc] init];
+    CMISRequest *request = [[CMISRequest alloc] init];
     
     // Fetch block for paged results
     CMISFetchNextPageBlock fetchNextPageBlock = ^(int skipCount, int maxItems, CMISFetchNextPageBlockCompletionBlock
pageBlockCompletionBlock)
     {
         // Fetch results through discovery service
-        request = [self.binding.discoveryService query:statement
+        CMISRequest *queryRequest = [self.binding.discoveryService query:statement
                                      searchAllVersions:searchAllVersion
                                          relationships:operationContext.relationships
                                        renditionFilter:operationContext.renditionFilterString
@@ -380,6 +383,9 @@
                                                           }];
                                  }
                              }];
+        
+        // set the underlying request object on the object returned to the original caller
+        request.httpRequest = queryRequest.httpRequest;
     };
     
     [CMISPagedResult pagedResultUsingFetchBlock:fetchNextPageBlock
@@ -421,7 +427,7 @@
             inFolder:(NSString *)folderObjectId
      completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
 {
-    __block CMISRequest *request = [[CMISRequest alloc] init];
+    CMISRequest *request = [[CMISRequest alloc] init];
     [self.objectConverter convertProperties:properties
                             forObjectTypeId:[properties objectForKey:kCMISPropertyObjectTypeId]
                             completionBlock:^(CMISProperties *convertedProperties, NSError
*error) {
@@ -505,7 +511,7 @@
                    completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
                      progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long
long bytesTotal))progressBlock
 {
-    __block CMISRequest *request = [[CMISRequest alloc] init];
+    CMISRequest *request = [[CMISRequest alloc] init];
     [self.objectConverter convertProperties:properties
                             forObjectTypeId:[properties objectForKey:kCMISPropertyObjectTypeId]
                             completionBlock:^(CMISProperties *convertedProperties, NSError
*error) {
@@ -536,7 +542,7 @@
                       completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
                         progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned
long long bytesTotal))progressBlock
 {
-    __block CMISRequest *request = [[CMISRequest alloc] init];
+    CMISRequest *request = [[CMISRequest alloc] init];
     [self.objectConverter convertProperties:properties
                             forObjectTypeId:[properties objectForKey:kCMISPropertyObjectTypeId]
                             completionBlock:^(CMISProperties *convertedProperties, NSError
*error) {

Modified: chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m?rev=1583375&r1=1583374&r2=1583375&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m Mon Mar 31 16:53:37
2014
@@ -977,6 +977,22 @@
      }];
 }
 
+- (void)testCancelQuery
+{
+    [self runTest:^ {
+        // Query all properties
+        self.request = [self.session query:@"SELECT * FROM cmis:document WHERE cmis:name
LIKE '%quote%'" searchAllVersions:NO completionBlock:^(CMISPagedResult *result, NSError *error)
{
+            XCTAssertNotNil(error, @"Failed to cancel query");
+            XCTAssertTrue(error.code == kCMISErrorCodeCancelled, @"Expected error code to
be 6 (kCMISErrorCodeCancelled) but it was %ld", (long)error.code);
+            XCTAssertNil(result, @"Did not expect to recieve a result object");
+            self.testCompleted = YES;
+        }];
+        
+        // immediately cancel the query
+        [self.request cancel];
+    }];
+}
+
 - (void)testRetrieveParents
 {
     [self runTest:^ {



Mime
View raw message