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 lu...@apache.org on 2004/08/15 15:01:15 UTC
cvs commit: jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs Delete.java Get.java Proppatch.java Put.java WebdavTask.java
luetzkendorf 2004/08/15 06:01:15
Modified: webdavclient/ant/src/java/org/apache/webdav/ant Tag:
SLIDE_2_1_RELEASE_BRANCH CollectionScanner.java
ResourceProperties.java Utils.java
WebdavFileSet.java
webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs
Tag: SLIDE_2_1_RELEASE_BRANCH Delete.java Get.java
Proppatch.java Put.java WebdavTask.java
Log:
first step for supporting https urls
Revision Changes Path
No revision
No revision
1.3.2.1 +7 -7 jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/CollectionScanner.java
Index: CollectionScanner.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/CollectionScanner.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- CollectionScanner.java 28 Jul 2004 09:31:49 -0000 1.3
+++ CollectionScanner.java 15 Aug 2004 13:01:15 -0000 1.3.2.1
@@ -97,7 +97,7 @@
throws URIException
{
if (!collURL.getPath().endsWith(SEPARATOR)) {
- collURL = new HttpURL(collURL, "");
+ collURL = Utils.createHttpURL(collURL, "");
collURL.setPath(collURL.getPath() + SEPARATOR);
}
@@ -132,9 +132,9 @@
if (!href.endsWith(SEPARATOR)) href = href + SEPARATOR;
// the collection URL itself may be in the list of
// response URL; filter them out to avoid recursion
- HttpURL sub = new HttpURL(collURL, href);
+ HttpURL sub = Utils.createHttpURL(collURL, href);
if (!sub.equals(collURL)) {
- subCollections.add(new HttpURL(collURL, href));
+ subCollections.add(Utils.createHttpURL(collURL, href));
}
} else {
addResource(href, false);
@@ -154,7 +154,7 @@
throws ScanException
{
try {
- String path = (new HttpURL(getBaseURL(), href)).getPath();
+ String path = (Utils.createHttpURL(getBaseURL(), href)).getPath();
String relPath = path.substring(getBaseURL().getPath().length());
if (relPath.startsWith(SEPARATOR)) {
relPath = relPath.substring(1);
1.3.2.1 +5 -5 jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/ResourceProperties.java
Index: ResourceProperties.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/ResourceProperties.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- ResourceProperties.java 28 Jul 2004 09:31:49 -0000 1.3
+++ ResourceProperties.java 15 Aug 2004 13:01:15 -0000 1.3.2.1
@@ -76,7 +76,7 @@
PropertyName propertyName)
throws URIException
{
- HttpURL url = new HttpURL(baseUrl, relative);
+ HttpURL url = Utils.createHttpURL(baseUrl, relative);
return getProperty(url.getURI(), propertyName);
}
@@ -109,7 +109,7 @@
public ResourceTypeProperty getResourceType(HttpURL baseUrl, String relative)
throws URIException
{
- HttpURL url = new HttpURL(baseUrl, relative);
+ HttpURL url = Utils.createHttpURL(baseUrl, relative);
return getResourceType(url.toString());
}
1.7.2.1 +34 -6 jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/Utils.java
Index: Utils.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/Utils.java,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- Utils.java 2 Aug 2004 15:45:51 -0000 1.7
+++ Utils.java 15 Aug 2004 13:01:15 -0000 1.7.2.1
@@ -38,6 +38,8 @@
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpURL;
+import org.apache.commons.httpclient.HttpsURL;
+import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.httpclient.methods.PutMethod;
@@ -222,7 +224,7 @@
Stack toBeCreated = new Stack();
while (!path.equals("/")) {
- HttpURL parent = new HttpURL(httpURL, path);
+ HttpURL parent = Utils.createHttpURL(httpURL, path);
if (!collectionExists(client, parent)) {
toBeCreated.push(path);
path = path.substring(0, path.lastIndexOf("/", path.length()-2)+1);
@@ -233,7 +235,7 @@
boolean created = !toBeCreated.empty();
while(!toBeCreated.empty()) {
- HttpURL newColl = new HttpURL(httpURL, (String)toBeCreated.pop());
+ HttpURL newColl = Utils.createHttpURL(httpURL, (String)toBeCreated.pop());
MkcolMethod mkcol = new MkcolMethod(newColl.getURI());
generateIfHeader(mkcol, lockToken);
int status = client.executeMethod(mkcol);
@@ -353,7 +355,11 @@
String destination, int depth, boolean overwrite)
throws IOException, HttpException
{
- CopyMethod copy = new CopyMethod(url.getURI(), destination, overwrite, depth);
+ CopyMethod copy = new CopyMethod(
+ url.getURI(),
+ destination,
+ overwrite,
+ depth);
int status = client.executeMethod(copy);
switch (status) {
case WebdavStatus.SC_OK:
@@ -435,4 +441,26 @@
return new BuildException(b.toString());
}
+
+
+ public static HttpURL createHttpURL(HttpURL base, String relative)
+ throws URIException
+ {
+ if (base instanceof HttpsURL) {
+ return new HttpsURL((HttpsURL)base, relative);
+ } else {
+ return new HttpURL(base, relative);
+ }
+ }
+
+ public static HttpURL createHttpURL(String url) throws URIException
+ {
+ if (url.startsWith("https://")) {
+ return new HttpsURL(url);
+ } else {
+ return new HttpURL(url);
+ }
+ }
+
+
}
1.3.2.1 +4 -4 jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/WebdavFileSet.java
Index: WebdavFileSet.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/WebdavFileSet.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- WebdavFileSet.java 28 Jul 2004 09:31:49 -0000 1.3
+++ WebdavFileSet.java 15 Aug 2004 13:01:15 -0000 1.3.2.1
@@ -59,7 +59,7 @@
CollectionScanner scanner = new CollectionScanner();
try {
- scanner.setBaseURL(new HttpURL(baseUrl, directory));
+ scanner.setBaseURL(Utils.createHttpURL(baseUrl, directory));
} catch (URIException e) {
throw new BuildException("Invalid URL. " + e.toString(), e);
}
No revision
No revision
1.5.2.1 +5 -5 jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/Delete.java
Index: Delete.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/Delete.java,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- Delete.java 2 Aug 2004 15:45:50 -0000 1.5
+++ Delete.java 15 Aug 2004 13:01:15 -0000 1.5.2.1
@@ -109,12 +109,12 @@
String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
- HttpURL url = new HttpURL(baseUrl, files[i]);
+ HttpURL url = Utils.createHttpURL(baseUrl, files[i]);
delete(url, files[i]);
}
String[] colls = scanner.getIncludedDirectories();
for (int i = 0; i < colls.length; i++) {
- HttpURL url = new HttpURL(baseUrl, colls[i]);
+ HttpURL url = Utils.createHttpURL(baseUrl, colls[i]);
delete(url, colls[i]);
}
}
1.3.2.1 +4 -4 jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/Get.java
Index: Get.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/Get.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- Get.java 28 Jul 2004 09:31:47 -0000 1.3
+++ Get.java 15 Aug 2004 13:01:15 -0000 1.3.2.1
@@ -120,7 +120,7 @@
String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
- HttpURL url = new HttpURL(baseUrl, files[i]);
+ HttpURL url = Utils.createHttpURL(baseUrl, files[i]);
downloadFile(url, files[i], scanner);
}
}
1.4.2.1 +5 -5 jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/Proppatch.java
Index: Proppatch.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/Proppatch.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- Proppatch.java 2 Aug 2004 15:45:50 -0000 1.4
+++ Proppatch.java 15 Aug 2004 13:01:15 -0000 1.4.2.1
@@ -153,12 +153,12 @@
String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; i++) {
- HttpURL url = new HttpURL(baseUrl, files[i]);
+ HttpURL url = Utils.createHttpURL(baseUrl, files[i]);
proppatch(url, files[i]);
}
String[] colls = scanner.getIncludedDirectories();
for (int i = 0; i < colls.length; i++) {
- HttpURL url = new HttpURL(baseUrl, colls[i]);
+ HttpURL url = Utils.createHttpURL(baseUrl, colls[i]);
proppatch(url, colls[i]);
}
}
1.3.2.1 +9 -9 jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/Put.java
Index: Put.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/Put.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- Put.java 28 Jul 2004 09:31:47 -0000 1.3
+++ Put.java 15 Aug 2004 13:01:15 -0000 1.3.2.1
@@ -162,7 +162,7 @@
Utils.assureExistingCollection(getHttpClient(), getUrl(), this.locktoken);
uploadFile(this.file.getName(), this.file);
} else {
- HttpURL targetColl = new HttpURL(getUrl(), ".");
+ HttpURL targetColl = Utils.createHttpURL(getUrl(), ".");
Utils.assureExistingCollection(getHttpClient(), targetColl, this.locktoken);
uploadFile(getUrl(), this.file, this.file.getName());
}
@@ -245,7 +245,7 @@
getUrl(),
this.locktoken);
} else {
- HttpURL collURL = new HttpURL(getUrl(), dir + "/");
+ HttpURL collURL = Utils.createHttpURL(getUrl(), dir + "/");
Utils.assureExistingCollection(getHttpClient(),
collURL,
this.locktoken);
@@ -291,7 +291,7 @@
private void uploadFile(String relative, File file)
throws IOException
{
- HttpURL url = new HttpURL(getUrl(), relative);
+ HttpURL url = Utils.createHttpURL(getUrl(), relative);
uploadFile(url, file, relative);
}
/**
@@ -372,7 +372,7 @@
getUrl(),
this.locktoken);
} else {
- HttpURL collURL = new HttpURL(getUrl(), dir + "/");
+ HttpURL collURL = Utils.createHttpURL(getUrl(), dir + "/");
Utils.assureExistingCollection(getHttpClient(),
collURL,
this.locktoken);
@@ -382,7 +382,7 @@
// write all files
String[] files = scanner.getIncludedFiles();
for (int i = 0; i < files.length; ++i) {
- uploadZipEntry(new HttpURL(getUrl(), files[i]), files[i], zipFile);
+ uploadZipEntry(Utils.createHttpURL(getUrl(), files[i]), files[i], zipFile);
}
}
1.4.2.1 +10 -8 jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/WebdavTask.java
Index: WebdavTask.java
===================================================================
RCS file: /home/cvs/jakarta-slide/webdavclient/ant/src/java/org/apache/webdav/ant/taskdefs/WebdavTask.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- WebdavTask.java 8 Aug 2004 13:28:07 -0000 1.4
+++ WebdavTask.java 15 Aug 2004 13:01:15 -0000 1.4.2.1
@@ -29,6 +29,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.apache.webdav.ant.Utils;
/**
* Base class of all WebDAV tasks. Provides common attributes and the creation
@@ -93,13 +94,14 @@
*/
public void setUrl(String url) {
try {
- this.url = new HttpURL(url);
+ this.url = Utils.createHttpURL(url);
// remove double slashes in url like /DAV/files//document.txt
- this.url.setPath(removeDoubleShashes(this.url.getPath()));
+ this.url.setPath(removeDoubleSlashes(this.url.getPath()));
} catch (URIException e) {
throw new BuildException("Invalid uri!", e);
}
}
+
protected void setUrl(HttpURL url) {
this.url = url;
}
@@ -119,19 +121,19 @@
return this.verbose ? Project.MSG_INFO : Project.MSG_VERBOSE;
}
- protected HttpURL assureCollectionUrl(HttpURL url)
+ public static HttpURL assureCollectionUrl(HttpURL url)
throws URIException
{
if (url.getPath().endsWith("/")) {
return url;
} else {
- HttpURL coll = new HttpURL(url, "");
+ HttpURL coll = Utils.createHttpURL(url, "");
coll.setPath(url.getPath() + "/");
return coll;
}
}
- static String removeDoubleShashes(String path) {
+ static String removeDoubleSlashes(String path) {
if (path.indexOf("//") == -1) return path;
StringBuffer r = new StringBuffer(path.length());
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org