chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1425870 [5/13] - in /chemistry/objectivecmis/trunk: ./ ObjectiveCMIS.xcodeproj/ ObjectiveCMIS.xcodeproj/project.xcworkspace/ ObjectiveCMIS/ ObjectiveCMIS/Bindings/ ObjectiveCMIS/Bindings/AtomPub/ ObjectiveCMIS/Bindings/AtomPub/AtomPubParse...
Date Wed, 26 Dec 2012 10:48:37 GMT
Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,143 @@
+/*
+    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 "CMISAtomPubNavigationService.h"
+#import "CMISAtomPubBaseService+Protected.h"
+#import "CMISAtomFeedParser.h"
+#import "CMISHttpUtil.h"
+#import "CMISHttpResponse.h"
+#import "CMISErrors.h"
+#import "CMISURLUtil.h"
+#import "CMISObjectList.h"
+
+@implementation CMISAtomPubNavigationService
+
+
+- (void)retrieveChildren:(NSString *)objectId orderBy:(NSString *)orderBy
+                  filter:(NSString *)filter includeRelationShips:(CMISIncludeRelationship)includeRelationship
+         renditionFilter:(NSString *)renditionFilter includeAllowableActions:(BOOL)includeAllowableActions
+      includePathSegment:(BOOL)includePathSegment skipCount:(NSNumber *)skipCount
+                maxItems:(NSNumber *)maxItems
+         completionBlock:(void (^)(CMISObjectList *objectList, NSError *error))completionBlock
+{
+    // Get Down link
+    [self loadLinkForObjectId:objectId andRelation:kCMISLinkRelationDown
+                      andType:kCMISMediaTypeChildren completionBlock:^(NSString *downLink, NSError *error) {
+                          if (error)
+                          {
+                              log(@"Could not retrieve down link: %@", error.description);
+                              completionBlock(nil, error);
+                              return;
+                          }
+                          
+                          // Add optional params (CMISUrlUtil will not append if the param name or value is nil)
+                          downLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterFilter withValue:filter toUrlString:downLink];
+                          downLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterOrderBy withValue:orderBy toUrlString:downLink];
+                          downLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterIncludeAllowableActions withValue:(includeAllowableActions ? @"true" : @"false") toUrlString:downLink];
+                          downLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterIncludeRelationships withValue:[CMISEnums stringForIncludeRelationShip:includeRelationship] toUrlString:downLink];
+                          downLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterRenditionFilter withValue:renditionFilter toUrlString:downLink];
+                          downLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterIncludePathSegment withValue:(includePathSegment ? @"true" : @"false") toUrlString:downLink];
+                          downLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterMaxItems withValue:[maxItems stringValue] toUrlString:downLink];
+                          downLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterSkipCount withValue:[skipCount stringValue] toUrlString:downLink];
+                          
+                          // execute the request
+                          [HttpUtil invokeGET:[NSURL URLWithString:downLink]
+                                  withSession:self.bindingSession
+                              completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+                                  if (httpResponse) {
+                                      if (httpResponse.data == nil) {
+                                          NSError *error = [CMISErrors createCMISErrorWithCode:kCMISErrorCodeConnection withDetailedDescription:nil];
+                                          completionBlock(nil, error);
+                                          return;
+                                      }
+                                      
+                                      // Parse the feed (containing entries for the children) you get back
+                                      CMISAtomFeedParser *parser = [[CMISAtomFeedParser alloc] initWithData:httpResponse.data];
+                                      NSError *internalError = nil;
+                                      if ([parser parseAndReturnError:&internalError])
+                                      {
+                                          NSString *nextLink = [parser.linkRelations linkHrefForRel:kCMISLinkRelationNext];
+                                          
+                                          CMISObjectList *objectList = [[CMISObjectList alloc] init];
+                                          objectList.hasMoreItems = (nextLink != nil);
+                                          objectList.numItems = parser.numItems;
+                                          objectList.objects = parser.entries;
+                                          completionBlock(objectList, nil);
+                                      }
+                                      else
+                                      {
+                                          NSError *error = [CMISErrors cmisError:internalError withCMISErrorCode:kCMISErrorCodeRuntime];
+                                          completionBlock(nil, error);
+                                      }
+                                  } else {
+                                      completionBlock(nil, error);
+                                  }
+                              }];
+                      }];
+}
+
+- (void)retrieveParentsForObject:(NSString *)objectId
+                           withFilter:(NSString *)filter
+             withIncludeRelationships:(CMISIncludeRelationship)includeRelationship
+                  withRenditionFilter:(NSString *)renditionFilter
+          withIncludeAllowableActions:(BOOL)includeAllowableActions
+       withIncludeRelativePathSegment:(BOOL)includeRelativePathSegment
+                      completionBlock:(void (^)(NSArray *parents, NSError *error))completionBlock
+{
+    // Get up link
+    [self loadLinkForObjectId:objectId andRelation:kCMISLinkRelationUp completionBlock:^(NSString *upLink, NSError *error) {
+        if (upLink == nil) {
+            log(@"Failing because the NSString upLink is nil");
+            completionBlock([NSArray array], nil); // TODO: shouldn't this return an error if the log talks about 'failing'?
+            return;
+        }
+        
+        // Add optional parameters
+        if (filter != nil)
+        {
+            upLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterFilter withValue:filter toUrlString:upLink];
+        }
+        upLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterIncludeAllowableActions withValue:(includeAllowableActions ? @"true" : @"false") toUrlString:upLink];
+        upLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterIncludeRelationships withValue:[CMISEnums stringForIncludeRelationShip:includeRelationship] toUrlString:upLink];
+        
+        if (renditionFilter != nil)
+        {
+            upLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterRenditionFilter withValue:renditionFilter toUrlString:upLink];
+        }
+        
+        upLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterRelativePathSegment withValue:(includeRelativePathSegment ? @"true" : @"false") toUrlString:upLink];
+        
+        [HttpUtil invokeGET:[NSURL URLWithString:upLink]
+                withSession:self.bindingSession
+            completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+                if (httpResponse) {
+                    CMISAtomFeedParser *parser = [[CMISAtomFeedParser alloc] initWithData:httpResponse.data];
+                    NSError *internalError;
+                    if (![parser parseAndReturnError:&internalError])
+                    {
+                        NSError *error = [CMISErrors cmisError:internalError withCMISErrorCode:kCMISErrorCodeRuntime];
+                        log(@"Failing because parsing the Atom Feed XML returns an error");
+                        completionBlock([NSArray array], error);
+                    } else {
+                        completionBlock(parser.entries, nil);
+                    }
+                } else {
+                    log(@"Failing because the invokeGET returns an error");
+                    completionBlock([NSArray array], error);
+                }
+            }];
+    }];
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectService.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectService.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectService.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectService.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,19 @@
+/*
+    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 "CMISAtomPubBaseService.h"
+
+@interface CMISAtomPubObjectService : CMISAtomPubBaseService <CMISObjectService>
+
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectService.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectService.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectService.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectService.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectService.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,744 @@
+/*
+ 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 "CMISAtomPubObjectService.h"
+#import "CMISAtomPubBaseService+Protected.h"
+#import "CMISHttpUtil.h"
+#import "CMISHttpResponse.h"
+#import "CMISAtomEntryWriter.h"
+#import "CMISAtomEntryParser.h"
+#import "CMISConstants.h"
+#import "CMISErrors.h"
+#import "CMISStringInOutParameter.h"
+#import "CMISURLUtil.h"
+#import "CMISFileUtil.h"
+#import "CMISRequest.h"
+
+@implementation CMISAtomPubObjectService
+
+- (void)retrieveObject:(NSString *)objectId
+            withFilter:(NSString *)filter
+andIncludeRelationShips:(CMISIncludeRelationship)includeRelationship
+   andIncludePolicyIds:(BOOL)includePolicyIds
+    andRenditionFilder:(NSString *)renditionFilter
+         andIncludeACL:(BOOL)includeACL
+andIncludeAllowableActions:(BOOL)includeAllowableActions
+       completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+{
+    [self retrieveObjectInternal:objectId
+               withReturnVersion:NOT_PROVIDED
+                      withFilter:filter
+         andIncludeRelationShips:includeRelationship
+             andIncludePolicyIds:includePolicyIds
+              andRenditionFilder:renditionFilter
+                   andIncludeACL:includeACL
+      andIncludeAllowableActions:includeAllowableActions
+                 completionBlock:^(CMISObjectData *objectData, NSError *error) {
+                     if (error) {
+                         completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeObjectNotFound]);
+                     } else {
+                         completionBlock(objectData, nil);
+                     }
+                 }];
+}
+
+- (void)retrieveObjectByPath:(NSString *)path
+                  withFilter:(NSString *)filter
+     andIncludeRelationShips:(CMISIncludeRelationship)includeRelationship
+         andIncludePolicyIds:(BOOL)includePolicyIds
+          andRenditionFilder:(NSString *)renditionFilter
+               andIncludeACL:(BOOL)includeACL
+  andIncludeAllowableActions:(BOOL)includeAllowableActions
+             completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+{
+    [self retrieveObjectByPathInternal:path
+                            withFilter:filter
+               andIncludeRelationShips:includeRelationship
+                   andIncludePolicyIds:includePolicyIds
+                    andRenditionFilder:renditionFilter
+                         andIncludeACL:includeACL
+            andIncludeAllowableActions:includeAllowableActions
+                       completionBlock:completionBlock];
+}
+
+- (CMISRequest*)downloadContentOfObject:(NSString *)objectId
+                           withStreamId:(NSString *)streamId
+                                 toFile:(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 downloadContentOfObject:objectId
+                            withStreamId:streamId
+                          toOutputStream:outputStream
+                         completionBlock:completionBlock
+                           progressBlock:progressBlock];
+}
+
+- (CMISRequest*)downloadContentOfObject:(NSString *)objectId
+                           withStreamId:(NSString *)streamId
+                         toOutputStream:(NSOutputStream *)outputStream
+                        completionBlock:(void (^)(NSError *error))completionBlock
+                          progressBlock:(void (^)(unsigned long long bytesDownloaded, unsigned long long bytesTotal))progressBlock;
+{
+    CMISRequest *request = [[CMISRequest alloc] init];
+    
+    [self retrieveObjectInternal:objectId completionBlock:^(CMISObjectData *objectData, NSError *error) {
+        if (error) {
+            log(@"Error while retrieving CMIS object for object id '%@' : %@", objectId, error.description);
+            if (completionBlock) {
+                completionBlock([CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeObjectNotFound]);
+            }
+        } else {
+            NSURL *contentUrl = objectData.contentUrl;
+            
+            // This is not spec-compliant!! Took me half a day to find this in opencmis ...
+            if (streamId != nil) {
+                contentUrl = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterStreamId withValue:streamId toUrl:contentUrl];
+            }
+            
+            unsigned long long streamLength = [[[objectData.properties.propertiesDictionary objectForKey:kCMISPropertyContentStreamLength] firstValue] unsignedLongLongValue];
+            
+            [HttpUtil invoke:contentUrl
+              withHttpMethod:HTTP_GET
+                 withSession:self.bindingSession
+                outputStream:outputStream
+               bytesExpected:streamLength
+             completionBlock:^(CMISHttpResponse *httpResponse, NSError *error)
+             {
+                 if (completionBlock) {
+                     completionBlock(error);
+                 }
+             }
+               progressBlock:progressBlock
+               requestObject:request];
+        }
+    }];
+    
+    return request;
+}
+
+- (void)deleteContentOfObject:(CMISStringInOutParameter *)objectIdParam
+              withChangeToken:(CMISStringInOutParameter *)changeTokenParam
+              completionBlock:(void (^)(NSError *error))completionBlock
+{
+    // Validate object id param
+    if (objectIdParam == nil || objectIdParam.inParameter == nil)
+    {
+        log(@"Object id is nil or inParameter of objectId is nil");
+        completionBlock([[NSError alloc] init]); // TODO: properly init error (CmisInvalidArgumentException)
+        return;
+    }
+    
+    // Get edit media link
+    [self loadLinkForObjectId:objectIdParam.inParameter andRelation:kCMISLinkEditMedia completionBlock:^(NSString *editMediaLink, NSError *error) {
+        if (editMediaLink == nil){
+            log(@"Could not retrieve %@ link for object '%@'", kCMISLinkEditMedia, objectIdParam.inParameter);
+            completionBlock(error);
+            return;
+        }
+        
+        // Append optional change token parameters
+        if (changeTokenParam != nil && changeTokenParam.inParameter != nil) {
+            editMediaLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterChangeToken
+                                                             withValue:changeTokenParam.inParameter toUrlString:editMediaLink];
+        }
+        
+        [HttpUtil invokeDELETE:[NSURL URLWithString:editMediaLink]
+                   withSession:self.bindingSession
+               completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+                   if (httpResponse) {
+                       // Atompub DOES NOT SUPPORT returning the new object id and change token
+                       // See http://docs.oasis-open.org/cmis/CMIS/v1.0/cs01/cmis-spec-v1.0.html#_Toc243905498
+                       objectIdParam.outParameter = nil;
+                       changeTokenParam.outParameter = nil;
+                       completionBlock(nil);
+                   } else {
+                       completionBlock(error);
+                   }
+               }];
+    }];
+}
+
+- (CMISRequest*)changeContentOfObject:(CMISStringInOutParameter *)objectIdParam
+                      toContentOfFile:(NSString *)filePath
+                withOverwriteExisting:(BOOL)overwrite
+                      withChangeToken:(CMISStringInOutParameter *)changeTokenParam
+                      completionBlock:(void (^)(NSError *error))completionBlock
+                        progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
+{
+    NSInputStream *inputStream = [NSInputStream inputStreamWithFileAtPath:filePath];
+    if (inputStream == nil) {
+        log(@"Could not find file %@", filePath);
+        if (completionBlock) {
+            completionBlock([CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:nil]);
+        }
+        return nil;
+    }
+    
+    NSError *fileError = nil;
+    unsigned long long fileSize = [FileUtil fileSizeForFileAtPath:filePath error:&fileError];
+    if (fileError) {
+        log(@"Could not determine size of file %@: %@", filePath, [fileError description]);
+    }
+    
+    return [self changeContentOfObject:objectIdParam
+                toContentOfInputStream:inputStream
+                         bytesExpected:fileSize
+                          withFilename:[filePath lastPathComponent]
+                 withOverwriteExisting:overwrite
+                       withChangeToken:changeTokenParam
+                       completionBlock:completionBlock
+                         progressBlock:progressBlock];
+}
+
+- (CMISRequest*)changeContentOfObject:(CMISStringInOutParameter *)objectIdParam
+               toContentOfInputStream:(NSInputStream *)inputStream
+                        bytesExpected:(unsigned long long)bytesExpected
+                         withFilename:(NSString*)filename
+                withOverwriteExisting:(BOOL)overwrite
+                      withChangeToken:(CMISStringInOutParameter *)changeTokenParam
+                      completionBlock:(void (^)(NSError *error))completionBlock
+                        progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
+{
+    // Validate object id param
+    if (objectIdParam == nil || objectIdParam.inParameter == nil)
+    {
+        log(@"Object id is nil or inParameter of objectId is nil");
+        if (completionBlock) {
+            completionBlock([CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:@"Must provide object id"]);
+        }
+        return nil;
+    }
+    
+    if (inputStream == nil) {
+        log(@"Invalid input stream");
+        if (completionBlock) {
+            completionBlock([CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:@"Invalid input stream"]);
+        }
+        return nil;
+    }
+    
+    // Atompub DOES NOT SUPPORT returning the new object id and change token
+    // See http://docs.oasis-open.org/cmis/CMIS/v1.0/cs01/cmis-spec-v1.0.html#_Toc243905498
+    objectIdParam.outParameter = nil;
+    changeTokenParam.outParameter = nil;
+    
+    CMISRequest *request = [[CMISRequest alloc] init];
+    // Get edit media link
+    [self loadLinkForObjectId:objectIdParam.inParameter andRelation:kCMISLinkEditMedia completionBlock:^(NSString *editMediaLink, NSError *error) {
+        if (editMediaLink == nil){
+            log(@"Could not retrieve %@ link for object '%@'", kCMISLinkEditMedia, objectIdParam.inParameter);
+            if (completionBlock) {
+                completionBlock([CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeObjectNotFound]);
+            }
+            return;
+        }
+        
+        // Append optional change token parameters
+        if (changeTokenParam != nil && changeTokenParam.inParameter != nil) {
+            editMediaLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterChangeToken
+                                                             withValue:changeTokenParam.inParameter toUrlString:editMediaLink];
+        }
+        
+        // Append overwrite flag
+        editMediaLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterOverwriteFlag
+                                                         withValue:(overwrite ? @"true" : @"false") toUrlString:editMediaLink];
+        
+        // Execute HTTP call on edit media link, passing the a stream to the file
+        NSDictionary *additionalHeader = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"attachment; filename=%@",
+                                                                             filename] forKey:@"Content-Disposition"];
+        
+        [HttpUtil invoke:[NSURL URLWithString:editMediaLink]
+          withHttpMethod:HTTP_PUT
+             withSession:self.bindingSession
+             inputStream:inputStream
+                 headers:additionalHeader
+           bytesExpected:bytesExpected
+         completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+             // Check response status
+             if (httpResponse) {
+                 if (httpResponse.statusCode == 200 || httpResponse.statusCode == 201 || httpResponse.statusCode == 204) {
+                     error = nil;
+                 } else {
+                     log(@"Invalid http response status code when updating content: %d", httpResponse.statusCode);
+                     error = [CMISErrors createCMISErrorWithCode:kCMISErrorCodeRuntime
+                                         withDetailedDescription:[NSString stringWithFormat:@"Could not update content: http status code %d", httpResponse.statusCode]];
+                 }
+             }
+             if (completionBlock) {
+                 completionBlock(error);
+             }
+         }
+           progressBlock:progressBlock
+           requestObject:request];
+    }];
+    
+    return request;
+}
+
+
+- (CMISRequest*)createDocumentFromFilePath:(NSString *)filePath
+                              withMimeType:(NSString *)mimeType
+                            withProperties:(CMISProperties *)properties
+                                  inFolder:(NSString *)folderObjectId
+                           completionBlock:(void (^)(NSString *objectId, NSError *Error))completionBlock
+                             progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
+{
+    NSInputStream *inputStream = [NSInputStream inputStreamWithFileAtPath:filePath];
+    if (inputStream == nil) {
+        log(@"Could not find file %@", filePath);
+        if (completionBlock) {
+            completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:@"Invalid file"]);
+        }
+        return nil;
+    }
+    
+    NSError *fileError = nil;
+    unsigned long long bytesExpected = [FileUtil fileSizeForFileAtPath:filePath error:&fileError];
+    if (fileError) {
+        log(@"Could not determine size of file %@: %@", filePath, [fileError description]);
+    }
+    
+    return [self createDocumentFromInputStream:inputStream
+                                  withMimeType:mimeType withProperties:properties
+                                      inFolder:folderObjectId
+                                 bytesExpected:bytesExpected
+                               completionBlock:completionBlock
+                                 progressBlock:progressBlock];
+}
+
+- (CMISRequest*)createDocumentFromInputStream:(NSInputStream *)inputStream // may be nil if you do not want to set content
+                                 withMimeType:(NSString *)mimeType
+                               withProperties:(CMISProperties *)properties
+                                     inFolder:(NSString *)folderObjectId
+                                bytesExpected:(unsigned long long)bytesExpected // optional
+                              completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
+                                progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
+{
+    // Validate properties
+    if ([properties propertyValueForId:kCMISPropertyName] == nil || [properties propertyValueForId:kCMISPropertyObjectTypeId] == nil)
+    {
+        log(@"Must provide %@ and %@ as properties", kCMISPropertyName, kCMISPropertyObjectTypeId);
+        if (completionBlock) {
+            completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:nil]);
+        }
+        return nil;
+    }
+    
+    // Validate mimetype
+    if (inputStream && !mimeType)
+    {
+        log(@"Must provide a mimetype when creating a cmis document");
+        if (completionBlock) {
+            completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:nil]);
+        }
+        return nil;
+    }
+    
+    CMISRequest *request = [[CMISRequest alloc] init];
+    // Get Down link
+    [self loadLinkForObjectId:folderObjectId andRelation:kCMISLinkRelationDown
+                      andType:kCMISMediaTypeChildren completionBlock:^(NSString *downLink, NSError *error) {
+                          if (error) {
+                              log(@"Could not retrieve down link: %@", error.description);
+                              if (completionBlock) {
+                                  completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeObjectNotFound]);
+                              }
+                          } else {
+                              
+                          }
+                          [self sendAtomEntryXmlToLink:downLink
+                                 withHttpRequestMethod:HTTP_POST
+                                        withProperties:properties
+                                withContentInputStream:inputStream
+                                   withContentMimeType:mimeType
+                                         bytesExpected:bytesExpected
+                                       completionBlock:completionBlock
+                                         progressBlock:progressBlock
+                                         requestObject:request];
+                      }];
+    return request;
+}
+
+
+- (void)deleteObject:(NSString *)objectId allVersions:(BOOL)allVersions completionBlock:(void (^)(BOOL objectDeleted, NSError *error))completionBlock
+{
+    [self loadLinkForObjectId:objectId andRelation:kCMISLinkRelationSelf completionBlock:^(NSString *selfLink, NSError *error) {
+        if (!selfLink) {
+            completionBlock(NO, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:nil]);
+        } else {
+            NSURL *selfUrl = [NSURL URLWithString:selfLink];
+            [HttpUtil invokeDELETE:selfUrl
+                       withSession:self.bindingSession
+                   completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+                       if (httpResponse) {
+                           completionBlock(YES, nil);
+                       } else {
+                           completionBlock(NO, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeUpdateConflict]);
+                       }
+                   }];
+        }
+    }];
+}
+
+- (void)createFolderInParentFolder:(NSString *)folderObjectId withProperties:(CMISProperties *)properties completionBlock:(void (^)(NSString *, NSError *))completionBlock
+{
+    if ([properties propertyValueForId:kCMISPropertyName] == nil || [properties propertyValueForId:kCMISPropertyObjectTypeId] == nil)
+    {
+        log(@"Must provide %@ and %@ as properties", kCMISPropertyName, kCMISPropertyObjectTypeId);
+        completionBlock(nil,  [CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:nil]);
+        return;
+    }
+    
+    // Validate parent folder id
+    if (!folderObjectId)
+    {
+        log(@"Must provide a parent folder object id when creating a new folder");
+        completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeObjectNotFound withDetailedDescription:nil]);
+        return;
+    }
+    
+    // Get Down link
+    [self loadLinkForObjectId:folderObjectId andRelation:kCMISLinkRelationDown
+                      andType:kCMISMediaTypeChildren completionBlock:^(NSString *downLink, NSError *error) {
+                          if (error) {
+                              log(@"Could not retrieve down link: %@", error.description);
+                              completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeConnection]);
+                          } else {
+                              [self sendAtomEntryXmlToLink:downLink
+                                     withHttpRequestMethod:HTTP_POST
+                                            withProperties:properties
+                                           completionBlock:^(CMISObjectData *objectData, NSError *error) {
+                                               completionBlock(objectData.identifier, error);
+                                           }];
+                          }
+                      }];
+}
+
+- (void)deleteTree:(NSString *)folderObjectId
+        allVersion:(BOOL)allVersions
+     unfileObjects:(CMISUnfileObject)unfileObjects
+ continueOnFailure:(BOOL)continueOnFailure
+   completionBlock:(void (^)(NSArray *failedObjects, NSError *error))completionBlock
+{
+    // Validate params
+    if (!folderObjectId)
+    {
+        log(@"Must provide a folder object id when deleting a folder tree");
+        completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeObjectNotFound withDetailedDescription:nil]);
+        return;
+    }
+    
+    [self loadLinkForObjectId:folderObjectId andRelation:kCMISLinkRelationDown andType:kCMISMediaTypeDescendants completionBlock:^(NSString *link, NSError *error) {
+        if (error) {
+            log(@"Error while fetching %@ link : %@", kCMISLinkRelationDown, error.description);
+            completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+            return;
+        }
+        
+        void (^continueWithLink)(NSString *) = ^(NSString *link) {
+            link = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterAllVersions withValue:(allVersions ? @"true" : @"false") toUrlString:link];
+            link = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterUnfileObjects withValue:[CMISEnums stringForUnfileObject:unfileObjects] toUrlString:link];
+            link = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterContinueOnFailure withValue:(continueOnFailure ? @"true" : @"false") toUrlString:link];
+            
+            [HttpUtil invokeDELETE:[NSURL URLWithString:link]
+                       withSession:self.bindingSession
+                   completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+                       if (httpResponse) {
+                           // TODO: retrieve failed folders and files and return
+                           completionBlock([NSArray array], nil);
+                       } else {
+                           completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeConnection]);
+                       }
+                   }];
+        };
+        
+        if (link == nil) {
+            [self loadLinkForObjectId:folderObjectId andRelation:kCMISLinkRelationFolderTree completionBlock:^(NSString *link, NSError *error) {
+                if (error) {
+                    log(@"Error while fetching %@ link : %@", kCMISLinkRelationFolderTree, error.description);
+                    completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+                } else if (link == nil) {
+                    log(@"Could not retrieve %@ nor %@ link", kCMISLinkRelationDown, kCMISLinkRelationFolderTree);
+                    completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeRuntime]);
+                } else {
+                    continueWithLink(link);
+                }
+            }];
+        } else {
+            continueWithLink(link);
+        }
+    }];
+}
+
+- (void)updatePropertiesForObject:(CMISStringInOutParameter *)objectIdParam
+                   withProperties:(CMISProperties *)properties
+                  withChangeToken:(CMISStringInOutParameter *)changeTokenParam
+                  completionBlock:(void (^)(NSError *error))completionBlock
+{
+    // Validate params
+    if (objectIdParam == nil || objectIdParam.inParameter == nil)
+    {
+        log(@"Object id is nil or inParameter of objectId is nil");
+        completionBlock([[NSError alloc] init]); // TODO: properly init error (CmisInvalidArgumentException)
+        return;
+    }
+    
+    // Get self link
+    [self loadLinkForObjectId:objectIdParam.inParameter andRelation:kCMISLinkRelationSelf completionBlock:^(NSString *selfLink, NSError *error) {
+        if (selfLink == nil)
+        {
+            log(@"Could not retrieve %@ link", kCMISLinkRelationSelf);
+            completionBlock([CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeConnection]);
+            return;
+        }
+        
+        // Append optional params
+        if (changeTokenParam != nil && changeTokenParam.inParameter != nil)
+        {
+            selfLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterChangeToken
+                                                        withValue:changeTokenParam.inParameter toUrlString:selfLink];
+        }
+        
+        // Execute request
+        [self sendAtomEntryXmlToLink:selfLink
+               withHttpRequestMethod:HTTP_PUT
+                      withProperties:properties
+                     completionBlock:^(CMISObjectData *objectData, NSError *error) {
+                         // Create XML needed as body of html
+                         
+                         CMISAtomEntryWriter *xmlWriter = [[CMISAtomEntryWriter alloc] init];
+                         xmlWriter.cmisProperties = properties;
+                         xmlWriter.generateXmlInMemory = YES;
+                         
+                         [HttpUtil invokePUT:[NSURL URLWithString:selfLink]
+                                 withSession:self.bindingSession
+                                        body:[xmlWriter.generateAtomEntryXml dataUsingEncoding:NSUTF8StringEncoding]
+                                     headers:[NSDictionary dictionaryWithObject:kCMISMediaTypeEntry forKey:@"Content-type"]
+                             completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+                                 if (httpResponse) {
+                                     // Object id and changeToken might have changed because of this operation
+                                     CMISAtomEntryParser *atomEntryParser = [[CMISAtomEntryParser alloc] initWithData:httpResponse.data];
+                                     NSError *error = nil;
+                                     if ([atomEntryParser parseAndReturnError:&error])
+                                     {
+                                         objectIdParam.outParameter = [[atomEntryParser.objectData.properties propertyForId:kCMISPropertyObjectId] firstValue];
+                                         
+                                         if (changeTokenParam != nil)
+                                         {
+                                             changeTokenParam.outParameter = [[atomEntryParser.objectData.properties propertyForId:kCMISPropertyChangeToken] firstValue];
+                                         }
+                                     }
+                                     completionBlock(nil);
+                                 } else {
+                                     completionBlock([CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeConnection]);
+                                 }
+                             }];
+                     }];
+    }];
+}
+
+
+- (void)retrieveRenditions:(NSString *)objectId withRenditionFilter:(NSString *)renditionFilter
+              withMaxItems:(NSNumber *)maxItems withSkipCount:(NSNumber *)skipCount
+           completionBlock:(void (^)(NSArray *renditions, NSError *error))completionBlock
+{
+    // Only fetching the bare minimum
+    [self retrieveObjectInternal:objectId withReturnVersion:LATEST withFilter:kCMISPropertyObjectId
+         andIncludeRelationShips:CMISIncludeRelationshipNone andIncludePolicyIds:NO
+              andRenditionFilder:renditionFilter andIncludeACL:NO andIncludeAllowableActions:NO
+                 completionBlock:^(CMISObjectData *objectData, NSError *error) {
+                     if (error) {
+                         completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeObjectNotFound]);
+                     } else {
+                         completionBlock(objectData.renditions, nil);
+                     }
+                 }];
+}
+
+#pragma mark Helper methods
+
+- (void)sendAtomEntryXmlToLink:(NSString *)link
+         withHttpRequestMethod:(CMISHttpRequestMethod)httpRequestMethod
+                withProperties:(CMISProperties *)properties
+               completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+{
+    // Validate params
+    if (link == nil) {
+        log(@"Could not retrieve link from object to do creation or update");
+        if (completionBlock) {
+            completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:nil]);
+        }
+        return;
+    }
+    
+    // Generate XML
+    NSString *writeResult = [self createAtomEntryWriter:properties
+                                        contentFilePath:nil
+                                        contentMimeType:nil
+                                    isXmlStoredInMemory:YES];
+    
+    // Execute call
+    [HttpUtil invoke:[NSURL URLWithString:link]
+      withHttpMethod:httpRequestMethod
+         withSession:self.bindingSession
+                body:[writeResult dataUsingEncoding:NSUTF8StringEncoding]
+             headers:[NSDictionary dictionaryWithObject:kCMISMediaTypeEntry forKey:@"Content-type"]
+     completionBlock:^(CMISHttpResponse *response, NSError *error) {
+         if (error) {
+             log(@"HTTP error when creating/uploading content: %@", error);
+             if (completionBlock) {
+                 completionBlock(nil, error);
+             }
+         } else if (response.statusCode == 200 || response.statusCode == 201 || response.statusCode == 204) {
+             if (completionBlock) {
+                 CMISAtomEntryParser *atomEntryParser = [[CMISAtomEntryParser alloc] initWithData:response.data];
+                 NSError *parseError = nil;
+                 [atomEntryParser parseAndReturnError:&parseError];
+                 if (parseError == nil) {
+                     completionBlock(atomEntryParser.objectData, nil);
+                 } else {
+                     log(@"Error while parsing response: %@", [parseError description]);
+                     completionBlock(nil, [CMISErrors cmisError:parseError withCMISErrorCode:kCMISErrorCodeUpdateConflict]);
+                 }
+             }
+         } else {
+             log(@"Invalid http response status code when creating/uploading content: %d", response.statusCode);
+             log(@"Error content: %@", [[NSString alloc] initWithData:response.data encoding:NSUTF8StringEncoding]);
+             if (completionBlock) {
+                 completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeConnection]);
+             }
+         }
+     }];
+}
+
+
+- (void)sendAtomEntryXmlToLink:(NSString *)link
+         withHttpRequestMethod:(CMISHttpRequestMethod)httpRequestMethod
+                withProperties:(CMISProperties *)properties
+        withContentInputStream:(NSInputStream *)contentInputStream
+           withContentMimeType:(NSString *)contentMimeType
+                 bytesExpected:(unsigned long long)bytesExpected
+               completionBlock:(void (^)(NSString *objectId, NSError *error))completionBlock
+                 progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
+                 requestObject:(CMISRequest*)request
+{
+    // Validate param
+    if (link == nil) {
+        log(@"Could not retrieve link from object to do creation or update");
+        if (completionBlock) {
+            completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeInvalidArgument withDetailedDescription:nil]);
+        }
+        return;
+    }
+    
+    // Generate XML
+    NSString *writeResult = [self createAtomEntryWriter:properties
+                                     contentInputStream:contentInputStream
+                                        contentMimeType:contentMimeType
+                                    isXmlStoredInMemory:NO];
+    
+    // Start the asynchronous POST http call
+    NSInputStream *inputStream = [NSInputStream inputStreamWithFileAtPath:writeResult];
+    
+    NSError *fileSizeError = nil;
+    unsigned long long fileSize = [FileUtil fileSizeForFileAtPath:writeResult error:&fileSizeError];
+    if (fileSizeError) {
+        log(@"Could not determine file size of %@ : %@", writeResult, [fileSizeError description]);
+    }
+    
+    [HttpUtil invoke:[NSURL URLWithString:link]
+      withHttpMethod:HTTP_POST
+         withSession:self.bindingSession
+         inputStream:inputStream
+             headers:[NSDictionary dictionaryWithObject:kCMISMediaTypeEntry forKey:@"Content-type"]
+       bytesExpected:fileSize
+     completionBlock:^(CMISHttpResponse *response, NSError *error) {
+         // close stream to and delete temporary file
+         [inputStream close];
+         NSError *fileError = nil;
+         [[NSFileManager defaultManager] removeItemAtPath:writeResult error:&fileError];
+         if (fileError) {
+             // the upload itself is not impacted by this error, so do not report it in the completion block
+             log(@"Could not delete temporary file %@: %@", writeResult, [fileError description]);
+         }
+         
+         if (error) {
+             log(@"HTTP error when creating/uploading content: %@", error);
+             if (completionBlock) {
+                 completionBlock(nil, error);
+             }
+         } else if (response.statusCode == 200 || response.statusCode == 201 || response.statusCode == 204) {
+             if (completionBlock) {
+                 NSError *parseError = nil;
+                 CMISAtomEntryParser *atomEntryParser = [[CMISAtomEntryParser alloc] initWithData:response.data];
+                 [atomEntryParser parseAndReturnError:&parseError];
+                 if (parseError == nil) {
+                     completionBlock(atomEntryParser.objectData.identifier, nil);
+                 } else {
+                     log(@"Error while parsing response: %@", [parseError description]);
+                     completionBlock(nil, [CMISErrors cmisError:parseError withCMISErrorCode:kCMISErrorCodeUpdateConflict]);
+                 }
+             }
+         } else {
+             log(@"Invalid http response status code when creating/uploading content: %d", response.statusCode);
+             log(@"Error content: %@", [[NSString alloc] initWithData:response.data encoding:NSUTF8StringEncoding]);
+             if (completionBlock) {
+                 completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeRuntime
+                                                  withDetailedDescription:[NSString stringWithFormat:@"Could not create content: http status code %d", response.statusCode]]);
+             }
+         }
+     }
+       progressBlock:progressBlock
+       requestObject:request];
+}
+
+
+/**
+ * Helper method: creates a writer for the xml needed to upload a file.
+ * The atom entry XML can become huge, as the whole file is stored as base64 in the XML itself
+ * Hence, we're allowing to store the atom entry xml in a temporary file and stream the body of the http post
+ */
+- (NSString *)createAtomEntryWriter:(CMISProperties *)properties
+                    contentFilePath:(NSString *)contentFilePath
+                    contentMimeType:(NSString *)contentMimeType
+                isXmlStoredInMemory:(BOOL)isXmlStoredInMemory
+{
+    
+    CMISAtomEntryWriter *atomEntryWriter = [[CMISAtomEntryWriter alloc] init];
+    atomEntryWriter.contentFilePath = contentFilePath;
+    atomEntryWriter.mimeType = contentMimeType;
+    atomEntryWriter.cmisProperties = properties;
+    atomEntryWriter.generateXmlInMemory = isXmlStoredInMemory;
+    NSString *writeResult = [atomEntryWriter generateAtomEntryXml];
+    return writeResult;
+}
+
+- (NSString *)createAtomEntryWriter:(CMISProperties *)properties
+                 contentInputStream:(NSInputStream *)contentInputStream
+                    contentMimeType:(NSString *)contentMimeType
+                isXmlStoredInMemory:(BOOL)isXmlStoredInMemory
+{
+    
+    CMISAtomEntryWriter *atomEntryWriter = [[CMISAtomEntryWriter alloc] init];
+    atomEntryWriter.inputStream= contentInputStream;
+    atomEntryWriter.mimeType = contentMimeType;
+    atomEntryWriter.cmisProperties = properties;
+    atomEntryWriter.generateXmlInMemory = isXmlStoredInMemory;
+    NSString *writeResult = [atomEntryWriter generateAtomEntryXml];
+    return writeResult;
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectService.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,19 @@
+/*
+    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 "CMISAtomPubBaseService.h"
+
+@interface CMISAtomPubRepositoryService : CMISAtomPubBaseService <CMISRepositoryService>
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,109 @@
+/*
+    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 "CMISAtomPubRepositoryService.h"
+#import "CMISAtomPubBaseService+Protected.h"
+#import "CMISWorkspace.h"
+#import "CMISErrors.h"
+#import "CMISTypeByIdUriBuilder.h"
+#import "CMISHttpUtil.h"
+#import "CMISHttpResponse.h"
+#import "CMISTypeDefinitionAtomEntryParser.h"
+
+@interface CMISAtomPubRepositoryService ()
+@property (nonatomic, strong) NSMutableDictionary *repositories;
+@end
+
+@interface CMISAtomPubRepositoryService (PrivateMethods)
+- (void)internalRetrieveRepositoriesWithCompletionBlock:(void (^)(NSError *error))completionBlock;
+@end
+
+
+@implementation CMISAtomPubRepositoryService
+
+@synthesize repositories = _repositories;
+
+- (void)retrieveRepositoriesWithCompletionBlock:(void (^)(NSArray *repositories, NSError *error))completionBlock
+{
+    [self internalRetrieveRepositoriesWithCompletionBlock:^(NSError *error) {
+        if (error) {
+            completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeObjectNotFound]);
+        } else {
+            completionBlock([self.repositories allValues], nil);
+        }
+    }];
+}
+
+- (void)retrieveRepositoryInfoForId:(NSString *)repositoryId completionBlock:(void (^)(CMISRepositoryInfo *repositoryInfo, NSError *error))completionBlock
+{
+    [self internalRetrieveRepositoriesWithCompletionBlock:^(NSError *error) {
+        if (error) {
+            completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeInvalidArgument]);
+        } else {
+            completionBlock([self.repositories objectForKey:repositoryId], nil);
+        }
+    }];
+}
+
+- (void)internalRetrieveRepositoriesWithCompletionBlock:(void (^)(NSError *error))completionBlock
+{
+    self.repositories = [NSMutableDictionary dictionary];
+    [self retrieveCMISWorkspacesWithCompletionBlock:^(NSArray *cmisWorkSpaces, NSError *error) {
+        if (cmisWorkSpaces != nil)
+        {
+            for (CMISWorkspace *workspace in cmisWorkSpaces)
+            {
+                [self.repositories setObject:workspace.repositoryInfo forKey:workspace.repositoryInfo.identifier];
+            }
+        }
+        completionBlock(error);
+    }];
+}
+
+- (void)retrieveTypeDefinition:(NSString *)typeId completionBlock:(void (^)(CMISTypeDefinition *typeDefinition, NSError *error))completionBlock
+{
+    if (typeId == nil)
+    {
+        log(@"Parameter typeId is required");
+        NSError *error = [[NSError alloc] init]; // TODO: proper error init
+        completionBlock(nil, error);
+        return;
+    }
+    
+    [self retrieveFromCache:kCMISBindingSessionKeyTypeByIdUriBuilder completionBlock:^(id object, NSError *error) {
+        CMISTypeByIdUriBuilder *typeByIdUriBuilder = object;
+        typeByIdUriBuilder.id = typeId;
+        
+        [HttpUtil invokeGET:[typeByIdUriBuilder buildUrl] withSession:self.bindingSession completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+            if (httpResponse) {
+                if (httpResponse.data != nil) {
+                    CMISTypeDefinitionAtomEntryParser *parser = [[CMISTypeDefinitionAtomEntryParser alloc] initWithData:httpResponse.data];
+                    NSError *error;
+                    if ([parser parseAndReturnError:&error]) {
+                        completionBlock(parser.typeDefinition, nil);
+                    } else {
+                        completionBlock(nil, error);
+                    }
+                } else {
+                    NSError *error = [[NSError alloc] init]; // TODO: proper error init
+                    completionBlock(nil, error);
+                }
+            } else {
+                completionBlock(nil, error);
+            }
+        }];
+    }];
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByIdUriBuilder.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByIdUriBuilder.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByIdUriBuilder.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByIdUriBuilder.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,42 @@
+/*
+    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"
+
+
+typedef enum
+{
+    NOT_PROVIDED,
+    THIS,
+    LATEST,
+    LATEST_MAJOR
+} CMISReturnVersion;
+
+@interface CMISObjectByIdUriBuilder : NSObject
+
+@property (nonatomic, strong) NSString *objectId;
+@property (nonatomic, strong) NSString *filter;
+@property BOOL includeAllowableActions;
+@property BOOL includePolicyIds;
+@property CMISIncludeRelationship includeRelationships;
+@property BOOL includeACL;
+@property (nonatomic, strong) NSString *renditionFilter;
+@property CMISReturnVersion returnVersion;
+
+- (id)initWithTemplateUrl:(NSString *)templateUrl;
+- (NSURL *)buildUrl;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByIdUriBuilder.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByIdUriBuilder.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByIdUriBuilder.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByIdUriBuilder.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByIdUriBuilder.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,85 @@
+/*
+    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 "CMISObjectByIdUriBuilder.h"
+
+@interface CMISObjectByIdUriBuilder ()
+
+@property (nonatomic, strong) NSString *templateUrl;
+
+@end
+
+@implementation CMISObjectByIdUriBuilder
+
+@synthesize templateUrl = _templateUrl;
+@synthesize objectId = _objectId;
+@synthesize filter = _filter;
+@synthesize includeAllowableActions = _includeAllowableActions;
+@synthesize includePolicyIds = _includePolicyIds;
+@synthesize includeRelationships = _includeRelationships;
+@synthesize includeACL = _includeACL;
+@synthesize renditionFilter = _renditionFilter;
+@synthesize returnVersion = _returnVersion;
+
+- (id)initWithTemplateUrl:(NSString *)templateUrl
+{
+    self = [super init];
+    if (self)
+    {
+        self.templateUrl = templateUrl;
+
+        // Defaults
+        self.includeAllowableActions = YES;
+        self.includeRelationships = CMISIncludeRelationshipNone;
+        self.returnVersion = NOT_PROVIDED;
+    }
+    return self;
+}
+
+- (NSURL *)buildUrl
+{
+    NSString *urlString = [self.templateUrl stringByReplacingOccurrencesOfString:@"{id}" withString:self.objectId];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{filter}" withString:(self.filter != nil ? self.filter : @"")];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeAllowableActions}" withString:(self.includeAllowableActions ? @"true" : @"false")];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includePolicyIds}" withString:(self.includePolicyIds ? @"true" : @"false")];
+
+    NSString *includeRelationShipParam = [CMISEnums stringForIncludeRelationShip:self.includeRelationships];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeRelationships}" withString:includeRelationShipParam];
+
+
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeACL}" withString:(self.includeACL ? @"true" : @"false")];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{renditionFilter}" withString:(self.renditionFilter != nil ? self.renditionFilter : @"")];
+
+    if (self.returnVersion != NOT_PROVIDED)
+    {
+        NSString *returnVersionParam = nil;
+        if (self.returnVersion == THIS)
+        {
+            returnVersionParam = @"this";
+        }
+        else if (self.returnVersion == LATEST)
+        {
+            returnVersionParam = @"latest";
+        }
+        else
+        {
+            returnVersionParam = @"latestmajor";
+        }
+
+        urlString = [NSString stringWithFormat:@"%@&returnVersion=%@", urlString, returnVersionParam];
+    }
+
+    return [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
+}
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByIdUriBuilder.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByPathUriBuilder.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByPathUriBuilder.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByPathUriBuilder.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByPathUriBuilder.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,32 @@
+/*
+    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 CMISObjectByPathUriBuilder : NSObject
+
+@property (nonatomic, strong) NSString *path;
+@property (nonatomic, strong) NSString *filter;
+@property BOOL includeAllowableActions;
+@property BOOL includePolicyIds;
+@property CMISIncludeRelationship includeRelationships;
+@property BOOL includeACL;
+@property (nonatomic, strong) NSString *renditionFilter;
+
+- (id)initWithTemplateUrl:(NSString *)templateUrl;
+- (NSURL *)buildUrl;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByPathUriBuilder.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByPathUriBuilder.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByPathUriBuilder.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByPathUriBuilder.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByPathUriBuilder.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,59 @@
+/*
+    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 "CMISObjectByPathUriBuilder.h"
+
+@interface CMISObjectByPathUriBuilder ()
+
+@property (nonatomic, strong) NSString *templateUrl;
+
+@end
+
+
+@implementation CMISObjectByPathUriBuilder
+
+@synthesize templateUrl = _templateUrl;
+@synthesize path = _path;
+@synthesize filter = _filter;
+@synthesize includeAllowableActions = _includeAllowableActions;
+@synthesize includePolicyIds = _includePolicyIds;
+@synthesize includeRelationships = _includeRelationships;
+@synthesize includeACL = _includeACL;
+@synthesize renditionFilter = _renditionFilter;
+
+- (id)initWithTemplateUrl:(NSString *)templateUrl
+{
+    self = [super init];
+    if (self)
+    {
+        self.templateUrl = templateUrl;
+    }
+    return self;
+}
+
+- (NSURL *)buildUrl
+{
+    NSString *urlString = [self.templateUrl stringByReplacingOccurrencesOfString:@"{path}" withString:self.path];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{filter}" withString:(self.filter != nil ? self.filter : @"")];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeAllowableActions}" withString:(self.includeAllowableActions ? @"true" : @"false")];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includePolicyIds}" withString:(self.includePolicyIds ? @"true" : @"false")];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeRelationships}" withString:[CMISEnums stringForIncludeRelationShip:self.includeRelationships]];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeACL}" withString:(self.includeACL ? @"true" : @"false")];
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{renditionFilter}" withString:(self.renditionFilter != nil ? self.renditionFilter : @"")];
+
+    return [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
+}
+
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISObjectByPathUriBuilder.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISQueryAtomEntryWriter.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISQueryAtomEntryWriter.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISQueryAtomEntryWriter.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISQueryAtomEntryWriter.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,30 @@
+/*
+    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 CMISQueryAtomEntryWriter : NSObject
+
+@property (nonatomic, strong) NSString *statement;
+@property BOOL searchAllVersions;
+@property CMISIncludeRelationship includeRelationships;
+@property (nonatomic, strong) NSString *renditionFilter;
+@property BOOL includeAllowableActions;
+@property (nonatomic, strong) NSNumber * skipCount;
+@property (nonatomic, strong) NSNumber * maxItems;
+
+- (NSString *)generateAtomEntryXML;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISQueryAtomEntryWriter.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISQueryAtomEntryWriter.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISQueryAtomEntryWriter.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISQueryAtomEntryWriter.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISQueryAtomEntryWriter.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,71 @@
+/*
+    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 "CMISQueryAtomEntryWriter.h"
+
+
+@implementation CMISQueryAtomEntryWriter
+
+@synthesize statement = _statement;
+@synthesize searchAllVersions = _searchAllVersions;
+@synthesize includeRelationships = _includeRelationships;
+@synthesize renditionFilter = _renditionFilter;
+@synthesize includeAllowableActions = _includeAllowableActions;
+@synthesize skipCount = _skipCount;
+@synthesize maxItems = _maxItems;
+
+
+- (id)init
+{
+    self = [super init];
+    if (self)
+    {
+        self.includeRelationships = CMISIncludeRelationshipNone;
+    }
+    return self;
+}
+
+
+- (NSString *)generateAtomEntryXML
+{
+    NSMutableString *xml = [[NSMutableString alloc] init];
+    [xml appendString:@"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+        "<cmis:query xmlns:cmis=\"http://docs.oasis-open.org/ns/cmis/core/200908/\" "
+                    "xmlns:cmism=\"http://docs.oasis-open.org/ns/cmis/messaging/200908/\" "
+                    "xmlns:atom=\"http://www.w3.org/2005/Atom\" "
+                    "xmlns:app=\"http://www.w3.org/2007/app\" "
+                    "xmlns:cmisra=\"http://docs.oasis-open.org/ns/cmis/restatom/200908/\">"];
+
+    [xml appendFormat:@"<cmis:statement>%@</cmis:statement>", self.statement];
+    [xml appendFormat:@"<cmis:searchAllVersions>%@</cmis:searchAllVersions>", self.searchAllVersions ? @"true" : @"false"];
+
+    [xml appendFormat:@"<cmis:includeAllowableActions>%@</cmis:includeAllowableActions>", self.includeAllowableActions ? @"true" : @"false"];
+    [xml appendFormat:@"<cmis:includeRelationships>%@</cmis:includeRelationships>", [CMISEnums stringForIncludeRelationShip:self.includeRelationships]];
+    [xml appendFormat:@"<cmis:renditionFilter>%@</cmis:renditionFilter>", self.renditionFilter != nil ? self.renditionFilter : @"*"];
+
+    if (self.maxItems != nil)
+    {
+        [xml appendFormat:@"<cmis:maxItems>%d</cmis:maxItems>", self.maxItems.intValue];
+    }
+
+    if (self.skipCount != nil)
+    {
+        [xml appendFormat:@"<cmis:skipCount>%d</cmis:skipCount>", self.skipCount.intValue];
+    }
+    [xml appendString:@"</cmis:query>"];
+
+    return xml;
+}
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISQueryAtomEntryWriter.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISTypeByIdUriBuilder.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISTypeByIdUriBuilder.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISTypeByIdUriBuilder.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISTypeByIdUriBuilder.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 CMISTypeByIdUriBuilder : NSObject
+
+@property (nonatomic, strong) NSString *id;
+
+- (id)initWithTemplateUrl:(NSString *)templateUrl;
+- (NSURL *)buildUrl;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISTypeByIdUriBuilder.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISTypeByIdUriBuilder.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISTypeByIdUriBuilder.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISTypeByIdUriBuilder.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISTypeByIdUriBuilder.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,45 @@
+/*
+    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 "CMISTypeByIdUriBuilder.h"
+
+@interface CMISTypeByIdUriBuilder ()
+
+@property (nonatomic, strong) NSString *templateUrl;
+
+@end
+
+
+@implementation CMISTypeByIdUriBuilder
+
+@synthesize id = _id;
+@synthesize templateUrl = _templateUrl;
+
+- (id)initWithTemplateUrl:(NSString *)templateUrl
+{
+    self = [super init];
+       if (self)
+       {
+           self.templateUrl = templateUrl;
+       }
+       return self;
+}
+
+- (NSURL *)buildUrl
+{
+    return [NSURL URLWithString:[self.templateUrl stringByReplacingOccurrencesOfString:@"{id}" withString:self.id]];
+}
+
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISTypeByIdUriBuilder.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CmisAtomPubVersioningService.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CmisAtomPubVersioningService.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CmisAtomPubVersioningService.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CmisAtomPubVersioningService.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,20 @@
+/*
+    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 "CMISAtomPubBaseService.h"
+
+
+@interface CMISAtomPubVersioningService : CMISAtomPubBaseService <CMISVersioningService>
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CmisAtomPubVersioningService.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CmisAtomPubVersioningService.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CmisAtomPubVersioningService.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CmisAtomPubVersioningService.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CmisAtomPubVersioningService.m Wed Dec 26 10:48:33 2012
@@ -0,0 +1,91 @@
+/*
+    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 "CMISAtomPubVersioningService.h"
+#import "CMISAtomPubBaseService+Protected.h"
+#import "CMISAtomPubConstants.h"
+#import "CMISHttpUtil.h"
+#import "CMISHttpResponse.h"
+#import "CMISAtomFeedParser.h"
+#import "CMISErrors.h"
+#import "CMISURLUtil.h"
+
+@implementation CMISAtomPubVersioningService
+
+- (void)retrieveObjectOfLatestVersion:(NSString *)objectId
+                                major:(BOOL)major
+                               filter:(NSString *)filter
+                 includeRelationShips:(CMISIncludeRelationship)includeRelationships
+                     includePolicyIds:(BOOL)includePolicyIds
+                      renditionFilter:(NSString *)renditionFilter
+                           includeACL:(BOOL)includeACL
+              includeAllowableActions:(BOOL)includeAllowableActions
+                      completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+{
+    [self retrieveObjectInternal:objectId withReturnVersion:(major ? LATEST_MAJOR : LATEST)
+                      withFilter:filter andIncludeRelationShips:includeRelationships
+             andIncludePolicyIds:includePolicyIds andRenditionFilder:renditionFilter
+                   andIncludeACL:includeACL andIncludeAllowableActions:includeAllowableActions
+                 completionBlock:^(CMISObjectData *objectData, NSError *error) {
+                     completionBlock(objectData, error);
+                 }];
+}
+
+- (void)retrieveAllVersions:(NSString *)objectId
+                     filter:(NSString *)filter
+    includeAllowableActions:(BOOL)includeAllowableActions
+            completionBlock:(void (^)(NSArray *objects, NSError *error))completionBlock
+{
+    // Validate params
+    if (!objectId)
+    {
+        log(@"Must provide an objectId when retrieving all versions");
+        completionBlock(nil, [CMISErrors createCMISErrorWithCode:kCMISErrorCodeObjectNotFound withDetailedDescription:nil]);
+        return;
+    }
+    
+    // Fetch version history link
+    [self loadLinkForObjectId:objectId andRelation:kCMISLinkVersionHistory completionBlock:^(NSString *versionHistoryLink, NSError *error) {
+        if (error) {
+            completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeObjectNotFound]);
+            return;
+        }
+        
+        if (filter) {
+            versionHistoryLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterFilter withValue:filter toUrlString:versionHistoryLink];
+        }
+        versionHistoryLink = [CMISURLUtil urlStringByAppendingParameter:kCMISParameterIncludeAllowableActions
+                                                              withValue:(includeAllowableActions ? @"true" : @"false") toUrlString:versionHistoryLink];
+        
+        // Execute call
+        [HttpUtil invokeGET:[NSURL URLWithString:versionHistoryLink]
+                withSession:self.bindingSession
+            completionBlock:^(CMISHttpResponse *httpResponse, NSError *error) {
+                if (httpResponse) {
+                    NSData *data = httpResponse.data;
+                    CMISAtomFeedParser *feedParser = [[CMISAtomFeedParser alloc] initWithData:data];
+                    NSError *error;
+                    if (![feedParser parseAndReturnError:&error]) {
+                        completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeVersioning]);
+                    } else {
+                        completionBlock(feedParser.entries, nil);
+                    }
+                } else {
+                    completionBlock(nil, [CMISErrors cmisError:error withCMISErrorCode:kCMISErrorCodeConnection]);
+                }
+            }];
+    }];
+}
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CmisAtomPubVersioningService.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomCollection.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomCollection.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomCollection.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomCollection.h Wed Dec 26 10:48:33 2012
@@ -0,0 +1,24 @@
+/*
+    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 CMISAtomCollection : NSObject
+
+@property (nonatomic, strong) NSString *href;
+@property (nonatomic, strong) NSString *title;
+@property (nonatomic, strong) NSString *accept;
+@property (nonatomic, strong) NSString *type;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomCollection.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomCollection.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomCollection.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomCollection.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomCollection.m 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 "CMISAtomCollection.h"
+
+
+@implementation CMISAtomCollection
+
+@synthesize href = _href;
+@synthesize title = _title;
+@synthesize accept = _accept;
+@synthesize type = _type;
+
+@end
\ No newline at end of file

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomCollection.m
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomLink.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomLink.h?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomLink.h (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomLink.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>
+
+@interface CMISAtomLink : NSObject
+
+@property (nonatomic, strong) NSString *rel;
+@property (nonatomic, strong) NSString *type;
+@property (nonatomic, strong) NSString *href;
+
+- (id)initWithRelation:(NSString *)rel type:(NSString *)type href:(NSString *)href;
+
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomLink.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomLink.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomLink.m?rev=1425870&view=auto
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomLink.m (added)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomLink.m 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 "CMISAtomLink.h"
+
+@implementation CMISAtomLink
+
+@synthesize rel = _rel;
+@synthesize type = _type;
+@synthesize href = _href;
+
+- (id)initWithRelation:(NSString *)rel type:(NSString *)type href:(NSString *)href
+{
+    self = [super init];
+    if (self)
+    {
+        self.rel = rel;
+        self.type = type;
+        self.href = href;
+    }
+    return self;
+}
+
+- (NSString *)description
+{
+    return [NSString stringWithFormat:@"CMISAtomLink rel=%@ type=%@ href=%@", self.rel, self.type, self.href];
+}
+
+@end

Propchange: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/Objects/CMISAtomLink.m
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message