chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gavincornw...@apache.org
Subject svn commit: r1591943 - in /chemistry/objectivecmis/branches/browser-binding: ObjectiveCMIS/Bindings/ ObjectiveCMIS/Bindings/AtomPub/ ObjectiveCMIS/Bindings/Browser/ ObjectiveCMIS/Utils/ ObjectiveCMISTests/
Date Fri, 02 May 2014 15:08:19 GMT
Author: gavincornwell
Date: Fri May  2 15:08:18 2014
New Revision: 1591943

URL: http://svn.apache.org/r1591943
Log:
Final part of re-factoring, moved last set of atom specific constants out of binding session.
Also fixed underlying issues to enable all test to pass on both atom and browser bindings
(both bindings are now enabled for testing).

Modified:
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.m
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.m
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBroswerFormDataWriter.m
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.h
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.m
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISURLUtil.h
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISURLUtil.m
    chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/env-cfg.plist

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.m?rev=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubBaseService.m
Fri May  2 15:08:18 2014
@@ -96,13 +96,13 @@
                     
                     // Cache uri's and uri templates
                     CMISAtomPubObjectByIdUriBuilder *objectByIdUriBuilder = [[CMISAtomPubObjectByIdUriBuilder
alloc] initWithTemplateUrl:workspace.objectByIdUriTemplate];
-                    [self.bindingSession setObject:objectByIdUriBuilder forKey:kCMISBindingSessionKeyObjectByIdUriBuilder];
+                    [self.bindingSession setObject:objectByIdUriBuilder forKey:kCMISAtomBindingSessionKeyObjectByIdUriBuilder];
                     
                     CMISAtomPubObjectByPathUriBuilder *objectByPathUriBuilder = [[CMISAtomPubObjectByPathUriBuilder
alloc] initWithTemplateUrl:workspace.objectByPathUriTemplate];
-                    [self.bindingSession setObject:objectByPathUriBuilder forKey:kCMISBindingSessionKeyObjectByPathUriBuilder];
+                    [self.bindingSession setObject:objectByPathUriBuilder forKey:kCMISAtomBindingSessionKeyObjectByPathUriBuilder];
                     
                     CMISAtomPubTypeByIdUriBuilder *typeByIdUriBuilder = [[CMISAtomPubTypeByIdUriBuilder
alloc] initWithTemplateUrl:workspace.typeByIdUriTemplate];
-                    [self.bindingSession setObject:typeByIdUriBuilder forKey:kCMISBindingSessionKeyTypeByIdUriBuilder];
+                    [self.bindingSession setObject:typeByIdUriBuilder forKey:kCMISAtomBindingSessionKeyTypeByIdUriBuilder];
                     
                     [self.bindingSession setObject:workspace.queryUriTemplate forKey:kCMISAtomBindingSessionKeyQueryUri];
                     
