chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lgr...@apache.org
Subject svn commit: r1589768 [2/2] - in /chemistry/objectivecmis/branches/browser-binding: ObjectiveCMIS.xcodeproj/ ObjectiveCMIS/Bindings/ ObjectiveCMIS/Bindings/AtomPub/ ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/ ObjectiveCMIS/Bindings/Browser/ ObjectiveC...
Date Thu, 24 Apr 2014 15:26:05 GMT
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISRepositoryInfo.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISRepositoryInfo.h?rev=1589768&r1=1589767&r2=1589768&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISRepositoryInfo.h
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISRepositoryInfo.h
Thu Apr 24 15:26:04 2014
@@ -19,6 +19,7 @@
 
 #import <Foundation/Foundation.h>
 #import "CMISExtensionData.h"
+#import "CMISRepositoryCapabilities.h"
 
 @interface CMISRepositoryInfo : CMISExtensionData
 
@@ -56,11 +57,11 @@
  */
 @property (nonatomic, strong) NSString *principalIdAnyone;
 
-// TODO the repositoryCapabilities property is currently not types.  
-/**  CMISRepositoryCapabilities needs to be created and replace the raw NSDictionary object
- * that is currently being set from the CMISRepositoryInfoParser
- * Use keypaths to get values until the property is properly typed **
+/**
+ * Returns Repository Capabilities Object
+ *
+ * @return Repository Capabilities
  */
-@property (nonatomic, strong) id repositoryCapabilities;
+@property (nonatomic, strong) CMISRepositoryCapabilities *repositoryCapabilities;
 
 @end

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m?rev=1589768&r1=1589767&r2=1589768&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
Thu Apr 24 15:26:04 2014
@@ -328,11 +328,11 @@ totalBytesExpectedToWrite:(NSInteger)tot
             if (self.base64InputStream) {
                 NSStreamStatus inputStatus = self.base64InputStream.streamStatus;
                 if (inputStatus == NSStreamStatusClosed) {
-                    CMISLogDebug(@"Base64InputStream %@ is closed", self.base64InputStream);
+                    CMISLogTrace(@"Base64InputStream %@ is closed", self.base64InputStream);
                 } else if (inputStatus == NSStreamStatusAtEnd){
-                    CMISLogDebug(@"Base64InputStream %@ has reached the end", self.base64InputStream);
+                    CMISLogTrace(@"Base64InputStream %@ has reached the end", self.base64InputStream);
                 } else if (inputStatus == NSStreamStatusError){
-                    CMISLogDebug(@"Base64InputStream %@ input stream error: %@", self.base64InputStream,
self.base64InputStream.streamError);
+                    CMISLogTrace(@"Base64InputStream %@ input stream error: %@", self.base64InputStream,
self.base64InputStream.streamError);
                     [self stopSendWithStatus:@"Network read error"];
                 }
             }
@@ -437,6 +437,9 @@ totalBytesExpectedToWrite:(NSInteger)tot
     encodedLength += self.streamStartData.length;
     encodedLength += self.streamEndData.length;
     self.encodedLength = encodedLength;
+    
+    // update the originally provided expected bytes with encoded length
+    self.bytesExpected = encodedLength;
 }
 
 - (void)prepareStreams
@@ -480,7 +483,7 @@ totalBytesExpectedToWrite:(NSInteger)tot
 - (void)stopSendWithStatus:(NSString *)statusString
 {
     if (nil != statusString) {
-        CMISLogDebug(@"Upload request terminated: Message is %@", statusString);
+        CMISLogTrace(@"Upload request terminated: Message is %@", statusString);
     }
     self.bufferOffset = 0;
     self.bufferLimit  = 0;

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISObjectConverter.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISObjectConverter.h?rev=1589768&r1=1589767&r2=1589768&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISObjectConverter.h
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISObjectConverter.h
Thu Apr 24 15:26:04 2014
@@ -38,4 +38,9 @@
           forObjectTypeId:(NSString *)objectTypeId 
           completionBlock:(void (^)(CMISProperties *convertedProperties, NSError *error))completionBlock;
 
+/**
+ * Converts the source to an array with elements of type CMISExtensionElement. Elements of
the source with keys that are contained in the cmisKeys set set are ignored.
+ */
++ (NSArray *)convertExtensions:(NSDictionary *)source cmisKeys:(NSSet *)cmisKeys;
+
 @end

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISObjectConverter.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISObjectConverter.m?rev=1589768&r1=1589767&r2=1589768&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISObjectConverter.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISObjectConverter.m
Thu Apr 24 15:26:04 2014
@@ -26,6 +26,7 @@
 #import "CMISSession.h"
 #import "CMISDateUtil.h"
 #import "CMISConstants.h"
+#import "CMISNSDictionary+CMISUtil.h"
 
 @interface CMISObjectConverter ()
 @property (nonatomic, weak) CMISSession *session;
@@ -465,4 +466,77 @@
     }
 }
 
