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/08/01 17:37:50 UTC

svn commit: r1615144 - in /chemistry/objectivecmis/trunk: ObjectiveCMIS/Bindings/ ObjectiveCMIS/Bindings/AtomPub/ ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/ ObjectiveCMIS/Bindings/Browser/ ObjectiveCMISTests/

Author: gavincornwell
Date: Fri Aug  1 15:37:49 2014
New Revision: 1615144

URL: http://svn.apache.org/r1615144
Log:
Fixes for the following issues:
CMIS-826: Choice data for a property definition is not being parsed
CMIS-827: The baseTypeId property is set to "unknown" when retrieving an aspect definition from Alfresco
CMIS-828: parentId is not parsed when requesting type definitions
CMIS-829: CMISTypeDefinition localNamespace property is incorrect

Modified:
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubPropertyDefinitionParser.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.h
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISPropertyDefinition.h
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISPropertyDefinition.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISTypeDefinition.h
    chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubPropertyDefinitionParser.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubPropertyDefinitionParser.m?rev=1615144&r1=1615143&r2=1615144&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubPropertyDefinitionParser.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubPropertyDefinitionParser.m Fri Aug  1 15:37:49 2014
@@ -24,8 +24,10 @@
 
 @interface CMISAtomPubPropertyDefinitionParser ()
 
-@property(nonatomic, strong, readwrite) CMISPropertyDefinition *propertyDefinition;
-@property(nonatomic, strong, readwrite) NSString *currentString;
+@property (nonatomic, strong, readwrite) CMISPropertyDefinition *propertyDefinition;
+@property (nonatomic, strong, readwrite) NSString *currentString;
+@property (nonatomic, strong, readwrite) NSMutableArray *currentChoices;
+@property (nonatomic, strong, readwrite) CMISPropertyChoice *currentChoice;
 
 // Properties if used as child delegate parser
 @property(nonatomic, weak) id <NSXMLParserDelegate, CMISAtomPubPropertyDefinitionDelegate> parentDelegate;
@@ -95,6 +97,19 @@
     }
 }
 
+- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
+{
+    if ([elementName isEqualToString:kCMISCoreChoice] || [elementName isEqualToString:kCMISCoreChoiceString]) {
+        if (self.currentChoices == nil)
+        {
+            self.currentChoices = [NSMutableArray array];
+        }
+        
+        self.currentChoice = [CMISPropertyChoice new];
+        self.currentChoice.displayName = attributeDict[kCMISAtomEntryDisplayName];
+    }
+}
+
 - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
 {
     if ([elementName isEqualToString:kCMISCorePropertyStringDefinition]
@@ -103,6 +118,10 @@
         || [elementName isEqualToString:kCMISCorePropertyIntegerDefinition]
         || [elementName isEqualToString:kCMISCorePropertyDateTimeDefinition]
         || [elementName isEqualToString:kCMISCorePropertyDecimalDefinition]) {
+        
+        // store any choice objects
+        self.propertyDefinition.choices = self.currentChoices;
+        
         if (self.parentDelegate) {
             if ([self.parentDelegate respondsToSelector:@selector(propertyDefinitionParser:didFinishParsingPropertyDefinition:)]) {
                 [self.parentDelegate performSelector:@selector(propertyDefinitionParser:didFinishParsingPropertyDefinition:) withObject:self withObject:self.propertyDefinition];
@@ -155,8 +174,11 @@
         self.propertyDefinition.orderable = [self parseBooleanValue:self.currentString];
     } else if ([elementName isEqualToString:kCMISCoreOpenChoice]) {
         self.propertyDefinition.openChoice = [self parseBooleanValue:self.currentString];
+    } else if ([elementName isEqualToString:kCMISAtomEntryValue]) {
+        self.currentChoice.value = self.currentString;
+        [self.currentChoices addObject:self.currentChoice];
     }
-
+    
     self.currentString = nil;
 }
 

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.h?rev=1615144&r1=1615143&r2=1615144&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.h (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.h Fri Aug  1 15:37:49 2014
@@ -19,11 +19,12 @@
 
 #import <Foundation/Foundation.h>
 #import "CMISAtomPubPropertyDefinitionParser.h"
+#import "CMISAtomPubExtensionDataParserBase.h"
 
 @class CMISTypeDefinition;
 
 // TODO: should we merge this parser with the generic AtomEntry parser?
-@interface CMISTypeDefinitionAtomEntryParser : NSObject <NSXMLParserDelegate, CMISAtomPubPropertyDefinitionDelegate>
+@interface CMISTypeDefinitionAtomEntryParser : CMISAtomPubExtensionDataParserBase <NSXMLParserDelegate, CMISAtomPubPropertyDefinitionDelegate>
 
 /**
 * Available after a successful parse.

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m?rev=1615144&r1=1615143&r2=1615144&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISTypeDefinitionAtomEntryParser.m Fri Aug  1 15:37:49 2014
@@ -30,8 +30,6 @@
 @property(nonatomic, strong, readwrite) NSData *atomData;
 @property(nonatomic, strong, readwrite) NSString *currentString;
 
-@property (nonatomic, strong) id<NSXMLParserDelegate> childParserDelegate;
-
 @end
 
 
@@ -70,27 +68,42 @@
 
 - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
 {
-    if ([elementName isEqualToString:kCMISRestAtomType]) {
-        __block BOOL documentType = NO;
-        [attributeDict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
-            if ([key hasSuffix:@"type"] && [obj hasSuffix:@"cmisTypeDocumentDefinitionType"]) {
-                documentType = YES;
+    if ([namespaceURI isEqualToString:kCMISNamespaceCmisRestAtom]) {
+        if ([elementName isEqualToString:kCMISRestAtomType]) {
+            __block BOOL documentType = NO;
+            [attributeDict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+                if ([key hasSuffix:@"type"] && [obj hasSuffix:@"cmisTypeDocumentDefinitionType"]) {
+                    documentType = YES;
+                }
+            }];
+            
+            if (documentType) {
+                self.typeDefinition = [[CMISDocumentTypeDefinition alloc] init];
+            } else {
+                self.typeDefinition = [[CMISTypeDefinition alloc] init];
             }
-        }];
-        
-        if (documentType) {
-            self.typeDefinition = [[CMISDocumentTypeDefinition alloc] init];
-        } else {
-            self.typeDefinition = [[CMISTypeDefinition alloc] init];
-        }
-        self.isParsingTypeDefinition = YES;
-    } else if ([elementName isEqualToString:kCMISCorePropertyStringDefinition]
-             || [elementName isEqualToString:kCMISCorePropertyIdDefinition]
-             || [elementName isEqualToString:kCMISCorePropertyBooleanDefinition]
-             || [elementName isEqualToString:kCMISCorePropertyIntegerDefinition]
-             || [elementName isEqualToString:kCMISCorePropertyDateTimeDefinition]
-             || [elementName isEqualToString:kCMISCorePropertyDecimalDefinition]) {
-        self.childParserDelegate = [CMISAtomPubPropertyDefinitionParser parserForPropertyDefinition:elementName withParentDelegate:self parser:parser];
+            self.isParsingTypeDefinition = YES;
+            
+            [self pushNewCurrentExtensionData:self.typeDefinition];
+        }
+    } else if ([namespaceURI isEqualToString:kCMISNamespaceCmis]) {
+        if ([elementName isEqualToString:kCMISCorePropertyStringDefinition] ||
+            [elementName isEqualToString:kCMISCorePropertyIdDefinition] ||
+            [elementName isEqualToString:kCMISCorePropertyBooleanDefinition] ||
+            [elementName isEqualToString:kCMISCorePropertyIntegerDefinition] ||
+            [elementName isEqualToString:kCMISCorePropertyDateTimeDefinition] ||
+            [elementName isEqualToString:kCMISCorePropertyDecimalDefinition]) {
+            self.childParserDelegate = [CMISAtomPubPropertyDefinitionParser parserForPropertyDefinition:elementName withParentDelegate:self parser:parser];
+        }
+    } else if ([namespaceURI isEqualToString:kCMISNamespaceApp] ||
+               [namespaceURI isEqualToString:kCMISNamespaceAtom]) {
+        // do nothing with these namespaces
+    } else {
+        // parse extension data
+        if (self.currentExtensionData != nil) {
+            self.childParserDelegate = [CMISAtomPubExtensionElementParser extensionElementParserWithElementName:elementName namespaceUri:namespaceURI
+                                                                                                     attributes:attributeDict parentDelegate:self parser:parser];
+        }
     }
 }
 
@@ -119,7 +132,7 @@
         }
     } else if ([elementName isEqualToString:kCMISCoreLocalNamespace]) {
         if (self.isParsingTypeDefinition) {
-            self.typeDefinition.localNameSpace = self.currentString;
+            self.typeDefinition.localNamespace = self.currentString;
         }
     } else if ([elementName isEqualToString:kCMISCoreDisplayName]) {
         if (self.isParsingTypeDefinition) {
@@ -139,8 +152,20 @@
                 self.typeDefinition.baseTypeId = CMISBaseTypeDocument;
             } else if ([self.currentString isEqualToString:kCMISPropertyObjectTypeIdValueFolder]) {
                 self.typeDefinition.baseTypeId = CMISBaseTypeFolder;
+            } else if ([self.currentString isEqualToString:kCMISPropertyObjectTypeIdValuePolicy]) {
+                self.typeDefinition.baseTypeId = CMISBaseTypePolicy;
+            } else if ([self.currentString isEqualToString:kCMISPropertyObjectTypeIdValueItem]) {
+                self.typeDefinition.baseTypeId = CMISBaseTypeItem;
+            } else if ([self.currentString isEqualToString:kCMISPropertyObjectTypeIdValueSecondary]) {
+                self.typeDefinition.baseTypeId = CMISBaseTypeSecondary;
+            } else if ([self.currentString isEqualToString:kCMISPropertyObjectTypeIdValueRelationship]) {
+                self.typeDefinition.baseTypeId = CMISBaseTypeRelationship;
             }
         }
+    } else if ([elementName isEqualToString:kCMISCoreParentId]) {
+        if (self.isParsingTypeDefinition) {
+            self.typeDefinition.parentTypeId = self.currentString;
+        }
     } else if ([elementName isEqualToString:kCMISCoreCreatable]) {
         if (self.isParsingTypeDefinition) {
             self.typeDefinition.creatable = [self.currentString.lowercaseString isEqualToString:kCMISAtomEntryValueTrue];
@@ -183,6 +208,9 @@
                 ((CMISDocumentTypeDefinition*)self.typeDefinition).contentStreamAllowed = CMISContentStreamRequired;
             }
         }
+    } else if ([elementName isEqualToString:kCMISAtomEntry]) {
+        // set the extensionData
+        [self saveCurrentExtensionsAndPushPreviousExtensionData];
     }
 
     self.currentString = nil;

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h?rev=1615144&r1=1615143&r2=1615144&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h Fri Aug  1 15:37:49 2014
@@ -136,6 +136,7 @@ extern NSString * const kCMISCoreDisplay
 extern NSString * const kCMISCoreQueryName;
 extern NSString * const kCMISCoreDescription;
 extern NSString * const kCMISCoreBaseId;
+extern NSString * const kCMISCoreParentId;
 extern NSString * const kCMISCoreCreatable;
 extern NSString * const kCMISCoreFileable;
 extern NSString * const kCMISCoreQueryable;
@@ -149,6 +150,8 @@ extern NSString * const kCMISCoreInherit
 extern NSString * const kCMISCoreRequired;
 extern NSString * const kCMISCoreOrderable;
 extern NSString * const kCMISCoreOpenChoice;
+extern NSString * const kCMISCoreChoice;
+extern NSString * const kCMISCoreChoiceString;
 extern NSString * const kCMISCoreVersionable;
 extern NSString * const kCMISCoreContentStreamAllowed;
 extern NSString * const kCMISCoreAllowed;

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m?rev=1615144&r1=1615143&r2=1615144&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m Fri Aug  1 15:37:49 2014
@@ -136,6 +136,7 @@ NSString * const kCMISCoreDisplayName = 
 NSString * const kCMISCoreQueryName = @"queryName";
 NSString * const kCMISCoreDescription = @"description";
 NSString * const kCMISCoreBaseId = @"baseId";
+NSString * const kCMISCoreParentId = @"parentId";
 NSString * const kCMISCoreCreatable = @"creatable";
 NSString * const kCMISCoreFileable = @"fileable";
 NSString * const kCMISCoreQueryable = @"queryable";
@@ -147,8 +148,10 @@ NSString * const kCMISCoreCardinality = 
 NSString * const kCMISCoreUpdatability = @"updatability";
 NSString * const kCMISCoreInherited = @"inherited";
 NSString * const kCMISCoreRequired = @"required";
-NSString * const kCMISCoreOrderable = @"queryable";
+NSString * const kCMISCoreOrderable = @"orderable";
 NSString * const kCMISCoreOpenChoice = @"openChoice";
+NSString * const kCMISCoreChoice = @"choice";
+NSString * const kCMISCoreChoiceString = @"choiceString";
 NSString * const kCMISCoreVersionable = @"versionable";
 NSString * const kCMISCoreContentStreamAllowed = @"contentStreamAllowed";
 NSString * const kCMISCoreAllowed = @"allowed";

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m?rev=1615144&r1=1615143&r2=1615144&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m Fri Aug  1 15:37:49 2014
@@ -209,7 +209,7 @@ NSString * const kCMISBrowserMaxValueJSO
         typeDef.includedInSupertypeQuery = [jsonDictionary cmis_boolForKey:kCMISBrowserJSONIncludedInSuperTypeQuery];
         typeDef.queryable = [jsonDictionary cmis_boolForKey:kCMISBrowserJSONQueryable];
         typeDef.localName = [jsonDictionary cmis_objectForKeyNotNull:kCMISBrowserJSONLocalName];
-        typeDef.localNameSpace = [jsonDictionary cmis_objectForKeyNotNull:kCMISBrowserJSONLocalNamespace];
+        typeDef.localNamespace = [jsonDictionary cmis_objectForKeyNotNull:kCMISBrowserJSONLocalNamespace];
         typeDef.parentTypeId = [jsonDictionary cmis_objectForKeyNotNull:kCMISBrowserJSONParentId];
         typeDef.queryName = [jsonDictionary cmis_objectForKeyNotNull:kCMISBrowserJSONQueryName];
         
@@ -1005,6 +1005,20 @@ NSString * const kCMISBrowserMaxValueJSO
     
     // TODO default value
     
+    // parse choices, if present
+    NSArray *choicesJSON = propertyDictionary[kCMISBrowserJSONChoice];
+    if (choicesJSON != nil) {
+        NSMutableArray *choices = [NSMutableArray array];
+        for (NSDictionary *choiceDictionary in choicesJSON) {
+            CMISPropertyChoice *choice = [CMISPropertyChoice new];
+            choice.displayName = [choiceDictionary cmis_objectForKeyNotNull:kCMISBrowserJSONDisplayName];
+            choice.value = [choiceDictionary cmis_objectForKeyNotNull:kCMISBrowserJSONValue];
+            [choices addObject:choice];
+        }
+        
+        propDef.choices = choices;
+    }
+    
     // handle extensions
     propDef.extensions = [CMISObjectConverter convertExtensions:propertyDictionary cmisKeys:[CMISBrowserConstants propertyTypeKeys]];
     

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISPropertyDefinition.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISPropertyDefinition.h?rev=1615144&r1=1615143&r2=1615144&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISPropertyDefinition.h (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISPropertyDefinition.h Fri Aug  1 15:37:49 2014
@@ -21,6 +21,11 @@
 #import "CMISEnums.h"
 #import "CMISExtensionData.h"
 
+@interface CMISPropertyChoice : NSObject
+@property (nonatomic, strong) NSString *displayName;
+@property (nonatomic, strong) id value;
+@end
+
 
 // TODO: type specific properties, see cmis spec line 527
 @interface CMISPropertyDefinition : CMISExtensionData
@@ -43,6 +48,8 @@
 @property (nonatomic, assign, getter = isOpenChoice) BOOL openChoice;
 
 @property (nonatomic, strong) NSArray *defaultValues;
+
+// Returns an array of CMISPropertyChoice objects
 @property (nonatomic, strong) NSArray *choices;
 
 @end
\ No newline at end of file

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISPropertyDefinition.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISPropertyDefinition.m?rev=1615144&r1=1615143&r2=1615144&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISPropertyDefinition.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISPropertyDefinition.m Fri Aug  1 15:37:49 2014
@@ -19,6 +19,10 @@
 
 #import "CMISPropertyDefinition.h"
 
+@implementation CMISPropertyChoice
+
+@end
+
 
 @implementation CMISPropertyDefinition
 

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISTypeDefinition.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISTypeDefinition.h?rev=1615144&r1=1615143&r2=1615144&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISTypeDefinition.h (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/CMISTypeDefinition.h Fri Aug  1 15:37:49 2014
@@ -28,7 +28,7 @@
 
 @property (nonatomic, strong) NSString *identifier;
 @property (nonatomic, strong) NSString *localName;
-@property (nonatomic, strong) NSString *localNameSpace;
+@property (nonatomic, strong) NSString *localNamespace;
 @property (nonatomic, strong) NSString *displayName;
 @property (nonatomic, strong) NSString *queryName;
 @property (nonatomic, strong) NSString *summary;

Modified: chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m?rev=1615144&r1=1615143&r2=1615144&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m Fri Aug  1 15:37:49 2014
@@ -1404,12 +1404,13 @@
              // Check type definition properties
              XCTAssertNotNil(typeDefinition, @"Type definition should not be nil");
              XCTAssertTrue(typeDefinition.baseTypeId == CMISBaseTypeDocument, @"Unexpected base type id");
-             XCTAssertNotNil(typeDefinition.description, @"Type description should not be nil");
+             XCTAssertNil(typeDefinition.parentTypeId, @"Expected parent type id to be nil");
+             XCTAssertNotNil(typeDefinition.summary, @"Type summary should not be nil");
              XCTAssertNotNil(typeDefinition.displayName, @"Type displayName should not be nil");
              XCTAssertNotNil(typeDefinition.identifier, @"Type id should not be nil");
              XCTAssertTrue([typeDefinition.identifier isEqualToString:@"cmis:document"], @"Wrong id for type");
              XCTAssertNotNil(typeDefinition.localName, @"Type local name should not be nil");
-             XCTAssertNotNil(typeDefinition.localNameSpace, @"Type local namespace should not be nil");
+             XCTAssertNotNil(typeDefinition.localNamespace, @"Type local namespace should not be nil");
              XCTAssertNotNil(typeDefinition.queryName, @"Type query name should not be nil");
              
              // Check property definitions
@@ -1417,7 +1418,7 @@
              for (id key in typeDefinition.propertyDefinitions)
              {
                  CMISPropertyDefinition *propertyDefinition = [typeDefinition.propertyDefinitions objectForKey:key];
-                 XCTAssertNotNil(propertyDefinition.description, @"Property definition description should not be nil");
+                 XCTAssertNotNil(propertyDefinition.summary, @"Property definition summary should not be nil");
                  XCTAssertNotNil(propertyDefinition.displayName, @"Property definition display name should not be nil");
                  XCTAssertNotNil(propertyDefinition.identifier, @"Property definition id should not be nil");
                  XCTAssertNotNil(propertyDefinition.localName, @"Property definition local name should not be nil");
@@ -1430,6 +1431,198 @@
      }];
 }
 
+- (void)testRetrieveSubTypeDefinition
+{
+    [self runTest:^ {
+        
+        // NOTE: This test will request a custom type from an Alfresco repository, if this type is not installed an error will
+        //       be returned, however, in this case, the test will still pass
+        
+        [self.session.binding.repositoryService retrieveTypeDefinition:@"D:fdk:everything" completionBlock:^(CMISTypeDefinition *typeDefinition, NSError *error) {
+            if (typeDefinition == nil)
+            {
+                // check the error code was ObjectNotFound
+                XCTAssertTrue(error.code == kCMISErrorCodeObjectNotFound, @"Expected error code of 257 but it was %lu", (unsigned long)error.code);
+                self.testCompleted = YES;
+            }
+            else
+            {
+                // Check type definition properties
+                XCTAssertNotNil(typeDefinition, @"Type definition should not be nil");
+                XCTAssertTrue([typeDefinition.identifier isEqualToString:@"D:fdk:everything"],
+                              @"Expected identifer to be 'D:fdk:everything' but it was %@", typeDefinition.identifier);
+                XCTAssertTrue([typeDefinition.localName isEqualToString:@"everything"],
+                              @"Expected localName to be 'everything' but it was %@", typeDefinition.localName);
+                XCTAssertTrue([typeDefinition.localNamespace isEqualToString:@"http://www.alfresco.org/model/fdk/1.0"],
+                              @"Expected localNameSpace to be 'http://www.alfresco.org/model/fdk/1.0' but it was %@", typeDefinition.localNamespace);
+                XCTAssertTrue([typeDefinition.queryName isEqualToString:@"fdk:everything"],
+                              @"Expected queryName to be 'fdk:everything' but it was %@", typeDefinition.queryName);
+                
+                // the following properties have different values on 4.0 servers
+                if ([self.session.repositoryInfo.productVersion hasPrefix:@"4.0."])
+                {
+                    XCTAssertTrue([typeDefinition.displayName isEqualToString:@"D:fdk:everything"],
+                                  @"Expected displayName to be 'D:fdk:everything' but it was %@", typeDefinition.displayName);
+                    XCTAssertTrue([typeDefinition.summary isEqualToString:@"D:fdk:everything"],
+                                  @"Expected summary to be 'D:fdk:everything' but it was %@", typeDefinition.summary);
+                }
+                else
+                {
+                    XCTAssertTrue([typeDefinition.displayName isEqualToString:@"Everything"],
+                                  @"Expected displayName to be 'Everything' but it was %@", typeDefinition.displayName);
+                    XCTAssertTrue([typeDefinition.summary isEqualToString:@"Everything"],
+                                  @"Expected summary to be 'Everything' but it was %@", typeDefinition.summary);
+                }
+                
+                XCTAssertTrue(typeDefinition.baseTypeId == CMISBaseTypeDocument, @"Unexpected base type id");
+                XCTAssertTrue([typeDefinition.parentTypeId isEqualToString:@"cmis:document"],
+                              @"Expected parentTypeId to be 'cmis:document' but it was %@", typeDefinition.parentTypeId);
+                XCTAssertTrue(typeDefinition.creatable, @"Expected creatable property to be true");
+                XCTAssertTrue(typeDefinition.fileable, @"Expected fileable property to be true");
+                XCTAssertTrue(typeDefinition.queryable, @"Expected queryable property to be true");
+                XCTAssertTrue(typeDefinition.fullTextIndexed, @"Expected fullTextIndexed property to be true");
+                XCTAssertTrue(typeDefinition.includedInSupertypeQuery, @"Expected includedInSupertypeQuery property to be true");
+                XCTAssertFalse(typeDefinition.controllablePolicy, @"Expected controllablePolicy property to be false");
+                XCTAssertTrue(typeDefinition.controllableAcl, @"Expected controllableAcl property to be true");
+                
+                // retrieve cmis:name property and check it
+                CMISPropertyDefinition *namePropertyDefiniton = [typeDefinition propertyDefinitionForId:@"cmis:name"];
+                XCTAssertNotNil(namePropertyDefiniton, @"Expected to find a property definition for cmis:name");
+                XCTAssertTrue([namePropertyDefiniton.identifier isEqualToString:@"cmis:name"],
+                              @"Expected identifier to be 'cmis:name' but it was %@", namePropertyDefiniton.identifier);
+                XCTAssertTrue([namePropertyDefiniton.localName isEqualToString:@"name"],
+                              @"Expected localName to be 'name' but it was %@", namePropertyDefiniton.localName);
+                XCTAssertTrue([namePropertyDefiniton.localNamespace isEqualToString:@"http://www.alfresco.org/model/cmis/1.0/cs01"],
+                              @"Expected localNameSpace to be 'http://www.alfresco.org/model/cmis/1.0/cs01' but it was %@", namePropertyDefiniton.localNamespace);
+                XCTAssertTrue([namePropertyDefiniton.displayName isEqualToString:@"Name"],
+                              @"Expected displayName to be 'Name' but it was %@", namePropertyDefiniton.displayName);
+                XCTAssertTrue([namePropertyDefiniton.queryName isEqualToString:@"cmis:name"],
+                              @"Expected queryName to be 'cmis:name' but it was %@", namePropertyDefiniton.queryName);
+                XCTAssertTrue([namePropertyDefiniton.summary isEqualToString:@"Name"],
+                              @"Expected summary to be 'Name' but it was %@", namePropertyDefiniton.summary);
+                XCTAssertTrue(namePropertyDefiniton.propertyType == CMISPropertyTypeString, @"Expected int property to be of type string");
+                XCTAssertTrue(namePropertyDefiniton.cardinality == CMISCardinalitySingle, @"Unexpected cardinality");
+                XCTAssertTrue(namePropertyDefiniton.updatability == CMISUpdatabilityReadWrite, @"Unexpected updatability");
+                XCTAssertTrue(namePropertyDefiniton.inherited, @"Expected inherited property to be true");
+                XCTAssertTrue(namePropertyDefiniton.queryable, @"Expected queryable property to be true");
+                XCTAssertTrue(namePropertyDefiniton.orderable, @"Expected orderable property to be true");
+                if ([self.session.repositoryInfo.productVersion hasPrefix:@"4.0."])
+                {
+                    // due to a bug on 4.0 servers the required property was set to false
+                    XCTAssertFalse(namePropertyDefiniton.required, @"Expected required property to be false");
+                }
+                else
+                {
+                    XCTAssertTrue(namePropertyDefiniton.required, @"Expected required property to be true");
+                }
+                
+                // retrieve other property types
+                CMISPropertyDefinition *intPropertyDefiniton = [typeDefinition propertyDefinitionForId:@"fdk:int"];
+                XCTAssertTrue(intPropertyDefiniton.propertyType == CMISPropertyTypeInteger, @"Expected int property to be of type integer");
+                CMISPropertyDefinition *doublePropertyDefiniton = [typeDefinition propertyDefinitionForId:@"fdk:double"];
+                XCTAssertTrue(doublePropertyDefiniton.propertyType == CMISPropertyTypeDecimal, @"Expected double property to be of type decimal");
+                CMISPropertyDefinition *boolPropertyDefiniton = [typeDefinition propertyDefinitionForId:@"fdk:boolean"];
+                XCTAssertTrue(boolPropertyDefiniton.propertyType == CMISPropertyTypeBoolean, @"Expected boolean property to be of type boolean");
+                CMISPropertyDefinition *dateTimePropertyDefiniton = [typeDefinition propertyDefinitionForId:@"fdk:dateTime"];
+                XCTAssertTrue(dateTimePropertyDefiniton.propertyType == CMISPropertyTypeDateTime, @"Expected dateTime property to be of type dateTime");
+                CMISPropertyDefinition *noderefPropertyDefiniton = [typeDefinition propertyDefinitionForId:@"fdk:noderef"];
+                XCTAssertTrue(noderefPropertyDefiniton.propertyType == CMISPropertyTypeId, @"Expected noderef property to be of type id");
+                
+                // retrieve choices
+                CMISPropertyDefinition *constraintPropertyDefiniton = [typeDefinition propertyDefinitionForId:@"fdk:listConstraint"];
+                XCTAssertTrue(constraintPropertyDefiniton.propertyType == CMISPropertyTypeString, @"Expected listConstraint property to be of type string");
+                XCTAssertTrue([constraintPropertyDefiniton.localNamespace isEqualToString:@"http://www.alfresco.org/model/fdk/1.0"],
+                              @"Expected localNameSpace to be 'http://www.alfresco.org/model/fdk/1.0' but it was %@", constraintPropertyDefiniton.localNamespace);
+                XCTAssertFalse(constraintPropertyDefiniton.openChoice, @"Expected openChoice property to be false");
+                NSArray *choices = constraintPropertyDefiniton.choices;
+                XCTAssertNotNil(choices, @"Expected choices property for listConstraint property to be populated");
+                XCTAssertTrue(choices.count == 3, @"Expected there to be 3 choices but there were %lu", (unsigned long)choices.count);
+                
+                // only perform the following tests on endpoints using OpenCMIS
+                if (self.session.sessionParameters.atomPubUrl == nil ||
+                    [self.session.sessionParameters.atomPubUrl.absoluteString rangeOfString:@"/alfresco/service/api/cmis" options:NSCaseInsensitiveSearch].location == NSNotFound) {
+                    CMISPropertyChoice *choice1 = choices[0];
+                    XCTAssertTrue([choice1.displayName isEqualToString:@"Phone"], @"Expected choice 1 displayName to be 'Phone' but was %@", choice1.displayName);
+                    XCTAssertTrue([choice1.value isEqualToString:@"Phone"], @"Expected choice 1 value to be 'Phone' but was %@", choice1.value);
+                    CMISPropertyChoice *choice2 = choices[1];
+                    XCTAssertTrue([choice2.displayName isEqualToString:@"Audio Visual"], @"Expected choice 2 displayName to be 'Audio Visual' but was %@", choice1.displayName);
+                    XCTAssertTrue([choice2.value isEqualToString:@"Audio Visual"], @"Expected choice 2 value to be 'Audio Visual' but was %@", choice1.value);
+                    CMISPropertyChoice *choice3 = choices[2];
+                    XCTAssertTrue([choice3.displayName isEqualToString:@"Computer"], @"Expected choice 3 displayName to be 'Computer' but was %@", choice1.displayName);
+                    XCTAssertTrue([choice3.value isEqualToString:@"Computer"], @"Expected choice 3 value to be 'Computer' but was %@", choice1.value);
+                    
+                    // make sure the extensions data is also populated
+                    NSArray *extensions = typeDefinition.extensions;
+                    XCTAssertNotNil(extensions, @"Expected extensions data to be populated");
+                    XCTAssertTrue(extensions.count == 1, @"Expected 1 extension element but there were: %lu", (unsigned long)extensions.count);
+                    CMISExtensionElement *extensionElement = extensions[0];
+                    XCTAssertTrue(extensionElement.children.count > 0, @"Expected extension element to have at least one child");
+                }
+                
+                self.testCompleted = YES;
+            }
+        }];
+    }];
+}
+
+- (void)testRetrieveAspectDefinition
+{
+    [self runTest:^ {
+        
+        // NOTE: This test will request an aspect from an Alfresco repository, if the server is not an Alfresco server an error will
+        //       be returned, however, in this case, the test will still pass
+        
+        [self.session.binding.repositoryService retrieveTypeDefinition:@"P:exif:exif" completionBlock:^(CMISTypeDefinition *aspectDefinition, NSError *error) {
+            if (aspectDefinition == nil)
+            {
+                // check the error code was ObjectNotFound
+                XCTAssertTrue(error.code == kCMISErrorCodeObjectNotFound, @"Expected error code of 257 but it was %lu", (unsigned long)error.code);
+                self.testCompleted = YES;
+            }
+            else
+            {
+                // Check type definition properties
+                XCTAssertNotNil(aspectDefinition, @"Aspect definition should not be nil");
+                XCTAssertTrue([aspectDefinition.identifier isEqualToString:@"P:exif:exif"],
+                              @"Expected identifer to be 'P:exif:exif' but it was %@", aspectDefinition.identifier);
+                XCTAssertTrue([aspectDefinition.localName isEqualToString:@"exif"],
+                              @"Expected localName to be 'exif' but it was %@", aspectDefinition.localName);
+                XCTAssertTrue([aspectDefinition.localNamespace isEqualToString:@"http://www.alfresco.org/model/exif/1.0"],
+                              @"Expected localNameSpace to be 'http://www.alfresco.org/model/exif/1.0' but it was %@", aspectDefinition.localNamespace);
+                XCTAssertTrue([aspectDefinition.displayName isEqualToString:@"EXIF"],
+                              @"Expected displayName to be 'EXIF' but it was %@", aspectDefinition.displayName);
+                XCTAssertTrue([aspectDefinition.queryName isEqualToString:@"exif:exif"],
+                              @"Expected queryName to be 'exif:exif' but it was %@", aspectDefinition.queryName);
+                XCTAssertTrue([aspectDefinition.summary isEqualToString:@"Subset of the standard EXIF metadata"],
+                              @"Expected summary to be 'Subset of the standard EXIF metadata' but it was %@", aspectDefinition.summary);
+                
+                if ([self.session.repositoryInfo.cmisVersionSupported isEqualToString:@"1.0"])
+                {
+                    XCTAssertTrue(aspectDefinition.baseTypeId == CMISBaseTypePolicy, @"Unexpected base type id");
+                    XCTAssertNotNil(aspectDefinition.parentTypeId, @"Expected parent type id to be populated");
+                }
+                else
+                {
+                    // from the 1.1 binding onwards aspects are represented as secondary types
+                    XCTAssertTrue(aspectDefinition.baseTypeId == CMISBaseTypeSecondary, @"Unexpected base type id");
+                    XCTAssertTrue([aspectDefinition.parentTypeId isEqualToString:@"cmis:secondary"],
+                                  @"Expected parentTypeId to be 'cmis:secondary' but it was %@", aspectDefinition.parentTypeId);
+                }
+                
+                XCTAssertFalse(aspectDefinition.creatable, @"Expected creatable property to be false");
+                XCTAssertFalse(aspectDefinition.fileable, @"Expected fileable property to be false");
+                XCTAssertTrue(aspectDefinition.queryable, @"Expected queryable property to be true");
+                XCTAssertTrue(aspectDefinition.fullTextIndexed, @"Expected fullTextIndexed property to be true");
+                XCTAssertTrue(aspectDefinition.includedInSupertypeQuery, @"Expected includedInSupertypeQuery property to be true");
+                XCTAssertFalse(aspectDefinition.controllablePolicy, @"Expected controllablePolicy property to be false");
+                XCTAssertFalse(aspectDefinition.controllableAcl, @"Expected controllableAcl property to be false");
+                
+                self.testCompleted = YES;
+            }
+        }];
+    }];
+}
+
 - (void)testUpdateDocumentPropertiesThroughObjectService
 {
     [self runTest:^ {