From: helge Date: Thu, 14 Jul 2005 09:05:03 +0000 (+0000) Subject: more work on etags and locations X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d88e680b4f1998e967eefe52f887c436c43f2682;p=scalable-opengroupware.org more work on etags and locations git-svn-id: http://svn.opengroupware.org/SOGo/trunk@743 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Appointments/ChangeLog b/SOGo/SoObjects/Appointments/ChangeLog index 0020203e..ef7e4c60 100644 --- a/SOGo/SoObjects/Appointments/ChangeLog +++ b/SOGo/SoObjects/Appointments/ChangeLog @@ -1,3 +1,8 @@ +2005-07-14 Helge Hess + + * SOGoAppointmentFolder.m: moved +globallyUniqueObjectId method to + SOGoFolder.m baseclass (v0.9.42) + 2005-07-13 Helge Hess * SOGoAppointmentFolder.m: added a method to determine the resource diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h index 27782d98..853ef0dc 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -46,8 +46,6 @@ NSMutableDictionary *uidToFilename; } -+ (NSString *)globallyUniqueObjectId; - /* selection */ - (NSArray *)calendarUIDs; diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m index b01b4a3f..3faab108 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -28,8 +28,6 @@ #include #include #include "common.h" -#include -#include #if APPLE_Foundation_LIBRARY || NeXT_Foundation_LIBRARY @interface NSDate(UsedPrivates) @@ -62,27 +60,6 @@ static NSTimeZone *MET = nil; MET = [[NSTimeZone timeZoneWithAbbreviation:@"MET"] retain]; } -+ (NSString *)globallyUniqueObjectId { - /* - 4C08AE1A-A808-11D8-AC5A-000393BBAFF6 - SOGo-Web-28273-18283-288182 - printf( "%x", *(int *) &f); - */ - static int pid = 0; - static int sequence = 0; - static float rndm = 0; - float f; - - if (pid == 0) { /* break if we fork ;-) */ - pid = getpid(); - rndm = random(); - } - sequence++; - f = [[NSDate date] timeIntervalSince1970]; - return [NSString stringWithFormat:@"%0X-%0X-%0X-%0X", - pid, *(int *)&f, sequence++, random]; -} - - (void)dealloc { [self->uidToFilename release]; [super dealloc]; diff --git a/SOGo/SoObjects/Appointments/Version b/SOGo/SoObjects/Appointments/Version index c492133d..02257ba2 100644 --- a/SOGo/SoObjects/Appointments/Version +++ b/SOGo/SoObjects/Appointments/Version @@ -1,7 +1,8 @@ # Version file -SUBMINOR_VERSION:=40 +SUBMINOR_VERSION:=42 +# v0.9.42 requires libSOGo v0.9.54 # v0.9.32 requires libGDLContentStore v4.5.26 # v0.9.28 requires libNGiCal v4.5.47 # v0.9.26 requires libSOGo v0.9.30 diff --git a/SOGo/SoObjects/Contacts/ChangeLog b/SOGo/SoObjects/Contacts/ChangeLog index 19211722..43d3b0c1 100644 --- a/SOGo/SoObjects/Contacts/ChangeLog +++ b/SOGo/SoObjects/Contacts/ChangeLog @@ -1,3 +1,8 @@ +2005-07-14 Helge Hess + + * SOGoContactFolder.m: use +globallyUniqueObjectId method from + SOGoFolder.m baseclass (v0.9.12) + 2005-07-13 Helge Hess * SOGoContactObject.m: hardened against vCard content (v0.9.11) diff --git a/SOGo/SoObjects/Contacts/SOGoContactFolder.h b/SOGo/SoObjects/Contacts/SOGoContactFolder.h index e68e7dab..4e4e3f66 100644 --- a/SOGo/SoObjects/Contacts/SOGoContactFolder.h +++ b/SOGo/SoObjects/Contacts/SOGoContactFolder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __Contacts_SOGoContactFolder_H__ #define __Contacts_SOGoContactFolder_H__ @@ -41,8 +40,6 @@ { } -+ (NSString *)globallyUniqueObjectId; - /* fetching */ - (NSArray *)fetchCoreInfos; diff --git a/SOGo/SoObjects/Contacts/SOGoContactFolder.m b/SOGo/SoObjects/Contacts/SOGoContactFolder.m index 608fcc86..6bd07b89 100644 --- a/SOGo/SoObjects/Contacts/SOGoContactFolder.m +++ b/SOGo/SoObjects/Contacts/SOGoContactFolder.m @@ -30,31 +30,6 @@ @implementation SOGoContactFolder -+ (NSString *)globallyUniqueObjectId { - /* - 4C08AE1A-A808-11D8-AC5A-000393BBAFF6 - SOGo-Web-28273-18283-288182 - printf( "%x", *(int *) &f); - */ - static int pid = 0; - static int sequence = 0; - static float rndm = 0; - float f; - - if (pid == 0) { /* break if we fork ;-) */ - pid = getpid(); - rndm = random(); - } - sequence++; - f = [[NSDate date] timeIntervalSince1970]; - return [NSString stringWithFormat:@"%0X-%0X-%0X-%0X", - pid, *(int *)&f, sequence++, random]; -} - -- (void)dealloc { - [super dealloc]; -} - /* name lookup */ - (BOOL)isValidContactName:(NSString *)_key { diff --git a/SOGo/SoObjects/Contacts/SOGoContactObject.m b/SOGo/SoObjects/Contacts/SOGoContactObject.m index 64ae6bd7..9092b2a2 100644 --- a/SOGo/SoObjects/Contacts/SOGoContactObject.m +++ b/SOGo/SoObjects/Contacts/SOGoContactObject.m @@ -67,7 +67,7 @@ - (id)valueForKey:(NSString *)_key { id value; - + if ((value = [[self record] valueForKey:_key]) != nil) return value; diff --git a/SOGo/SoObjects/Contacts/Version b/SOGo/SoObjects/Contacts/Version index f941fe0f..a234750e 100644 --- a/SOGo/SoObjects/Contacts/Version +++ b/SOGo/SoObjects/Contacts/Version @@ -1,6 +1,7 @@ # version file -SUBMINOR_VERSION:=11 +SUBMINOR_VERSION:=12 -# v0.9.9 requires libGDLContentStore v4.5.26 -# v0.9.5 requires libNGExtensions v4.5.136 +# v0.9.12 requires libSOGo v0.9.54 +# v0.9.9 requires libGDLContentStore v4.5.26 +# v0.9.5 requires libNGExtensions v4.5.136 diff --git a/SOGo/SoObjects/SOGo/ChangeLog b/SOGo/SoObjects/SOGo/ChangeLog index 25d2d2b5..7d9c6413 100644 --- a/SOGo/SoObjects/SOGo/ChangeLog +++ b/SOGo/SoObjects/SOGo/ChangeLog @@ -1,5 +1,13 @@ 2005-07-14 Helge Hess + * v0.9.54 + + * SOGoContentObject.m: added support for special 'new' key (server will + assign a name and add the new location in a special response header) + + * SOGoFolder.m: added +globallyUniqueObjectId (previously the method + was duplicated in each subclass) + * SOGoContentObject.m: added transactionally save etag-checks in PUT (use the etag value as the baseVersion in the content store) (v0.9.53) diff --git a/SOGo/SoObjects/SOGo/SOGoAppointment.h b/SOGo/SoObjects/SOGo/SOGoAppointment.h index dfdd731f..278f6e62 100644 --- a/SOGo/SoObjects/SOGo/SOGoAppointment.h +++ b/SOGo/SoObjects/SOGo/SOGoAppointment.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __SOGoAppointment_H_ #define __SOGoAppointment_H_ diff --git a/SOGo/SoObjects/SOGo/SOGoContentObject.m b/SOGo/SoObjects/SOGo/SOGoContentObject.m index a520050c..5316413e 100644 --- a/SOGo/SoObjects/SOGo/SOGoContentObject.m +++ b/SOGo/SoObjects/SOGo/SOGoContentObject.m @@ -20,6 +20,7 @@ */ #include "SOGoContentObject.h" +#include "SOGoFolder.h" #include #include "common.h" #include @@ -161,13 +162,37 @@ static BOOL kontactGroupDAV = YES; WORequest *rq; NSException *error; unsigned int baseVersion; - id etag; + id etag, tmp; + BOOL needsLocation; if ((error = [self matchesRequestConditionInContext:_ctx]) != nil) return error; 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 container] class] globallyUniqueObjectId]; + needsLocation = YES; + + [self debugWithFormat: + @"reassigned a new location for special new-location: %@", tmp]; + + /* kinda dangerous */ + ASSIGNCOPY(self->nameInContainer, tmp); + ASSIGN(self->ocsPath, nil); + } + /* determine base version from etag in if-match header */ /* Note: The -matchesRequestConditionInContext: already checks whether the @@ -176,10 +201,11 @@ static BOOL kontactGroupDAV = YES; commit. (between the check and the update a change could have been done) */ - etag = [rq headerForKey:@"if-match"]; - etag = [self parseETagList:etag]; - if ([etag count] > 0) { - if ([etag count] > 1) { + 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 @@ -187,10 +213,10 @@ static BOOL kontactGroupDAV = YES; */ [self warnWithFormat: @"Got multiple if-match etags from client, only attempting to " - @"save with the first: %@", etag]; + @"save with the first: %@", tmp]; } - etag = [etag objectAtIndex:0]; + etag = [tmp objectAtIndex:0]; } baseVersion = ([etag length] > 0) ? [etag unsignedIntValue] @@ -202,11 +228,19 @@ static BOOL kontactGroupDAV = YES; baseVersion:baseVersion]) != nil) return error; - // TODO: this should be automatic if we return nil? + /* setup response */ + + // TODO: this should be automatic in the SoDispatcher if we return nil? [[_ctx response] setStatus:201 /* Created */]; if ((etag = [self davEntityTag]) != nil) [[_ctx response] setHeader:etag forKey:@"etag"]; + + if (needsLocation) { + [[_ctx response] setHeader:[self baseURLInContext:_ctx] + forKey:@"location"]; + } + return [_ctx response]; } diff --git a/SOGo/SoObjects/SOGo/SOGoFolder.h b/SOGo/SoObjects/SOGo/SOGoFolder.h index f48036e9..f64d8e11 100644 --- a/SOGo/SoObjects/SOGo/SOGoFolder.h +++ b/SOGo/SoObjects/SOGo/SOGoFolder.h @@ -40,6 +40,8 @@ GCSFolder *ocsFolder; } ++ (NSString *)globallyUniqueObjectId; + /* accessors */ - (void)setOCSPath:(NSString *)_Path; diff --git a/SOGo/SoObjects/SOGo/SOGoFolder.m b/SOGo/SoObjects/SOGo/SOGoFolder.m index c4a11c08..ee96bf3b 100644 --- a/SOGo/SoObjects/SOGo/SOGoFolder.m +++ b/SOGo/SoObjects/SOGo/SOGoFolder.m @@ -23,6 +23,8 @@ #include "common.h" #include #include +#include +#include @implementation SOGoFolder @@ -35,6 +37,27 @@ NSStringFromClass([self superclass]), [super version]); } ++ (NSString *)globallyUniqueObjectId { + /* + 4C08AE1A-A808-11D8-AC5A-000393BBAFF6 + SOGo-Web-28273-18283-288182 + printf( "%x", *(int *) &f); + */ + static int pid = 0; + static int sequence = 0; + static float rndm = 0; + float f; + + if (pid == 0) { /* break if we fork ;-) */ + pid = getpid(); + rndm = random(); + } + sequence++; + f = [[NSDate date] timeIntervalSince1970]; + return [NSString stringWithFormat:@"%0X-%0X-%0X-%0X", + pid, *(int *)&f, sequence++, random]; +} + - (void)dealloc { [self->ocsFolder release]; [self->ocsPath release]; diff --git a/SOGo/SoObjects/SOGo/Version b/SOGo/SoObjects/SOGo/Version index 53f7a360..6b463245 100644 --- a/SOGo/SoObjects/SOGo/Version +++ b/SOGo/SoObjects/SOGo/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=53 +SUBMINOR_VERSION:=54 # v0.9.50 requires libGDLContentStore v4.5.30 # v0.9.34 requires libGDLContentStore v4.5.26