KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/CheckinMethod.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 /**
35  * The CHECKIN method can be applied to a checked-out version-controlled
36  * resource to produce a new version whose content and dead properties are
37  * copied from the checked-out resource.
38  *
39  * <p> This implementation of a CHECKIN client method does support a
40  * a request body.</p>
41  *
42  * <p> If a CHECKIN request fails, the server state preceding the request
43  * MUST be restored. The request body MUST be a DAV:checkin XML element with
44  * at most one DAV:keep-checked-out or DAV:fork-ok.</p>
45  *
46  *
47  * <h3>Example Request</h3>
48  * <pre>
49  * CHECKIN /foo.html HTTP/1.1
50  * Host: www.server.org
51  * Content-type: text/xml; charset="utf-8"
52  * Content-Length: xx
53  * </pre>
54  *
55  * <h3>Example Response</h3>
56  * <pre>
57  * HTTP/1.1 201 Created
58  * Location: http://server.org/history/1/1.1
59  * Content-type: text/xml; charset="utf-8"
60  * </pre>
61  *
62  */

63 public class CheckinMethod
64     extends XMLResponseMethodBase {
65
66
67     // -------------------------------------------------------------- Constants
68

69
70
71     // ----------------------------------------------------- Instance Variables
72

73
74     // ----------------------------------------------------------- Constructors
75

76
77     /**
78      * Method constructor.
79      */

80     public CheckinMethod() {
81     }
82
83
84     /**
85      * Method constructor.
86      */

87     public CheckinMethod(String JavaDoc path) {
88         super(path);
89     }
90
91
92
93
94
95     // ------------------------------------------------------------- Properties
96

97     // --------------------------------------------------- WebdavMethod Methods
98

99     /**
100      * Parse response.
101      *
102      * @param input Input stream
103      */

104     public void parseResponse(InputStream JavaDoc input, HttpState state, HttpConnection conn)
105         throws IOException JavaDoc, HttpException {
106         try
107         {
108             if (getStatusLine().getStatusCode() == WebdavStatus.SC_CONFLICT ||
109                 getStatusLine().getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
110                 parseXMLResponse(input);
111             }
112         }
113         catch (IOException JavaDoc e) {
114                 // FIX ME: provide a way to deliver non xml data
115
}
116     }
117
118     public String JavaDoc getName() {
119         return "CHECKIN";
120     }
121 }
122
Popular Tags