|
@@ -43,6 +43,10 @@ import java.util.Set;
|
|
|
* Please note:
|
|
* Please note:
|
|
|
* As every URIHandler, it should not be constructed directly, but connected with some instance of URIResolver.
|
|
* As every URIHandler, it should not be constructed directly, but connected with some instance of URIResolver.
|
|
|
*
|
|
*
|
|
|
|
|
+ * Supported query parameters:
|
|
|
|
|
+ * charset = UTF-8
|
|
|
|
|
+ * timeout = 1000
|
|
|
|
|
+ *
|
|
|
* @author Ranides Atterwim {@literal <ranides@gmail.com>}
|
|
* @author Ranides Atterwim {@literal <ranides@gmail.com>}
|
|
|
*/
|
|
*/
|
|
|
public class CFTPHandler implements URIHandler {
|
|
public class CFTPHandler implements URIHandler {
|
|
@@ -285,7 +289,8 @@ public class CFTPHandler implements URIHandler {
|
|
|
private final Optional<String> user;
|
|
private final Optional<String> user;
|
|
|
private final Optional<String> pass;
|
|
private final Optional<String> pass;
|
|
|
private final Optional<Integer> port;
|
|
private final Optional<Integer> port;
|
|
|
-
|
|
|
|
|
|
|
+ private final int timeout;
|
|
|
|
|
+
|
|
|
public FTPHostName(URI uri, UserStore users) {
|
|
public FTPHostName(URI uri, UserStore users) {
|
|
|
host = uri.getHost();
|
|
host = uri.getHost();
|
|
|
Optional<GenericMap<String>> uis = users.find(uri).last();
|
|
Optional<GenericMap<String>> uis = users.find(uri).last();
|
|
@@ -298,6 +303,7 @@ public class CFTPHandler implements URIHandler {
|
|
|
pass = Optional.empty();
|
|
pass = Optional.empty();
|
|
|
}
|
|
}
|
|
|
port = URIUtils.getPort(uri);
|
|
port = URIUtils.getPort(uri);
|
|
|
|
|
+ timeout = URIUtils.getParam(uri, "timeout").map(Integer::valueOf).orElse(CONNECT_TIMEOUT);
|
|
|
hash = HashUtils.hashValues(5, 23, host, user, pass, port);
|
|
hash = HashUtils.hashValues(5, 23, host, user, pass, port);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -325,10 +331,10 @@ public class CFTPHandler implements URIHandler {
|
|
|
ftp.configure(config);
|
|
ftp.configure(config);
|
|
|
|
|
|
|
|
if(port.isPresent()) {
|
|
if(port.isPresent()) {
|
|
|
- ftp.setConnectTimeout(CONNECT_TIMEOUT);
|
|
|
|
|
|
|
+ ftp.setConnectTimeout(timeout);
|
|
|
ftp.connect(host, port.get());
|
|
ftp.connect(host, port.get());
|
|
|
} else {
|
|
} else {
|
|
|
- ftp.setConnectTimeout(CONNECT_TIMEOUT);
|
|
|
|
|
|
|
+ ftp.setConnectTimeout(timeout);
|
|
|
ftp.connect(host);
|
|
ftp.connect(host);
|
|
|
}
|
|
}
|
|
|
ftp.enterLocalPassiveMode();
|
|
ftp.enterLocalPassiveMode();
|