use of com.revolsys.io.file.FolderConnection in project com.revolsys.open by revolsys.
the class FileUtil method getFile.
public static File getFile(URI uri) {
final String scheme = uri.getScheme();
if ("folderconnection".equalsIgnoreCase(scheme)) {
final String authority = uri.getAuthority();
final String connectionName = UrlUtil.percentDecode(authority);
final String path = uri.getPath();
File file = null;
for (final FolderConnectionRegistry registry : FileConnectionManager.get().getConnectionRegistries()) {
final FolderConnection connection = registry.getConnection(connectionName);
if (connection != null) {
final File directory = connection.getFile();
file = new File(directory, path);
if (file.exists()) {
return getFile(file);
}
}
}
return file;
} else if ("file".equalsIgnoreCase(scheme)) {
try {
uri = new URI(scheme, uri.getPath(), null);
} catch (final URISyntaxException e) {
}
return getFile(new File(uri));
} else {
throw new IllegalArgumentException("file URL expected: " + uri);
}
}
Aggregations