This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 207116
Collapse All | Expand All

(-)a/dlight.remote.impl/src/org/netbeans/modules/remote/impl/fs/RemoteFileUrlMapper.java (+24 lines)
Lines 80-85 Link Here
80
                FileObject fo = fs.findResource(url.getFile());
80
                FileObject fo = fs.findResource(url.getFile());
81
                return new FileObject[] { fo };
81
                return new FileObject[] { fo };
82
            }
82
            }
83
        } else if (url.getProtocol().equals("file")) {
84
            String host = url.getHost();
85
            String user = url.getUserInfo();
86
            int port = url.getPort();
87
            if (host != null) {
88
                ExecutionEnvironment env;
89
                if (user != null) {
90
                    env = ExecutionEnvironmentFactory.createNew(user, host, port);
91
                } else {
92
                    RemoteLogger.assertTrue(false, "Trying to access remote file system without user name");
93
                    env = RemoteFileSystemUtils.getExecutionEnvironment(host, port);
94
                    if (env == null) {
95
                        user = System.getProperty("user.name");
96
                        if (user != null) {
97
                            env = ExecutionEnvironmentFactory.createNew(user, host, port);
98
                        }
99
                    }
100
                }
101
                if (env != null) {
102
                    RemoteFileSystem fs = RemoteFileSystemManager.getInstance().getFileSystem(env);
103
                    FileObject fo = fs.findResource(url.getFile());
104
                    return new FileObject[] { fo };
105
                }
106
            }
83
        }
107
        }
84
        return null;
108
        return null;
85
    }
109
    }
(-)a/dlight.remote/src/org/netbeans/modules/remote/api/ui/FileObjectBasedFile.java (+47 lines)
Lines 47-52 Link Here
47
import java.io.IOException;
47
import java.io.IOException;
48
import java.io.StringWriter;
48
import java.io.StringWriter;
49
import java.io.Writer;
49
import java.io.Writer;
50
import java.net.MalformedURLException;
51
import java.net.URI;
52
import java.net.URISyntaxException;
53
import java.net.URL;
50
import java.util.ArrayList;
54
import java.util.ArrayList;
51
import java.util.List;
55
import java.util.List;
52
import java.util.concurrent.Callable;
56
import java.util.concurrent.Callable;
Lines 61-67 Link Here
61
import org.netbeans.modules.remote.support.RemoteLogger;
65
import org.netbeans.modules.remote.support.RemoteLogger;
62
import org.openide.filesystems.FileLock;
66
import org.openide.filesystems.FileLock;
63
import org.openide.filesystems.FileObject;
67
import org.openide.filesystems.FileObject;
68
import org.openide.filesystems.FileStateInvalidException;
64
import org.openide.filesystems.FileUtil;
69
import org.openide.filesystems.FileUtil;
70
import org.openide.util.Exceptions;
65
import org.openide.util.RequestProcessor;
71
import org.openide.util.RequestProcessor;
66
import org.openide.util.Utilities;
72
import org.openide.util.Utilities;
67
73
Lines 245-250 Link Here
245
    }
251
    }
246
    
252
    
247
    @Override
253
    @Override
254
    public boolean delete() {
255
        if (fo == null) {
256
            fo = FileSystemProvider.getFileObject(env, path);
257
        }
258
        if (fo != null) {
259
            try {
260
                fo.delete();
261
                return true;
262
            } catch (IOException ex) {
263
                return false;
264
            }
265
        }
266
        return false;
267
    }
268
269
    @Override
270
    public URL toURL() throws MalformedURLException {
271
        URL url = getURL(env, path, isDirectory());
272
        return url;
273
    }
274
275
    private static URL getURL(ExecutionEnvironment env, String path, boolean folder) throws MalformedURLException {
276
        String host = env.getUser() + '@' + env.getHost();
277
        URL url = new URL("file", host, env.getSSHPort(), path);
278
        String ext = url.toExternalForm() + (folder ? "/" : ""); // is there a way to set authority? // NOI18N
279
        return new URL(ext);
280
    }
281
    
282
    
283
    @Override
284
    public URI toURI() {
285
        try {
286
            return toURL().toURI();
287
        } catch (URISyntaxException ex) {
288
            throw new Error(ex); // should never happen
289
        } catch (MalformedURLException ex) {
290
            throw new Error(ex); // should never happen
291
        }
292
    }
293
294
    @Override
248
    public String getName() {
295
    public String getName() {
249
        return (fo == null) ? PathUtilities.getBaseName(path): fo.getNameExt();
296
        return (fo == null) ? PathUtilities.getBaseName(path): fo.getNameExt();
250
    }
297
    }

Return to bug 207116