Monotone-Parent: 1c96c7fdd2f2dab8f4bc3173deb36b069ade3bf1

Monotone-Revision: d5160c781f03a73e64550870c92c96c8310b439a

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2009-08-05T15:36:09
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2009-08-05 15:36:09 +00:00
parent 5b3592c974
commit ecfa434da2
3 changed files with 35 additions and 20 deletions

View File

@@ -1,5 +1,9 @@
2009-08-05 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/SOGoGCSFolder.m (-davSyncCollection): enhanced to
return a DAV error with the "valid-sync-token" condition tag when
a token is provided while the collection is empty.
* SoObjects/SOGo/WOResponse+SOGo.m: new class module.
(-appendDAVError:): utility method that adds and formats the XML
body of a DAV error, with the error condition passed as argument.

View File

@@ -69,6 +69,7 @@
#import "SOGoUser.h"
#import "SOGoWebDAVAclManager.h"
#import "WORequest+SOGo.h"
#import "WOResponse+SOGo.h"
#import "SOGoGCSFolder.h"
@@ -896,7 +897,7 @@ static NSArray *childRecordFields = nil;
}
- (NSArray *) _fetchSyncTokenFields: (NSDictionary *) properties
matchingSyncToken: (int) syncToken
matchingSyncToken: (NSString *) syncToken
{
/* TODO:
- validation:
@@ -908,6 +909,7 @@ static NSArray *childRecordFields = nil;
EOQualifier *qualifier;
NSEnumerator *addFields;
NSString *currentField, *filter;
int syncTokenInt;
fields = [NSMutableArray arrayWithObjects: @"c_name", @"c_component",
@"c_creationdate", @"c_lastmodified", nil];
@@ -916,16 +918,17 @@ static NSArray *childRecordFields = nil;
if ([currentField length])
[fields addObjectUniquely: currentField];
if (syncToken)
if ([syncToken length])
{
syncTokenInt = [syncToken intValue];
qualifier = [EOQualifier qualifierWithQualifierFormat:
@"c_lastmodified > %d", syncToken];
@"c_lastmodified > %d", syncTokenInt];
mRecords = [NSMutableArray arrayWithArray: [self _fetchFields: fields
withQualifier: qualifier
ignoreDeleted: YES]];
withQualifier: qualifier
ignoreDeleted: YES]];
qualifier = [EOQualifier qualifierWithQualifierFormat:
@"c_lastmodified > %d and c_deleted == 1",
syncToken];
syncTokenInt];
fields = [NSMutableArray arrayWithObjects: @"c_name", @"c_deleted", nil];
[mRecords addObjectsFromArray: [self _fetchFields: fields
withQualifier: qualifier
@@ -1090,10 +1093,10 @@ static NSArray *childRecordFields = nil;
if (newToken < currentLM)
newToken = currentLM;
[syncResponses addObject: [self _syncResponseWithProperties: properties
andMethodSelectors: selectors
fromRecord: record
withToken: syncToken
andBaseURL: baseURL]];
andMethodSelectors: selectors
fromRecord: record
withToken: syncToken
andBaseURL: baseURL]];
}
NSZoneFree (NULL, selectors);
@@ -1122,15 +1125,12 @@ static NSArray *childRecordFields = nil;
NSString *syncToken;
NSDictionary *properties;
NSArray *records;
int syncTokenInt;
r = [context response];
[r setStatus: 207];
[r setContentEncoding: NSUTF8StringEncoding];
[r setHeader: @"text/xml; charset=\"utf-8\"" forKey: @"content-type"];
[r setHeader: @"no-cache" forKey: @"pragma"];
[r setHeader: @"no-cache" forKey: @"cache-control"];
[r appendContentString:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"];
document = [[context request] contentAsDOMDocument];
documentElement = (DOMElement *) [document documentElement];
@@ -1139,15 +1139,21 @@ static NSArray *childRecordFields = nil;
propElement = [documentElement firstElementWithTag: @"prop"
inNamespace: XMLNS_WEBDAV];
syncTokenInt = [syncToken intValue];
properties = [self parseDAVRequestedProperties: propElement];
records = [self _fetchSyncTokenFields: properties
matchingSyncToken: syncTokenInt];
[self _appendComponentProperties: [properties allKeys]
fromRecords: records
matchingSyncToken: syncTokenInt
toResponse: r];
matchingSyncToken: syncToken];
if (![syncToken length] || [records count])
{
[r setStatus: 207];
[r appendContentString: @"<?xml version=\"1.0\""
@" encoding=\"utf-8\"?>\r\n"];
[self _appendComponentProperties: [properties allKeys]
fromRecords: records
matchingSyncToken: [syncToken intValue]
toResponse: r];
}
else
[r appendDAVError: davElement (@"valid-sync-token", XMLNS_WEBDAV)];
return r;
}

View File

@@ -7,6 +7,11 @@ setup
2) edit testconfig.py to suit your environment
3) run the test scripts
runnable scripts
----------------
webdav-sync.py
other
-----