diff --git a/SOPE/GDLContentStore/GCSFolder.h b/SOPE/GDLContentStore/GCSFolder.h index 1d9627b47..919e0d2a1 100644 --- a/SOPE/GDLContentStore/GCSFolder.h +++ b/SOPE/GDLContentStore/GCSFolder.h @@ -123,6 +123,7 @@ - (NSException *) deleteContentWithName: (NSString *) _name; - (NSException *) deleteAllContent; +- (NSException *) touchContentWithName: (NSString *) _name; - (NSException *) deleteFolder; diff --git a/SOPE/GDLContentStore/GCSFolder.m b/SOPE/GDLContentStore/GCSFolder.m index 644d6351c..e3679026a 100644 --- a/SOPE/GDLContentStore/GCSFolder.m +++ b/SOPE/GDLContentStore/GCSFolder.m @@ -1187,7 +1187,7 @@ andAttribute: (EOAttribute *)_attribute return error; } -- (NSException *)deleteContentWithName:(NSString *)_name { +- (NSException *) deleteContentWithName:(NSString *)_name { EOAdaptorChannel *storeChannel, *quickChannel; EOAdaptorContext *adaptorCtx; NSException *error; @@ -1195,7 +1195,6 @@ andAttribute: (EOAttribute *)_attribute NSCalendarDate *nowDate; /* check preconditions */ - if (_name == nil) { return [NSException exceptionWithName:@"GCSDeleteException" reason:@"no content filename was provided" @@ -1334,6 +1333,58 @@ andAttribute: (EOAttribute *)_attribute return error; } +- (NSException *) touchContentWithName: (NSString *) _name +{ + NSString *touchSql, *table; + EOAdaptorContext *adaptorCtx; + EOAdaptorChannel *channel; + EOAttribute *attribute; + NSCalendarDate *nowDate; + + if (_name == nil) + return [NSException exceptionWithName: @"GCSDeleteException" + reason: @"no content filename was provided" + userInfo: nil]; + + channel = [self acquireStoreChannel]; + + if ((channel = [self acquireStoreChannel]) == nil) + { + [self errorWithFormat:@"could not open storage channel!"]; + return nil; + } + + adaptorCtx = [channel adaptorContext]; + [adaptorCtx beginTransaction]; + + table = [self storeTableName]; + attribute = [self _attributeForColumn: @"c_name"]; + nowDate = [NSCalendarDate date]; + + if ([GCSFolderManager singleStoreMode]) + touchSql = [NSString stringWithFormat: @"UPDATE %@ SET c_lastmodified = %u WHERE c_name = %@ AND c_folder_id = %@", + table, + (unsigned int) [nowDate timeIntervalSince1970], + [self _formatRowValue: _name + withAdaptor: [adaptorCtx adaptor] + andAttribute: attribute], + folderId]; + else + touchSql = [NSString stringWithFormat: @"UPDATE %@ SET c_lastmodified = %u WHERE c_name = %@", + table, + (unsigned int) [nowDate timeIntervalSince1970], + [self _formatRowValue: _name + withAdaptor: [adaptorCtx adaptor] + andAttribute: attribute]]; + + [channel evaluateExpressionX: touchSql]; + + [[channel adaptorContext] commitTransaction]; + [self releaseChannel: channel]; + + return nil; +} + - (NSException *)deleteFolder { EOAdaptorChannel *channel; NSString *delsql; diff --git a/SoObjects/SOGo/SOGoContentObject.h b/SoObjects/SOGo/SOGoContentObject.h index fbd0e7365..411007486 100644 --- a/SoObjects/SOGo/SOGoContentObject.h +++ b/SoObjects/SOGo/SOGoContentObject.h @@ -1,6 +1,6 @@ /* - Copyright (C) 2004 SKYRIX Software AG - Copyright (C) 2005-2014 Inverse inc. + Copyright (C) 2006-2016 Inverse inc. + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of SOGo. @@ -74,6 +74,7 @@ - (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder; - (NSException *) moveToFolder: (SOGoGCSFolder *) newFolder; - (NSException *) delete; +- (NSException *) touch; /* DAV support */ diff --git a/SoObjects/SOGo/SOGoContentObject.m b/SoObjects/SOGo/SOGoContentObject.m index 9e7ecb0e3..137c59529 100644 --- a/SoObjects/SOGo/SOGoContentObject.m +++ b/SoObjects/SOGo/SOGoContentObject.m @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2014 Inverse inc. + Copyright (C) 2006-2016 Inverse inc. Copyright (C) 2004-2005 SKYRIX Software AG This file is part of SOGo. @@ -260,16 +260,17 @@ NSException *ex; // TODO: add precondition check? (or add DELETEAction?) - - if ((folder = [container ocsFolder]) == nil) { - [self errorWithFormat:@"Did not find folder of content object."]; - return nil; - } - - if ((ex = [folder deleteContentWithName:[self nameInContainer]])) { - [self errorWithFormat:@"delete failed: %@", ex]; - return ex; - } + if ((folder = [container ocsFolder]) == nil) + { + [self errorWithFormat: @"Did not find folder of content object."]; + return nil; + } + + if ((ex = [folder deleteContentWithName:[self nameInContainer]])) + { + [self errorWithFormat:@"delete failed: %@", ex]; + return ex; + } [container removeChildRecordWithName: nameInContainer]; [[SOGoCache sharedCache] unregisterObjectWithName: nameInContainer @@ -278,24 +279,36 @@ return nil; } +- (NSException *) touch +{ + NSCalendarDate *now; + GCSFolder *folder; + NSException *ex; + + if ((folder = [container ocsFolder]) == nil) + { + [self errorWithFormat: @"Did not find folder of content object."]; + return nil; + } + + if ((ex = [folder touchContentWithName: nameInContainer])) + { + [self errorWithFormat: @"touch failed: %@", ex]; + return ex; + } + + now = [NSCalendarDate calendarDate]; + ASSIGN(lastModified, now); + + [container removeChildRecordWithName: nameInContainer]; + [[SOGoCache sharedCache] unregisterObjectWithName: nameInContainer + inContainer: container]; + + return nil; +} + + /* actions */ - -// - (id) lookupName: -// { -// SoSelectorInvocation *invocation; -// NSString *name; - -// name = [NSString stringWithFormat: @"%@:", [_key davMethodToObjC]]; - -// invocation = [[SoSelectorInvocation alloc] -// initWithSelectorNamed: name -// addContextParameter: YES]; -// [invocation autorelease]; - -// return invocation; - -// } - - (id) PUTAction: (WOContext *) _ctx { WORequest *rq;