From 651edc45f326fdb57011852b98dc262a2284382b Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Wed, 11 Apr 2007 19:27:10 +0000 Subject: [PATCH] [181917] EFS Improvements: Avoid unclosed Streams, - Fix early startup issues by deferring FileStore evaluation and classloading, - Improve performance by RSEFileStore instance factory and caching IRemoteFile. - Also remove unnecessary class RSEFileCache and obsolete branding files. --- .../about.ini | 27 - .../about.mappings | 6 - .../about.properties | 29 - .../build.properties | 10 +- .../eclipse32.png | Bin 4594 -> 0 bytes .../eclipse/filesystem/Activator.java | 25 +- .../eclipse/filesystem/RSEFileCache.java | 154 ---- .../eclipse/filesystem/RSEFileStore.java | 736 ++++++------------ .../eclipse/filesystem/RSEFileStoreImpl.java | 631 +++++++++++++++ .../eclipse/filesystem/RSEFileSystem.java | 127 ++- .../filesystem/RSEFileSystemContributor.java | 10 +- .../CreateRemoteProjectActionDelegate.java | 13 +- 12 files changed, 939 insertions(+), 829 deletions(-) delete mode 100644 rse/plugins/org.eclipse.rse.eclipse.filesystem/about.ini delete mode 100644 rse/plugins/org.eclipse.rse.eclipse.filesystem/about.mappings delete mode 100644 rse/plugins/org.eclipse.rse.eclipse.filesystem/about.properties delete mode 100644 rse/plugins/org.eclipse.rse.eclipse.filesystem/eclipse32.png delete mode 100644 rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileCache.java create mode 100644 rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileStoreImpl.java diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/about.ini b/rse/plugins/org.eclipse.rse.eclipse.filesystem/about.ini deleted file mode 100644 index fdd61ff0dd8..00000000000 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/about.ini +++ /dev/null @@ -1,27 +0,0 @@ -# about.ini -# contains information about a feature -# java.io.Properties file (ISO 8859-1 with "\" escapes) -# "%key" are externalized strings defined in about.properties -# This file does not need to be translated. - -# Property "aboutText" contains blurb for "About" dialog (translated) -aboutText=%blurb - -# Property "windowImage" contains path to window icon (16x16) -# needed for primary features only - -# Property "featureImage" contains path to feature image (32x32) -featureImage=eclipse32.png - -# Property "aboutImage" contains path to product image (500x330 or 115x164) -# needed for primary features only - -# Property "appName" contains name of the application (not translated) -# needed for primary features only - -# Property "welcomePage" contains path to welcome page (special XML-based format) -# optional - -# Property "welcomePerspective" contains the id of the perspective in which the -# welcome page is to be opened. -# optional \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/about.mappings b/rse/plugins/org.eclipse.rse.eclipse.filesystem/about.mappings deleted file mode 100644 index bddaab43109..00000000000 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/about.mappings +++ /dev/null @@ -1,6 +0,0 @@ -# about.mappings -# contains fill-ins for about.properties -# java.io.Properties file (ISO 8859-1 with "\" escapes) -# This file does not need to be translated. - -0=@build@ \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/about.properties b/rse/plugins/org.eclipse.rse.eclipse.filesystem/about.properties deleted file mode 100644 index c9a7fcae02f..00000000000 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/about.properties +++ /dev/null @@ -1,29 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2007 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# NLS_MESSAGEFORMAT_NONE -# NLS_ENCODING=UTF-8 - -# about.properties -# contains externalized strings for about.ini -# java.io.Properties file (ISO 8859-1 with "\" escapes) -# fill-ins are supplied by about.mappings -# This file should be translated. -# -# Do not translate any values surrounded by {} - -blurb=Remote System Explorer Experimental Eclipse Filesystem (EFS) Provider\n\ -\n\ -Version: {featureVersion}\n\ -Build id: {0}\n\ -\n\ -(c) Copyright IBM Corporation and others 2006, 2007. All rights reserved.\n\ -Visit http://www.eclipse.org/dsdp/tm \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/build.properties b/rse/plugins/org.eclipse.rse.eclipse.filesystem/build.properties index 4eeb1202be5..d66d9b4024e 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/build.properties +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/build.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2001, 2006 IBM Corporation and others. +# Copyright (c) 2001, 2007 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at @@ -7,14 +7,14 @@ # # Contributors: # IBM Corporation - initial API and implementation +# Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, +# - Fix early startup issues by deferring FileStore evaluation and classloading, +# - Improve performance by RSEFileStore instance factory and caching IRemoteFile. +# - Also remove unnecessary class RSEFileCache and obsolete branding files. ############################################################################### bin.includes = META-INF/,\ plugin.xml,\ about.html,\ - about.ini,\ - about.mappings,\ - about.properties,\ - eclipse32.png,\ plugin.properties,\ . source.. = src/ diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/eclipse32.png b/rse/plugins/org.eclipse.rse.eclipse.filesystem/eclipse32.png deleted file mode 100644 index 568fac1d05f4d05a2470f02033e92c77ce49a660..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4594 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 if the file exists in the cache, false otherwise. - * @param remoteFile the remote file. - * @return true if the file exists in the cache, false otherwise. - */ - public boolean isExistsInCache(IRemoteFile remoteFile) { - File file = getFromCache(remoteFile); - - if (file != null) { - return true; - } - else { - return false; - } - } - - /** - * Writes to the cache. If this is a directory, it simply creates the folder. - * @param remoteFile the remote file. - * @param inputStream the input stream with the contents of the remote file, or null if this is a directory. - * @return the file in the cache. - */ - public File writeToCache(IRemoteFile remoteFile, InputStream inputStream) { - - String path = getCachePath(remoteFile.getParentRemoteFileSubSystem().getHost().getHostName(), remoteFile.getAbsolutePath()); - File file = new File(path); - - if (remoteFile.isDirectory()) { - - if (!file.exists()) { - boolean success = file.mkdirs(); - - if (success) { - return file; - } - else { - return null; - } - } - else { - return file; - } - } - else { - File parent = file.getParentFile(); - - if (!parent.exists()) { - parent.mkdirs(); - } - } - - FileOutputStream outputStream = null; - BufferedOutputStream bufOutputStream = null; - - try { - outputStream = new FileOutputStream(file); - bufOutputStream = new BufferedOutputStream(outputStream); - - byte[] buffer = new byte[4096]; - - int readCount; - - while((readCount = inputStream.read(buffer)) > 0) { - bufOutputStream.write(buffer, 0, readCount); - } - - bufOutputStream.flush(); - inputStream.close(); - bufOutputStream.close(); - } - catch (Exception e) { - return null; - } - - return file; - } - - /** - * Gets the cached file for the remote file from the cache if any. - * @param remoteFile the remote file. - * @return the cached file, or null if none. - */ - public File getFromCache(IRemoteFile remoteFile) { - String path = getCachePath(remoteFile.getParentRemoteFileSubSystem().getHost().getHostName(), remoteFile.getAbsolutePath()); - File file = new File(path); - - if (file.exists()) { - return file; - } - else { - return null; - } - } - - /** - * Gets the cache path. - * @param hostname the hostname. - * @param remotePath the remote path. - * @return the cache path. - */ - private String getCachePath(String hostname, String remotePath) { - IPath path = Platform.getStateLocation(Activator.getDefault().getBundle()); - path = path.makeAbsolute(); - path = path.addTrailingSeparator(); - path = path.append(hostname); - path = path.addTrailingSeparator(); - path = path.append(remotePath); - return path.toOSString(); - } -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileStore.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileStore.java index 3842b5feddb..9a8b03d3580 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileStore.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileStore.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation. All rights reserved. + * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -12,17 +12,18 @@ * * Contributors: * Kushal Munir (IBM) - moved to internal package + * Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, + * - Fix early startup issues by deferring FileStore evaluation and classloading, + * - Improve performance by RSEFileStore instance factory and caching IRemoteFile. + * - Also remove unnecessary class RSEFileCache and obsolete branding files. ********************************************************************************/ package org.eclipse.rse.internal.eclipse.filesystem; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URI; -import java.net.URISyntaxException; +import java.util.HashMap; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileInfo; @@ -30,545 +31,274 @@ import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileInfo; import org.eclipse.core.filesystem.provider.FileStore; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; -import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.services.files.IHostFile; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString; -import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; -import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration; -import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileContext; -import org.eclipse.swt.widgets.Display; - +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +/** + * Implementation of IFileStore for RSE. + * + * An RSEFileStore is an immutable object. Once created, it always + * references the same remote item. Therefore, instances can be + * shared. + * + * @since RSE 2.0 + */ public class RSEFileStore extends FileStore implements IFileStore { - private IFileStore _parent; - private IRemoteFileSubSystem _subSystem; - private String _absolutePath; + private RSEFileStore _parent; + private String _host; private String _name; - private IRemoteFile _remoteFile; + private IPath _absolutePath; + + //cached IRemoteFile object: an Object to avoid early class loading + private transient RSEFileStoreImpl _impl = null; + private static HashMap instanceMap = new HashMap(); + + /** + * Constructor to use if the parent file store is known. + * @param parent the parent file store. + * @param name the name of the file store. + */ + private RSEFileStore(RSEFileStore parent, String name) { + _parent = parent; + _host = parent.getHost(); + _name = name; + _absolutePath = parent._absolutePath.append(name); + } /** * Constructor to use if the file store is a handle. - * @param parent the parent. - * @param name the name of the file store. + * @param host the connection name for the file store. + * @param absolutePath an absolute path to the file, valid on the remote file system. */ - public RSEFileStore(RSEFileStore parent, IRemoteFileSubSystem subSystem, String parentAbsolutePath, String name) { - _parent = parent; - _subSystem = subSystem; - - if (!parentAbsolutePath.endsWith(_subSystem.getSeparator())) { - _absolutePath = parentAbsolutePath + _subSystem.getSeparator() + name; - } - else { - _absolutePath = parentAbsolutePath + name; - } - - _name = name; - } - - // an input stream that wraps another input stream and closes the wrappered input stream in a runnable that is always run with the user interface thread - private class RSEFileStoreInputStream extends BufferedInputStream { - - /** - * Creates a BufferedInputStream and saves its argument, the input stream, for later use. An internal buffer array is created. - * @param in the underlying input stream. - */ - public RSEFileStoreInputStream(InputStream in) { - super(in); - } - - /** - * Creates a BufferedInputStream and saves its argument, the input stream, for later use. An internal buffer array of the given size is created. - * @param in the underlying input stream. - * @param size the buffer size. - */ - public RSEFileStoreInputStream(InputStream in, int size) { - super(in, size); - } - - /** - * @see java.io.BufferedInputStream#close() - */ - public void close() throws IOException { - - Display current = Display.getCurrent(); - - if (current != null) { - super.close(); - } - } - } - - private class RSEFileStoreOutputStream extends BufferedOutputStream { - - /** - * Creates a new buffered output stream to write data to the specified underlying output stream with a default 512-byte buffer size. - * @param out the underlying output stream. - */ - public RSEFileStoreOutputStream(OutputStream out) { - super(out); - } - - /** - * Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size. - * @param out the underlying output stream. - * @param size the buffer size. - */ - public RSEFileStoreOutputStream(OutputStream out, int size) { - super(out, size); - } - - /** - * @see java.io.BufferedOutputStream#close() - */ - public void close() throws IOException { - - Display current = Display.getCurrent(); - - if (current != null) { - super.close(); - } - } - } - - public String[] childNames(int options, IProgressMonitor monitor) throws CoreException { - - String[] names; - - if (!_subSystem.isConnected()) { - - try { - _subSystem.connect(monitor); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not connect to subsystem", e)); //$NON-NLS-1$ - } - } - - // at this point get the live remote file because we want to fetch the info about this file - try { - _remoteFile = _subSystem.getRemoteFileObject(_absolutePath); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not get remote file", e)); //$NON-NLS-1$ - } - - if (_remoteFile == null || !_remoteFile.exists()) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "The file store does not exist")); //$NON-NLS-1$ - } - - if (!_remoteFile.isStale() && _remoteFile.hasContents(RemoteChildrenContentsType.getInstance()) && !(_subSystem instanceof IFileServiceSubSystem)) - { - Object[] children = _remoteFile.getContents(RemoteChildrenContentsType.getInstance()); - names = new String[children.length]; - - for (int i = 0; i < children.length; i++) - { - names[i] = ((IRemoteFile)children[i]).getName(); - } - } - else - { - try { - - IRemoteFile[] children = null; - - if (_subSystem instanceof FileServiceSubSystem) { - FileServiceSubSystem fileServiceSubSystem = ((FileServiceSubSystem)_subSystem); - IHostFile[] results = fileServiceSubSystem.getFileService().getFilesAndFolders(monitor, _remoteFile.getAbsolutePath(), "*"); //$NON-NLS-1$ - IRemoteFileSubSystemConfiguration config = _subSystem.getParentRemoteFileSubSystemConfiguration(); - RemoteFileFilterString filterString = new RemoteFileFilterString(config, _remoteFile.getAbsolutePath(), "*"); //$NON-NLS-1$ - filterString.setShowFiles(true); - filterString.setShowSubDirs(true); - RemoteFileContext context = new RemoteFileContext(_subSystem, _remoteFile, filterString); - children = fileServiceSubSystem.getHostFileToRemoteFileAdapter().convertToRemoteFiles(fileServiceSubSystem, context, _remoteFile, results); - } - else { - children = _subSystem.listFoldersAndFiles(_remoteFile, "*", monitor); //$NON-NLS-1$ - } - - names = new String[children.length]; - - for (int i = 0; i < children.length; i++) { - names[i] = (children[i]).getName(); - } - } - catch (SystemMessageException e) { - names = new String[0]; - } - } - - return names; + private RSEFileStore(String host, String absolutePath) { + _parent = null; + _host = host; + _absolutePath = new Path(absolutePath); + _name = _absolutePath.lastSegment(); } /** - * @see org.eclipse.core.filesystem.provider.FileStore#childInfos(int, org.eclipse.core.runtime.IProgressMonitor) + * Public factory method for obtaining RSEFileStore instances. + * @param uri URI to get a fileStore for + * @return an RSEFileStore instance for the URI. */ - public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException { - - FileInfo[] infos; - - if (!_subSystem.isConnected()) { - - try { - _subSystem.connect(monitor); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not connect to subsystem", e)); //$NON-NLS-1$ + public static RSEFileStore getInstance(URI uri) { + synchronized(instanceMap) { + RSEFileStore store = (RSEFileStore)instanceMap.get(uri); + if (store==null) { + String path = uri.getPath(); + String hostName = uri.getHost(); + store = new RSEFileStore(hostName, path); + instanceMap.put(uri, store); } + return store; } - - // at this point get the live remote file because we want to fetch the info about this file - try { - _remoteFile = _subSystem.getRemoteFileObject(_absolutePath); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not get remote file", e)); //$NON-NLS-1$ - } - - if (_remoteFile == null || !_remoteFile.exists()) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "The file store does not exist")); //$NON-NLS-1$ - } - - if (!_remoteFile.isStale() && _remoteFile.hasContents(RemoteChildrenContentsType.getInstance()) && !(_subSystem instanceof IFileServiceSubSystem)) - { - Object[] children = _remoteFile.getContents(RemoteChildrenContentsType.getInstance()); - - infos = new FileInfo[children.length]; - - for (int i = 0; i < children.length; i++) - { - IRemoteFile file = (IRemoteFile)(children[i]); - FileInfo info = new FileInfo(file.getName()); - - if (!file.exists()) { - info.setExists(false); - } - else { - info.setExists(true); - info.setLastModified(file.getLastModified()); - boolean isDir = file.isDirectory(); - info.setDirectory(isDir); - info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, !file.canWrite()); - info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, file.isExecutable()); - info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, file.isArchive()); - info.setAttribute(EFS.ATTRIBUTE_HIDDEN, file.isHidden()); - - if (!isDir) { - info.setLength(file.getLength()); - } - } - - infos[i] = info; - } - } - else - { - try { - - IRemoteFile[] children = null; - - if (_subSystem instanceof FileServiceSubSystem) { - FileServiceSubSystem fileServiceSubSystem = ((FileServiceSubSystem)_subSystem); - IHostFile[] results = fileServiceSubSystem.getFileService().getFilesAndFolders(monitor, _remoteFile.getAbsolutePath(), "*"); //$NON-NLS-1$ - IRemoteFileSubSystemConfiguration config = _subSystem.getParentRemoteFileSubSystemConfiguration(); - RemoteFileFilterString filterString = new RemoteFileFilterString(config, _remoteFile.getAbsolutePath(), "*"); //$NON-NLS-1$ - filterString.setShowFiles(true); - filterString.setShowSubDirs(true); - RemoteFileContext context = new RemoteFileContext(_subSystem, _remoteFile, filterString); - children = fileServiceSubSystem.getHostFileToRemoteFileAdapter().convertToRemoteFiles(fileServiceSubSystem, context, _remoteFile, results); - } - else { - children = _subSystem.listFoldersAndFiles(_remoteFile, "*", monitor); //$NON-NLS-1$ - } - - infos = new FileInfo[children.length]; - - for (int i = 0; i < children.length; i++) - { - IRemoteFile file = children[i]; - FileInfo info = new FileInfo(file.getName()); - - if (!file.exists()) { - info.setExists(false); - } - else { - info.setExists(true); - info.setLastModified(file.getLastModified()); - boolean isDir = file.isDirectory(); - info.setDirectory(isDir); - info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, !file.canWrite()); - info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, file.isExecutable()); - info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, file.isArchive()); - info.setAttribute(EFS.ATTRIBUTE_HIDDEN, file.isHidden()); - //TODO Add symbolic link attribute - - if (!isDir) { - info.setLength(file.getLength()); - } - } - - infos[i] = info; - } - } - catch (SystemMessageException e) { - //TODO check whether we should not throw an exception ourselves - infos = new FileInfo[0]; - } - } - - return infos; } - public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException { - - // connect if needed - if (!_subSystem.isConnected()) { - - try { - _subSystem.connect(monitor); - } - catch (Exception e) { - // throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not connect to subsystem", e)); //$NON-NLS-1$ - FileInfo info = new FileInfo(getName()); - info.setExists(false); - return info; + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileStore#getChild(java.lang.String) + */ + public IFileStore getChild(String name) { + RSEFileStore tmpChild = new RSEFileStore(this, name); + URI uri = tmpChild.toURI(); + synchronized(instanceMap) { + RSEFileStore storedChild = (RSEFileStore)instanceMap.get(uri); + if (storedChild==null) { + instanceMap.put(uri, tmpChild); + } else { + tmpChild = storedChild; } } - - // at this point get the live remote file because we want to fetch the info about this file - try { - _remoteFile = _subSystem.getRemoteFileObject(_absolutePath); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not get remote file", e)); //$NON-NLS-1$ - } - - FileInfo info = new FileInfo(getName()); - - if (_remoteFile == null || !_remoteFile.exists()) { - info.setExists(false); - return info; - } - - info.setExists(true); - info.setLastModified(_remoteFile.getLastModified()); - boolean isDir = _remoteFile.isDirectory(); - info.setDirectory(isDir); - info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, !_remoteFile.canWrite()); - info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, _remoteFile.isExecutable()); - info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, _remoteFile.isArchive()); - info.setAttribute(EFS.ATTRIBUTE_HIDDEN, _remoteFile.isHidden()); + return tmpChild; + } - if (!isDir) { - info.setLength(_remoteFile.getLength()); - } - - return info; + /** + * Returns the host name or address for this file store. + * @return the host name or address for this file store. + */ + /*package*/ String getHost() { + //TODO consider computing this instead of storing it + return _host; } + /** + * Returns an absolute path for this file store. + * + * The absolute path is in normalized form, as it can use in URIs + * (with separator '/'). + * + * @return an absolute path for this file store in normalized form. + */ + /*package*/ String getAbsolutePath() { + //TODO consider computing this instead of storing it + return _absolutePath.toString(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileStore#getName() + */ public String getName() { return _name; } + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileStore#getParent() + */ public IFileStore getParent() { return _parent; } - - public synchronized InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException - { - if (!_subSystem.isConnected()) { - - try { - _subSystem.connect(monitor); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not connect to subsystem", e)); //$NON-NLS-1$ - } - } - - // at this point get the live remote file - try { - _remoteFile = _subSystem.getRemoteFileObject(_absolutePath); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not get remote file", e)); //$NON-NLS-1$ - } - - if (_remoteFile == null || !_remoteFile.exists()) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "The file store does not exist")); //$NON-NLS-1$ - } - - if (_remoteFile.isDirectory()) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "The file store represents a directory")); //$NON-NLS-1$ - } - - if (_remoteFile.isFile()) { - - try { - return new RSEFileStoreInputStream(_subSystem.getInputStream(_remoteFile.getParentPath(), _remoteFile.getName(), true, monitor)); - } - catch (SystemMessageException e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not get input stream", e)); //$NON-NLS-1$ - } - } - - return null; - } - - public URI toURI() { - - try { - String path = _absolutePath; - - if (path.charAt(0) != '/') { - path = "/" + path.replace('\\', '/'); //$NON-NLS-1$ - } - - return new URI("rse", _subSystem.getHost().getHostName(), path, null); //$NON-NLS-1$ - } - catch (URISyntaxException e) { - throw new RuntimeException(e); - } + + /** + * Returns the parent file store as an RSEFileStore. + * @return the parent file store as an RSEFileStore. + */ + /*package*/ RSEFileStore getParentStore() { + return _parent; } - public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException - { - if (!_subSystem.isConnected()) { - - try { - _subSystem.connect(monitor); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not connect to subsystem", e)); //$NON-NLS-1$ - } - } - - // at this point get the live remote file - try { - _remoteFile = _subSystem.getRemoteFileObject(_absolutePath); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not get remote file", e)); //$NON-NLS-1$ - } - - if (!_remoteFile.exists()) { - try { - _remoteFile = _subSystem.createFolder(_remoteFile); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "The directory could not be created", e)); //$NON-NLS-1$ - } - - return this; - } - else { - - if (_remoteFile.isFile()) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "A file of that name already exists")); //$NON-NLS-1$ - } - else { - return this; + /** + * Get FileStore implementation. + *

