/*
- Copyright (C) 2004 SKYRIX Software AG
+ Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of OpenGroupware.org.
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#ifndef __Contacts_SOGoContactObject_H__
#define __Contacts_SOGoContactObject_H__
/*
- Copyright (C) 2004 SKYRIX Software AG
+ Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of OpenGroupware.org.
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "SOGoContactObject.h"
#include "common.h"
return r;
}
+/* specialized actions */
+
+- (NSException *)saveRecord:(id)_record {
+ return [self saveContentString:[_record description]];
+}
+
+- (NSException *)patchField:(NSString *)_fname value:(NSString *)_value
+ inContext:(id)_ctx
+{
+ NSMutableDictionary *md;
+
+ if ([_fname length] == 0) {
+ return [NSException exceptionWithHTTPStatus:400 /* Bad Request */
+ reason:@"missing form field name"];
+ }
+
+ if ((md = [[[self record] mutableCopy] autorelease]) == nil) {
+ return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+ reason:@"did not find contact record"];
+ }
+
+ [md setObject:[_value isNotNull] ? _value : @"" forKey:_fname];
+
+ return [self saveRecord:md];
+}
+
+- (id)patchOneFieldAction:(id)_ctx {
+ /*
+ expects: fieldname\nfieldvalue
+
+ TODO: should be extended to properly parse XML.
+ */
+ NSArray *fields;
+ NSException *error;
+
+ fields = [[[_ctx request] contentAsString]
+ componentsSeparatedByString:@"\n"];
+
+ if ([fields count] < 2) {
+ return [NSException exceptionWithHTTPStatus:400 /* Bad Request */
+ reason:@"missing form fields"];
+ }
+
+ error = [self patchField:[fields objectAtIndex:0]
+ value:[fields objectAtIndex:1]
+ inContext:_ctx];
+ if (error != nil)
+ return error;
+
+ return [_ctx response];
+}
+
/* message type */
- (NSString *)outlookMessageClass {