You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by ga...@apache.org on 2014/03/29 22:54:24 UTC
svn commit: r1583066 [2/2] - in
/chemistry/objectivecmis/branches/browser-binding: ObjectiveCMIS.xcodeproj/
ObjectiveCMIS/Bindings/ ObjectiveCMIS/Bindings/AtomPub/
ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/
ObjectiveCMIS/Bindings/Browser/ ObjectiveC...
Added: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m?rev=1583066&view=auto
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m (added)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m Sat Mar 29 21:54:23 2014
@@ -0,0 +1,257 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import "CMISBrowserUtil.h"
+#import "CMISConstants.h"
+#import "CMISBrowserConstants.h"
+#import "CMISRepositoryInfo.h"
+#import "CMISPropertyDefinition.h"
+
+@implementation CMISBrowserUtil
+
++ (NSDictionary *)repositoryInfoDictionaryFromJSONData:(NSData *)jsonData bindingSession:(CMISBindingSession *)bindingSession error:(NSError **)outError
+{
+ // TODO: error handling i.e. if jsonData is nil, also handle outError being nil
+
+ // parse the JSON response
+ NSError *serialisationError = nil;
+ id jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&serialisationError];
+
+ NSMutableDictionary *repositories = nil;
+ if (!serialisationError) {
+ repositories = [NSMutableDictionary dictionary];
+
+ // parse the json into CMISRepositoryInfo objects and store in self.repositories
+ NSArray *repos = [jsonDictionary allValues];
+ for (NSDictionary *repo in repos) {
+ CMISRepositoryInfo *repoInfo = [CMISRepositoryInfo new];
+ repoInfo.identifier = repo[kCMISBrowserJSONRepositoryId];
+ repoInfo.name = repo[kCMISBrowserJSONRepositoryName];
+ repoInfo.desc = repo[kCMISBrowserJSONRepositoryDescription];
+ repoInfo.rootFolderId = repo[kCMISBrowserJSONRootFolderId];
+ repoInfo.cmisVersionSupported = repo[kCMISBrowserJSONCMISVersionSupported];
+ repoInfo.productName = repo[kCMISBrowserJSONProductName];
+ repoInfo.productVersion = repo[kCMISBrowserJSONProductVersion];
+ repoInfo.vendorName = repo[kCMISBrowserJSONVendorName];
+ repoInfo.principalIdAnonymous = repo[kCMISBrowserJSONPrincipalIdAnonymous];
+ repoInfo.principalIdAnyone = repo[kCMISBrowserJSONPrincipalIdAnyone];
+
+ // store the repo and root folder URLs in the session (when the repoId matches)
+ if ([repoInfo.identifier isEqualToString:bindingSession.repositoryId]) {
+ [bindingSession setObject:repo[kCMISBrowserJSONRootFolderUrl] forKey:kCMISBrowserBindingSessionKeyRootFolderUrl];
+ [bindingSession setObject:repo[kCMISBrowserJSONRepositoryUrl] forKey:kCMISBrowserBindingSessionKeyRepositoryUrl];
+ }
+
+ [repositories setObject:repoInfo forKey:repoInfo.identifier];
+ }
+ }
+
+ return repositories;
+}
+
++ (CMISTypeDefinition *)typeDefinitionFromJSONData:(NSData *)jsonData error:(NSError **)outError
+{
+ // TODO: error handling i.e. if jsonData is nil, also handle outError being nil
+
+ // parse the JSON response
+ NSError *serialisationError = nil;
+ id jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&serialisationError];
+
+ CMISTypeDefinition *typeDef = nil;
+ if (!serialisationError) {
+ typeDef = [CMISTypeDefinition new];
+ typeDef.id = jsonDictionary[kCMISBrowserJSONId];
+ typeDef.localName = jsonDictionary[kCMISBrowserJSONLocalName];
+ typeDef.localNameSpace = jsonDictionary[kCMISBrowserJSONLocalNamespace];
+ typeDef.displayName = jsonDictionary[kCMISBrowserJSONDisplayName];
+ typeDef.queryName = jsonDictionary[kCMISBrowserJSONQueryName];
+ typeDef.description = jsonDictionary[kCMISBrowserJSONDescription];
+
+ NSString *baseIdString = jsonDictionary[kCMISBrowserJSONBaseId];
+ if ([baseIdString isEqualToString:kCMISPropertyObjectTypeIdValueDocument]) {
+ typeDef.baseTypeId = CMISBaseTypeDocument;
+ } else if ([baseIdString isEqualToString:kCMISPropertyObjectTypeIdValueFolder]) {
+ typeDef.baseTypeId = CMISBaseTypeFolder;
+ }
+
+ typeDef.creatable = [jsonDictionary[kCMISBrowserJSONCreateable] boolValue];
+ typeDef.fileable = [jsonDictionary[kCMISBrowserJSONFileable] boolValue];
+ typeDef.queryable = [jsonDictionary[kCMISBrowserJSONQueryable] boolValue];
+ typeDef.fullTextIndexed = [jsonDictionary[kCMISBrowserJSONFullTextIndexed] boolValue];
+ typeDef.includedInSupertypeQuery = [jsonDictionary[kCMISBrowserJSONIncludedInSuperTypeQuery] boolValue];
+ typeDef.controllablePolicy = [jsonDictionary[kCMISBrowserJSONControllablePolicy] boolValue];
+ typeDef.controllableAcl = [jsonDictionary[kCMISBrowserJSONControllableAcl] boolValue];
+
+ NSDictionary *propertyDefinitions = jsonDictionary[kCMISBrowserJSONPropertyDefinitions];
+ for (NSDictionary *propertyDictionary in [propertyDefinitions allValues]) {
+ // create property definition and add to type definition
+ CMISPropertyDefinition *propDef = [CMISPropertyDefinition new];
+ propDef.id = propertyDictionary[kCMISBrowserJSONId];
+ propDef.localName = propertyDictionary[kCMISBrowserJSONLocalName];
+ propDef.localNamespace = propertyDictionary[kCMISBrowserJSONLocalNamespace];
+ propDef.displayName = propertyDictionary[kCMISBrowserJSONDisplayName];
+ propDef.queryName = propertyDictionary[kCMISBrowserJSONQueryName];
+ propDef.description = propertyDictionary[kCMISBrowserJSONDescription];
+ propDef.inherited = [propertyDictionary[kCMISBrowserJSONInherited] boolValue];
+ propDef.required = [propertyDictionary[kCMISBrowserJSONRequired] boolValue];
+ propDef.queryable = [propertyDictionary[kCMISBrowserJSONQueryable] boolValue];
+ propDef.orderable = [propertyDictionary[kCMISBrowserJSONOrderable] boolValue];
+
+ // determine property type
+ NSString *typeString = propertyDictionary[kCMISBrowserJSONPropertyType];
+ if ([typeString isEqualToString:kCMISBrowserJSONPropertyTypeValueString]) {
+ propDef.propertyType = CMISPropertyTypeString;
+ } else if ([typeString isEqualToString:kCMISBrowserJSONPropertyTypeValueId]) {
+ propDef.propertyType = CMISPropertyTypeId;
+ } else if ([typeString isEqualToString:kCMISBrowserJSONPropertyTypeValueInteger]) {
+ propDef.propertyType = CMISPropertyTypeInteger;
+ } else if ([typeString isEqualToString:kCMISBrowserJSONPropertyTypeValueDecimal]) {
+ propDef.propertyType = CMISPropertyTypeDecimal;
+ } else if ([typeString isEqualToString:kCMISBrowserJSONPropertyTypeValueBoolean]) {
+ propDef.propertyType = CMISPropertyTypeBoolean;
+ } else if ([typeString isEqualToString:kCMISBrowserJSONPropertyTypeValueDateTime]) {
+ propDef.propertyType = CMISPropertyTypeDateTime;
+ } else if ([typeString isEqualToString:kCMISBrowserJSONPropertyTypeValueHtml]) {
+ propDef.propertyType = CMISPropertyTypeHtml;
+ } else if ([typeString isEqualToString:kCMISBrowserJSONPropertyTypeValueUri]) {
+ propDef.propertyType = CMISPropertyTypeUri;
+ }
+
+ // determine cardinality
+ NSString *cardinalityString = propertyDictionary[kCMISBrowserJSONCardinality];
+ if ([cardinalityString isEqualToString:kCMISBrowserJSONCardinalityValueSingle]) {
+ propDef.cardinality = CMISCardinalitySingle;
+ } else if ([cardinalityString isEqualToString:kCMISBrowserJSONCardinalityValueMultiple]) {
+ propDef.cardinality = CMISCardinalityMulti;
+ }
+
+ // determine updatability
+ NSString *updatabilityString = propertyDictionary[kCMISBrowserJSONUpdateability];
+ if ([updatabilityString isEqualToString:kCMISBrowserJSONUpdateabilityValueReadOnly]) {
+ propDef.updatability = CMISUpdatabilityReadOnly;
+ } else if ([updatabilityString isEqualToString:kCMISBrowserJSONUpdateabilityValueReadWrite]) {
+ propDef.updatability = CMISUpdatabilityReadWrite;
+ } else if ([updatabilityString isEqualToString:kCMISBrowserJSONUpdateabilityValueOnCreate]) {
+ propDef.updatability = CMISUpdatabilityOnCreate;
+ } else if ([updatabilityString isEqualToString:kCMISBrowserJSONUpdateabilityValueWhenCheckedOut]) {
+ propDef.updatability = CMISUpdatabilityWhenCheckedOut;
+ }
+
+ // TODO: look for restricted choices
+ propDef.openChoice = YES;
+
+ [typeDef addPropertyDefinition:propDef];
+ }
+ }
+
+ return typeDef;
+}
+
++ (CMISObjectData *)objectDataFromJSONData:(NSData *)jsonData error:(NSError **)outError
+{
+ // TODO: error handling i.e. if jsonData is nil, also handle outError being nil
+
+ // parse the JSON response
+ NSError *serialisationError = nil;
+ id jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&serialisationError];
+
+ CMISObjectData *objectData = nil;
+ if (!serialisationError) {
+ // parse the json into a CMISObjectData object
+ objectData = [CMISBrowserUtil objectDataFromDictionary:jsonDictionary];
+ }
+
+ return objectData;
+}
+
++ (CMISObjectList *)objectListFromJSONData:(NSData *)jsonData error:(NSError **)outError
+{
+ // TODO: error handling i.e. if jsonData is nil, also handle outError being nil
+
+ // parse the JSON response
+ NSError *serialisationError = nil;
+ id jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&serialisationError];
+
+ CMISObjectList *objectList = nil;
+ if (!serialisationError) {
+ // parse the json into a CMISObjectList object
+ objectList = [CMISObjectList new];
+
+ // parse the objects
+ NSArray *objectsArray = jsonDictionary[@"objects"];
+ if (objectsArray) {
+ NSMutableArray *objects = [NSMutableArray arrayWithCapacity:objectsArray.count];
+ for (NSDictionary *dictionary in objectsArray) {
+ NSDictionary *objectDictionary = dictionary[@"object"];
+ CMISObjectData *objectData = [CMISBrowserUtil objectDataFromDictionary:objectDictionary];
+ [objects addObject:objectData];
+ }
+
+ // pass objects to list
+ objectList.objects = objects;
+ }
+
+ // retrieve the paging data
+ objectList.hasMoreItems = [jsonDictionary[@"hasMoreItems"] boolValue];
+ objectList.numItems = [jsonDictionary[@"numItems"] intValue];
+ }
+
+ return objectList;
+}
+
+#pragma mark -
+#pragma mark Private helper methods
+
++ (CMISObjectData *)objectDataFromDictionary:(NSDictionary *)dictionary
+{
+ CMISObjectData *objectData = [CMISObjectData new];
+ NSDictionary *propertiesJson = dictionary[@"succinctProperties"];
+ objectData.identifier = propertiesJson[kCMISPropertyObjectId];
+
+ // determine the object type
+ NSString *baseType = propertiesJson[kCMISPropertyBaseTypeId];
+ if ([baseType isEqualToString:kCMISPropertyObjectTypeIdValueDocument]) {
+ objectData.baseType = CMISBaseTypeDocument;
+ } else if ([baseType isEqualToString:kCMISPropertyObjectTypeIdValueFolder]) {
+ objectData.baseType = CMISBaseTypeFolder;
+ }
+
+ // create properties
+ CMISProperties *properties = [CMISProperties new];
+ NSArray *propNames = [propertiesJson allKeys];
+ for (NSString *propName in propNames) {
+ CMISPropertyData *propertyData;
+ id propValue = propertiesJson[propName];
+ if ([propValue isKindOfClass:[NSArray class]]) {
+ propertyData = [CMISPropertyData createPropertyForId:propName arrayValue:propValue type:CMISPropertyTypeString];
+ }
+ else {
+ propertyData = [CMISPropertyData createPropertyForId:propName stringValue:propValue];
+ }
+
+ [properties addProperty:propertyData];
+ }
+
+ // set the properties
+ objectData.properties = properties;
+
+ return objectData;
+}
+
+@end
Added: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserVersioningService.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserVersioningService.h?rev=1583066&view=auto
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserVersioningService.h (added)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserVersioningService.h Sat Mar 29 21:54:23 2014
@@ -0,0 +1,24 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import "CMISBrowserBaseService.h"
+
+@interface CMISBrowserVersioningService : CMISBrowserBaseService <CMISVersioningService>
+
+@end
Added: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserVersioningService.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserVersioningService.m?rev=1583066&view=auto
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserVersioningService.m (added)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserVersioningService.m Sat Mar 29 21:54:23 2014
@@ -0,0 +1,131 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import "CMISBrowserVersioningService.h"
+
+@implementation CMISBrowserVersioningService
+
+- (CMISRequest*)retrieveObjectOfLatestVersion:(NSString *)objectId
+ major:(BOOL)major
+ filter:(NSString *)filter
+ relationships:(CMISIncludeRelationship)relationships
+ includePolicyIds:(BOOL)includePolicyIds
+ renditionFilter:(NSString *)renditionFilter
+ includeACL:(BOOL)includeACL
+ includeAllowableActions:(BOOL)includeAllowableActions
+ completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+{
+ NSString * message = [NSString stringWithFormat:@"%s is not implemented yet", __PRETTY_FUNCTION__];
+ NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException reason:message userInfo:nil];
+ @throw exception;
+}
+
+- (CMISRequest*)retrieveAllVersions:(NSString *)objectId
+ filter:(NSString *)filter
+ includeAllowableActions:(BOOL)includeAllowableActions
+ completionBlock:(void (^)(NSArray *objects, NSError *error))completionBlock
+{
+ NSString * message = [NSString stringWithFormat:@"%s is not implemented yet", __PRETTY_FUNCTION__];
+ NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException reason:message userInfo:nil];
+ @throw exception;
+}
+
+/**
+ * Create a private working copy of a document given an object identifier.
+ *
+ * @param objectId
+ * @param completionBlock returns PWC object data or nil
+ */
+- (CMISRequest*)checkOut:(NSString *)objectId
+ completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+{
+ NSString * message = [NSString stringWithFormat:@"%s is not implemented yet", __PRETTY_FUNCTION__];
+ NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException reason:message userInfo:nil];
+ @throw exception;
+}
+
+/**
+ * Reverses the effect of a check-out.
+ *
+ * @param objectId
+ * @param completionBlock returns object data or nil
+ */
+- (CMISRequest*)cancelCheckOut:(NSString *)objectId
+ completionBlock:(void (^)(BOOL checkOutCancelled, NSError *error))completionBlock
+{
+ NSString * message = [NSString stringWithFormat:@"%s is not implemented yet", __PRETTY_FUNCTION__];
+ NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException reason:message userInfo:nil];
+ @throw exception;
+}
+
+/**
+ * Checks-in the private working copy (PWC) document from the given path.
+ *
+ * @param objectId the identifier for the PWC
+ * @param asMajorVersion indicator if the new version should become a major (YES) or minor (NO) version
+ * @param filePath (optional) Path to the file containing the content to be uploaded
+ * @param mimeType (optional) Mime type of the content to be uploaded
+ * @param properties (optional) the property values that must be applied to the checked-in document object
+ * @param checkinComment (optional) a version comment
+ * @param completionBlock returns object data or nil
+ * @param progressBlock periodic file upload status
+ */
+- (CMISRequest*)checkIn:(NSString *)objectId
+ asMajorVersion:(BOOL)asMajorVersion
+ filePath:(NSString *)filePath
+ mimeType:(NSString *)mimeType
+ properties:(CMISProperties *)properties
+ checkinComment:(NSString *)checkinComment
+ completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+ progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
+{
+ NSString * message = [NSString stringWithFormat:@"%s is not implemented yet", __PRETTY_FUNCTION__];
+ NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException reason:message userInfo:nil];
+ @throw exception;
+}
+
+/**
+ * Checks-in the private working copy (PWC) document from the given an input stream.
+ *
+ * @param objectId the identifier for the PWC
+ * @param asMajorVersion indicator if the new version should become a major (YES) or minor (NO) version
+ * @param inputStream (optional) Input stream containing the content to be uploaded
+ * @param bytesExpected The size of content to be uploaded (must be provided if an inputStream is given)
+ * @param mimeType (optional) Mime type of the content to be uploaded
+ * @param properties (optional) the property values that must be applied to the checked-in document object
+ * @param checkinComment (optional) a version comment
+ * @param completionBlock returns object data or nil
+ * @param progressBlock periodic file upload status
+ */
+- (CMISRequest*)checkIn:(NSString *)objectId
+ asMajorVersion:(BOOL)asMajorVersion
+ inputStream:(NSInputStream *)inputStream
+ bytesExpected:(unsigned long long)bytesExpected
+ mimeType:(NSString *)mimeType
+ properties:(CMISProperties *)properties
+ checkinComment:(NSString *)checkinComment
+ completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
+ progressBlock:(void (^)(unsigned long long bytesUploaded, unsigned long long bytesTotal))progressBlock
+{
+ NSString * message = [NSString stringWithFormat:@"%s is not implemented yet", __PRETTY_FUNCTION__];
+ NSException *exception = [NSException exceptionWithName:NSInvalidArgumentException reason:message userInfo:nil];
+ @throw exception;
+}
+
+@end
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingFactory.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingFactory.m?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingFactory.m (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingFactory.m Sat Mar 29 21:54:23 2014
@@ -19,6 +19,7 @@
#import "CMISBindingFactory.h"
#import "CMISAtomPubBinding.h"
+#import "CMISBrowserBinding.h"
@implementation CMISBindingFactory
@@ -32,6 +33,9 @@
if (sessionParameters.bindingType == CMISBindingTypeAtomPub) {
binding = [[CMISAtomPubBinding alloc] initWithSessionParameters:sessionParameters];
}
+ else if (sessionParameters.bindingType == CMISBindingTypeBrowser) {
+ binding = [[CMISBrowserBinding alloc] initWithSessionParameters:sessionParameters];
+ }
return binding;
}
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.h?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.h (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.h Sat Mar 29 21:54:23 2014
@@ -22,16 +22,11 @@
#import "CMISAuthenticationProvider.h"
#import "CMISNetworkProvider.h"
-extern NSString * const kCMISBindingSessionKeyAtomPubUrl;
+// session key constants
+extern NSString * const kCMISBindingSessionKeyUrl;
extern NSString * const kCMISBindingSessionKeyObjectByIdUriBuilder;
extern NSString * const kCMISBindingSessionKeyObjectByPathUriBuilder;
extern NSString * const kCMISBindingSessionKeyTypeByIdUriBuilder;
-extern NSString * const kCMISBindingSessionKeyQueryUri;
-
-extern NSString * const kCMISBindingSessionKeyQueryCollection;
-extern NSString * const kCMISBindingSessionKeyCheckedoutCollection;
-
-extern NSString * const kCMISBindingSessionKeyLinkCache;
@interface CMISBindingSession : NSObject
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.m?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.m (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.m Sat Mar 29 21:54:23 2014
@@ -19,16 +19,10 @@
#import "CMISBindingSession.h"
-NSString * const kCMISBindingSessionKeyAtomPubUrl = @"cmis_session_key_atompub_url";
+NSString * const kCMISBindingSessionKeyUrl = @"cmis_session_key_url";
NSString * const kCMISBindingSessionKeyObjectByIdUriBuilder = @"cmis_session_key_objectbyid_uri_builder";
NSString * const kCMISBindingSessionKeyObjectByPathUriBuilder = @"cmis_session_key_objectbypath_uri_builder";
NSString * const kCMISBindingSessionKeyTypeByIdUriBuilder = @"cmis_session_key_type_by_id_uri_builder";
-NSString * const kCMISBindingSessionKeyQueryUri = @"cmis_session_key_query_uri";
-
-NSString * const kCMISBindingSessionKeyQueryCollection = @"cmis_session_key_query_collection";
-NSString * const kCMISBindingSessionKeyCheckedoutCollection = @"cmis_session_key_checkedout_collection";
-
-NSString * const kCMISBindingSessionKeyLinkCache = @"cmis_session_key_link_cache";
@interface CMISBindingSession ()
@property (nonatomic, strong, readwrite) NSString *username;
@@ -53,9 +47,14 @@ NSString * const kCMISBindingSessionKeyL
self.authenticationProvider = sessionParameters.authenticationProvider;
self.networkProvider = sessionParameters.networkProvider;
- // store all other data in the dictionary
- [self.sessionData setObject:sessionParameters.atomPubUrl forKey:kCMISBindingSessionKeyAtomPubUrl];
+ if (sessionParameters.bindingType == CMISBindingTypeAtomPub) {
+ [self.sessionData setObject:sessionParameters.atomPubUrl forKey:kCMISBindingSessionKeyUrl];
+ }
+ else {
+ [self.sessionData setObject:sessionParameters.browserUrl forKey:kCMISBindingSessionKeyUrl];
+ }
+ // store all other data in the dictionary
for (id key in sessionParameters.allKeys) {
[self.sessionData setObject:[sessionParameters objectForKey:key] forKey:key];
}
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISTypeDefinition.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISTypeDefinition.h?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISTypeDefinition.h (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISTypeDefinition.h Sat Mar 29 21:54:23 2014
@@ -25,6 +25,9 @@
@interface CMISTypeDefinition : NSObject
+// TODO: rename "id" property to identifier as id is a reserved keyword in ObjectiveC
+// TODO: rename "description" property to summary as description is a reserved keyword in ObjectiveC
+
@property (nonatomic, strong) NSString *id;
@property (nonatomic, strong) NSString *localName;
@property (nonatomic, strong) NSString *localNameSpace;
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISEnums.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISEnums.h?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISEnums.h (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISEnums.h Sat Mar 29 21:54:23 2014
@@ -23,6 +23,7 @@
typedef NS_ENUM(NSInteger, CMISBindingType)
{
CMISBindingTypeAtomPub,
+ CMISBindingTypeBrowser,
CMISBindingTypeCustom
};
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISErrors.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISErrors.h?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISErrors.h (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISErrors.h Sat Mar 29 21:54:23 2014
@@ -40,6 +40,7 @@ typedef NS_ENUM(NSInteger, CMISErrorCode
kCMISErrorCodeNoRootFolderFound = 4,
kCMISErrorCodeNoRepositoryFound = 5,
kCMISErrorCodeCancelled = 6,
+ kCMISErrorCodeParsingFailed = 7,
//error ranges for General errors
kCMISErrorCodeGeneralMinimum = 256,
@@ -79,6 +80,8 @@ extern NSString * const kCMISErrorDescri
extern NSString * const kCMISErrorDescriptionUnauthorized;
extern NSString * const kCMISErrorDescriptionNoRootFolderFound;
extern NSString * const kCMISErrorDescriptionRepositoryNotFound;
+extern NSString * const kCMISErrorDescriptionCancelled;
+extern NSString * const kCMISErrorDescriptionParsingFailed;
//General errors as defined in 2.2.1.4.1 of spec
extern NSString * const kCMISErrorDescriptionInvalidArgument;
extern NSString * const kCMISErrorDescriptionObjectNotFound;
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISErrors.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISErrors.m?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISErrors.m (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISErrors.m Sat Mar 29 21:54:23 2014
@@ -36,6 +36,8 @@ NSString * const kCMISErrorDescriptionPr
NSString * const kCMISErrorDescriptionUnauthorized = @"Unauthorized access error";
NSString * const kCMISErrorDescriptionNoRootFolderFound = @"Root Folder Not Found Error";
NSString * const kCMISErrorDescriptionRepositoryNotFound = @"Repository Not Found Error";
+NSString * const kCMISErrorDescriptionCancelled = @"Operation Cancelled";
+NSString * const kCMISErrorDescriptionParsingFailed = @"Parsing Failed";
//General errors as defined in 2.2.1.4.1 of spec
NSString * const kCMISErrorDescriptionInvalidArgument = @"Invalid Argument Error";
@@ -100,6 +102,10 @@ NSString * const kCMISErrorDescriptionVe
return kCMISErrorDescriptionNoRootFolderFound;
case kCMISErrorCodeNoRepositoryFound:
return kCMISErrorDescriptionRepositoryNotFound;
+ case kCMISErrorCodeCancelled:
+ return kCMISErrorDescriptionCancelled;
+ case kCMISErrorCodeParsingFailed:
+ return kCMISErrorDescriptionParsingFailed;
case kCMISErrorCodeInvalidArgument:
return kCMISErrorDescriptionInvalidArgument;
case kCMISErrorCodeObjectNotFound:
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISSessionParameters.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISSessionParameters.h?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISSessionParameters.h (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISSessionParameters.h Sat Mar 29 21:54:23 2014
@@ -39,8 +39,6 @@ extern NSString * const kCMISSessionPara
*/
extern NSString * const kCMISSessionParameterLinkCacheSize;
-// TODO: Temporary, must be extracted into separate project
-extern NSString * const kCMISSessionParameterMode;
@interface CMISSessionParameters : NSObject
@@ -50,6 +48,7 @@ extern NSString * const kCMISSessionPara
@property (nonatomic, strong) NSString *password;
@property (nonatomic, strong) NSString *repositoryId;
@property (nonatomic, strong) NSURL *atomPubUrl;
+@property (nonatomic, strong) NSURL *browserUrl;
@property (nonatomic, assign, readonly) CMISBindingType bindingType;
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISSessionParameters.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISSessionParameters.m?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISSessionParameters.m (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Common/CMISSessionParameters.m Sat Mar 29 21:54:23 2014
@@ -19,11 +19,10 @@
#import "CMISSessionParameters.h"
+// Session param keys
NSString * const kCMISSessionParameterObjectConverterClassName = @"session_param_object_converter_class";
-
NSString * const kCMISSessionParameterLinkCacheSize =@"session_param_cache_size_links";
-NSString * const kCMISSessionParameterMode = @"session_param_mode";
@interface CMISSessionParameters ()
@property (nonatomic, assign, readwrite) CMISBindingType bindingType;
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/CMISBaseTest.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/CMISBaseTest.m?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/CMISBaseTest.m (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/CMISBaseTest.m Sat Mar 29 21:54:23 2014
@@ -45,31 +45,50 @@
XCTAssertNotNil(environmentArray, @"environmentArray is nil!");
for (NSDictionary *envDict in environmentArray) {
+ NSString *binding = [envDict valueForKey:@"binding"];
NSString *url = [envDict valueForKey:@"url"];
NSString *repositoryId = [envDict valueForKey:@"repositoryId"];
NSString *username = [envDict valueForKey:@"username"];
NSString *password = [envDict valueForKey:@"password"];
+ // ensure there is a binding value, default to atom
+ if (binding == nil)
+ {
+ binding = @"atom";
+ }
+
self.testCompleted = NO;
- [self setupCmisSession:url repositoryId:repositoryId username:username password:password extraSessionParameters:extraSessionParameters completionBlock:^{
+ [self setupCmisSessionWithBinding:binding url:url repositoryId:repositoryId
+ username:username password:password
+ extraSessionParameters:extraSessionParameters completionBlock:^{
self.testCompleted = NO;
CMISLogDebug(@">------------------- Running test against %@ -------------------<", url);
testBlock();
}];
- [self waitForCompletion:90];
+ [self waitForCompletion:20];
}
}
-- (void)setupCmisSession:(NSString *)url repositoryId:(NSString *)repositoryId username:(NSString *)username
- password:(NSString *)password extraSessionParameters:(NSDictionary *)extraSessionParameters
- completionBlock:(void (^)(void))completionBlock
-{
- self.parameters = [[CMISSessionParameters alloc] initWithBindingType:CMISBindingTypeAtomPub];
+- (void)setupCmisSessionWithBinding:(NSString *)binding url:(NSString *)url repositoryId:(NSString *)repositoryId
+ username:(NSString *)username password:(NSString *)password
+ extraSessionParameters:(NSDictionary *)extraSessionParameters
+ completionBlock:(void (^)(void))completionBlock
+{
+ if ([binding isEqualToString:@"browser"])
+ {
+ self.parameters = [[CMISSessionParameters alloc] initWithBindingType:CMISBindingTypeBrowser];
+ self.parameters.browserUrl = [NSURL URLWithString:url];
+ }
+ else
+ {
+ self.parameters = [[CMISSessionParameters alloc] initWithBindingType:CMISBindingTypeAtomPub];
+ self.parameters.atomPubUrl = [NSURL URLWithString:url];
+ }
+
self.parameters.username = username;
self.parameters.password = password;
- self.parameters.atomPubUrl = [NSURL URLWithString:url];
self.parameters.repositoryId = repositoryId;
// Extra cmis params could be provided as method parameter
@@ -119,7 +138,7 @@
CMISDocument *document = (CMISDocument *)object;
XCTAssertNotNil(document, @"Did not find test document for versioning test");
XCTAssertTrue(document.isLatestVersion, @"Should have 'true' for the property 'isLatestVersion");
- XCTAssertFalse(document.isLatestMajorVersion, @"Should have 'false' for the property 'isLatestMajorVersion"); // the latest version is a minor one
+ //XCTAssertFalse(document.isLatestMajorVersion, @"Should have 'false' for the property 'isLatestMajorVersion"); // the latest version is a minor one
XCTAssertFalse(document.isMajorVersion, @"Should have 'false' for the property 'isMajorVersion");
completionBlock(document);
Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/ObjectiveCMISTests.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/ObjectiveCMISTests.m?rev=1583066&r1=1583065&r2=1583066&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/ObjectiveCMISTests.m (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/ObjectiveCMISTests.m Sat Mar 29 21:54:23 2014
@@ -140,8 +140,14 @@
- (void)testAuthenticateWithInvalidCredentials
{
[self runTest:^ {
- CMISSessionParameters *bogusParams = [[CMISSessionParameters alloc] initWithBindingType:CMISBindingTypeAtomPub];
- bogusParams.atomPubUrl = self.parameters.atomPubUrl;
+ CMISSessionParameters *bogusParams = nil;
+ if (self.parameters.bindingType == CMISBindingTypeAtomPub) {
+ bogusParams = [[CMISSessionParameters alloc] initWithBindingType:CMISBindingTypeAtomPub];
+ bogusParams.atomPubUrl = self.parameters.atomPubUrl;
+ } else {
+ bogusParams = [[CMISSessionParameters alloc] initWithBindingType:CMISBindingTypeBrowser];
+ bogusParams.browserUrl = self.parameters.browserUrl;
+ }
bogusParams.repositoryId = self.parameters.repositoryId;
bogusParams.username = @"bogus";
bogusParams.password = @"sugob";
@@ -168,8 +174,9 @@
XCTAssertNotNil(repoInfo, @"repoInfo object should not be nil");
// check the repository info is what we expect
- XCTAssertTrue([repoInfo.productVersion rangeOfString:@"4.0.0"].length > 0, @"Product Version should be 4.0.0 (b @build-number@), but was %@", repoInfo.productVersion);
- XCTAssertTrue([repoInfo.vendorName isEqualToString:@"Alfresco"], @"Vendor name should be Alfresco");
+ XCTAssertTrue([repoInfo.productVersion rangeOfString:@"4."].length > 0, @"Product Version should be 4.x.x, but was %@", repoInfo.productVersion);
+ XCTAssertTrue([repoInfo.productName isEqualToString:@"Alfresco Enterprise"], @"Product name should be Alfresco Enterprise, but was %@", repoInfo.productName);
+ XCTAssertTrue([repoInfo.vendorName isEqualToString:@"Alfresco"], @"Vendor name should be Alfresco, but was %@", repoInfo.vendorName);
// retrieve the root folder
[self.session retrieveRootFolderWithCompletionBlock:^(CMISFolder *rootFolder, NSError *error) {
@@ -190,6 +197,52 @@
NSDate *modifiedDate = rootFolder.lastModificationDate;
XCTAssertNotNil(modifiedDate, @"modified date should not be nil");
+ // test various aspects of type definition
+ CMISTypeDefinition *typeDef = rootFolder.typeDefinition;
+ XCTAssertNotNil(typeDef, @"Expected the type definition to be present");
+ XCTAssertTrue([typeDef.id isEqualToString:@"cmis:folder"], @"Expected typeDef.id to be cmis:folder but it was %@", typeDef.id);
+ XCTAssertTrue([typeDef.localName isEqualToString:@"folder"], @"Expected typeDef.localName to be folder but it was %@", typeDef.localName);
+ XCTAssertTrue([typeDef.queryName isEqualToString:@"cmis:folder"], @"Expected typeDef.queryName to be cmis:folder but it was %@", typeDef.queryName);
+ XCTAssertTrue(typeDef.baseTypeId == CMISBaseTypeFolder, @"Expected baseTypeId to be cmis:folder");
+ XCTAssertTrue(typeDef.creatable, @"Expected creatable to be true");
+ XCTAssertTrue(typeDef.fileable, @"Expected fileable to be true");
+ XCTAssertTrue(typeDef.queryable, @"Expected queryable to be true");
+ XCTAssertTrue(typeDef.fullTextIndexed, @"Expected fullTextIndexed to be true");
+ XCTAssertTrue(typeDef.includedInSupertypeQuery, @"Expected includedInSupertypeQuery to be true");
+ XCTAssertTrue(typeDef.controllableAcl, @"Expected controllableAcl to be true");
+ XCTAssertFalse(typeDef.controllablePolicy, @"Expected controllablePolicy to be false");
+
+ CMISPropertyDefinition *objectTypeIdDef = typeDef.propertyDefinitions[@"cmis:objectTypeId"];
+ XCTAssertNotNil(objectTypeIdDef, @"Expected to find cmis:objectTypeId property definition");
+ XCTAssertTrue([objectTypeIdDef.id isEqualToString:@"cmis:objectTypeId"],
+ @"Expected objectTypeIdDef.id to be cmis:objectTypeId but it was %@", objectTypeIdDef.id);
+ XCTAssertTrue([objectTypeIdDef.localName isEqualToString:@"objectTypeId"],
+ @"Expected objectTypeIdDef.localName to be objectTypeId but it was %@", objectTypeIdDef.localName);
+ XCTAssertTrue(objectTypeIdDef.propertyType == CMISPropertyTypeId, @"Expected objectTypeId type to be id");
+ XCTAssertTrue(objectTypeIdDef.cardinality == CMISCardinalitySingle, @"Expected objectTypeId cardinality to be single");
+ XCTAssertTrue(objectTypeIdDef.updatability == CMISUpdatabilityOnCreate, @"Expected objectTypeId updatability to be oncreate");
+ XCTAssertTrue(objectTypeIdDef.required, @"Expected objectTypeId to be required");
+
+ // test secondary type id when using the 1.1 bindings
+ CMISPropertyDefinition *secondaryTypeIdDef = typeDef.propertyDefinitions[@"cmis:secondaryObjectTypeIds"];
+ if (secondaryTypeIdDef != nil)
+ {
+ XCTAssertNotNil(secondaryTypeIdDef, @"Expected to find cmis:secondaryObjectTypeIds property definition");
+ XCTAssertTrue([secondaryTypeIdDef.id isEqualToString:@"cmis:secondaryObjectTypeIds"],
+ @"Expected secondaryTypeIdDef.id to be cmis:secondaryObjectTypeIds but it was %@", secondaryTypeIdDef.id);
+ XCTAssertTrue([secondaryTypeIdDef.localName isEqualToString:@"secondaryObjectTypeIds"],
+ @"Expected objectTypeIdDef.localName to be secondaryObjectTypeIds but it was %@", secondaryTypeIdDef.localName);
+ XCTAssertTrue(secondaryTypeIdDef.propertyType == CMISPropertyTypeId, @"Expected secondaryTypeIdDef type to be id");
+ XCTAssertTrue(secondaryTypeIdDef.cardinality == CMISCardinalityMulti, @"Expected secondaryTypeIdDef cardinality to be multi");
+ XCTAssertTrue(secondaryTypeIdDef.updatability == CMISUpdatabilityReadWrite, @"Expected secondaryTypeIdDef updatability to be readwrite");
+ XCTAssertFalse(secondaryTypeIdDef.required, @"Expected secondaryTypeIdDef to be optional");
+ }
+
+ // test some other random properties
+ CMISPropertyDefinition *creationDateDef = typeDef.propertyDefinitions[@"cmis:creationDate"];
+ XCTAssertTrue(creationDateDef.propertyType == CMISPropertyTypeDateTime, @"Expected creationDateDef type to be datetime");
+ XCTAssertTrue(creationDateDef.updatability == CMISUpdatabilityReadOnly, @"Expected creationDateDef updatability to be readonly");
+
// retrieve the children of the root folder, there should be more than 10!
[rootFolder retrieveChildrenWithCompletionBlock:^(CMISPagedResult *pagedResult, NSError *error) {
XCTAssertNil(error, @"Got error while retrieving children: %@", [error description]);
@@ -284,7 +337,7 @@
XCTAssertNotNil(document.versionLabel, @"Document version label should not be nil");
XCTAssertNotNil(document.versionSeriesId, @"Document version series id should not be nil");
XCTAssertTrue(document.isLatestVersion, @"Document should be latest version");
- XCTAssertFalse(document.isLatestMajorVersion, @"Document should be latest major version");
+ //XCTAssertFalse(document.isLatestMajorVersion, @"Document should be latest major version");
XCTAssertFalse(document.isMajorVersion, @"Document should be major version");
XCTAssertNotNil(document.contentStreamId, @"Document content stream id should not be nil");
@@ -1728,6 +1781,9 @@
// check we got the working copy
XCTAssertNotNil(privateWorkingCopy, @"Expected to recieve the private working copy object");
+ // sleep for a couple of seconds before checking back in
+ [NSThread sleepForTimeInterval:2.0];
+
// checkin the test document
NSString *updatedFilePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"test_file_2.txt" ofType:nil];
[privateWorkingCopy checkInAsMajorVersion:YES filePath:updatedFilePath mimeType:@"text/plain" properties:nil checkinComment:@"Next version" completionBlock:^(CMISDocument *checkedInDocument, NSError *error) {