Monotone-Parent: 1bf1f8309760e932ba1283aea44e9ce3f1137047

Monotone-Revision: f689524b3f038037e97064846ef2c5bb5328aef6

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2009-08-19T12:48:35
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2009-08-19 12:48:35 +00:00
parent d00a20e9f5
commit 3a0abd7197
3 changed files with 39 additions and 75 deletions
+8
View File
@@ -1,3 +1,11 @@
2009-08-19 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/SOGoObject.m (-parseETagList:): greatly
simplified method by using the "trimmedComponents" utility method.
* SoObjects/SOGo/SOGoContentObject.m (-PUTAction:): removed "new"
hack. Sanitized var names.
2009-08-18 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/SOGoGCSFolder.m
+22 -50
View File
@@ -273,8 +273,8 @@
WORequest *rq;
NSException *error;
unsigned int baseVersion;
id etag, tmp;
BOOL needsLocation;
NSArray *etags;
NSString *etag;
WOResponse *response;
error = [self matchesRequestConditionInContext: _ctx];
@@ -284,30 +284,6 @@
{
rq = [_ctx request];
/* check whether its a request to the 'special' 'new' location */
/*
Note: this is kinda hack. The OGo ZideStore detects writes to 'new' as
object creations and will assign a server side identifier. Most
current GroupDAV clients rely on this behaviour, so we reproduce it
here.
A correct client would loop until it has a name which doesn't not
yet exist (by using if-none-match).
*/
needsLocation = NO;
tmp = [[self nameInContainer] stringByDeletingPathExtension];
if ([tmp isEqualToString: @"new"])
{
tmp = [self globallyUniqueObjectId];
needsLocation = YES;
[self debugWithFormat:
@"reassigned a new location for special new-location: %@", tmp];
/* kinda dangerous */
ASSIGNCOPY (nameInContainer, tmp);
}
/* determine base version from etag in if-match header */
/*
Note: The -matchesRequestConditionInContext: already checks whether the
@@ -316,25 +292,26 @@
commit.
(between the check and the update a change could have been done)
*/
tmp = [rq headerForKey: @"if-match"];
tmp = [self parseETagList: tmp];
etag = nil;
if ([tmp count] > 0) {
if ([tmp count] > 1) {
/*
Note: we would have to attempt a save for _each_ of the etags being
passed in! In practice most WebDAV clients submit exactly one
etag.
*/
[self warnWithFormat:
@"Got multiple if-match etags from client, only attempting to "
@"save with the first: %@", tmp];
}
etag = [tmp objectAtIndex: 0];
}
etags = [self parseETagList: [rq headerForKey: @"if-match"]];
if ([etags count] > 0)
{
if ([etags count] > 1)
{
/*
Note: we would have to attempt a save for _each_ of the etags
being passed in! In practice most WebDAV clients submit
exactly one etag.
*/
[self warnWithFormat:
@"Got multiple if-match etags from client, only"
@" attempting to save with the first: %@", etags];
}
etag = [etags objectAtIndex: 0];
}
else
etag = nil;
baseVersion = (isNew ? 0 : version);
/* attempt a save */
error = [self saveContentString: [rq contentAsString]
@@ -357,12 +334,7 @@
etag = [self davEntityTag];
if (etag)
{
[response setHeader: etag forKey: @"etag"];
if (needsLocation)
[response setHeader: [self baseURLInContext:_ctx]
forKey: @"location"];
}
[response setHeader: etag forKey: @"etag"];
}
}
+9 -25
View File
@@ -901,32 +901,16 @@ SEL SOGoSelectorForPropertySetter (NSString *property)
}
/* etag support */
- (NSArray *) parseETagList: (NSString *) list
{
NSArray *etags;
- (NSArray *)parseETagList:(NSString *)_c {
NSMutableArray *ma;
NSArray *etags;
unsigned i, count;
if ([_c length] == 0)
return nil;
if ([_c isEqualToString:@"*"])
return nil;
etags = [_c componentsSeparatedByString:@","];
count = [etags count];
ma = [NSMutableArray arrayWithCapacity:count];
for (i = 0; i < count; i++) {
NSString *etag;
etag = [[etags objectAtIndex:i] stringByTrimmingSpaces];
#if 0 /* this is non-sense, right? */
if ([etag hasPrefix:@"\""] && [etag hasSuffix:@"\""])
etag = [etag substringWithRange:NSMakeRange(1, [etag length] - 2)];
#endif
if (etag != nil) [ma addObject:etag];
}
return ma;
if (![list length] || [list isEqualToString:@"*"])
etags = nil;
else
etags = [[list componentsSeparatedByString: @","] trimmedComponents];
return etags;
}
- (NSException *)checkIfMatchCondition:(NSString *)_c inContext:(id)_ctx {