chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gavincornw...@apache.org
Subject svn commit: r1630752 - in /chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub: CMISAtomPubObjectByIdUriBuilder.m CMISAtomPubObjectByPathUriBuilder.m
Date Fri, 10 Oct 2014 10:07:06 GMT
Author: gavincornwell
Date: Fri Oct 10 10:07:06 2014
New Revision: 1630752

URL: http://svn.apache.org/r1630752
Log:
CMIS-851: Fix NSInvalidArgumentException in [CMISObjectByIdUriBuilder buildUrl]

Added an assert for the objectId and path in the builder objects and added protection around
relationship parameter (had the potential to be nil).

Modified:
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectByIdUriBuilder.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectByPathUriBuilder.m

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectByIdUriBuilder.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectByIdUriBuilder.m?rev=1630752&r1=1630751&r2=1630752&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectByIdUriBuilder.m
(original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectByIdUriBuilder.m
Fri Oct 10 10:07:06 2014
@@ -44,17 +44,21 @@
 
 - (NSURL *)buildUrl
 {
+    // make sure we have an objectId, without one there's little point in generating the
URL!
+    assert(self.objectId);
+    
     NSString *urlString = [self.templateUrl stringByReplacingOccurrencesOfString:@"{id}"
withString:self.objectId];
     urlString = [urlString stringByReplacingOccurrencesOfString:@"{filter}" withString:(self.filter
!= nil ? self.filter : @"")];
     urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeAllowableActions}"
withString:(self.includeAllowableActions ? @"true" : @"false")];
     urlString = [urlString stringByReplacingOccurrencesOfString:@"{includePolicyIds}" withString:(self.includePolicyIds
? @"true" : @"false")];
-
-    NSString *includeRelationShipParam = [CMISEnums stringForIncludeRelationShip:self.relationships];
-    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeRelationships}"
withString:includeRelationShipParam];
-
-
     urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeACL}" withString:(self.includeACL
? @"true" : @"false")];
     urlString = [urlString stringByReplacingOccurrencesOfString:@"{renditionFilter}" withString:(self.renditionFilter
!= nil ? self.renditionFilter : @"")];
+    
+    NSString *includeRelationShipParam = [CMISEnums stringForIncludeRelationShip:self.relationships];
+    if (includeRelationShipParam == nil) {
+        includeRelationShipParam = [CMISEnums stringForIncludeRelationShip:CMISIncludeRelationshipNone];
+    }
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeRelationships}"
withString:includeRelationShipParam];
 
     if (self.returnVersion != NOT_PROVIDED) {
         NSString *returnVersionParam = nil;

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectByPathUriBuilder.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectByPathUriBuilder.m?rev=1630752&r1=1630751&r2=1630752&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectByPathUriBuilder.m
(original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubObjectByPathUriBuilder.m
Fri Oct 10 10:07:06 2014
@@ -40,13 +40,21 @@
 
 - (NSURL *)buildUrl
 {
+    // make sure we have a path, without one there's little point in generating the URL!
+    assert(self.path);
+    
     NSString *urlString = [self.templateUrl stringByReplacingOccurrencesOfString:@"{path}"
withString:self.path];
     urlString = [urlString stringByReplacingOccurrencesOfString:@"{filter}" withString:(self.filter
!= nil ? self.filter : @"")];
     urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeAllowableActions}"
withString:(self.includeAllowableActions ? @"true" : @"false")];
     urlString = [urlString stringByReplacingOccurrencesOfString:@"{includePolicyIds}" withString:(self.includePolicyIds
? @"true" : @"false")];
-    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeRelationships}"
withString:[CMISEnums stringForIncludeRelationShip:self.relationships]];
     urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeACL}" withString:(self.includeACL
? @"true" : @"false")];
     urlString = [urlString stringByReplacingOccurrencesOfString:@"{renditionFilter}" withString:(self.renditionFilter
!= nil ? self.renditionFilter : @"")];
+    
+    NSString *includeRelationShipParam = [CMISEnums stringForIncludeRelationShip:self.relationships];
+    if (includeRelationShipParam == nil) {
+        includeRelationShipParam = [CMISEnums stringForIncludeRelationShip:CMISIncludeRelationshipNone];
+    }
+    urlString = [urlString stringByReplacingOccurrencesOfString:@"{includeRelationships}"
withString:includeRelationShipParam];
 
     return [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
 }



Mime
View raw message