Search in sources :

Example 1 with FileURL

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

the class QuickFindAction method performAction.

@Override
public void performAction() {
    AbstractFile currentFile = mainFrame.getActivePanel().getCurrentFolder();
    FileURL searchURL = SearchUtils.toSearchURL(currentFile);
    LocationTextField locationTextField = mainFrame.getActivePanel().getLocationTextField();
    locationTextField.setText(searchURL.toString());
    locationTextField.requestFocus();
}
Also used : FileURL(com.mucommander.commons.file.FileURL) LocationTextField(com.mucommander.ui.main.LocationTextField) AbstractFile(com.mucommander.commons.file.AbstractFile)

Example 2 with FileURL

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

the class VSphereFile method ls.

@Override
public AbstractFile[] ls() throws IOException, UnsupportedFileOperationException {
    List<GuestFileInfo> fileInfos = new ArrayList<GuestFileInfo>();
    int index = 0;
    VsphereConnHandler connHandler = null;
    try {
        connHandler = getConnHandler();
        ManagedObjectReference fileManager = getFileManager(connHandler);
        boolean haveRemaining;
        do {
            GuestListFileInfo res = connHandler.getClient().getVimPort().listFilesInGuest(fileManager, vm, credentials, getPathInVm(), index, null, null);
            haveRemaining = (res.getRemaining() != 0);
            fileInfos.addAll(res.getFiles());
            index = fileInfos.size();
        } while (haveRemaining);
        String parentPath = PathUtils.removeTrailingSeparator(fileURL.getPath()) + SEPARATOR;
        Collection<AbstractFile> res = new ArrayList<AbstractFile>();
        for (GuestFileInfo f : fileInfos) {
            final String name = getFileName(f.getPath());
            if (name.equals(".") || name.equals("..")) {
                continue;
            }
            FileURL childURL = (FileURL) fileURL.clone();
            childURL.setPath(parentPath + name);
            AbstractFile newFile = new VSphereFile(childURL, this, f);
            res.add(newFile);
        }
        return res.toArray(new AbstractFile[0]);
    } catch (FileFaultFaultMsg e) {
        translateandLogException(e);
    } catch (GuestOperationsFaultFaultMsg e) {
        translateandLogException(e);
    } catch (InvalidStateFaultMsg e) {
        translateandLogException(e);
    } catch (RuntimeFaultFaultMsg e) {
        translateandLogException(e);
    } catch (TaskInProgressFaultMsg e) {
        translateandLogException(e);
    } catch (InvalidPropertyFaultMsg e) {
        translateandLogException(e);
    } catch (URISyntaxException e) {
        translateandLogException(e);
    } finally {
        releaseConnHandler(connHandler);
    }
    // we never get here..
    return null;
}
Also used : GuestListFileInfo(com.vmware.vim25.GuestListFileInfo) GuestFileInfo(com.vmware.vim25.GuestFileInfo) AbstractFile(com.mucommander.commons.file.AbstractFile) TaskInProgressFaultMsg(com.vmware.vim25.TaskInProgressFaultMsg) ArrayList(java.util.ArrayList) RuntimeFaultFaultMsg(com.vmware.vim25.RuntimeFaultFaultMsg) URISyntaxException(java.net.URISyntaxException) FileURL(com.mucommander.commons.file.FileURL) InvalidStateFaultMsg(com.vmware.vim25.InvalidStateFaultMsg) InvalidPropertyFaultMsg(com.vmware.vim25.InvalidPropertyFaultMsg) FileFaultFaultMsg(com.vmware.vim25.FileFaultFaultMsg) GuestOperationsFaultFaultMsg(com.vmware.vim25.GuestOperationsFaultFaultMsg) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 3 with FileURL

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

the class VSphereFile method getRoot.

@Override
public AbstractFile getRoot() {
    FileURL rootURL = (FileURL) getURL().clone();
    String rootPath = getRootPath();
    rootURL.setPath("/" + vmIdentifier + "/" + rootPath);
    return FileFactory.getFile(rootURL);
}
Also used : FileURL(com.mucommander.commons.file.FileURL)

Example 4 with FileURL

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

the class S3File method getParent.

// ///////////////////////////////
// ProtocolFile implementation //
// ///////////////////////////////
@Override
public AbstractFile getParent() {
    if (!parentSet) {
        FileURL parentFileURL = this.fileURL.getParent();
        if (parentFileURL != null) {
            try {
                parent = FileFactory.getFile(parentFileURL, null, Collections.singletonMap("service", service));
            } catch (IOException e) {
            // No parent
            }
        }
        parentSet = true;
    }
    return parent;
}
Also used : FileURL(com.mucommander.commons.file.FileURL) IOException(java.io.IOException)

Example 5 with FileURL

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

the class S3File method listObjects.

protected AbstractFile[] listObjects(String bucketName, String prefix, S3File parent) throws IOException {
    try {
        StorageObjectsChunk chunk = service.listObjectsChunked(bucketName, prefix, "/", Constants.DEFAULT_OBJECT_LIST_CHUNK_SIZE, null, true);
        StorageObject[] objects = chunk.getObjects();
        String[] commonPrefixes = chunk.getCommonPrefixes();
        if (objects.length == 0 && !prefix.equals("")) {
            // This happens only when the directory does not exist
            throw new IOException();
        }
        AbstractFile[] children = new AbstractFile[objects.length + commonPrefixes.length];
        FileURL childURL;
        int i = 0;
        String objectKey;
        for (StorageObject object : objects) {
            // Discard the object corresponding to the prefix itself
            objectKey = object.getKey();
            if (objectKey.equals(prefix))
                continue;
            childURL = (FileURL) fileURL.clone();
            childURL.setPath(bucketName + "/" + objectKey);
            Map<String, Object> parameters = new HashMap<>();
            parameters.put("service", service);
            parameters.put("object", object);
            children[i] = FileFactory.getFile(childURL, parent, parameters);
            i++;
        }
        org.jets3t.service.model.S3Object directoryObject;
        for (String commonPrefix : commonPrefixes) {
            childURL = (FileURL) fileURL.clone();
            childURL.setPath(bucketName + "/" + commonPrefix);
            directoryObject = new org.jets3t.service.model.S3Object(commonPrefix);
            // Common prefixes are not objects per se, and therefore do not have a date, content-length nor owner.
            directoryObject.setLastModifiedDate(new Date(System.currentTimeMillis()));
            directoryObject.setContentLength(0);
            Map<String, Object> parameters = new HashMap<>();
            parameters.put("service", service);
            parameters.put("object", directoryObject);
            children[i] = FileFactory.getFile(childURL, parent, parameters);
            i++;
        }
        // to know in advance whether the prefix will appear in the results or not.
        if (i < children.length) {
            AbstractFile[] childrenTrimmed = new AbstractFile[i];
            System.arraycopy(children, 0, childrenTrimmed, 0, i);
            return childrenTrimmed;
        }
        return children;
    } catch (ServiceException e) {
        throw getIOException(e);
    }
}
Also used : StorageObject(org.jets3t.service.model.StorageObject) AbstractFile(com.mucommander.commons.file.AbstractFile) StorageObjectsChunk(org.jets3t.service.StorageObjectsChunk) HashMap(java.util.HashMap) IOException(java.io.IOException) Date(java.util.Date) FileURL(com.mucommander.commons.file.FileURL) ServiceException(org.jets3t.service.ServiceException) StorageObject(org.jets3t.service.model.StorageObject)

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