]> err.no Git - sope/commitdiff
fixed OGo bug #1883
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Wed, 11 Jul 2007 10:09:10 +0000 (10:09 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Wed, 11 Jul 2007 10:09:10 +0000 (10:09 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1506 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

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

index 7937e596a45f699b9f151fea8830c806520fb8b7..1b062a949eb789a3a358fc077ff21a005a0a1828 100644 (file)
@@ -1,3 +1,13 @@
+2007-07-11  Helge Hess  <helge.hess@opengroupware.org>
+
+       * GCSFolderManager.m: added some error checking, plenty of open ends
+         pending (eg folder creation not wrapped in a transaction) (v4.7.46)
+       
+2007-06-29  Wolfgang Sourdeau  <WSourdeau@Inverse.CA>
+
+       * GCSFolderManager.m: fixed folder creation to populate empty path
+         fields with NULLs (OGo bug #1883) (v4.7.45)
+
 2007-04-25  Wolfgang Sourdeau  <WSourdeau@Inverse.CA>
 
        * GCSFolder.[hm]: added methods to delete ACL records (OGo bug #1866)
index 5de55dd9fe0d2bdccbddb9e8146f8c808ae82bfc..8932c98e8a54a7c7888d9755ee5cac09b9030014 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2004-2005 SKYRIX Software AG
+  Copyright (C) 2004-2007 SKYRIX Software AG
 
   This file is part of OpenGroupware.org.
 
@@ -688,7 +688,7 @@ static NSCharacterSet *asciiAlphaNumericCS    = nil;
   sqlTest = [NSString stringWithFormat: sqlTestFormat,
                      potentialName, potentialName, potentialName];
   count = 0;
-  while ([[self performSQL: sqlTest] count] > 0) {
+  while ([[self performSQL: sqlTest] isNotEmpty]) {
     count++;
     potentialName = [NSString stringWithFormat: @"%@%d", _baseName, count];
     sqlTest = [NSString stringWithFormat: sqlTestFormat,
@@ -699,16 +699,21 @@ static NSCharacterSet *asciiAlphaNumericCS    = nil;
 }
 
 - (NSException *)createFolderOfType:(NSString *)_type atPath:(NSString *)_path{
-  GCSFolderType *ftype;
-  NSString *tableName, *quickTableName, *aclTableName;
-  NSString *baseURL;
+  // TBD: badly broken, needs to be wrapped in a transaction.
+  // TBD: would be best to perform all operations as a single SQL statement.
+  GCSFolderType    *ftype;
+  NSString         *tableName, *quickTableName, *aclTableName;
+  NSString         *baseURL, *pathElement;
   EOAdaptorChannel *channel;
-  NSMutableArray *paths;
+  NSEnumerator     *pathElements;
+  NSMutableArray   *paths;
+  NSException      *error;
+  NSString         *sql;
 
   if ([[self performSQL: [NSString stringWithFormat: @"SELECT * FROM %@"
                                  @" WHERE c_path = '%@'",
                                  [self folderInfoTableName], _path]]
-       count] > 0) {
+       isNotEmpty]) {
     return [NSException exceptionWithName:@"GCSExitingFolder"
                        reason:@"a folder already exists at that path"
                        userInfo:nil];
@@ -729,32 +734,49 @@ static NSCharacterSet *asciiAlphaNumericCS    = nil;
   tableName = [self finalizedTableNameForBaseName: tableName
                    atBaseURL: baseURL withChannel: channel];
   quickTableName = [NSString stringWithFormat: @"%@_quick", tableName];
-  aclTableName = [NSString stringWithFormat: @"%@_acl", tableName];
-
-  [channel evaluateExpressionX:
-             [NSString stringWithFormat: @"DROP TABLE %@", tableName]];
-  [channel evaluateExpressionX:
-             [NSString stringWithFormat: @"DROP TABLE %@", quickTableName]];
-  [channel evaluateExpressionX:
-             [NSString stringWithFormat: @"DROP TABLE %@", aclTableName]];
-  [channel evaluateExpressionX:
-            [self sqlCreateWithTableName: tableName]];
-  [channel evaluateExpressionX:
-             [ftype sqlQuickCreateWithTableName: quickTableName]];
-  [channel evaluateExpressionX:
-            [self sqlAclCreateWithTableName: aclTableName]];
-
-  paths = [NSMutableArray
-            arrayWithArray: [_path componentsSeparatedByString: @"/"]];
+  aclTableName   = [NSString stringWithFormat: @"%@_acl",   tableName];
+
+  sql = [@"DROP TABLE " stringByAppendingString:tableName];
+  if ((error = [channel evaluateExpressionX:sql]) != nil)
+    return error;
+
+  sql = [@"DROP TABLE " stringByAppendingString:quickTableName];
+  if ((error = [channel evaluateExpressionX:sql]) != nil)
+    return error;
+  
+  sql = [self sqlCreateWithTableName: tableName];
+  if ((error = [channel evaluateExpressionX:sql]) != nil)
+    return error;
+
+  sql = [ftype sqlQuickCreateWithTableName: quickTableName];
+  if ((error = [channel evaluateExpressionX:sql]) != nil)
+    return error;
+  
+  sql = [@"DROP TABLE " stringByAppendingString:aclTableName];
+  if ((error = [channel evaluateExpressionX:sql]) != nil)
+    return error;
+  
+  sql = [self sqlAclCreateWithTableName: aclTableName];
+  if ((error = [channel evaluateExpressionX:sql]) != nil)
+    return error;
+  
+  paths = [[NSMutableArray alloc] initWithCapacity: 5];
+
+  pathElements = [[_path componentsSeparatedByString: @"/"] objectEnumerator];
+  while ((pathElement  = [pathElements nextObject]) != nil) {
+    NSString *p = [[NSString alloc] initWithFormat: @"'%@'", pathElement];
+    [paths addObject: p];
+    [p release]; p = nil;
+  }
+  
   while ([paths count] < 5)
-    [paths addObject: @""];
+    [paths addObject: @"NULL"];
 
-  [channel evaluateExpressionX:
-             [NSString stringWithFormat: @"INSERT INTO %@"
+  sql = [NSString stringWithFormat: @"INSERT INTO %@"
                        @"        (c_path, c_path1, c_path2, c_path3, c_path4,"
                        @"         c_foldername, c_location, c_quick_location,"
                        @"         c_acl_location, c_folder_type)"
-                       @" VALUES ('%@', '%@', '%@', '%@', '%@', '%@', '%@/%@',"
+                       @" VALUES ('%@', %@, %@, %@, %@, '%@', '%@/%@',"
                        @"         '%@/%@', '%@/%@', '%@')",
                        [self folderInfoTableName], _path,
                        [paths objectAtIndex: 1], [paths objectAtIndex: 2],
@@ -763,8 +785,11 @@ static NSCharacterSet *asciiAlphaNumericCS    = nil;
                       baseURL, tableName,
                       baseURL, quickTableName,
                       baseURL, aclTableName,
-                       _type]];
+                       _type];
+  if ((error = [channel evaluateExpressionX:sql]) != nil)
+    return error;
 
+  [paths release]; paths = nil;
   [self releaseChannel: channel];
 
   return nil;
index f1c7bbbcd89e98322afd29e1e41b8615f6c56e72..e03084c928ed55a5d47f0909871bdc649df3132d 100644 (file)
@@ -2,7 +2,7 @@
 
 MAJOR_VERSION:=4
 MINOR_VERSION:=7
-SUBMINOR_VERSION:=44
+SUBMINOR_VERSION:=46
 
 # v4.5.29 requires libNGExtensions v4.5.161
 # v4.5.26 does not require libNGiCal anymore