}
}
private IRemoteFile createRemoteFile(String string)
throws URISyntaxException, FileCreateException, SecurityException {
URLRemoteFile file = null;
IFileID id = null;
String[] parts = string.split("\\|");
// Check to see if this string can be parsed
if (parts.length < 4) {
id = FileIDFactory.getDefault().createFileID(
IDFactory.getDefault().getNamespaceByName(
FileTransferNamespace.PROTOCOL), "scp://unknown");
file = new URLRemoteFile(0, 0, id);
} else {
// Build the filename back up, since the filename may also contain
// "|"
// characters
StringBuilder builder = new StringBuilder("scp://");
for (int i = 3; i < parts.length; i++) {
builder.append(parts[i]);
// Put the | back into the name
if (i > 3 && i < parts.length - 1) {
builder.append("|");
}
}
// If it's a directory, then make sure it ends with /
if (parts[0].equals("directory")
&& !builder.toString().endsWith("/")) {
builder.append("/");
} else if (!parts[0].equals("directory")
&& builder.toString().endsWith("/")) {
builder.deleteCharAt(builder.length() - 1);
}
String originalName = builder.toString();
String formatedName = originalName.replace(" ", "%20");
URI uri = new URI(formatedName);
// Create the FileID
id = FileIDFactory.getDefault().createFileID(
IDFactory.getDefault().getNamespaceByName(
FileTransferNamespace.PROTOCOL),
new Object[] { uri });
long size = Long.parseLong(parts[1]);
long modification = Long.parseLong(parts[2]);
file = new URLRemoteFile(modification, size, id);
}
return file;
}