(feat) added content "touching" capability (for developers)
parent
a09e6dee06
commit
b34f38f7fc
|
@ -123,6 +123,7 @@
|
||||||
|
|
||||||
- (NSException *) deleteContentWithName: (NSString *) _name;
|
- (NSException *) deleteContentWithName: (NSString *) _name;
|
||||||
- (NSException *) deleteAllContent;
|
- (NSException *) deleteAllContent;
|
||||||
|
- (NSException *) touchContentWithName: (NSString *) _name;
|
||||||
|
|
||||||
- (NSException *) deleteFolder;
|
- (NSException *) deleteFolder;
|
||||||
|
|
||||||
|
|
|
@ -1187,7 +1187,7 @@ andAttribute: (EOAttribute *)_attribute
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSException *)deleteContentWithName:(NSString *)_name {
|
- (NSException *) deleteContentWithName:(NSString *)_name {
|
||||||
EOAdaptorChannel *storeChannel, *quickChannel;
|
EOAdaptorChannel *storeChannel, *quickChannel;
|
||||||
EOAdaptorContext *adaptorCtx;
|
EOAdaptorContext *adaptorCtx;
|
||||||
NSException *error;
|
NSException *error;
|
||||||
|
@ -1195,7 +1195,6 @@ andAttribute: (EOAttribute *)_attribute
|
||||||
NSCalendarDate *nowDate;
|
NSCalendarDate *nowDate;
|
||||||
|
|
||||||
/* check preconditions */
|
/* check preconditions */
|
||||||
|
|
||||||
if (_name == nil) {
|
if (_name == nil) {
|
||||||
return [NSException exceptionWithName:@"GCSDeleteException"
|
return [NSException exceptionWithName:@"GCSDeleteException"
|
||||||
reason:@"no content filename was provided"
|
reason:@"no content filename was provided"
|
||||||
|
@ -1334,6 +1333,58 @@ andAttribute: (EOAttribute *)_attribute
|
||||||
return error;
|
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 {
|
- (NSException *)deleteFolder {
|
||||||
EOAdaptorChannel *channel;
|
EOAdaptorChannel *channel;
|
||||||
NSString *delsql;
|
NSString *delsql;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2004 SKYRIX Software AG
|
Copyright (C) 2006-2016 Inverse inc.
|
||||||
Copyright (C) 2005-2014 Inverse inc.
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||||
|
|
||||||
This file is part of SOGo.
|
This file is part of SOGo.
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@
|
||||||
- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder;
|
- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder;
|
||||||
- (NSException *) moveToFolder: (SOGoGCSFolder *) newFolder;
|
- (NSException *) moveToFolder: (SOGoGCSFolder *) newFolder;
|
||||||
- (NSException *) delete;
|
- (NSException *) delete;
|
||||||
|
- (NSException *) touch;
|
||||||
|
|
||||||
/* DAV support */
|
/* 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
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||||
|
|
||||||
This file is part of SOGo.
|
This file is part of SOGo.
|
||||||
|
@ -260,16 +260,17 @@
|
||||||
NSException *ex;
|
NSException *ex;
|
||||||
|
|
||||||
// TODO: add precondition check? (or add DELETEAction?)
|
// 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."];
|
[self errorWithFormat: @"Did not find folder of content object."];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ex = [folder deleteContentWithName:[self nameInContainer]])) {
|
if ((ex = [folder deleteContentWithName:[self nameInContainer]]))
|
||||||
[self errorWithFormat:@"delete failed: %@", ex];
|
{
|
||||||
return ex;
|
[self errorWithFormat:@"delete failed: %@", ex];
|
||||||
}
|
return ex;
|
||||||
|
}
|
||||||
|
|
||||||
[container removeChildRecordWithName: nameInContainer];
|
[container removeChildRecordWithName: nameInContainer];
|
||||||
[[SOGoCache sharedCache] unregisterObjectWithName: nameInContainer
|
[[SOGoCache sharedCache] unregisterObjectWithName: nameInContainer
|
||||||
|
@ -278,24 +279,36 @@
|
||||||
return nil;
|
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 */
|
/* 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
|
- (id) PUTAction: (WOContext *) _ctx
|
||||||
{
|
{
|
||||||
WORequest *rq;
|
WORequest *rq;
|
||||||
|
|
Loading…
Reference in New Issue