jericho 01/04/23 07:17:07
Modified: src/webdav/client/src/org/apache/webdav/util
WebdavResource.java
Log:
- Simplify code for getting WebdavClient instance.
- Fix a bug to set httpURL with the additional path.
Revision Changes Path
1.47 +12 -60
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.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- WebdavResource.java 2001/04/23 08:50:20 1.46
+++ WebdavResource.java 2001/04/23 14:17:06 1.47
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.46 2001/04/23 08:50:20 jericho Exp $
- * $Revision: 1.46 $
- * $Date: 2001/04/23 08:50:20 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.47 2001/04/23 14:17:06 jericho Exp $
+ * $Revision: 1.47 $
+ * $Date: 2001/04/23 14:17:06 $
*
* ====================================================================
*
@@ -314,6 +314,12 @@
/**
+ * The WebdavClient instance for this resource.
+ */
+ private WebdavClient client;
+
+
+ /**
* Table of the hrefs gotten in a collection.
*/
private WebdavResources childResources = new WebdavResources();
@@ -795,6 +801,8 @@
throws WebdavException, IOException {
this.httpURL = httpURL;
+ client = getSessionInstance(httpURL);
+ client.setDebug(debug);
// make its existence false
setExistence(false);
setProperties(action, depth);
@@ -882,7 +890,7 @@
throws WebdavException, IOException {
this.httpURL = new HttpURL(httpURL, additionalPath);
- setHttpURL(httpURL, defaultAction, defaultDepth);
+ setHttpURL(this.httpURL, defaultAction, defaultDepth);
}
@@ -1589,8 +1597,6 @@
public void setEncodeURLs(boolean encodeURLs)
throws MalformedURLException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
State state = client.getState();
if (state != null) {
state.setEncodeURLs(encodeURLs);
@@ -1613,14 +1619,11 @@
public InputStream getMethodData()
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
// use disk to save by default
GetMethod method = new GetMethod(httpURL.getPath());
method.setUseDisk(useDiskForGet);
if (tempDirForGet != null)
method.setTempDir(tempDirForGet);
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -1638,13 +1641,10 @@
public String getMethodDataAsString()
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
GetMethod method = new GetMethod(httpURL.getPath());
method.setUseDisk(useDiskForGet);
if (tempDirForGet != null)
method.setTempDir(tempDirForGet);
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -1679,12 +1679,9 @@
public boolean getMethod(String path, File file)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
// use disk to save by default
GetMethod method = new GetMethod(HttpURL.getPathQuery(path), file);
method.setUseDisk(true);
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -1725,11 +1722,8 @@
public boolean putMethod(String path, String data)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
PutMethod method = new PutMethod(HttpURL.getPath(path));
method.sendData(data);
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -1770,11 +1764,8 @@
public boolean putMethod(String path, File file)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
PutMethod method = new PutMethod(HttpURL.getPath(path));
method.sendData(file);
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -1818,11 +1809,8 @@
public boolean putMethod(String path, URL url)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
PutMethod method = new PutMethod(HttpURL.getPath(path));
method.sendData(url);
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -1859,14 +1847,11 @@
public boolean optionsMethod(String path)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
OptionsMethod method;
if (path.trim().equals("*"))
method = new OptionsMethod("*");
else
method = new OptionsMethod(HttpURL.getPath(path));
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -1988,13 +1973,10 @@
public Enumeration propfindMethod(String path, int depth)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
// Check the path alright.
path = HttpURL.getPath(path);
// Change the depth for allprop
PropFindMethod method = new PropFindMethod(path, depth);
- client.setDebug(debug);
method.setDebug(debug);
// Default depth=infinity, type=allprop
client.executeMethod(method);
@@ -2055,14 +2037,11 @@
Vector properties)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
// Check the path alright.
path = HttpURL.getPath(path);
// Change the depth for prop
PropFindMethod method = new PropFindMethod(path, depth,
properties.elements());
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -2147,15 +2126,12 @@
public Enumeration propfindMethod(String path, Vector properties)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
// Check the path alright.
path = HttpURL.getPath(path);
// Default depth=0, type=by_name
PropFindMethod method =
new PropFindMethod(path, DepthSupport.DEPTH_0,
properties.elements());
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -2261,8 +2237,6 @@
public boolean proppatchMethod(String path, Hashtable property)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
PropPatchMethod method = new PropPatchMethod(HttpURL.getPath(path));
Enumeration names = property.keys();
boolean hasSomething = false;
@@ -2275,7 +2249,6 @@
}
if (hasSomething) {
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -2318,10 +2291,7 @@
public boolean headMethod(String path)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
HeadMethod method = new HeadMethod(HttpURL.getPath(path));
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -2360,10 +2330,7 @@
public boolean deleteMethod(String path)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
DeleteMethod method = new DeleteMethod(HttpURL.getPath(path));
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -2405,10 +2372,7 @@
public boolean moveMethod(String source, String destination)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
MoveMethod method = new MoveMethod(source, destination);
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -2453,10 +2417,7 @@
public boolean copyMethod(String source, String destination)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
CopyMethod method = new CopyMethod(source, destination);
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -2498,10 +2459,7 @@
public boolean mkcolMethod(String path)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
MkcolMethod method = new MkcolMethod(HttpURL.getPath(path));
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -2595,13 +2553,10 @@
public boolean lockMethod(String path, String owner, short timeout)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
// default lock type setting
short lockType = LockMethod.SCOPE_EXCLUSIVE;
LockMethod method =
new LockMethod(HttpURL.getPath(path), owner, lockType, timeout);
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
String lock = method.getLockToken();
@@ -2653,8 +2608,6 @@
public boolean unlockMethod(String path)
throws WebdavException, IOException {
- WebdavClient client = getSessionInstance(httpURL);
-
// Get the lock for the given path.
State state = client.getState();
// Check the given path is alright.
@@ -2670,7 +2623,6 @@
// unlock for the given path.
UnlockMethod method = new UnlockMethod(path);
method.setLockToken(lock);
- client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);