Search in sources :

Example 51 with FileURL

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);
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) HashMap(java.util.HashMap) S3ServiceException(org.jets3t.service.S3ServiceException) FileURL(com.mucommander.commons.file.FileURL)

Example 52 with FileURL

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;
}
Also used : FileURL(com.mucommander.commons.file.FileURL) FileStatus(org.apache.hadoop.fs.FileStatus) AbstractFile(com.mucommander.commons.file.AbstractFile) HashMap(java.util.HashMap) IOException(java.io.IOException)

Example 53 with FileURL

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;
}
Also used : FileURL(com.mucommander.commons.file.FileURL) Credentials(com.mucommander.commons.file.Credentials)

Example 54 with FileURL

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);
}
Also used : FileURL(com.mucommander.commons.file.FileURL) ServerPanelListener(com.mucommander.protocol.ui.ServerPanelListener) DefaultSchemeParser(com.mucommander.commons.file.DefaultSchemeParser) JFrame(javax.swing.JFrame) ProtocolPanelProvider(com.mucommander.protocol.ui.ProtocolPanelProvider) Credentials(com.mucommander.commons.file.Credentials) FileProtocolService(com.mucommander.commons.file.osgi.FileProtocolService) DefaultSchemeHandler(com.mucommander.commons.file.DefaultSchemeHandler)

Example 55 with FileURL

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);
}
Also used : FileURL(com.mucommander.commons.file.FileURL)

Aggregations

FileURL (com.mucommander.commons.file.FileURL)60 AbstractFile (com.mucommander.commons.file.AbstractFile)18 Credentials (com.mucommander.commons.file.Credentials)16 IOException (java.io.IOException)11 AuthException (com.mucommander.commons.file.AuthException)7 MalformedURLException (java.net.MalformedURLException)5 CredentialsMapping (com.mucommander.auth.CredentialsMapping)3 UnsupportedFileOperationException (com.mucommander.commons.file.UnsupportedFileOperationException)3 ProtocolFile (com.mucommander.commons.file.protocol.ProtocolFile)3 File (java.io.File)3 SftpException (com.jcraft.jsch.SftpException)2 AuthDialog (com.mucommander.ui.dialog.auth.AuthDialog)2 RandomAccessFile (java.io.RandomAccessFile)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 DbxException (com.dropbox.core.DbxException)1 DbxRequestConfig (com.dropbox.core.DbxRequestConfig)1 JsonReader (com.dropbox.core.json.JsonReader)1 DbxCredential (com.dropbox.core.oauth.DbxCredential)1