jericho 01/03/06 05:27:53
Modified: src/webdav/client/src/org/apache/webdav/util
WebdavResource.java
Log:
- Fix the session to be saved.
- Fix the current properties to be set.
- Fix the compareTo method.
Revision Changes Path
1.10 +69 -34
jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java
Index: WebdavResource.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- WebdavResource.java 2001/03/06 12:51:42 1.9
+++ WebdavResource.java 2001/03/06 13:27:52 1.10
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.9 2001/03/06 12:51:42 jericho Exp $
- * $Revision: 1.9 $
- * $Date: 2001/03/06 12:51:42 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.10 2001/03/06 13:27:52 jericho Exp $
+ * $Revision: 1.10 $
+ * $Date: 2001/03/06 13:27:52 $
*
* ====================================================================
*
@@ -497,10 +497,15 @@
*
* @see #getUsed()
* @see #setUnused()
+ * @exception MalformedURLException
*/
- private void setUsed() {
+ private void setUsed() throws MalformedURLException {
httpUrlChecked = httpUrl.toString();
+ // Save the current session.
+ if (client != null)
+ clients.setSession(httpUrl, client);
+ client = null;
}
@@ -569,55 +574,86 @@
// ------------------------------ Checking WebDAV properties
if (property.getLocalName().equals(DISPLAYNAME)) {
- displayName = property.getPropertyAsString();
- if (!itself)
+ String displayName =
property.getPropertyAsString();
+ if (!itself) {
hrefProperties.put(DISPLAYNAME, displayName);
+ } else {
+ this.displayName = displayName;
+ }
} else
if (property.getLocalName().equals(GETCONTENTLENGTH)) {
- getContentLength =
property.getPropertyAsString();
- if (!itself)
+ String getContentLength =
property.getPropertyAsString();
+ if (!itself) {
hrefProperties.put
(GETCONTENTLENGTH, getContentLength);
+ } else {
+ this.getContentLength = getContentLength;
+ }
} else
if (property.getLocalName().equals(RESOURCETYPE)) {
- resourceType = (ResourceTypeProperty) property;
- if (!itself)
+ ResourceTypeProperty resourceType =
+ (ResourceTypeProperty) property;
+ if (!itself) {
hrefProperties.put(RESOURCETYPE, resourceType);
+ } else {
+ this.resourceType = resourceType;
+ }
} else
if (property.getLocalName().equals(GETCONTENTTYPE)) {
- getContentType =
property.getPropertyAsString();
- if (!itself)
+ String getContentType =
property.getPropertyAsString();
+ if (!itself) {
hrefProperties.put(GETCONTENTTYPE, getContentType);
+ } else {
+ this.getContentType = getContentType;
+ }
} else
if (property.getLocalName().equals(GETLASTMODIFIED)) {
- getLastModified = property.getPropertyAsString();
- if (!itself)
+ String getLastModified = property.getPropertyAsString();
+ if (!itself) {
hrefProperties.put(GETLASTMODIFIED, getLastModified);
+ } else {
+ this.getLastModified = getLastModified;
+ }
} else
if (property.getLocalName().equals(CREATIONDATE)) {
- creationDate = property.getPropertyAsString();
- if (!itself)
+ String creationDate =
property.getPropertyAsString();
+ if (!itself) {
hrefProperties.put(CREATIONDATE, creationDate);
+ } else {
+ this.creationDate = creationDate;
+ }
} else
if (property.getLocalName().equals(GETETAG)) {
- getEtag = property.getPropertyAsString();
- if (!itself)
+ String getEtag =
property.getPropertyAsString();
+ if (!itself) {
hrefProperties.put(GETETAG, getEtag);
+ } else {
+ this.getEtag = getEtag;
+ }
} else
if (property.getLocalName().equals(ISHIDDEN)) {
- isHidden= property.getPropertyAsString();
- if (!itself)
+ String isHidden =
property.getPropertyAsString();
+ if (!itself) {
hrefProperties.put(ISHIDDEN, isHidden);
+ } else {
+ this.isHidden = isHidden;
+ }
} else
if (property.getLocalName().equals(ISCOLLECTION)) {
- isCollection = property.getPropertyAsString();
- if (!itself)
+ String isCollection =
property.getPropertyAsString();
+ if (!itself) {
hrefProperties.put(ISCOLLECTION, isCollection);
+ } else {
+ this.isCollection = isCollection;
+ }
} else
if (property.getLocalName().equals(SUPPORTEDLOCK)) {
- supportedLock = property.getPropertyAsString();
- if (!itself)
+ String supportedLock =
property.getPropertyAsString();
+ if (!itself) {
hrefProperties.put(SUPPORTEDLOCK, supportedLock);
+ } else {
+ this.supportedLock = supportedLock;
+ }
}
}
if (!itself)
@@ -1345,6 +1381,8 @@
// Set the status code.
setStatusCode(method.getStatusCode());
+ // In order to save this session.
+ this.client = client;
return method.getResponses();
}
@@ -1939,19 +1977,14 @@
public int compareToWebdavResource(WebdavResource another) {
try {
+ URL anotherUrl = another.getURL();
String thisHost = httpUrl.getHost();
- String anotherHost= another.httpUrl.getHost();
- if (thisHost == null)
- thisHost = "";
- if (anotherHost == null)
- anotherHost = "";
+ String anotherHost= anotherUrl.getHost();
if (!thisHost.equalsIgnoreCase(anotherHost))
return thisHost.compareTo(anotherHost);
int thisPort = httpUrl.getPort();
- int anotherPort= another.httpUrl.getPort();
- if (thisPort == -1)
- thisPort = 80;
+ int anotherPort= anotherUrl.getPort();
if (anotherPort == -1)
anotherPort = 80;
if (thisPort != anotherPort)
@@ -1964,8 +1997,10 @@
if (anotherCollection && !thisCollection)
return 1;
- String thisPath = this.httpUrl.getPath();
- String anotherPath= httpUrl.getPath();
+ String thisPath = httpUrl.getPath();
+ String anotherPath= anotherUrl.getFile();
+ if (anotherPath == null)
+ anotherPath = "/";
return thisPath.compareTo(anotherPath);
// TODO: consider of more dead properties?