| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.apache.camel.component.file.remote; |
| 18 |
|
|
| 19 |
|
import java.net.URI; |
| 20 |
|
|
| 21 |
|
import org.apache.camel.RuntimeCamelException; |
| 22 |
|
|
| 23 |
|
public class RemoteFileConfiguration implements Cloneable { |
| 24 |
|
private String protocol; |
| 25 |
|
private String username; |
| 26 |
|
private String host; |
| 27 |
|
private int port; |
| 28 |
|
private String password; |
| 29 |
|
private String file; |
| 30 |
|
private boolean binary; |
| 31 |
6 |
private boolean directory = true; |
| 32 |
|
|
| 33 |
6 |
public RemoteFileConfiguration() { |
| 34 |
6 |
} |
| 35 |
|
|
| 36 |
0 |
public RemoteFileConfiguration(URI uri) { |
| 37 |
0 |
configure(uri); |
| 38 |
0 |
} |
| 39 |
|
|
| 40 |
|
public RemoteFileConfiguration copy() { |
| 41 |
|
try { |
| 42 |
6 |
return (RemoteFileConfiguration)clone(); |
| 43 |
0 |
} catch (CloneNotSupportedException e) { |
| 44 |
0 |
throw new RuntimeCamelException(e); |
| 45 |
|
} |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
public String toString() { |
| 49 |
0 |
return protocol + ":\\" + username + "@" + host + ":" + port + "/" + directory; |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
public void configure(URI uri) { |
| 53 |
6 |
setProtocol(uri.getScheme()); |
| 54 |
6 |
setDefaultPort(); |
| 55 |
6 |
setUsername(uri.getUserInfo()); |
| 56 |
6 |
setHost(uri.getHost()); |
| 57 |
6 |
setPort(uri.getPort()); |
| 58 |
6 |
setFile(uri.getPath()); |
| 59 |
6 |
} |
| 60 |
|
|
| 61 |
|
protected void setDefaultPort() { |
| 62 |
6 |
if ("ftp".equalsIgnoreCase(protocol)) { |
| 63 |
3 |
setPort(21); |
| 64 |
3 |
} else if ("sftp".equalsIgnoreCase(protocol)) { |
| 65 |
3 |
setPort(22); |
| 66 |
|
} |
| 67 |
6 |
} |
| 68 |
|
|
| 69 |
|
public String getFile() { |
| 70 |
6 |
return file; |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
public void setFile(String file) { |
| 74 |
6 |
this.file = file; |
| 75 |
6 |
} |
| 76 |
|
|
| 77 |
|
public String getHost() { |
| 78 |
6 |
return host; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
public void setHost(String host) { |
| 82 |
6 |
this.host = host; |
| 83 |
6 |
} |
| 84 |
|
|
| 85 |
|
public int getPort() { |
| 86 |
6 |
return port; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
public void setPort(int port) { |
| 90 |
12 |
if (port != -1) { |
| 91 |
10 |
this.port = port; |
| 92 |
|
} |
| 93 |
12 |
} |
| 94 |
|
|
| 95 |
|
public String getPassword() { |
| 96 |
0 |
return password; |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
public void setPassword(String password) { |
| 100 |
6 |
this.password = password; |
| 101 |
6 |
} |
| 102 |
|
|
| 103 |
|
public String getProtocol() { |
| 104 |
9 |
return protocol; |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
public void setProtocol(String protocol) { |
| 108 |
6 |
this.protocol = protocol; |
| 109 |
6 |
} |
| 110 |
|
|
| 111 |
|
public String getUsername() { |
| 112 |
6 |
return username; |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
public void setUsername(String username) { |
| 116 |
6 |
this.username = username; |
| 117 |
6 |
} |
| 118 |
|
|
| 119 |
|
public boolean isBinary() { |
| 120 |
4 |
return binary; |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
public void setBinary(boolean binary) { |
| 124 |
1 |
this.binary = binary; |
| 125 |
1 |
} |
| 126 |
|
|
| 127 |
|
public boolean isDirectory() { |
| 128 |
6 |
return directory; |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
public void setDirectory(boolean directory) { |
| 132 |
1 |
this.directory = directory; |
| 133 |
1 |
} |
| 134 |
|
|
| 135 |
|
public String dump() { |
| 136 |
0 |
return "RemoteFileConfiguration{" + "protocol='" + protocol + '\'' + ", username='" + username + '\'' + ", host='" + host + '\'' + ", port=" + port + ", password='" + password + '\'' |
| 137 |
|
+ ", file='" + file + '\'' + ", binary=" + binary + ", directory=" + directory + '}'; |
| 138 |
|
} |
| 139 |
|
} |