Package com.mucommander.commons.file

Examples of com.mucommander.commons.file.FileURL


            // in the event that the absolute path still didn't match canonical one after the file is
            // resolved again.
            if(!canonicalPathFollowed && followCanonicalPath(folder)) {
              try {
                // Recreate the FileURL using the file's canonical path
                FileURL newURL = FileURL.getFileURL(folder.getCanonicalPath());
                // Keep the credentials and properties (if any)
                newURL.setCredentials(folderURL.getCredentials());
                newURL.importProperties(folderURL);
                this.folderURL = newURL;
                // Invalidate the AbstractFile instance
                this.folder = null;
                // There won't be any further attempts after this one
                canonicalPathFollowed = true;
View Full Code Here


      // Make all actions active again
      mainFrame.setNoEventsMode(false);

      if(!folderChangedSuccessfully) {
        FileURL failedURL = folder==null?folderURL:folder.getURL();
        // Notifies listeners that location change has been cancelled by the user or has failed
        if(killed)
          locationManager.fireLocationCancelled(failedURL);
        else
          locationManager.fireLocationFailed(failedURL);
View Full Code Here

    ////////////////////////////////
 
    @Override
    FileURL getServerURL() throws MalformedURLException {
        updateValues();
        FileURL url = FileURL.getFileURL(FileProtocols.SMB+"://"+lastServer+(lastShare.startsWith("/")?"":"/")+lastShare);

        // Insert the domain (if any) before the username, separated by a semicolon
        String userInfo = lastUsername;
        if(!lastDomain.equals(""))
            userInfo = lastDomain+";"+userInfo;

        url.setCredentials(new Credentials(userInfo, lastPassword));

        return url;
    }
View Full Code Here

    }


    protected void updateURLLabel() {
        try {
            FileURL url = currentServerPanel.getServerURL();
            urlLabel.setText(url==null?" ":url.toString(false));
        }
        catch(MalformedURLException ex) {
            urlLabel.setText(" ");
        }
    }
View Full Code Here

        }

        try {
            currentServerPanel.dialogValidated();

            FileURL serverURL = currentServerPanel.getServerURL()// Can throw a MalformedURLException

            // Create a CredentialsMapping instance and pass to Folder so that it uses it to connect to the folder and
            // adds to CredentialsManager once the folder has been successfully changed
            Credentials credentials = serverURL.getCredentials();
            CredentialsMapping credentialsMapping;
            if(credentials!=null) {
                credentialsMapping = new CredentialsMapping(credentials, serverURL, saveCredentialsCheckBox.isSelected());
            }
            else {
View Full Code Here

    FileURL getServerURL() throws MalformedURLException {
        updateValues();
        if(!lastInitialDir.startsWith("/"))
            lastInitialDir = "/"+lastInitialDir;

        FileURL url = FileURL.getFileURL(FileProtocols.HDFS+"://"+lastServer+lastInitialDir);

        // Set user and group
        url.setCredentials(new Credentials(lastUsername, ""));
//        url.setProperty(HDFSFile.GROUP_PROPERTY_NAME, lastGroup);

        // Set port
        url.setPort(lastPort);

        return url;
    }
View Full Code Here

     * The button's icon will be the current folder's one.
     */
    private void updateButton() {
        AbstractFile currentFolder = folderPanel.getCurrentFolder();
        String currentPath = currentFolder.getAbsolutePath();
        FileURL currentURL = currentFolder.getURL();

        String newLabel = null;
//        String newToolTip = null;

        // First tries to find a bookmark matching the specified folder
        java.util.List<Bookmark> bookmarks = BookmarkManager.getBookmarks();
        int nbBookmarks = bookmarks.size();
        Bookmark b;
        for(int i=0; i<nbBookmarks; i++) {
            b = bookmarks.get(i);
            if(currentPath.equals(b.getLocation())) {
                // Note: if several bookmarks match current folder, the first one will be used
                newLabel = b.getName();
                break;
            }
        }
   
        // If no bookmark matched current folder
        if(newLabel == null) {
            String protocol = currentURL.getScheme();
            // Remote file, use the protocol's name
            if(!protocol.equals(FileProtocols.FILE)) {
                newLabel = protocol.toUpperCase();
            }
            // Local file, use volume's name
            else {
                // Patch for Windows UNC network paths (weakly characterized by having a host different from 'localhost'):
                // display 'SMB' which is the underlying protocol
                if(OsFamily.WINDOWS.isCurrent() && !FileURL.LOCALHOST.equals(currentURL.getHost())) {
                    newLabel = "SMB";
                }
                else {
                    // getCanonicalPath() must be avoided under Windows for the following reasons:
                    // a) it is not necessary, Windows doesn't have symlinks
View Full Code Here

    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;
    }
View Full Code Here

        updateValues();
       
        if(!(lastURL.toLowerCase().startsWith(FileProtocols.HTTP+"://") || lastURL.toLowerCase().startsWith(FileProtocols.HTTPS+"://")))
            lastURL = FileProtocols.HTTP+"://"+lastURL;

        FileURL fileURL = FileURL.getFileURL(lastURL);

        fileURL.setCredentials(new Credentials(lastUsername, lastPassword));

        return fileURL;
    }
View Full Code Here

        else if(qName.equals(ELEMENT_URL)) {
            // Until early 0.8 beta3 nightly builds, credentials were stored directly in the bookmark's url.
            // Now bookmark locations are free of credentials, these are stored in a dedicated credentials file where
            // the password is encrypted.
            try {
                FileURL url = FileURL.getFileURL(characters.toString().trim());
                Credentials credentials = url.getCredentials();

                // If the URL contains credentials, import them into CredentialsManager and remove credentials
                // from the bookmark's location
                if(credentials!=null) {
                    CredentialsManager.addCredentials(new CredentialsMapping(credentials, url, true));
                    bookmarkLocation = url.toString(false);
                }
                else {
                    bookmarkLocation = characters.toString().trim();
                }
            }
View Full Code Here

TOP

Related Classes of com.mucommander.commons.file.FileURL

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.