01: /*
02: * Copyright (c) 2000, Jacob Smullyan.
03: *
04: * This is part of SkunkDAV, a WebDAV client. See http://skunkdav.sourceforge.net/
05: * for the latest version.
06: *
07: * SkunkDAV is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License as published
09: * by the Free Software Foundation; either version 2, or (at your option)
10: * any later version.
11: *
12: * SkunkDAV is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with SkunkDAV; see the file COPYING. If not, write to the Free
19: * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20: * 02111-1307, USA.
21: */
22:
23: package org.skunk.dav.client.method;
24:
25: import org.skunk.dav.client.AbstractDAVMethod;
26: import org.skunk.dav.client.DAVConstants;
27: import org.skunk.dav.client.DAVMethodName;
28: import java.util.Map;
29: import java.util.StringTokenizer;
30:
31: public class OptionsMethod extends AbstractDAVMethod {
32: private String[] options;
33:
34: public OptionsMethod(String url) {
35: super (url);
36: }
37:
38: public DAVMethodName getRequestMethodName() {
39: return DAVMethodName.OPTIONS;
40: }
41:
42: public void processResponseHeaders() {
43: //if status is ok, get relevant options
44: int s = getStatus();
45: if (s >= 200 && s < 300) {
46: Map headers = getResponseHeaders();
47: if (headers.containsKey(DAVConstants.ALLOW_HEADER)) {
48: Object allowed = headers.get(DAVConstants.ALLOW_HEADER);
49: if (allowed != null)
50: options = extractOptions(allowed.toString());
51: }
52: }
53: if (options == null)
54: options = new String[] {};
55: }
56:
57: public String[] getOptions() {
58: return options;
59: }
60:
61: private String[] extractOptions(String optionStr) {
62: StringTokenizer st = new StringTokenizer(optionStr, ", ");
63: String[] ops = new String[st.countTokens()];
64: for (int i = 0; i < ops.length; i++)
65: ops[i] = st.nextToken();
66: return ops;
67: }
68: }
69:
70: /* $Log: OptionsMethod.java,v $
71: /* Revision 1.7 2001/07/15 18:16:37 smulloni
72: /* fixed some copyright notices.
73: /*
74: /* Revision 1.6 2000/12/03 23:53:26 smulloni
75: /* added license and copyright preamble to java files.
76: /*
77: /* Revision 1.5 2000/11/09 23:35:08 smullyan
78: /* log added to every Java file, with the help of python. Lock stealing
79: /* implemented, and treatment of locks made more robust.
80: /* */
|