Author: maartenc
Date: Wed Aug 6 15:46:07 2008
New Revision: 683438
URL: http://svn.apache.org/viewvc?rev=683438&view=rev
Log:
FIX: Incorrect parsing artifactPattern attribute in a sftp resolver (IVY-661)
(thanks to Alexey Kiselev)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=683438&r1=683437&r2=683438&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Wed Aug 6 15:46:07 2008
@@ -38,6 +38,7 @@
Christer Jonsson
Michael Kebe
Matthias Kilian
+ Alexey Kiselev
Gregory Kisling
Tat Leung
Costin Leau
@@ -101,6 +102,7 @@
- IMPROVEMENT: Smarter determination if an expression is exact or not for
RegexpPatternMatcher and GlobPatternMatcher
- IMPROVEMENT: Check branch consistency during resolve (IVY-858)
+- FIX: Incorrect parsing artifactPattern attribute in a sftp resolver
(IVY-661) (thanks to Alexey Kiselev)
- FIX: Maven2 "ejb" packaging is not supported (IVY-873)
- FIX: Config files with # in path can't be read (IVY-868) (thanks to Simon
Steiner)
- FIX: Cache can't distinguish artifacts with classifiers (IVY-803) (thanks to
James P. White)
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java?rev=683438&r1=683437&r2=683438&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java
Wed Aug 6 15:46:07 2008
@@ -20,6 +20,8 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -87,7 +89,9 @@
public Resource resolveResource(String path) {
try {
ChannelSftp c = getSftpChannel(path);
- Collection r = c.ls(path);
+
+ Collection r = c.ls(getPath(path));
+
if (r != null) {
for (Iterator iter = r.iterator(); iter.hasNext();) {
Object obj = iter.next();
@@ -103,31 +107,44 @@
Message.debug("reolving resource error: " + e.getMessage());
// silent fail, return unexisting resource
}
+
return new BasicResource(path, false, 0, 0, false);
}
public InputStream openStream(SFTPResource resource) throws IOException {
ChannelSftp c = getSftpChannel(resource.getName());
try {
- return c.get(resource.getName());
+ String path = getPath(resource.getName());
+ return c.get(path);
} catch (SftpException e) {
IOException ex = new IOException("impossible to open stream for "
+ resource + " on "
+ getHost() + (e.getMessage() != null ? ": " +
e.getMessage() : ""));
ex.initCause(e);
throw ex;
- }
+ } catch (URISyntaxException e) {
+ IOException ex = new IOException("impossible to open stream for "
+ resource + " on "
+ + getHost() + (e.getMessage() != null ? ": " + e.getMessage()
: ""));
+ ex.initCause(e);
+ throw ex;
+ }
}
public void get(String source, File destination) throws IOException {
fireTransferInitiated(getResource(source), TransferEvent.REQUEST_GET);
ChannelSftp c = getSftpChannel(source);
try {
- c.get(source, destination.getAbsolutePath(), new
MyProgressMonitor());
+ String path = getPath(source);
+ c.get(path, destination.getAbsolutePath(), new
MyProgressMonitor());
} catch (SftpException e) {
IOException ex = new IOException("impossible to get " + source + "
on " + getHost()
+ (e.getMessage() != null ? ": " + e.getMessage() : ""));
ex.initCause(e);
throw ex;
+ } catch (URISyntaxException e) {
+ IOException ex = new IOException("impossible to get " + source + "
on " + getHost()
+ + (e.getMessage() != null ? ": " + e.getMessage() : ""));
+ ex.initCause(e);
+ throw ex;
}
}
@@ -135,17 +152,22 @@
fireTransferInitiated(getResource(destination),
TransferEvent.REQUEST_PUT);
ChannelSftp c = getSftpChannel(destination);
try {
- if (!overwrite && checkExistence(destination, c)) {
+ String path = getPath(destination);
+ if (!overwrite && checkExistence(path, c)) {
throw new IOException("destination file exists and overwrite
== false");
}
- if (destination.indexOf('/') != -1) {
- mkdirs(destination.substring(0, destination.lastIndexOf('/')),
c);
+ if (path.indexOf('/') != -1) {
+ mkdirs(path.substring(0, path.lastIndexOf('/')), c);
}
- c.put(source.getAbsolutePath(), destination, new
MyProgressMonitor());
+ c.put(source.getAbsolutePath(), path, new MyProgressMonitor());
} catch (SftpException e) {
IOException ex = new IOException(e.getMessage());
ex.initCause(e);
throw ex;
+ } catch (URISyntaxException e) {
+ IOException ex = new IOException(e.getMessage());
+ ex.initCause(e);
+ throw ex;
}
}
@@ -164,6 +186,18 @@
c.mkdir(directory);
}
}
+
+ private String getPath(String sftpURI) throws URISyntaxException {
+ String result = null;
+ URI uri = new URI(sftpURI);
+ result = uri.getPath();
+
+ if (result == null) {
+ throw new URISyntaxException(sftpURI, "Missing path in
URI.");
+ }
+
+ return result;
+ }
public List list(String parent) throws IOException {
try {