]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@235 d1b88da0-ebda-0310-925b-ed51d...
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Sun, 15 Aug 2004 20:31:07 +0000 (20:31 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Sun, 15 Aug 2004 20:31:07 +0000 (20:31 +0000)
OGoContentStore/ChangeLog
OGoContentStore/OCSFolder.h
OGoContentStore/OCSFolder.m
OGoContentStore/Version

index e7422c26f9087105e1140129fb35d23153527866..b9a53300d22a456d70aa537c4a28f268022593db 100644 (file)
@@ -1,4 +1,6 @@
-2004-08-15    <helge@agenor.opengroupware.org>
+2004-08-15  Helge Hess  <helge.hess@skyrix.com>
+
+       * OCSFolder.m: added content deletion (v0.9.3)
 
        * OCSFolder.m: added sanity check to store method (v0.9.2)
 
index 627f58ed0a59f2254ef1542c2f508a7c65453f8b..5e3aad72271645385e0c67799aca28665506313b 100644 (file)
@@ -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;
 
index 68a85cd045ebc9cc1d41f3c7ee3d86153b65c041..6fd24ba59ae33ec53f39bfe25559a79b20ba07da 100644 (file)
@@ -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;
 }
 
index 06aebcd36090bc2e090f58c0c6abb4524282610e..12dfa9a87c97d73cc7fe3fdd4fcc3df9b638150a 100644 (file)
@@ -2,4 +2,4 @@
 
 MAJOR_VERSION=0
 MINOR_VERSION=9
-SUBMINOR_VERSION:=2
+SUBMINOR_VERSION:=3