]> err.no Git - sope/commitdiff
added ACL support
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Mon, 15 Jan 2007 19:15:46 +0000 (19:15 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Mon, 15 Jan 2007 19:15:46 +0000 (19:15 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1400 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-gdl1/GDLContentStore/ChangeLog
sope-gdl1/GDLContentStore/GCSFolder.h
sope-gdl1/GDLContentStore/GCSFolder.m
sope-gdl1/GDLContentStore/GCSFolderManager.m
sope-gdl1/GDLContentStore/Version

index b7826499c5e733a7aa7d7a75c854bed8dd93b66d..f5fec6eb829311ff68ee61e068ff76cfb5a5a12e 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-15  Wolfgang Sourdeau  <WSourdeau@Inverse.CA>
+
+       * GCSFolder.[hm], GCSFolderManager.m: added support for content table
+         ACLs (v4.5.38)
+
 2006-08-31  Wolfgang Sourdeau  <WSourdeau@Inverse.CA>
 
        * EOQualifier+GCS.m: added support for OR qualifiers and for case
index 3fe9cd38f6cdd92fe9586032294809cc9d83391a..6abd810de0aeb5af0a76510f95769bf84781deb8 100644 (file)
@@ -1,5 +1,6 @@
 /*
-  Copyright (C) 2004-2005 SKYRIX Software AG
+  Copyright (C) 2004-2007 SKYRIX Software AG
+  Copyright (C) 2007      Helge Hess
 
   This file is part of OpenGroupware.org.
 
@@ -54,6 +55,7 @@
   NSString *path;
   NSURL    *location;
   NSURL    *quickLocation;
+  NSURL    *aclLocation;
   NSString *folderTypeName;
 
   struct {
@@ -66,6 +68,7 @@
 - (id)initWithPath:(NSString *)_path primaryKey:(id)_folderId
   folderTypeName:(NSString *)_ftname folderType:(GCSFolderType *)_ftype
   location:(NSURL *)_loc quickLocation:(NSURL *)_qloc
+  aclLocation: (NSURL *)_aloc
   folderManager:(GCSFolderManager *)_fm;
 
 /* accessors */
@@ -75,6 +78,7 @@
 - (NSString *)path;
 - (NSURL    *)location;
 - (NSURL    *)quickLocation;
+- (NSURL    *)aclLocation;
 - (NSString *)folderTypeName;
 
 - (GCSFolderManager *)folderManager;
 
 - (NSString *)storeTableName;
 - (NSString *)quickTableName;
+- (NSString *)aclTableName;
 - (BOOL)isQuickInfoStoredInContentTable;
 
 /* connection */
 
 - (EOAdaptorChannel *)acquireStoreChannel;
 - (EOAdaptorChannel *)acquireQuickChannel;
+- (EOAdaptorChannel *)acquireAclChannel;
 - (void)releaseChannel:(EOAdaptorChannel *)_channel;
 
 - (BOOL)canConnectStore;
 - (NSArray *)fetchFields:(NSArray *)_flds 
   fetchSpecification:(EOFetchSpecification *)_fs;
 - (NSArray *)fetchFields:(NSArray *)_flds matchingQualifier:(EOQualifier *)_q;
+- (NSArray *)fetchAclMatchingQualifier:(EOQualifier *)_q;
 
 @end
 
index b4c1647c4f461b625a12e88900b0d78b7b3bb898..31dfae7c15f3f5f0a0fe0573d7433cdf8437a98b 100644 (file)
@@ -1,5 +1,6 @@
 /*
-  Copyright (C) 2004-2005 SKYRIX Software AG
+  Copyright (C) 2004-2007 SKYRIX Software AG
+  Copyright (C) 2007      Helge Hess
 
   This file is part of OpenGroupware.org.
 
@@ -57,6 +58,7 @@ static GCSStringFormatter *stringFormatter = nil;
 - (id)initWithPath:(NSString *)_path primaryKey:(id)_folderId
   folderTypeName:(NSString *)_ftname folderType:(GCSFolderType *)_ftype
   location:(NSURL *)_loc quickLocation:(NSURL *)_qloc
+  aclLocation:(NSURL *)_aloc
   folderManager:(GCSFolderManager *)_fm
 {
   if (![_loc isNotNull]) {
@@ -75,8 +77,9 @@ static GCSStringFormatter *stringFormatter = nil;
     self->path           = [_path   copy];
     self->location       = [_loc    retain];
     self->quickLocation  = _qloc ? [_qloc   retain] : [_loc retain];
+    self->aclLocation    = [_aloc   retain];
     self->folderTypeName = [_ftname copy];
-    
+
     self->ofFlags.requiresFolderSelect = 0;
     self->ofFlags.sameTableForQuick = 
       [self->location isEqualTo:self->quickLocation] ? 1 : 0;
@@ -87,8 +90,19 @@ static GCSStringFormatter *stringFormatter = nil;
   return [self initWithPath:nil primaryKey:nil
               folderTypeName:nil folderType:nil 
               location:nil quickLocation:nil
+               aclLocation:nil
               folderManager:nil];
 }
+- (id)initWithPath:(NSString *)_path primaryKey:(id)_folderId
+  folderTypeName:(NSString *)_ftname folderType:(GCSFolderType *)_ftype
+  location:(NSURL *)_loc quickLocation:(NSURL *)_qloc
+  folderManager:(GCSFolderManager *)_fm
+{
+  return [self initWithPath:_path primaryKey:_folderId folderTypeName:_ftname
+              folderType:_ftype location:_loc quickLocation:_qloc
+              aclLocation:nil
+              folderManager:_fm];
+}
 
 - (void)dealloc {
   [self->folderManager  release];
@@ -98,6 +112,7 @@ static GCSStringFormatter *stringFormatter = nil;
   [self->path           release];
   [self->location       release];
   [self->quickLocation  release];
+  [self->aclLocation    release];
   [self->folderTypeName release];
   [super dealloc];
 }
@@ -121,6 +136,9 @@ static GCSStringFormatter *stringFormatter = nil;
 - (NSURL *)quickLocation {
   return self->quickLocation;
 }
+- (NSURL *)aclLocation {
+  return self->aclLocation;
+}
 
 - (NSString *)folderTypeName {
   return self->folderTypeName;
@@ -139,6 +157,9 @@ static GCSStringFormatter *stringFormatter = nil;
 - (NSString *)quickTableName {
   return [[self quickLocation] gcsTableName];
 }
+- (NSString *)aclTableName {
+  return [[self aclLocation] gcsTableName];
+}
 
 - (BOOL)isQuickInfoStoredInContentTable {
   return self->ofFlags.sameTableForQuick ? YES : NO;
@@ -152,6 +173,9 @@ static GCSStringFormatter *stringFormatter = nil;
 - (EOAdaptorChannel *)acquireQuickChannel {
   return [[self channelManager] acquireOpenChannelForURL:[self quickLocation]];
 }
+- (EOAdaptorChannel *)acquireAclChannel {
+  return [[self channelManager] acquireOpenChannelForURL:[self aclLocation]];
+}
 
 - (void)releaseChannel:(EOAdaptorChannel *)_channel {
   [[self channelManager] releaseChannel:_channel];
@@ -164,6 +188,9 @@ static GCSStringFormatter *stringFormatter = nil;
 - (BOOL)canConnectQuick {
   return [[self channelManager] canConnect:[self quickLocation]];
 }
+- (BOOL)canConnectAcl {
+  return [[self channelManager] canConnect:[self quickLocation]];
+}
 
 /* errors */
 
@@ -826,6 +853,89 @@ static GCSStringFormatter *stringFormatter = nil;
   return [self fetchFields:_flds fetchSpecification:fs];
 }
 
+- (NSArray *)fetchAclWithSpecification:(EOFetchSpecification *)_fs
+{
+  EOQualifier      *qualifier;
+  NSArray          *sortOrderings;
+  EOAdaptorChannel *channel;
+  NSException      *error;
+  NSMutableString  *sql;
+  NSArray          *attrs;
+  NSMutableArray   *results;
+  NSDictionary     *row;
+  
+  qualifier     = [_fs qualifier];
+  sortOrderings = [_fs sortOrderings];
+  
+#if 0
+  [self logWithFormat:@"FETCH: %@", _flds];
+  [self logWithFormat:@"  MATCH: %@", _q];
+#endif
+  
+  /* generate SQL */
+
+  sql = [NSMutableString stringWithCapacity:256];
+  [sql appendString:@"SELECT c_uid, c_object, c_role"];
+  [sql appendString:@" FROM "];
+  [sql appendString:[self aclTableName]];
+  
+  if (qualifier != nil) {
+    [sql appendString:@" WHERE "];
+    [sql appendString:[self generateSQLForQualifier:qualifier]];
+  }
+  if ([sortOrderings count] > 0) {
+    [sql appendString:@" ORDER BY "];
+    [sql appendString:[self generateSQLForSortOrderings:sortOrderings]];
+  }
+#if 0
+  /* limit */
+  [sql appendString:@" LIMIT "]; // count
+  [sql appendString:@" OFFSET "]; // index from 0
+#endif
+  
+  /* open channel */
+
+  if ((channel = [self acquireAclChannel]) == nil) {
+    [self logWithFormat:@"ERROR(%s): could not open acl channel!"];
+    return nil;
+  }
+  
+  /* run SQL */
+
+  if ((error = [channel evaluateExpressionX:sql]) != nil) {
+    [self logWithFormat:@"ERROR(%s): cannot execute acl-fetch SQL '%@': %@", 
+           __PRETTY_FUNCTION__, sql, error];
+    [self releaseChannel:channel];
+    return nil;
+  }
+  
+  /* fetch results */
+  
+  results = [NSMutableArray arrayWithCapacity:64];
+  attrs   = [channel describeResults:NO /* do not beautify names */];
+  while ((row = [channel fetchAttributes:attrs withZone:NULL]) != nil)
+    [results addObject:row];
+  
+  /* release channels */
+  
+  [self releaseChannel:channel];
+  
+  return results;
+}
+- (NSArray *) fetchAclMatchingQualifier:(EOQualifier *)_q {
+  EOFetchSpecification *fs;
+
+  if (_q == nil)
+    fs = nil;
+  else {
+    fs = [EOFetchSpecification fetchSpecificationWithEntityName:
+                                [self folderName]
+                              qualifier:_q
+                              sortOrderings:nil];
+  }
+  return [self fetchAclWithSpecification:fs];
+}
+
 /* description */
 
 - (NSString *)description {
index 68c9a9dcc587f812d199f2fbd54bcd871a8c1456..3d1adeff5b798ea27d13719342105496b9d901bc 100644 (file)
@@ -229,7 +229,7 @@ static const char *GCSPathColumnPattern     = "c_path%i";
   GCSFolderType *folderType;
   NSString      *folderTypeName, *locationString, *folderName, *path;
   NSNumber      *folderId;
-  NSURL         *location, *quickLocation;
+  NSURL         *location, *quickLocation, *aclLocation;
   
   if (_record == nil) return nil;
   
@@ -270,11 +270,17 @@ static const char *GCSPathColumnPattern     = "c_path%i";
     [self logWithFormat:@"WARNING(%s): missing quick location in record: %@", 
            __PRETTY_FUNCTION__, _record];
   }
+
+  locationString = [_record objectForKey:@"c_acl_location"];
+  aclLocation = [locationString isNotNull]
+    ? [NSURL URLWithString:locationString]
+    : nil;
   
   folder = [[GCSFolder alloc] initWithPath:path primaryKey:folderId
                              folderTypeName:folderTypeName 
                              folderType:folderType
                              location:location quickLocation:quickLocation
+                              aclLocation:aclLocation
                              folderManager:self];
   return [folder autorelease];
 }
@@ -561,8 +567,8 @@ static const char *GCSPathColumnPattern     = "c_path%i";
   [sql appendString:@"SELECT "];
   [sql appendString:@"c_folder_id, "];
   [sql appendString:@"c_path, "];
-  [sql appendString:@"c_location, c_quick_location, "];
-  [sql appendString:@"c_folder_type"];
+  [sql appendString:@"c_location, c_quick_location, c_acl_location,"];
+  [sql appendString:@" c_folder_type"];
   [sql appendString:@" FROM "];
   [sql appendString:[self folderInfoTableName]];
   [sql appendString:@" WHERE "];
index cc3cbaec112e79044374e9100c85f26120c078a3..5d9ca27c210a1d5a76b5e2bf2144878b09da09c9 100644 (file)
@@ -2,7 +2,7 @@
 
 MAJOR_VERSION:=4
 MINOR_VERSION:=5
-SUBMINOR_VERSION:=37
+SUBMINOR_VERSION:=38
 
 # v4.5.29 requires libNGExtensions v4.5.161
 # v4.5.26 does not require libNGiCal anymore