]> err.no Git - scalable-opengroupware.org/commitdiff
added a method to patch a field of the address record
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 18 Feb 2005 17:40:11 +0000 (17:40 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 18 Feb 2005 17:40:11 +0000 (17:40 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@585 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Contacts/ChangeLog
SOGo/SoObjects/Contacts/SOGoContactObject.h
SOGo/SoObjects/Contacts/SOGoContactObject.m
SOGo/SoObjects/Contacts/Version
SOGo/SoObjects/Contacts/product.plist

index 3b86b0d9214c0b404b64c377167a37b4698e411a..d0bef1c21217b4d91bd4af4d127a826e8f892930 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-18  Helge Hess  <helge.hess@opengroupware.org>
+
+       * SOGoContactObject.m: added a REST method to patch a single field of
+         the contact (v0.9.7)
+
 2005-02-06  Helge Hess  <helge.hess@opengroupware.org>
 
        * SOGoContactObject.m, SOGoContactFolder.m: added proper
index 2290d3347ef566212c8f0cd812c1c87be05e5ae6..1b45c7be4cf90f088a829aeba6c76fbd54223778 100644 (file)
@@ -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__
index cd65803268726578dd82407c8c707c46ed9b9882..123e0e65938d688a44a53c46eb69f999f78773f7 100644 (file)
@@ -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"
   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 {
index e120731d5bf2514019f0f72c029fcb3658fe33a1..863cd7ff5691499a75031abaf1b5dc60201d8a75 100644 (file)
@@ -1,5 +1,5 @@
 # version file
 
-SUBMINOR_VERSION:=6
+SUBMINOR_VERSION:=7
 
 # v0.9.5 requires NGExtensions v4.5.136
index c4f8b45bac4541523e4bc7e465014dfbc67cd04f..1f3e8b53170d1aa1db22e5d5b5027a3873c009b6 100644 (file)
@@ -13,6 +13,9 @@
     };
     SOGoContactObject = {
       superclass    = "SOGoContentObject";
+
+      methods = {
+      };
     };
   };
 }