+ * Moved implementation to separate class in order to defer class loading + * until resources plugin is up. + *

+ * @return the RSEFileStoreImpl implementation. + */ + /*package*/ RSEFileStoreImpl getImpl() throws CoreException { + //FIXME Workaround for Platform bug 181998 - activation problems on early startup: + //Resources plugin opens the workspace in its start() method, triggers the + //save manager and this in turn would activate org.eclipse.rse.ui which depends + //on resources... this activation circle does not work, therefore throw an + //exception if resources are not yet up. + if (_impl==null) { + if (!isResourcesPluginUp()) { + throw new CoreException(new Status(IStatus.WARNING, + Activator.getDefault().getBundle().getSymbolicName(), + "Cannot access file: Resources not loaded yet")); } + _impl = new RSEFileStoreImpl(this); } + return _impl; } - public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException { - - if (!_subSystem.isConnected()) { - - try { - _subSystem.connect(monitor); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not connect to subsystem", e)); //$NON-NLS-1$ - } - } - - // at this point get the live remote file - try { - _remoteFile = _subSystem.getRemoteFileObject(_absolutePath); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not get remote file", e)); //$NON-NLS-1$ - } - - if (!_remoteFile.exists()) { - - try { - _remoteFile = _subSystem.createFile(_remoteFile); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not create file", e)); //$NON-NLS-1$ - } - } - - if (_remoteFile.isFile()) { - - try { - return new RSEFileStoreOutputStream(_subSystem.getOutputStream(_remoteFile.getParentPath(), _remoteFile.getName(), true, monitor)); - } - catch (SystemMessageException e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not get output stream", e)); //$NON-NLS-1$ - } - } - else { - - if (_remoteFile.isDirectory()) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "This is a directory")); //$NON-NLS-1$ - } - else { - return null; - } - } - } - - public IFileStore getChild(String name) { - return new RSEFileStore(this, _subSystem, _absolutePath, name); - } - - public void delete(int options, IProgressMonitor monitor) throws CoreException + private static Bundle resourcesBundle = null; + private static boolean isResourcesPluginUp() { - if (!_subSystem.isConnected()) { - - try { - _subSystem.connect(monitor); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not connect to subsystem", e)); //$NON-NLS-1$ - } - } - - // at this point get the live remote file - try { - _remoteFile = _subSystem.getRemoteFileObject(_absolutePath); - } - catch (Exception e) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not get remote file", e)); //$NON-NLS-1$ - } - - if (!_remoteFile.exists()) { - return; - } - else { - - try { - boolean success = _subSystem.delete(_remoteFile, monitor); - - if (!success) { - throw new CoreException(new Status(IStatus.ERROR, Activator.getDefault().getBundle().getSymbolicName(), "Could not delete file")); //$NON-NLS-1$ + if (resourcesBundle==null) { + BundleContext ctx = Activator.getDefault().getBundle().getBundleContext(); + Bundle[] bundles = ctx.getBundles(); + for (int i=0; i + * FIXME This is a HACK to fix early startup problems until + * Platform bug 182006 is resolved! Returns an info + * object indicating a non-existing file while the Eclipse resources + * plugin is not fully activated. This is in order to avoid problems + * of activating too much of RSE while Eclipse is not yet ready. + *

+ * @return a file info object for this file store. + */ + public IFileInfo fetchInfo() { + try { + return fetchInfo(EFS.NONE, null); + } catch (CoreException e) { + if (!isResourcesPluginUp()) { + //FIXME HACK workaround for platform bug 182006: + //Claim that files do not exist while resources + //plugin is not yet fully up. + return new FileInfo(getName()); } + //Whoa! Bad bad... wrapping a checked exception in an unchecked one... + throw new RuntimeException(e); } } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileStore#fetchInfo(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException { + return getImpl().fetchInfo(options, monitor); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileStore#openInputStream(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException + { + return getImpl().openInputStream(options, monitor); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileStore#toURI() + */ + public URI toURI() { + return RSEFileSystem.getURIFor(getHost(), getAbsolutePath()); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileStore#mkdir(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException + { + return getImpl().mkdir(options, monitor); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileStore#openOutputStream(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException + { + return getImpl().openOutputStream(options, monitor); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileStore#delete(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public void delete(int options, IProgressMonitor monitor) throws CoreException + { + getImpl().delete(options, monitor); + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileStoreImpl.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileStoreImpl.java new file mode 100644 index 00000000000..8ccc78db887 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileStoreImpl.java @@ -0,0 +1,631 @@ +/******************************************************************************** + * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight, Kushal Munir, + * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, + * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. + * + * Contributors: + * Kushal Munir (IBM) - moved to internal package + * Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, + * - Fix early startup issues by deferring FileStore evaluation and classloading, + * - Improve performance by RSEFileStore instance factory and caching IRemoteFile. + * - Also remove unnecessary class RSEFileCache and obsolete branding files. + ********************************************************************************/ + +package org.eclipse.rse.internal.eclipse.filesystem; + +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; + +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.provider.FileInfo; +import org.eclipse.core.filesystem.provider.FileStore; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType; +import org.eclipse.rse.services.clientserver.messages.SystemMessageException; +import org.eclipse.rse.services.files.IHostFile; +import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString; +import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; +import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; +import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration; +import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileContext; +import org.eclipse.rse.ui.RSEUIPlugin; + +/** + * Implementation of IFileStore for RSE. + * + * The RSEFileStore delegates to this impl class in order to defer class + * loading until file contents are really needed. + */ +public class RSEFileStoreImpl extends FileStore +{ + private RSEFileStore _parent; + + //cached IRemoteFile object: an Object to avoid early class loading + private transient IRemoteFile _remoteFile; + + /** + * Constructor to use if the parent file store is known. + * @param parent the parent file store. + */ + public RSEFileStoreImpl(RSEFileStore parent) { + _parent = parent; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#getChild(java.lang.String) + */ + public IFileStore getChild(String name) { + return _parent.getChild(name); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#getName() + */ + public String getName() { + return _parent.getName(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#getParent() + */ + public IFileStore getParent() { + return _parent.getParent(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#toURI() + */ + public URI toURI() { + return _parent.toURI(); + } + + /** + * Return the best RSE connection object matching the given host name. + * + * @param hostNameOrAddr IP address of requested host. + * @return RSE connection object matching the given host name, or + * null if no matching connection object was found. + */ + public static IHost getConnectionFor(String hostNameOrAddr, IProgressMonitor monitor) { + if (hostNameOrAddr==null) { + return null; + } + ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry(); + IHost[] connections = sr.getHosts(); + + //FIXME HACK workaround until we get an API method to know when persistent data is fully restored + //Without this hack, the first time a directory is expanded RSEUIPlugin is activated and it + //is too slow reading persistent data. We wait up to 5 seconds for RSE to initialize. + if (connections.length==0) { + long startTime = System.currentTimeMillis(); + long endTime = startTime+5000; + //int iterations=0; + do { + try { + Thread.sleep(500); + //iterations++; + } catch(InterruptedException e) { + break; + } + if (monitor!=null) { + monitor.worked(1); + if (monitor.isCanceled()) { + break; + } + } + connections = sr.getHosts(); + } while((connections.length==0 || getConnectionFor(hostNameOrAddr, monitor)==null) + && System.currentTimeMillis() + *
  • A connected FileServiceSubsystem
  • + *
  • A connected IRemoteFileSubSystem
  • + *
  • An unconnected FileServiceSubsystem
  • + *
  • An unconnected IRemoteFileSubSystem
  • + * + * @param host + * @return an IRemoteFileSubSystem for the given connection, or + * null if no IRemoteFileSubSystem is configured. + */ + public static IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) { + IRemoteFileSubSystem candidate = null; + FileServiceSubSystem serviceCandidate = null; + IRemoteFileSubSystem[] subSys = RemoteFileUtility.getFileSubSystems(host); + for (int i=0; inull. + * @param hostNameOrAddr host name or IP address + * @param monitor progress monitor + * @return The best connected file subsystem for this file store. + * @throws CoreException if no file subsystem could be found or connected. + */ + public static IRemoteFileSubSystem getConnectedFileSubSystem(String hostNameOrAddr, IProgressMonitor monitor) throws CoreException + { + IHost con = RSEFileStoreImpl.getConnectionFor(hostNameOrAddr, monitor); + if (con == null) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Connection not found for host: "+hostNameOrAddr)); + } + IRemoteFileSubSystem subSys = RSEFileStoreImpl.getRemoteFileSubSystem(con); + if (subSys == null) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "No file subsystem found on host: "+hostNameOrAddr+" connection "+con.getAliasName())); + } + if (!subSys.isConnected()) { + try { + if (monitor==null) monitor=new NullProgressMonitor(); + subSys.connect(monitor, false); + } + catch (Exception e) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not connect to host: "+hostNameOrAddr+" subsystem "+subSys.getConfigurationId(), e)); + } + } + return subSys; + } + + private IRemoteFile getCachedRemoteFile() { + return _remoteFile; + } + + private void cacheRemoteFile(IRemoteFile remoteFile) { + //if (_remoteFile != remoteFile) _remoteFile = remoteFile; + _remoteFile = remoteFile; + } + + /** + * Returns an IRemoteFile for this file store. + * Requires that the file subsystem is connected. + * @param monitor progress monitor + * @param forceExists if true, throw an exception if the remote file does not exist + * @return an IRemoteFile for this file store + * @throws CoreException if connecting is not possible. + */ + private synchronized IRemoteFile getRemoteFileObject(IProgressMonitor monitor, boolean forceExists) throws CoreException { + IRemoteFile remoteFile = getCachedRemoteFile(); + if (remoteFile!=null) { + if (remoteFile.getParentRemoteFileSubSystem().isConnected()) { + return remoteFile; + } else { + //need to re-initialize cache + remoteFile=null; + cacheRemoteFile(null); + } + } + + RSEFileStore parentStore = _parent.getParentStore(); + if (parentStore!=null) { + //Handle was created naming a parent file store + IRemoteFile parent = parentStore.getImpl().getRemoteFileObject(monitor, forceExists); + if (parent==null) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not get remote file")); + } + try { + remoteFile = parent.getParentRemoteFileSubSystem().getRemoteFileObject(parent, _parent.getName()); + } catch(Exception e) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not get remote file", e)); + } + } else { + //Handle was created with an absolute name + IRemoteFileSubSystem subSys = RSEFileStoreImpl.getConnectedFileSubSystem(_parent.getHost(), monitor); + try { + //TODO method missing a progressmonitor! + remoteFile = subSys.getRemoteFileObject(_parent.getAbsolutePath()); + } + catch (Exception e) { + throw new CoreException(new Status( + IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not get remote file", e)); + } + } + + cacheRemoteFile(remoteFile); + if (forceExists && (remoteFile == null || !remoteFile.exists())) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "The file store does not exist")); + } + return remoteFile; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#childNames(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public String[] childNames(int options, IProgressMonitor monitor) throws CoreException { + + String[] names; + IRemoteFile remoteFile = getRemoteFileObject(monitor, true); + IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); + if (!remoteFile.isStale() && remoteFile.hasContents(RemoteChildrenContentsType.getInstance()) && !(subSys instanceof IFileServiceSubSystem)) + { + Object[] children = remoteFile.getContents(RemoteChildrenContentsType.getInstance()); + names = new String[children.length]; + + for (int i = 0; i < children.length; i++) + { + names[i] = ((IRemoteFile)children[i]).getName(); + } + } + else + { + try { + IRemoteFile[] children = null; + + if (subSys instanceof FileServiceSubSystem) { + FileServiceSubSystem fileServiceSubSystem = ((FileServiceSubSystem)subSys); + IHostFile[] results = fileServiceSubSystem.getFileService().getFilesAndFolders(monitor, remoteFile.getAbsolutePath(), "*"); //$NON-NLS-1$ + IRemoteFileSubSystemConfiguration config = subSys.getParentRemoteFileSubSystemConfiguration(); + RemoteFileFilterString filterString = new RemoteFileFilterString(config, remoteFile.getAbsolutePath(), "*"); //$NON-NLS-1$ + filterString.setShowFiles(true); + filterString.setShowSubDirs(true); + RemoteFileContext context = new RemoteFileContext(subSys, remoteFile, filterString); + children = fileServiceSubSystem.getHostFileToRemoteFileAdapter().convertToRemoteFiles(fileServiceSubSystem, context, remoteFile, results); + } + else { + children = subSys.listFoldersAndFiles(remoteFile, "*", monitor); //$NON-NLS-1$ + } + + names = new String[children.length]; + + for (int i = 0; i < children.length; i++) { + names[i] = (children[i]).getName(); + } + } + catch (SystemMessageException e) { + names = new String[0]; + } + } + + return names; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#childInfos(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException { + + FileInfo[] infos; + IRemoteFile remoteFile = getRemoteFileObject(monitor, true); + IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); + if (!remoteFile.isStale() && remoteFile.hasContents(RemoteChildrenContentsType.getInstance()) && !(subSys instanceof IFileServiceSubSystem)) + { + Object[] children = remoteFile.getContents(RemoteChildrenContentsType.getInstance()); + + infos = new FileInfo[children.length]; + + for (int i = 0; i < children.length; i++) + { + IRemoteFile file = (IRemoteFile)(children[i]); + FileInfo info = new FileInfo(file.getName()); + + if (!file.exists()) { + info.setExists(false); + } + else { + info.setExists(true); + info.setLastModified(file.getLastModified()); + boolean isDir = file.isDirectory(); + info.setDirectory(isDir); + info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, !file.canWrite()); + info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, file.isExecutable()); + info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, file.isArchive()); + info.setAttribute(EFS.ATTRIBUTE_HIDDEN, file.isHidden()); + + if (!isDir) { + info.setLength(file.getLength()); + } + } + + infos[i] = info; + } + } + else + { + try { + + IRemoteFile[] children = null; + + if (subSys instanceof FileServiceSubSystem) { + FileServiceSubSystem fileServiceSubSystem = ((FileServiceSubSystem)subSys); + IHostFile[] results = fileServiceSubSystem.getFileService().getFilesAndFolders(monitor, remoteFile.getAbsolutePath(), "*"); //$NON-NLS-1$ + IRemoteFileSubSystemConfiguration config = subSys.getParentRemoteFileSubSystemConfiguration(); + RemoteFileFilterString filterString = new RemoteFileFilterString(config, remoteFile.getAbsolutePath(), "*"); //$NON-NLS-1$ + filterString.setShowFiles(true); + filterString.setShowSubDirs(true); + RemoteFileContext context = new RemoteFileContext(subSys, remoteFile, filterString); + children = fileServiceSubSystem.getHostFileToRemoteFileAdapter().convertToRemoteFiles(fileServiceSubSystem, context, remoteFile, results); + } + else { + children = subSys.listFoldersAndFiles(remoteFile, "*", monitor); //$NON-NLS-1$ + } + + infos = new FileInfo[children.length]; + + for (int i = 0; i < children.length; i++) + { + IRemoteFile file = children[i]; + FileInfo info = new FileInfo(file.getName()); + + if (!file.exists()) { + info.setExists(false); + } + else { + info.setExists(true); + info.setLastModified(file.getLastModified()); + boolean isDir = file.isDirectory(); + info.setDirectory(isDir); + info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, !file.canWrite()); + info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, file.isExecutable()); + info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, file.isArchive()); + info.setAttribute(EFS.ATTRIBUTE_HIDDEN, file.isHidden()); + //TODO Add symbolic link attribute + + if (!isDir) { + info.setLength(file.getLength()); + } + } + + infos[i] = info; + } + } + catch (SystemMessageException e) { + //TODO check whether we should not throw an exception ourselves + infos = new FileInfo[0]; + } + } + + return infos; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#fetchInfo(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException { + + // connect if needed. Will throw exception if not successful. + IRemoteFile remoteFile = getRemoteFileObject(monitor, false); + + FileInfo info = new FileInfo(_parent.getName()); + if (remoteFile == null || !remoteFile.exists()) { + info.setExists(false); + return info; + } + + info.setExists(true); + info.setLastModified(remoteFile.getLastModified()); + boolean isDir = remoteFile.isDirectory(); + info.setDirectory(isDir); + info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, !remoteFile.canWrite()); + info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, remoteFile.isExecutable()); + info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, remoteFile.isArchive()); + info.setAttribute(EFS.ATTRIBUTE_HIDDEN, remoteFile.isHidden()); + + if (!isDir) { + info.setLength(remoteFile.getLength()); + } + + return info; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#openInputStream(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException + { + IRemoteFile remoteFile = getRemoteFileObject(monitor, true); + IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); + + if (remoteFile.isDirectory()) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "The file store represents a directory")); + } + + if (remoteFile.isFile()) { + + try { + return subSys.getInputStream(remoteFile.getParentPath(), remoteFile.getName(), true, monitor); + } + catch (SystemMessageException e) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not get input stream", e)); + } + } + + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#mkdir(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException + { + IRemoteFile remoteFile = getRemoteFileObject(monitor, false); + if (remoteFile==null) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not get remote file")); + } + IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); + if (!remoteFile.exists()) { + try { + remoteFile = subSys.createFolder(remoteFile); + } + catch (Exception e) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "The directory could not be created", e)); + } + return _parent; + } + else if (remoteFile.isFile()) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "A file of that name already exists")); + } + else { + return _parent; + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#openOutputStream(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException { + + IRemoteFile remoteFile = getRemoteFileObject(monitor, false); + if (remoteFile==null) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not get remote file")); + } + IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); + if (!remoteFile.exists()) { + try { + remoteFile = subSys.createFile(remoteFile); + } + catch (Exception e) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not create file", e)); + } + } + + if (remoteFile.isFile()) { + + try { + return subSys.getOutputStream(remoteFile.getParentPath(), remoteFile.getName(), true, monitor); + } + catch (SystemMessageException e) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not get output stream", e)); + } + } + else if (remoteFile.isDirectory()) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "This is a directory")); + } + else { + //TODO check what to do for symbolic links and other strange stuff + return null; + } + } + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.IFileStore#delete(int, org.eclipse.core.runtime.IProgressMonitor) + */ + public void delete(int options, IProgressMonitor monitor) throws CoreException + { + IRemoteFile remoteFile = getRemoteFileObject(monitor, false); + if (remoteFile==null || !remoteFile.exists()) { + return; + } + else { + IRemoteFileSubSystem subSys = remoteFile.getParentRemoteFileSubSystem(); + try { + boolean success = subSys.delete(remoteFile, monitor); + if (!success) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not delete file")); + } + } + catch (Exception e) { + throw new CoreException(new Status(IStatus.ERROR, + Activator.getDefault().getBundle().getSymbolicName(), + "Could not delete file", e)); + } + } + } +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileSystem.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileSystem.java index a34f86b4a9e..766700d39e6 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileSystem.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileSystem.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation. All rights reserved. + * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -13,6 +13,10 @@ * Contributors: * David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies * Kushal Munir (IBM) - moved to internal package + * Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, + * - Fix early startup issues by deferring FileStore evaluation and classloading, + * - Improve performance by RSEFileStore instance factory and caching IRemoteFile. + * - Also remove unnecessary class RSEFileCache and obsolete branding files. ********************************************************************************/ package org.eclipse.rse.internal.eclipse.filesystem; @@ -23,114 +27,73 @@ import java.net.URISyntaxException; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.provider.FileSystem; -import org.eclipse.core.runtime.Path; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.model.ISystemRegistry; -import org.eclipse.rse.core.subsystems.IConnectorService; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; -import org.eclipse.rse.ui.RSEUIPlugin; public class RSEFileSystem extends FileSystem { private static RSEFileSystem _instance = new RSEFileSystem(); - + + /** + * Default constructor. + */ public RSEFileSystem() { super(); } + /** + * Return the singleton instance of this file system. + * @return the singleton instance of this file system. + */ public static RSEFileSystem getInstance() { return _instance; } + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileSystem#canDelete() + */ public boolean canDelete() { return true; } - + + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileSystem#canWrite() + */ public boolean canWrite() { return true; } - public static IHost getConnectionFor(String hostName) { - - ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry(); - IHost[] connections = sr.getHosts(); - IHost unconnected = null; - - for (int i = 0; i < connections.length; i++) { - - IHost con = connections[i]; - - if (con.getHostName().equalsIgnoreCase(hostName)) { - - boolean isConnected = false; - IConnectorService[] connectorServices = con.getConnectorServices(); - - for (int c = 0; c < connectorServices.length && !isConnected; c++) - { - IConnectorService serv = connectorServices[c]; - isConnected = serv.isConnected(); - } - - if (isConnected) { - return con; - } - else { - unconnected = con; - } - } + /* + * (non-Javadoc) + * @see org.eclipse.core.filesystem.provider.FileSystem#getStore(java.net.URI) + */ + public IFileStore getStore(URI uri) { + try { + return RSEFileStore.getInstance(uri); + } + catch (Exception e) { + //Could be an URI format exception + return EFS.getNullFileSystem().getStore(uri); } - - return unconnected; } - - public static IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) { - return RemoteFileUtility.getFileSubSystem(host); - } - - public URI getURIFor(IRemoteFile file) { - String path = file.getAbsolutePath(); - - if (path.charAt(0) != '/') { - path = "/" + path.replace('\\', '/'); //$NON-NLS-1$ + + /** + * Return an URI uniquely naming an RSE remote resource. + * @param hostNameOrAddr host name or IP address of remote system + * @param absolutePath absolute path to resource as valid on the remote system + * @return an URI uniquely naming the remote resource. + */ + public static URI getURIFor(String hostNameOrAddr, String absolutePath) { + //FIXME backslashes are valid in UNIX file names. This is not correctly handled yet. + if (absolutePath.charAt(0) != '/') { + absolutePath = "/" + absolutePath.replace('\\', '/'); //$NON-NLS-1$ } - try { - return new URI("rse", file.getParentRemoteFileSubSystem().getHost().getHostName(), path, null); //$NON-NLS-1$ + return new URI("rse", hostNameOrAddr, absolutePath, null); //$NON-NLS-1$ } catch (URISyntaxException e) { throw new RuntimeException(e); } } - - public IFileStore getStore(URI uri) { - - try { - - String path = uri.getPath(); - String hostName = uri.getHost(); - IHost con = getConnectionFor(hostName); - - if (con != null) { - - IRemoteFileSubSystem fs = getRemoteFileSubSystem(con); - - if (fs != null) { - Path absPath = new Path(path); - return new RSEFileStore(null, fs, absPath.removeLastSegments(1).toString(), absPath.lastSegment()); - } - else { - return EFS.getNullFileSystem().getStore(uri); - } - } - else { - return EFS.getNullFileSystem().getStore(uri); - } - } - catch (Exception e) { - return EFS.getNullFileSystem().getStore(uri); - } - } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileSystemContributor.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileSystemContributor.java index 2061a76177c..7ae07af0236 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileSystemContributor.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/RSEFileSystemContributor.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -12,6 +12,10 @@ * * Contributors: * Kushal Munir (IBM) - moved to internal package. + * Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, + * - Fix early startup issues by deferring FileStore evaluation and classloading, + * - Improve performance by RSEFileStore instance factory and caching IRemoteFile. + * - Also remove unnecessary class RSEFileCache and obsolete branding files. ********************************************************************************/ @@ -41,8 +45,8 @@ public class RSEFileSystemContributor extends FileSystemContributor { try { URI uri = new URI(initialPath); - IHost host = RSEFileSystem.getConnectionFor(uri.getHost()); - IRemoteFileSubSystem fs = RSEFileSystem.getRemoteFileSubSystem(host); + IHost host = RSEFileStoreImpl.getConnectionFor(uri.getHost(), null); + IRemoteFileSubSystem fs = RSEFileStoreImpl.getRemoteFileSubSystem(host); dlg.setInputObject(fs.getRemoteFileObject(uri.getPath())); } catch (Exception e) { diff --git a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java index 309304791b6..17623e5c529 100644 --- a/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java +++ b/rse/plugins/org.eclipse.rse.eclipse.filesystem/src/org/eclipse/rse/internal/eclipse/filesystem/ui/actions/CreateRemoteProjectActionDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved. + * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -14,7 +14,11 @@ * IBM Corporation - initial API and implementation * Kushal Munir (IBM) - moved to internal package * Martin Oberhuber (Wind River) - added progress dialog - * - (adapted from org.eclipse.ui.actions.CopyProjectAction, copyright IBM) + * - (adapted from org.eclipse.ui.actions.CopyProjectAction, copyright IBM) + * Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams, + * - Fix early startup issues by deferring FileStore evaluation and classloading, + * - Improve performance by RSEFileStore instance factory and caching IRemoteFile. + * - Also remove unnecessary class RSEFileCache and obsolete branding files. ********************************************************************************/ package org.eclipse.rse.internal.eclipse.filesystem.ui.actions; @@ -166,7 +170,6 @@ public class CreateRemoteProjectActionDelegate implements IActionDelegate { // (Copyright 2000, 2006 IBM Corporation and others) //---------------------------------------------------------------------------- - private IProject createRemoteProject(IRemoteFile directory, IProgressMonitor monitor) { IWorkspaceRoot root = SystemBasePlugin.getWorkspaceRoot(); @@ -185,7 +188,9 @@ public class CreateRemoteProjectActionDelegate implements IActionDelegate { try { IProjectDescription description = root.getWorkspace().newProjectDescription(directory.getName()); - URI location = RSEFileSystem.getInstance().getURIFor(directory); + String hostNameOrAddr = directory.getParentRemoteFileSubSystem().getHost().getHostName(); + String absolutePath = directory.getAbsolutePath(); + URI location = RSEFileSystem.getURIFor(hostNameOrAddr, absolutePath); description.setLocationURI(location); editProject.create(description, monitor);