KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webdav > lib > methods > DeleteMethod


1 /*
2  * $Header: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/DeleteMethod.java,v 1.4 2004/08/02 15:45:48 unico Exp $
3  * $Revision: 1.4 $
4  * $Date: 2004/08/02 15:45:48 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.webdav.lib.methods;
25
26 import java.io.IOException JavaDoc;
27 import java.io.InputStream JavaDoc;
28 import org.apache.commons.httpclient.HttpConnection;
29 import org.apache.commons.httpclient.HttpException;
30 import org.apache.commons.httpclient.HttpState;
31 import org.apache.webdav.lib.util.WebdavStatus;
32
33 /**
34  * DELETE Method. The delete method can be sent to either a collection or
35  * non-collection resource. If a delete is sent to a collection, then all
36  * members of that collection are deleted.
37  *
38  * <p> Deletes can fail because of permission problems or if a resource is
39  * currently locked.
40  *
41  * <p> A typical request/response pair might look like this:
42  *
43  * <h3>Request</h3>
44  * <pre>
45  * DELETE /container/ HTTP/1.1
46  * Host: www.foo.bar
47  * </pre>
48  *
49  * <h3>Response</h3>
50  * <pre>
51  * HTTP/1.1 207 Multi-Status
52  * Content-Type: text/xml; charset="utf-8"
53  * Content-Length: xxxx
54  * &lt;?xml version="1.0" encoding="utf-8" ?&gt;
55  * &lt;d:multistatus xmlns:d="DAV:"&gt;
56  * &lt;d:response&gt;
57  * &lt;d:href&gt;http://www.foo.bar/container/resource3&lt;/d:href&gt;
58  * &lt;d:status&gt;HTTP/1.1 423 Locked&lt;/d:status&gt;
59  * &lt;/d:response&gt;
60  * &lt;/d:multistatus&gt;
61  * </pre>
62  *
63  * <p> In this example, the delete failed because one of the members was
64  * locked.
65  *
66  */

67 public class DeleteMethod
68     extends XMLResponseMethodBase {
69
70
71     // ----------------------------------------------------------- Constructors
72

73
74     /**
75      * Method constructor.
76      */

77     public DeleteMethod() {
78     }
79
80
81     /**
82      * Method constructor.
83      */

84     public DeleteMethod(String JavaDoc path) {
85         super(path);
86     }
87
88     /**
89      * Parse response.
90      *
91      * @param input Input stream
92      */

93     public void parseResponse(InputStream JavaDoc input, HttpState state, HttpConnection conn)
94         throws IOException JavaDoc, HttpException {
95         try
96         {
97             int code = getStatusLine().getStatusCode();
98             if (code == WebdavStatus.SC_CONFLICT ||
99                 code == WebdavStatus.SC_MULTI_STATUS ||
100                 code == WebdavStatus.SC_FORBIDDEN ) {
101                 parseXMLResponse(input);
102             }
103         }
104         catch (IOException JavaDoc e) {
105                 // FIX ME: provide a way to deliver non xml data
106
}
107     }
108
109     public String JavaDoc getName() {
110         return "DELETE";
111     }
112
113     // --------------------------------------------------- WebdavMethod Methods
114

115 }
116
Popular Tags