From ca4f48fd059cad033d5edf54e46396d220510801 Mon Sep 17 00:00:00 2001 From: helge Date: Sun, 4 Jun 2006 14:11:28 +0000 Subject: [PATCH] work on REPORT git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1267 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/NGObjWeb/ChangeLog | 6 ++ .../NGObjWeb/SoObjects/SoActionInvocation.m | 4 +- sope-appserver/NGObjWeb/Version | 3 +- .../WebDAV/SoObjectWebDAVDispatcher.m | 61 +++++++++++++++++-- 4 files changed, 66 insertions(+), 8 deletions(-) diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 49f4bae6..438bac41 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,9 @@ +2006-06-04 Helge Hess + + * WebDAV/SoWebDAVDispatcher.m: added some basic REPORT support, allows + mapping of the top-level report XML element name to a SoMethod + (v4.5.234) + 2006-05-20 Marcus Mueller * DynamicElements/WOForm.api: added wosid parameter. There probably diff --git a/sope-appserver/NGObjWeb/SoObjects/SoActionInvocation.m b/sope-appserver/NGObjWeb/SoObjects/SoActionInvocation.m index 25ea8a74..01f01c38 100644 --- a/sope-appserver/NGObjWeb/SoObjects/SoActionInvocation.m +++ b/sope-appserver/NGObjWeb/SoObjects/SoActionInvocation.m @@ -119,7 +119,7 @@ static int debugOn = 0; qppath = [_spec valueForKey:key]; value = [qppath isNotNull] ? [soapEnvelope lookupQueryPath:qppath] : nil; - [args setObject:(value != nil ? value : [NSNull null]) forKey:key]; + [args setObject:(value != nil ? value : (id)[NSNull null]) forKey:key]; } return args; } @@ -130,6 +130,8 @@ static int debugOn = 0; { if ([_type isEqualToString:@"SOAP"]) return [self extractSOAPArgumentsFromContext:_ctx specification:_spec]; + + // TODO: would be cool to have that for REPORTs as well [self errorWithFormat: @"cannot extract parameters for request type: '%@'", _type]; diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 9ae0437d..65ce298d 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,7 +1,8 @@ # version file -SUBMINOR_VERSION:=233 +SUBMINOR_VERSION:=234 +# v4.5.234 requires libDOM v4.5.21 # v4.5.214 requires libNGExtensions v4.5.179 # v4.5.122 requires libNGExtensions v4.5.153 # v4.5.91 requires libNGExtensions v4.5.134 diff --git a/sope-appserver/NGObjWeb/WebDAV/SoObjectWebDAVDispatcher.m b/sope-appserver/NGObjWeb/WebDAV/SoObjectWebDAVDispatcher.m index 22d47d72..92b3dc9a 100644 --- a/sope-appserver/NGObjWeb/WebDAV/SoObjectWebDAVDispatcher.m +++ b/sope-appserver/NGObjWeb/WebDAV/SoObjectWebDAVDispatcher.m @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "common.h" @@ -104,7 +105,7 @@ static NSTimeZone *gmt = nil; ui = [NSDictionary dictionaryWithObjectsAndKeys: self, @"dispatcher", [NSNumber numberWithInt:_status], @"http-status", - nil]; + nil]; return [NSException exceptionWithName: [NSString stringWithFormat:@"HTTP%i", _status] reason:_reason @@ -1509,8 +1510,10 @@ static NSTimeZone *gmt = nil; /* DAV reports */ - (id)doREPORT:(WOContext *)_ctx { + id domDocument; WORequest *rq; - id domDocument; + NSString *mname; + id method, resultObject; rq = [_ctx request]; @@ -1528,12 +1531,58 @@ static NSTimeZone *gmt = nil; reason:@"Could not parse XML of WebDAV REPORT."]; } - /* process DOM */ + /* first try to lookup method with fully qualified name */ + + mname = [NSString stringWithFormat:@"{%@}%@", + [[domDocument documentElement] namespaceURI], + [[domDocument documentElement] localName]]; + method = [self->object lookupName:mname inContext:_ctx acquire:NO]; + + if (method == nil || [method isKindOfClass:[NSException class]]) { + /* then try to lookup by simplified name */ + id m2; + + m2 = [self->object lookupName:[[domDocument documentElement] localName] + inContext:_ctx acquire:NO]; + if (m2 == nil) + ; /* failed */ + else if ([m2 isKindOfClass:[NSException class]]) { + if (method == nil) + method = m2; /* use the second exceptions */ + } + else { + method = m2; + mname = [[domDocument documentElement] localName]; + } + } + + // TODO: what I would really like to have here is a pluggable dispatcher + // mechanism which translates the report payload into a customized + // method call. + + /* check for lookup errors */ + + if (method == nil || [method isKindOfClass:[NSException class]]) { + [self logWithFormat:@"did not find a method to server the REPORT"]; + return [NSException exceptionWithHTTPStatus:501 /* not implemented */ + reason:@"did not find the specified REPORT"]; + } + else if ([method isKindOfClass:[NSException class]]) { + [self logWithFormat:@"failed to lookup the REPORT: %@", method]; + return method; + } + else if (![method isCallable]) { + [self warnWithFormat: + @"object found for REPORT '%@' is not callable: %@", + mname, method]; + } + [self debugWithFormat:@"REPORT method: %@", method]; - [self logWithFormat:@"TODO: process REPORT: %@", domDocument]; + /* perform call */ - return [self httpException:405 /* method not allowed */ - reason:@"WebDAV reports not yet implemented."]; + resultObject = [method callOnObject:[_ctx clientObject] inContext:_ctx]; + if (debugOn) [self debugWithFormat:@"got REPORT result: %@", resultObject]; + return resultObject; } /* CalDAV */ -- 2.39.5