(feat) added content "touching" capability (for developers)
parent
a09e6dee06
commit
b34f38f7fc
|
@ -123,6 +123,7 @@
|
|||
|
||||
- (NSException *) deleteContentWithName: (NSString *) _name;
|
||||
- (NSException *) deleteAllContent;
|
||||
- (NSException *) touchContentWithName: (NSString *) _name;
|
||||
|
||||
- (NSException *) deleteFolder;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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,13 +260,14 @@
|
|||
NSException *ex;
|
||||
|
||||
// TODO: add precondition check? (or add DELETEAction?)
|
||||
|
||||
if ((folder = [container ocsFolder]) == nil) {
|
||||
if ((folder = [container ocsFolder]) == nil)
|
||||
{
|
||||
[self errorWithFormat: @"Did not find folder of content object."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ((ex = [folder deleteContentWithName:[self nameInContainer]])) {
|
||||
if ((ex = [folder deleteContentWithName:[self nameInContainer]]))
|
||||
{
|
||||
[self errorWithFormat:@"delete failed: %@", ex];
|
||||
return ex;
|
||||
}
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue