msmith 02/02/07 20:24:06
Modified: src/contrib/webdavgui/src/java/org/apache/webdav/ui
SPWebdavClient.java
src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser
SPFileChooser.java SPFileFilter.java
src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir
SPDirectoryService.java SPFile.java
SPResourceNode.java SPWebFile.java SPWebFolder.java
src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods
SPLockMethod.java SPPropFindMethod.java
SPPutMethod.java SPUnlockMethod.java
src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties
SPProperty.java
Removed: src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties
WebdavProperty.java
Log:
Fairly major changes to make filechooser more intelligent in use of webdav
(to avoid extra webdav requests, which are potentially slow over a slow
network).
Revision Changes Path
1.2 +0 -17
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/SPWebdavClient.java
Index: SPWebdavClient.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/SPWebdavClient.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SPWebdavClient.java 17 Jul 2001 04:00:45 -0000 1.1
+++ SPWebdavClient.java 8 Feb 2002 04:24:05 -0000 1.2
@@ -6,7 +6,6 @@
import org.apache.webdav.ui.lib.properties.*;
import org.apache.webdav.lib.methods.*;
-import org.apache.webdav.ui.util.SPUtils;
import org.apache.commons.httpclient.*;
@@ -25,22 +24,6 @@
public String getSessionPort() {
return String.valueOf(this.sessionPort);
- }
-
- public Credentials getCredentials() {
- return credentials;
- }
-
- public String getLockToken(String uri) {
- String lockToken = null;
-
- LockdiscoveryProperty lockdiscoveryProp =
- (LockdiscoveryProperty) SPUtils.getProperty(this, uri, "lockdiscovery");
- if (lockdiscoveryProp != null) {
- lockToken = lockdiscoveryProp.getLockToken(credentials.getUserName());
- }
-
- return lockToken;
}
} //End of SPWebdavClient class
1.4 +5 -4
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java
Index: SPFileChooser.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SPFileChooser.java 4 Feb 2002 23:49:13 -0000 1.3
+++ SPFileChooser.java 8 Feb 2002 04:24:05 -0000 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java,v
1.3 2002/02/04 23:49:13 msmith Exp $
- * $Revision: 1.3 $
- * $Date: 2002/02/04 23:49:13 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileChooser.java,v
1.4 2002/02/08 04:24:05 msmith Exp $
+ * $Revision: 1.4 $
+ * $Date: 2002/02/08 04:24:05 $
*
* ====================================================================
*
@@ -113,7 +113,8 @@
String rootUrlPath, SPDirectoryService service) throws Exception {
try {
- directoryService = service;
+ directoryService = (service==null)?(new SPDirectoryService(
+ client, rootUrlPath)):service;
SPFileSystemView fileSystemView =
new SPFileSystemView(directoryService);
SPFileChooser fileChooser = new SPFileChooser(fileSystemView);
1.3 +3 -4
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileFilter.java
Index: SPFileFilter.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SPFileFilter.java 17 Jul 2001 04:00:46 -0000 1.2
+++ SPFileFilter.java 8 Feb 2002 04:24:05 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileFilter.java,v
1.2 2001/07/17 04:00:46 msmith Exp $
- * $Revision: 1.2 $
- * $Date: 2001/07/17 04:00:46 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/SPFileFilter.java,v
1.3 2002/02/08 04:24:05 msmith Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/02/08 04:24:05 $
*
* ====================================================================
*
@@ -69,7 +69,6 @@
import javax.swing.filechooser.FileFilter;
import org.apache.webdav.ui.filechooser.dir.SPFile;
-import org.apache.webdav.ui.util.SPUtils;
/**
* Title: SPFileFilter.java
1.4 +3 -4
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPDirectoryService.java
Index: SPDirectoryService.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPDirectoryService.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SPDirectoryService.java 18 Oct 2001 00:15:00 -0000 1.3
+++ SPDirectoryService.java 8 Feb 2002 04:24:05 -0000 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPDirectoryService.java,v
1.3 2001/10/18 00:15:00 msmith Exp $
- * $Revision: 1.3 $
- * $Date: 2001/10/18 00:15:00 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPDirectoryService.java,v
1.4 2002/02/08 04:24:05 msmith Exp $
+ * $Revision: 1.4 $
+ * $Date: 2002/02/08 04:24:05 $
*
* ====================================================================
*
@@ -69,7 +69,6 @@
import org.apache.webdav.lib.*;
import org.apache.webdav.ui.lib.methods.SPPropFindMethod;
-import org.apache.webdav.ui.util.SPUtils;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
1.5 +22 -13
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java
Index: SPFile.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SPFile.java 4 Feb 2002 23:49:13 -0000 1.4
+++ SPFile.java 8 Feb 2002 04:24:05 -0000 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java,v
1.4 2002/02/04 23:49:13 msmith Exp $
- * $Revision: 1.4 $
- * $Date: 2002/02/04 23:49:13 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPFile.java,v
1.5 2002/02/08 04:24:05 msmith Exp $
+ * $Revision: 1.5 $
+ * $Date: 2002/02/08 04:24:05 $
*
* ====================================================================
*
@@ -69,7 +69,6 @@
import org.apache.webdav.lib.*;
import org.apache.webdav.lib.properties.*;
-import org.apache.webdav.ui.util.SPUtils;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
@@ -167,12 +166,16 @@
return getResourceNode().isLocked();
}
- public boolean isReadOnly() {
- return getResourceNode().isReadOnly();
+ public boolean isLockedByOthers() {
+ return getResourceNode().isLockedByOthers();
+ }
+
+ public boolean isLockedByOthersNotCached() {
+ return getResourceNode().isLockedByOthersNotCached();
}
public boolean getReadOnlyCached() {
- return getResourceNode().getReadOnlyCached();
+ return !getResourceNode().hasWriteAccess();
}
public boolean hasReadAccess() {
@@ -220,9 +223,10 @@
if (directoryService!=null)
return new SPFile(absPath, directoryService);
- else
- return new SPFile(absPath,
- SPUtils.getSPResourceNode(_resourceNode.getClient(), absPath));
+ else {
+ System.err.println("ERRPR: Getting parent _without_ directoryService, can't
do this at the moment!");
+ return null;
+ }
}
/*
@@ -235,8 +239,8 @@
public long getContentLength() {
GetContentLengthProperty prop = (GetContentLengthProperty)
- SPUtils.getProperty(getResourceNode(), "getcontentlength");
- return prop.getLength();
+ getResourceNode().getProperty("getcontentlength");
+ return prop.getLength();
}
/*
@@ -406,7 +410,12 @@
}
private String getExtension() {
- return SPUtils.getExtension(getName());
+ int i = getName().lastIndexOf(".");
+
+ if (i > 0 && i < getName().length() - 1)
+ return getName().substring(i+1).toLowerCase();
+ else
+ return null;
}
} //End of SPFile class
1.3 +375 -63
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPResourceNode.java
Index: SPResourceNode.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPResourceNode.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SPResourceNode.java 17 Jul 2001 04:00:47 -0000 1.2
+++ SPResourceNode.java 8 Feb 2002 04:24:05 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPResourceNode.java,v
1.2 2001/07/17 04:00:47 msmith Exp $
- * $Revision: 1.2 $
- * $Date: 2001/07/17 04:00:47 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPResourceNode.java,v
1.3 2002/02/08 04:24:05 msmith Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/02/08 04:24:05 $
*
* ====================================================================
*
@@ -64,12 +64,24 @@
package org.apache.webdav.ui.filechooser.dir;
import java.util.List;
+import java.util.Vector;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.io.IOException;
+
+import javax.swing.JOptionPane;
import org.apache.webdav.ui.lib.properties.*;
import org.apache.webdav.lib.*;
-import org.apache.webdav.ui.util.SPUtils;
+import org.apache.webdav.lib.methods.DepthSupport;
+import org.apache.webdav.ui.lib.methods.SPLockMethod;
+import org.apache.webdav.ui.lib.methods.SPUnlockMethod;
+import org.apache.webdav.ui.lib.methods.SPPropFindMethod;
+import org.apache.webdav.ui.lib.methods.SPPropPatchMethod;
+import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
/**
* Title: SPResourceNode.java
@@ -87,20 +99,42 @@
protected HttpClient client;
protected String resourceUrlPath=null;
protected String name=null;
+ protected String lockToken = null;
+
+ protected Hashtable cachedProperties = new Hashtable();
- /* readAccess and writeAccess fields are this node's access privilege.
- *
- * readOnlyCached is a cache for this node's read only mode. This field
- * is used by SPFileChooser when refreshing the content of a folder.
- * When a current state of read only mode is desired, the user must call
- * the isReadOnly() instead.
- */
- protected boolean readAccess=false, writeAccess=false,
- readOnlyCached=false, accessPrivilegeChecked=false;
protected SPWebFolder parentNode=null;
public abstract List getChildren();
+ public void addCachedProperties(Enumeration props, Vector propnames) {
+ while(props.hasMoreElements())
+ {
+ Property prop = (Property)props.nextElement();
+
+ SPProperty spProp = SPProperty.factory(prop);
+
+ System.err.println("Caching property "+spProp.getName());
+ cachedProperties.put(spProp.getName(),
+ new PropertiesCacheEntry(spProp));
+ propnames.remove(spProp.getName());
+ }
+
+ /* Ok. Now propnames contains those propnames which did NOT have
+ * corresponding properties in the enumeration. This occurs if the
+ * property was requested in the PROPFIND, but didn't exist.
+ * Since we _have_ checked for it, though, we want to explicitly
+ * cache the fact that it doesn't exist.
+ */
+ Enumeration nullProps = propnames.elements();
+
+ while(nullProps.hasMoreElements()) {
+ String propname = (String)nullProps.nextElement();
+ cachedProperties.put(propname, new PropertiesCacheEntry(null));
+ System.err.println("Caching absence of property "+propname);
+ }
+ }
+
public String getName() {
return name;
}
@@ -109,18 +143,35 @@
this.name = newName;
}
- public void setReadOnlyCached(boolean b) {
- this.readOnlyCached = b;
- }
-
- public boolean getReadOnlyCached() {
- return readOnlyCached;
+ public boolean isLockedByOthers() {
+ if(lockToken != null)
+ return false;
+
+ LockdiscoveryProperty prop = (LockdiscoveryProperty)getProperty(
+ "lockdiscovery");
+ if(prop != null && prop.getActiveLock(
+ getClient().getCredentials().getUserName()) == null) {
+ return true;
+ }
+ else
+ return false;
}
public SPResourceNode getParent() {
if (parentNode == null) {
- parentNode = new SPWebFolder(client,
- SPUtils.getParentUrl(resourceUrlPath));
+ String parentUrlPath = resourceUrlPath;
+
+ if(!parentUrlPath.startsWith("/"))
+ parentUrlPath = "/" + parentUrlPath;
+
+ if(parentUrlPath.length() > 1) {
+ if(parentUrlPath.endsWith("/"))
+ parentUrlPath = parentUrlPath.substring(
+ 0, parentUrlPath.length()-1);
+ parentUrlPath = parentUrlPath.substring(
+ 0, parentUrlPath.lastIndexOf("/") + 1);
+ }
+ parentNode = new SPWebFolder(client, parentUrlPath);
}
return parentNode;
}
@@ -146,86 +197,293 @@
}
public boolean isLocked() {
- return SPUtils.isLocked(this);
- }
-
- public boolean isReadOnly() {
- return SPUtils.isReadOnly(this);
+ LockdiscoveryProperty prop = (LockdiscoveryProperty)getProperty(
+ "lockdiscovery");
+ return prop!=null;
+ }
+
+ public boolean isLockedByOthersNotCached() {
+ if(lockToken != null) {
+ return false;
+ }
+ LockdiscoveryProperty prop = (LockdiscoveryProperty)getProperty(
+ "lockdiscovery", true);
+ if(prop != null && prop.getActiveLock(
+ getClient().getCredentials().getUserName()) == null) {
+ return true;
+ }
+ else
+ return false;
}
public String lock() {
- return SPUtils.lock(this);
+ return lock(DEFAULT_TIMEOUT);
}
public String lock(long timeout) {
- return SPUtils.lock(this, timeout);
+ System.err.println("Locking file...");
+ try {
+ SPLockMethod method;
+
+ if(lockToken == null) {
+ LockdiscoveryProperty prop = (LockdiscoveryProperty)getProperty(
+ "lockdiscovery");
+ if(prop != null) {
+ // This may return null, meaning someone else has it locked.
+ lockToken = prop.getLockToken(
+ getClient().getCredentials().getUserName());
+ }
+ }
+
+ if(lockToken != null) /* Refresh the lock */ {
+ System.err.println("Refreshing lock using lockToken "+lockToken);
+ method = new SPLockMethod(this, lockToken, timeout);
+ }
+ else /* New lock */ {
+ System.err.println("Getting new lock");
+ method = new SPLockMethod(this, timeout);
+ }
+
+ method.execute();
+ int status = method.getStatusCode();
+
+ if(status == HttpStatus.SC_OK) {
+ lockToken = method.getLockToken();
+ System.err.println("Got locktoken back from server: "+lockToken);
+ }
+ else if(status == HttpStatus.SC_LOCKED)
+ showErrorMessage("Locking Failure",
+ "Unable to lock resource.\n"+
+ "The resource \""+method.getPath()+"\" is currently "+
+ "locked by another user.");
+ else
+ showErrorMessage("Locking Failure",
+ "Unable to lock resource \""+method.getPath()+"\": "+
+ status+".");
+ }
+ catch(HttpException e) {
+ e.printStackTrace();
+ }
+ catch(IOException e) {
+ e.printStackTrace();
+ }
+
+ return lockToken;
}
public boolean unlock() {
- return SPUtils.unlock(this);
+ System.err.println("Unlocking file...");
+ SPUnlockMethod method;
+ if(lockToken != null) {
+ System.err.println("Unlocking using stored lockToken: "+lockToken);
+ method = new SPUnlockMethod(this, lockToken);
+ }
+ else {
+ System.out.println("ERROR: Unlock() without a known locktoken!");
+ method = null;
+ /* FIXME: What should we do here - unlock without a lock token
+ * known.
+ */
+ }
+
+ try {
+ method.execute();
+ int status = method.getStatusCode();
+
+ System.out.println("Unlock status: "+status);
+ if(status != HttpStatus.SC_NO_CONTENT) {
+ showErrorMessage("Unlocking Failure",
+ "Unable to unlock resource \""+method.getPath()+
+ "\": "+status+".");
+ return false;
+ }
+ else
+ return true;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public SPProperty getProperty(String propertyName) {
+ return getProperty(propertyName, false);
+ }
+
+ protected boolean shouldFetchProperty(String self, String possible) {
+ if(self.equals(possible))
+ return false;
+ else {
+ PropertiesCacheEntry prop = (PropertiesCacheEntry)
+ cachedProperties.get(possible);
+
+ if(prop != null) {
+ if(System.currentTimeMillis() - prop.time > 1000*60*5)
+ return true;
+ else
+ return false;
+ }
+ else
+ return true;
+ }
+ }
+
+
+ /* if uncached is set, this never comes out of the cache */
+ public SPProperty getProperty(String propertyName, boolean uncached) {
+ System.err.println("Asking for property \""+propertyName+"\"");
+ PropertiesCacheEntry prop = (PropertiesCacheEntry)cachedProperties.get(
+ propertyName);
+
+ if(prop != null) {
+ if(!uncached) {
+ System.err.println("Returning property from cache");
+ return prop.prop;
+ }
+
+ /* Even if an uncached property was requested, if it's less than 5
+ * minutes old, give them a cached property.
+ */
+ long now = System.currentTimeMillis();
+ if(now - prop.time < 1000*60*5) {
+ System.err.println("Request for UNCACHED property ignored: have current
value");
+ return prop.prop;
+ }
+ else
+ System.err.println("Had cached version, but was "+((now -
prop.time)/(1000*60))+" seconds old");
+
+ }
+ else
+ System.err.println("Not found in cache.");
+
+ if(uncached)
+ System.err.println("Explicit request for non-cached copy");
+
+ System.err.println("Requesting property from server: "+propertyName);
+
+ SPPropFindMethod method = new SPPropFindMethod(getClient());
+
+ method.setPath(resourceUrlPath);
+ method.setDepth(DepthSupport.DEPTH_0);
+
+ Vector propList = new Vector(4);
+ propList.add(propertyName);
+ if(shouldFetchProperty(propertyName, "current-user-privilege-set"))
+ propList.add("current-user-privilege-set");
+ if(shouldFetchProperty(propertyName, "lockdiscovery"))
+ propList.add("lockdiscovery");
+
+
+ try {
+ method.executeByName(propList.elements());
+ int status = method.getStatusCode();
+
+ if(status >= 200 && status < 300) {
+ Enumeration props = propList.elements();
+ SPProperty result=null;
+
+ while(props.hasMoreElements()) {
+ String propName = (String)props.nextElement();
+ SPProperty spProp = (SPProperty)method.getProperty(propName);
+ if(propName.equals(propertyName))
+ result = spProp;
+
+ if(spProp == null) {
+ System.err.println("Caching absent property");
+ cachedProperties.put(propName,
+ new PropertiesCacheEntry(null));
+ }
+
+ System.out.println("Caching property \""+propName+"\"");
+ cachedProperties.put(propName,
+ new PropertiesCacheEntry(spProp));
+ }
+ return result;
+ }
+ else {
+ showErrorMessage("Remote Failure",
+ "Unable to fetch property "+propertyName+" on resource "
+ +resourceUrlPath);
+ return null;
+ }
+ } catch(Exception e) {
+ return null;
+ }
}
- public SPProperty getProperty(String propertyName) {
- return SPUtils.getProperty(this, propertyName);
+ public void setProperties(Enumeration properties) {
+ SPPropPatchMethod method = new SPPropPatchMethod(this);
+
+ while(properties.hasMoreElements()) {
+ SPProperty prop = (SPProperty)properties.nextElement();
+ method.addPropertyToSet(prop.getLocalName(),
+ encodeXML(prop.getPropertyAsString()),
+ prop.getNamespaceURI(), prop.getNamespaceURI());
+
+ cachedProperties.put(prop.getName(),
+ new PropertiesCacheEntry(prop));
+ }
+
+ try {
+ method.execute();
+ int status = method.getStatusCode();
+
+ if((status < 200 || status >= 300) &&
+ status != HttpStatus.SC_NOT_FOUND) {
+ showErrorMessage("Remote Failure",
+ "Unable to set property on resource "+
+ getResourceUrlPath()+": "+status+".");
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
}
+
public HttpClient getClient() {
return client;
}
+ public String getCurrentLockToken() {
+ return lockToken;
+ }
+
public String getLockToken() {
+ System.err.println("getLockToken() called - doing full lockdiscovery!");
String lockToken = null;
LockdiscoveryProperty lockdiscoveryProp =
(LockdiscoveryProperty) getProperty("lockdiscovery");
if (lockdiscoveryProp != null) {
- String userName = getClient().getCredentials().getUserName();
+ String userName = getClient().getCredentials().getUserName();
lockToken = lockdiscoveryProp.getLockToken(userName);
+ this.lockToken = lockToken;
}
+ System.err.println("Got lockToken: "+lockToken);
+
return lockToken;
}
public boolean hasReadAccess() {
- if (! accessPrivilegeChecked) {
- checkAccessPrivilege();
- }
- return readAccess;
- }
+ CurrentUserPrivilegeSetProperty prop = (CurrentUserPrivilegeSetProperty)
+ getProperty("current-user-privilege-set");
- public boolean hasWriteAccess() {
- if (! accessPrivilegeChecked) {
- checkAccessPrivilege();
- }
- return writeAccess;
+ return (prop != null)?prop.hasReadAccess():true;
}
- public boolean hasReadWriteAccess() {
- if (! accessPrivilegeChecked) {
- checkAccessPrivilege();
- }
- return readAccess && writeAccess;
- }
+ public boolean hasWriteAccess() {
+ CurrentUserPrivilegeSetProperty prop = (CurrentUserPrivilegeSetProperty)
+ getProperty("current-user-privilege-set");
- public void setPrivilege(boolean readAccess, boolean writeAccess) {
- this.readAccess = readAccess;
- this.writeAccess = writeAccess;
- accessPrivilegeChecked = true;
+ return (prop != null)?prop.hasWriteAccess():true;
}
+ public boolean hasReadWriteAccess() {
+ CurrentUserPrivilegeSetProperty prop = (CurrentUserPrivilegeSetProperty)
+ getProperty("current-user-privilege-set");
- protected void checkAccessPrivilege() {
- CurrentUserPrivilegeSetProperty userPrivilege =
- (CurrentUserPrivilegeSetProperty) SPUtils.getProperty(client,
- resourceUrlPath, "current-user-privilege-set");
- if (userPrivilege != null) {
- readAccess = userPrivilege.hasReadAccess();
- writeAccess = userPrivilege.hasWriteAccess();
- accessPrivilegeChecked = true;
- } else {
- accessPrivilegeChecked = false;
- }
+ return (prop != null)?(prop.hasWriteAccess()&&prop.hasReadAccess()):false;
}
public boolean equals(Object obj) {
@@ -234,6 +492,60 @@
return ( (client == objNode.getClient())
&& (resourceUrlPath.equals(objNode.getResourceUrlPath())) );
}
+
+ protected class PropertiesCacheEntry {
+
+ public SPProperty prop;
+ public long time;
+
+ public PropertiesCacheEntry(SPProperty prop) {
+ this.prop = prop;
+ this.time = System.currentTimeMillis();
+ }
+ }
+
+ /* This is a nasty hack, should fix this properly one day */
+ private String encodeXML(String in) {
+ StringBuffer buf = new StringBuffer();
+ int i;
+
+ char input[] = in.toCharArray();
+
+ for(i = 0; i < input.length; i++) {
+ switch(input[i]) {
+ case '&':
+ buf.append("&");
+ break;
+ case '>':
+ buf.append(">");
+ break;
+ case '<':
+ buf.append("<");
+ break;
+ default:
+ buf.append(input[i]);
+ break;
+ }
+ }
+
+ return buf.toString();
+ }
+
+ protected static String getFileNameOfUrl(String path) {
+ if(path.endsWith("/"))
+ path = path.substring(0, path.length()-1);
+ return path.substring(path.lastIndexOf("/") + 1);
+ }
+
+ protected void showErrorMessage(String title, String message)
+ throws HttpException
+ {
+ JOptionPane.showMessageDialog(null, message, title,
+ JOptionPane.ERROR_MESSAGE);
+
+ throw new HttpException(message);
+ }
+
} //End of SPResourceNode class
1.6 +20 -31
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFile.java
Index: SPWebFile.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFile.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SPWebFile.java 23 Oct 2001 23:39:34 -0000 1.5
+++ SPWebFile.java 8 Feb 2002 04:24:05 -0000 1.6
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFile.java,v
1.5 2001/10/23 23:39:34 msmith Exp $
- * $Revision: 1.5 $
- * $Date: 2001/10/23 23:39:34 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFile.java,v
1.6 2002/02/08 04:24:05 msmith Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/02/08 04:24:05 $
*
* ====================================================================
*
@@ -69,7 +69,6 @@
import org.apache.webdav.lib.*;
import org.apache.webdav.ui.lib.methods.*;
import org.apache.webdav.lib.properties.*;
-import org.apache.webdav.ui.util.SPUtils;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpClient;
@@ -86,7 +85,7 @@
public class SPWebFile extends SPResourceNode {
public SPWebFile(HttpClient client, String urlPath) {
- this(client, urlPath, SPUtils.getFileNameOfUrl(urlPath));
+ this(client, urlPath, getFileNameOfUrl(urlPath));
}
public SPWebFile(HttpClient client, String urlPath, String name) {
@@ -94,22 +93,7 @@
this.resourceUrlPath = urlPath;
this.name = name;
}
-/*
- public SPWebFile(HttpClient client, String urlPath, boolean readAccess,
- boolean writeAccess) {
- this(client, urlPath, SPUtils.getFileNameOfUrl(urlPath), readAccess,
writeAccess);
- }
- public SPWebFile(HttpClient client, String urlPath, String name,
- boolean readAccess, boolean writeAccess) {
- this.client = client;
- this.resourceUrlPath = urlPath;
- this.name = name;
- this.readAccess = readAccess;
- this.writeAccess = writeAccess;
- accessPrivilegeChecked = true;
- }
-*/
public List getChildren() {
return null;
}
@@ -121,7 +105,7 @@
public boolean isAcceptable(String aFilterDescription) {
boolean isAcceptable = false;
- String extension = SPUtils.getExtension(name);
+ String extension = getExtension();
int openingBrace = aFilterDescription.indexOf("(");
int closingBrace = aFilterDescription.indexOf(")");
@@ -163,7 +147,7 @@
final String title = "Import Failure";
final String msg = "Server Response Status is NOT OK ("+statusCode+")\n"+
"Resource Path = "+resourceUrlPath;
- SPUtils.showMessageDialog(title, msg);
+ showErrorMessage(title, msg);
}
return theString;
@@ -194,7 +178,7 @@
final String title = "Import Failure";
final String msg = "Server Response Status is NOT OK ("+statusCode+")\n"+
"Resource Path = "+resourceUrlPath;
- SPUtils.showMessageDialog(title, msg);
+ showErrorMessage(title, msg);
theStream = null;
}
@@ -207,7 +191,7 @@
String title = "Export Failure";
String msg = "Write Access Denied ("+HttpStatus.SC_FORBIDDEN+")\n"+
"Resource Path = "+resourceUrlPath;
- SPUtils.showMessageDialog(title, msg);
+ showErrorMessage(title, msg);
return (HttpStatus.SC_FORBIDDEN);
}
@@ -226,7 +210,7 @@
msg = "Server Response Status is NOT OK ("+statusCode+")\n"+
"Resource Path = "+resourceUrlPath;
}
- SPUtils.showMessageDialog(title, msg);
+ showErrorMessage(title, msg);
}
return statusCode;
@@ -238,7 +222,7 @@
String title = "Export Failure";
String msg = "Write Access Denied ("+HttpStatus.SC_FORBIDDEN+")\n"+
"Resource Path = "+resourceUrlPath;
- SPUtils.showMessageDialog(title, msg);
+ showErrorMessage(title, msg);
return (HttpStatus.SC_FORBIDDEN);
}
@@ -258,18 +242,23 @@
msg = "Server Response Status is NOT OK ("+statusCode+")\n"
+"Resource Path = "+resourceUrlPath;
}
- SPUtils.showMessageDialog(title, msg);
+ showErrorMessage(title, msg);
}
return statusCode;
}//putFileContent(File)
- public void setProperties(Enumeration properties) {
- SPUtils.setProperty(this, properties);
- }
-
public void refreshContent() {
//do nothing
+ }
+
+ private String getExtension() {
+ int i = getName().lastIndexOf(".");
+
+ if (i > 0 && i < getName().length() - 1)
+ return getName().substring(i+1).toLowerCase();
+ else
+ return null;
}
} //End of SPWebFile class
1.6 +37 -73
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFolder.java
Index: SPWebFolder.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFolder.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- SPWebFolder.java 4 Feb 2002 23:49:13 -0000 1.5
+++ SPWebFolder.java 8 Feb 2002 04:24:05 -0000 1.6
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFolder.java,v
1.5 2002/02/04 23:49:13 msmith Exp $
- * $Revision: 1.5 $
- * $Date: 2002/02/04 23:49:13 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/filechooser/dir/SPWebFolder.java,v
1.6 2002/02/08 04:24:05 msmith Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/02/08 04:24:05 $
*
* ====================================================================
*
@@ -67,9 +67,9 @@
import java.io.*;
import org.apache.webdav.lib.*;
+import org.apache.webdav.lib.methods.DepthSupport;
import org.apache.webdav.ui.lib.methods.SPPropFindMethod;
import org.apache.webdav.ui.lib.properties.*;
-import org.apache.webdav.ui.util.SPUtils;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpClient;
@@ -90,7 +90,7 @@
protected List children = null;
public SPWebFolder(HttpClient client, String urlPath) {
- this(client, urlPath, SPUtils.getFileNameOfUrl(urlPath));
+ this(client, urlPath, getFileNameOfUrl(urlPath));
}
public SPWebFolder(HttpClient client, String urlPath, String name) {
@@ -101,27 +101,6 @@
this.resourceUrlPath = urlPath;
this.name = name;
}
-/*
- public SPWebFolder(HttpClient client, String urlPath,
- boolean readAccess, boolean writeAccess) {
- this(client, urlPath, SPUtils.getFileNameOfUrl(urlPath),
- readAccess, writeAccess);
- }
-
- public SPWebFolder(HttpClient client, String urlPath, String name,
- boolean readAccess, boolean writeAccess) {
-
- this.client = client;
-
- //urlPath must point to a collection
- urlPath = (urlPath.endsWith("/")) ? urlPath : urlPath+"/";
- this.resourceUrlPath = urlPath;
- this.name = name;
- this.readAccess = readAccess;
- this.writeAccess = writeAccess;
- accessPrivilegeChecked = true;
- }
-*/
public List getChildren() {
if (children == null) {
@@ -139,16 +118,25 @@
}
public void init() throws Exception {
+
SPPropFindMethod propFindMethod = new SPPropFindMethod(client);
+
propFindMethod.setPath(resourceUrlPath);
- propFindMethod.execute();
+
+ Vector propList = new Vector(5);
+ propList.add("current-user-privilege-set");
+ propList.add("resourcetype");
+ propList.add("lockdiscovery");
+
+ propFindMethod.setDepth(DepthSupport.DEPTH_1);
+ propFindMethod.executeByName(propList.elements());
int statusCode = propFindMethod.getStatusCode();
if (statusCode<200 || statusCode >299) {
final String title = "Remote Failure";
final String msg = "Unable to access a remote directory ("+statusCode+")";
- SPUtils.showMessageDialog(title, msg);
+ showErrorMessage(title, msg);
}
children = new ArrayList();
@@ -163,53 +151,29 @@
while (enum.hasMoreElements()){
String url = (String) enum.nextElement();
- Property p =
(Property)propFindMethod.getProperty("current-user-privilege-set", url);
- //System.err.println("current-user-privilege-set is
"+p.getClass().getName());
- CurrentUserPrivilegeSetProperty userPrivilege =
-// (CurrentUserPrivilegeSetProperty)
- // propFindMethod.getProperty("current-user-privilege-set", url);
- (CurrentUserPrivilegeSetProperty)p;
-
- boolean readAccess = userPrivilege.hasReadAccess();
- boolean writeAccess = userPrivilege.hasWriteAccess();
-
- LockdiscoveryProperty lockdiscoveryProp =
- (LockdiscoveryProperty)
- propFindMethod.getProperty("lockdiscovery", url);
-
- boolean readOnly=false;
- if (lockdiscoveryProp != null) { //is being locked
- String userName = client.getCredentials().getUserName();
- if (lockdiscoveryProp.getLockToken(userName) == null) {
- // is locked by others
- readOnly = true;
- }
- }
+ System.err.println("Next URL: "+url);
+
+ if(!url.endsWith(resourceUrlPath) && !url.endsWith(urlPathSlashIndep)) {
+ SPResourceNode newChild;
- SPResourceNode newChild;
+ if(propFindMethod.isCollection(url)) {
+ System.err.println("Inserting new child folder: "+url);
+ newChild = new SPWebFolder(client, url);
+ }
+ else {
+ System.err.println("Inserting new child file: "+url);
+ newChild = new SPWebFile(client, url);
+ }
+ newChild.addCachedProperties(propFindMethod.getResponseProperties(
+ url), propList);
+ children.add(newChild);
+ }
+ else {
+ System.err.println("Caching properties on directory.");
+ this.addCachedProperties(propFindMethod.getResponseProperties(
+ url), propList);
+ }
- // Pending: Waiting for the proper setting of "displayname" property
- // in the server
- if( ! url.endsWith(resourceUrlPath)
- && ! url.endsWith(urlPathSlashIndep)) {
- //if not this SPWebFolder's url
- //create a SPWebFolder or SPWebFile child according to its type
-
- if (propFindMethod.isCollection(url)) {
- newChild = new SPWebFolder(client, url);
- } else {
- newChild = new SPWebFile(client, url);
- }
-
- newChild.setPrivilege(readAccess, writeAccess);
- newChild.setReadOnlyCached(readOnly);
- newChild.setParent(this);
- children.add(newChild);
- } else {
- this.readAccess = readAccess;
- this.writeAccess = writeAccess;
- accessPrivilegeChecked = true;
- }// if(! url.endsWidth...)
}// while (enum...)
}// init()
1.3 +17 -27
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPLockMethod.java
Index: SPLockMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPLockMethod.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SPLockMethod.java 17 Jul 2001 04:00:49 -0000 1.2
+++ SPLockMethod.java 8 Feb 2002 04:24:06 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPLockMethod.java,v
1.2 2001/07/17 04:00:49 msmith Exp $
- * $Revision: 1.2 $
- * $Date: 2001/07/17 04:00:49 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPLockMethod.java,v
1.3 2002/02/08 04:24:06 msmith Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/02/08 04:24:06 $
*
* ====================================================================
*
@@ -64,6 +64,7 @@
package org.apache.webdav.ui.lib.methods;
import java.util.Enumeration;
+import java.io.IOException;
import org.apache.webdav.lib.*;
import org.apache.webdav.lib.methods.*;
@@ -73,6 +74,7 @@
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
public class SPLockMethod extends LockMethod
implements SPWebdavMethod {
@@ -139,39 +141,27 @@
}
}
- public SPWebdavMethod execute() throws Exception {
- String lockToken = ((SPWebdavClient)client).getLockToken(path);
- SPLockMethod executedLockMethod = this;
+ public SPWebdavMethod execute() throws IOException, HttpException {
try {
- if (lockToken != null) {
- executedLockMethod = refresh(lockToken);
- } else {
- client.executeMethod(this.getWebdavMethodHandle());
- }
- } catch(Exception e) {
- e.printStackTrace();
- throw e;
+ client.executeMethod(this);
+ } catch(IOException e) {
+ e.printStackTrace();
+ throw e;
+ } catch(HttpException e) {
+ e.printStackTrace();
+ throw e;
}
- return executedLockMethod;
- }//execute()
-
- public HttpMethod getWebdavMethodHandle() {
return this;
- }
+ }//execute()
public String toString() {
return (new String("LockMethod()"));
}
- private SPLockMethod refresh(String lockToken) throws Exception {
- SPLockMethod lockMethod = new SPLockMethod(client, path, lockToken,
getTimeout());
- try {
- client.executeMethod(lockMethod.getWebdavMethodHandle());
- } catch(Exception e) {
- throw e;
- }
- return lockMethod;
+ public HttpMethod getWebdavMethodHandle() {
+ return this;
}
+
}//End of SPLockMethod class
1.5 +7 -4
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropFindMethod.java
Index: SPPropFindMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropFindMethod.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SPPropFindMethod.java 4 Feb 2002 23:49:14 -0000 1.4
+++ SPPropFindMethod.java 8 Feb 2002 04:24:06 -0000 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropFindMethod.java,v
1.4 2002/02/04 23:49:14 msmith Exp $
- * $Revision: 1.4 $
- * $Date: 2002/02/04 23:49:14 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPropFindMethod.java,v
1.5 2002/02/08 04:24:06 msmith Exp $
+ * $Revision: 1.5 $
+ * $Date: 2002/02/08 04:24:06 $
*
* ====================================================================
*
@@ -136,6 +136,7 @@
}
public SPProperty getProperty(String propertyName) {
+ System.err.println("SPPropFindMethod.getProperty():
propertyName="+propertyName+", path = "+this.path);
return getProperty(propertyName, this.path);
}
@@ -153,8 +154,10 @@
while ( !isFound && propEnum.hasMoreElements()){
Property prop = (Property) propEnum.nextElement();
+ System.err.println("Seeing if property "+prop.getLocalName()+" is
appopriate");
if ( (prop.getLocalName()).lastIndexOf(propertyName) != -1) {
+ System.err.println("Found property. Creating property object");
theProperty = SPProperty.factory(prop);
isFound = true;
}
@@ -177,11 +180,11 @@
}
}
+
public SPWebdavMethod executeByName(Enumeration propertyList)
throws Exception {
setPropertyNames(propertyList);
setType(BY_NAME);
- setDepth(DepthSupport.DEPTH_0);
return execute();
}
1.4 +9 -10
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPutMethod.java
Index: SPPutMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPutMethod.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SPPutMethod.java 10 Oct 2001 04:42:45 -0000 1.3
+++ SPPutMethod.java 8 Feb 2002 04:24:06 -0000 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPutMethod.java,v
1.3 2001/10/10 04:42:45 msmith Exp $
- * $Revision: 1.3 $
- * $Date: 2001/10/10 04:42:45 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPPutMethod.java,v
1.4 2002/02/08 04:24:06 msmith Exp $
+ * $Revision: 1.4 $
+ * $Date: 2002/02/08 04:24:06 $
*
* ====================================================================
*
@@ -68,7 +68,6 @@
import org.apache.webdav.lib.*;
import org.apache.webdav.lib.methods.*;
import org.apache.webdav.ui.filechooser.dir.SPResourceNode;
-import org.apache.webdav.ui.util.SPUtils;
import org.apache.webdav.ui.SPWebdavClient;
import org.apache.commons.httpclient.HttpMethod;
@@ -80,6 +79,7 @@
HttpClient client;
private String lockToken=null;
+ protected SPResourceNode resource = null;
public SPPutMethod(HttpClient client) {
setClient(client);
@@ -88,6 +88,7 @@
public SPPutMethod(SPResourceNode resource) {
setClient(resource.getClient());
setPath(resource.getResourceUrlPath());
+ this.resource = resource;
}
public void setClient(HttpClient client) {
@@ -107,14 +108,12 @@
}
public SPWebdavMethod execute() throws Exception {
- lockToken = ((SPWebdavClient)client).getLockToken(path); //the current token
from the server
-
try {
client.executeMethod(this.getWebdavMethodHandle());
- if (lockToken != null) {
- SPUtils.lock(client, path); //by default, refresh the lock timeout
- }
-
+ if(resource != null)
+ resource.lock();
+ else
+ System.err.println("ERROR: No resource available, cannot set locktoken");
}
catch(Exception e) {
e.printStackTrace();
1.3 +10 -13
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPUnlockMethod.java
Index: SPUnlockMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPUnlockMethod.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SPUnlockMethod.java 17 Jul 2001 04:00:50 -0000 1.2
+++ SPUnlockMethod.java 8 Feb 2002 04:24:06 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPUnlockMethod.java,v
1.2 2001/07/17 04:00:50 msmith Exp $
- * $Revision: 1.2 $
- * $Date: 2001/07/17 04:00:50 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/methods/SPUnlockMethod.java,v
1.3 2002/02/08 04:24:06 msmith Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/02/08 04:24:06 $
*
* ====================================================================
*
@@ -66,7 +66,6 @@
import org.apache.webdav.lib.*;
import org.apache.webdav.lib.methods.*;
import org.apache.webdav.ui.filechooser.dir.SPResourceNode;
-import org.apache.webdav.ui.util.SPUtils;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpClient;
@@ -85,6 +84,11 @@
this.client = resource.getClient();
}
+ public SPUnlockMethod(SPResourceNode resource, String lockToken) {
+ super(resource.getResourceUrlPath(), lockToken);
+ this.client = resource.getClient();
+ }
+
public void setClient(HttpClient client) {
this.client = client;
}
@@ -103,7 +107,6 @@
public SPWebdavMethod execute() throws Exception {
try {
- setLockToken();
client.executeMethod(this.getWebdavMethodHandle());
} catch(Exception e) {
e.printStackTrace();
@@ -112,20 +115,14 @@
return this;
}
- private void setLockToken() {
- SPResourceNode node = SPUtils.getSPResourceNode(client, path);
- if (node != null) {
- setLockToken(node.getLockToken());
- }
+ public String toString() {
+ return (new String("UnlockMethod()"));
}
public HttpMethod getWebdavMethodHandle() {
return this;
}
- public String toString() {
- return (new String("UnlockMethod()"));
- }
}// End of SPUnlockMethod() class
1.2 +76 -12
jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/SPProperty.java
Index: SPProperty.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/SPProperty.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SPProperty.java 17 Jul 2001 04:00:53 -0000 1.1
+++ SPProperty.java 8 Feb 2002 04:24:06 -0000 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/SPProperty.java,v
1.1 2001/07/17 04:00:53 msmith Exp $
- * $Revision: 1.1 $
- * $Date: 2001/07/17 04:00:53 $
+ * $Header:
/home/cvs/jakarta-slide/src/contrib/webdavgui/src/java/org/apache/webdav/ui/lib/properties/SPProperty.java,v
1.2 2002/02/08 04:24:06 msmith Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/02/08 04:24:06 $
*
* ====================================================================
*
@@ -71,7 +71,6 @@
import org.w3c.dom.NodeList;
import org.apache.webdav.lib.*;
-import org.apache.webdav.ui.util.SPUtils;
import org.apache.util.*;
/**
@@ -85,7 +84,14 @@
public class SPProperty implements Property {
- Property property;
+ Property property=null;
+
+ String name;
+ String value;
+ String localName;
+ String namespaceURI;
+ Element element;
+
public static SPProperty factory(Property property) {
SPProperty theSPProperty=null;
@@ -95,7 +101,7 @@
//It may or may not contain namespace. In addition, a property name
//may have a dash character.
//converToClassName() removes the namespace and any dash character
- String propName = SPUtils.convertToClassName(property.getName());
+ String propName = convertToClassName(property.getLocalName());
Class propClass = Class.forName(
"org.apache.webdav.ui.lib.properties."+propName);
@@ -104,34 +110,92 @@
theSPProperty = (SPProperty) constructor.newInstance(
new Object[] {property});
} catch (Exception e) {
+ System.err.println("DEBUG: Creating new generic SPProperty object for
property "+property.getLocalName());
theSPProperty = new SPProperty(property);
}
return theSPProperty;
}
- protected SPProperty(Property property) {
+ /* There must be a more sensible way to do this... */
+ public static String convertToClassName(String propertyName) {
+ //Remove the namespace and any dash character out of propertyName
+ //and change its first character to uppercase.
+ String theResult="";
+
+ //First namespace
+ int colonIndex = propertyName.indexOf(':');
+ propertyName = (colonIndex >= 0)
+ ? propertyName.substring(colonIndex+1)
+ : propertyName;
+
+ propertyName = (propertyName.substring(0,1)).toUpperCase()+
+ propertyName.substring(1)+"Property";
+
+ //Then dash character
+ StringTokenizer stoken = new StringTokenizer(propertyName, "-");
+ while (stoken.hasMoreTokens()) {
+ String s = stoken.nextToken();
+ theResult += (s.substring(0,1)).toUpperCase() + s.substring(1);
+ }
+ return theResult;
+ }
+
+ public SPProperty() {
+ }
+
+ public SPProperty(Property property) {
this.property = property;
}
+ public SPProperty(String namespace, String namespaceInfo,
+ String name, String value)
+ {
+ this.namespaceURI = namespaceInfo;
+ this.name = name;
+ this.value = value;
+ }
+
+ public SPProperty(String name, String value)
+ {
+ this.namespaceURI = null;
+ this.name = name;
+ this.value = value;
+ }
+
public String getName() {
- return property.getName();
+ if(property != null)
+ return property.getName();
+ else
+ return name;
}
public String getLocalName() {
- return property.getLocalName();
+ if(property != null)
+ return property.getLocalName();
+ else
+ return localName;
}
public String getNamespaceURI() {
- return property.getNamespaceURI();
+ if(property != null)
+ return property.getNamespaceURI();
+ else
+ return namespaceURI;
}
public Element getElement() {
- return property.getElement();
+ if(property != null)
+ return property.getElement();
+ else
+ return element;
}
public String getPropertyAsString() {
- return property.getPropertyAsString();
+ if(property != null)
+ return property.getPropertyAsString();
+ else
+ return value;
}
public int getStatusCode() {
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>