]> err.no Git - scalable-opengroupware.org/blobdiff - SOGo/UI/Scheduler/UIxAppointmentView.m
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@237 d1b88da0-ebda-0310-925b-ed51d...
[scalable-opengroupware.org] / SOGo / UI / Scheduler / UIxAppointmentView.m
index e04dd8668e387cceb59b7a92163fd9edc8d73dca..dc3819a28736d3609aa394c0eda0d081843ccba6 100644 (file)
@@ -3,6 +3,7 @@
 #include "UIxAppointmentView.h"
 #include <NGiCal/NGiCal.h>
 #include <SOGoLogic/SOGoAppointment.h>
+#include <Appointments/SOGoAppointmentObject.h>
 #include <SOGoUI/SOGoDateFormatter.h>
 #include "common.h"
 
   return self;
 }
 
+- (BOOL)isDeletableClientObject {
+  return [[self clientObject] respondsToSelector:@selector(delete)];
+}
+
+- (id)deleteAction {
+  NSException *ex;
+  
+  if ([self appointment] == nil) {
+    return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+                       reason:@"could not locate appointment"];
+  }
+
+  if (![self isDeletableClientObject]) {
+    /* return 400 == Bad Request */
+    return [NSException exceptionWithHTTPStatus:400
+                        reason:@"method cannot be invoked on "
+                               @"the specified object"];
+  }
+  
+  if ((ex = [[self clientObject] delete]) != nil) {
+    // TODO: improve error handling
+    [self debugWithFormat:@"failed to delete: %@", ex];
+    return ex;
+  }
+  
+#warning TODO: fix redirect
+  return [[[self clientObject] container] baseURLInContext:[self context]];
+}
+
 @end /* UIxAppointmentView */