added auto-retrieval of CMISTypeDefinition (like in OpenCMIS), added support for 'versionable' and 'contentStreamAllowed' properties in CMISDocumentTypeDefinition
git-svn-id: https://svn.apache.org/repos/asf/chemistry/objectivecmis/trunk@1526505 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ObjectiveCMIS.xcodeproj/project.pbxproj b/ObjectiveCMIS.xcodeproj/project.pbxproj
index 9f746a2..5b3bfdc 100644
--- a/ObjectiveCMIS.xcodeproj/project.pbxproj
+++ b/ObjectiveCMIS.xcodeproj/project.pbxproj
@@ -186,6 +186,8 @@
BD5C9713162C11E3002DDC6E /* CMISHttpResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5C9711162C11E3002DDC6E /* CMISHttpResponse.h */; settings = {ATTRIBUTES = (Public, ); }; };
BD5C9714162C11E3002DDC6E /* CMISHttpResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = BD5C9712162C11E3002DDC6E /* CMISHttpResponse.m */; };
BD5C9715162C11E3002DDC6E /* CMISHttpResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = BD5C9712162C11E3002DDC6E /* CMISHttpResponse.m */; };
+ BD70F11B17F4649B00AE2B0C /* CMISDocumentTypeDefinition.h in Headers */ = {isa = PBXBuildFile; fileRef = BD70F11917F4649B00AE2B0C /* CMISDocumentTypeDefinition.h */; };
+ BD70F11C17F4649B00AE2B0C /* CMISDocumentTypeDefinition.m in Sources */ = {isa = PBXBuildFile; fileRef = BD70F11A17F4649B00AE2B0C /* CMISDocumentTypeDefinition.m */; };
FE21296415946B94005234FE /* CMISAuthenticationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 82C1C62A153426E4009B7B3D /* CMISAuthenticationProvider.h */; settings = {ATTRIBUTES = (Public, ); }; };
FE417D5715761A0C009056AA /* CMISOperationContext.h in Headers */ = {isa = PBXBuildFile; fileRef = FE417D5315761A0C009056AA /* CMISOperationContext.h */; settings = {ATTRIBUTES = (Public, ); }; };
FE417D5815761A0C009056AA /* CMISOperationContext.m in Sources */ = {isa = PBXBuildFile; fileRef = FE417D5415761A0C009056AA /* CMISOperationContext.m */; };
@@ -378,6 +380,8 @@
BD5C970D16282977002DDC6E /* CMISHttpDownloadRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = CMISHttpDownloadRequest.m; path = Utils/CMISHttpDownloadRequest.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
BD5C9711162C11E3002DDC6E /* CMISHttpResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CMISHttpResponse.h; path = Utils/CMISHttpResponse.h; sourceTree = "<group>"; };
BD5C9712162C11E3002DDC6E /* CMISHttpResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = CMISHttpResponse.m; path = Utils/CMISHttpResponse.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
+ BD70F11917F4649B00AE2B0C /* CMISDocumentTypeDefinition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CMISDocumentTypeDefinition.h; path = Bindings/CMISDocumentTypeDefinition.h; sourceTree = "<group>"; };
+ BD70F11A17F4649B00AE2B0C /* CMISDocumentTypeDefinition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CMISDocumentTypeDefinition.m; path = Bindings/CMISDocumentTypeDefinition.m; sourceTree = "<group>"; };
FE417D5315761A0C009056AA /* CMISOperationContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CMISOperationContext.h; path = Client/CMISOperationContext.h; sourceTree = "<group>"; };
FE417D5415761A0C009056AA /* CMISOperationContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CMISOperationContext.m; path = Client/CMISOperationContext.m; sourceTree = "<group>"; };
FE417D5515761A0C009056AA /* CMISPagedResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CMISPagedResult.h; path = Client/CMISPagedResult.h; sourceTree = "<group>"; };
@@ -618,6 +622,8 @@
8276E157155E392A00344A29 /* CMISRepositoryService.h */,
FE417D6115761A34009056AA /* CMISTypeDefinition.h */,
FE417D6215761A34009056AA /* CMISTypeDefinition.m */,
+ BD70F11917F4649B00AE2B0C /* CMISDocumentTypeDefinition.h */,
+ BD70F11A17F4649B00AE2B0C /* CMISDocumentTypeDefinition.m */,
8276E158155E392A00344A29 /* CMISVersioningService.h */,
8280730D1515405C00EF635C /* AtomPub */,
);
@@ -810,6 +816,7 @@
BD30D33D162D7DD7001FFF80 /* CMISRequest.h in Headers */,
278B269C177BB10B0049C229 /* CMISStandardAuthenticationProvider.h in Headers */,
278B269F177BB3000049C229 /* CMISStandardUntrustedSSLAuthenticationProvider.h in Headers */,
+ BD70F11B17F4649B00AE2B0C /* CMISDocumentTypeDefinition.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1021,6 +1028,7 @@
4E3C32A916C4EF190099B21E /* CMISAtomPubVersioningService.m in Sources */,
82895A1B16D8A8C5007BC80A /* CMISLog.m in Sources */,
278B26A0177BB3000049C229 /* CMISStandardUntrustedSSLAuthenticationProvider.m in Sources */,
+ BD70F11C17F4649B00AE2B0C /* CMISDocumentTypeDefinition.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubConstants.h b/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubConstants.h
index 7e759b0..d8cd488 100644
--- a/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubConstants.h
+++ b/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubConstants.h
@@ -156,6 +156,10 @@
extern NSString * const kCMISCoreRequired;
extern NSString * const kCMISCoreOrderable;
extern NSString * const kCMISCoreOpenChoice;
+extern NSString * const kCMISCoreVersionable;
+extern NSString * const kCMISCoreContentStreamAllowed;
+extern NSString * const kCMISCoreAllowed;
+extern NSString * const kCMISCoreNotAllowed;
extern NSString * const kCMISCorePropertyStringDefinition;
extern NSString * const kCMISCorePropertyIdDefinition;
diff --git a/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubConstants.m b/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubConstants.m
index e0ec87c..041b689 100644
--- a/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubConstants.m
+++ b/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubConstants.m
@@ -155,6 +155,10 @@
NSString * const kCMISCoreRequired = @"required";
NSString * const kCMISCoreOrderable = @"queryable";
NSString * const kCMISCoreOpenChoice = @"openChoice";
+NSString * const kCMISCoreVersionable = @"versionable";
+NSString * const kCMISCoreContentStreamAllowed = @"contentStreamAllowed";
+NSString * const kCMISCoreAllowed = @"allowed";
+NSString * const kCMISCoreNotAllowed = @"notallowed";
NSString * const kCMISCorePropertyStringDefinition = @"propertyStringDefinition";
NSString * const kCMISCorePropertyIdDefinition = @"propertyIdDefinition";
diff --git a/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m b/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m
index 6ea74fd..c806e54 100644
--- a/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m
+++ b/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m
@@ -19,6 +19,7 @@
#import "CMISTypeDefinitionAtomEntryParser.h"
#import "CMISTypeDefinition.h"
+#import "CMISDocumentTypeDefinition.h"
#import "CMISAtomPubConstants.h"
#import "CMISConstants.h"
@@ -70,7 +71,18 @@
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if ([elementName isEqualToString:kCMISRestAtomType]) {
- self.typeDefinition = [[CMISTypeDefinition alloc] init];
+ __block BOOL documentType = NO;
+ [attributeDict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+ if ([key hasSuffix:@"type"] && [obj hasSuffix:@"cmisTypeDocumentDefinitionType"]) {
+ documentType = YES;
+ }
+ }];
+
+ if (documentType) {
+ self.typeDefinition = [[CMISDocumentTypeDefinition alloc] init];
+ } else {
+ self.typeDefinition = [[CMISTypeDefinition alloc] init];
+ }
self.isParsingTypeDefinition = YES;
} else if ([elementName isEqualToString:kCMISCorePropertyStringDefinition]
|| [elementName isEqualToString:kCMISCorePropertyIdDefinition]
@@ -157,6 +169,20 @@
if (self.isParsingTypeDefinition) {
self.typeDefinition.controllablePolicy = [self.currentString.lowercaseString isEqualToString:kCMISAtomEntryValueTrue];
}
+ } else if ([elementName isEqualToString:kCMISCoreVersionable]) {
+ if (self.isParsingTypeDefinition && [self.typeDefinition isKindOfClass:CMISDocumentTypeDefinition.class]) {
+ ((CMISDocumentTypeDefinition*)self.typeDefinition).versionable = [self.currentString.lowercaseString isEqualToString:kCMISAtomEntryValueTrue];
+ }
+ } else if ([elementName isEqualToString:kCMISCoreContentStreamAllowed]) {
+ if (self.isParsingTypeDefinition && [self.typeDefinition isKindOfClass:CMISDocumentTypeDefinition.class]) {
+ if ([self.currentString isEqualToString:kCMISCoreAllowed]) {
+ ((CMISDocumentTypeDefinition*)self.typeDefinition).contentStreamAllowed = CMISContentStreamAllowed;
+ } else if ([self.currentString isEqualToString:kCMISCoreNotAllowed]) {
+ ((CMISDocumentTypeDefinition*)self.typeDefinition).contentStreamAllowed = CMISContentStreamNotAllowed;
+ } else if ([self.currentString isEqualToString:kCMISCoreRequired]) {
+ ((CMISDocumentTypeDefinition*)self.typeDefinition).contentStreamAllowed = CMISContentStreamRequired;
+ }
+ }
}
self.currentString = nil;
diff --git a/ObjectiveCMIS/Bindings/CMISDocumentTypeDefinition.h b/ObjectiveCMIS/Bindings/CMISDocumentTypeDefinition.h
new file mode 100644
index 0000000..03df2f2
--- /dev/null
+++ b/ObjectiveCMIS/Bindings/CMISDocumentTypeDefinition.h
@@ -0,0 +1,29 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import "CMISEnums.h"
+#import "CMISTypeDefinition.h"
+
+@interface CMISDocumentTypeDefinition : CMISTypeDefinition
+
+@property (nonatomic, assign, getter = isVersionable) BOOL versionable;
+@property (nonatomic, assign) CMISContentStreamAllowedType contentStreamAllowed;
+
+@end
diff --git a/ObjectiveCMIS/Bindings/CMISDocumentTypeDefinition.m b/ObjectiveCMIS/Bindings/CMISDocumentTypeDefinition.m
new file mode 100644
index 0000000..2332685
--- /dev/null
+++ b/ObjectiveCMIS/Bindings/CMISDocumentTypeDefinition.m
@@ -0,0 +1,24 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import "CMISDocumentTypeDefinition.h"
+
+@implementation CMISDocumentTypeDefinition
+
+@end
diff --git a/ObjectiveCMIS/Client/CMISDocument.m b/ObjectiveCMIS/Client/CMISDocument.m
index c1af8a4..b1612ff 100644
--- a/ObjectiveCMIS/Client/CMISDocument.m
+++ b/ObjectiveCMIS/Client/CMISDocument.m
@@ -76,7 +76,10 @@
CMISLogError(@"Error while retrieving all versions: %@", error.description);
completionBlock(nil, [CMISErrors cmisError:error cmisErrorCode:kCMISErrorCodeRuntime]);
} else {
- completionBlock([self.session.objectConverter convertObjects:objects], nil);
+ [self.session.objectConverter convertObjects:objects
+ completionBlock:^(NSArray *objects, NSError *error) {
+ completionBlock([[CMISCollection alloc] initWithItems:objects], error);
+ }];
}
}];
}
@@ -142,7 +145,10 @@
if (error) {
completionBlock(nil, [CMISErrors cmisError:error cmisErrorCode:kCMISErrorCodeRuntime]);
} else {
- completionBlock((CMISDocument *) [self.session.objectConverter convertObject:objectData], nil);
+ [self.session.objectConverter convertObject:objectData
+ completionBlock:^(CMISObject *object, NSError *error) {
+ completionBlock((CMISDocument *)object, error);
+ }];
}
}];
}
diff --git a/ObjectiveCMIS/Client/CMISFileableObject.m b/ObjectiveCMIS/Client/CMISFileableObject.m
index 3cd30a5..1b76a6b 100644
--- a/ObjectiveCMIS/Client/CMISFileableObject.m
+++ b/ObjectiveCMIS/Client/CMISFileableObject.m
@@ -40,13 +40,10 @@
includeAllowableActions:operationContext.includeAllowableActions
includeRelativePathSegment:operationContext.includePathSegments
completionBlock:^(NSArray *parentObjectDataArray, NSError *error) {
- NSMutableArray *parentFolders = [NSMutableArray array];
- for (CMISObjectData *parentObjectData in parentObjectDataArray){
- [parentFolders addObject:[self.session.objectConverter convertObject:parentObjectData]];
- }
-
- completionBlock(parentFolders, error);
-
+ [self.session.objectConverter convertObjects:parentObjectDataArray
+ completionBlock:^(NSArray *objects, NSError *error) {
+ completionBlock(objects, error);
+ }];
}];
}
diff --git a/ObjectiveCMIS/Client/CMISFolder.m b/ObjectiveCMIS/Client/CMISFolder.m
index 78d73b7..6fdaed8 100644
--- a/ObjectiveCMIS/Client/CMISFolder.m
+++ b/ObjectiveCMIS/Client/CMISFolder.m
@@ -96,8 +96,11 @@
result.hasMoreItems = objectList.hasMoreItems;
result.numItems = objectList.numItems;
- result.resultArray = [self.session.objectConverter convertObjects:objectList.objects].items;
- pageBlockCompletionBlock(result, nil);
+ [self.session.objectConverter convertObjects:objectList.objects
+ completionBlock:^(NSArray *objects, NSError *error) {
+ result.resultArray = objects;
+ pageBlockCompletionBlock(result, error);
+ }];
}
}];
};
diff --git a/ObjectiveCMIS/Client/CMISObject.h b/ObjectiveCMIS/Client/CMISObject.h
index b3f7f64..73ce66c 100644
--- a/ObjectiveCMIS/Client/CMISObject.h
+++ b/ObjectiveCMIS/Client/CMISObject.h
@@ -36,6 +36,7 @@
@property (nonatomic, strong, readonly) NSDate *lastModificationDate;
@property (nonatomic, strong, readonly) NSString *objectType;
@property (nonatomic, strong, readonly) NSString *changeToken;
+@property (nonatomic, strong, readonly) CMISTypeDefinition *typeDefinition;
//@property (nonatomic, strong, readonly) CMISBaseTypeId *baseTypeId;
//@property (nonatomic, strong, readonly) CMISObjectType *baseType;
//@property (nonatomic, strong, readonly) CMISObjectType *type;
@@ -50,6 +51,12 @@
- (id)initWithObjectData:(CMISObjectData *)objectData session:(CMISSession *)session;
/**
+ * set the typeDefinition property initally
+ */
+- (void)fetchTypeDefinitionWithCompletionBlock:(void (^)(NSError *error))completionBlock;
+
+
+/**
* Updates the properties that are provided.
* completionBlock returns the updated CMISObject instance or nil if unsuccessful
*/
diff --git a/ObjectiveCMIS/Client/CMISObject.m b/ObjectiveCMIS/Client/CMISObject.m
index 3e87704..30652df 100644
--- a/ObjectiveCMIS/Client/CMISObject.m
+++ b/ObjectiveCMIS/Client/CMISObject.m
@@ -25,6 +25,8 @@
#import "CMISSession.h"
#import "CMISRenditionData.h"
#import "CMISRendition.h"
+#import "CMISLog.h"
+
@interface CMISObject ()
@@ -39,6 +41,7 @@
@property (nonatomic, strong, readwrite) NSDate *lastModificationDate;
@property (nonatomic, strong, readwrite) NSString *objectType;
@property (nonatomic, strong, readwrite) NSString *changeToken;
+@property (nonatomic, strong, readwrite) CMISTypeDefinition *typeDefinition;
@property (nonatomic, strong, readwrite) CMISProperties *properties;
@property (nonatomic, strong, readwrite) CMISAllowableActions *allowableActions;
@@ -89,6 +92,29 @@
return self;
}
+
+- (void)fetchTypeDefinitionWithCompletionBlock:(void (^)(NSError *error))completionBlock
+{
+ if (self.typeDefinition) {
+ if (completionBlock) {
+ completionBlock(nil);
+ }
+ } else {
+ [self.session retrieveTypeDefinition:self.objectType
+ completionBlock:^(CMISTypeDefinition *typeDefinition, NSError *error) {
+ if (error == nil) {
+ self.typeDefinition = typeDefinition;
+ } else {
+ CMISLogError(@"Error while fetching type definiton for object type %@: %@", self.objectType, error.description);
+ }
+ if (completionBlock) {
+ completionBlock(error);
+ }
+ }];
+ }
+}
+
+
- (NSArray *)nonNilArray:(NSArray *)aArray
{ // Move to category on NSArray?
return ((aArray == nil) ? [NSArray array] : aArray);
diff --git a/ObjectiveCMIS/Client/CMISSession.m b/ObjectiveCMIS/Client/CMISSession.m
index 9998c98..bd871e5 100644
--- a/ObjectiveCMIS/Client/CMISSession.m
+++ b/ObjectiveCMIS/Client/CMISSession.m
@@ -217,9 +217,13 @@
} else {
CMISObject *object = nil;
if (objectData) {
- object = [self.objectConverter convertObject:objectData];
+ [self.objectConverter convertObject:objectData
+ completionBlock:^(CMISObject *object, NSError *error) {
+ completionBlock(object, error);
+ }];
+ } else {
+ completionBlock(object, nil);
}
- completionBlock(object, nil);
}
}];
}
@@ -241,8 +245,11 @@
includeACL:operationContext.includeACLs
includeAllowableActions:operationContext.includeAllowableActions
completionBlock:^(CMISObjectData *objectData, NSError *error) {
- if (objectData != nil && error == nil) {
- completionBlock([self.objectConverter convertObject:objectData], nil);
+ if (objectData != nil && error == nil) {
+ [self.objectConverter convertObject:objectData
+ completionBlock:^(CMISObject *object, NSError *error) {
+ completionBlock(object, error);
+ }];
} else {
if (error == nil) {
NSError *error = [[NSError alloc] init];
@@ -368,13 +375,11 @@
result.hasMoreItems = objectList.hasMoreItems;
result.numItems = objectList.numItems;
- NSMutableArray *resultArray = [[NSMutableArray alloc] init];
- result.resultArray = resultArray;
- for (CMISObjectData *objectData in objectList.objects)
- {
- [resultArray addObject:[self.objectConverter convertObject:objectData]];
- }
- pageBlockCompletionBlock(result, nil);
+ [self.objectConverter convertObjects:objectList.objects
+ completionBlock:^(NSArray *objects, NSError *error) {
+ result.resultArray = objects;
+ pageBlockCompletionBlock(result, error);
+ }];
}
}];
};
diff --git a/ObjectiveCMIS/Common/CMISEnums.h b/ObjectiveCMIS/Common/CMISEnums.h
index 082e245..aa156ee 100644
--- a/ObjectiveCMIS/Common/CMISEnums.h
+++ b/ObjectiveCMIS/Common/CMISEnums.h
@@ -134,6 +134,14 @@
CMISDelete, // default
} CMISUnfileObject;
+// ContentStreamAllowed
+typedef enum
+{
+ CMISContentStreamNotAllowed,
+ CMISContentStreamAllowed,
+ CMISContentStreamRequired
+} CMISContentStreamAllowedType;
+
@interface CMISEnums : NSObject
+ (NSString *)stringForIncludeRelationShip:(CMISIncludeRelationship)includeRelationship;
diff --git a/ObjectiveCMIS/Utils/CMISObjectConverter.h b/ObjectiveCMIS/Utils/CMISObjectConverter.h
index bd85484..282e5f1 100644
--- a/ObjectiveCMIS/Utils/CMISObjectConverter.h
+++ b/ObjectiveCMIS/Utils/CMISObjectConverter.h
@@ -20,7 +20,6 @@
#import <Foundation/Foundation.h>
#import "CMISObject.h"
#import "CMISObjectData.h"
-#import "CMISCollection.h"
@class CMISSession;
@@ -28,8 +27,8 @@
- (id)initWithSession:(CMISSession *)session;
-- (CMISObject *)convertObject:(CMISObjectData *)objectData;
-- (CMISCollection *)convertObjects:(NSArray *)objects;
+- (void)convertObject:(CMISObjectData *)objectData completionBlock:(void (^)(CMISObject *object, NSError *error))completionBlock;
+- (void)convertObjects:(NSArray *)objectDatas completionBlock:(void (^)(NSArray *objects, NSError *error))completionBlock;
/**
* Converts the given dictionary of properties, where the key is the property id and the value
diff --git a/ObjectiveCMIS/Utils/CMISObjectConverter.m b/ObjectiveCMIS/Utils/CMISObjectConverter.m
index 29c69ab..1181a64 100644
--- a/ObjectiveCMIS/Utils/CMISObjectConverter.m
+++ b/ObjectiveCMIS/Utils/CMISObjectConverter.m
@@ -45,7 +45,7 @@
return self;
}
-- (CMISObject *)convertObject:(CMISObjectData *)objectData
+- (void)convertObject:(CMISObjectData *)objectData completionBlock:(void (^)(CMISObject *object, NSError *error))completionBlock
{
CMISObject *object = nil;
@@ -55,21 +55,41 @@
object = [[CMISFolder alloc] initWithObjectData:objectData session:self.session];
}
- return object;
+ [object fetchTypeDefinitionWithCompletionBlock:^(NSError *error) {
+ completionBlock(object, error);
+ }];
}
-- (CMISCollection *)convertObjects:(NSArray *)objects
+
+- (void)internalConvertObject:(NSArray *)objectDatas position:(NSInteger)position completionBlock:(void (^)(NSMutableArray *objects, NSError *error))completionBlock
{
- NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:[objects count]];
-
- for (CMISObjectData *object in objects) {
- [items addObject:[self convertObject:object]];
+ [self convertObject:[objectDatas objectAtIndex:position]
+ completionBlock:^(CMISObject *object, NSError *error) {
+ if (position == 0) {
+ NSMutableArray *objects = [[NSMutableArray alloc] initWithCapacity:objectDatas.count];
+ [objects addObject:object];
+ completionBlock(objects, error);
+ } else {
+ [self internalConvertObject:objectDatas position:(position - 1) completionBlock:^(NSMutableArray *objects, NSError *error) {
+ [objects addObject:object];
+ completionBlock(objects, error);
+ }];
+ }
+ }];
+}
+
+
+- (void)convertObjects:(NSArray *)objectDatas completionBlock:(void (^)(NSArray *objects, NSError *error))completionBlock
+{
+ if (objectDatas.count > 0) {
+ [self internalConvertObject:objectDatas
+ position:(objectDatas.count - 1) // start recursion with last item
+ completionBlock:^(NSMutableArray *objects, NSError *error) {
+ completionBlock(objects, error);
+ }];
+ } else {
+ completionBlock([[NSArray alloc] init], nil);
}
-
- // create the collection
- CMISCollection *collection = [[CMISCollection alloc] initWithItems:items];
-
- return collection;
}
diff --git a/ObjectiveCMISTests/ObjectiveCMISTests.m b/ObjectiveCMISTests/ObjectiveCMISTests.m
index ad8ca22..cc86a51 100644
--- a/ObjectiveCMISTests/ObjectiveCMISTests.m
+++ b/ObjectiveCMISTests/ObjectiveCMISTests.m
@@ -353,7 +353,7 @@
NSError *fileError = nil;
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:&fileError];
STAssertNil(fileError, @"Could not verify attributes of file %@: %@", filePath, [fileError description]);
- STAssertTrue([fileAttributes fileSize] > 10, @"Expected a file of at least 10 bytes, but found one of %d bytes", [fileAttributes fileSize]);
+ STAssertTrue([fileAttributes fileSize] >= 10, @"Expected a file of at least 10 bytes, but found one of %d bytes", [fileAttributes fileSize]);
// Nice boys clean up after themselves
[[NSFileManager defaultManager] removeItemAtPath:filePath error:&fileError];