@@ -183,7 +183,7 @@
                    cmisRequest:(CMISRequest *)cmisRequest
                completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
 {
-    [self retrieveFromCache:kCMISBindingSessionKeyObjectByIdUriBuilder
+    [self retrieveFromCache:kCMISAtomBindingSessionKeyObjectByIdUriBuilder
                 cmisRequest:cmisRequest
             completionBlock:^(id object, NSError *error) {
         CMISAtomPubObjectByIdUriBuilder *objectByIdUriBuilder = object;
@@ -233,7 +233,7 @@
                          cmisRequest:(CMISRequest *)cmisRequest
                      completionBlock:(void (^)(CMISObjectData *objectData, NSError *error))completionBlock
 {
-    [self retrieveFromCache:kCMISBindingSessionKeyObjectByPathUriBuilder
+    [self retrieveFromCache:kCMISAtomBindingSessionKeyObjectByPathUriBuilder
                 cmisRequest:cmisRequest
             completionBlock:^(id object, NSError *error) {
         CMISAtomPubObjectByPathUriBuilder *objectByPathUriBuilder = object;

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h?rev=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.h
Fri May  2 15:08:18 2014
@@ -20,6 +20,10 @@
 #import <Foundation/Foundation.h>
 
 // Session keys
+extern NSString * const kCMISAtomBindingSessionKeyObjectByIdUriBuilder;
+extern NSString * const kCMISAtomBindingSessionKeyObjectByPathUriBuilder;
+extern NSString * const kCMISAtomBindingSessionKeyChildrenByIdUriBuilder;
+extern NSString * const kCMISAtomBindingSessionKeyTypeByIdUriBuilder;
 extern NSString * const kCMISAtomBindingSessionKeyQueryUri;
 extern NSString * const kCMISAtomBindingSessionKeyQueryCollection;
 extern NSString * const kCMISAtomBindingSessionKeyCheckedoutCollection;

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m?rev=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubConstants.m
Fri May  2 15:08:18 2014
@@ -20,6 +20,10 @@
 #import "CMISAtomPubConstants.h"
 
 // Session keys
+NSString * const kCMISAtomBindingSessionKeyObjectByIdUriBuilder = @"cmis_session_key_atom_objectbyid_uri_builder";
+NSString * const kCMISAtomBindingSessionKeyObjectByPathUriBuilder = @"cmis_session_key_atom_objectbypath_uri_builder";
+NSString * const kCMISAtomBindingSessionKeyChildrenByIdUriBuilder = @"cmis_session_key_atom_childrenbyid_uri_builder";
+NSString * const kCMISAtomBindingSessionKeyTypeByIdUriBuilder = @"cmis_session_key_atom_type_by_id_uri_builder";
 NSString * const kCMISAtomBindingSessionKeyQueryUri = @"cmis_session_key_atom_query_uri";
 NSString * const kCMISAtomBindingSessionKeyQueryCollection = @"cmis_session_key_atom_query_collection";
 NSString * const kCMISAtomBindingSessionKeyCheckedoutCollection = @"cmis_session_key_atom_checkedout_collection";

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.m?rev=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/AtomPub/CMISAtomPubRepositoryService.m
Fri May  2 15:08:18 2014
@@ -19,6 +19,7 @@
 
 #import "CMISAtomPubRepositoryService.h"
 #import "CMISAtomPubBaseService+Protected.h"
+#import "CMISAtomPubConstants.h"
 #import "CMISAtomWorkspace.h"
 #import "CMISErrors.h"
 #import "CMISAtomPubTypeByIdUriBuilder.h"
@@ -85,7 +86,7 @@
         return nil;
     }
     CMISRequest *request = [[CMISRequest alloc] init];
-    [self retrieveFromCache:kCMISBindingSessionKeyTypeByIdUriBuilder
+    [self retrieveFromCache:kCMISAtomBindingSessionKeyTypeByIdUriBuilder
                 cmisRequest:request
             completionBlock:^(id object, NSError *error) {
         CMISAtomPubTypeByIdUriBuilder *typeByIdUriBuilder = object;

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBroswerFormDataWriter.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBroswerFormDataWriter.m?rev=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBroswerFormDataWriter.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBroswerFormDataWriter.m
Fri May  2 15:08:18 2014
@@ -23,6 +23,7 @@
 #import "CMISEnums.h"
 #import "CMISLog.h"
 #import "CMISMimeHelper.h"
+#import "CMISURLUtil.h"
 
 NSString * const kCMISFormDataContentTypeUrlEncoded = @"application/x-www-form-urlencoded;charset=utf-8";
 NSString * const kCMISFormDataContentTypeFormData = @"multipart/form-data; boundary=";
@@ -156,8 +157,8 @@ NSString * const kCMISFormDataContentTyp
             } else {
                 [data appendData:amp];
             }
-            NSString *parameterValue = [self.parameters[parameterKey] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-            NSString *parameter = [NSString stringWithFormat:@"%@=%@", parameterKey, parameterValue];
+            NSString *encodedParameterValue = [CMISURLUtil encodeUrlParameterValue:self.parameters[parameterKey]];
+            NSString *parameter = [NSString stringWithFormat:@"%@=%@", parameterKey, encodedParameterValue];
             [data appendData:[parameter dataUsingEncoding:NSUTF8StringEncoding]];
         }
 

Modified: 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=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/Browser/CMISBrowserUtil.m
Fri May  2 15:08:18 2014
@@ -37,6 +37,9 @@
 #import "CMISPrincipal.h"
 #import "CMISAllowableActions.h"
 
+NSString * const kCMISBrowserMinValueJSONProperty = @"\"minValue\":0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049,";
+NSString * const kCMISBrowserMaxValueJSONProperty = @"\"maxValue\":179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,";
+
 @interface NSObject (CMISUtil)
 
 + (void)performBlock:(void (^)(void))block;
@@ -124,6 +127,23 @@
     NSError *serialisationError = nil;
     id jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&serialisationError];
     
+    // HACK: An Apple bug can cause deserialisation to fail if very small or very large numbers
are used.
+    // This is usually caused when the web service providing the JSON has used a MIN or MAX
value for the data type.
+    // If an error occurred attempt to remove the offending data and re-try the deserialisation.
+    if (serialisationError)
+    {
+        // convert to string
+        NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
+        
+        // remove the minValue and maxValue properties as they are effectively indicating
any reasonable value is valid
+        jsonString = [jsonString stringByReplacingOccurrencesOfString:kCMISBrowserMinValueJSONProperty
withString:@""];
+        jsonString = [jsonString stringByReplacingOccurrencesOfString:kCMISBrowserMaxValueJSONProperty
withString:@""];
+        
+        // re-try and JSON parse
+        serialisationError = nil;
+        jsonDictionary = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]
options:0 error:&serialisationError];
+    }
+    
     CMISTypeDefinition *typeDef = nil;
     if (!serialisationError) {
         //TODO check for valid baseTypeId (cmis:document, cmis:folder, cmis:relationship,
cmis:policy, [cmis:item, cmis:secondary])

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=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.h
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.h
Fri May  2 15:08:18 2014
@@ -25,10 +25,6 @@
 
 // session key constants
 extern NSString * const kCMISBindingSessionKeyUrl;
-extern NSString * const kCMISBindingSessionKeyObjectByIdUriBuilder;
-extern NSString * const kCMISBindingSessionKeyObjectByPathUriBuilder;
-extern NSString * const kCMISBindingSessionKeyChildrenByIdUriBuilder;
-extern NSString * const kCMISBindingSessionKeyTypeByIdUriBuilder;
 
 @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=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Bindings/CMISBindingSession.m
Fri May  2 15:08:18 2014
@@ -20,10 +20,6 @@
 #import "CMISBindingSession.h"
 
 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 kCMISBindingSessionKeyChildrenByIdUriBuilder = @"cmis_session_key_childrenbyid_uri_builder";
-NSString * const kCMISBindingSessionKeyTypeByIdUriBuilder = @"cmis_session_key_type_by_id_uri_builder";
 
 @interface CMISBindingSession ()
 @property (nonatomic, strong, readwrite) NSString *username;

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m?rev=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
(original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISHttpUploadRequest.m
Fri May  2 15:08:18 2014
@@ -126,7 +126,7 @@ const NSUInteger kRawBufferSize = 24576;
     httpRequest.additionalHeaders = additionalHeaders;
     httpRequest.bytesExpected = bytesExpected;
     httpRequest.authenticationProvider = authenticationProvider;
-    httpRequest.combinedInputStream = NO;
+    httpRequest.useCombinedInputStream = NO;
     httpRequest.combinedInputStream = nil;
     httpRequest.encoderStream = nil;
     
@@ -174,7 +174,8 @@ authenticationProvider:(id<CMISAuthentic
            headers:(NSDictionary *)additionalHeaders
      bytesExpected:(unsigned long long)bytesExpected
 authenticationProvider:(id<CMISAuthenticationProvider>)authenticationProvider
-         startData:(NSData *)startData endData:(NSData *)endData
+         startData:(NSData *)startData
+           endData:(NSData *)endData
    completionBlock:(void (^)(CMISHttpResponse *, NSError *))completionBlock
      progressBlock:(void (^)(unsigned long long, unsigned long long))progressBlock
 {

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISURLUtil.h
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISURLUtil.h?rev=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISURLUtil.h (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISURLUtil.h Fri
May  2 15:08:18 2014
@@ -21,16 +21,23 @@
 
 
 @interface CMISURLUtil : NSObject
+
 /// utility method to obtain a URL string for given parameter and string value
 + (NSString *)urlStringByAppendingParameter:(NSString *)parameterName value:(NSString *)parameterValue
urlString:(NSString *)urlString;
+
 /// convenient utility method to obtain a URL string for given parameter and boolean value
 + (NSString *)urlStringByAppendingParameter:(NSString *)parameterName boolValue:(BOOL)parameterValue
urlString:(NSString *)urlString;
+
 /// convenient utility method to obtain a URL string for given parameter and boolean value
 + (NSString *)urlStringByAppendingParameter:(NSString *)parameterName numberValue:(NSNumber
*)parameterValue urlString:(NSString *)urlString;
+
 /// utility method to obtain a URL string by appending the given path
 + (NSString *)urlStringByAppendingPath:(NSString *)path urlString:(NSString *)urlString;
 
 /// utility method to obtain a URL string
 + (NSURL *)urlStringByAppendingParameter:(NSString *)parameterName value:(NSString *)parameterValue
url:(NSURL *)url;
 
+/// utility method to encode a URL parameter value
++ (NSString *)encodeUrlParameterValue:(NSString *)value;
+
 @end
\ No newline at end of file

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISURLUtil.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISURLUtil.m?rev=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISURLUtil.m (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMIS/Utils/CMISURLUtil.m Fri
May  2 15:08:18 2014
@@ -127,4 +127,14 @@ NSString * const kCMISRFC7232Reserved = 
     return [NSURL URLWithString:[CMISURLUtil urlStringByAppendingParameter:parameterName
value:parameterValue urlString:[url absoluteString]]];
 }
 
++ (NSString *)encodeUrlParameterValue:(NSString *)value
+{
+    NSString *encodedValue = CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,
+                                                                                       (CFStringRef)value,
+                                                                                       NULL,
+                                                                                       (CFStringRef)kCMISRFC7232Reserved,
+                                                                                       kCFStringEncodingUTF8));
+    return encodedValue;
+}
+
 @end
\ No newline at end of file

Modified: chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/env-cfg.plist
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/env-cfg.plist?rev=1591943&r1=1591942&r2=1591943&view=diff
==============================================================================
--- chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/env-cfg.plist (original)
+++ chemistry/objectivecmis/branches/browser-binding/ObjectiveCMISTests/env-cfg.plist Fri
May  2 15:08:18 2014
@@ -48,7 +48,7 @@
 		</dict>
 		<dict>
 			<key>disabled</key>
-			<true/>
+			<false/>
 			<key>summary</key>
 			<string>Alfresco v4.2.0 Enterprise. OpenCMIS (PublicAPI) Browser 1.1</string>
 			<key>binding</key>



Mime
View raw message