From: helge Date: Fri, 18 Feb 2005 17:40:11 +0000 (+0000) Subject: added a method to patch a field of the address record X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64759ef24e1d4cfc4ada0cede7cabe845806989e;p=scalable-opengroupware.org added a method to patch a field of the address record git-svn-id: http://svn.opengroupware.org/SOGo/trunk@585 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Contacts/ChangeLog b/SOGo/SoObjects/Contacts/ChangeLog index 3b86b0d9..d0bef1c2 100644 --- a/SOGo/SoObjects/Contacts/ChangeLog +++ b/SOGo/SoObjects/Contacts/ChangeLog @@ -1,3 +1,8 @@ +2005-02-18 Helge Hess + + * SOGoContactObject.m: added a REST method to patch a single field of + the contact (v0.9.7) + 2005-02-06 Helge Hess * SOGoContactObject.m, SOGoContactFolder.m: added proper diff --git a/SOGo/SoObjects/Contacts/SOGoContactObject.h b/SOGo/SoObjects/Contacts/SOGoContactObject.h index 2290d334..1b45c7be 100644 --- a/SOGo/SoObjects/Contacts/SOGoContactObject.h +++ b/SOGo/SoObjects/Contacts/SOGoContactObject.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_SOGoContactObject_H__ #define __Contacts_SOGoContactObject_H__ diff --git a/SOGo/SoObjects/Contacts/SOGoContactObject.m b/SOGo/SoObjects/Contacts/SOGoContactObject.m index cd658032..123e0e65 100644 --- a/SOGo/SoObjects/Contacts/SOGoContactObject.m +++ b/SOGo/SoObjects/Contacts/SOGoContactObject.m @@ -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$ #include "SOGoContactObject.h" #include "common.h" @@ -78,6 +77,58 @@ 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 { diff --git a/SOGo/SoObjects/Contacts/Version b/SOGo/SoObjects/Contacts/Version index e120731d..863cd7ff 100644 --- a/SOGo/SoObjects/Contacts/Version +++ b/SOGo/SoObjects/Contacts/Version @@ -1,5 +1,5 @@ # version file -SUBMINOR_VERSION:=6 +SUBMINOR_VERSION:=7 # v0.9.5 requires NGExtensions v4.5.136 diff --git a/SOGo/SoObjects/Contacts/product.plist b/SOGo/SoObjects/Contacts/product.plist index c4f8b45b..1f3e8b53 100644 --- a/SOGo/SoObjects/Contacts/product.plist +++ b/SOGo/SoObjects/Contacts/product.plist @@ -13,6 +13,9 @@ }; SOGoContactObject = { superclass = "SOGoContentObject"; + + methods = { + }; }; }; }