You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2012/12/26 11:48:37 UTC

svn commit: r1425870 [7/13] - in /chemistry/objectivecmis/trunk: ./ ObjectiveCMIS.xcodeproj/ ObjectiveCMIS.xcodeproj/project.xcworkspace/ ObjectiveCMIS/ ObjectiveCMIS/Bindings/ ObjectiveCMIS/Bindings/AtomPub/ ObjectiveCMIS/Bindings/AtomPub/AtomPubParse...

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISDocument.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISDocument.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISDocument.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISDocument.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,168 @@
+/*
+    Licensed 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 "CMISDocument.h"
+#import "CMISConstants.h"
+#import "CMISHttpUtil.h"
+#import "CMISObjectConverter.h"
+#import "CMISStringInOutParameter.h"
+#import "CMISOperationContext.h"
+#import "CMISFileUtil.h"
+#import "CMISErrors.h"
+#import "CMISRequest.h"
+#import "CMISSession.h"
+
+@interface CMISDocument()
+
+@property (nonatomic, strong, readwrite) NSString *contentStreamId;
+@property (nonatomic, strong, readwrite) NSString *contentStreamFileName;
+@property (nonatomic, strong, readwrite) NSString *contentStreamMediaType;
+@property (readwrite) unsigned long long contentStreamLength;
+
+@property (nonatomic, strong, readwrite) NSString *versionLabel;
+@property (readwrite) BOOL isLatestVersion;
+@property (readwrite) BOOL isMajorVersion;
+@property (readwrite) BOOL isLatestMajorVersion;
+@property (nonatomic, strong, readwrite) NSString *versionSeriesId;
+
+@end
+
+@implementation CMISDocument
+
+@synthesize contentStreamId = _contentStreamId;
+@synthesize contentStreamFileName = _contentStreamFileName;
+@synthesize contentStreamMediaType = _contentStreamMediaType;
+@synthesize contentStreamLength = _contentStreamLength;
+@synthesize versionLabel = _versionLabel;
+@synthesize isLatestVersion = _isLatestVersion;
+@synthesize isMajorVersion = _isMajorVersion;
+@synthesize versionSeriesId = _versionSeriesId;
+@synthesize isLatestMajorVersion = _isLatestMajorVersion;
+
+- (id)initWithObjectData:(CMISObjectData *)objectData withSession:(CMISSession *)session
+{
+    self = [super initWithObjectData:objectData withSession:session];
+    if (self)
+    {
+        self.contentStreamId = [[objectData.properties.propertiesDictionary objectForKey:kCMISProperyContentStreamId] firstValue];
+        self.contentStreamMediaType = [[objectData.properties.propertiesDictionary objectForKey:kCMISPropertyContentStreamMediaType] firstValue];
+        self.contentStreamLength = [[[objectData.properties.propertiesDictionary objectForKey:kCMISPropertyContentStreamLength] firstValue] unsignedLongLongValue];
+        self.contentStreamFileName = [[objectData.properties.propertiesDictionary objectForKey:kCMISPropertyContentStreamFileName] firstValue];
+
+        self.versionLabel = [[objectData.properties.propertiesDictionary objectForKey:kCMISPropertyVersionLabel] firstValue];
+        self.versionSeriesId = [[objectData.properties.propertiesDictionary objectForKey:kCMISPropertyVersionSeriesId] firstValue];
+        self.isLatestVersion = [[[objectData.properties.propertiesDictionary objectForKey:kCMISPropertyIsLatestVersion] firstValue] boolValue];
+        self.isLatestMajorVersion = [[[objectData.properties.propertiesDictionary objectForKey:kCMISPropertyIsLatestMajorVersion] firstValue] boolValue];
+        self.isMajorVersion = [[[objectData.properties.propertiesDictionary objectForKey:kCMISPropertyIsMajorVersion] firstValue] boolValue];
+    }
+    return self;
+}
+
+- (void)retrieveAllVersionsWithCompletionBlock:(void (^)(CMISCollection *allVersionsOfDocument, NSError *error))completionBlock
+{
+    [self retrieveAllVersionsWithOperationContext:[CMISOperationContext defaultOperationContext] completionBlock:completionBlock];
+}
+
+- (void)retrieveAllVersionsWithOperationContext:(CMISOperationContext *)operationContext completionBlock:(void (^)(CMISCollection *collection, NSError *error))completionBlock
+{
+    [self.binding.versioningService retrieveAllVersions:self.identifier
+           filter:operationContext.filterString includeAllowableActions:operationContext.isIncludeAllowableActions completionBlock:^(NSArray *objects, NSError *error) {
+               if (error) {
+                   log(@"Error while retrieving all versions: %@", error.description);
+                   completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+               } else {
+                   completionBlock([self.session.objectConverter convertObjects:objects], nil);
+               }
+           }];
+}
+
+- (CMISRequest*)changeContentToContentOfFile:(NSString *)filePath withOverwriteExisting:(BOOL)overwrite
+                             completionBlock:(void (^)(NSError *error))completionBlock
+                               progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
+{
+    return [self.binding.objectService changeContentOfObject:[CMISStringInOutParameter inOutParameterUsingInParameter:self.identifier]
+                                             toContentOfFile:filePath
+                                       withOverwriteExisting:overwrite
+                                             withChangeToken:[CMISStringInOutParameter inOutParameterUsingInParameter:self.changeToken]
+                                             completionBlock:completionBlock
+                                               progressBlock:progressBlock];
+}
+
+- (CMISRequest*)changeContentToContentOfInputStream:(NSInputStream *)inputStream
+                                      bytesExpected:(unsigned long long)bytesExpected
+                                       withFileName:(NSString *)filename
+                              withOverwriteExisting:(BOOL)overwrite
+                                    completionBlock:(void (^)(NSError *error))completionBlock
+                                      progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
+{
+    return [self.binding.objectService changeContentOfObject:[CMISStringInOutParameter inOutParameterUsingInParameter:self.identifier]
+                                      toContentOfInputStream:inputStream
+                                               bytesExpected:bytesExpected
+                                                withFilename:filename
+                                       withOverwriteExisting:overwrite
+                                             withChangeToken:[CMISStringInOutParameter inOutParameterUsingInParameter:self.changeToken]
+                                             completionBlock:completionBlock
+                                               progressBlock:progressBlock];
+}
+
+- (void)deleteContentWithCompletionBlock:(void (^)(NSError *error))completionBlock
+{
+    [self.binding.objectService deleteContentOfObject:[CMISStringInOutParameter inOutParameterUsingInParameter:self.identifier]
+                                      withChangeToken:[CMISStringInOutParameter inOutParameterUsingInParameter:self.changeToken]
+                                      completionBlock:completionBlock];
+}
+
+- (void)retrieveObjectOfLatestVersionWithMajorVersion:(BOOL)major completionBlock:(void (^)(CMISDocument *document, NSError *error))completionBlock
+{
+    [self retrieveObjectOfLatestVersionWithMajorVersion:major withOperationContext:[CMISOperationContext defaultOperationContext] completionBlock:completionBlock];
+}
+
+- (void)retrieveObjectOfLatestVersionWithMajorVersion:(BOOL)major
+                                 withOperationContext:(CMISOperationContext *)operationContext
+                                      completionBlock:(void (^)(CMISDocument *document, NSError *error))completionBlock
+{
+    [self.binding.versioningService retrieveObjectOfLatestVersion:self.identifier
+                                                            major:major filter:operationContext.filterString
+                                             includeRelationShips:operationContext.includeRelationShips
+                                                 includePolicyIds:operationContext.isIncludePolicies
+                                                  renditionFilter:operationContext.renditionFilterString
+                                                       includeACL:operationContext.isIncluseACLs
+                                          includeAllowableActions:operationContext.isIncludeAllowableActions
+                                                  completionBlock:^(CMISObjectData *objectData, NSError *error) {
+            if (error) {
+                completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+            } else {
+                completionBlock((CMISDocument *) [self.session.objectConverter convertObject:objectData], nil);
+            }
+        }];
+}
+
+- (CMISRequest*)downloadContentToFile:(NSString *)filePath
+                      completionBlock:(void (^)(NSError *error))completionBlock
+                        progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock
+{
+    NSOutputStream *outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:NO];
+    return [self.binding.objectService downloadContentOfObject:self.identifier
+                                                  withStreamId:nil
+                                                toOutputStream:outputStream
+                                               completionBlock:completionBlock
+                                                 progressBlock:progressBlock];
+}
+
+- (void)deleteAllVersionsWithCompletionBlock:(void (^)(BOOL documentDeleted, NSError *error))completionBlock
+{
+    [self.binding.objectService deleteObject:self.identifier allVersions:YES completionBlock:completionBlock];
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISDocument.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFileableObject.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFileableObject.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFileableObject.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFileableObject.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,37 @@
+/*
+    Licensed 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 "CMISObject.h"
+
+@class CMISOperationContext;
+
+@interface CMISFileableObject : CMISObject
+
+/**
+* Returns all the parents of this object as an array of CMISFolder objects.
+*
+* Will be nil for root folder and non-fileable objects.
+*/
+- (void)retrieveParentsWithCompletionBlock:(void (^)(NSArray *parentFolders, NSError *error))completionBlock;
+
+/**
+* Returns all the parents of this object as an array of CMISFolder objects.
+*
+* Will be nil for root folder and non-fileable objects.
+*/
+- (void)retrieveParentsWithOperationContext:(CMISOperationContext *)operationContext 
+                            completionBlock:(void (^)(NSArray *parentFolders, NSError *error))completionBlock;
+
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFileableObject.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFileableObject.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFileableObject.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFileableObject.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFileableObject.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,49 @@
+/*
+    Licensed 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 "CMISFileableObject.h"
+#import "CMISObjectConverter.h"
+#import "CMISOperationContext.h"
+#import "CMISSession.h"
+
+@implementation CMISFileableObject
+
+
+- (void)retrieveParentsWithCompletionBlock:(void (^)(NSArray *parentFolders, NSError *error))completionBlock
+{
+    return [self retrieveParentsWithOperationContext:[CMISOperationContext defaultOperationContext] completionBlock:completionBlock];
+}
+
+- (void)retrieveParentsWithOperationContext:(CMISOperationContext *)operationContext
+                            completionBlock:(void (^)(NSArray *parentFolders, NSError *error))completionBlock
+{
+    [self.binding.navigationService retrieveParentsForObject:self.identifier
+                                                  withFilter:operationContext.filterString
+                                    withIncludeRelationships:operationContext.includeRelationShips
+                                         withRenditionFilter:operationContext.renditionFilterString
+                                 withIncludeAllowableActions:operationContext.isIncludeAllowableActions
+                              withIncludeRelativePathSegment:operationContext.isIncludePathSegments
+                                             completionBlock:^(NSArray *parentObjectDataArray, NSError *error) {
+                                                 NSMutableArray *parentFolders = [NSMutableArray array];
+                                                 for (CMISObjectData *parentObjectData in parentObjectDataArray)
+                                                 {
+                                                     [parentFolders addObject:[self.session.objectConverter convertObject:parentObjectData]];
+                                                 }
+                                                 
+                                                 completionBlock(parentFolders, error);
+                                                 
+                                             }];
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFileableObject.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,67 @@
+/*
+    Licensed 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 "CMISFileableObject.h"
+#import "CMISCollection.h"
+
+@class CMISDocument;
+@class CMISPagedResult;
+@class CMISOperationContext;
+
+@interface CMISFolder : CMISFileableObject
+
+@property (nonatomic, strong, readonly) NSString *path;
+
+/**
+ * Retrieves the children of this folder as a paged result.
+ *
+ * The returned objects will be instances of CMISObject.
+ */
+- (void)retrieveChildrenWithCompletionBlock:(void (^)(CMISPagedResult *result, NSError *error))completionBlock;
+
+/**
+ * Checks if this folder is the root folder.
+ */
+- (BOOL)isRootFolder;
+
+/**
+ * Gets the parent folder object.
+ */
+- (void)retrieveFolderParentWithCompletionBlock:(void (^)(CMISFolder *folder, NSError *error))completionBlock;
+
+/**
+ * Retrieves the children of this folder as a paged result using the provided operation context.
+ *
+ * The returned objects will be instances of CMISObject.
+ */
+- (void)retrieveChildrenWithOperationContext:(CMISOperationContext *)operationContext completionBlock:(void (^)(CMISPagedResult *result, NSError *error))completionBlock;
+
+- (void)createFolder:(NSDictionary *)properties completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock;
+
+- (void)createDocumentFromFilePath:(NSString *)filePath
+                      withMimeType:(NSString *)mimeType
+                    withProperties:(NSDictionary *)properties
+                   completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
+                     progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock;
+
+- (void)deleteTreeWithDeleteAllVersions:(BOOL)deleteAllversions
+                      withUnfileObjects:(CMISUnfileObject)unfileObjects
+                  withContinueOnFailure:(BOOL)continueOnFailure
+                        completionBlock:(void (^)(NSArray *failedObjects, NSError *error))completionBlock;
+
+
+@end
+
+

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,162 @@
+/*
+    Licensed 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 "CMISFolder.h"
+#import "CMISObjectConverter.h"
+#import "CMISConstants.h"
+#import "CMISErrors.h"
+#import "CMISPagedResult.h"
+#import "CMISOperationContext.h"
+#import "CMISObjectList.h"
+#import "CMISSession.h"
+
+@interface CMISFolder ()
+
+@property (nonatomic, strong, readwrite) NSString *path;
+@property (nonatomic, strong, readwrite) CMISCollection *children;
+@end
+
+@implementation CMISFolder
+
+@synthesize path = _path;
+@synthesize children = _children;
+
+- (id)initWithObjectData:(CMISObjectData *)objectData withSession:(CMISSession *)session
+{
+    self = [super initWithObjectData:objectData withSession:session];
+    if (self)
+    {
+        self.path = [[objectData.properties propertyForId:kCMISPropertyPath] firstValue];
+    }
+    return self;
+}
+
+- (void)retrieveChildrenWithCompletionBlock:(void (^)(CMISPagedResult *result, NSError *error))completionBlock
+{
+    [self retrieveChildrenWithOperationContext:[CMISOperationContext defaultOperationContext] completionBlock:completionBlock];
+}
+
+- (BOOL)isRootFolder
+{
+    return [self.identifier isEqualToString:self.session.repositoryInfo.rootFolderId];
+}
+
+- (void)retrieveFolderParentWithCompletionBlock:(void (^)(CMISFolder *folder, NSError *error))completionBlock
+{
+    if ([self isRootFolder])
+    {
+        completionBlock(nil, nil);
+    } else {
+        [self retrieveParentsWithCompletionBlock:^(NSArray *parentFolders, NSError *error) {
+            if (parentFolders.count > 0) {
+                completionBlock([parentFolders objectAtIndex:0], error);
+            } else {
+                completionBlock(nil, error);
+            }
+        }];
+    }
+}
+
+- (void)retrieveChildrenWithOperationContext:(CMISOperationContext *)operationContext completionBlock:(void (^)(CMISPagedResult *result, NSError *error))completionBlock
+{
+    CMISFetchNextPageBlock fetchNextPageBlock = ^(int skipCount, int maxItems, CMISFetchNextPageBlockCompletionBlock pageBlockCompletionBlock)
+    {
+        // Fetch results through navigationService
+        [self.binding.navigationService retrieveChildren:self.identifier
+                                                 orderBy:operationContext.orderBy
+                                                  filter:operationContext.filterString
+                                    includeRelationShips:operationContext.includeRelationShips
+                                         renditionFilter:operationContext.renditionFilterString
+                                 includeAllowableActions:operationContext.isIncludeAllowableActions
+                                      includePathSegment:operationContext.isIncludePathSegments
+                                               skipCount:[NSNumber numberWithInt:skipCount]
+                                                maxItems:[NSNumber numberWithInt:maxItems]
+                                         completionBlock:^(CMISObjectList *objectList, NSError *error) {
+                                             if (error) {
+                                                 pageBlockCompletionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeConnection]);
+                                             } else {
+                                                 CMISFetchNextPageBlockResult *result = [[CMISFetchNextPageBlockResult alloc] init];
+                                                 result.hasMoreItems = objectList.hasMoreItems;
+                                                 result.numItems = objectList.numItems;
+                                             
+                                                 result.resultArray = [self.session.objectConverter convertObjects:objectList.objects].items;
+                                                 pageBlockCompletionBlock(result, nil);
+                                             }
+                                         }];
+    };
+
+    [CMISPagedResult pagedResultUsingFetchBlock:fetchNextPageBlock
+                             andLimitToMaxItems:operationContext.maxItemsPerPage
+                          andStartFromSkipCount:operationContext.skipCount
+                          completionBlock:^(CMISPagedResult *result, NSError *error) {
+                              if (error) {
+                                  completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+                              } else {
+                                  completionBlock(result, nil);
+                              }
+                          }];
+}
+
+- (void)createFolder:(NSDictionary *)properties completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
+{
+    [self.session.objectConverter convertProperties:properties
+                                    forObjectTypeId:[properties objectForKey:kCMISPropertyObjectTypeId]
+                                    completionBlock:^(CMISProperties *properties, NSError *error) {
+                     if (error) {
+                         completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+                     } else {
+                         [self.binding.objectService createFolderInParentFolder:self.identifier
+                                                                 withProperties:properties
+                                                                completionBlock:^(NSString *objectId, NSError *error) {
+                                                                    completionBlock(objectId, error);
+                                                                }];
+                     }
+                 }];
+}
+
+- (void)createDocumentFromFilePath:(NSString *)filePath
+                      withMimeType:(NSString *)mimeType
+                    withProperties:(NSDictionary *)properties
+                   completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
+                     progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
+{
+    [self.session.objectConverter convertProperties:properties
+                                    forObjectTypeId:[properties objectForKey:kCMISPropertyObjectTypeId]
+                                    completionBlock:^(CMISProperties *convertedProperties, NSError *error) {
+        if (error) {
+            log(@"Could not convert properties: %@", error.description);
+            if (completionBlock) {
+                completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+            }
+        } else {
+            [self.binding.objectService createDocumentFromFilePath:filePath
+                                                      withMimeType:mimeType
+                                                    withProperties:convertedProperties
+                                                          inFolder:self.identifier
+                                                   completionBlock:completionBlock
+                                                     progressBlock:progressBlock];
+        }
+    }];
+}
+
+- (void)deleteTreeWithDeleteAllVersions:(BOOL)deleteAllversions
+                           withUnfileObjects:(CMISUnfileObject)unfileObjects
+                       withContinueOnFailure:(BOOL)continueOnFailure
+                             completionBlock:(void (^)(NSArray *failedObjects, NSError *error))completionBlock
+{
+    [self.binding.objectService deleteTree:self.identifier allVersion:deleteAllversions
+                                    unfileObjects:unfileObjects continueOnFailure:continueOnFailure completionBlock:completionBlock];
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISFolder.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObject.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObject.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObject.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObject.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,62 @@
+/*
+    Licensed 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 "CMISObjectData.h"
+#import "CMISBinding.h"
+#import "CMISObjectId.h"
+
+@class CMISSession;
+
+@interface CMISObject : CMISObjectId
+
+@property (nonatomic, strong, readonly) CMISSession *session;
+@property (nonatomic, strong, readonly) id<CMISBinding> binding;
+
+@property (nonatomic, strong, readonly) NSString *name;
+@property (nonatomic, strong, readonly) NSString *createdBy;
+@property (nonatomic, strong, readonly) NSDate *creationDate;
+@property (nonatomic, strong, readonly) NSString *lastModifiedBy;
+@property (nonatomic, strong, readonly) NSDate *lastModificationDate;
+@property (nonatomic, strong, readonly) NSString *objectType;
+@property (nonatomic, strong, readonly) NSString *changeToken;
+//@property (nonatomic, strong, readonly) CMISBaseTypeId *baseTypeId;
+//@property (nonatomic, strong, readonly) CMISObjectType *baseType;
+//@property (nonatomic, strong, readonly) CMISObjectType *type;
+@property (nonatomic, strong, readonly) CMISAllowableActions *allowableActions;
+@property (nonatomic, strong, readonly) NSArray *renditions; // An array containing CMISRendition objects
+
+@property (nonatomic, strong, readonly) CMISProperties *properties;
+
+- (id)initWithObjectData:(CMISObjectData *)objectData withSession:(CMISSession *)session;
+
+/**
+ * Updates the properties that are provided.
+ *
+ * @param properties The properties to update. The key should be the property id.
+ *                   The value can be an instance of CMISPropertyData, or a regular string.
+ *                   If it is a string, a conversion to the CMISPropertyData will be done for you,
+ *                   but keep in mind that this can trigger another remote call to the server to fetch the type info.
+ *
+ * @return the updated object (a repository might have created a new version of the object)
+*/
+- (void)updateProperties:(NSDictionary *)properties completionBlock:(void (^)(CMISObject *object, NSError *error))completionBlock;
+
+/**
+ * Returns the extensions for the given level as an array of CMISExtensionElement
+ */
+- (NSArray *)extensionsForExtensionLevel:(CMISExtensionLevel)extensionLevel;
+
+@end
+

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObject.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObject.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObject.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObject.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObject.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,156 @@
+/*
+    Licensed 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 "CMISObject.h"
+#import "CMISConstants.h"
+#import "CMISErrors.h"
+#import "CMISObjectConverter.h"
+#import "CMISStringInOutParameter.h"
+#import "CMISSession.h"
+#import "CMISRenditionData.h"
+#import "CMISRendition.h"
+
+@interface CMISObject ()
+
+@property (nonatomic, strong, readwrite) CMISSession *session;
+@property (nonatomic, strong, readwrite) id<CMISBinding> binding;
+
+@property (nonatomic, strong, readwrite) NSString *identifier;
+@property (nonatomic, strong, readwrite) NSString *name;
+@property (nonatomic, strong, readwrite) NSString *createdBy;
+@property (nonatomic, strong, readwrite) NSDate *creationDate;
+@property (nonatomic, strong, readwrite) NSString *lastModifiedBy;
+@property (nonatomic, strong, readwrite) NSDate *lastModificationDate;
+@property (nonatomic, strong, readwrite) NSString *objectType;
+@property (nonatomic, strong, readwrite) NSString *changeToken;
+
+@property (nonatomic, strong, readwrite) CMISProperties *properties;
+@property (nonatomic, strong, readwrite) CMISAllowableActions *allowableActions;
+@property (nonatomic, strong, readwrite) NSArray *renditions;
+
+@property (nonatomic, strong) NSMutableDictionary *extensionsDict;
+
+// returns a non-nil NSArray
+- (NSArray *)nonNilArray:(NSArray *)aArray;
+@end
+
+@implementation CMISObject
+
+@synthesize session = _session;
+@synthesize binding = _binding;
+@synthesize identifier = _identifier;
+@synthesize name = _name;
+@synthesize createdBy = _createdBy;
+@synthesize creationDate = _creationDate;
+@synthesize lastModifiedBy = _lastModifiedBy;
+@synthesize lastModificationDate = _lastModificationDate;
+@synthesize objectType = _objectType;
+@synthesize changeToken = _changeToken;
+@synthesize properties = _properties;
+@synthesize allowableActions = _allowableActions;
+@synthesize renditions = _renditions;
+@synthesize extensionsDict = _extensionsDict;
+
+- (id)initWithObjectData:(CMISObjectData *)objectData withSession:(CMISSession *)session
+{
+    self =  [super initWithString:objectData.identifier];
+    if (self)
+    {
+        self.session = session;
+        self.binding = session.binding;
+
+        self.properties = objectData.properties;
+        self.name = [[self.properties propertyForId:kCMISPropertyName] firstValue];
+        self.createdBy = [[self.properties propertyForId:kCMISPropertyCreatedBy] firstValue];
+        self.lastModifiedBy = [[self.properties propertyForId:kCMISPropertyModifiedBy] firstValue];
+        self.creationDate = [[self.properties propertyForId:kCMISPropertyCreationDate] firstValue];
+        self.lastModificationDate = [[self.properties propertyForId:kCMISPropertyModificationDate] firstValue];
+        self.objectType = [[self.properties propertyForId:kCMISPropertyObjectTypeId] firstValue];
+        self.changeToken = [[self.properties propertyForId:kCMISPropertyChangeToken] firstValue];
+
+        self.allowableActions = objectData.allowableActions;
+
+        // Extract Extensions and store in the extensionsDict
+        self.extensionsDict = [[NSMutableDictionary alloc] init];
+        [self.extensionsDict setObject:[self nonNilArray:objectData.extensions] forKey:[NSNumber numberWithInt:CMISExtensionLevelObject]];
+        [self.extensionsDict setObject:[self nonNilArray:self.properties.extensions] forKey:[NSNumber numberWithInt:CMISExtensionLevelProperties]];
+        [self.extensionsDict setObject:[self nonNilArray:self.allowableActions.extensions] forKey:[NSNumber numberWithInt:CMISExtensionLevelAllowableActions]];        
+
+        // Renditions must be converted here, because they need access to the session
+        if (objectData.renditions != nil)
+        {
+            NSMutableArray *renditions = [NSMutableArray array];
+            for (CMISRenditionData *renditionData in objectData.renditions)
+            {
+                [renditions addObject:[[CMISRendition alloc] initWithRenditionData:renditionData andObjectId:self.identifier andSession:session]];
+            }
+            self.renditions = renditions;
+        }
+    }
+    
+    return self;
+}
+
+- (NSArray *)nonNilArray:(NSArray *)aArray
+{   // Move to category on NSArray?
+    return ((aArray == nil) ? [NSArray array] : aArray);
+}
+
+- (void)updateProperties:(NSDictionary *)properties completionBlock:(void (^)(CMISObject *object, NSError *error))completionBlock
+{
+    // Validate properties param
+        if (!properties || properties.count == 0)
+    {
+        completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:@"Properties cannot be nil or empty"]);
+        return;
+    }
+
+    // Convert properties to an understandable format for the service
+    [self.session.objectConverter convertProperties:properties forObjectTypeId:self.objectType completionBlock:^(CMISProperties *convertedProperties, NSError *error) {
+        if (convertedProperties)
+        {
+            CMISStringInOutParameter *objectIdInOutParam = [CMISStringInOutParameter inOutParameterUsingInParameter:self.identifier];
+            CMISStringInOutParameter *changeTokenInOutParam = [CMISStringInOutParameter inOutParameterUsingInParameter:self.changeToken];
+            [self.binding.objectService
+             updatePropertiesForObject:objectIdInOutParam
+             withProperties:convertedProperties
+             withChangeToken:changeTokenInOutParam
+             completionBlock:^(NSError *error) {
+                 if (objectIdInOutParam.outParameter) {
+                     [self.session retrieveObject:objectIdInOutParam.outParameter
+                                  completionBlock:^(CMISObject *object, NSError *error) {
+                                      completionBlock(object, error);
+                                  }];
+                 }
+                 else
+                 {
+                     completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+                 }
+             }];
+        }
+        else
+        {
+            completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+        }
+    }];
+}
+
+- (NSArray *)extensionsForExtensionLevel:(CMISExtensionLevel)extensionLevel
+{
+    // TODO Need to implement the following extension levels CMISExtensionLevelAcl, CMISExtensionLevelPolicies, CMISExtensionLevelChangeEvent
+    
+    return [self.extensionsDict objectForKey:[NSNumber numberWithInt:extensionLevel]];
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObject.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObjectId.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObjectId.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObjectId.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObjectId.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,25 @@
+/*
+    Licensed 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>
+
+
+@interface CMISObjectId : NSObject
+
+@property (nonatomic, strong, readonly) NSString *identifier;
+
+- (id)initWithString:(NSString *)string;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObjectId.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObjectId.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObjectId.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObjectId.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObjectId.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,37 @@
+/*
+    Licensed 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 "CMISObjectId.h"
+
+
+@interface  CMISObjectId ()
+@property (nonatomic, strong, readwrite) NSString *identifier;
+@end
+
+@implementation CMISObjectId
+
+@synthesize identifier = _identifier;
+
+- (id)initWithString:(NSString *)string
+{
+    self = [super init];
+    if (self)
+    {
+        self.identifier = string;
+    }
+
+    return self;
+}
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISObjectId.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISOperationContext.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISOperationContext.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISOperationContext.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISOperationContext.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,34 @@
+/*
+    Licensed 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"
+
+
+@interface CMISOperationContext : NSObject
+
+@property (nonatomic, strong) NSString *filterString;
+@property BOOL isIncludeAllowableActions;
+@property BOOL isIncluseACLs;
+@property CMISIncludeRelationship includeRelationShips;
+@property BOOL isIncludePolicies;
+@property (nonatomic, strong) NSString *renditionFilterString;
+@property (nonatomic, strong) NSString *orderBy;
+@property BOOL isIncludePathSegments;
+@property NSInteger maxItemsPerPage;
+@property NSInteger skipCount;
+
++ (CMISOperationContext *)defaultOperationContext;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISOperationContext.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISOperationContext.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISOperationContext.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISOperationContext.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISOperationContext.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,48 @@
+/*
+    Licensed 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 "CMISOperationContext.h"
+
+
+@implementation CMISOperationContext
+
+@synthesize filterString = _filterString;
+@synthesize isIncludeAllowableActions = _isIncludeAllowableActions;
+@synthesize isIncluseACLs = _isIncluseACLs;
+@synthesize includeRelationShips = _includeRelationShips;
+@synthesize isIncludePolicies = _isIncludePolicies;
+@synthesize renditionFilterString = _renditionFilterString;
+@synthesize maxItemsPerPage = _maxItemsPerPage;
+@synthesize skipCount = _skipCount;
+@synthesize orderBy = _orderBy;
+@synthesize isIncludePathSegments = _isIncludePathSegments;
+
++ (CMISOperationContext *)defaultOperationContext
+{
+    CMISOperationContext *defaultContext = [[CMISOperationContext alloc] init];
+    defaultContext.filterString = nil;
+    defaultContext.isIncludeAllowableActions = YES;
+    defaultContext.isIncluseACLs = NO;
+    defaultContext.isIncludePolicies = NO;
+    defaultContext.includeRelationShips = CMISIncludeRelationshipNone;
+    defaultContext.renditionFilterString = nil;
+    defaultContext.orderBy = nil;
+    defaultContext.isIncludePathSegments = NO;
+    defaultContext.maxItemsPerPage = 100;
+    defaultContext.skipCount = 0;
+    return defaultContext;
+}
+
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISOperationContext.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISPagedResult.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISPagedResult.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISPagedResult.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISPagedResult.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,50 @@
+/*
+    Licensed 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>
+
+/**
+ * Wrapper class for the results of fetching a new page using the block below.
+ */
+@interface CMISFetchNextPageBlockResult : NSObject
+
+@property (nonatomic, strong) NSArray *resultArray;
+@property BOOL hasMoreItems;
+@property NSInteger numItems;
+
+@end
+
+typedef void (^CMISFetchNextPageBlockCompletionBlock)(CMISFetchNextPageBlockResult *result, NSError *error);
+typedef void (^CMISFetchNextPageBlock)(int skipCount, int maxItems, CMISFetchNextPageBlockCompletionBlock completionBlock);
+
+@class CMISObject;
+
+/**
+ * The result of executing an operation which has potentially more results than returned in once.
+ */
+@interface CMISPagedResult : NSObject
+
+@property (nonatomic, strong, readonly) NSArray *resultArray;
+@property (readonly) BOOL hasMoreItems;
+@property (readonly) NSInteger numItems;
+
++ (void)pagedResultUsingFetchBlock:(CMISFetchNextPageBlock)fetchNextPageBlock
+                andLimitToMaxItems:(NSInteger)maxItems andStartFromSkipCount:(NSInteger)skipCount
+                   completionBlock:(void (^)(CMISPagedResult *result, NSError *error))completionBlock;
+
+- (void)fetchNextPageWithCompletionBlock:(void (^)(CMISPagedResult *result, NSError *error))completionBlock;
+- (void)enumerateItemsUsingBlock:(void (^)(CMISObject *object, BOOL *stop))enumerationBlock
+                 completionBlock:(void (^)(NSError *error))completionBlock;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISPagedResult.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISPagedResult.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISPagedResult.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISPagedResult.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISPagedResult.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,128 @@
+/*
+    Licensed 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 "CMISPagedResult.h"
+#import "CMISErrors.h"
+
+/**
+ * Implementation of the wrapper class for the returned results
+ */
+@implementation CMISFetchNextPageBlockResult
+
+@synthesize resultArray = _resultArray;
+@synthesize hasMoreItems = _hasMoreItems;
+@synthesize numItems = _numItems;
+
+@end
+
+/**
+ * Private interface for CMISPagedResult
+ */
+@interface CMISPagedResult ()
+
+@property (nonatomic, strong, readwrite) NSArray *resultArray;
+@property (readwrite) BOOL hasMoreItems;
+@property (readwrite) NSInteger numItems;
+@property (readwrite) NSInteger maxItems;
+@property (readwrite) NSInteger skipCount;
+
+@property (nonatomic, copy) CMISFetchNextPageBlock fetchNextPageBlock;
+
+@end
+
+/**
+ * The implementation of the result when fetching a new page.
+ */
+@implementation CMISPagedResult
+
+@synthesize resultArray = _resultArray;
+@synthesize hasMoreItems = _hasMoreItems;
+@synthesize numItems = _numItems;
+@synthesize fetchNextPageBlock = _fetchNextPageBlock;
+@synthesize maxItems = _maxItems;
+@synthesize skipCount = _skipCount;
+
+
+/** Internal init */
+- (id)initWithResultArray:(NSArray *)resultArray
+ retrievedUsingFetchBlock:(CMISFetchNextPageBlock)fetchNextPageBlock
+              andNumItems:(NSInteger)numItems andHasMoreItems:(BOOL)hasMoreItems
+              andMaxItems:(NSInteger)maxItems andSkipCount:(NSInteger)skipCount;
+{
+    self = [super init];
+    if (self)
+    {
+        self.resultArray = resultArray;
+        self.fetchNextPageBlock = fetchNextPageBlock;
+        self.hasMoreItems = hasMoreItems;
+        self.numItems = numItems;
+        self.maxItems = maxItems;
+        self.skipCount = skipCount;
+    }
+    return self;
+}
+
++ (void)pagedResultUsingFetchBlock:(CMISFetchNextPageBlock)fetchNextPageBlock
+                andLimitToMaxItems:(NSInteger)maxItems andStartFromSkipCount:(NSInteger)skipCount
+                   completionBlock:(void (^)(CMISPagedResult *result, NSError *error))completionBlock
+{
+    // Fetch the first requested page
+    fetchNextPageBlock(skipCount, maxItems, ^(CMISFetchNextPageBlockResult *result, NSError *error) {
+        if (error) {
+            completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+        } else {
+            completionBlock([[CMISPagedResult alloc] initWithResultArray:result.resultArray
+                                                retrievedUsingFetchBlock:fetchNextPageBlock
+                                                             andNumItems:result.numItems
+                                                         andHasMoreItems:result.hasMoreItems
+                                                             andMaxItems:maxItems
+                                                            andSkipCount:skipCount],
+                            nil);
+        }
+    });
+}
+
+- (void)fetchNextPageWithCompletionBlock:(void (^)(CMISPagedResult *result, NSError *error))completionBlock
+{
+    [CMISPagedResult pagedResultUsingFetchBlock:self.fetchNextPageBlock
+                             andLimitToMaxItems:self.maxItems
+                          andStartFromSkipCount:(self.skipCount + self.resultArray.count)
+                                completionBlock:completionBlock];
+}
+
+- (void)enumerateItemsUsingBlock:(void (^)(CMISObject *object, BOOL *stop))enumerationBlock completionBlock:(void (^)(NSError *error))completionBlock
+{
+    BOOL stop = NO;
+    for (CMISObject *object in self.resultArray) {
+        enumerationBlock(object, &stop);
+        if (stop) {
+            NSError *error = [CMISErrors createCMISErrorWithCode:kCMISErrorCodeCancelled withDetailedDescription:@"Item enumeration was stopped"];
+            completionBlock(error);
+            return;
+        }
+    }
+    if (self.hasMoreItems) {
+        [self fetchNextPageWithCompletionBlock:^(CMISPagedResult *result, NSError *error) {
+            if (error) {
+                completionBlock(error);
+            } else {
+                [result enumerateItemsUsingBlock:enumerationBlock completionBlock:completionBlock];
+            }
+        }];
+    } else {
+        completionBlock(nil);
+    }
+}
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISPagedResult.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRendition.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRendition.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRendition.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRendition.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,40 @@
+/*
+    Licensed 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 "CMISRenditionData.h"
+
+@class CMISDocument;
+@class CMISOperationContext;
+@class CMISSession;
+
+
+@interface CMISRendition : CMISRenditionData
+
+- (id)initWithRenditionData:(CMISRenditionData *)renditionData andObjectId:(NSString *)objectId andSession:(CMISSession *)session;
+
+- (void)retrieveRenditionDocumentWithCompletionBlock:(void (^)(CMISDocument *document, NSError *error))completionBlock;
+
+- (void)retrieveRenditionDocumentWithOperationContext:(CMISOperationContext *)operationContext
+                                      completionBlock:(void (^)(CMISDocument *document, NSError *error))completionBlock;
+
+- (void)downloadRenditionContentToFile:(NSString *)filePath
+                       completionBlock:(void (^)(NSError *error))completionBlock
+                         progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock;
+
+- (void)downloadRenditionContentToOutputStream:(NSOutputStream *)outputStream
+                               completionBlock:(void (^)(NSError *error))completionBlock
+                                 progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRendition.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRendition.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRendition.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRendition.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRendition.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,103 @@
+/*
+    Licensed 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 "CMISRendition.h"
+#import "CMISDocument.h"
+#import "CMISOperationContext.h"
+#import "CMISSession.h"
+
+@interface CMISRendition ()
+
+@property (nonatomic, strong) CMISSession *session;
+@property (nonatomic, strong) NSString *objectId;
+
+@end
+
+@implementation CMISRendition
+
+@synthesize session = _session;
+@synthesize objectId = _objectId;
+
+- (id)initWithRenditionData:(CMISRenditionData *)renditionData andObjectId:(NSString *)objectId andSession:(CMISSession *)session
+{
+    self = [super initWithRenditionData:renditionData];
+    if (self)
+    {
+        self.objectId = objectId;
+        self.session = session;
+    }
+    return self;
+}
+
+- (void)retrieveRenditionDocumentWithCompletionBlock:(void (^)(CMISDocument *document, NSError *error))completionBlock
+{
+    [self retrieveRenditionDocumentWithOperationContext:[CMISOperationContext defaultOperationContext] completionBlock:completionBlock];
+}
+
+- (void)retrieveRenditionDocumentWithOperationContext:(CMISOperationContext *)operationContext
+                                      completionBlock:(void (^)(CMISDocument *document, NSError *error))completionBlock
+{
+    if (self.renditionDocumentId == nil)
+    {
+        log(@"Cannot retrieve rendition document: no renditionDocumentId was returned by the server.");
+        completionBlock(nil, nil);
+        return;
+    }
+
+    [self.session retrieveObject:self.renditionDocumentId withOperationContext:operationContext completionBlock:^(CMISObject *renditionDocument, NSError *error) {
+        if (renditionDocument != nil && !([[renditionDocument class] isKindOfClass:[CMISDocument class]]))
+        {
+            completionBlock(nil, nil);
+            return;
+        }
+        
+        completionBlock((CMISDocument *) renditionDocument, nil);
+    }];
+}
+
+- (void)downloadRenditionContentToFile:(NSString *)filePath
+                       completionBlock:(void (^)(NSError *error))completionBlock
+                         progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock
+{
+    if (self.objectId == nil || self.streamId == nil)
+    {
+        log(@"Object id or stream id is nil. Both are needed when fetching the content of a rendition");
+        return;
+    }
+
+    [self.session.binding.objectService downloadContentOfObject:self.objectId
+                                                   withStreamId:self.streamId
+                                                         toFile:filePath
+                                                completionBlock:completionBlock
+                                                  progressBlock:progressBlock];
+}
+
+- (void)downloadRenditionContentToOutputStream:(NSOutputStream *)outputStream
+                               completionBlock:(void (^)(NSError *error))completionBlock
+                                 progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock
+{
+    if (self.objectId == nil || self.streamId == nil)
+    {
+        log(@"Object id or stream id is nil. Both are needed when fetching the content of a rendition");
+        return;
+    }
+    
+    [self.session.binding.objectService downloadContentOfObject:self.objectId
+                                                   withStreamId:self.streamId
+                                                         toOutputStream:outputStream
+                                                completionBlock:completionBlock
+                                                  progressBlock:progressBlock];
+}
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRendition.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRequest.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRequest.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRequest.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRequest.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,26 @@
+/*
+ Licensed 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>
+
+@class CMISHttpRequest;
+
+@interface CMISRequest : NSObject
+
+@property (nonatomic, weak) CMISHttpRequest *httpRequest;
+@property (nonatomic, readonly, getter = isCancelled) BOOL cancelled;
+
+- (void)cancel;
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRequest.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRequest.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRequest.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRequest.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRequest.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,46 @@
+/*
+ Licensed 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 "CMISRequest.h"
+#import "CMISHttpRequest.h"
+
+@interface CMISRequest ()
+
+@property (nonatomic, getter = isCancelled) BOOL cancelled;
+
+@end
+
+
+@implementation CMISRequest
+
+@synthesize httpRequest = _httpRequest;
+@synthesize cancelled = _cancelled;
+
+- (void)cancel
+{
+    self.cancelled = YES;
+    
+    [self.httpRequest cancel];
+}
+
+- (void)setHttpRequest:(CMISHttpRequest *)httpRequest
+{
+    _httpRequest = httpRequest;
+    
+    if (self.isCancelled) {
+        [httpRequest cancel];
+    }
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISRequest.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,171 @@
+/*
+    Licensed 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 "CMISSessionParameters.h"
+#import "CMISRepositoryInfo.h"
+#import "CMISBinding.h"
+#import "CMISFolder.h"
+
+@class CMISOperationContext;
+@class CMISPagedResult;
+@class CMISTypeDefinition;
+@class CMISObjectConverter;
+
+@interface CMISSession : NSObject
+
+// Flag to indicate whether the session has been authenticated.
+@property (nonatomic, assign, readonly) BOOL isAuthenticated;
+
+// The binding object being used for the session.
+@property (nonatomic, strong, readonly) id<CMISBinding> binding;
+
+// The parameters used to create this session.
+@property (nonatomic, strong) CMISSessionParameters *sessionParameters;
+
+// Information about the repository the session is connected to, will be nil until the session is authenticated.
+@property (nonatomic, strong, readonly) CMISRepositoryInfo *repositoryInfo;
+
+//used for converting properties. This can be set to a custom object converter
+@property (nonatomic, strong, readonly) CMISObjectConverter *objectConverter;
+
+// *** setup ***
+
+// returns an array of CMISRepositoryInfo objects representing the repositories available at the endpoint.
++ (void)arrayOfRepositories:(CMISSessionParameters *)sessionParameters
+            completionBlock:(void (^)(NSArray *repositories, NSError *error))completionBlock;
+
+
++ (void)connectWithSessionParameters:(CMISSessionParameters *)sessionParameters
+                     completionBlock:(void (^)(CMISSession *session, NSError * error))completionBlock;
+
+// *** CMIS operations ***
+
+/**
+ * Retrieves the root folder for the repository.
+ */
+- (void)retrieveRootFolderWithCompletionBlock:(void (^)(CMISFolder *folder, NSError *error))completionBlock;
+
+/**
+ * Retrieves the root folder for the repository using the provided operation context.
+ */
+- (void)retrieveFolderWithOperationContext:(CMISOperationContext *)operationContext
+                           completionBlock:(void (^)(CMISFolder *folder, NSError *error))completionBlock;
+ 
+/**
+  * Retrieves the object with the given identifier.
+  */
+- (void)retrieveObject:(NSString *)objectId
+       completionBlock:(void (^)(CMISObject *object, NSError *error))completionBlock;
+
+/**
+  * Retrieves the object with the given identifier, using the provided operation context.
+  */
+- (void)retrieveObject:(NSString *)objectId
+  withOperationContext:(CMISOperationContext *)operationContext
+       completionBlock:(void (^)(CMISObject *object, NSError *error))completionBlock;
+
+/**
+  * Retrieves the object for the given path.
+  */
+- (void)retrieveObjectByPath:(NSString *)path
+             completionBlock:(void (^)(CMISObject *object, NSError *error))completionBlock;
+
+ 
+/**
+ * Retrieves the object for the given path, using the provided operation context.
+ */
+- (void)retrieveObjectByPath:(NSString *)path
+        withOperationContext:(CMISOperationContext *)operationContext
+             completionBlock:(void (^)(CMISObject *object, NSError *error))completionBlock;
+
+/**
+ * Retrieves the definition for the given type.
+ */
+- (void)retrieveTypeDefinition:(NSString *)typeId 
+               completionBlock:(void (^)(CMISTypeDefinition *typeDefinition, NSError *error))completionBlock;
+/**
+ * Retrieves all objects matching the given cmis query.
+ *
+ * @return An array of CMISQueryResult objects.
+ */
+- (void)query:(NSString *)statement searchAllVersions:(BOOL)searchAllVersion
+                                      completionBlock:(void (^)(CMISPagedResult *pagedResult, NSError *error))completionBlock;
+
+/**
+ * Retrieves all objects matching the given cmis query, as CMISQueryResult objects.
+ * and using the parameters provided in the operation context.
+ *
+ * @return An array of CMISQueryResult objects.
+ */
+- (void)query:(NSString *)statement searchAllVersions:(BOOL)searchAllVersion
+                                     operationContext:(CMISOperationContext *)operationContext
+                                      completionBlock:(void (^)(CMISPagedResult *pagedResult, NSError *error))completionBlock;
+
+/**
+ * Queries for a specific type of objects.
+ * Returns a paged result set, containing CMISObject instances.
+ */
+- (void)queryObjectsWithTypeid:(NSString *)typeId
+               withWhereClause:(NSString *)whereClause
+             searchAllVersions:(BOOL)searchAllVersion
+              operationContext:(CMISOperationContext *)operationContext
+               completionBlock:(void (^)(CMISPagedResult *result, NSError *error))completionBlock;
+
+
+/**
+ * Creates a folder in the provided folder.
+ */
+- (void)createFolder:(NSDictionary *)properties
+            inFolder:(NSString *)folderObjectId
+     completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock;
+
+
+/**
+ * Downloads the content of object with the provided object id to the given path.
+ */
+- (CMISRequest*)downloadContentOfCMISObject:(NSString *)objectId
+                                     toFile:(NSString *)filePath
+                            completionBlock:(void (^)(NSError *error))completionBlock
+                              progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock;
+
+/**
+ * Downloads the content of object with the provided object id to the given stream.
+ */
+- (CMISRequest*)downloadContentOfCMISObject:(NSString *)objectId
+                             toOutputStream:(NSOutputStream*)outputStream
+                            completionBlock:(void (^)(NSError *error))completionBlock
+                              progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock;
+
+/**
+ * Creates a cmis document using the content from the file path.
+ */
+- (void)createDocumentFromFilePath:(NSString *)filePath
+                      withMimeType:(NSString *)mimeType
+                    withProperties:(NSDictionary *)properties
+                          inFolder:(NSString *)folderObjectId
+                   completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
+                     progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock;
+
+/**
+ * Creates a cmis document using the content from the given stream.
+ */
+- (void)createDocumentFromInputStream:(NSInputStream *)inputStream
+                         withMimeType:(NSString *)mimeType
+                       withProperties:(NSDictionary *)properties
+                             inFolder:(NSString *)folderObjectId
+                        bytesExpected:(unsigned long long)bytesExpected
+                      completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
+                        progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock;
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.h
------------------------------------------------------------------------------
    svn:eol-style = native