jericho 01/04/16 07:19:28
Modified: src/webdav/client/src/org/apache/webdav/util
WebdavResource.java
src/webdav/client/src/org/apache/webdav/cmd Slide.java
Log:
- Add the putMethod for URL on another remote site.
- Add the function to put remote to remote in the Slide client.
- Fix to check a collection on apache mod_dav.
Revision Changes Path
1.44 +53 -3
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.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- WebdavResource.java 2001/04/16 02:27:14 1.43
+++ WebdavResource.java 2001/04/16 14:19:27 1.44
@@ -1,7 +1,7 @@
/*
- * $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 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/util/WebdavResource.java,v
1.44 2001/04/16 14:19:27 jericho Exp $
+ * $Revision: 1.44 $
+ * $Date: 2001/04/16 14:19:27 $
*
* ====================================================================
*
@@ -832,6 +832,8 @@
* @see #getIsCollection()
*/
public boolean isCollection() {
+ if (getResourceType() == null)
+ return false;
return getResourceType().isCollection();
}
@@ -1548,6 +1550,54 @@
PutMethod method = new PutMethod(HttpURL.getPath(path));
method.sendData(file);
+ client.setDebug(debug);
+ method.setDebug(debug);
+ client.executeMethod(method);
+
+ int statusCode = method.getStatusCode();
+ setStatusCode(statusCode);
+
+ return (statusCode >= 200 && statusCode < 300) ? true : false;
+ }
+
+
+
+ /*
+ * Execute the PUT method for this resource from the given url.
+ * It's like a streaming copy about a resource of the specified remote url
+ * to another remote url of this resource.
+ *
+ * @param url The URL to get a resource.
+ * @return true if the method is succeeded.
+ * @exception WebdavException
+ * @exception IOException
+ */
+ public boolean putMethod(URL url)
+ throws WebdavException, IOException {
+
+ boolean result = putMethod(httpURL.getPath(), url);
+ if (result)
+ setAllProp(DepthSupport.DEPTH_0);
+ return result;
+ }
+
+
+ /*
+ * Execute the PUT method for the given path from the given url.
+ *
+ * @param path The http URL to request.
+ * @param url The URL to get a resource.
+ * @return true if the method is succeeded.
+ * @exception WebdavException
+ * @exception IOException
+ */
+ 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);
1.21 +30 -13
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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Slide.java 2001/04/16 02:27:14 1.20
+++ Slide.java 2001/04/16 14:19:28 1.21
@@ -1,7 +1,7 @@
/*
- * $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 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v 1.21
2001/04/16 14:19:28 jericho Exp $
+ * $Revision: 1.21 $
+ * $Date: 2001/04/16 14:19:28 $
*
* ====================================================================
*
@@ -876,15 +876,30 @@
if (todo.equalsIgnoreCase("put")) {
int count = params.size();
if (count == 1 || count == 2) {
- String dest = dest = checkUri((String) params.pop());
- String src = (count == 1) ? HttpURL.getName(dest)
- : (String) params.pop();
+ String dest = (String) params.pop();
+ dest = dest.indexOf(":") > 1 ? dest : checkUri(dest);
+ String src = (count == 1) ?
+ HttpURL.getName(dest) : (String) params.pop();
try {
- File file = new File(dir, src);
+ if ((count == 2 && src.indexOf(":") > 1) ||
+ count == 1 && dest.indexOf(":") > 1) {
+ URL url = new URL(count == 1 ? dest : src);
+ System.out.print("Uploading '" +
+ ((count == 2) ? src : dest) +
+ "' to '" + ((count == 2) ?
+ dest : src) + "': ");
+ if (webdavResource.putMethod(dest, url)) {
+ System.out.println("succeeded.");
+ } else {
+ System.err.println("failed.");
+ }
+ continue;
+ }
+ File file = new File(dir.getCanonicalPath(), src);
if (file.exists()) {
- System.out.print("Uploading '" + dest +
- "' to '" + src + "': ");
+ System.out.print("Uploading '" + src +
+ "' to '" + dest + "': ");
if (webdavResource.putMethod(dest, file)) {
System.out.println("succeeded.");
} else {
@@ -895,6 +910,8 @@
} else
System.err.println
("Warning: File not exists");
+ } catch (MalformedURLException mue) {
+ System.err.println("Warning: " + mue.getMessage());
} catch (WebdavException we) {
System.err.println("Warning: " + we.getMessage());
} catch (IOException e) {
@@ -1265,7 +1282,7 @@
private static void printSlideClientUsage() {
System.out.println(version + " commands:");
- System.out.println(" options [abs_path|http_URL] " +
+ System.out.println(" options {http_URL|path} " +
"Print available http methods");
System.out.println(" open [http_URL] " +
"Connect to specified URL");
@@ -1293,8 +1310,8 @@
"Print latest http status message");
System.out.println(" get path [file] " +
"Get a resource to a file");
- System.out.println(" put file path " +
- "Put a file to path");
+ System.out.println(" put {URL|file} [path] " +
+ "Put a given file or URL to path");
System.out.println(" mkcol path ... " +
"Make new collections");
System.out.println(" delete path ... " +
@@ -1311,7 +1328,7 @@
"Print value of specified property");
System.out.println(" propput path property value " +
"Set property with given value");
- System.out.println(" set urlencode [on|off] " +
+ System.out.println(" set urlencode {on|off} " +
"Set URL encoding flag, default: on");
System.out.println("Aliases: help=?, ls=dir, pwc=pwd, cc=cd, " +
"copy=cp, move=mv, delete=del=rm,\n mkcol=mkdir, " +