From: helge Date: Wed, 11 Jul 2007 10:09:10 +0000 (+0000) Subject: fixed OGo bug #1883 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c069140f6e33eceda786ce90da37f800a609b25c;p=sope fixed OGo bug #1883 git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1506 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-gdl1/GDLContentStore/ChangeLog b/sope-gdl1/GDLContentStore/ChangeLog index 7937e596..1b062a94 100644 --- a/sope-gdl1/GDLContentStore/ChangeLog +++ b/sope-gdl1/GDLContentStore/ChangeLog @@ -1,3 +1,13 @@ +2007-07-11 Helge Hess + + * 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 + + * GCSFolderManager.m: fixed folder creation to populate empty path + fields with NULLs (OGo bug #1883) (v4.7.45) + 2007-04-25 Wolfgang Sourdeau * GCSFolder.[hm]: added methods to delete ACL records (OGo bug #1866) diff --git a/sope-gdl1/GDLContentStore/GCSFolderManager.m b/sope-gdl1/GDLContentStore/GCSFolderManager.m index 5de55dd9..8932c98e 100644 --- a/sope-gdl1/GDLContentStore/GCSFolderManager.m +++ b/sope-gdl1/GDLContentStore/GCSFolderManager.m @@ -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; diff --git a/sope-gdl1/GDLContentStore/Version b/sope-gdl1/GDLContentStore/Version index f1c7bbbc..e03084c9 100644 --- a/sope-gdl1/GDLContentStore/Version +++ b/sope-gdl1/GDLContentStore/Version @@ -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