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 je...@apache.org on 2001/03/13 09:13:22 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/util WebdavResource.java GenericURI.java
jericho 01/03/13 00:13:20
Modified: src/webdav/client/src/org/apache/webdav/util
WebdavResource.java GenericURI.java
Log:
- Add methods for abs_path and net_path.
- Fix the getMethod to have abs_path as an arguement.
Revision Changes Path
1.15 +5 -5 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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- WebdavResource.java 2001/03/08 11:56:21 1.14
+++ WebdavResource.java 2001/03/13 08:13:14 1.15
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v 1.14 2001/03/08 11:56:21 jericho Exp $
- * $Revision: 1.14 $
- * $Date: 2001/03/08 11:56:21 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v 1.15 2001/03/13 08:13:14 jericho Exp $
+ * $Revision: 1.15 $
+ * $Date: 2001/03/13 08:13:14 $
*
* ====================================================================
*
@@ -1135,7 +1135,7 @@
public boolean getMethod(File file)
throws WebdavException, IOException {
- return getMethod(httpUrl.getPath(), file);
+ return getMethod(httpUrl.getAbsPath(), file);
}
@@ -1154,7 +1154,7 @@
WebdavClient client = WebdavSession.getSessionInstance(httpUrl);
// use disk to save by default
- GetMethod method = new GetMethod(HttpURL.getPath(path), file);
+ GetMethod method = new GetMethod(HttpURL.getAbsPath(path), file);
client.executeMethod(method);
int statusCode = method.getStatusCode();
1.7 +77 -4 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GenericURI.java 2001/02/28 12:56:38 1.6
+++ GenericURI.java 2001/03/13 08:13:16 1.7
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v 1.6 2001/02/28 12:56:38 jericho Exp $
- * $Revision: 1.6 $
- * $Date: 2001/02/28 12:56:38 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/GenericURI.java,v 1.7 2001/03/13 08:13:16 jericho Exp $
+ * $Revision: 1.7 $
+ * $Date: 2001/03/13 08:13:16 $
*
* ====================================================================
*
@@ -538,6 +538,80 @@
/*
+ * Get the net_path of the given URI string.
+ * The net_path consists of the net_loc and abs_path.
+ *
+ * @return the nel_path.
+ */
+ public String getNetPath() {
+
+ return getNetPath(uri.toString());
+ }
+
+
+ /*
+ * Get the net_path of the given URI string.
+ * The net_path consists of the net_loc and abs_path.
+ *
+ * @param uri the specified URI string.
+ * @return the net_path.
+ */
+ public static String getNetPath(String uri) {
+
+ // consider of net_path
+ int from = uri.indexOf("//");
+ // Ignore the authority part of URI
+ int to = uri.length();
+ // check the fragment
+ if (uri.indexOf("#") > 0)
+ to = uri.indexOf("#");
+ // get only the path.
+ uri = (from >= 0) ? uri.substring(from, to) : null;
+
+ return uri;
+ }
+
+
+ /*
+ * Get the abs_path for this generic URI.
+ * The abs_path includes the query.
+ * This method ignores the scheme and authority part of the URI path.
+ *
+ * @return the abs_path.
+ */
+ public String getAbsPath() {
+
+ return getAbsPath(uri.toString());
+ }
+
+
+ /*
+ * Get the abs_path of the given URI string.
+ * The abs_path includes the query.
+ * This method ignores the scheme and authority part of the URI path.
+ *
+ * @param uri the specified URI string.
+ * @return the abs_path.
+ */
+ public static String getAbsPath(String uri) {
+
+ // consider of net_path
+ int at = uri.indexOf("//");
+ // Ignore the authority part of URI
+ int to = uri.length();
+ // Ignore the '?' mark so to ignore the query.
+ // check the fragment
+ if (uri.indexOf("#") > 0)
+ to = uri.indexOf("#");
+ int from = uri.indexOf("/", (at >= 0) ? at + 2 : 0);
+ // get only the wanted path.
+ uri = (from >= 0) ? uri.substring(from, to) : "/";
+
+ return uri;
+ }
+
+
+ /*
* Set the path for this generic URI.
*
* @return the path.
@@ -569,7 +643,6 @@
* This method ignores the scheme and authority part of the URI path.
*
* @param uri the specified URI string.
- * It could be the generic URI and relative URI.
* @return the path.
*/
public static String getPath(String uri) {