use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.
the class S3Root method ls.
@Override
public AbstractFile[] ls() throws IOException {
try {
org.jets3t.service.model.S3Bucket[] buckets = service.listAllBuckets();
int nbBuckets = buckets.length;
AbstractFile[] bucketFiles = new AbstractFile[nbBuckets];
FileURL bucketURL;
for (int i = 0; i < nbBuckets; i++) {
bucketURL = (FileURL) fileURL.clone();
bucketURL.setPath("/" + buckets[i].getName());
Map<String, Object> parameters = new HashMap<>();
parameters.put("service", service);
parameters.put("bucket", buckets[i]);
bucketFiles[i] = FileFactory.getFile(bucketURL, null, parameters);
}
return bucketFiles;
} catch (S3ServiceException e) {
throw getIOException(e);
}
}
use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.
the class HadoopFile method ls.
// //////////////////////
// Overridden methods //
// //////////////////////
@Override
public AbstractFile[] ls(FilenameFilter filter) throws IOException {
// throw an exception
if (!exists() || !isDirectory())
throw new IOException();
FileStatus[] statuses = filter == null ? fs.listStatus(path) : fs.listStatus(path, new HadoopFilenameFilter(filter));
int nbChildren = statuses == null ? 0 : statuses.length;
AbstractFile[] children = new AbstractFile[nbChildren];
String parentPath = fileURL.getPath();
if (!parentPath.endsWith("/"))
parentPath += "/";
FileURL childURL;
FileStatus childStatus;
for (int i = 0; i < nbChildren; i++) {
childStatus = statuses[i];
childURL = (FileURL) fileURL.clone();
childURL.setPath(parentPath + childStatus.getPath().getName());
Map<String, Object> parameters = new HashMap<>();
parameters.put("file-system", fs);
parameters.put("file-status", childStatus);
children[i] = FileFactory.getFile(childURL, this, parameters);
}
return children;
}
use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.
the class SFTPPanel method getServerURL.
// //////////////////////////////
// ServerPanel implementation //
// //////////////////////////////
@Override
public FileURL getServerURL() throws MalformedURLException {
updateValues();
if (!lastInitialDir.startsWith("/"))
lastInitialDir = "/" + lastInitialDir;
FileURL url = FileURL.getFileURL(FileProtocols.SFTP + "://" + lastServer + lastInitialDir);
// Set credentials
url.setCredentials(new Credentials(lastUsername, lastPassword));
if (!"".equals(lastKeyPath.trim()))
url.setProperty(SFTPFile.PRIVATE_KEY_PATH_PROPERTY_NAME, lastKeyPath);
// Set port
url.setPort(lastPort);
return url;
}
use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.
the class Activator method start.
@Override
public void start(BundleContext context) throws Exception {
FileProtocolService service = new FileProtocolService() {
@Override
public String getSchema() {
return "smb";
}
@Override
public ProtocolProvider getProtocolProvider() {
return new SMBProtocolProvider();
}
@Override
public SchemeHandler getSchemeHandler() {
return new DefaultSchemeHandler(new DefaultSchemeParser(), -1, "/", AuthenticationType.AUTHENTICATION_REQUIRED, new Credentials("GUEST", "")) {
@Override
public FileURL getRealm(FileURL location) {
FileURL realm = new FileURL(this);
String newPath = location.getPath();
// Find first path token (share)
int pos = newPath.indexOf('/', 1);
newPath = newPath.substring(0, pos == -1 ? newPath.length() : pos + 1);
realm.setPath(newPath);
realm.setScheme(location.getScheme());
realm.setHost(location.getHost());
realm.setPort(location.getPort());
// Copy properties (if any)
realm.importProperties(location);
return realm;
}
};
}
};
ProtocolPanelProvider panelProvider = new ProtocolPanelProvider() {
@Override
public String getSchema() {
return "smb";
}
@Override
public ServerPanel get(ServerPanelListener listener, JFrame mainFrame) {
return new SMBPanel(listener, mainFrame);
}
@Override
public int priority() {
return 4000;
}
@Override
public Class<? extends ServerPanel> getPanelClass() {
return SMBPanel.class;
}
};
serviceRegistration = context.registerService(FileProtocolService.class, service, null);
uiServiceRegistration = context.registerService(ProtocolPanelProvider.class, panelProvider, null);
}
use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.
the class GoogleDriveFile method getChild.
@Override
public AbstractFile getChild(String filename, AbstractFile template) throws IOException {
if (template == null)
return super.getChild(filename, template);
FileURL url = (FileURL) getURL().clone();
String parentPath = PathUtils.removeTrailingSeparator(url.getPath()) + AbstractFile.DEFAULT_SEPARATOR;
url.setPath(parentPath + filename);
return new GoogleDriveFile(url);
}
Aggregations