++ (NSArray *)convertExtensions:(NSDictionary *)source cmisKeys:(NSSet *)cmisKeys
+{
+    if (!source) {
+        return nil;
+    }
+    
+    NSMutableArray *extensions = nil; // array of CMISExtensionElement's
+    
+    for (NSString *key in source.keyEnumerator) {
+        if ([cmisKeys containsObject:key]) {
+            continue;
+        }
+        
+        if (!extensions) {
+            extensions = [[NSMutableArray alloc] init];
+        }
+        
+        id value = [source cmis_objectForKeyNotNull:key];
+        if ([value isKindOfClass:NSDictionary.class]) {
+            [extensions addObject:[[CMISExtensionElement alloc] initNodeWithName:key namespaceUri:nil
attributes:nil children:[CMISObjectConverter convertExtension:value]]];
+        } else if ([value isKindOfClass:NSArray.class]) {
+            [extensions addObjectsFromArray:[CMISObjectConverter convertExtension: key fromArray:value]];
+        } else {
+            [extensions addObject:[[CMISExtensionElement alloc] initLeafWithName:key namespaceUri:nil
attributes:nil value:value]];
+        }
+    }
+    return extensions;
+}
+
++ (NSArray *)convertExtension:(NSDictionary *)dictionary
+{
+    if (!dictionary) {
+        return nil;
+    }
+    
+    NSMutableArray *extensions = [[NSMutableArray alloc] init]; // array of CMISExtensionElement's
+    
+    for (NSString *key in dictionary.keyEnumerator) {
+        id value = [dictionary cmis_objectForKeyNotNull:key];
+        if ([value isKindOfClass:NSDictionary.class]) {
+            [extensions addObject:[[CMISExtensionElement alloc] initNodeWithName:key namespaceUri:nil
attributes:nil children:[CMISObjectConverter convertExtension:value]]];
+        } else if ([value isKindOfClass:NSArray.class]) {
+            [extensions addObjectsFromArray:[CMISObjectConverter convertExtension: key fromArray:value]];
+        } else {
+            [extensions addObject:[[CMISExtensionElement alloc] initLeafWithName:key namespaceUri:nil
attributes:nil value:value]];
+        }
+    }
+    
+    return extensions;
+}
+
++ (NSArray *)convertExtension:(NSString *)key fromArray:(NSArray *)array
+{
+    if (!array) {
+        return nil;
+    }
+    
+    NSMutableArray *extensions = [[NSMutableArray alloc] init]; // array of CMISExtensionElement's
+    
+    for (id element in array) {
+        if ([element isKindOfClass:NSDictionary.class]) {
+            [extensions addObject:[[CMISExtensionElement alloc] initNodeWithName:key namespaceUri:nil
attributes:nil children:[CMISObjectConverter convertExtension:element]]];
+        } else if ([element isKindOfClass:NSArray.class]) {
+            [extensions addObjectsFromArray:[CMISObjectConverter convertExtension: key fromArray:element]];
+        } else {
+            [extensions addObject:[[CMISExtensionElement alloc] initLeafWithName:key namespaceUri:nil
attributes:nil value:element]];
+        }
+    }
+    
+    return extensions;
+}
+
+
 @end

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/ObjectiveCMISTests.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/ObjectiveCMISTests.m?rev=1589768&r1=1589767&r2=1589768&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/ObjectiveCMISTests.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/ObjectiveCMISTests.m
Thu Apr 24 15:26:04 2014
@@ -713,6 +713,159 @@
     }];
 }
 
