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 2003/02/07 15:58:58 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib WebdavResource.java
juergen 2003/02/07 06:58:57
Modified: src/webdav/client/src/org/apache/webdav/lib
WebdavResource.java
Log:
The new commons-http API did change. made the necessary adaptions.
Revision Changes Path
1.55 +681 -659 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.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- WebdavResource.java 16 Dec 2002 15:17:29 -0000 1.54
+++ WebdavResource.java 7 Feb 2003 14:58:57 -0000 1.55
@@ -63,36 +63,58 @@
package org.apache.webdav.lib;
+import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.InputStream;
+import java.io.FileInputStream;
import java.io.IOException;
-import java.io.FileOutputStream;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.Locale;
-import java.util.Vector;
-import java.util.Hashtable;
-import java.util.Enumeration;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.net.URL;
-import java.net.MalformedURLException;
-
-import org.apache.util.WebdavStatus;
-import org.apache.util.DOMUtils;
-
-import org.apache.util.HttpURL;
-import org.apache.commons.httpclient.*;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.TimeZone;
+import java.util.Vector;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.webdav.lib.methods.*;
-import org.apache.webdav.lib.properties.ResourceTypeProperty;
-import org.apache.webdav.lib.properties.LockDiscoveryProperty;
+import org.apache.util.DOMUtils;
+import org.apache.util.HttpURL;
+import org.apache.util.WebdavStatus;
+import org.apache.webdav.lib.methods.AclMethod;
+import org.apache.webdav.lib.methods.CheckinMethod;
+import org.apache.webdav.lib.methods.CheckoutMethod;
+import org.apache.webdav.lib.methods.CopyMethod;
+import org.apache.webdav.lib.methods.DeleteMethod;
+import org.apache.webdav.lib.methods.DepthSupport;
+import org.apache.webdav.lib.methods.LabelMethod;
+import org.apache.webdav.lib.methods.LockMethod;
+import org.apache.webdav.lib.methods.MkWorkspaceMethod;
+import org.apache.webdav.lib.methods.MkcolMethod;
+import org.apache.webdav.lib.methods.MoveMethod;
+import org.apache.webdav.lib.methods.OptionsMethod;
+import org.apache.webdav.lib.methods.PropFindMethod;
+import org.apache.webdav.lib.methods.PropPatchMethod;
+import org.apache.webdav.lib.methods.ReportMethod;
+import org.apache.webdav.lib.methods.UncheckoutMethod;
+import org.apache.webdav.lib.methods.UnlockMethod;
+import org.apache.webdav.lib.methods.UpdateMethod;
+import org.apache.webdav.lib.methods.VersionControlMethod;
import org.apache.webdav.lib.properties.AclProperty;
+import org.apache.webdav.lib.properties.LockDiscoveryProperty;
import org.apache.webdav.lib.properties.PrincipalCollectionSetProperty;
+import org.apache.webdav.lib.properties.ResourceTypeProperty;
/**
* The class <code>WebdavResource</code> is an abstract representation
@@ -201,10 +223,10 @@
* @author Remy Maucherat
*/
public class WebdavResource extends WebdavSession {
-
-
+
+
// ------------------------------------------------------- Constructors
-
+
/**
* The default constructor.
*/
@@ -232,11 +254,11 @@
*/
public WebdavResource(HttpURL httpURL, int action, int depth)
throws HttpException, IOException {
-
+
setHttpURL(httpURL, action, depth);
}
-
-
+
+
/**
* The constructor.
*
@@ -248,12 +270,12 @@
*/
public WebdavResource(HttpURL httpURL, int depth)
throws HttpException, IOException {
-
+
setHttpURL(httpURL, defaultAction, depth);
-
+
}
-
-
+
+
/**
* The constructor.
*
@@ -264,11 +286,11 @@
*/
public WebdavResource(HttpURL httpURL)
throws HttpException, IOException {
-
+
setHttpURL(httpURL);
}
-
-
+
+
/**
* The constructor.
* It must be put an escaped http URL as an arguement.
@@ -280,11 +302,11 @@
*/
public WebdavResource(String escapedHttpURL)
throws HttpException, IOException {
-
+
setHttpURL(escapedHttpURL);
}
-
-
+
+
/**
* The constructor.
*
@@ -296,130 +318,130 @@
*/
public WebdavResource(HttpURL httpURL, String additionalPath)
throws HttpException, IOException {
-
+
setHttpURL(httpURL, additionalPath);
}
-
-
+
+
// -------------------------------------- Constants for WebDAV properties.
-
-
+
+
/**
* The displayname property.
*/
public static final String DISPLAYNAME = "displayname";
-
-
+
+
/**
* The getcontentlanguage property.
*/
public static final String GETCONTENTLANGUAGE = "getcontentlanguage";
-
-
+
+
/**
* The getcontentlength property.
*/
public static final String GETCONTENTLENGTH = "getcontentlength";
-
-
+
+
/**
* The getlastmodifed property.
*/
public static final String GETLASTMODIFIED = "getlastmodified";
-
-
+
+
/**
* The creationdate property.
*/
public static final String CREATIONDATE = "creationdate";
-
-
+
+
/**
* The resourcetype property.
*/
public static final String RESOURCETYPE = "resourcetype";
-
-
+
+
/**
* The source property.
*/
public static final String SOURCE = "source";
-
+
/**
* The getcontenttype property.
*/
public static final String GETCONTENTTYPE = "getcontenttype";
-
-
+
+
/**
* The getetag property.
*/
public static final String GETETAG = "getetag";
-
-
+
+
/**
* The ishidden property.
*/
public static final String ISHIDDEN = "ishidden";
-
-
+
+
/**
* The iscollection property.
*/
public static final String ISCOLLECTION = "iscollection";
-
-
+
+
/**
* The supportedlock property.
*/
public static final String SUPPORTEDLOCK = "supportedlock";
-
-
+
+
/**
* The lockdiscovery property.
*/
public static final String LOCKDISCOVERY = "lockdiscovery";
-
-
+
+
// ------------------------------------------------------------ Constants
-
-
+
+
/**
* No action to find properties for this resource.
*/
public static final int NOACTION = 1;
-
-
+
+
/**
* The action setting only the displayname for this resource.
*/
public static final int NAME = 2;
-
-
+
+
/**
* The action setting the basic properties for this resource.
*/
public static final int BASIC = 3;
-
-
+
+
/**
* The action setting the default DAV properties for this resource.
*/
public static final int DEFAULT = 4;
-
-
+
+
/**
* The action setting the all properties for this resource.
*/
public static final int ALL = 5;
-
-
+
+
/**
*
*/
public static final int OPTIONS_WORKSPACE = 8;
-
+
/**
*
*/
@@ -429,25 +451,25 @@
public static final int LABEL_REMOVE = 11;
public static final int LABEL_ADD = 12;
-
+
/**
* Owner information for locking and unlocking.
*/
public static final String defaultOwner = "Slide";
-
-
+
+
/**
* The true constant string.
*/
public static final String TRUE = "1";
-
-
+
+
/**
* The false constant string.
*/
public static final String FALSE = "0";
-
-
+
+
/**
* Date formats using for Date parsing.
*/
@@ -459,199 +481,199 @@
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US),
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", Locale.US)
};
-
-
+
+
/**
* GMT timezone.
*/
protected final static TimeZone gmtZone = TimeZone.getTimeZone("GMT");
-
-
+
+
static {
for (int i = 0; i < formats.length; i++) {
formats[i].setTimeZone(gmtZone);
}
}
-
-
+
+
// --------------------------------------------------- Instance Variables
-
-
+
+
/**
* The HttpURL to represent a WebDAV resource.
*/
protected HttpURL httpURL;
-
-
+
+
/**
* Table of the hrefs gotten in a collection.
*/
protected WebdavResources childResources = new WebdavResources();
-
-
+
+
/**
* The default action to find properties.
*/
protected static int defaultAction = BASIC;
-
-
+
+
/**
* The default depth for WebDAV methods.
*/
protected static int defaultDepth = DepthSupport.DEPTH_0;
-
-
+
+
/**
* The default temporary directory for the GET method.
*/
protected static String tempDirForGet;
-
-
+
+
/**
* The flag setter to use the disk for the GET method.
*/
protected static boolean useDiskForGet = true;
-
-
+
+
/**
* The flag to set the status code by propfind.
*/
protected boolean thisResource;
-
-
+
+
/**
* The allowed HTTP methods.
*/
protected Enumeration allowedMethods;
-
-
+
+
/**
* The capabilities of the WebDAV server.
*/
protected Enumeration davCapabilities;
-
-
+
+
/**
* An WebdavResource flag to check its existence;
*/
protected boolean exists;
-
-
+
+
/**
* An WebdavResource flag to check overwriting;
*/
protected boolean overwrite;
-
-
+
+
/**
* An status code performed by HTTP methods at the most recent.
*/
protected int latestStatusCode;
-
-
+
+
/**
* An status message performed by HTTP methods at the most recent.
*/
protected String latestStatusMessage = "";
-
-
+
+
/**
* An WebDAV property, displayname.
*/
protected String displayName = "";
-
-
+
+
/**
* An WebDAV property, getcontentlength.
*/
protected long getContentLength;
-
-
+
+
/**
* An WebDAV property, getcontenttype.
*/
protected String getContentType = "";
-
-
+
+
/**
* An WebDAV property, resourcetype.
*/
protected ResourceTypeProperty resourceType;
-
-
+
+
/**
* An WebDAV property, getlastmodified.
*/
protected long getLastModified;
-
-
+
+
/**
* An WebDAV property, creationdate.
*/
protected long creationDate;
-
-
+
+
/**
* An WebDAV property, getetag.
*/
protected String getEtag = "";
-
+
/**
* Owner information for locking and unlocking.
*/
protected String owner = null;
-
-
+
+
/**
* An WebDAV property, ishidden.
*/
protected boolean isHidden;
-
-
+
+
/**
* An WebDAV property, iscollection.
*/
protected boolean isCollection;
-
-
+
+
/**
* An WebDAV property, supportedlock.
*/
protected String supportedLock = "";
-
-
+
+
/**
* An WebDAV property, lockdiscovery.
*/
protected LockDiscoveryProperty lockDiscovery;
-
-
+
+
// --------------------------------------------------------- Basic settings
-
+
/**
* Generate and add the If header to the specified HTTP method.
*/
protected void generateIfHeader(HttpMethod method) {
-
+
if (client == null) return;
if (method == null) return;
-
+
WebdavState state = (WebdavState) client.getState();
String[] lockTokens = state.getAllLocks(method.getPath());
-
+
if (lockTokens.length == 0) return;
-
+
StringBuffer ifHeaderValue = new StringBuffer();
-
+
for (int i = 0; i < lockTokens.length; i++) {
ifHeaderValue.append("(<").append(lockTokens[i]).append(">) ");
}
-
+
method.setRequestHeader("If", ifHeaderValue.toString());
-
+
}
-
-
+
+
/**
* Parse the <code>java.util.Date</code> string for HTTP-date.
*
@@ -668,11 +690,11 @@
} catch (ParseException e) {
}
}
-
+
return date;
}
-
-
+
+
/**
* Set only the displayname property for this resource.
*
@@ -680,14 +702,14 @@
*/
protected void setNameProperties(int depth)
throws HttpException, IOException {
-
+
Vector properties = new Vector();
properties.addElement(DISPLAYNAME);
-
+
setNamedProp(depth, properties);
}
-
-
+
+
/**
* Set the DAV basic properties like:
* <pre>
@@ -703,7 +725,7 @@
*/
protected void setBasicProperties(int depth)
throws HttpException, IOException {
-
+
Vector properties = new Vector();
properties.addElement(DISPLAYNAME);
properties.addElement(GETCONTENTLENGTH);
@@ -711,10 +733,10 @@
properties.addElement(RESOURCETYPE);
properties.addElement(GETLASTMODIFIED);
properties.addElement(LOCKDISCOVERY);
-
+
setNamedProp(depth, properties);
}
-
+
/**
* Set the DAV default properties like:
@@ -736,7 +758,7 @@
*/
protected void setDefaultProperties(int depth)
throws HttpException, IOException {
-
+
Vector properties = new Vector();
properties.addElement(CREATIONDATE);
properties.addElement(DISPLAYNAME);
@@ -749,11 +771,11 @@
properties.addElement(RESOURCETYPE);
properties.addElement(SOURCE);
properties.addElement(SUPPORTEDLOCK);
-
+
setNamedProp(depth, properties);
}
-
-
+
+
/**
* Set the named properties for this resource.
*
@@ -762,12 +784,12 @@
*/
protected void setNamedProp(int depth, Vector propertyNames)
throws HttpException, IOException {
-
+
Enumeration responses = propfindMethod(depth, propertyNames);
setWebdavProperties(responses);
}
-
-
+
+
/**
* Set all properties for this resource.
*
@@ -775,12 +797,12 @@
*/
protected void setAllProp(int depth)
throws HttpException, IOException {
-
+
Enumeration responses = propfindMethod(depth);
setWebdavProperties(responses);
}
-
-
+
+
/**
* Set WebDAV properties following to the given http URL.
* This method is fundamental for getting information of a collection.
@@ -792,14 +814,14 @@
*/
protected void setWebdavProperties(Enumeration responses)
throws HttpException, IOException {
-
+
// Make the resources in the collection empty.
childResources.removeAll();
while (responses.hasMoreElements()) {
-
+
ResponseEntity response =
(ResponseEntity) responses.nextElement();
-
+
boolean itself = false;
String href = (String) response.getHref();
if (!href.startsWith("/"))
@@ -815,7 +837,7 @@
setExistence(true);
itself = true;
}
-
+
// Get to know each resource.
WebdavResource workingResource = null;
if (itself) {
@@ -826,20 +848,20 @@
workingResource.setDebug(debug);
}
String displayName = null;
-
+
// clear the current lock set
workingResource.setLockDiscovery(null);
-
+
// Process the resource's properties
Enumeration properties = response.getProperties();
while (properties.hasMoreElements()) {
-
+
Property property = (Property) properties.nextElement();
-
+
// ------------------------------ Checking WebDAV properties
- workingResource.processProperty(property);
+ workingResource.processProperty(property);
}
-
+
if (displayName == null || displayName.trim().equals("")) {
displayName = HttpURL.getName(href);
}
@@ -854,11 +876,11 @@
childResources.addResource(workingResource);
}
}
-
-
+
+
// ------------------------------------------------------------ Properties
-
-
+
+
/**
* Set the default action for this resource.
* The default action is set as 'BASIC' for the first time.
@@ -875,8 +897,8 @@
public static void setDefaultAction(int action) {
defaultAction = action;
}
-
-
+
+
/**
* Get the default action.
*
@@ -885,8 +907,8 @@
public static int getDefaultAction() {
return defaultAction;
}
-
-
+
+
/**
* Set the default action for this resource.
*
@@ -900,8 +922,8 @@
public static void setDefaultDepth(int depth) {
defaultDepth = depth;
}
-
-
+
+
/**
* Get the default action.
*
@@ -910,8 +932,8 @@
public static int getDefaultDepth() {
return defaultDepth;
}
-
-
+
+
/**
* Get the default temporary directory for the GET method.
*
@@ -920,8 +942,8 @@
public static void setGetTempDir(String tempDir) {
tempDirForGet = tempDir;
}
-
-
+
+
/**
* Get the default temporary directory for the GET method.
* The default temporary directory is "temp/".
@@ -932,9 +954,9 @@
public static String getGetTempDir() {
return tempDirForGet;
}
-
-
-
+
+
+
/**
* Set the use disk flag for the GET method.
*
@@ -943,8 +965,8 @@
public static void setGetUseDisk(boolean useDisk) {
useDiskForGet = useDisk;
}
-
-
+
+
/**
* Get the use disk flag for the GET method.
*
@@ -954,8 +976,8 @@
public static boolean getGetUseDisk() {
return useDiskForGet;
}
-
-
+
+
/**
* Test that the httpURL is the same with the client.
*
@@ -976,11 +998,11 @@
HttpURL clientHttpURL =
new HttpURL(userName, password,
client.getHost(), client.getPort());
-
+
return clientHttpURL.getAuthority().equals(httpURL.getAuthority());
}
-
-
+
+
/**
* Set the client for this resource.
*
@@ -989,8 +1011,8 @@
protected void setClient() throws IOException {
setClient(httpURL);
}
-
-
+
+
/**
* Set the client for this resource and the given http URL.
*
@@ -998,14 +1020,14 @@
* @exception IOException
*/
protected synchronized void setClient(HttpURL httpURL) throws IOException {
-
+
if ((client == null) || ((client != null) && !isTheClient())) {
closeSession();
client = getSessionInstance(httpURL);
}
}
-
-
+
+
/**
* Set the HttpURL for this WebdavResource.
*
@@ -1020,15 +1042,15 @@
*/
public void setHttpURL(HttpURL httpURL, int action, int depth)
throws HttpException, IOException {
-
+
this.httpURL = httpURL;
setClient(httpURL);
// make its existence false
setExistence(false);
setProperties(action, depth);
}
-
-
+
+
/**
* Set the HttpURL for this WebdavResource.
*
@@ -1042,12 +1064,12 @@
*/
public void setHttpURL(HttpURL httpURL, int depth)
throws HttpException, IOException {
-
+
// Follow the default action.
setHttpURL(httpURL, defaultAction, depth);
}
-
-
+
+
/**
* Set the HttpURL for this WebdavResource.
* It must be put an escaped path part of the http URL as an arguement.
@@ -1065,11 +1087,11 @@
public void setHttpURL
(HttpURL httpURL, String additionalPath, int action, int depth)
throws HttpException, IOException {
-
+
setHttpURL(new HttpURL(httpURL, additionalPath), action, depth);
}
-
-
+
+
/**
* Set the HttpURL for this WebdavResource.
* It must be put an escaped path part of the http URL as an arguement.
@@ -1086,11 +1108,11 @@
public void setHttpURL
(HttpURL httpURL, String additionalPath, int action)
throws HttpException, IOException {
-
+
setHttpURL(new HttpURL(httpURL, additionalPath), action, defaultDepth);
}
-
-
+
+
/**
* Set the HttpURL for this WebdavResource.
*
@@ -1104,12 +1126,12 @@
*/
public void setHttpURL(HttpURL httpURL, String additionalPath)
throws HttpException, IOException {
-
+
setHttpURL(new HttpURL(httpURL, additionalPath),
defaultAction, defaultDepth);
}
-
-
+
+
/**
* Set the HttpURL for this WebdavResource.
*
@@ -1122,11 +1144,11 @@
*/
public void setHttpURL(HttpURL httpURL)
throws HttpException, IOException {
-
+
setHttpURL(httpURL, defaultDepth);
}
-
-
+
+
/**
* Set the HttpURL of this WebdavResource.
* It must be put an escaped http URL as an arguement.
@@ -1140,11 +1162,11 @@
*/
public void setHttpURL(String escapedHttpURL)
throws HttpException, IOException {
-
+
setHttpURL(new HttpURL(escapedHttpURL));
}
-
-
+
+
/**
* Get the HttpURL of this WebdavResource.
*
@@ -1153,8 +1175,8 @@
public HttpURL getHttpURL() {
return httpURL;
}
-
-
+
+
/**
* Get the HttpURL except for userinfo.
*
@@ -1162,11 +1184,11 @@
*/
public HttpURL getHttpURLExceptForUserInfo()
throws MalformedURLException {
-
+
return httpURL.getHttpURLExceptForUserInfo();
}
-
-
+
+
/**
* Set the path part of this WebdavResource.
*
@@ -1179,12 +1201,12 @@
*/
public void setPath(String path)
throws HttpException, IOException {
-
+
httpURL.setPath(path);
setHttpURL(httpURL);
}
-
-
+
+
/**
* Get the path part of this WebdavResource.
*
@@ -1194,8 +1216,8 @@
public String getPath() {
return httpURL.getPath();
}
-
-
+
+
/**
* Get the hostname of this WebdavResource.
*
@@ -1205,8 +1227,8 @@
public String getHost() throws MalformedURLException {
return httpURL.getHost();
}
-
-
+
+
/**
* Set the userinfo part of this WebdavResource.
*
@@ -1218,15 +1240,15 @@
*/
public void setUserInfo(String userName, String password)
throws HttpException, IOException {
-
+
httpURL.setUserInfo(userName, password);
setHttpURL(httpURL);
}
-
-
+
+
// ------------------------------------------------ DAV properties checking
-
-
+
+
/**
* Get the value of DAV property, displayname.
*
@@ -1235,8 +1257,8 @@
public String getDisplayName() {
return displayName;
}
-
-
+
+
/**
* Set the value of DAV property, displayname.
*
@@ -1245,8 +1267,8 @@
protected void setDisplayName(String displayName) {
this.displayName = displayName;
}
-
-
+
+
/**
* Get the value of DAV property, getcontentlength.
*
@@ -1255,8 +1277,8 @@
public long getGetContentLength() {
return getContentLength;
}
-
-
+
+
/**
* Set the value of DAV property, getcontentlength.
*
@@ -1265,8 +1287,8 @@
protected void setGetContentLength(long getContentLength) {
this.getContentLength = getContentLength;
}
-
-
+
+
/**
* Set the value of DAV property, getcontentlength.
*
@@ -1279,8 +1301,8 @@
// it's ok to ignore this error.
}
}
-
-
+
+
/**
* Get the value of DAV property, resourcetype.
*
@@ -1290,8 +1312,8 @@
public ResourceTypeProperty getResourceType() {
return resourceType;
}
-
-
+
+
/**
* Set the value of DAV property, resourcetype.
*
@@ -1300,8 +1322,8 @@
protected void setResourceType(ResourceTypeProperty resourceType) {
this.resourceType = resourceType;
}
-
-
+
+
/**
* Get the value of DAV property, resourcetype
*
@@ -1313,8 +1335,8 @@
if (getResourceType() == null) return false;
return getResourceType().isCollection();
}
-
-
+
+
/**
* Get the value of DAV property, getcontenttype.
*
@@ -1323,8 +1345,8 @@
public String getGetContentType() {
return getContentType;
}
-
-
+
+
/**
* Set the value of DAV property, getcontenttype.
*
@@ -1334,14 +1356,14 @@
this.getContentType = getContentType;
}
- /**
+ /**
* Set the content-type to use for this resource, for PUTs.
* @param contentType The content-type string.
*/
public void setContentType(String contentType) {
this.getContentType = contentType;
}
-
+
/**
* Get the value of DAV property, getlastmodified.
*
@@ -1350,8 +1372,8 @@
public long getGetLastModified() {
return getLastModified;
}
-
-
+
+
/**
* Set the value of DAV property, getlastmodified.
*
@@ -1361,8 +1383,8 @@
protected void setGetLastModified(long getLastModified) {
this.getLastModified = getLastModified;
}
-
-
+
+
/**
* Set the value of DAV property, getlastmodified.
*
@@ -1374,8 +1396,8 @@
if (date != null)
this.getLastModified = date.getTime();
}
-
-
+
+
/**
* Get the value of DAV property, creationdate.
*
@@ -1384,8 +1406,8 @@
public long getCreationDate() {
return creationDate;
}
-
-
+
+
/**
* Set the value of DAV property, creationdate.
*
@@ -1394,8 +1416,8 @@
protected void setCreationDate(long creationDate) {
this.creationDate = creationDate;
}
-
-
+
+
/**
* Set the value of DAV property, creationdate.
*
@@ -1406,8 +1428,8 @@
if (date != null)
this.creationDate = date.getTime();
}
-
-
+
+
/**
* Get the value of DAV property, getetag.
*
@@ -1416,8 +1438,8 @@
public String getGetEtag() {
return getEtag;
}
-
-
+
+
/**
* Set the value of DAV property, getetag.
*
@@ -1426,14 +1448,14 @@
protected void setGetEtag(String getEtag) {
this.getEtag = getEtag;
}
-
+
/**
* Get the owner string, as used for locking purposes.
*/
public String getOwner() {
return owner;
}
-
+
/**
* Get the value of DAV property, supportedlock.
*
@@ -1442,8 +1464,8 @@
public String getSupportedLock() {
return supportedLock;
}
-
-
+
+
/**
* Set the value of DAV property, supportedlock.
*
@@ -1452,8 +1474,8 @@
protected void setSupportedLock(String supportedLock) {
this.supportedLock = supportedLock;
}
-
-
+
+
/**
* Get the value of DAV property, lockdiscovery.
*
@@ -1462,7 +1484,7 @@
public LockDiscoveryProperty getLockDiscovery() {
return lockDiscovery;
}
-
+
/**
* Set the value of DAV property, lockdiscovery.
*
@@ -1471,8 +1493,8 @@
protected void setLockDiscovery(LockDiscoveryProperty lockDiscovery) {
this.lockDiscovery = lockDiscovery;
}
-
-
+
+
/**
* Get the activelock owners for this resource.
*
@@ -1490,7 +1512,7 @@
return buff.elements();
}
-
+
/**
* Test that this resource is locked.
*
@@ -1505,8 +1527,8 @@
}
return false;
}
-
-
+
+
/**
* Get the value of DAV property, ishidden.
*
@@ -1515,8 +1537,8 @@
public boolean getIsHidden() {
return isHidden;
}
-
-
+
+
/**
* Set the value of DAV property, ishidden.
*
@@ -1525,8 +1547,8 @@
protected void setIsHidden(boolean isHidden) {
this.isHidden = isHidden;
}
-
-
+
+
/**
* Set the value of DAV property, ishidden.
*
@@ -1535,8 +1557,8 @@
protected void setIsHidden(String isHidden) {
this.isHidden = isHidden.equals(TRUE) ? true : false;
}
-
-
+
+
/**
* Get the value of DAV property, iscollection
*
@@ -1546,8 +1568,8 @@
public boolean getIsCollection() {
return isCollection;
}
-
-
+
+
/**
* Set the value of DAV property, iscollection
*
@@ -1556,8 +1578,8 @@
protected void setIsCollection(boolean isCollection) {
this.isCollection = isCollection;
}
-
-
+
+
/**
* Set the value of DAV property, iscollection
*
@@ -1566,11 +1588,11 @@
protected void setIsCollection(String isCollection) {
this.isCollection = isCollection.equals(TRUE) ? true : false;
}
-
-
+
+
// --------------------------------------- WebDAV Resource Public Methods
-
-
+
+
/**
* Set the properties for this resource.
*
@@ -1579,7 +1601,7 @@
*/
public void setProperties(int action, int depth)
throws HttpException, IOException {
-
+
switch (action) {
case NAME:
setNameProperties(depth);
@@ -1598,8 +1620,8 @@
break;
}
}
-
-
+
+
/**
* Set the properties for this resource.
*
@@ -1607,10 +1629,10 @@
*/
public void setProperties(int depth)
throws HttpException, IOException {
-
+
setProperties(defaultAction, depth);
}
-
+
/**
* Refresh the properties of this resource
* without changing the status of the previous command
@@ -1623,7 +1645,7 @@
this.latestStatusCode=latestStatusCode;
this.latestStatusMessage=latestStatusMessage;
}
-
+
/*
* Test if it exists.
* This is a wrapper method for getExistence.
@@ -1634,8 +1656,8 @@
public boolean exists() {
return getExistence();
}
-
-
+
+
/*
* Set its existence.
*
@@ -1644,8 +1666,8 @@
protected void setExistence(boolean exists) {
this.exists = exists;
}
-
-
+
+
/*
* Get its existence.
*
@@ -1654,8 +1676,8 @@
public boolean getExistence() {
return exists;
}
-
-
+
+
/**
* Set the overwrite flag for COPY and MOVE.
* Should be set before the method is executed.
@@ -1665,8 +1687,8 @@
public void setOverwrite(boolean overwrite) {
this.overwrite = overwrite;
}
-
-
+
+
/**
* Get the current value of the overwrite flag for COPY and MOVE.
*
@@ -1675,16 +1697,16 @@
public boolean getOverwrite() {
return overwrite;
}
-
-
+
+
/**
* Close the session of this client
*/
public void close() throws IOException {
closeSession();
}
-
-
+
+
/**
* Get the lastest value of the status message by HTTP methods.
*
@@ -1693,8 +1715,8 @@
public String getStatusMessage() {
return latestStatusMessage;
}
-
-
+
+
/**
* Get the lastest value of the status code by HTTP methods.
*
@@ -1703,8 +1725,8 @@
public int getStatusCode() {
return latestStatusCode;
}
-
-
+
+
/**
* Set the lastest value of the status code by HTTP methods.
*
@@ -1713,8 +1735,8 @@
protected void setStatusCode(int statusCode) {
setStatusCode(statusCode, null);
}
-
-
+
+
/**
* Set the lastest value of the status code by HTTP methods.
*
@@ -1722,13 +1744,13 @@
* @param message the additional message.
*/
protected void setStatusCode(int statusCode, String message) {
-
+
latestStatusCode = statusCode;
latestStatusMessage = WebdavStatus.getStatusText(statusCode) +
" (" + statusCode + ")" + ((message == null) ? "" : message);
}
-
-
+
+
/**
* Get the allowed methods, checked by HTTP OPTIONS.
*
@@ -1738,8 +1760,8 @@
public Enumeration getAllowedMethods() {
return allowedMethods;
}
-
-
+
+
/**
* Get the WebDAV capabilities, checked by HTTP OPTIONS.
*
@@ -1749,8 +1771,8 @@
public Enumeration getDavCapabilities() {
return davCapabilities;
}
-
-
+
+
/*
* Get all resources in this collection with the depth 1.
*
@@ -1760,13 +1782,13 @@
*/
public WebdavResources getChildResources()
throws HttpException, IOException {
-
+
setProperties(DepthSupport.DEPTH_1);
-
+
return childResources;
}
-
-
+
+
/**
* Get an array of resources denoting the WebDAV child resources in the
* collection of this resources.
@@ -1777,11 +1799,11 @@
*/
public WebdavResource[] listWebdavResources()
throws HttpException, IOException {
-
+
return getChildResources().listResources();
}
-
-
+
+
/**
* Get an array of pathnames denoting the WebDAV resources in the
* collection denoted by this pathname.
@@ -1789,14 +1811,14 @@
* @return An array of pathnames denoting the resources.
*/
public String[] list() {
-
+
try {
setNameProperties(DepthSupport.DEPTH_1);
} catch (IOException e) {
return null;
}
Enumeration hrefs = childResources.getResourceNames();
-
+
// To be atomic.
Vector hrefList = new Vector();
while (hrefs.hasMoreElements()) {
@@ -1808,11 +1830,11 @@
for (int i = 0; i < num; i++) {
pathnames[i] = (String) hrefList.elementAt(i);
}
-
+
return pathnames;
}
-
-
+
+
/*
* Get an array of pathnames and basic information denoting the WebDAV
* resources in the denoted by this pathname.
@@ -1828,21 +1850,21 @@
*/
public Vector listBasic()
throws HttpException, IOException {
-
+
setBasicProperties(DepthSupport.DEPTH_1);
Enumeration hrefs = childResources.getResourceNames();
-
+
Vector hrefList = new Vector();
while (hrefs.hasMoreElements()) {
try {
String resourceName = (String) hrefs.nextElement();
WebdavResource currentResource =
childResources.getResource(resourceName);
-
+
String[] longFormat = new String[4];
// displayname.
longFormat[0] = currentResource.getDisplayName();
-
+
long length = currentResource.getGetContentLength();
// getcontentlength
longFormat[1] = new Long(length).toString();
@@ -1868,11 +1890,11 @@
//log.error(e,e);
}
}
-
+
return hrefList;
}
-
-
+
+
/**
* Set the URL encoding flag for this http URL.
*
@@ -1883,13 +1905,13 @@
* @deprecated No longer has any effect.
*/
public void setEncodeURLs(boolean encodeURLs) {
-
+
}
-
-
+
+
// -------------------------- General accessor to use http request methods.
-
-
+
+
/**
* Retrieve the current http client for this resource.
*
@@ -1898,12 +1920,12 @@
*/
public HttpClient retrieveSessionInstance()
throws IOException {
-
+
setClient();
return client;
}
-
-
+
+
/**
* Execute the http request method. And get its status code.
*
@@ -1914,22 +1936,22 @@
*/
public int executeHttpRequestMethod(HttpClient client, HttpMethod method)
throws IOException, HttpException {
-
+
client.executeMethod(method);
return method.getStatusCode();
}
-
-
+
+
// --------------------------------- WebDAV Request-method Public Methods
-
+
/**
* Updates the resource with a new set of aces.
*/
public boolean aclMethod(String path, Ace[] aces)
throws HttpException, IOException {
-
+
setClient();
-
+
AclMethod method = new AclMethod(path);
generateIfHeader(method);
for (int i=0; i<aces.length ; i++) {
@@ -1937,45 +1959,45 @@
method.addAce(ace);
}
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
+
/**
* Return the <code>AclProperty</code> for the resource at the given path
- * @return acl property, null if the server doesn't respond with
+ * @return acl property, null if the server doesn't respond with
* <code>AclProperty</code>
*/
public AclProperty aclfindMethod(String path)
throws HttpException, IOException {
-
+
setClient();
-
+
AclProperty acl = null;
-
+
Vector properties = new Vector();
properties.addElement(AclProperty.TAG_NAME);
-
+
// Default depth=0, type=by_name
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path),
DepthSupport.DEPTH_0, properties.elements());
client.executeMethod(method);
-
+
Enumeration responses = method.getResponses();
if (responses.hasMoreElements()) {
ResponseEntity response =
(ResponseEntity) responses.nextElement();
String href = (String) response.getHref();
-
+
// Set status code for this resource.
if ((thisResource == true) && (response.getStatusCode() > 0))
setStatusCode(response.getStatusCode());
thisResource = false;
-
+
Enumeration responseProperties =
method.getResponseProperties(href);
while (responseProperties.hasMoreElements()) {
@@ -1984,14 +2006,14 @@
if (property instanceof AclProperty) {
acl = (AclProperty)property;
}
-
+
}
}
-
+
return acl;
}
-
+
/**
* Get the <code>PrincipalCollectionSetProperty</code> for the resource.
*
@@ -2000,31 +2022,31 @@
*/
public PrincipalCollectionSetProperty principalCollectionSetFindMethod(
String path) throws HttpException, IOException {
-
+
setClient();
-
+
PrincipalCollectionSetProperty set = null;
-
+
Vector properties = new Vector();
properties.addElement(PrincipalCollectionSetProperty.TAG_NAME);
-
+
// Default depth=0, type=by_name
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path),
DepthSupport.DEPTH_0, properties.elements());
client.executeMethod(method);
-
+
Enumeration responses = method.getResponses();
if (responses.hasMoreElements()) {
ResponseEntity response =
(ResponseEntity) responses.nextElement();
String href = (String) response.getHref();
-
+
// Set status code for this resource.
if ((thisResource == true) && (response.getStatusCode() > 0))
setStatusCode(response.getStatusCode());
thisResource = false;
-
+
Enumeration responseProperties =
method.getResponseProperties(href);
while (responseProperties.hasMoreElements()) {
@@ -2033,47 +2055,47 @@
if (property instanceof PrincipalCollectionSetProperty) {
set = (PrincipalCollectionSetProperty)property;
}
-
+
}
}
-
+
return set;
}
-
-
-
-
+
+
+
+
/**
* Return the LockDiscoveryProperty for the resource at the given path
* returns null if the server doesn't respond with a LockDiscoveryProperty
*/
public LockDiscoveryProperty lockDiscoveryPropertyFindMethod(String path)
throws HttpException, IOException {
-
+
setClient();
-
+
LockDiscoveryProperty set = null;
-
+
Vector properties = new Vector();
properties.addElement(LockDiscoveryProperty.TAG_NAME);
-
+
// Default depth=0, type=by_name
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path),
DepthSupport.DEPTH_0, properties.elements());
client.executeMethod(method);
-
+
Enumeration responses = method.getResponses();
if (responses.hasMoreElements()) {
ResponseEntity response =
(ResponseEntity) responses.nextElement();
String href = (String) response.getHref();
-
+
// Set status code for this resource.
if ((thisResource == true) && (response.getStatusCode() > 0))
setStatusCode(response.getStatusCode());
thisResource = false;
-
+
Enumeration responseProperties =
method.getResponseProperties(href);
while (responseProperties.hasMoreElements()) {
@@ -2082,14 +2104,14 @@
if (property instanceof LockDiscoveryProperty) {
set = (LockDiscoveryProperty)property;
}
-
+
}
}
-
+
return set;
}
-
-
+
+
/*
* Get InputStream for the GET method.
*
@@ -2099,7 +2121,7 @@
*/
public InputStream getMethodData()
throws HttpException, IOException {
-
+
setClient();
// use disk to save by default
GetMethod method = new GetMethod(httpURL.getPath());
@@ -2110,14 +2132,14 @@
int statusCode = method.getStatusLine().getStatusCode();
setStatusCode(statusCode);
-
- if(statusCode >= 200 && statusCode < 300)
+
+ if(statusCode >= 200 && statusCode < 300)
return method.getResponseBodyAsStream();
else
throw new IOException("Couldn't get file");
}
-
-
+
+
/*
* Get data as a String for the GET method.
*
@@ -2127,7 +2149,7 @@
*/
public String getMethodDataAsString()
throws HttpException, IOException {
-
+
setClient();
GetMethod method = new GetMethod(httpURL.getPath());
method.setUseDisk(useDiskForGet);
@@ -2139,8 +2161,8 @@
return method.getResponseBodyAsString();
}
-
-
+
+
/*
* Execute the GET method for this WebdavResource path.
*
@@ -2151,11 +2173,11 @@
*/
public boolean getMethod(File file)
throws HttpException, IOException {
-
+
return getMethod(httpURL.getPathQuery(), file);
}
-
-
+
+
/*
* Execute the GET method for the given path.
*
@@ -2167,18 +2189,18 @@
*/
public boolean getMethod(String path, File file)
throws HttpException, IOException {
-
+
setClient();
// use disk to save by default
GetMethod method = new GetMethod(HttpURL.getPathQuery(path), file);
method.setUseDisk(true);
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
+
+
/**
* Execute the PUT method for this resource.
*
@@ -2189,7 +2211,7 @@
*/
public boolean putMethod(byte[] data)
throws HttpException, IOException {
-
+
boolean result = putMethod(httpURL.getPathQuery(), data);
if (result) refresh();
return result;
@@ -2207,7 +2229,7 @@
*/
public boolean putMethod(String path, byte[] data)
throws HttpException, IOException {
-
+
setClient();
PutMethod method = new PutMethod(HttpURL.getPathQuery(path));
generateIfHeader(method);
@@ -2215,15 +2237,15 @@
method.setRequestHeader("Content-Type", getGetContentType());
method.setRequestHeader("Content-Length", String.valueOf(data.length));
- method.setRequestBody(data);
+ method.setRequestBody(new ByteArrayInputStream(data));
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
+
+
/**
* Execute the PUT method for this resource.
*
@@ -2234,11 +2256,11 @@
*/
public boolean putMethod(InputStream is)
throws HttpException, IOException {
-
+
return putMethod(httpURL.getPathQuery(), is);
}
-
-
+
+
/**
* Execute the PUT method for the given path.
*
@@ -2250,7 +2272,7 @@
*/
public boolean putMethod(String path, InputStream is)
throws HttpException, IOException {
-
+
setClient();
PutMethod method = new PutMethod(HttpURL.getPathQuery(path));
generateIfHeader(method);
@@ -2258,12 +2280,12 @@
method.setRequestHeader("Content-Type", getGetContentType());
method.setRequestBody(is);
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
+
+
/*
* Execute the PUT method for this WebdavResource.
*
@@ -2274,14 +2296,14 @@
*/
public boolean putMethod(String data)
throws HttpException, IOException {
-
+
boolean result = putMethod(httpURL.getPath(), data);
if (result) refresh();
return result;
}
-
-
+
+
/*
* Execute the PUT method for the given path.
*
@@ -2293,7 +2315,7 @@
*/
public boolean putMethod(String path, String data)
throws HttpException, IOException {
-
+
setClient();
PutMethod method = new PutMethod(HttpURL.getPath(path));
generateIfHeader(method);
@@ -2301,12 +2323,12 @@
method.setRequestHeader("Content-Type", getGetContentType());
method.setRequestBody(data);
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
+
+
/*
* Execute the PUT method for this WebdavResource.
*
@@ -2317,14 +2339,14 @@
*/
public boolean putMethod(File file)
throws HttpException, IOException {
-
+
boolean result = putMethod(httpURL.getPath(), file);
if (result) refresh();
return result;
}
-
-
+
+
/*
* Execute the PUT method for the given path.
*
@@ -2336,21 +2358,21 @@
*/
public boolean putMethod(String path, File file)
throws HttpException, IOException {
-
+
setClient();
PutMethod method = new PutMethod(HttpURL.getPath(path));
generateIfHeader(method);
if(getGetContentType() != null && !getGetContentType().equals(""))
method.setRequestHeader("Content-Type", getGetContentType());
- method.setRequestBody(file);
+ method.setRequestBody(new FileInputStream(file));
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
-
+
+
+
/*
* Execute the PUT method for this resource from the given url.
* It's like a streaming copy about a resource of the specified remote url
@@ -2363,14 +2385,14 @@
*/
public boolean putMethod(URL url)
throws HttpException, IOException {
-
+
boolean result = putMethod(httpURL.getPath(), url);
if (result) refresh();
return result;
}
-
-
+
+
/*
* Execute the PUT method for the given path from the given url.
*
@@ -2382,20 +2404,20 @@
*/
public boolean putMethod(String path, URL url)
throws HttpException, IOException {
-
+
setClient();
PutMethod method = new PutMethod(HttpURL.getPath(path));
generateIfHeader(method);
if(getGetContentType() != null && !getGetContentType().equals(""))
method.setRequestHeader("Content-Type", getGetContentType());
- method.setRequestBody(url);
+ method.setRequestBody(url.openStream());
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
+
+
/*
* Execute OPTIONS method for this WebdavResource.
*
@@ -2405,11 +2427,11 @@
*/
public boolean optionsMethod()
throws HttpException, IOException {
-
+
return optionsMethod(httpURL.getPath());
}
-
-
+
+
/*
* Execute OPTIONS method for the given path.
*
@@ -2421,7 +2443,7 @@
*/
public boolean optionsMethod(String path)
throws HttpException, IOException {
-
+
setClient();
OptionsMethod method;
if (path.trim().equals("*"))
@@ -2429,9 +2451,9 @@
else
method = new OptionsMethod(HttpURL.getPath(path));
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
-
+
if (statusCode >= 200 && statusCode < 300) {
// check if the specific method is possbile
allowedMethods = method.getAllowedMethods();
@@ -2439,11 +2461,11 @@
davCapabilities = method.getDavCapabilities();
return true;
}
-
+
return false;
}
-
-
+
+
/*
* Execute OPTIONS method for the given path.
*
@@ -2455,7 +2477,7 @@
*/
public boolean optionsMethod(String path, String aMethod)
throws HttpException, IOException {
-
+
if (aMethod != null && optionsMethod(httpURL.getPath())) {
while (allowedMethods.hasMoreElements()) {
if (aMethod.equalsIgnoreCase((String)
@@ -2463,11 +2485,11 @@
return true;
}
}
-
+
return false;
}
-
-
+
+
/*
* Execute OPTIONS method for the given http URL.
*
@@ -2478,12 +2500,12 @@
*/
public Enumeration optionsMethod(HttpURL httpURL)
throws HttpException, IOException {
-
+
HttpClient client = getSessionInstance(httpURL, true);
-
+
OptionsMethod method = new OptionsMethod(httpURL.getPath());
client.executeMethod(method);
-
+
Vector options = new Vector();
int statusCode = method.getStatusLine().getStatusCode();
if (statusCode >= 200 && statusCode < 300) {
@@ -2517,11 +2539,11 @@
options.addElement(sResult);
}
}
-
+
return options.elements();
}
-
+
/*
* Execute OPTIONS method for the given http URL, DELTAV
*
@@ -2532,12 +2554,12 @@
*/
public Enumeration optionsMethod(HttpURL httpURL, int type)
throws HttpException, IOException {
-
+
HttpClient client = getSessionInstance(httpURL, true);
-
+
OptionsMethod method = new OptionsMethod(httpURL.getPath(), type);
client.executeMethod(method);
-
+
Vector options = new Vector();
int statusCode = method.getStatusLine().getStatusCode();
if (statusCode >= 200 && statusCode < 300) {
@@ -2565,11 +2587,11 @@
// options.addElement(sResult);
}
}
-
+
return options.elements();
}
-
+
/*
* Execute OPTIONS method for the given path.
*
@@ -2581,11 +2603,11 @@
*/
public Enumeration optionsMethod(String path, int type)
throws HttpException, IOException {
-
+
return optionsMethod(HttpURL.getPath(path),type);
}
- /**
+ /**
* Execute a LABEL method on the current path, setting the given label
*/
public boolean labelMethod(String labelname, int type)
@@ -2610,7 +2632,7 @@
labelname);
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
@@ -2619,7 +2641,7 @@
* Execute the REPORT method.
*/
public Enumeration reportMethod(HttpURL httpURL, int depth)
-
+
throws HttpException, IOException {
setClient();
// Default depth=0, type=by_name
@@ -2645,7 +2667,7 @@
Property property = (Property) responseProperties.nextElement();
sResult += "\n" + property.getName() + ":\t" +
DOMUtils.getTextValue(property.getElement());
-
+
}
results.addElement(sResult);
}
@@ -2654,21 +2676,21 @@
}
public Enumeration reportMethod(HttpURL httpURL, Vector properties)
-
+
throws HttpException, IOException {
setClient();
// Default depth=0, type=by_name
ReportMethod method =
- new ReportMethod(httpURL.getPath(), DepthSupport.DEPTH_0,
+ new ReportMethod(httpURL.getPath(), DepthSupport.DEPTH_0,
properties.elements());
client.executeMethod(method);
return method.getResponses();
}
-
+
public Enumeration reportMethod(HttpURL httpURL, Vector properties,
int depth)
-
+
throws HttpException, IOException {
setClient();
// Default depth=0, type=by_name
@@ -2678,15 +2700,15 @@
/*first draft, does work anyhow
Enumeration results = method.getAllResponseURLs();
-
+
return results;*/
/* Enumeration responses = method.getResponses();
ResponseEntity response = (ResponseEntity) responses.nextElement();
String href = (String) response.getHref();
Enumeration results = method.getResponseProperties(href);
-
+
return results;*/
-
+
Vector results = new Vector();
Enumeration responses = method.getResponses();
@@ -2717,7 +2739,7 @@
// locate-by-history Report
public Enumeration reportMethod(HttpURL httpURL, Vector properties,
Vector histUri, int depth)
-
+
throws HttpException, IOException {
setClient();
// Default depth=0, type=by_name
@@ -2725,7 +2747,7 @@
new ReportMethod(httpURL.getPath(), depth, properties.elements(),
histUri.elements());
client.executeMethod(method);
-
+
Vector results = new Vector();
Enumeration responses = method.getResponses();
@@ -2752,7 +2774,7 @@
}
// expand-property Report
public Enumeration reportMethod(HttpURL httpURL, String sQuery, int depth)
-
+
throws HttpException, IOException {
setClient();
// Default depth=0, type=by_name
@@ -2777,7 +2799,7 @@
/*while (responseProperties.hasMoreElements()) {
Property property = (Property) responseProperties.nextElement();
sResult += "\t" + DOMUtils.getTextValue(property.getElement());
-
+
}*/
results.addElement(sResult);
}
@@ -2785,7 +2807,7 @@
return results.elements();
}
-
+
/*
* Execute PROPFIND method with allprop for this WebdavResource.
* Get list of all WebDAV properties on this WebDAV resource.
@@ -2803,12 +2825,12 @@
*/
public Enumeration propfindMethod(int depth)
throws HttpException, IOException {
-
+
thisResource = true;
return propfindMethod(httpURL.getPath(), depth);
}
-
-
+
+
/*
* Execute PROPFIND method with allprop for the given path.
* Get list of all WebDAV properties on the given resource.
@@ -2827,7 +2849,7 @@
*/
public Enumeration propfindMethod(String path, int depth)
throws HttpException, IOException {
-
+
setClient();
// Change the depth for allprop
PropFindMethod method =
@@ -2845,12 +2867,12 @@
throw ex;
}
thisResource = false;
-
+
return method.getResponses();
}
-
-
-
+
+
+
/*
* Execute PROPFIND method with by propname for theis resource.
* Get list of named WebDAV properties on this resource.
@@ -2869,12 +2891,12 @@
*/
public Enumeration propfindMethod(int depth, Vector properties)
throws HttpException, IOException {
-
+
thisResource = true;
return propfindMethod(httpURL.getPath(), depth, properties);
}
-
-
+
+
/*
* Execute PROPFIND method with by propname for the given path.
* Get list of named WebDAV properties on the given resource.
@@ -2895,14 +2917,14 @@
public Enumeration propfindMethod(String path, int depth,
Vector properties)
throws HttpException, IOException {
-
+
setClient();
// Change the depth for prop
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path), depth,
properties.elements());
int status = client.executeMethod(method);
-
+
// Set status code for this resource.
if (thisResource == true) {
// Set the status code.
@@ -2914,11 +2936,11 @@
throw ex;
}
thisResource = false;
-
+
return method.getResponses();
}
-
-
+
+
/*
* Execute PROPFIND method for this WebdavResource.
* Get list of given WebDAV properties on this WebDAV resource.
@@ -2930,15 +2952,15 @@
*/
public Enumeration propfindMethod(String propertyName)
throws HttpException, IOException {
-
+
Vector property = new Vector();
property.addElement(propertyName);
-
+
thisResource = true;
return propfindMethod(httpURL.getPath(), property);
}
-
-
+
+
/*
* Execute PROPFIND method for the given WebdavResource path.
* Get list of given WebDAV properties on this WebDAV resource.
@@ -2950,15 +2972,15 @@
*/
public Enumeration propfindMethod(String path, String propertyName)
throws HttpException, IOException {
-
+
Vector property = new Vector();
property.addElement(propertyName);
-
+
thisResource = false;
return propfindMethod(HttpURL.getPath(path), property);
}
-
-
+
+
/*
* Execute PROPFIND method for this WebdavResource.
* Get list of given WebDAV properties on this WebDAV resource.
@@ -2970,12 +2992,12 @@
*/
public Enumeration propfindMethod(Vector properties)
throws HttpException, IOException {
-
+
thisResource = true;
return propfindMethod(httpURL.getPath(), properties);
}
-
-
+
+
/*
* Execute PROPFIND method for the given path and properties.
* Get list of given WebDAV properties on the given resource.
@@ -2988,14 +3010,14 @@
*/
public Enumeration propfindMethod(String path, Vector properties)
throws HttpException, IOException {
-
+
setClient();
// Default depth=0, type=by_name
PropFindMethod method =
new PropFindMethod(HttpURL.getPath(path), DepthSupport.DEPTH_0,
properties.elements());
int status = client.executeMethod(method);
-
+
if (status != HttpStatus.SC_MULTI_STATUS) {
HttpException ex = new HttpException();
ex.setReasonCode(status);
@@ -3004,18 +3026,18 @@
// It contains the results.
Vector results = new Vector();
-
+
Enumeration responses = method.getResponses();
if (responses.hasMoreElements()) {
ResponseEntity response =
(ResponseEntity) responses.nextElement();
String href = (String) response.getHref();
-
+
// Set status code for this resource.
if ((thisResource == true) && (response.getStatusCode() > 0))
setStatusCode(response.getStatusCode());
thisResource = false;
-
+
Enumeration responseProperties =
method.getResponseProperties(href);
while (responseProperties.hasMoreElements()) {
@@ -3024,11 +3046,11 @@
results.addElement(property.getPropertyAsString());
}
}
-
+
return results.elements();
}
-
-
+
+
/*
* Execute PROPATCH method for this WebdavResource.
*
@@ -3041,7 +3063,7 @@
*/
public boolean proppatchMethod(String propertyName, String propertyValue)
throws HttpException, IOException {
-
+
boolean result = proppatchMethod(httpURL.getPath(),
propertyName, propertyValue, true);
if (result) refresh();
@@ -3049,7 +3071,7 @@
return result;
}
-
+
/*
* Execute PROPATCH method for this resource with the given property.
*
@@ -3063,14 +3085,14 @@
*/
public boolean proppatchMethod(String propertyName, String propertyValue,
boolean action) throws HttpException, IOException {
-
+
boolean result = proppatchMethod(httpURL.getPath(),
propertyName, propertyValue, action);
if (result) refresh();
return result;
}
-
+
/*
* Execute PROPATCH method for this WebdavResource.
@@ -3093,7 +3115,7 @@
return result;
}
-
+
/*
* Execute PROPATCH method for this resource with the given property.
*
@@ -3115,8 +3137,8 @@
return result;
}
-
-
+
+
/*
* Execute PROPATCH method for the given WebdavResource.
*
@@ -3135,7 +3157,7 @@
property.put(propertyName, propertyValue);
return proppatchMethod(path, property, true);
}
-
+
/*
* Execute PROPATCH method for the specific resource with the given
@@ -3158,7 +3180,7 @@
property.put(propertyName, propertyValue);
return proppatchMethod(path, property, action);
}
-
+
/*
* Execute PROPATCH method for the given WebdavResource.
@@ -3173,14 +3195,14 @@
*/
public boolean proppatchMethod(String path, PropertyName propertyName,
String propertyValue) throws HttpException, IOException {
-
+
Hashtable property = new Hashtable();
property.put(propertyName, propertyValue);
-
+
return proppatchMethod(path, property, true);
}
-
-
+
+
/**
* Execute PROPATCH method for the geven resource with the given properties.
*
@@ -3201,7 +3223,7 @@
property.put(propertyName, propertyValue);
return proppatchMethod(path, property, action);
}
-
+
/*
* Execute PROPATCH method for this WebdavResource.
@@ -3215,13 +3237,13 @@
*/
public boolean proppatchMethod(Hashtable properties)
throws HttpException, IOException {
-
+
boolean result = proppatchMethod(httpURL.getPath(), properties, true);
if (result) refresh();
return result;
}
-
+
/*
* Execute PROPATCH method for this resource with the given properties.
@@ -3242,7 +3264,7 @@
return result;
}
-
+
/*
* Execute PROPATCH method for the given WebdavResource.
@@ -3261,7 +3283,7 @@
return proppatchMethod(path, properties, true);
}
-
+
/*
* Execute PROPATCH method for the specific resource with the given
* properties.
@@ -3277,7 +3299,7 @@
*/
public boolean proppatchMethod(String path, Hashtable properties,
boolean action) throws HttpException, IOException {
-
+
setClient();
PropPatchMethod method = new PropPatchMethod(HttpURL.getPath(path));
generateIfHeader(method);
@@ -3320,8 +3342,8 @@
}
return false;
}
-
-
+
+
/*
* Execute the HEAD method for this WebdavResource.
*
@@ -3331,11 +3353,11 @@
*/
public boolean headMethod()
throws HttpException, IOException {
-
+
return headMethod(httpURL.getPath());
}
-
-
+
+
/*
* Execute the HEAD method for the given path.
*
@@ -3346,16 +3368,16 @@
*/
public boolean headMethod(String path)
throws HttpException, IOException {
-
+
setClient();
HeadMethod method = new HeadMethod(HttpURL.getPath(path));
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
+
+
/*
* Execute the DELETE method for this WebdavResource.
*
@@ -3365,14 +3387,14 @@
*/
public boolean deleteMethod()
throws HttpException, IOException {
-
+
boolean result = deleteMethod(httpURL.getPath());
if (result) refresh();
return result;
}
-
-
+
+
/*
* Execute the DELETE method for the given path.
*
@@ -3383,17 +3405,17 @@
*/
public boolean deleteMethod(String path)
throws HttpException, IOException {
-
+
setClient();
DeleteMethod method = new DeleteMethod(HttpURL.getPath(path));
generateIfHeader(method);
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
+
+
/*
* Execute the MOVE method for this WebdavReource.
*
@@ -3404,15 +3426,15 @@
*/
public boolean moveMethod(String destination)
throws HttpException, IOException {
-
+
boolean result = moveMethod(httpURL.getPath(),
HttpURL.getPath(destination));
if (result) refresh();
return result;
}
-
-
+
+
/*
* Execute the MOVE method the given source and destination.
*
@@ -3424,21 +3446,21 @@
*/
public boolean moveMethod(String source, String destination)
throws HttpException, IOException {
-
+
setClient();
MoveMethod method = new MoveMethod(source, destination);
generateIfHeader(method);
method.setOverwrite(overwrite);
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
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
+
+
/*
* Execute the COPY method for the given destination path.
*
@@ -3449,15 +3471,15 @@
*/
public boolean copyMethod(String destination)
throws HttpException, IOException {
-
+
boolean result = copyMethod(httpURL.getPath(),
HttpURL.getPath(destination));
if (result) refresh();
return result;
}
-
-
+
+
/*
* Execute the COPY method the given source and destination.
*
@@ -3469,22 +3491,22 @@
*/
public boolean copyMethod(String source, String destination)
throws HttpException, IOException {
-
+
setClient();
CopyMethod method = new CopyMethod(source, destination);
generateIfHeader(method);
method.setOverwrite(overwrite);
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
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
-
+
+
+
/*
* Execute the MKCOL method for this WebdavResource.
*
@@ -3494,14 +3516,14 @@
*/
public boolean mkcolMethod()
throws HttpException, IOException {
-
+
boolean result = mkcolMethod(httpURL.getPath());
if (result) refresh();
return result;
}
-
-
+
+
/*
* Execute the MKCOL method for the given path.
*
@@ -3512,20 +3534,20 @@
*/
public boolean mkcolMethod(String path)
throws HttpException, IOException {
-
+
setClient();
MkcolMethod method = new MkcolMethod(HttpURL.getPath(path));
generateIfHeader(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
setStatusCode(statusCode);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
+
+
/*
* Execute the LOCK method for this WebdavResource.
*
@@ -3535,18 +3557,18 @@
*/
public boolean lockMethod()
throws HttpException, IOException {
-
+
String owner = (httpURL.getUserName() != null) ?
httpURL.getUserName() : defaultOwner;
-
+
boolean result = lockMethod(httpURL.getPath(), owner, 120);
if (result) refresh();
return result;
}
-
-
-
+
+
+
/*
* Execute the LOCK method for this WebdavResource.
*
@@ -3558,14 +3580,14 @@
*/
public boolean lockMethod(String owner, int timeout)
throws HttpException, IOException {
-
+
boolean result = lockMethod(httpURL.getPath(), owner, timeout);
if (result) refresh();
return result;
}
-
-
+
+
/*
* Execute the LOCK method for the given path.
*
@@ -3576,14 +3598,14 @@
*/
public boolean lockMethod(String path)
throws HttpException, IOException {
-
+
String owner = (httpURL.getUserName() != null) ?
httpURL.getUserName() : defaultOwner;
-
+
return lockMethod(path, owner, 120);
}
-
-
+
+
/*
* Execute the LOCK method for the given path.
*
@@ -3596,7 +3618,7 @@
*/
public boolean lockMethod(String path, String owner, int timeout)
throws HttpException, IOException {
-
+
setClient();
// default lock type setting
short lockType = LockMethod.SCOPE_EXCLUSIVE;
@@ -3610,14 +3632,14 @@
state.addLock(path, lock);
}
this.owner = method.getOwner();
-
+
// Possbile LOCK Status Codes => SC_OK
// WebdavStatus.SC_SC_PRECONDITION_FAILED, SC_LOCKED
setStatusCode(statusCode, lock);
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
+
/*
* Execute the LOCK method for this WebdavResource.
@@ -3642,9 +3664,9 @@
throws HttpException, IOException {
return lockMethod(path, owner, (int) timeout);
- }
+ }
+
-
/*
* Execute the Unlock method for this WebdavResource.
*
@@ -3653,7 +3675,7 @@
* @exception IOException
*/
public boolean unlockMethod() throws HttpException, IOException {
-
+
String owner = (httpURL.getUserName() != null) ?
httpURL.getUserName() : defaultOwner;
@@ -3662,8 +3684,8 @@
return result;
}
-
-
+
+
/*
* Execute the Unlock method with the given owner.
*
@@ -3692,7 +3714,7 @@
*/
public boolean unlockMethod(String path, String owner)
throws HttpException, IOException {
-
+
setClient();
// Get the lock for the given path.
WebdavState state = (WebdavState) client.getState();
@@ -3707,16 +3729,16 @@
generateIfHeader(method);
method.setLockToken(lock);
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
if (statusCode >= 200 && statusCode < 300) {
state.removeLocks(path);
return true;
}
-
+
return false;
}
-
+
/**
* Discover the given owner and locktoken and set the locktoken
@@ -3778,17 +3800,17 @@
setStatusCode(statusCode);
- return (statusCode >= 200 && statusCode < 300) ? true : false;
+ return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
+
public boolean versionControlMethod(String path)
throws HttpException, IOException {
setClient();
// Check the given path is alright.
path = HttpURL.getPath(path);
-
+
VersionControlMethod method = new VersionControlMethod(path);
generateIfHeader(method);
int statusCode = client.executeMethod(method);
@@ -3798,14 +3820,14 @@
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
+
public boolean versionControlMethod(String path, String target)
throws HttpException, IOException {
setClient();
// Check the given path is alright.
path = HttpURL.getPath(path);
-
+
VersionControlMethod method = new VersionControlMethod(path, target);
generateIfHeader(method);
int statusCode = client.executeMethod(method);
@@ -3815,7 +3837,7 @@
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
+
/*
* Execute the MKCOL method for this WebdavResource.
*
@@ -3825,14 +3847,14 @@
*/
public boolean mkWorkspaceMethod()
throws HttpException, IOException {
-
+
boolean result = mkWorkspaceMethod(httpURL.getPath());
if (result) refresh();
return result;
}
-
-
+
+
/*
* Execute the MKCOL method for the given path.
*
@@ -3843,25 +3865,25 @@
*/
public boolean mkWorkspaceMethod(String path)
throws HttpException, IOException {
-
+
setClient();
MkWorkspaceMethod method = new MkWorkspaceMethod(HttpURL.getPath(path));
generateIfHeader(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
-
+
setStatusCode(statusCode);
-
+
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
-
+
+
// -------------------------------------------------------- Basic Methods
-
-
+
+
/*
* Compare to the WebdavResource object.
*
@@ -3869,38 +3891,38 @@
* @return the value 0 if the argument is equal.
*/
public int compareToWebdavResource(WebdavResource another) {
-
+
try {
HttpURL anotherUrl = another.getHttpURL();
-
+
String thisHost = httpURL.getHost();
String anotherHost= anotherUrl.getHost();
if (!thisHost.equalsIgnoreCase(anotherHost))
return thisHost.compareTo(anotherHost);
-
+
int thisPort = httpURL.getPort();
int anotherPort= anotherUrl.getPort();
if (thisPort != anotherPort)
return (thisPort < anotherPort) ? -1 : 1;
-
+
boolean thisCollection = isCollection();
boolean anotherCollection = another.isCollection();
if (thisCollection && !anotherCollection)
return -1;
if (anotherCollection && !thisCollection)
return 1;
-
+
String thisPath = httpURL.getPathQuery();
String anotherPath= anotherUrl.getPathQuery();
return thisPath.compareTo(anotherPath);
} catch (Exception e) {
// FIXME: not to return 0.
}
-
+
return 0;
}
-
-
+
+
/**
* Compare to the given another object.
*
@@ -3908,18 +3930,18 @@
* @return the value 0 if another is equal.
*/
public int compareTo(Object another) {
-
+
if ((another != null) && (another instanceof WebdavResource)) {
return compareToWebdavResource((WebdavResource) another);
}
-
+
String thisUrl = toString();
String anotherUrl = another.toString();
-
+
return thisUrl.compareTo(anotherUrl);
}
-
-
+
+
/**
* Test the object.
*
@@ -3927,14 +3949,14 @@
* @return true if it's equal.
*/
public boolean equals(Object obj) {
-
+
if ((obj != null) && (obj instanceof WebdavResource)) {
return compareTo(obj) == 0;
}
return false;
}
-
-
+
+
/**
* Return the http URL string.
*
@@ -4032,7 +4054,7 @@
-
+
/*
* Execute the CHECKOUT method for the given path.
*
@@ -4043,14 +4065,14 @@
*/
public boolean uncheckoutMethod(String path)
throws HttpException, IOException {
-
+
setClient();
UncheckoutMethod method = new UncheckoutMethod(HttpURL.getPath(path));
generateIfHeader(method);
int statusCode = client.executeMethod(method);
-
+
setStatusCode(statusCode);
-
+
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org