From: helge Date: Sun, 15 Aug 2004 20:31:07 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/trunk@235 d1b88da0-ebda-0310-925b-ed51d... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1274d7ca1e17866f7de92baf5bbf6394a85ef07;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/trunk@235 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/OGoContentStore/ChangeLog b/OGoContentStore/ChangeLog index e7422c26..b9a53300 100644 --- a/OGoContentStore/ChangeLog +++ b/OGoContentStore/ChangeLog @@ -1,4 +1,6 @@ -2004-08-15 +2004-08-15 Helge Hess + + * OCSFolder.m: added content deletion (v0.9.3) * OCSFolder.m: added sanity check to store method (v0.9.2) diff --git a/OGoContentStore/OCSFolder.h b/OGoContentStore/OCSFolder.h index 627f58ed..5e3aad72 100644 --- a/OGoContentStore/OCSFolder.h +++ b/OGoContentStore/OCSFolder.h @@ -79,6 +79,7 @@ - (NSString *)fetchContentWithName:(NSString *)_name; - (NSException *)writeContent:(NSString *)_content toName:(NSString *)_name; +- (NSException *)deleteContentWithName:(NSString *)_name; - (NSArray *)fetchFields:(NSArray *)_flds matchingQualifier:(EOQualifier *)_q; diff --git a/OGoContentStore/OCSFolder.m b/OGoContentStore/OCSFolder.m index 68a85cd0..6fd24ba5 100644 --- a/OGoContentStore/OCSFolder.m +++ b/OGoContentStore/OCSFolder.m @@ -332,6 +332,7 @@ static BOOL doLogStore = NO; userInfo:nil]; } + /* run */ #warning TODO: properly escape SQL specials! error = nil; @@ -339,7 +340,7 @@ static BOOL doLogStore = NO; now = [NSNumber numberWithUnsignedInt:[nowDate timeIntervalSince1970]]; if (doLogStore) - [self logWithFormat:@"SHOULD store content: %@\n%@", _name, _content]; + [self logWithFormat:@"should store content: '%@'\n%@", _name, _content]; storedVersion = [self versionOfContentWithName:_name]; if (doLogStore) @@ -428,7 +429,67 @@ static BOOL doLogStore = NO; [self releaseChannel:storeChannel]; [self releaseChannel:quickChannel]; + return error; +} + +- (NSException *)deleteContentWithName:(NSString *)_name { + EOAdaptorChannel *storeChannel, *quickChannel; + NSException *error; + NSString *delsql; + + /* check preconditions */ + if (_name == nil) { + return [NSException exceptionWithName:@"OCSDeleteException" + reason:@"no content filename was provided" + userInfo:nil]; + } + + if (doLogStore) + [self logWithFormat:@"should delete content: '%@'", _name]; + + /* open channels */ + + if ((storeChannel = [self acquireStoreChannel]) == nil) { + [self logWithFormat:@"ERROR(%s): could not open storage channel!"]; + return nil; + } + if ((quickChannel = [self acquireQuickChannel]) == nil) { + [self logWithFormat:@"ERROR(%s): could not open quick channel!"]; + [self releaseChannel:storeChannel]; + return nil; + } + + /* delete rows */ + + delsql = [@"DELETE FROM " stringByAppendingString:[self storeTableName]]; + delsql = [delsql stringByAppendingString:@" WHERE c_name="]; + delsql = [delsql stringByAppendingString:[self _formatRowValue:_name]]; + if ((error = [storeChannel evaluateExpressionX:delsql]) != nil) { + [self logWithFormat: + @"ERROR(%s): cannot delete content '%@': %@", + __PRETTY_FUNCTION__, delsql, error]; + } + else { + /* content row deleted, now delete the quick row */ + delsql = [@"DELETE FROM " stringByAppendingString:[self quickTableName]]; + delsql = [delsql stringByAppendingString:@" WHERE c_name="]; + delsql = [delsql stringByAppendingString:[self _formatRowValue:_name]]; + if ((error = [quickChannel evaluateExpressionX:delsql]) != nil) { + [self logWithFormat: + @"ERROR(%s): cannot delete quick row '%@': %@", + __PRETTY_FUNCTION__, delsql, error]; + /* + Note: we now have a "broken" record, needs to be periodically GCed by + a script! + */ + } + } + + /* release channels and return */ + + [self releaseChannel:storeChannel]; + [self releaseChannel:quickChannel]; return error; } diff --git a/OGoContentStore/Version b/OGoContentStore/Version index 06aebcd3..12dfa9a8 100644 --- a/OGoContentStore/Version +++ b/OGoContentStore/Version @@ -2,4 +2,4 @@ MAJOR_VERSION=0 MINOR_VERSION=9 -SUBMINOR_VERSION:=2 +SUBMINOR_VERSION:=3