From bfe281adb67d895ba95536a545b38268d67af039 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 21 Feb 2005 00:56:32 +0000 Subject: [PATCH] fixed for SQLite git-svn-id: http://svn.opengroupware.org/SOGo/trunk@596 d1b88da0-ebda-0310-925b-ed51d893ca5b --- OGoContentStore/ChangeLog | 10 +++++ OGoContentStore/NSURL+OCS.m | 2 +- OGoContentStore/OCSChannelManager.m | 58 +++++++++++++++++------------ OGoContentStore/OCSFolderManager.m | 23 ++++++------ OGoContentStore/README | 6 ++- OGoContentStore/Version | 4 +- OGoContentStore/sql/README | 14 ++++++- 7 files changed, 76 insertions(+), 41 deletions(-) diff --git a/OGoContentStore/ChangeLog b/OGoContentStore/ChangeLog index ff081cfe..53fc28e8 100644 --- a/OGoContentStore/ChangeLog +++ b/OGoContentStore/ChangeLog @@ -1,3 +1,13 @@ +2005-02-21 Helge Hess + + * v0.9.20 + + * OCSFolderManager.m: removed quoting of SQL table and column names + (breaks with SQLite and isn't necessary for PG), fixed URL pooling + for SQLite + + * NSURL+OCS.m: use tablename for last path component + 2005-02-12 Marcus Mueller * OCSiCalFieldExtractor.m: uses new iCalEvent API to determine correct diff --git a/OGoContentStore/NSURL+OCS.m b/OGoContentStore/NSURL+OCS.m index 19b9a3db..50e6085b 100644 --- a/OGoContentStore/NSURL+OCS.m +++ b/OGoContentStore/NSURL+OCS.m @@ -46,7 +46,7 @@ return [self ocsPathComponent:1]; } - (NSString *)ocsTableName { - return [self ocsPathComponent:2]; + return [[self path] lastPathComponent]; } @end /* NSURL(OCS) */ diff --git a/OGoContentStore/OCSChannelManager.m b/OGoContentStore/OCSChannelManager.m index 0188ad87..6c4bfa3f 100644 --- a/OGoContentStore/OCSChannelManager.m +++ b/OGoContentStore/OCSChannelManager.m @@ -151,10 +151,8 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; } - (EOAdaptor *)adaptorForURL:(NSURL *)_url { - EOAdaptor *adaptor; - NSString *adaptorName; - NSString *key; - NSDictionary *condict; + EOAdaptor *adaptor; + NSString *key; if (_url == nil) return nil; @@ -167,21 +165,30 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; [self debugWithFormat:@"creating new adaptor for URL: %@", _url]; - adaptorName = [[self class] adaptorNameForURLScheme:[_url scheme]]; - if ([adaptorName length] == 0) { - [self logWithFormat:@"ERROR: cannot handle URL: %@", _url]; - return nil; + if ([EOAdaptor respondsToSelector:@selector(adaptorForURL:)]) { + adaptor = [EOAdaptor adaptorForURL:_url]; } + else { + NSString *adaptorName; + NSDictionary *condict; + + adaptorName = [[self class] adaptorNameForURLScheme:[_url scheme]]; + if ([adaptorName length] == 0) { + [self logWithFormat:@"ERROR: cannot handle URL: %@", _url]; + return nil; + } - condict = [self connectionDictionaryForURL:_url]; + condict = [self connectionDictionaryForURL:_url]; - if ((adaptor = [EOAdaptor adaptorWithName:adaptorName]) == nil) { - [self logWithFormat:@"ERROR: did not find adaptor '%@' for URL: %@", + if ((adaptor = [EOAdaptor adaptorWithName:adaptorName]) == nil) { + [self logWithFormat:@"ERROR: did not find adaptor '%@' for URL: %@", adaptorName, _url]; - return nil; + return nil; + } + + [adaptor setConnectionDictionary:condict]; } - [adaptor setConnectionDictionary:condict]; [self->urlToAdaptor setObject:adaptor forKey:key]; return adaptor; } @@ -443,14 +450,18 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; } - (BOOL)canHandleURL:(NSURL *)_url { + BOOL isSQLite; + if (_url == nil) { [self logWithFormat:@"MISMATCH: no url .."]; return NO; } if (_url == self->url) return YES; + + isSQLite = [[_url scheme] isEqualToString:@"sqlite"]; - if (![[self->url host] isEqual:[_url host]]) { + if (!isSQLite && ![[self->url host] isEqual:[_url host]]) { [self logWithFormat:@"MISMATCH: different host .."]; return NO; } @@ -458,16 +469,17 @@ static NSTimeInterval ChannelCollectionTimer = 5 * 60; [self logWithFormat:@"MISMATCH: different db .."]; return NO; } - if (![[self->url user] isEqual:[_url user]]) { - [self logWithFormat:@"MISMATCH: different user .."]; - return NO; - } - if ([[self->url port] intValue] != [[_url port] intValue]) { - [self logWithFormat:@"MISMATCH: different port (%@ vs %@) ..", - [self->url port], [_url port]]; - return NO; + if (!isSQLite) { + if (![[self->url user] isEqual:[_url user]]) { + [self logWithFormat:@"MISMATCH: different user .."]; + return NO; + } + if ([[self->url port] intValue] != [[_url port] intValue]) { + [self logWithFormat:@"MISMATCH: different port (%@ vs %@) ..", + [self->url port], [_url port]]; + return NO; + } } - return YES; } diff --git a/OGoContentStore/OCSFolderManager.m b/OGoContentStore/OCSFolderManager.m index e7762fa3..57dd90c5 100644 --- a/OGoContentStore/OCSFolderManager.m +++ b/OGoContentStore/OCSFolderManager.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "OCSFolderManager.h" #include "OCSChannelManager.h" @@ -181,7 +180,7 @@ static const char *OCSPathColumnPattern = "c_path%i"; /* run SQL */ if ((ex = [channel evaluateExpressionX:_sql]) != nil) { - [self logWithFormat:@"ERROR(%s): cannot execute SQL '%@': %@", + [self logWithFormat:@"ERROR(%s): cannot execute\n SQL '%@':\n %@", __PRETTY_FUNCTION__, _sql, ex]; [self releaseChannel:channel]; return nil; @@ -308,7 +307,7 @@ static const char *OCSPathColumnPattern = "c_path%i"; } if (_beExact && (count > quickPathCount)) { - [sql appendString:@" AND \"c_foldername\" = '"]; + [sql appendString:@" AND c_foldername = '"]; [sql appendString:[_names lastObject]]; [sql appendString:@"'"]; } @@ -329,7 +328,7 @@ static const char *OCSPathColumnPattern = "c_path%i"; return nil; sql = [NSMutableString stringWithCapacity:256]; - [sql appendString:@"SELECT \"c_path\" FROM "]; + [sql appendString:@"SELECT c_path FROM "]; [sql appendString:[self folderInfoTableName]]; [sql appendString:@" WHERE "]; [sql appendString:ws]; @@ -401,7 +400,7 @@ static const char *OCSPathColumnPattern = "c_path%i"; recName = [record objectForKey:OCSPathRecordName]; #if 0 [self logWithFormat:@"check '%@' vs '%@' (%@)...", - name, recName,[_records objectAtIndex:i]]; + name, recName, [_records objectAtIndex:i]]; #endif if ([name isEqualToString:recName]) @@ -528,10 +527,10 @@ static const char *OCSPathColumnPattern = "c_path%i"; sql = [NSMutableString stringWithCapacity:256]; [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_folder_id, "]; + [sql appendString:@"c_path, "]; + [sql appendString:@"c_location, c_quick_location, "]; + [sql appendString:@"c_folder_type"]; [sql appendString:@" FROM "]; [sql appendString:[self folderInfoTableName]]; [sql appendString:@" WHERE "]; @@ -546,7 +545,9 @@ static const char *OCSPathColumnPattern = "c_path%i"; } // TODO: need to filter on path - + // required when we start to have deeper hierarchies + // => isn't that already done below? + if ([records count] != 1) { if ([records count] == 0) { [self debugWithFormat:@"found no records for path: '%@'", _path]; diff --git a/OGoContentStore/README b/OGoContentStore/README index 8d52d62f..b2d35c76 100644 --- a/OGoContentStore/README +++ b/OGoContentStore/README @@ -1,5 +1,3 @@ -# $Id$ - Storage Backend =============== @@ -15,6 +13,10 @@ Note: to sync with LDAP we need to periodically delete or archive old folders Folders have associated a type (like 'calendar') which defines the query attributes and serialization format. +TODO +==== +- hierarchies deeper than 4 (properly filter on path in OCS) + Open Questions ============== diff --git a/OGoContentStore/Version b/OGoContentStore/Version index ad8d9fe8..78e0144f 100644 --- a/OGoContentStore/Version +++ b/OGoContentStore/Version @@ -1,8 +1,8 @@ -# $Id: Version,v 1.201 2004/06/29 13:45:54 helge Exp $ +# Version file MAJOR_VERSION=0 MINOR_VERSION=9 -SUBMINOR_VERSION:=19 +SUBMINOR_VERSION:=20 # v0.9.19 requires libNGiCal v4.5.40 # v0.9.18 requires libNGiCal v4.5.38 diff --git a/OGoContentStore/sql/README b/OGoContentStore/sql/README index d29019ce..7f2ecb2e 100644 --- a/OGoContentStore/sql/README +++ b/OGoContentStore/sql/README @@ -1,5 +1,3 @@ -# $Id$ - Files ===== @@ -27,3 +25,15 @@ register-agenor-helge-privcal.psql testapt-agenor-helge-privcal.psql - insert a raw iCalendar test appointment in the /Users/helge/Calendar folder quick and content tables + + +Notes +===== + +Listing the folders of a certain user: + + sqlite> SELECT c_path FROM SOGo_folder_info \ + WHERE c_path2 = 'test.et.di.cete-lyon'; + /Users/test.et.di.cete-lyon + /Users/test.et.di.cete-lyon/Calendar + /Users/test.et.di.cete-lyon/Contacts -- 2.39.5