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/22 09:03:34 UTC
svn commit: r1619684 - in /chemistry/objectivecmis/trunk:
ObjectiveCMIS/Bindings/AtomPub/ ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/
ObjectiveCMIS/Bindings/Browser/ ObjectiveCMISTests/
Author: gavincornwell
Date: Fri Aug 22 07:03:33 2014
New Revision: 1619684
URL: http://svn.apache.org/r1619684
Log:
Fixed https://issues.apache.org/jira/browse/CMIS-838 (Property definition default value is not being parsed by either binding)
Modified:
chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubPropertyDefinitionParser.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/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=1619684&r1=1619683&r2=1619684&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubPropertyDefinitionParser.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/AtomPubParser/CMISAtomPubPropertyDefinitionParser.m Fri Aug 22 07:03:33 2014
@@ -28,6 +28,7 @@
@property (nonatomic, strong, readwrite) NSString *currentString;
@property (nonatomic, strong, readwrite) NSMutableArray *currentChoices;
@property (nonatomic, strong, readwrite) CMISPropertyChoice *currentChoice;
+@property (nonatomic, strong, readwrite) NSMutableArray *currentValues;
// Properties if used as child delegate parser
@property(nonatomic, weak) id <NSXMLParserDelegate, CMISAtomPubPropertyDefinitionDelegate> parentDelegate;
@@ -43,6 +44,7 @@
self = [super init];
if (self) {
self.propertyDefinition = [[CMISPropertyDefinition alloc] init];
+ self.currentValues = [NSMutableArray array];
}
return self;
}
@@ -175,8 +177,22 @@
} 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];
+ if (self.currentString != nil) {
+ [self.currentValues addObject:self.currentString];
+ } else {
+ // a value element being present without a value signifies an empty string
+ [self.currentValues addObject:@""];
+ }
+ } else if ([elementName isEqualToString:kCMISCoreChoice] || [elementName isEqualToString:kCMISCoreChoiceString]) {
+ // there should only ever be one value for a single choice element
+ if (self.currentValues.count == 1) {
+ self.currentChoice.value = self.currentValues[0];
+ [self.currentChoices addObject:self.currentChoice];
+ }
+ [self.currentValues removeAllObjects];
+ } else if ([elementName isEqualToString:kCMISCoreDefaultValue]) {
+ self.propertyDefinition.defaultValues = [NSArray arrayWithArray:self.currentValues];
+ [self.currentValues removeAllObjects];
}
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=1619684&r1=1619683&r2=1619684&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h Fri Aug 22 07:03:33 2014
@@ -152,6 +152,7 @@ extern NSString * const kCMISCoreOrderab
extern NSString * const kCMISCoreOpenChoice;
extern NSString * const kCMISCoreChoice;
extern NSString * const kCMISCoreChoiceString;
+extern NSString * const kCMISCoreDefaultValue;
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=1619684&r1=1619683&r2=1619684&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m Fri Aug 22 07:03:33 2014
@@ -152,6 +152,7 @@ NSString * const kCMISCoreOrderable = @"
NSString * const kCMISCoreOpenChoice = @"openChoice";
NSString * const kCMISCoreChoice = @"choice";
NSString * const kCMISCoreChoiceString = @"choiceString";
+NSString * const kCMISCoreDefaultValue = @"defaultValue";
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=1619684&r1=1619683&r2=1619684&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m Fri Aug 22 07:03:33 2014
@@ -1003,7 +1003,21 @@ NSString * const kCMISBrowserMaxValueJSO
propDef.updatability = CMISUpdatabilityWhenCheckedOut;
}
- // TODO default value
+ // parse default value
+ id defaultValueObject = propertyDictionary[kCMISBrowserJSONDefaultValue];
+ if (defaultValueObject != nil)
+ {
+ // for single valued properties this will be actual default value,
+ // for multi valued properties this will be an array
+ if ([defaultValueObject isKindOfClass:[NSArray class]])
+ {
+ propDef.defaultValues = defaultValueObject;
+ }
+ else
+ {
+ propDef.defaultValues = @[defaultValueObject];
+ }
+ }
// parse choices, if present
NSArray *choicesJSON = propertyDictionary[kCMISBrowserJSONChoice];
Modified: chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m?rev=1619684&r1=1619683&r2=1619684&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMISTests/ObjectiveCMISTests.m Fri Aug 22 07:03:33 2014
@@ -1537,20 +1537,19 @@
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);
+ // add the displayNames of each choice to a set and then check for existence (order differs on older Alfresco servers)
+ NSMutableSet *choicesDisplayNameSet = [NSMutableSet set];
+ for (CMISPropertyChoice *choice in constraintPropertyDefiniton.choices)
+ {
+ [choicesDisplayNameSet addObject:choice.displayName];
+ }
+ XCTAssertTrue([choicesDisplayNameSet containsObject:@"Phone"], @"Expected to find a choice of 'Phone'");
+ XCTAssertTrue([choicesDisplayNameSet containsObject:@"Audio Visual"], @"Expected to find a choice of 'Audio Visual'");
+ XCTAssertTrue([choicesDisplayNameSet containsObject:@"Computer"], @"Expected to find a choice of 'Computer'");
- // only perform the following tests on endpoints using OpenCMIS
+ // only perform the following test 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");
@@ -1565,6 +1564,49 @@
}];
}
+- (void)testDefaultValuesForPropertyDefinition
+{
+ [self runTest:^ {
+
+ // NOTE: This test will request an task type 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:@"D:wf:adhocTask" completionBlock:^(CMISTypeDefinition *taskDefinition, NSError *error) {
+ if (taskDefinition == 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 task definition properties
+ XCTAssertNotNil(taskDefinition, @"Task definition should not be nil");
+ XCTAssertTrue([taskDefinition.identifier isEqualToString:@"D:wf:adhocTask"],
+ @"Expected identifer to be 'D:wf:adhocTask' but it was %@", taskDefinition.identifier);
+
+ // retrieve and check some property definition objects
+ CMISPropertyDefinition *statusPropertyDefiniton = [taskDefinition propertyDefinitionForId:@"bpm:status"];
+ XCTAssertNotNil(statusPropertyDefiniton, @"Expected to find a property definition for bpm:status");
+ XCTAssertTrue([statusPropertyDefiniton.identifier isEqualToString:@"bpm:status"],
+ @"Expected identifier to be 'bpm:status' but it was %@", statusPropertyDefiniton.identifier);
+
+ NSArray *defaultValues = statusPropertyDefiniton.defaultValues;
+ XCTAssertNotNil(defaultValues, @"Expected defaultValues to be populated");
+ XCTAssertTrue(defaultValues.count == 1, @"Expected there to be 1 default value but there were %lu", (unsigned long)defaultValues.count);
+ XCTAssertTrue([defaultValues[0] isEqualToString:@"Not Yet Started"],
+ @"Expected default value to be 'Not Yet Started' but it was %@", defaultValues[0]);
+
+ NSArray *choices = statusPropertyDefiniton.choices;
+ XCTAssertNotNil(choices, @"Expected choices to be populated");
+ XCTAssertTrue(choices.count == 5, @"Expected there to be 5 choices but there were %lu", (unsigned long)choices.count);
+
+ self.testCompleted = YES;
+ }
+ }];
+ }];
+}
+
- (void)testRetrieveAspectDefinition
{
[self runTest:^ {