+- (void)testMoveDocument
+{
+    [self runTest:^ {
+        
+        [self setupMoveTestFoldersAndDocumentWithCompletionBlock:^(NSString *containerFolderId,
CMISFolder *folder1, CMISFolder *folder2, CMISDocument *document) {
+            
+            [document moveFromFolderWithId:folder1.identifier toFolderWithId:folder2.identifier
completionBlock:^(CMISObject *object, NSError *error) {
+                XCTAssertNil(error, @"Error while moving document: %@", [error description]);
+                XCTAssertNotNil(object, @"Moved document is nil but should not");
+                
+                [folder2 retrieveChildrenWithCompletionBlock:^(CMISPagedResult *result, NSError
*error) {
+                    XCTAssertNil(error, @"Got error while retrieving children: %@", [error
description]);
+                    XCTAssertNotNil(result, @"Return result should not be nil");
+                    
+                    NSArray *children = result.resultArray;
+                    XCTAssertNotNil(children, @"children should not be nil");
+                    CMISLogDebug(@"There are %d children", [children count]);
+                    XCTAssertTrue([children count] == 1, @"There should be at least 3 children");
+                    
+                    CMISObject *child = children[0];
+                    XCTAssertTrue([child isKindOfClass:[CMISDocument class]], @"The child
of folder2 is not a CMISDocument but should be");
+                    CMISDocument *retrievedDocument = (CMISDocument *)child;
+                    XCTAssertTrue([retrievedDocument.name isEqualToString:document.name],
@"Moved document's name is not equal to original");
+                    
+                    [self.session.binding.objectService deleteTree:containerFolderId
+                                                        allVersion:YES
+                                                     unfileObjects:CMISDelete
+                                                 continueOnFailure:YES
+                                                   completionBlock:^(NSArray *failedObjects,
NSError *error) {
+                                                       XCTAssertNil(error, @"Error while
move test folders and document: %@", [error description]);
+                                                       
+                                                       self.testCompleted = YES;
+                                                   }];
+                }];
+            }];
+        }];
+    }];
+}
+
+- (void)testMoveFolder
+{
+    [self runTest:^ {
+        
+        [self setupMoveTestFoldersAndDocumentWithCompletionBlock:^(NSString *containerFolderId,
CMISFolder *folder1, CMISFolder *folder2, CMISDocument *document) {
+            
+            [folder1 moveFromFolderWithId:containerFolderId toFolderWithId:folder2.identifier
completionBlock:^(CMISObject *object, NSError *error) {
+                XCTAssertNil(error, @"Error while moving document: %@", [error description]);
+                XCTAssertNotNil(object, @"Moved document is nil but should not");
+                
+                [folder2 retrieveChildrenWithCompletionBlock:^(CMISPagedResult *result, NSError
*error) {
+                    XCTAssertNil(error, @"Got error while retrieving children: %@", [error
description]);
+                    XCTAssertNotNil(result, @"Return result should not be nil");
+                    
+                    NSArray *children = result.resultArray;
+                    XCTAssertNotNil(children, @"children should not be nil");
+                    CMISLogDebug(@"There are %d children", [children count]);
+                    XCTAssertTrue([children count] == 1, @"There should be at least 3 children");
+                    
+                    CMISObject *child = children[0];
+                    XCTAssertTrue([child isKindOfClass:[CMISFolder class]], @"The child of
folder2 is not a CMISFolder but should be");
+                    CMISFolder *retrievedFolder = (CMISFolder *)child;
+                    XCTAssertTrue([retrievedFolder.name isEqualToString:folder1.name], @"Moved
folder's name is not equal to original");
+                    
+                    [self.session.binding.objectService deleteTree:containerFolderId
+                                                        allVersion:YES
+                                                     unfileObjects:CMISDelete
+                                                 continueOnFailure:YES
+                                                   completionBlock:^(NSArray *failedObjects,
NSError *error) {
+                                                       XCTAssertNil(error, @"Error while
move test folders and document: %@", [error description]);
+                                                       
+                                                       self.testCompleted = YES;
+                                                   }];
+                }];
+            }];
+        }];
+    }];
+}
+
+- (void)setupMoveTestFoldersAndDocumentWithCompletionBlock:(void (^)(NSString *containerFolderId,
CMISFolder *folder1, CMISFolder *folder2, CMISDocument *document))completionBlock
+{
+    // Setup test folder container
+    NSMutableDictionary *containerFolderProperties = [NSMutableDictionary dictionary];
+    NSString *containerFolderName = [NSString stringWithFormat:@"test-moveObject-%@", [self
stringFromCurrentDate]];
+    [containerFolderProperties setObject:containerFolderName forKey:kCMISPropertyName];
+    [containerFolderProperties setObject:kCMISPropertyObjectTypeIdValueFolder forKey:kCMISPropertyObjectTypeId];
+    
+    NSMutableDictionary *propertiesFolder1 = [NSMutableDictionary dictionary];
+    NSString *folder1Name = [NSString stringWithFormat:@"folder1"];
+    [propertiesFolder1 setObject:folder1Name forKey:kCMISPropertyName];
+    [propertiesFolder1 setObject:kCMISPropertyObjectTypeIdValueFolder forKey:kCMISPropertyObjectTypeId];
+    
+    NSMutableDictionary *propertiesFolder2 = [NSMutableDictionary dictionary];
+    NSString *folder2Name = [NSString stringWithFormat:@"folder2"];
+    [propertiesFolder2 setObject:folder2Name forKey:kCMISPropertyName];
+    [propertiesFolder2 setObject:kCMISPropertyObjectTypeIdValueFolder forKey:kCMISPropertyObjectTypeId];
+    
+    // Setup test file
+    // Check if test file exists
+    NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"test_file.txt"
ofType:nil];
+    XCTAssertTrue([[NSFileManager defaultManager] fileExistsAtPath:filePath],
+                  @"Test file 'test_file.txt' cannot be found as resource for the test");
+    
+    // Upload test file
+    NSString *documentName = [NSString stringWithFormat:@"test_file_%@.txt", [self stringFromCurrentDate]];
+    NSMutableDictionary *documentProperties = [NSMutableDictionary dictionary];
+    [documentProperties setObject:documentName forKey:kCMISPropertyName];
+    [documentProperties setObject:kCMISPropertyObjectTypeIdValueDocument forKey:kCMISPropertyObjectTypeId];
+    
+    // Create container folder
+    [self.rootFolder createFolder:containerFolderProperties completionBlock:^(NSString *containerFolderId,
NSError *error) {
+        XCTAssertNil(error, @"Error while creating containerFolder in root folder: %@", [error
description]);
+        
+        // Create folder 1
+        [self.session createFolder:propertiesFolder1 inFolder:containerFolderId completionBlock:^(NSString
*folder1Id, NSError *error) {
+            XCTAssertNil(error, @"Error while creating folder1 in container folder: %@",
[error description]);
+            
+            [self.session retrieveObject:folder1Id completionBlock:^(CMISObject *object,
NSError *error) {
+                CMISFolder *folder1 = (CMISFolder *)object;
+                XCTAssertNil(error, @"Error while retrieving newly created folder: %@", [error
description]);
+                XCTAssertNotNil(folder1, @"New folder should not be nil");
+                
+                // Create folder 2
+                [self.session createFolder:propertiesFolder2 inFolder:containerFolderId completionBlock:^(NSString
*folder2Id, NSError *error) {
+                    XCTAssertNil(error, @"Error while creating folder2 in container folder:
%@", [error description]);
+                    
+                    [self.session retrieveObject:folder2Id completionBlock:^(CMISObject *object,
NSError *error) {
+                        CMISFolder *folder2 = (CMISFolder *)object;
+                        XCTAssertNil(error, @"Error while retrieving newly created folder:
%@", [error description]);
+                        XCTAssertNotNil(folder2, @"New folder should not be nil");
+                        
+                        
+                        [self.session createDocumentFromFilePath:filePath mimeType:@"text/plain"
+                                                      properties:documentProperties
+                                                        inFolder:folder1Id
+                                                 completionBlock:^(NSString *objectId, NSError
*error) {
+                                                     XCTAssertNil(error, @"Error while creating
document in folder1 folder: %@", [error description]);
+                                                     
+                                                     [self.session retrieveObject:objectId
completionBlock:^(CMISObject *object, NSError *error) {
+                                                         CMISDocument *document = (CMISDocument
*)object;
+                                                         XCTAssertNil(error, @"Error while
retrieving newly created document: %@", [error description]);
+                                                         XCTAssertNotNil(document, @"New
document should not be nil");
+                                                         
+                                                         completionBlock(containerFolderId,
folder1, folder2, document);
+                                                     }];
+                                                 } progressBlock:nil];
+                    }];
+                }];
+                
+            }];
+        }];
+    }];
+}
+
 - (void)testRetrieveAllVersionsOfDocument
 {
     [self runTest:^ {



Mime
View raw message