chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peberl...@apache.org
Subject svn commit: r1507292 - in /chemistry/objectivecmis/trunk/ObjectiveCMIS: Client/CMISSession.m Utils/CMISObjectConverter.m
Date Fri, 26 Jul 2013 12:38:21 GMT
Author: peberlein
Date: Fri Jul 26 12:38:21 2013
New Revision: 1507292

URL: http://svn.apache.org/r1507292
Log:
added type cache

Modified:
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m
    chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISObjectConverter.m

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m?rev=1507292&r1=1507291&r2=1507292&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Client/CMISSession.m Fri Jul 26 12:38:21 2013
@@ -38,6 +38,7 @@
 @property (nonatomic, assign, readwrite, getter = isAuthenticated) BOOL authenticated;
 @property (nonatomic, strong, readwrite) id<CMISBinding> binding;
 @property (nonatomic, strong, readwrite) CMISRepositoryInfo *repositoryInfo;
+@property (nonatomic, strong, readwrite) NSMutableDictionary *typeCache;
 // Returns a CMISSession using the given session parameters.
 - (id)initWithSessionParameters:(CMISSessionParameters *)sessionParameters;
 
@@ -115,6 +116,8 @@
         } else { //default
             self.objectConverter = [[CMISObjectConverter alloc] initWithSession:self];
         }
+        
+        self.typeCache = [[NSMutableDictionary alloc] init];
     
         // TODO: setup locale
         // TODO: setup default session parameters
@@ -252,7 +255,18 @@
 
 - (CMISRequest*)retrieveTypeDefinition:(NSString *)typeId completionBlock:(void (^)(CMISTypeDefinition
*typeDefinition, NSError *error))completionBlock
 {
-    return [self.binding.repositoryService retrieveTypeDefinition:typeId completionBlock:completionBlock];
+    CMISTypeDefinition *typeDefinition = [self.typeCache objectForKey:typeId];
+    if (typeDefinition) {
+        completionBlock(typeDefinition, nil);
+        return nil;
+    }
+    
+    return [self.binding.repositoryService retrieveTypeDefinition:typeId completionBlock:^(CMISTypeDefinition
*typeDefinition, NSError *error) {
+        if (typeDefinition) {
+            [self.typeCache setObject:typeDefinition forKey:typeId];
+        }
+        completionBlock(typeDefinition, error);
+    }];
 }
 
 - (CMISRequest*)query:(NSString *)statement searchAllVersions:(BOOL)searchAllVersion completionBlock:(void
(^)(CMISPagedResult *pagedResult, NSError *error))completionBlock

Modified: chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISObjectConverter.m
URL: http://svn.apache.org/viewvc/chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISObjectConverter.m?rev=1507292&r1=1507291&r2=1507292&view=diff
==============================================================================
--- chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISObjectConverter.m (original)
+++ chemistry/objectivecmis/trunk/ObjectiveCMIS/Utils/CMISObjectConverter.m Fri Jul 26 12:38:21
2013
@@ -328,17 +328,16 @@
                               completionBlock:completionBlock];
         
     } else {
-        [self.session.binding.repositoryService
-         retrieveTypeDefinition:objectTypeId
-         completionBlock:^(CMISTypeDefinition *typeDefinition, NSError *error) {
-             if (error) {
-                 completionBlock(nil, [CMISErrors cmisError:error cmisErrorCode:kCMISErrorCodeRuntime]);
-             } else {
-                 [self internalNormalConvertProperties:properties
-                                        typeDefinition:typeDefinition
-                                       completionBlock:completionBlock];
-             }
-         }];
+        [self.session retrieveTypeDefinition:objectTypeId
+                             completionBlock:^(CMISTypeDefinition *typeDefinition, NSError
*error) {
+                                 if (error) {
+                                     completionBlock(nil, [CMISErrors cmisError:error cmisErrorCode:kCMISErrorCodeRuntime]);
+                                 } else {
+                                     [self internalNormalConvertProperties:properties
+                                                            typeDefinition:typeDefinition
+                                                           completionBlock:completionBlock];
+                                 }
+                             }];
     }
 }
 



Mime
View raw message