You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ju...@apache.org on 2002/12/16 16:17:30 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/properties AclProperty.java
juergen 2002/12/16 07:17:30
Modified: src/webdav/client/src/org/apache/webdav/lib/methods
XMLResponseMethodBase.java
VersionControlMethod.java UpdateMethod.java
UnlockMethod.java UncheckoutMethod.java
SearchMethod.java ReportMethod.java
PropPatchMethod.java PropFindMethod.java
OptionsMethod.java MoveMethod.java
MkWorkspaceMethod.java MkcolMethod.java
LockMethod.java LabelMethod.java GetMethod.java
DeleteMethod.java CopyMethod.java
CheckoutMethod.java CheckinMethod.java
AclMethod.java
src/webdav/client/src/org/apache/webdav/lib WebdavState.java
WebdavSession.java WebdavResource.java
src/webdav/client/src/org/apache/webdav/ant/taskdefs
Put.java Get.java
src/webdav/client/src/org/apache/webdav/cmd Client.java
src/webdav/client/src/org/apache/webdav/lib/properties
AclProperty.java
Added: src/webdav/client/src/org/apache/webdav/lib/methods
HttpRequestBodyMethodBase.java
Log:
Commit of the modification necessary for the new httpClient. Thanks to Eric Johnson.
Revision Changes Path
1.34 +110 -39 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/XMLResponseMethodBase.java
Index: XMLResponseMethodBase.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/XMLResponseMethodBase.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- XMLResponseMethodBase.java 14 Aug 2002 15:22:24 -0000 1.33
+++ XMLResponseMethodBase.java 16 Dec 2002 15:17:28 -0000 1.34
@@ -64,9 +64,11 @@
package org.apache.webdav.lib.methods;
+import java.io.FilterInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
import java.text.DateFormat;
import java.text.ParseException;
@@ -83,9 +85,7 @@
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.commons.httpclient.State;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.*;
//import org.apache.commons.httpclient.log.Log;
//import org.apache.commons.httpclient.log.LogSource;
@@ -114,8 +114,8 @@
* @author Remy Maucherat
* @author Dirk Verbeeck
*/
-public class XMLResponseMethodBase
- extends HttpMethodBase {
+public abstract class XMLResponseMethodBase
+ extends HttpRequestBodyMethodBase {
//static private final Log log = LogSource.getInstance(XMLResponseMethodBase.class.getName());
@@ -183,9 +183,9 @@
}
- protected State getState() {
+ /*protected HttpState getState() {
return state;
- }
+ }*/
// --------------------------------------------------- WebdavMethod Methods
@@ -212,17 +212,88 @@
responseHashtable = null;
}
+ protected void readResponseBody(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
+
+ super.readResponseBody(state, conn);
+ InputStream inStream = getResponseBodyAsStream();
+ parseResponse(inStream, state, conn);
+
+ inStream.close();
+ }
+
+ /**
+ * Return the length (in bytes) of my request body, suitable for use in a
+ * <tt>Content-Length</tt> header.
+ *
+ * <p>
+ * Return <tt>-1</tt> when the content-length is unknown.
+ * </p>
+ *
+ * <p>
+ * This implementation returns <tt>0</tt>, indicating that the request has
+ * no body.
+ * </p>
+ *
+ * @return <tt>0</tt>, indicating that the request has no body.
+ */
+ protected int getRequestContentLength() {
+ if (!isRequestContentAlreadySet()) {
+ String contents = generateRequestBody();
+ // be nice - allow overriding functions to return null or empty
+ // strings for no content.
+ if (contents == null)
+ contents = "";
+
+ setRequestBody(contents);
+ }
+
+ return super.getRequestContentLength();
+ }
+
+ /**
+ * DAV requests that contain a body must override this function to
+ * generate that body.
+ *
+ * <p>The default behavior simply returns an empty body.</p>
+ */
+ protected String generateRequestBody() {
+ return "";
+ }
+
+ /**
+ * Write the request body to the given {@link HttpConnection}
+ *
+ * <p>
+ * This implementation writes any computed body and returns <tt>true</tt>.
+ * </p>
+ *
+ * @param state the client state
+ * @param conn the connection to write to
+ *
+ * @return <tt>true</tt>
+ * @throws IOException when i/o errors occur reading the response
+ * @throws HttpException when a protocol error occurs or state is invalid
+ */
+ protected boolean writeRequestBody(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
+
+ if (getRequestContentLength() > 0) {
+ return super.writeRequestBody(state, conn);
+ }
+ return true;
+ }
/**
* Parse response.
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_MULTI_STATUS ) {
+ if (getStatusLine().getStatusCode() == WebdavStatus.SC_MULTI_STATUS ) {
parseXMLResponse(input);
}
}
@@ -259,10 +330,10 @@
// init the response table to display the responses during debugging
- if (debug > 10) {
+ /*if (debug > 10) {
//if (log.isDebugEnabled()) {
initResponseHashtable();
- }
+ }*/
}
@@ -280,7 +351,7 @@
if (responseHashtable == null) {
responseHashtable = new Hashtable();
- int status = getStatusCode();
+ int status = getStatusLine().getStatusCode();
if (status == WebdavStatus.SC_MULTI_STATUS) {
@@ -300,8 +371,8 @@
new ResponseWithinMultistatus(child);
responseHashtable.put(response.getHref(),
response);
- if (debug>10)
- System.out.println(response);
+ /*if (debug>10)
+ System.out.println(response); */
//log.debug(response);
}
} catch (ClassCastException e) {
@@ -312,8 +383,8 @@
Response response = new SingleResponse(responseDocument,
getPath(), status);
responseHashtable.put(response.getHref(), response);
- if (debug>10)
- System.out.println(response);
+ /*if (debug>10)
+ System.out.println(response); */
//log.debug(response);
}
}
@@ -450,7 +521,7 @@
return DOMUtils.parseStatus(DOMUtils.getTextValue(status));
}
}
-
+
// <multistatus xmlns=\DAV:\>
// <response>
// <href>/slide/files/</href>
@@ -469,10 +540,11 @@
public String getHref() {
Element href = getFirstElement("DAV:", "href");
if (href != null) {
- return getState().URLDecode(DOMUtils.getTextValue(href));
+ return URIUtil.decode(DOMUtils.getTextValue(href));
} else {
return "";
}
+
}
protected Element getFirstElement(String namespace, String name) {
@@ -480,7 +552,6 @@
}
}
-
class SingleResponse extends Response {
private int statusCode = -1;
@@ -500,29 +571,29 @@
return this.href;
}
}
-
+
class OptionsResponse extends SingleResponse{
-
+
OptionsResponse(Document document, String href, int statusCode) {
super(document, href, statusCode);
-
+
}
-
+
public Enumeration getWorkspaces(){
-
-
+
+
Node root = responseDocument.cloneNode(true).getFirstChild();
//System.out.println("Rootnode ws: "+ root.getNodeName());
-
+
String sPrefix = root.getPrefix();
Vector result = new Vector();
-
+
Node child = root.getFirstChild();
while (child!=null && !child.getNodeName().equalsIgnoreCase(sPrefix+":workspace-collection-set")){
child = child.getNextSibling();
}
-
+
if (child!=null && child.getNodeName().equalsIgnoreCase(sPrefix+":workspace-collection-set")){
child = child.getFirstChild();
while (child!=null){
@@ -530,24 +601,24 @@
child = child.getNextSibling();
}
}
-
+
return result.elements();
}
-
+
public Enumeration getHistories(){
Node root = responseDocument.cloneNode(true).getFirstChild();
//System.out.println("Rootnode vh : " + root.getNodeName());
-
+
String sPrefix = root.getPrefix();
Vector result = new Vector();
-
+
//System.out.println("Prefix : " + sPrefix);
-
+
Node child = root.getFirstChild();
while (child!=null && !child.getNodeName().equalsIgnoreCase(sPrefix+":version-history-collection-set")){
child = child.getNextSibling();
}
-
+
if (child!=null && child.getNodeName().equalsIgnoreCase(sPrefix+":version-history-collection-set")){
child = child.getFirstChild();
while (child!=null){
@@ -555,10 +626,10 @@
child = child.getNextSibling();
}
}
-
+
return result.elements();
}
-
+
}
protected void setDocument(Document doc){
responseDocument = doc;
1.8 +24 -22 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/VersionControlMethod.java
Index: VersionControlMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/VersionControlMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- VersionControlMethod.java 14 Aug 2002 15:22:24 -0000 1.7
+++ VersionControlMethod.java 16 Dec 2002 15:17:28 -0000 1.8
@@ -66,8 +66,9 @@
import java.io.InputStream;
import java.io.IOException;
-import org.apache.commons.httpclient.State;
import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpConnection;
import org.apache.util.XMLPrinter;
@@ -98,7 +99,6 @@
* Method constructor.
*/
public VersionControlMethod() {
- name = "VERSION-CONTROL";
sComment ="none";
sCreatorDisplayName ="unknown";
}
@@ -109,12 +109,10 @@
*/
public VersionControlMethod(String path) {
super(path);
- name = "VERSION-CONTROL";
}
public VersionControlMethod(String path, String sTarget) {
super(path);
- name = "VERSION-CONTROL";
this.sTarget = sTarget;
}
@@ -135,9 +133,9 @@
}
- public void setHeader(String headerName, String headerValue) {
- super.setHeader(headerName, headerValue);
- if (sTarget != null) super.setHeader("Content-Type", "text/xml; charset=utf-8");
+ public void setRequestHeader(String headerName, String headerValue) {
+ super.setRequestHeader(headerName, headerValue);
+ if (sTarget != null) super.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
}
@@ -145,18 +143,19 @@
// --------------------------------------------------- WebdavMethod Methods
-
+ public String getName() {
+ return "VERSION-CONTROL";
+ }
/**
- * Generate the query body.
+ * DAV requests that contain a body must override this function to
+ * generate that body.
*
- * @return String query
+ * <p>The default behavior simply returns an empty body.</p>
*/
- public String generateQuery() {
-
- if (query != null) {
- return query;
- } else if (sTarget != null){
+ protected String generateRequestBody() {
+
+ if (sTarget != null){
XMLPrinter printer = new XMLPrinter();
printer.writeXMLHeader();
@@ -170,7 +169,9 @@
printer.writeElement("D", "version-control", XMLPrinter.CLOSING);
return printer.toString();
- } else return "";
+ }
+ else
+ return "";
}
@@ -179,12 +180,13 @@
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_CONFLICT ||
- getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
+ int code = getStatusLine().getStatusCode();
+ if (code == WebdavStatus.SC_CONFLICT ||
+ code == WebdavStatus.SC_FORBIDDEN ) {
parseXMLResponse(input);
}
}
1.5 +25 -27 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UpdateMethod.java
Index: UpdateMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UpdateMethod.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- UpdateMethod.java 27 Sep 2002 06:00:20 -0000 1.4
+++ UpdateMethod.java 16 Dec 2002 15:17:28 -0000 1.5
@@ -66,8 +66,9 @@
import java.io.InputStream;
import java.io.IOException;
-import org.apache.commons.httpclient.State;
import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpConnection;
import org.apache.util.XMLPrinter;
import org.apache.util.WebdavStatus;
@@ -88,11 +89,9 @@
// ----------------------------------------------------- Instance Variables
-
- private String comment, creatorDisplayName;
-
+
private String target = null;
-
+
// ----------------------------------------------------------- Constructors
@@ -101,9 +100,6 @@
* Method constructor.
*/
public UpdateMethod() {
- name = "UPDATE";
- comment ="none";
- creatorDisplayName ="unknown";
}
@@ -112,7 +108,6 @@
*/
public UpdateMethod(String path) {
super(path);
- name = "UPDATE";
}
@@ -125,20 +120,22 @@
*/
public UpdateMethod(String path, String target) {
super(path);
- name = "UPDATE";
this.target = target;
}
+ public String getName() {
+ return "UPDATE";
+ }
+
/**
- * Generate the query body.
+ * DAV requests that contain a body must override this function to
+ * generate that body.
*
- * @return String query
+ * <p>The default behavior simply returns an empty body.</p>
*/
- public String generateQuery() {
- if (query != null) {
- return query;
- } else if (target != null) {
+ protected String generateRequestBody() {
+ if (target != null) {
XMLPrinter printer = new XMLPrinter();
printer.writeXMLHeader();
printer.writeElement("D", "DAV:", "update", XMLPrinter.OPENING);
@@ -148,25 +145,26 @@
printer.writeElement("D", "href", XMLPrinter.CLOSING);
printer.writeElement("D", "version", XMLPrinter.CLOSING);
printer.writeElement("D", "update", XMLPrinter.CLOSING);
-
+
return printer.toString();
- } else return "";
+ }
+ else
+ return "";
}
-
-
/**
* Parse response.
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_CONFLICT ||
- getStatusCode() == WebdavStatus.SC_MULTI_STATUS ||
- getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
+ int code = getStatusLine().getStatusCode();
+ if (code == WebdavStatus.SC_CONFLICT ||
+ code == WebdavStatus.SC_MULTI_STATUS ||
+ code == WebdavStatus.SC_FORBIDDEN ) {
parseXMLResponse(input);
}
}
1.15 +18 -28 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UnlockMethod.java
Index: UnlockMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UnlockMethod.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- UnlockMethod.java 25 Apr 2002 21:15:15 -0000 1.14
+++ UnlockMethod.java 16 Dec 2002 15:17:28 -0000 1.15
@@ -66,10 +66,7 @@
import java.io.InputStream;
import java.io.IOException;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.State;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.*;
import org.apache.webdav.lib.WebdavState;
@@ -96,7 +93,6 @@
* Method constructor.
*/
public UnlockMethod() {
- name = "UNLOCK";
}
@@ -105,7 +101,6 @@
*/
public UnlockMethod(String path) {
super(path);
- name = "UNLOCK";
}
@@ -129,7 +124,9 @@
// --------------------------------------------------- WebdavMethod Methods
-
+ public String getName() {
+ return "UNLOCK";
+ }
/**
* Set header. handle the special case of lock-token.
@@ -137,12 +134,12 @@
* @param headerName Header name
* @param headerValue Header value
*/
- public void setHeader(String headerName, String headerValue) {
+ public void setRequestHeader(String headerName, String headerValue) {
if (headerName.equalsIgnoreCase("Lock-Token")){
setLockToken(headerValue);
}
else{
- super.setHeader(headerName, headerValue);
+ super.setRequestHeader(headerName, headerValue);
}
}
@@ -153,30 +150,23 @@
* Generate additional headers needed by the request.
*
* @param host the host
- * @param state State token
+ * @param state HttpState token
*/
- public void generateHeaders(String host, State state) {
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
- super.generateHeaders(host, state);
+ super.addRequestHeaders(state, conn);
- super.setHeader("Lock-Token", "<" + lockToken + ">");
+ super.setRequestHeader("Lock-Token", "<" + lockToken + ">");
}
-
- /**
- * Parse response.
- *
- * @param is Input stream
- */
- public void parseResponse(InputStream is)
- throws IOException {
- if ((getStatusCode() == HttpStatus.SC_NO_CONTENT) &&
- (this.state instanceof WebdavState)) {
+ protected void processResponseBody(HttpState state, HttpConnection conn) {
+ if ((getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT) &&
+ (state instanceof WebdavState)) {
((WebdavState) state).removeLock(getPath(), lockToken);
}
}
-
-
+
}
1.8 +12 -22 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UncheckoutMethod.java
Index: UncheckoutMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UncheckoutMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- UncheckoutMethod.java 14 Aug 2002 15:22:24 -0000 1.7
+++ UncheckoutMethod.java 16 Dec 2002 15:17:28 -0000 1.8
@@ -66,8 +66,9 @@
import java.io.InputStream;
import java.io.IOException;
-import org.apache.commons.httpclient.State;
import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpConnection;
import org.apache.util.WebdavStatus;
@@ -110,8 +111,6 @@
* Method constructor.
*/
public UncheckoutMethod() {
- name = "UNCHECKOUT";
-
}
@@ -120,7 +119,6 @@
*/
public UncheckoutMethod(String path) {
super(path);
- name = "UNCHECKOUT";
}
@@ -129,30 +127,22 @@
// ------------------------------------------------------------- Properties
-
- /**
- * Generate the query body.
- *
- * @return String query
- */
- public String generateQuery() {
-
- return "";
-
-
- }
+ public String getName() {
+ return "UNCHECKOUT";
+ }
/**
* Parse response.
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_CONFLICT ||
- getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
+ int code = getStatusLine().getStatusCode();
+ if (code == WebdavStatus.SC_CONFLICT ||
+ code == WebdavStatus.SC_FORBIDDEN ) {
parseXMLResponse(input);
}
}
1.7 +26 -22 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/SearchMethod.java
Index: SearchMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/SearchMethod.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SearchMethod.java 14 Aug 2002 15:22:24 -0000 1.6
+++ SearchMethod.java 16 Dec 2002 15:17:28 -0000 1.7
@@ -74,8 +74,9 @@
import org.apache.util.WebdavStatus;
+import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.State;
+import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.HttpException;
@@ -156,7 +157,6 @@
* Method constructor.
*/
public SearchMethod() {
- name = "SEARCH";
}
@@ -165,7 +165,6 @@
*/
public SearchMethod(String path) {
super(path);
- name = "SEARCH";
}
@@ -179,7 +178,7 @@
*/
public SearchMethod(String path, String query) {
this(path);
- setQuery(query);
+ preloadedQuery = query;
}
@@ -191,12 +190,16 @@
*/
protected String prefix = null;
+ private String preloadedQuery = null;
// ------------------------------------------------------------- Properties
// --------------------------------------------------- WebdavMethod Methods
+ public String getName() {
+ return "SEARCH";
+ }
public void recycle() {
super.recycle();
@@ -210,22 +213,23 @@
* @param host the host
* @param state State token
*/
- public void generateHeaders(String host, State state) {
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
- super.generateHeaders(host, state);
- super.setHeader("Content-Type", "text/xml; charset=utf-8");
+ super.addRequestHeaders(state, conn);
+ super.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
}
/**
- * Return the query supplied in the constructor or setQuery(). In future,
- * this will construct a query in the grammar you're interested in.
+ * DAV requests that contain a body must override this function to
+ * generate that body.
*
- * @return String query
+ * <p>The default behavior simply returns an empty body.</p>
*/
- public String generateQuery() {
+ protected String generateRequestBody() {
- if (query == null || query.trim().length() < 1) {
+ if (preloadedQuery == null || preloadedQuery.trim().length() < 1) {
// TODO Must support some mechanism for delegating the
// generation of the query to a pluggable query grammar
// support class or package. Right now, executing this
@@ -233,12 +237,11 @@
// query is an error.
return "";
} else {
- return query;
+ return preloadedQuery;
}
}
-
/**
* This method returns an enumeration of URL paths. If the PropFindMethod
* was sent to the URL of a collection, then there will be multiple URLs.
@@ -273,14 +276,15 @@
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_BAD_REQUEST ||
- getStatusCode() == WebdavStatus.SC_MULTI_STATUS ||
- getStatusCode() == WebdavStatus.SC_FORBIDDEN ||
- getStatusCode() == WebdavStatus.SC_CONFLICT ) {
+ int code = getStatusLine().getStatusCode();
+ if (code == WebdavStatus.SC_BAD_REQUEST ||
+ code == WebdavStatus.SC_MULTI_STATUS ||
+ code == WebdavStatus.SC_FORBIDDEN ||
+ code == WebdavStatus.SC_CONFLICT ) {
parseXMLResponse(input);
}
}
1.5 +28 -24 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/ReportMethod.java
Index: ReportMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/ReportMethod.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ReportMethod.java 30 Jul 2002 07:05:22 -0000 1.4
+++ ReportMethod.java 16 Dec 2002 15:17:28 -0000 1.5
@@ -65,10 +65,13 @@
import java.util.Enumeration;
import java.util.Vector;
+import java.io.IOException;
import org.apache.util.XMLPrinter;
-import org.apache.commons.httpclient.State;
+import org.apache.commons.httpclient.HttpConnection;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpException;
import org.apache.webdav.lib.PropertyName;
/**
@@ -106,7 +109,7 @@
public String sVersionHistory ="";
-
+ private String preloadedQuery = null;
// ----------------------------------------------------------- Constructors
@@ -115,7 +118,6 @@
* Method constructor.
*/
public ReportMethod() {
- name = "REPORT";
}
@@ -124,7 +126,6 @@
*/
public ReportMethod(String path) {
super(path);
- name = "REPORT";
}
@@ -173,7 +174,7 @@
this(path);
setDepth(depth);
setType(SUB_SET);
- query=sBody;
+ preloadedQuery = sBody;
}
@@ -214,7 +215,7 @@
* @param headerName Header name
* @param headerValue Header value
*/
- public void setHeader(String headerName, String headerValue) {
+ public void setRequestHeader(String headerName, String headerValue) {
if (headerName.equalsIgnoreCase("Depth")){
int depth = -1;
if (headerValue.equals("0")){
@@ -229,7 +230,7 @@
setDepth(depth);
}
else{
- super.setHeader(headerName, headerValue);
+ super.setRequestHeader(headerName, headerValue);
}
}
@@ -347,6 +348,9 @@
// --------------------------------------------------- WebdavMethod Methods
+ public String getName() {
+ return "REPORT";
+ }
public void recycle() {
super.recycle();
@@ -359,36 +363,38 @@
* @param host the host
* @param state State token
*/
- public void generateHeaders(String host, State state) {
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
- super.generateHeaders(host, state);
+ super.addRequestHeaders(state, conn);
- super.setHeader("Content-Type", "text/xml; charset=utf-8");
+ super.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
switch (depth) {
case DEPTH_0:
- super.setHeader("Depth", "0");
+ super.setRequestHeader("Depth", "0");
break;
case DEPTH_1:
- super.setHeader("Depth", "1");
+ super.setRequestHeader("Depth", "1");
break;
case DEPTH_INFINITY:
- super.setHeader("Depth", "infinity");
+ super.setRequestHeader("Depth", "infinity");
break;
}
}
-
/**
- * Generate the query body.
+ * DAV requests that contain a body must override this function to
+ * generate that body.
*
- * @return String query
+ * <p>The default behavior simply returns an empty body.</p>
*/
- public String generateQuery() {
+ protected String generateRequestBody() {
+
+ if (preloadedQuery != null)
+ return preloadedQuery;
- if (query != null) return query;
-
XMLPrinter printer = new XMLPrinter();
printer.writeXMLHeader();
if (type!= LOCATE_HISTORY)
@@ -438,13 +444,11 @@
break;
}
-
//System.out.println(query);
return printer.toString();
}
-
/**
* This method returns an enumeration of URL paths. If the ReportMethod
1.23 +23 -25 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropPatchMethod.java
Index: PropPatchMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropPatchMethod.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- PropPatchMethod.java 14 Aug 2002 15:22:24 -0000 1.22
+++ PropPatchMethod.java 16 Dec 2002 15:17:28 -0000 1.23
@@ -75,7 +75,8 @@
import org.apache.util.XMLPrinter;
import org.apache.util.WebdavStatus;
-import org.apache.commons.httpclient.State;
+import org.apache.commons.httpclient.HttpConnection;
+import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpException;
@@ -99,7 +100,6 @@
* Method constructor.
*/
public PropPatchMethod() {
- name = "PROPPATCH";
}
@@ -108,7 +108,6 @@
*/
public PropPatchMethod(String path) {
super(path);
- name = "PROPPATCH";
}
@@ -213,31 +212,32 @@
// --------------------------------------------------- WebdavMethod Methods
+ public String getName() {
+ return "PROPPATCH";
+ }
+
/**
* Generate additional headers needed by the request.
*
* @param host the host
* @param state State token
*/
- public void generateHeaders(String host, State state) {
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
- super.generateHeaders(host, state);
+ super.addRequestHeaders(state, conn);
- super.setHeader("Content-Type", "text/xml; charset=utf-8");
+ super.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
}
-
/**
- * Generate the query body.
+ * DAV requests that contain a body must override this function to
+ * generate that body.
*
- * @return String query
+ * <p>The default behavior simply returns an empty body.</p>
*/
- public String generateQuery() {
-
- if (query != null)
- return query;
-
+ protected String generateRequestBody() {
XMLPrinter printer = new XMLPrinter();
printer.writeXMLHeader();
printer.writeElement("D", "DAV:", "propertyupdate",
@@ -284,24 +284,22 @@
printer.writeElement("D", "propertyupdate", XMLPrinter.CLOSING);
- query = printer.toString();
-
- return query;
+ return printer.toString();
}
-
/**
* Parse response.
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_CONFLICT ||
- getStatusCode() == WebdavStatus.SC_MULTI_STATUS ||
- getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
+ int code = getStatusLine().getStatusCode();
+ if (code == WebdavStatus.SC_CONFLICT ||
+ code == WebdavStatus.SC_MULTI_STATUS ||
+ code == WebdavStatus.SC_FORBIDDEN ) {
parseXMLResponse(input);
}
}
1.32 +26 -25 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMethod.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- PropFindMethod.java 25 Jul 2002 10:56:01 -0000 1.31
+++ PropFindMethod.java 16 Dec 2002 15:17:28 -0000 1.32
@@ -72,8 +72,10 @@
import org.apache.util.XMLPrinter;
+import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.State;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpException;
import org.apache.webdav.lib.Property;
import org.apache.webdav.lib.PropertyName;
@@ -145,7 +147,6 @@
* Method constructor.
*/
public PropFindMethod() {
- name = "PROPFIND";
}
@@ -154,7 +155,6 @@
*/
public PropFindMethod(String path) {
super(path);
- name = "PROPFIND";
}
@@ -236,7 +236,7 @@
* @param headerName Header name
* @param headerValue Header value
*/
- public void setHeader(String headerName, String headerValue) {
+ public void setRequestHeader(String headerName, String headerValue) {
if (headerName.equalsIgnoreCase("Depth")){
int depth = -1;
if (headerValue.equals("0")){
@@ -251,7 +251,7 @@
setDepth(depth);
}
else{
- super.setHeader(headerName, headerValue);
+ super.setRequestHeader(headerName, headerValue);
}
}
@@ -360,42 +360,46 @@
prefix = null;
}
+ public String getName() {
+ return "PROPFIND";
+
+ }
+
+
/**
* Generate additional headers needed by the request.
*
* @param host the host
* @param state State token
*/
- public void generateHeaders(String host, State state) {
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
- super.generateHeaders(host, state);
+ super.addRequestHeaders(state, conn);
- super.setHeader("Content-Type", "text/xml; charset=utf-8");
+ super.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
switch (depth) {
case DEPTH_0:
- super.setHeader("Depth", "0");
+ super.setRequestHeader("Depth", "0");
break;
case DEPTH_1:
- super.setHeader("Depth", "1");
+ super.setRequestHeader("Depth", "1");
break;
case DEPTH_INFINITY:
- super.setHeader("Depth", "infinity");
+ super.setRequestHeader("Depth", "infinity");
break;
}
}
-
/**
- * Generate the query body.
+ * DAV requests that contain a body must override this function to
+ * generate that body.
*
- * @return String query
+ * <p>The default behavior simply returns an empty body.</p>
*/
- public String generateQuery() {
-
- if (query != null)
- return query;
+ protected String generateRequestBody() {
XMLPrinter printer = new XMLPrinter();
printer.writeXMLHeader();
@@ -433,11 +437,8 @@
printer.writeElement("D", "propfind", XMLPrinter.CLOSING);
- query = printer.toString();
- return query;
-
+ return printer.toString();
}
-
/**
* This method returns an enumeration of URL paths. If the PropFindMethod
1.14 +35 -43 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/OptionsMethod.java
Index: OptionsMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/OptionsMethod.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- OptionsMethod.java 25 Oct 2002 03:24:34 -0000 1.13
+++ OptionsMethod.java 16 Dec 2002 15:17:28 -0000 1.14
@@ -72,8 +72,8 @@
import java.util.Hashtable;
import java.util.StringTokenizer;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.State;
+import org.apache.commons.httpclient.HttpConnection;
+import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpException;
@@ -166,7 +166,6 @@
* Method constructor.
*/
public OptionsMethod() {
- name = "OPTIONS";
}
@@ -175,7 +174,6 @@
*/
public OptionsMethod(String path) {
super(path);
- name = "OPTIONS";
}
/**
@@ -183,7 +181,6 @@
*/
public OptionsMethod(String path, int type) {
super(path);
- name = "OPTIONS";
this.type = type;
}
@@ -247,12 +244,12 @@
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_OK && hasXMLBody) {
- parseXMLResponse(input);
+ if (getStatusLine().getStatusCode() == WebdavStatus.SC_OK && hasXMLBody) {
+ parseXMLResponse(input);
}
}
catch (IOException e) {
@@ -273,9 +270,10 @@
*
* @param headers Headers list
*/
- public void processResponseHeaders(Hashtable headers) {
+ public void processResponseHeaders(HttpState state,
+ HttpConnection conn) {
- Header davHeader = (Header) headers.get("dav");
+ Header davHeader = getResponseHeader("dav");
if (davHeader != null) {
String davHeaderValue = davHeader.getValue();
StringTokenizer tokenizer =
@@ -286,7 +284,7 @@
}
}
- Header allowHeader = (Header) headers.get("allow");
+ Header allowHeader = getResponseHeader("allow");
if (allowHeader != null) {
String allowHeaderValue = allowHeader.getValue();
StringTokenizer tokenizer =
@@ -298,8 +296,8 @@
}
}
- Header lengthHeader = (Header) headers.get("content-length");
- Header typeHeader = (Header) headers.get("content-type");
+ Header lengthHeader = getResponseHeader("content-length");
+ Header typeHeader = getResponseHeader("content-type");
if(
(lengthHeader != null &&
Integer.parseInt(lengthHeader.getValue()) > 0) ||
@@ -307,55 +305,49 @@
typeHeader.getValue().startsWith("text/xml")))
hasXMLBody = true;
- super.processResponseHeaders(headers);
+ super.processResponseHeaders(state, conn);
}
-
-
-
-
- /**
- * Generate the query body.
+ /**
+ * DAV requests that contain a body must override this function to
+ * generate that body.
*
- * @return String query
+ * <p>The default behavior simply returns an empty body.</p>
*/
- public String generateQuery() { //return null;
-
- if (query != null) return query;
-
-
+ protected String generateRequestBody() {
+
if (type != 0){
XMLPrinter printer = new XMLPrinter();
printer.writeXMLHeader();
//System.out.println(printer.toString());
- if (query != null)
- return printer.toString()+ query;
printer.writeElement("D", "DAV:", "options",
XMLPrinter.OPENING);
-
+
if (type == OPTIONS_VERSION_HISTORY)
printer.writeElement("D", "version-history-collection-set", XMLPrinter.NO_CONTENT);
if (type == OPTIONS_WORKSPACE)
printer.writeElement("D", "workspace-collection-set", XMLPrinter.NO_CONTENT);
-
+
printer.writeElement("D", "options", XMLPrinter.CLOSING);
- query = printer.toString();
- //System.out.println("query: " +query);
- return query;
-}
-
+ return printer.toString();
+ }
+
return null;
}
-
-
+ public String getName() {
+ return "OPTIONS";
+ }
+
//get and set header
- public void generateHeaders(String host, State state) {
- super.generateHeaders(host, state);
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
+
+ super.addRequestHeaders(state, conn);
if (type!= 0){
- super.setHeader("Content-Type", "text/xml; charset=utf-8");
+ super.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
//System.out.println("Content-Type set" );
}
}
1.18 +25 -20 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MoveMethod.java
Index: MoveMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MoveMethod.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- MoveMethod.java 25 Apr 2002 21:27:30 -0000 1.17
+++ MoveMethod.java 16 Dec 2002 15:17:28 -0000 1.18
@@ -60,11 +60,16 @@
* [Additional notices, if required by prior licensing conditions]
*
*/
-
+
package org.apache.webdav.lib.methods;
-import org.apache.commons.httpclient.State;
+import org.apache.commons.httpclient.HttpConnection;
+import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.util.URLUtil;
+
+import java.io.IOException;
/**
@@ -83,7 +88,6 @@
* Method constructor.
*/
public MoveMethod() {
- name = "MOVE";
}
@@ -92,7 +96,6 @@
*/
public MoveMethod(String source) {
super(source);
- name = "MOVE";
}
@@ -130,16 +133,16 @@
// ------------------------------------------------------------- Properties
-
-
-
+
+
+
/**
* Set header. handle the special case of Overwrite and Destination
*
* @param headerName Header name
* @param headerValue Header value
*/
- public void setHeader(String headerName, String headerValue) {
+ public void setRequestHeader(String headerName, String headerValue) {
if (headerName.equalsIgnoreCase("Overwrite")){
setOverwrite(! (headerValue.equalsIgnoreCase("F") ||
headerValue.equalsIgnoreCase("False") ) );
@@ -148,7 +151,7 @@
setDestination(headerValue);
}
else{
- super.setHeader(headerName, headerValue);
+ super.setRequestHeader(headerName, headerValue);
}
}
@@ -209,6 +212,10 @@
// --------------------------------------------------- WebdavMethod Methods
+ public String getName() {
+ return "MOVE";
+ }
+
/**
* Generate additional headers needed by the request.
*
@@ -216,19 +223,17 @@
* @param host the host
* @param state State token
*/
- public void generateHeaders(boolean httpsRequired, String host, State state) {
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
- super.generateHeaders(host, state);
+ super.addRequestHeaders(state, conn);
- String protocol;
- if (httpsRequired) protocol = "https://";
- else protocol = "http://";
String absoluteDestination =
- protocol + host + state.URLEncode(destination);
+ conn.getProtocol() + "://" + conn.getHost() + URLUtil.URLEncode(destination, "utf-8"); //for now jpl
+ super.setRequestHeader("Destination", absoluteDestination);
- super.setHeader("Destination", absoluteDestination);
if (!isOverwrite())
- super.setHeader("Overwrite", "F");
+ super.setRequestHeader("Overwrite", "F");
}
1.7 +12 -8 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MkWorkspaceMethod.java
Index: MkWorkspaceMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MkWorkspaceMethod.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MkWorkspaceMethod.java 14 Aug 2002 15:22:24 -0000 1.6
+++ MkWorkspaceMethod.java 16 Dec 2002 15:17:28 -0000 1.7
@@ -68,6 +68,8 @@
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpConnection;
import org.apache.util.WebdavStatus;
@@ -105,7 +107,6 @@
* Method constructor.
*/
public MkWorkspaceMethod() {
- name = "MKWORKSPACE";
}
@@ -114,24 +115,27 @@
*/
public MkWorkspaceMethod(String path) {
super(path);
- name = "MKWORKSPACE";
}
// --------------------------------------------------- WebdavMethod Methods
+ public String getName() {
+ return "MKWORKSPACE";
+ }
/**
* Parse response.
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_CONFLICT ||
- getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
+ int code = getStatusLine().getStatusCode();
+ if (code == WebdavStatus.SC_CONFLICT ||
+ code == WebdavStatus.SC_FORBIDDEN ) {
parseXMLResponse(input);
}
}
1.8 +6 -5 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MkcolMethod.java
Index: MkcolMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MkcolMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- MkcolMethod.java 25 Apr 2002 21:27:30 -0000 1.7
+++ MkcolMethod.java 16 Dec 2002 15:17:28 -0000 1.8
@@ -115,7 +115,6 @@
* Method constructor.
*/
public MkcolMethod() {
- name = "MKCOL";
}
@@ -124,7 +123,6 @@
*/
public MkcolMethod(String path) {
super(path);
- name = "MKCOL";
}
@@ -141,5 +139,8 @@
throws IOException {
}
+ public String getName() {
+ return "MKCOL";
+ }
}
1.33 +30 -29 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod.java
Index: LockMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- LockMethod.java 28 Aug 2002 07:04:20 -0000 1.32
+++ LockMethod.java 16 Dec 2002 15:17:28 -0000 1.33
@@ -72,7 +72,8 @@
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.commons.httpclient.State;
+import org.apache.commons.httpclient.HttpConnection;
+import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
@@ -213,7 +214,6 @@
* Method constructor.
*/
public LockMethod() {
- name = "LOCK";
}
@@ -222,7 +222,6 @@
*/
public LockMethod(String path) {
super(path);
- name = "LOCK";
}
@@ -274,7 +273,7 @@
* @param headerName Header name
* @param headerValue Header value
*/
- public void setHeader(String headerName, String headerValue) {
+ public void setRequestHeader(String headerName, String headerValue) {
if (headerName.equalsIgnoreCase("Depth")){
int depth = -1;
if (headerValue.equals("0")){
@@ -300,7 +299,7 @@
setOwner(headerValue);
}
else{
- super.setHeader(headerName, headerValue);
+ super.setRequestHeader(headerName, headerValue);
}
}
@@ -417,6 +416,9 @@
// --------------------------------------------------- WebdavMethod Methods
+ public String getName() {
+ return "LOCK";
+ }
public void recycle() {
super.recycle();
@@ -434,43 +436,44 @@
* @param host the host
* @param state State token
*/
- public void generateHeaders(String host, State state) {
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
- super.generateHeaders(host, state);
+ super.addRequestHeaders(state, conn);
switch (depth) {
case DEPTH_0:
- super.setHeader("Depth", "0");
+ super.setRequestHeader("Depth", "0");
break;
case DEPTH_INFINITY:
- super.setHeader("Depth", "infinity");
+ super.setRequestHeader("Depth", "infinity");
break;
default:
}
if (timeout == TIMEOUT_INFINITY) {
- super.setHeader("Timeout", "Infinite, Second-" + TIMEOUT_INFINITY);
+ super.setRequestHeader("Timeout", "Infinite, Second-" + TIMEOUT_INFINITY);
} else {
- super.setHeader("Timeout", "Second-" + timeout);
+ super.setRequestHeader("Timeout", "Second-" + timeout);
}
if (isRefresh()) {
- super.setHeader("If", "(<" + refreshOpaqueToken + ">)");
+ super.setRequestHeader("If", "(<" + refreshOpaqueToken + ">)");
}
- super.setHeader("Content-Type", "text/xml; charset=utf-8");
+ super.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
}
-
/**
- * Generate the query body.
+ * DAV requests that contain a body must override this function to
+ * generate that body.
*
- * @return String query
+ * <p>The default behavior simply returns an empty body.</p>
*/
- public String generateQuery() {
+ protected String generateRequestBody() {
- if (query != null) return query;
+ String result = "";
if (!isRefresh()) {
@@ -518,7 +521,7 @@
DOMWriter domWriter = new DOMWriter(stringWriter, false);
domWriter.print(document);
- query = stringWriter.getBuffer().toString();
+ result = stringWriter.getBuffer().toString();
} catch (DOMException e) {
} catch (ParserConfigurationException e) {
@@ -526,19 +529,17 @@
}
- return query;
-
+ return result;
}
-
/**
* Parse response.
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
- int status = getStatusCode();
+ int status = getStatusLine().getStatusCode();
// if (status == HttpStatus.SC_OK ||
// status == HttpStatus.SC_MULTI_STATUS ||
// status == HttpStatus.SC_CONFLICT) {
@@ -549,7 +550,7 @@
parseXMLResponse(input);
if ( (status == HttpStatus.SC_OK) &&
- (this.state instanceof WebdavState)) {
+ (state instanceof WebdavState)) {
String prefix = DOMUtils.findDavPrefix(
getResponseDocument());
NodeList list = getResponseDocument().getDocumentElement()
@@ -561,7 +562,7 @@
prefix + "href");
if (list2.getLength() == 1) {
this.lockToken = DOMUtils.getTextValue(list2.item(0));
- ((WebdavState) this.state).addLock
+ ((WebdavState) state).addLock
(getPath(), this.lockToken);
}
}
1.8 +21 -21 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LabelMethod.java
Index: LabelMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LabelMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- LabelMethod.java 20 Sep 2002 07:06:20 -0000 1.7
+++ LabelMethod.java 16 Dec 2002 15:17:28 -0000 1.8
@@ -66,9 +66,10 @@
import java.io.InputStream;
import java.io.IOException;
+import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.State;
+import org.apache.commons.httpclient.HttpState;
import org.apache.util.WebdavStatus;
import org.apache.util.XMLPrinter;
@@ -138,7 +139,6 @@
* The default constructor.
*/
public LabelMethod() {
- name = "LABEL";
}
@@ -151,7 +151,6 @@
*/
public LabelMethod(String path, int action, String labelName) {
super(path);
- name = "LABEL";
this.labelName = labelName;
this.type = action;
}
@@ -203,21 +202,19 @@
* @param host the host
* @param state the state
*/
- public void generateHeaders(String host, State state) {
- super.generateHeaders(host, state);
- super.setHeader("Content-Type", "text/xml; charset=utf-8");
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
+ super.addRequestHeaders(state, conn);
+ super.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
}
-
/**
- * Generate the query body.
+ * DAV requests that contain a body must override this function to
+ * generate that body.
*
- * @return the query
+ * <p>The default behavior simply returns an empty body.</p>
*/
- public String generateQuery() {
-
- if (query != null) return query;
-
+ protected String generateRequestBody() {
if (type <= 0 || labelName == null)
throw new IllegalStateException
@@ -251,19 +248,19 @@
return printer.toString();
}
-
/**
* Parse response.
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_CONFLICT ||
- getStatusCode() == WebdavStatus.SC_MULTI_STATUS ||
- getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
+ int code = getStatusLine().getStatusCode();
+ if (code == WebdavStatus.SC_CONFLICT ||
+ code == WebdavStatus.SC_MULTI_STATUS ||
+ code == WebdavStatus.SC_FORBIDDEN ) {
parseXMLResponse(input);
}
}
@@ -272,6 +269,9 @@
}
}
+ public String getName() {
+ return "LABEL";
+ }
}
1.14 +3 -20 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/GetMethod.java
Index: GetMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/GetMethod.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- GetMethod.java 25 Apr 2002 21:12:29 -0000 1.13
+++ GetMethod.java 16 Dec 2002 15:17:28 -0000 1.14
@@ -104,27 +104,10 @@
/**
* Method constructor.
*/
- public GetMethod(String path, boolean useDisk, String tempDir) {
- super(path, useDisk, tempDir);
- }
-
-
- /**
- * Method constructor.
- */
public GetMethod(String path, String tempDir, String tempFile) {
super(path, tempDir, tempFile);
}
- /**
- * Method constructor.
- */
- public GetMethod(String path, boolean useDisk, String tempDir,
- String tempFile) {
- super(path, useDisk, tempDir, tempFile);
- }
-
-
/**
* Method constructor.
*/
1.10 +14 -10 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/DeleteMethod.java
Index: DeleteMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/DeleteMethod.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DeleteMethod.java 14 Aug 2002 15:22:24 -0000 1.9
+++ DeleteMethod.java 16 Dec 2002 15:17:28 -0000 1.10
@@ -63,9 +63,10 @@
package org.apache.webdav.lib.methods;
-import org.apache.commons.httpclient.State;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpConnection;
import org.apache.util.WebdavStatus;
@@ -119,7 +120,6 @@
* Method constructor.
*/
public DeleteMethod() {
- name = "DELETE";
}
@@ -128,7 +128,6 @@
*/
public DeleteMethod(String path) {
super(path);
- name = "DELETE";
}
/**
@@ -136,13 +135,14 @@
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_CONFLICT ||
- getStatusCode() == WebdavStatus.SC_MULTI_STATUS ||
- getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
+ int code = getStatusLine().getStatusCode();
+ if (code == WebdavStatus.SC_CONFLICT ||
+ code == WebdavStatus.SC_MULTI_STATUS ||
+ code == WebdavStatus.SC_FORBIDDEN ) {
parseXMLResponse(input);
}
}
@@ -150,6 +150,10 @@
// FIX ME: provide a way to deliver non xml data
}
}
+
+ public String getName() {
+ return "DELETE";
+ }
// --------------------------------------------------- WebdavMethod Methods
1.18 +23 -21 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CopyMethod.java
Index: CopyMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CopyMethod.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- CopyMethod.java 25 Apr 2002 21:12:29 -0000 1.17
+++ CopyMethod.java 16 Dec 2002 15:17:28 -0000 1.18
@@ -60,11 +60,14 @@
* [Additional notices, if required by prior licensing conditions]
*
*/
-
+
package org.apache.webdav.lib.methods;
-import org.apache.commons.httpclient.State;
-import org.apache.commons.httpclient.Header;
+import java.io.IOException;
+import org.apache.commons.httpclient.HttpConnection;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.util.URLUtil;
/**
@@ -84,7 +87,6 @@
* Method constructor.
*/
public CopyMethod() {
- name = "COPY";
}
@@ -93,7 +95,6 @@
*/
public CopyMethod(String source) {
super(source);
- name = "COPY";
}
@@ -139,7 +140,7 @@
* @param headerName Header name
* @param headerValue Header value
*/
- public void setHeader(String headerName, String headerValue) {
+ public void setRequestHeader(String headerName, String headerValue) {
if (headerName.equalsIgnoreCase("Overwrite")){
setOverwrite(! (headerValue.equalsIgnoreCase("F") ||
headerValue.equalsIgnoreCase("False") ) );
@@ -148,7 +149,7 @@
setDestination(headerValue);
}
else{
- super.setHeader(headerName, headerValue);
+ super.setRequestHeader(headerName, headerValue);
}
}
@@ -207,6 +208,10 @@
}
+ public String getName() {
+ return "COPY";
+ }
+
// --------------------------------------------------- WebdavMethod Methods
@@ -215,22 +220,19 @@
*
* @param httpsRequired true, if the protocol is https, else http
* @param host the host
- * @param state State token
+ * @param state HttpState token
*/
- public void generateHeaders(boolean httpsRequired, String host, State state) {
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
+
+ super.addRequestHeaders(state, conn);
- super.generateHeaders(host, state);
-
- String protocol;
- if (httpsRequired) protocol = "https://";
- else protocol = "http://";
String absoluteDestination =
- protocol + host + state.URLEncode(destination);
-
+ conn.getProtocol() + "://" + conn.getHost() + URLUtil.URLEncode(destination, "utf-8"); //for now jpl
+ super.setRequestHeader("Destination", absoluteDestination);
- super.setHeader("Destination", absoluteDestination);
if (!isOverwrite())
- super.setHeader("Overwrite", "F");
+ super.setRequestHeader("Overwrite", "F");
}
1.9 +11 -28 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CheckoutMethod.java
Index: CheckoutMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CheckoutMethod.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CheckoutMethod.java 14 Aug 2002 15:22:24 -0000 1.8
+++ CheckoutMethod.java 16 Dec 2002 15:17:28 -0000 1.9
@@ -66,8 +66,9 @@
import java.io.InputStream;
import java.io.IOException;
-import org.apache.commons.httpclient.State;
import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpConnection;
import org.apache.util.WebdavStatus;
@@ -111,8 +112,6 @@
* Method constructor.
*/
public CheckoutMethod() {
- name = "CHECKOUT";
-
}
@@ -121,24 +120,6 @@
*/
public CheckoutMethod(String path) {
super(path);
- name = "CHECKOUT";
- }
-
-
-
-
-
-
- /**
- * Generate the query body.
- *
- * @return String query
- */
- public String generateQuery() {
-
- if (query != null) {
- return query;
- } else return "";
}
/**
@@ -146,12 +127,12 @@
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_CONFLICT ||
- getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
+ if (getStatusLine().getStatusCode() == WebdavStatus.SC_CONFLICT ||
+ getStatusLine().getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
parseXMLResponse(input);
}
}
@@ -160,5 +141,7 @@
}
}
-
+ public String getName() {
+ return "CHECKOUT";
+ }
}
1.8 +11 -34 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CheckinMethod.java
Index: CheckinMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CheckinMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CheckinMethod.java 14 Aug 2002 15:22:24 -0000 1.7
+++ CheckinMethod.java 16 Dec 2002 15:17:28 -0000 1.8
@@ -66,8 +66,9 @@
import java.io.InputStream;
import java.io.IOException;
-import org.apache.commons.httpclient.State;
import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpConnection;
import org.apache.util.XMLPrinter;
import org.apache.util.WebdavStatus;
@@ -121,8 +122,6 @@
* Method constructor.
*/
public CheckinMethod() {
- name = "CHECKIN";
-
}
@@ -131,7 +130,6 @@
*/
public CheckinMethod(String path) {
super(path);
- name = "CHECKIN";
}
@@ -140,43 +138,19 @@
// ------------------------------------------------------------- Properties
-
-
- public void setHeader(String headerName, String headerValue) {
- super.setHeader(headerName, headerValue);
- }
-
-
-
// --------------------------------------------------- WebdavMethod Methods
-
-
-
- /**
- * Generate the query body.
- *
- * @return String query
- */
- public String generateQuery() {
- String result = "";
-
- if (query != null) result = query;
-
- return result;
- }
-
/**
* Parse response.
*
* @param input Input stream
*/
- public void parseResponse(InputStream input)
+ public void parseResponse(InputStream input, HttpState state, HttpConnection conn)
throws IOException, HttpException {
try
{
- if (getStatusCode() == WebdavStatus.SC_CONFLICT ||
- getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
+ if (getStatusLine().getStatusCode() == WebdavStatus.SC_CONFLICT ||
+ getStatusLine().getStatusCode() == WebdavStatus.SC_FORBIDDEN ) {
parseXMLResponse(input);
}
}
@@ -185,4 +159,7 @@
}
}
+ public String getName() {
+ return "CHECKIN";
+ }
}
1.8 +17 -25 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/AclMethod.java
Index: AclMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/AclMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AclMethod.java 1 Aug 2002 10:48:38 -0000 1.7
+++ AclMethod.java 16 Dec 2002 15:17:28 -0000 1.8
@@ -73,9 +73,7 @@
import org.apache.util.XMLPrinter;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.State;
-import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.*;
import org.apache.webdav.lib.Ace;
import org.apache.webdav.lib.Privilege;
@@ -101,7 +99,6 @@
* Method constructor.
*/
public AclMethod() {
- name = "ACL";
}
@@ -110,7 +107,6 @@
*/
public AclMethod(String path) {
super(path);
- name = "ACL";
}
@@ -149,24 +145,21 @@
* @param host the host
* @param state State token
*/
- public void generateHeaders(String host, State state) {
+ public void addRequestHeaders(HttpState state, HttpConnection conn)
+ throws IOException, HttpException {
- super.generateHeaders(host, state);
-
- super.setHeader("Content-Type", "text/xml; charset=utf-8");
+ super.addRequestHeaders(state, conn);
+ super.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
}
-
-
+
/**
- * Generate the query body.
+ * DAV requests that contain a body must override this function to
+ * generate that body.
*
- * @return String query
+ * <p>The default behavior simply returns an empty body.</p>
*/
- public String generateQuery() {
-
- if (query != null)
- return query;
+ protected String generateRequestBody() {
XMLPrinter printer = new XMLPrinter();
printer.writeXMLHeader();
@@ -241,11 +234,10 @@
printer.writeElement("D", "acl", XMLPrinter.CLOSING);
- query = printer.toString();
- return query;
-
+ return printer.toString();
}
-
-
+ public String getName() {
+ return "ACL";
+ }
}
1.1 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/HttpRequestBodyMethodBase.java
Index: HttpRequestBodyMethodBase.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/HttpRequestBodyMethodBase.java,v 1.1 2002/12/16 15:17:28 juergen Exp $
* $Revision: 1.1 $
* $Date: 2002/12/16 15:17:28 $
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "HttpClient", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib.methods;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* PUT Method.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
*
* @since 1.0
*/
public abstract class HttpRequestBodyMethodBase extends HttpMethodBase {
// ----------------------------------------------------------- Constructors
/**
* Default constructor.
*/
public HttpRequestBodyMethodBase() {
super();
}
/**
* Path-setting constructor.
* @param path the path to request
*
* @since 1.0
*/
public HttpRequestBodyMethodBase(String path) {
super(path);
}
// ------------------------------------------------------- Instance Methods
/**
* Request body content to be sent.
*/
private byte[] data = null;
/**
* Request body content to be sent.
*/
private File file = null;
/**
* Request body content to be sent.
*/
private URL url = null;
// --------------------------------------------------------- Public Methods
/**
* Set my request body content to the contents of a file.
*
* @since 2.0
*/
public void setRequestBody(File file) throws IOException {
checkNotUsed();
this.file = file;
}
/**
* Set my request body content to the resource at the specified URL.
*
* @since 2.0
*/
public void setRequestBody(URL url) throws IOException {
checkNotUsed();
this.url = url;
}
/**
* Set my request body content to the contents of a byte array.
*
* @since 2.0
*/
public void setRequestBody(byte[] bodydata) {
checkNotUsed();
this.data = bodydata;
}
/**
* Set my request body content to the contents of a string.
*
* @since 2.0
*/
public void setRequestBody(String bodydata) {
checkNotUsed();
setRequestBody(bodydata.getBytes());
}
/**
* Set my request body content to the contents of an input stream.
* The contents will be buffered into
* memory. To upload large entities, it is recommended to first buffer the
* data into a temporary file, and then send that file.
*
* @since 2.0
*/
public void setRequestBody(InputStream is)
throws IOException {
log.trace("enter HttpRequestBodyMethodBase.setRequestBody(InputStream)");
checkNotUsed();
byte[] buffer = new byte[4096];
ByteArrayOutputStream os = new ByteArrayOutputStream();
int nb = 0;
while (true) {
nb = is.read(buffer);
if (nb == -1) {
break;
}
os.write(buffer, 0, nb);
}
data = os.toByteArray();
}
/**
* Returns true if <tt>100 Continue</tt> status code
* is found.
*
* @since 2.0
*/
public boolean readContinueCode() {
if (getStatusLine() == null) {
return false;
}
if(null != getRequestHeader("expect") &&
getStatusLine().getStatusCode() != HttpStatus.SC_CONTINUE) {
return false;
}
return true;
}
/**
* Do write the request body.
* Override the method of {@link HttpMethodBase}
* if the method should wait until a <tt>100 Continue</tt> status code
* is expected (@link readContinueCode)
*
* @since 2.0
*/
protected boolean writeRequestBody(HttpState state, HttpConnection conn)
throws IOException, HttpException {
log.trace("enter HttpRequestBodyMethodBase.writeRequestBody(HttpState, HttpConnection)");
OutputStream out = conn.getRequestOutputStream((isHttp11() && (null == getRequestHeader("Content-Length"))));
InputStream inputStream = null;
if (file != null && file.exists()) {
inputStream = new FileInputStream(file);
} else if (url != null) {
inputStream = url.openConnection().getInputStream();
} else if(data != null){
inputStream = new ByteArrayInputStream(data);
} else {
return true;
}
byte[] buffer = new byte[4096];
int nb = 0;
while (true) {
nb = inputStream.read(buffer);
if (nb == -1) {
break;
}
out.write(buffer, 0, nb);
}
out.flush();
return true;
}
/**
* Override the method of {@link HttpMethodBase}
* to return the appropriate content length.
*
* @since 2.0
*/
protected int getRequestContentLength() {
log.trace("enter HttpRequestBodyMethodBase.getRequestContentLength()");
if(null != data) {
return data.length;
} else if(null != file && file.exists()) {
return (int)(file.length());
} else if(url != null) {
return -1;
} else {
return 0;
}
}
/**
* return true, if the method setRequestContent has been called (with a null parameter)
*
* @since 2.0
*/
protected boolean isRequestContentAlreadySet() {
log.trace("enter HttpRequestBodyMethodBase.isRequestContentSet()");
return (data != null) || (file != null) || (url != null);
}
/**
*
* @since 1.0
*/
public void recycle() {
super.recycle();
data = null;
url = null;
file = null;
}
/** Log object for this class. */
private static final Log log = LogFactory.getLog(HttpRequestBodyMethodBase.class);
}
1.6 +5 -5 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavState.java
Index: WebdavState.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavState.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WebdavState.java 25 Apr 2002 21:15:17 -0000 1.5
+++ WebdavState.java 16 Dec 2002 15:17:29 -0000 1.6
@@ -68,14 +68,14 @@
import java.util.ArrayList;
import java.util.Vector;
import java.util.Enumeration;
-import org.apache.commons.httpclient.State;
+import org.apache.commons.httpclient.HttpState;
/**
* Session state.
*
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
*/
-public class WebdavState extends State {
+public class WebdavState extends HttpState {
// -------------------------------------------------------------- Constants
1.25 +8 -131 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java
Index: WebdavSession.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- WebdavSession.java 23 Oct 2002 06:15:24 -0000 1.24
+++ WebdavSession.java 16 Dec 2002 15:17:29 -0000 1.25
@@ -72,8 +72,7 @@
import org.apache.util.HttpURL;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.ConnectionInterceptor;
-import org.apache.commons.httpclient.StreamInterceptor;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
/**
* This WebdavSession class is for the session management of WebDAV clients.
@@ -94,8 +93,7 @@
*
* @author <a href="mailto:jericho@thinkfree.com">Park, Sung-Gu</a>
*/
-public abstract class WebdavSession
- implements ConnectionInterceptor {
+public abstract class WebdavSession {
// ------------------------------------------------------- Constructors
@@ -143,9 +141,6 @@
*/
public void setDebug(int debug) {
this.debug = debug;
- if (client != null) {
- client.setDebug(debug);
- }
}
@@ -186,7 +181,6 @@
client = null;
if (client == null) {
client = new HttpClient();
- client.setDebug(debug);
// Set a state which allows lock tracking
client.setState(new WebdavState());
if(proxyHost != null && proxyPort > 0)
@@ -199,9 +193,10 @@
String userName = httpURL.getUserName();
if (userName != null && userName.length() > 0) {
String password = httpURL.getPassword();
- client.setCredentials(new Credentials(userName, password));
+ client.getState().setCredentials(null,
+ new UsernamePasswordCredentials(userName, password));
+
}
- client.setConnectionInterceptor(this);
}
return client;
@@ -242,124 +237,6 @@
public synchronized void closeSession(HttpClient client)
throws IOException {
closeSession();
- }
-
-
- /**
- * Connect.
- */
- public void connect() {
- if (debug == 9) {
- System.err.println("CLIENT: connected.");
- }
- }
-
-
- /**
- * Disconnect.
- */
- public void disconnect() {
- if (debug == 9) {
- System.err.println("CLIENT: disconnected.");
- }
- }
-
-
- /**
- * Retry.
- *
- * @return boolean true if a retry should be attempted
- */
- public boolean retry(int status) {
- if (debug == 9) {
- System.err.println("CLIENT: retrying.");
- }
- return false;
- }
-
-
- /**
- * Recieved an informational status code.
- *
- * @return boolean true if a retry should be attempted
- */
- public boolean info(int status, Hashtable headers) {
- if (debug == 9) {
- System.err.println("CLIENT: Status: " + status + "\nHeaders: ");
- Enumeration keys = headers.keys();
- while (keys.hasMoreElements()) {
- String header = (String) keys.nextElement();
- String value = (String) headers.get(header);
- System.err.println("\t" + header + ": " + value);
- }
- }
- return false;
- }
-
-
- /**
- * Unexpected error.
- *
- * @param status Status code; can be equal to -1 if status code is not
- * known
- * @param e Underlying exception; can be null
- * @return boolean true if processing of the request should be stopped
- */
- public boolean error(int status, Exception e) {
- if (debug == 9) {
- System.err.println("CLIENT: Status: " + status + ", Exception: " +
- e.getMessage());
- }
- return false;
- }
-
-
- /**
- * Sent request.
- */
- public void sentRequest() {
- if (debug == 9) {
- System.err.println("CLIENT: sent request.");
- }
- }
-
-
- /**
- * Received response.
- */
- public void receivedResponse() {
- if (debug == 9) {
- System.err.println("CLIENT: received response.");
- }
- }
-
-
- /**
- * Received expectation.
- */
- public void receivedExpectation() {
- if (debug == 9) {
- System.err.println("CLIENT: received expectation.");
- }
- }
-
- /**
- * Authenticate.
- */
- public void requiredAuthentication() {
- if (debug == 9) {
- System.err.println("CLIENT: required authentication.");
- }
- }
-
-
- /**
- * Authenticate.
- */
- public void authenticate() {
- if (debug == 9) {
- System.err.println("CLIENT: authenticating.");
- }
}
1.54 +93 -141 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java
Index: WebdavResource.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- WebdavResource.java 27 Oct 2002 22:34:30 -0000 1.53
+++ WebdavResource.java 16 Dec 2002 15:17:29 -0000 1.54
@@ -647,7 +647,7 @@
ifHeaderValue.append("(<").append(lockTokens[i]).append(">) ");
}
- method.setHeader("If", ifHeaderValue.toString());
+ method.setRequestHeader("If", ifHeaderValue.toString());
}
@@ -962,9 +962,19 @@
* @return true if the given httpURL is the client for this resource.
*/
protected synchronized boolean isTheClient() throws MalformedURLException {
-
+
+ HttpState state = client.getState();
+ Credentials creds = client.getState().getCredentials(null);
+ String userName = null;
+ String password = null;
+
+ if (creds instanceof UsernamePasswordCredentials) {
+ UsernamePasswordCredentials upc = (UsernamePasswordCredentials) creds;
+ userName = upc.getUserName();
+ password = upc.getPassword();
+ }
HttpURL clientHttpURL =
- new HttpURL(client.getUserName(), client.getPassword(),
+ new HttpURL(userName, password,
client.getHost(), client.getPort());
return clientHttpURL.getAuthority().equals(httpURL.getAuthority());
@@ -1784,8 +1794,6 @@
setNameProperties(DepthSupport.DEPTH_1);
} catch (IOException e) {
return null;
- } catch (HttpException e) {
- return null;
}
Enumeration hrefs = childResources.getResourceNames();
@@ -1871,14 +1879,11 @@
* @param encodeURLs true if it is encoded.
* @exception MalformedURLException
* @exception IOException
+ *
+ * @deprecated No longer has any effect.
*/
- public void setEncodeURLs(boolean encodeURLs)
- throws MalformedURLException, IOException {
+ public void setEncodeURLs(boolean encodeURLs) {
- State state = client.getState();
- if (state != null) {
- state.setEncodeURLs(encodeURLs);
- }
}
@@ -1931,10 +1936,8 @@
Ace ace = aces[i];
method.addAce(ace);
}
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
@@ -1960,7 +1963,6 @@
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path),
DepthSupport.DEPTH_0, properties.elements());
- method.setDebug(debug);
client.executeMethod(method);
Enumeration responses = method.getResponses();
@@ -2010,7 +2012,6 @@
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path),
DepthSupport.DEPTH_0, properties.elements());
- method.setDebug(debug);
client.executeMethod(method);
Enumeration responses = method.getResponses();
@@ -2060,7 +2061,6 @@
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path),
DepthSupport.DEPTH_0, properties.elements());
- method.setDebug(debug);
client.executeMethod(method);
Enumeration responses = method.getResponses();
@@ -2106,14 +2106,13 @@
method.setUseDisk(useDiskForGet);
if (tempDirForGet != null)
method.setTempDir(tempDirForGet);
- method.setDebug(debug);
client.executeMethod(method);
- int statusCode = method.getStatusCode();
+ int statusCode = method.getStatusLine().getStatusCode();
setStatusCode(statusCode);
if(statusCode >= 200 && statusCode < 300)
- return method.getData();
+ return method.getResponseBodyAsStream();
else
throw new IOException("Couldn't get file");
}
@@ -2134,13 +2133,11 @@
method.setUseDisk(useDiskForGet);
if (tempDirForGet != null)
method.setTempDir(tempDirForGet);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
- return method.getDataAsString();
+ return method.getResponseBodyAsString();
}
@@ -2175,12 +2172,9 @@
// use disk to save by default
GetMethod method = new GetMethod(HttpURL.getPathQuery(path), file);
method.setUseDisk(true);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -2218,15 +2212,14 @@
PutMethod method = new PutMethod(HttpURL.getPathQuery(path));
generateIfHeader(method);
if(getGetContentType() != null && !getGetContentType().equals(""))
- method.setHeader("Content-Type", getGetContentType());
- method.setHeader("Content-Length", String.valueOf(data.length));
- method.sendData(data);
- method.setDebug(debug);
- client.executeMethod(method);
+ method.setRequestHeader("Content-Type", getGetContentType());
+
+ method.setRequestHeader("Content-Length", String.valueOf(data.length));
+ method.setRequestBody(data);
+
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -2262,14 +2255,11 @@
PutMethod method = new PutMethod(HttpURL.getPathQuery(path));
generateIfHeader(method);
if(getGetContentType() != null && !getGetContentType().equals(""))
- method.setHeader("Content-Type", getGetContentType());
- method.sendData(is);
- method.setDebug(debug);
- client.executeMethod(method);
+ method.setRequestHeader("Content-Type", getGetContentType());
+ method.setRequestBody(is);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -2308,14 +2298,11 @@
PutMethod method = new PutMethod(HttpURL.getPath(path));
generateIfHeader(method);
if(getGetContentType() != null && !getGetContentType().equals(""))
- method.setHeader("Content-Type", getGetContentType());
- method.sendData(data);
- method.setDebug(debug);
- client.executeMethod(method);
+ method.setRequestHeader("Content-Type", getGetContentType());
+ method.setRequestBody(data);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -2354,14 +2341,11 @@
PutMethod method = new PutMethod(HttpURL.getPath(path));
generateIfHeader(method);
if(getGetContentType() != null && !getGetContentType().equals(""))
- method.setHeader("Content-Type", getGetContentType());
- method.sendData(file);
- method.setDebug(debug);
- client.executeMethod(method);
+ method.setRequestHeader("Content-Type", getGetContentType());
+ method.setRequestBody(file);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -2403,14 +2387,11 @@
PutMethod method = new PutMethod(HttpURL.getPath(path));
generateIfHeader(method);
if(getGetContentType() != null && !getGetContentType().equals(""))
- method.setHeader("Content-Type", getGetContentType());
- method.sendData(url);
- method.setDebug(debug);
- client.executeMethod(method);
+ method.setRequestHeader("Content-Type", getGetContentType());
+ method.setRequestBody(url);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -2447,10 +2428,8 @@
method = new OptionsMethod("*");
else
method = new OptionsMethod(HttpURL.getPath(path));
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
if (statusCode >= 200 && statusCode < 300) {
@@ -2506,7 +2485,7 @@
client.executeMethod(method);
Vector options = new Vector();
- int statusCode = method.getStatusCode();
+ int statusCode = method.getStatusLine().getStatusCode();
if (statusCode >= 200 && statusCode < 300) {
// check if the specific method is possbile
Enumeration allowedMethods = method.getAllowedMethods();
@@ -2560,7 +2539,7 @@
client.executeMethod(method);
Vector options = new Vector();
- int statusCode = method.getStatusCode();
+ int statusCode = method.getStatusLine().getStatusCode();
if (statusCode >= 200 && statusCode < 300) {
Enumeration responses = method.getResponses();
if (responses.hasMoreElements()) {
@@ -2630,12 +2609,9 @@
LabelMethod method = new LabelMethod(httpURL.getPath(), labeltype,
labelname);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -2649,7 +2625,6 @@
// Default depth=0, type=by_name
ReportMethod method =
new ReportMethod(httpURL.getPath(), depth);
- method.setDebug(debug);
client.executeMethod(method);
Vector results = new Vector();
@@ -2686,7 +2661,6 @@
ReportMethod method =
new ReportMethod(httpURL.getPath(), DepthSupport.DEPTH_0,
properties.elements());
- method.setDebug(debug);
client.executeMethod(method);
return method.getResponses();
@@ -2700,7 +2674,6 @@
// Default depth=0, type=by_name
ReportMethod method =
new ReportMethod(httpURL.getPath(), depth, properties.elements());
- method.setDebug(debug);
client.executeMethod(method);
/*first draft, does work anyhow
@@ -2751,7 +2724,6 @@
ReportMethod method =
new ReportMethod(httpURL.getPath(), depth, properties.elements(),
histUri.elements());
- method.setDebug(debug);
client.executeMethod(method);
Vector results = new Vector();
@@ -2786,7 +2758,6 @@
// Default depth=0, type=by_name
ReportMethod method =
new ReportMethod(httpURL.getPath(), depth, sQuery);
- method.setDebug(debug);
client.executeMethod(method);
Vector results = new Vector();
@@ -2861,13 +2832,17 @@
// Change the depth for allprop
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path), depth);
- method.setDebug(debug);
// Default depth=infinity, type=allprop
- client.executeMethod(method);
-
+ int status = client.executeMethod(method);
+
// Set status code for this resource.
if (thisResource == true) {
- setStatusCode(method.getStatusCode());
+ setStatusCode(status);
+ }
+ if (status != HttpStatus.SC_MULTI_STATUS) {
+ HttpException ex = new HttpException();
+ ex.setReasonCode(status);
+ throw ex;
}
thisResource = false;
@@ -2926,13 +2901,17 @@
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path), depth,
properties.elements());
- method.setDebug(debug);
- client.executeMethod(method);
+ int status = client.executeMethod(method);
// Set status code for this resource.
if (thisResource == true) {
// Set the status code.
- setStatusCode(method.getStatusCode());
+ setStatusCode(method.getStatusLine().getStatusCode());
+ }
+ if (status != HttpStatus.SC_MULTI_STATUS) {
+ HttpException ex = new HttpException();
+ ex.setReasonCode(status);
+ throw ex;
}
thisResource = false;
@@ -3015,9 +2994,14 @@
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path), DepthSupport.DEPTH_0,
properties.elements());
- method.setDebug(debug);
- client.executeMethod(method);
+ int status = client.executeMethod(method);
+ if (status != HttpStatus.SC_MULTI_STATUS) {
+ HttpException ex = new HttpException();
+ ex.setReasonCode(status);
+ throw ex;
+ }
+
// It contains the results.
Vector results = new Vector();
@@ -3326,11 +3310,9 @@
}
}
if (hasSomething) {
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
// Possbile Status Codes => SC_OK
// WebdavStatus.SC_FORBIDDEN, SC_CONFLICT, SC_LOCKED, 507
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
if (statusCode >= 200 && statusCode < 300) {
return true;
@@ -3367,12 +3349,9 @@
setClient();
HeadMethod method = new HeadMethod(HttpURL.getPath(path));
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -3408,12 +3387,9 @@
setClient();
DeleteMethod method = new DeleteMethod(HttpURL.getPath(path));
generateIfHeader(method);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -3453,15 +3429,12 @@
MoveMethod method = new MoveMethod(source, destination);
generateIfHeader(method);
method.setOverwrite(overwrite);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
// Possbile MOVE Status Codes => SC_CREATED, SC_NO_CONTENT
// WebdavStatus.SC_FORBIDDEN, SC_CONFLICT, SC_PRECONDITION_FAILED,
// SC_LOCKED, SC_BAD_GATEWAY
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -3501,15 +3474,12 @@
CopyMethod method = new CopyMethod(source, destination);
generateIfHeader(method);
method.setOverwrite(overwrite);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
// Possbile COPY Status Codes => SC_CREATED, SC_NO_CONTENT
// WebdavStatus.SC_FORBIDDEN, SC_CONFLICT, SC_PRECONDITION_FAILED,
// SC_LOCKED, SC_BAD_GATEWAY, SC_INSUFFICIENT_STORAGE
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -3546,16 +3516,12 @@
setClient();
MkcolMethod method = new MkcolMethod(HttpURL.getPath(path));
generateIfHeader(method);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
// Possbile MKCOL Status Codes => SC_CREATED
// WebdavStatus.SC_FORBIDDEN, SC_METHOD_NOT_ALLOWED, SC_CONFLICT,
// SC_LOCKED, SC_UNSUPPORTED_MEDIA_TYPE, SC_INSUFFICIENT_STORAGE
-
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -3637,8 +3603,7 @@
LockMethod method =
new LockMethod(HttpURL.getPath(path), owner, lockType, timeout);
generateIfHeader(method);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
String lock = method.getLockToken();
WebdavState state = (WebdavState) client.getState();
if (state != null) {
@@ -3648,8 +3613,6 @@
// Possbile LOCK Status Codes => SC_OK
// WebdavStatus.SC_SC_PRECONDITION_FAILED, SC_LOCKED
-
- int statusCode = method.getStatusCode();
setStatusCode(statusCode, lock);
return (statusCode >= 200 && statusCode < 300) ? true : false;
@@ -3691,7 +3654,10 @@
*/
public boolean unlockMethod() throws HttpException, IOException {
- boolean result = unlockMethod(httpURL.getPath(), defaultOwner);
+ String owner = (httpURL.getUserName() != null) ?
+ httpURL.getUserName() : defaultOwner;
+
+ boolean result = unlockMethod(httpURL.getPath(), owner);
if (result) refresh();
return result;
@@ -3706,10 +3672,13 @@
* @exception HttpException
* @exception IOException
*/
- public boolean unlockMethod(String owner)
+ public boolean unlockMethod(String path)
throws HttpException, IOException {
- return unlockMethod(httpURL.getPath(), owner);
+ String owner = (httpURL.getUserName() != null) ?
+ httpURL.getUserName() : defaultOwner;
+
+ return unlockMethod(path, owner);
}
@@ -3737,12 +3706,9 @@
UnlockMethod method = new UnlockMethod(path);
generateIfHeader(method);
method.setLockToken(lock);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
-
if (statusCode >= 200 && statusCode < 300) {
state.removeLocks(path);
return true;
@@ -3808,10 +3774,8 @@
path = HttpURL.getPath(path);
UpdateMethod method = new UpdateMethod(path, target);
generateIfHeader(method);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
@@ -3827,10 +3791,8 @@
VersionControlMethod method = new VersionControlMethod(path);
generateIfHeader(method);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
@@ -3846,10 +3808,8 @@
VersionControlMethod method = new VersionControlMethod(path, target);
generateIfHeader(method);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
@@ -3887,14 +3847,12 @@
setClient();
MkWorkspaceMethod method = new MkWorkspaceMethod(HttpURL.getPath(path));
generateIfHeader(method);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
// Possbile MKCOL Status Codes => SC_CREATED
// WebdavStatus.SC_FORBIDDEN, SC_METHOD_NOT_ALLOWED, SC_CONFLICT,
// SC_LOCKED, SC_UNSUPPORTED_MEDIA_TYPE, SC_INSUFFICIENT_STORAGE
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
@@ -4015,10 +3973,8 @@
setClient();
CheckinMethod method = new CheckinMethod(HttpURL.getPath(path));
generateIfHeader(method);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
@@ -4053,10 +4009,8 @@
setClient();
CheckoutMethod method = new CheckoutMethod(HttpURL.getPath(path));
generateIfHeader(method);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
@@ -4093,10 +4047,8 @@
setClient();
UncheckoutMethod method = new UncheckoutMethod(HttpURL.getPath(path));
generateIfHeader(method);
- method.setDebug(debug);
- client.executeMethod(method);
+ int statusCode = client.executeMethod(method);
- int statusCode = method.getStatusCode();
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
1.7 +12 -14 jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/taskdefs/Put.java
Index: Put.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/taskdefs/Put.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Put.java 25 Apr 2002 21:27:32 -0000 1.6
+++ Put.java 16 Dec 2002 15:17:30 -0000 1.7
@@ -77,7 +77,7 @@
import org.apache.tools.ant.types.FileSet;
import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
@@ -212,8 +212,8 @@
if ((this.userid != null && !this.userid.equals("")) &&
(this.password != null && !this.password.equals(""))) {
- client.setCredentials(
- new Credentials(this.userid, this.password));
+ client.getState().setCredentials(null,
+ new UsernamePasswordCredentials(this.userid, this.password));
}
// validity check on the URL
@@ -253,8 +253,6 @@
throw new BuildException(e.getMessage(), e);
} catch (IOException e) {
throw new BuildException(e.getMessage(), e);
- } catch (HttpException e) {
- throw new BuildException(e.getMessage(), e);
}
}
@@ -280,17 +278,17 @@
URLConnection connection = url.openConnection();
method.setPath(concatenate(urlFile, path, "/"));
- method.setHeader("content-type", connection.getContentType());
- method.sendData(connection.getInputStream());
+ method.setRequestHeader("content-type", connection.getContentType());
+ method.setRequestBody(connection.getInputStream());
client.executeMethod(method);
- int status = method.getStatusCode();
+ int status = method.getStatusLine().getStatusCode();
if ((status != HttpStatus.SC_OK) &&
(status != HttpStatus.SC_CREATED) &&
(status != HttpStatus.SC_ACCEPTED) &&
(status != HttpStatus.SC_NO_CONTENT)) {
- log("Status code " + method.getStatusCode() +
- " (" + HttpStatus.getStatusText(method.getStatusCode()) +
+ log("Status code " + method.getStatusLine().getStatusCode() +
+ " (" + HttpStatus.getStatusText(method.getStatusLine().getStatusCode()) +
") received while uploading " + method.getPath());
}
}
1.6 +6 -6 jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/taskdefs/Get.java
Index: Get.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/ant/taskdefs/Get.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Get.java 25 Apr 2002 21:12:34 -0000 1.5
+++ Get.java 16 Dec 2002 15:17:30 -0000 1.6
@@ -73,7 +73,7 @@
import org.apache.webdav.ant.taskdefs.WebdavMatchingTask;
-import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
@@ -134,7 +134,7 @@
if ((this.userid != null && !this.userid.equals("")) &&
(this.password != null && !this.password.equals(""))) {
- client.setCredentials(new Credentials(this.userid, this.password));
+ client.getState().setCredentials(null, new UsernamePasswordCredentials(this.userid, this.password));
}
// validity check on the URL
@@ -166,7 +166,7 @@
client.executeMethod(getMethod);
- InputStream input = getMethod.getData();
+ InputStream input = getMethod.getResponseBodyAsStream();
if( input == null ) {
throw new BuildException( "Can't get " + resource + " to " + file);
}
1.9 +7 -7 jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Client.java
Index: Client.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Client.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Client.java 27 Sep 2002 06:00:20 -0000 1.8
+++ Client.java 16 Dec 2002 15:17:30 -0000 1.9
@@ -209,10 +209,10 @@
private void handleException(Exception ex)
{
if (ex instanceof HttpException) {
- if (((HttpException) ex).getStatusCode() == HttpStatus.SC_METHOD_NOT_ALLOWED) {
+ if (((HttpException) ex).getReasonCode() == HttpStatus.SC_METHOD_NOT_ALLOWED) {
out.println("Warning: Not WebDAV-enabled?");
}
- else if (((HttpException) ex).getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
+ else if (((HttpException) ex).getReasonCode() == HttpStatus.SC_UNAUTHORIZED) {
out.println("Warning: Unauthorized");
}
else {
@@ -320,7 +320,7 @@
setPath(webdavResource.getPath());
}
catch (HttpException we) {
- if (we.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
+ if (we.getReasonCode() == HttpStatus.SC_UNAUTHORIZED) {
try {
out.print("UserName: ");
BufferedReader in =
@@ -408,7 +408,7 @@
}
}
} catch (HttpException we) {
- if (we.getStatusCode() ==
+ if (we.getReasonCode() ==
HttpStatus.SC_UNAUTHORIZED) {
BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
1.9 +6 -5 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/properties/AclProperty.java
Index: AclProperty.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/properties/AclProperty.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- AclProperty.java 25 Apr 2002 21:12:29 -0000 1.8
+++ AclProperty.java 16 Dec 2002 15:17:30 -0000 1.9
@@ -71,8 +71,9 @@
import org.w3c.dom.Node;
import org.apache.util.DOMUtils;
+import org.apache.util.URLUtil;
-import org.apache.commons.httpclient.URLUtil;
+import org.apache.commons.httpclient.URIUtil;
import org.apache.webdav.lib.Ace;
import org.apache.webdav.lib.BaseProperty;
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>