2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "SOGoContentObject.h"
24 #include <OGoContentStore/OCSFolder.h>
26 @implementation SOGoContentObject
29 [self->content release];
30 [self->ocsPath release];
37 [self->content release]; self->content = nil;
47 - (void)setOCSPath:(NSString *)_path {
48 if ([self->ocsPath isEqualToString:_path])
52 [self warnWithFormat:@"OCS path is already set! '%@'", _path];
54 ASSIGNCOPY(self->ocsPath, _path);
57 - (NSString *)ocsPath {
58 if (self->ocsPath == nil) {
61 if ((p = [self ocsPathOfContainer]) != nil) {
62 if (![p hasSuffix:@"/"]) p = [p stringByAppendingString:@"/"];
63 p = [p stringByAppendingString:[self nameInContainer]];
64 self->ocsPath = [p copy];
70 - (NSString *)ocsPathOfContainer {
71 if (![[self container] respondsToSelector:@selector(ocsPath)])
74 return [[self container] ocsPath];
77 - (OCSFolder *)ocsFolder {
78 if (![[self container] respondsToSelector:@selector(ocsFolder)])
81 return [[self container] ocsFolder];
86 - (NSString *)contentAsString {
89 if (self->content != nil)
92 if ((folder = [self ocsFolder]) == nil) {
93 [self logWithFormat:@"did not find folder of appointment."];
97 self->content = [[folder fetchContentWithName:[self nameInContainer]] copy];
101 - (NSException *)saveContentString:(NSString *)_str {
102 /* Note: "iCal multifolder saves" are implemented in the apt subclass! */
106 if ((folder = [self ocsFolder]) == nil) {
107 [self logWithFormat:@"did not find folder of appointment."];
110 if ((ex = [folder writeContent:_str toName:[self nameInContainer]])) {
111 [self logWithFormat:@"write failed: %@", ex];
117 - (NSException *)delete {
118 /* Note: "iCal multifolder saves" are implemented in the apt subclass! */
122 if ((folder = [self ocsFolder]) == nil) {
123 [self logWithFormat:@"did not find folder of appointment."];
127 if ((ex = [folder deleteContentWithName:[self nameInContainer]])) {
128 [self logWithFormat:@"delete failed: %@", ex];
136 - (id)PUTAction:(WOContext *)_ctx {
141 if ((error = [self saveContentString:[rq contentAsString]]) != nil)
144 // TODO: this should be automatic if we return nil?
145 [[_ctx response] setStatus:201 /* Created */];
146 return [_ctx response];
151 - (BOOL)davIsCollection {
152 return [self isFolderish];
157 - (NSString *)outlookMessageClass {
163 - (void)appendAttributesToDescription:(NSMutableString *)_ms {
164 [super appendAttributesToDescription:_ms];
166 [_ms appendFormat:@" ocs=%@", [self ocsPath]];
169 @end /* SOGoContentObject */