Search in sources :

Example 31 with FileURL

use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.

the class GoogleDriveFile method toFile.

private GoogleDriveFile toFile(File file) {
    FileURL url = (FileURL) getURL().clone();
    String parentPath = PathUtils.removeTrailingSeparator(url.getPath()) + AbstractFile.DEFAULT_SEPARATOR;
    url.setPath(parentPath + file.getName());
    GoogleDriveFile result = new GoogleDriveFile(url, file);
    result.setParent(this);
    return result;
}
Also used : FileURL(com.mucommander.commons.file.FileURL)

Example 32 with FileURL

use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.

the class DropboxConnectionHandler method getCredentialFileURL.

public static FileURL getCredentialFileURL(String account) throws IOException {
    AbstractFile credentialFolder = getCredentialsFolder();
    FileURL credentialFileURL = (FileURL) credentialFolder.getURL().clone();
    credentialFileURL.setPath(credentialFolder.addTrailingSeparator(credentialFileURL.getPath()) + account);
    return credentialFileURL;
}
Also used : FileURL(com.mucommander.commons.file.FileURL) AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 33 with FileURL

use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.

the class DropboxFile method ls.

@Override
public AbstractFile[] ls() throws IOException, UnsupportedFileOperationException {
    try (DropboxConnectionHandler connHandler = getConnHandler()) {
        DbxUserFilesRequests r = connHandler.getDbxClient().files();
        ListFolderResult result;
        try {
            result = r.listFolder(getId());
        } catch (DbxException e) {
            LOGGER.error("failed to list folder", e);
            return null;
        }
        return result.getEntries().stream().filter(meta -> !(meta instanceof DeletedMetadata)).map(meta -> {
            FileURL url = (FileURL) fileURL.clone();
            url.setPath(meta.getPathDisplay());
            return new DropboxFile(url, this, meta);
        }).toArray(AbstractFile[]::new);
    }
}
Also used : FileFactory(com.mucommander.commons.file.FileFactory) FilePermissions(com.mucommander.commons.file.FilePermissions) ConnectionPool(com.mucommander.commons.file.connection.ConnectionPool) BufferedInputStream(java.io.BufferedInputStream) Date(java.util.Date) ConnectionHandlerFactory(com.mucommander.commons.file.connection.ConnectionHandlerFactory) LoggerFactory(org.slf4j.LoggerFactory) WriteMode(com.dropbox.core.v2.files.WriteMode) ListFolderResult(com.dropbox.core.v2.files.ListFolderResult) BufferedOutputStream(java.io.BufferedOutputStream) CreateFolderResult(com.dropbox.core.v2.files.CreateFolderResult) ByteArrayInputStream(java.io.ByteArrayInputStream) ProtocolFile(com.mucommander.commons.file.protocol.ProtocolFile) FolderMetadata(com.dropbox.core.v2.files.FolderMetadata) SpaceUsage(com.dropbox.core.v2.users.SpaceUsage) DbxUserFilesRequests(com.dropbox.core.v2.files.DbxUserFilesRequests) PermissionBits(com.mucommander.commons.file.PermissionBits) PermissionType(com.mucommander.commons.file.PermissionType) DeletedMetadata(com.dropbox.core.v2.files.DeletedMetadata) OutputStream(java.io.OutputStream) Logger(org.slf4j.Logger) UploadSessionCursor(com.dropbox.core.v2.files.UploadSessionCursor) PermissionAccess(com.mucommander.commons.file.PermissionAccess) IOException(java.io.IOException) RandomAccessInputStream(com.mucommander.commons.io.RandomAccessInputStream) ConnectionHandler(com.mucommander.commons.file.connection.ConnectionHandler) PathUtils(com.mucommander.commons.file.util.PathUtils) FileMetadata(com.dropbox.core.v2.files.FileMetadata) DbxException(com.dropbox.core.DbxException) RandomAccessOutputStream(com.mucommander.commons.io.RandomAccessOutputStream) CommitInfo(com.dropbox.core.v2.files.CommitInfo) FileOperation(com.mucommander.commons.file.FileOperation) UnsupportedFileOperation(com.mucommander.commons.file.UnsupportedFileOperation) FileURL(com.mucommander.commons.file.FileURL) Metadata(com.dropbox.core.v2.files.Metadata) AbstractFile(com.mucommander.commons.file.AbstractFile) UnsupportedFileOperationException(com.mucommander.commons.file.UnsupportedFileOperationException) InputStream(java.io.InputStream) DbxUserFilesRequests(com.dropbox.core.v2.files.DbxUserFilesRequests) FileURL(com.mucommander.commons.file.FileURL) ListFolderResult(com.dropbox.core.v2.files.ListFolderResult) DeletedMetadata(com.dropbox.core.v2.files.DeletedMetadata) DbxException(com.dropbox.core.DbxException)

Example 34 with FileURL

use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.

the class DropboxPanel method getServerURL.

@Override
public FileURL getServerURL() throws MalformedURLException {
    FileURL url = FileURL.getFileURL(String.format("%s://%s", SCHEMA, accountAlias.getText()));
    url.setCredentials(new Credentials(accountAlias.getText(), token.getText()));
    return url;
}
Also used : FileURL(com.mucommander.commons.file.FileURL) Credentials(com.mucommander.commons.file.Credentials)

Example 35 with FileURL

use of com.mucommander.commons.file.FileURL in project mucommander by mucommander.

the class FTPPanel method getServerURL.

// //////////////////////////////
// ServerPanel implementation //
// //////////////////////////////
@Override
public FileURL getServerURL() throws MalformedURLException {
    updateValues();
    if (!lastInitialDir.startsWith("/"))
        lastInitialDir = "/" + lastInitialDir;
    FileURL url = FileURL.getFileURL(FileProtocols.FTP + "://" + lastServer + lastInitialDir);
    if (anonymousUser)
        url.setCredentials(new Credentials(ANONYMOUS_CREDENTIALS.getLogin(), new String(passwordField.getPassword())));
    else
        url.setCredentials(new Credentials(lastUsername, lastPassword));
    // Set port
    url.setPort(lastPort);
    // Set passiveMode property to true (default) or false
    url.setProperty(FTPFile.PASSIVE_MODE_PROPERTY_NAME, "" + passiveMode);
    // Set FTP encoding property
    url.setProperty(FTPFile.ENCODING_PROPERTY_NAME, encodingSelectBox.getSelectedEncoding());
    // Set connection retry properties
    url.setProperty(FTPFile.NB_CONNECTION_RETRIES_PROPERTY_NAME, "" + nbRetriesSpinner.getValue());
    url.setProperty(FTPFile.CONNECTION_RETRY_DELAY_PROPERTY_NAME, "" + retryDelaySpinner.getValue());
    return url;
}
Also used : FileURL(com.mucommander.commons.file.FileURL) Credentials(com.mucommander.commons.file.Credentials)

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