Author: gavincornwell
Date: Mon Oct 13 13:41:53 2014
New Revision: 1631391
URL: http://svn.apache.org/r1631391
Log:
CMIS-856: Add support for retrieving a users checked out documents
Modified:
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.m
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserNavigationService.m
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISNavigationService.h
chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.h
chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m
chemistry/objectivecmis/trunk/ObjectiveCMIS/Common/CMISConstants.h
chemistry/objectivecmis/trunk/ObjectiveCMIS/Common/CMISConstants.m
chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m
Modified:
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.m
URL:
http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.m?rev=1631391&r1=1631390&r2=1631391&view=diff
==============================================================================
---
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.m
(original)
+++
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubNavigationService.m
Mon Oct 13 13:41:53 2014
@@ -155,4 +155,68 @@
return request;
}
+- (CMISRequest*)retrieveCheckedOutDocumentsInFolder:(NSString *)folderId
+ orderBy:(NSString *)orderBy
+ filter:(NSString *)filter
+
relationships:(CMISIncludeRelationship)relationships
+ renditionFilter:(NSString *)renditionFilter
+
includeAllowableActions:(BOOL)includeAllowableActions
+ skipCount:(NSNumber *)skipCount
+ maxItems:(NSNumber *)maxItems
+ completionBlock:(void (^)(CMISObjectList
*objectList, NSError *error))completionBlock
+{
+ // Get checked out link
+ NSString *checkedoutLink = [self.bindingSession
objectForKey:kCMISAtomBindingSessionKeyCheckedoutCollection];
+ if (checkedoutLink == nil) {
+ CMISLogDebug(@"Checkedout not supported!");
+ completionBlock(nil, [CMISErrors
createCMISErrorWithCode:kCMISErrorCodeNotSupported detailedDescription:nil]);
+ return nil;
+ }
+
+ // add the parameters to the URL (CMISUrlUtil will not append if the param
name or value is nil)
+ checkedoutLink = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterFolderId value:folderId
urlString:checkedoutLink];
+ checkedoutLink = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterFilter value:filter
urlString:checkedoutLink];
+ checkedoutLink = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterOrderBy value:orderBy
urlString:checkedoutLink];
+ checkedoutLink = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterIncludeAllowableActions
value:(includeAllowableActions ? @"true" : @"false") urlString:checkedoutLink];
+ checkedoutLink = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterIncludeRelationships
value:[CMISEnums stringForIncludeRelationShip:relationships]
urlString:checkedoutLink];
+ checkedoutLink = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterRenditionFilter
value:renditionFilter urlString:checkedoutLink];
+ checkedoutLink = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterMaxItems value:[maxItems
stringValue] urlString:checkedoutLink];
+ checkedoutLink = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterSkipCount value:[skipCount
stringValue] urlString:checkedoutLink];
+
+ // retrieve the list
+ CMISRequest *request = [[CMISRequest alloc] init];
+ [self.bindingSession.networkProvider invokeGET:[NSURL
URLWithString:checkedoutLink]
+ session:self.bindingSession
+ cmisRequest:request
+ completionBlock:^(CMISHttpResponse
*httpResponse, NSError *error) {
+ if (httpResponse) {
+ if (httpResponse.data == nil) {
+ NSError *error = [CMISErrors
createCMISErrorWithCode:kCMISErrorCodeConnection detailedDescription:nil];
+ completionBlock(nil, error);
+ return;
+ }
+
+ // Parse the feed (containing entries for the documents)
+ 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
cmisErrorCode:kCMISErrorCodeRuntime];
+ completionBlock(nil, error);
+ }
+ } else {
+ completionBlock(nil, error);
+ }
+ }];
+
+ return request;
+}
+
@end
Modified:
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserNavigationService.m
URL:
http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserNavigationService.m?rev=1631391&r1=1631390&r2=1631391&view=diff
==============================================================================
---
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserNavigationService.m
(original)
+++
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserNavigationService.m
Mon Oct 13 13:41:53 2014
@@ -112,4 +112,52 @@
return cmisRequest;
}
+- (CMISRequest*)retrieveCheckedOutDocumentsInFolder:(NSString *)folderId
+ orderBy:(NSString *)orderBy
+ filter:(NSString *)filter
+
relationships:(CMISIncludeRelationship)relationships
+ renditionFilter:(NSString *)renditionFilter
+
includeAllowableActions:(BOOL)includeAllowableActions
+ skipCount:(NSNumber *)skipCount
+ maxItems:(NSNumber *)maxItems
+ completionBlock:(void (^)(CMISObjectList
*objectList, NSError *error))completionBlock
+{
+ NSString *checkedOutUrl = nil;
+ if (folderId != nil) {
+ checkedOutUrl = [self retrieveObjectUrlForObjectWithId:folderId
selector:kCMISBrowserJSONSelectorCheckedout];
+ } else {
+ checkedOutUrl = [self
retrieveRepositoryUrlWithSelector:kCMISBrowserJSONSelectorCheckedout];
+ }
+ checkedOutUrl = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterFilter value:filter
urlString:checkedOutUrl];
+ checkedOutUrl = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterOrderBy value:orderBy
urlString:checkedOutUrl];
+ checkedOutUrl = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterIncludeAllowableActions
boolValue:includeAllowableActions urlString:checkedOutUrl];
+ checkedOutUrl = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterIncludeRelationships
value:[CMISEnums stringForIncludeRelationShip:relationships]
urlString:checkedOutUrl];
+ checkedOutUrl = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterRenditionFilter
value:renditionFilter urlString:checkedOutUrl];
+ checkedOutUrl = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterMaxItems numberValue:maxItems
urlString:checkedOutUrl];
+ checkedOutUrl = [CMISURLUtil
urlStringByAppendingParameter:kCMISParameterSkipCount numberValue:skipCount
urlString:checkedOutUrl];
+ checkedOutUrl = [CMISURLUtil
urlStringByAppendingParameter:kCMISBrowserJSONParameterSuccinct
value:kCMISParameterValueTrue urlString:checkedOutUrl];
+
+ CMISRequest *cmisRequest = [[CMISRequest alloc] init];
+
+ [self.bindingSession.networkProvider invokeGET:[NSURL
URLWithString:checkedOutUrl]
+ session:self.bindingSession
+ cmisRequest:cmisRequest
+ completionBlock:^(CMISHttpResponse
*httpResponse, NSError *error) {
+ if (httpResponse.statusCode == 200 &&
httpResponse.data) {
+ CMISBrowserTypeCache *typeCache =
[[CMISBrowserTypeCache alloc]
initWithRepositoryId:self.bindingSession.repositoryId bindingService:self];
+ [CMISBrowserUtil
objectListFromJSONData:httpResponse.data typeCache:typeCache isQueryResult:NO
completionBlock:^(CMISObjectList *objectList, NSError *error) {
+ if (error) {
+ completionBlock(nil, error);
+ } else {
+ completionBlock(objectList,
nil);
+ }
+ }];
+ } else {
+ completionBlock(nil, error);
+ }
+ }];
+
+ return cmisRequest;
+}
+
@end
Modified:
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISNavigationService.h
URL:
http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISNavigationService.h?rev=1631391&r1=1631390&r2=1631391&view=diff
==============================================================================
---
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISNavigationService.h
(original)
+++
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISNavigationService.h
Mon Oct 13 13:41:53 2014
@@ -31,15 +31,15 @@
* completionBlock returns object list or nil if unsuccessful
*/
- (CMISRequest*)retrieveChildren:(NSString *)objectId
- orderBy:(NSString *)orderBy
- filter:(NSString *)filter
- relationships:(CMISIncludeRelationship)relationships
- renditionFilter:(NSString *)renditionFilter
- includeAllowableActions:(BOOL)includeAllowableActions
- includePathSegment:(BOOL)includePathSegment
- skipCount:(NSNumber *)skipCount
- maxItems:(NSNumber *)maxItems
- completionBlock:(void (^)(CMISObjectList *objectList, NSError
*error))completionBlock;
+ orderBy:(NSString *)orderBy
+ filter:(NSString *)filter
+ relationships:(CMISIncludeRelationship)relationships
+ renditionFilter:(NSString *)renditionFilter
+ includeAllowableActions:(BOOL)includeAllowableActions
+ includePathSegment:(BOOL)includePathSegment
+ skipCount:(NSNumber *)skipCount
+ maxItems:(NSNumber *)maxItems
+ completionBlock:(void (^)(CMISObjectList *objectList, NSError
*error))completionBlock;
/**
* Retrieves the parent of a given object.
@@ -49,12 +49,24 @@
* completionBlock returns array of parents or nil if unsuccessful
*/
- (CMISRequest*)retrieveParentsForObject:(NSString *)objectId
- filter:(NSString *)filter
- relationships:(CMISIncludeRelationship)relationships
- renditionFilter:(NSString *)renditionFilter
- includeAllowableActions:(BOOL)includeAllowableActions
- includeRelativePathSegment:(BOOL)includeRelativePathSegment
- completionBlock:(void (^)(NSArray *parents, NSError
*error))completionBlock;
+ filter:(NSString *)filter
+ relationships:(CMISIncludeRelationship)relationships
+ renditionFilter:(NSString *)renditionFilter
+ includeAllowableActions:(BOOL)includeAllowableActions
+ includeRelativePathSegment:(BOOL)includeRelativePathSegment
+ completionBlock:(void (^)(NSArray *parents, NSError
*error))completionBlock;
+/**
+ * Retrieves the checked out documents for the current user.
+ */
+- (CMISRequest*)retrieveCheckedOutDocumentsInFolder:(NSString *)folderId
+ orderBy:(NSString *)orderBy
+ filter:(NSString *)filter
+
relationships:(CMISIncludeRelationship)relationships
+ renditionFilter:(NSString *)renditionFilter
+
includeAllowableActions:(BOOL)includeAllowableActions
+ skipCount:(NSNumber *)skipCount
+ maxItems:(NSNumber *)maxItems
+ completionBlock:(void (^)(CMISObjectList
*objectList, NSError *error))completionBlock;
@end
Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.h
URL:
http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.h?rev=1631391&r1=1631390&r2=1631391&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.h (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.h Mon Oct 13
13:41:53 2014
@@ -76,7 +76,20 @@
*/
- (CMISRequest*)retrieveFolderWithOperationContext:(CMISOperationContext
*)operationContext
completionBlock:(void (^)(CMISFolder *folder,
NSError *error))completionBlock;
-
+
+/**
+ * Retrieves a list of documents the current user has checked out.
+ * completionBlock returns the checked out documents as a paged results object
or nil if unsuccessful.
+ */
+- (CMISRequest*)retrieveCheckedOutDocumentsWithCompletionBlock:(void
(^)(CMISPagedResult *result, NSError *error))completionBlock;
+
+/**
+ * Retrieves a list of documents the current user has checked out using the
provided operation context.
+ * completionBlock returns the checked out documents as a paged results object
or nil if unsuccessful.
+ */
+-
(CMISRequest*)retrieveCheckedOutDocumentsWithOperationContext:(CMISOperationContext
*)operationContext
+ completionBlock:(void
(^)(CMISPagedResult *result, NSError *error))completionBlock;
+
/**
* Retrieves the object with the given identifier.
* completionBlock returns the CMIS object or nil if unsuccessful
Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m
URL:
http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m?rev=1631391&r1=1631390&r2=1631391&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m Mon Oct 13
13:41:53 2014
@@ -186,6 +186,59 @@
}];
}
+- (CMISRequest*)retrieveCheckedOutDocumentsWithCompletionBlock:(void
(^)(CMISPagedResult *result, NSError *error))completionBlock
+{
+ return [self
retrieveCheckedOutDocumentsWithOperationContext:[CMISOperationContext
defaultOperationContext] completionBlock:completionBlock];
+}
+
+-
(CMISRequest*)retrieveCheckedOutDocumentsWithOperationContext:(CMISOperationContext
*)operationContext
+ completionBlock:(void
(^)(CMISPagedResult *result, NSError *error))completionBlock
+{
+ CMISRequest *request = [[CMISRequest alloc] init];
+ CMISFetchNextPageBlock fetchNextPageBlock = ^(int skipCount, int maxItems,
CMISFetchNextPageBlockCompletionBlock pageBlockCompletionBlock)
+ {
+ // Fetch results through navigationService
+ CMISRequest * checkedoutRequest = [self.binding.navigationService
retrieveCheckedOutDocumentsInFolder:nil
+
orderBy:operationContext.orderBy
+
filter:operationContext.filterString
+
relationships:operationContext.relationships
+
renditionFilter:operationContext.renditionFilterString
+
includeAllowableActions:operationContext.includeAllowableActions
+
skipCount:[NSNumber numberWithInt:skipCount]
+
maxItems:[NSNumber numberWithInt:maxItems]
+
completionBlock:^(CMISObjectList *objectList, NSError *error) {
+
if (error) {
+
pageBlockCompletionBlock(nil, [CMISErrors cmisError:error
cmisErrorCode:kCMISErrorCodeConnection]);
+ }
else {
+
CMISFetchNextPageBlockResult *result = [[CMISFetchNextPageBlockResult alloc]
init];
+
result.hasMoreItems = objectList.hasMoreItems;
+
result.numItems = objectList.numItems;
+
+
[self.objectConverter convertObjects:objectList.objects
+
completionBlock:^(NSArray *objects, NSError *error) {
+
result.resultArray = objects;
+
pageBlockCompletionBlock(result, error);
+
}];
+ }
+ }];
+
+ // set the underlying request object on the object returned to the
original caller
+ request.httpRequest = checkedoutRequest.httpRequest;
+ };
+
+ [CMISPagedResult pagedResultUsingFetchBlock:fetchNextPageBlock
+
limitToMaxItems:operationContext.maxItemsPerPage
+ startFromSkipCount:operationContext.skipCount
+ completionBlock:^(CMISPagedResult *result,
NSError *error) {
+ if (error) {
+ completionBlock(nil, [CMISErrors
cmisError:error cmisErrorCode:kCMISErrorCodeRuntime]);
+ } else {
+ completionBlock(result, nil);
+ }
+ }];
+ return request;
+}
+
- (CMISRequest*)retrieveObject:(NSString *)objectId completionBlock:(void
(^)(CMISObject *object, NSError *error))completionBlock
{
return [self retrieveObject:objectId
operationContext:[CMISOperationContext defaultOperationContext]
completionBlock:completionBlock];
Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Common/CMISConstants.h
URL:
http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Common/CMISConstants.h?rev=1631391&r1=1631390&r2=1631391&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Common/CMISConstants.h
(original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Common/CMISConstants.h Mon Oct
13 13:41:53 2014
@@ -103,6 +103,7 @@ extern NSString * const kCMISParameterIn
extern NSString * const kCMISParameterFilter;
extern NSString * const kCMISParameterMaxItems;
extern NSString * const kCMISParameterObjectId;
+extern NSString * const kCMISParameterFolderId;
extern NSString * const kCMISParameterOrderBy;
extern NSString * const kCMISParameterIncludePathSegment;
extern NSString * const kCMISParameterIncludeRelationships;
Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Common/CMISConstants.m
URL:
http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Common/CMISConstants.m?rev=1631391&r1=1631390&r2=1631391&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Common/CMISConstants.m
(original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Common/CMISConstants.m Mon Oct
13 13:41:53 2014
@@ -115,6 +115,7 @@ NSString * const kCMISParameterIncludeAl
NSString * const kCMISParameterFilter = @"filter";
NSString * const kCMISParameterMaxItems = @"maxItems";
NSString * const kCMISParameterObjectId = @"objectId";
+NSString * const kCMISParameterFolderId = @"folderId";
NSString * const kCMISParameterOrderBy = @"orderBy";
NSString * const kCMISParameterIncludePathSegment = @"includePathSegment";
NSString * const kCMISParameterIncludeRelationships = @"includeRelationships";
Modified: chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m
URL:
http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m?rev=1631391&r1=1631390&r2=1631391&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m
(original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m Mon
Oct 13 13:41:53 2014
@@ -2368,6 +2368,67 @@
}];
}
+- (void)testCheckedOutDocuments
+{
+ [self runTest:^ {
+ // Upload test file
+ [self uploadTestFileWithCompletionBlock:^(CMISDocument *testDocument) {
+
+ XCTAssertNotNil(testDocument, @"Expected testDocument to be
uploaded!");
+
+ // checkout the uploaded test document
+ [testDocument checkOutWithCompletionBlock:^(CMISDocument
*privateWorkingCopy, NSError *checkOutError) {
+ XCTAssertNotNil(privateWorkingCopy, @"Expected to recieve the
private working copy object");
+
+ // retrieve the checked out documents
+ [self.session
retrieveCheckedOutDocumentsWithCompletionBlock:^(CMISPagedResult
*checkedOutDocs, NSError *retrieveError) {
+ XCTAssertNotNil(checkedOutDocs, @"Expected to receive a
paged result");
+
+ // ensure the PWC is part of the list
+ BOOL pwcFound = NO;
+ for (CMISObject *object in checkedOutDocs.resultArray)
+ {
+ if ([object.identifier
isEqualToString:privateWorkingCopy.identifier])
+ {
+ pwcFound = YES;
+ break;
+ }
+ }
+ XCTAssertTrue(pwcFound, @"Expected to find the private
working copy in the checkedout files");
+
+ // cancel checkout of the test document
+ [privateWorkingCopy
cancelCheckOutWithCompletionBlock:^(BOOL checkoutCancelled, NSError
*cancelError) {
+ XCTAssertTrue(checkoutCancelled, @"Expected cancel
checkout to be successful");
+
+ // retrieve checked out documents and ensure test
document is not listed
+ [self.session
retrieveCheckedOutDocumentsWithCompletionBlock:^(CMISPagedResult
*checkedOutDocs2, NSError *retrieveError2) {
+ XCTAssertNotNil(checkedOutDocs2, @"Expected to
receive a paged result");
+
+ // ensure the PWC is NOT part of the list
+ BOOL pwcFound2 = NO;
+ for (CMISObject *object in
checkedOutDocs2.resultArray)
+ {
+ if ([object.identifier
isEqualToString:privateWorkingCopy.identifier])
+ {
+ pwcFound2 = YES;
+ break;
+ }
+ }
+ XCTAssertFalse(pwcFound2, @"Did not expect to find
the private working copy in the checkedout files");
+
+ // delete the test document
+ [self deleteDocumentAndVerify:testDocument
completionBlock:^{
+ // mark the test as completed
+ self.testCompleted = YES;
+ }];
+ }];
+ }];
+ }];
+ }];
+ }];
+ }];
+}
+
- (void)testSecondaryTypes
{
[self runTest:^ {