jericho 01/04/15 19:27:14
Modified: src/webdav/client/src/org/apache/webdav/util
WebdavResources.java WebdavResource.java
GenericURI.java
src/webdav/client/src/org/apache/webdav/cmd Slide.java
Log:
- WebdavResource class
- Rename the listInDetail method to listBasic.
- Add the listWebdavResource method to return array of WebdavResource.
- WebdavResources class
- Add list and listResources.
- Remove the size method.
- GenericURI calss
- Rename the getAbsPathQuery method to getPathQuery.
- Slide class
- Apply above changes.
Revision Changes Path
1.4 +49 -14
jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResources.java
Index: WebdavResources.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResources.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WebdavResources.java 2001/04/05 01:29:25 1.3
+++ WebdavResources.java 2001/04/16 02:27:14 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResources.java,v
1.3 2001/04/05 01:29:25 jericho Exp $
- * $Revision: 1.3 $
- * $Date: 2001/04/05 01:29:25 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResources.java,v
1.4 2001/04/16 02:27:14 jericho Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/04/16 02:27:14 $
*
* ====================================================================
*
@@ -75,7 +75,6 @@
// --------------------------------------------------------- Constructors
-
/**
* Default constuctor.
*/
@@ -106,16 +105,6 @@
/**
- * Get the number of WebDAV resources for the current collection.
- *
- * @return the number of resources.
- */
- public int size() {
- return hrefTable.size();
- }
-
-
- /**
* Test if there is no resource.
*
* @return true if it's empty.
@@ -163,6 +152,52 @@
*/
public Enumeration getResources() {
return hrefTable.elements();
+ }
+
+
+ /**
+ * Get an array of resource names.
+ *
+ * @return An array of resource names.
+ */
+ public String[] list() {
+
+ synchronized (hrefTable) {
+ int num = hrefTable.size();
+ String resourceNames[] = new String[num];
+
+ Enumeration resources = getResourceNames();
+ int i = 0;
+ while (resources.hasMoreElements()) {
+ resourceNames[i] = (String) resources.nextElement();
+ i++;
+ }
+
+ return resourceNames;
+ }
+ }
+
+
+ /**
+ * Get an arraay of resources.
+ *
+ * @return An array of resources.
+ */
+ public WebdavResource[] listResources() {
+
+ synchronized (hrefTable) {
+ int num = hrefTable.size();
+ WebdavResource WebdavResources[] = new WebdavResource[num];
+
+ Enumeration resources = getResources();
+ int i = 0;
+ while (resources.hasMoreElements()) {
+ WebdavResources[i] = (WebdavResource) resources.nextElement();
+ i++;
+ }
+
+ return WebdavResources;
+ }
}
1.43 +47 -32
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.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- WebdavResource.java 2001/04/14 13:22:40 1.42
+++ WebdavResource.java 2001/04/16 02:27:14 1.43
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.42 2001/04/14 13:22:40 jericho Exp $
- * $Revision: 1.42 $
- * $Date: 2001/04/14 13:22:40 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.43 2001/04/16 02:27:14 jericho Exp $
+ * $Revision: 1.43 $
+ * $Date: 2001/04/16 02:27:14 $
*
* ====================================================================
*
@@ -222,21 +222,21 @@
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
@@ -390,25 +390,25 @@
*/
private void setNamedProp(int depth, Vector propertyNames)
throws WebdavException, IOException {
-
+
Enumeration responses = propfindMethod(depth, propertyNames);
setWebdavProperties(responses);
}
-
-
+
+
/**
* Set all properties for this resource.
*
* @param depth The depth
- */
- private void setAllProp(int depth)
+ */
+ private void setAllProp(int depth)
throws WebdavException, 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.
@@ -559,7 +559,7 @@
}
- // ----------------------------------------------- HttpURL Public Methods
+ // ----------------------------------------------- HttpURL Public Methods
/**
@@ -801,7 +801,7 @@
// it's ok to ignore this error.
}
}
-
+
/**
* Get the value of DAV property, resourcetype.
@@ -1194,9 +1194,24 @@
setNamedProp(DepthSupport.DEPTH_1, properties);
}
+
+
+ /**
+ * Get an array of resources denoting the WebDAV child resources in the
+ * collection of this resources.
+ *
+ * @return An array of child resources in this resource.
+ * @exception WebdavException
+ * @exception IOException
+ */
+ public WebdavResource[] listWebdavResources()
+ throws WebdavException, IOException {
+ return getChildResources().listResources();
+ }
+
- /*
+ /**
* Get an array of pathnames denoting the WebDAV resources in the
* collection denoted by this pathname.
*
@@ -1241,7 +1256,7 @@
* @exception WebdavException
* @exception IOException
*/
- public Vector listInDetail()
+ public Vector listBasic()
throws WebdavException, IOException {
setBasicProperties();
@@ -1423,7 +1438,7 @@
public boolean getMethod(File file)
throws WebdavException, IOException {
- return getMethod(httpURL.getAbsPathQuery(), file);
+ return getMethod(httpURL.getPathQuery(), file);
}
@@ -1442,7 +1457,7 @@
WebdavClient client = getSessionInstance(httpURL);
// use disk to save by default
- GetMethod method = new GetMethod(HttpURL.getAbsPathQuery(path), file);
+ GetMethod method = new GetMethod(HttpURL.getPathQuery(path), file);
client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
@@ -1739,7 +1754,7 @@
*/
public Enumeration propfindMethod(int depth, Vector properties)
throws WebdavException, IOException {
-
+
thisResource = true;
return propfindMethod(httpURL.getPath(), depth, properties);
}
@@ -1765,9 +1780,9 @@
public Enumeration propfindMethod(String path, int depth,
Vector properties)
throws WebdavException, IOException {
-
+
WebdavClient client = getSessionInstance(httpURL);
-
+
// Check the path alright.
path = HttpURL.getPath(path);
// Change the depth for prop
@@ -1783,7 +1798,7 @@
setStatusCode(method.getStatusCode());
}
thisResource = false;
-
+
return method.getResponses();
}
@@ -1857,7 +1872,7 @@
*/
public Enumeration propfindMethod(String path, Vector properties)
throws WebdavException, IOException {
-
+
WebdavClient client = getSessionInstance(httpURL);
// Check the path alright.
@@ -1869,7 +1884,7 @@
client.setDebug(debug);
method.setDebug(debug);
client.executeMethod(method);
-
+
// It contains the results.
Vector results = new Vector();
@@ -1897,7 +1912,7 @@
}
}
}
-
+
return results.elements();
}
@@ -2430,8 +2445,8 @@
if (anotherCollection && !thisCollection)
return 1;
- String thisPath = httpURL.getAbsPathQuery();
- String anotherPath= anotherUrl.getAbsPathQuery();
+ String thisPath = httpURL.getPathQuery();
+ String anotherPath= anotherUrl.getPathQuery();
return thisPath.compareTo(anotherPath);
} catch (Exception e) {
// FIXME: not to return 0.
1.16 +12 -12
jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java
Index: GenericURI.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- GenericURI.java 2001/04/07 19:53:03 1.15
+++ GenericURI.java 2001/04/16 02:27:14 1.16
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
1.15 2001/04/07 19:53:03 jericho Exp $
- * $Revision: 1.15 $
- * $Date: 2001/04/07 19:53:03 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v
1.16 2001/04/16 02:27:14 jericho Exp $
+ * $Revision: 1.16 $
+ * $Date: 2001/04/16 02:27:14 $
*
* ====================================================================
*
@@ -371,7 +371,7 @@
URI = getScheme() + "://" +
((userName != null) ?
userName + ((password != null) ? ":" + password : "") + "@" : "")
- + getHostPort() + getAbsPathQuery();
+ + getHostPort() + getPathQuery();
}
@@ -602,26 +602,26 @@
/**
- * Get the abs_path and query for this generic URI.
+ * Get the abs_path or rel_path, and query for this generic URI.
* This method just ignores the scheme and authority part of the URI path.
* So this method doesn't throw any exception.
*
- * @return the escaped abs_path and query.
+ * @return the escaped abs_path or rel_path, and query.
*/
- public String getAbsPathQuery() {
- return getAbsPathQuery(URI);
+ public String getPathQuery() {
+ return getPathQuery(URI);
}
/**
- * Get the abs_path and query of the escaped given URI string.
+ * Get the abs_path or rel_path, and query of the escaped given URI string.
* This method just ignores the scheme and authority part of the URI path.
* So this method doesn't throw any exception.
*
* @param escapedURI the specified escaped URI string.
- * @return the escaped abs_path and query.
+ * @return the escaped abs_path or rel_path, and query.
*/
- public static String getAbsPathQuery(String escapedURI) {
+ public static String getPathQuery(String escapedURI) {
// consider of net_path
int at = escapedURI.indexOf("//");
@@ -870,7 +870,7 @@
getUserInfo().equals(URI.getUserInfo()) &&
getHost().equalsIgnoreCase(URI.getHost()) &&
getPort() == URI.getPort() &&
- getPath().equals(URI.getPath()))
+ getPathQuery().equals(URI.getPathQuery()))
return true;
1.20 +9 -9
jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java
Index: Slide.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Slide.java 2001/04/13 05:31:41 1.19
+++ Slide.java 2001/04/16 02:27:14 1.20
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v 1.19
2001/04/13 05:31:41 remm Exp $
- * $Revision: 1.19 $
- * $Date: 2001/04/13 05:31:41 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v 1.20
2001/04/16 02:27:14 jericho Exp $
+ * $Revision: 1.20 $
+ * $Date: 2001/04/16 02:27:14 $
*
* ====================================================================
*
@@ -279,18 +279,18 @@
}
if (command.length() <= 0)
continue;
-
+
StringTokenizer st = new StringTokenizer(command);
String todo = st.nextToken();
Stack params = new Stack();
while (st.hasMoreTokens()) {
params.push(st.nextToken());
}
-
+
if (todo.equalsIgnoreCase("open")) {
String inputUrl = null;
switch (params.size()) {
- case 0:
+ case 0:
System.out.print("Enter http URL: ");
inputUrl = in.readLine();
if (inputUrl == null) {
@@ -311,7 +311,7 @@
"http://username:password@hostname:port/path");
continue;
}
-
+
try {
// Set up for processing WebDAV resources
httpURL = new HttpURL(inputUrl);
@@ -624,7 +624,7 @@
if (todo.equalsIgnoreCase("url")) {
try {
System.out.println
-
(webdavResource.getHttpURLExceptForUserInfo());
+ (webdavResource.getHttpURLExceptForUserInfo());
} catch (MalformedURLException mue) {
System.err.println("Warning: " + mue.getMessage());
}
@@ -747,7 +747,7 @@
switch (options[o]) {
case 'l':
try {
- Vector list = webdavResource.listInDetail();
+ Vector list = webdavResource.listBasic();
for (int i = 0; i < list.size(); i++) {
String[] longFormat =
(String []) list.elementAt(i);