2 Copyright (C) 2004 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
23 #include "DSoObject.h"
25 #include <NGObjWeb/SoHTTPAuthenticator.h>
26 #include <GDLAccess/GDLAccess.h>
28 @implementation DSoObject
36 - (NSString *)defaultDatabase {
37 /* template1 is supposed to exist always (#postgresql channel ;-) */
41 - (EOAdaptor *)adaptorForHostName:(NSString *)_hname port:(int)_port
42 databaseName:(NSString *)_dbname inContext:(WOContext *)_ctx
45 NSDictionary *condict;
46 NSString *login = nil, *pwd = nil, *auth;
49 if ((adaptor = [EOAdaptor adaptorWithName:@"PostgreSQL72"]) == nil) {
50 [self logWithFormat:@"missing PostgreSQL72 adaptor"];
54 /* extract login/password */
56 if ((auth = [[_ctx request] headerForKey:@"authorization"]) == nil) {
57 [self logWithFormat:@"missing 'authorization' .."];
60 creds = [SoHTTPAuthenticator parseCredentials:auth];
61 if ([creds count] < 2) {
62 [self logWithFormat:@"cannot use credentials: %@", creds];
65 login = [creds objectAtIndex:0];
66 pwd = [creds objectAtIndex:1];
70 _dbname = [_dbname isNotNull] ? _dbname : [self defaultDatabase];
73 condict = [[NSDictionary alloc] initWithObjectsAndKeys:
77 _dbname, @"databaseName",
79 [adaptor setConnectionDictionary:condict];
85 - (id)GETAction:(id)_ctx {
86 /* per default, return nothing ... */
87 WOResponse *r = [(WOContext *)_ctx response];
90 if ((defName = [self defaultMethodNameInContext:_ctx])) {
91 [r setStatus:302 /* moved */];
92 [r setHeader:[[self baseURL] stringByAppendingPathComponent:defName]
97 [r setStatus:200 /* Ok */];
98 [self logWithFormat:@"GET on folder, just saying OK"];
105 - (id)valueForUndefinedKey:(NSString *)_key {
106 [self debugWithFormat:@"queried undefined key: '%@'", _key];
110 - (BOOL)isCollection {