From 78e2da4542a1b5a1c8e7a41255735fd98a934b22 Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Fri, 22 Feb 2008 20:30:15 +0000 Subject: [PATCH] [220020][api][breaking] SystemFileTransferModeRegistry should be internal --- .../UniversalFileTransferUtility.java | 14 +++-- .../UniversalPreferencePage.java | 7 ++- .../model/SystemFileTransferModeMapping.java | 58 +++++++++--------- .../model/SystemFileTransferModeRegistry.java | 13 ++-- .../core/model/RemoteFileFilterString.java | 53 +++++++++++----- .../files/core/model/RemoteFileUtility.java | 36 ++++++++++- .../FileServiceSubSystem.java | 5 +- .../files/core/subsystems/RemoteFile.java | 61 +++++++++---------- .../core/subsystems/RemoteFileEmpty.java | 10 +-- .../files/core/subsystems/RemoteFileRoot.java | 13 +++- .../DStoreFileSubSystemConfiguration.java | 7 ++- .../LocalFileSubSystemConfiguration.java | 7 ++- 12 files changed, 176 insertions(+), 108 deletions(-) rename rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/{ => internal}/subsystems/files/core/model/SystemFileTransferModeMapping.java (71%) rename rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/{ => internal}/subsystems/files/core/model/SystemFileTransferModeRegistry.java (96%) diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java index 8b458150f61..d83491451ee 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java @@ -40,6 +40,7 @@ * Xuan Chen (IBM) - [191370] [dstore] supertransfer zip not deleted when cancelling copy * Xuan Chen (IBM) - [210816] Archive testcases throw ResourceException if they are run in batch * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible + * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal ********************************************************************************/ package org.eclipse.rse.files.ui.resources; @@ -96,7 +97,6 @@ import org.eclipse.rse.services.files.RemoteFileSecurityException; import org.eclipse.rse.services.files.RemoteFolderNotEmptyException; import org.eclipse.rse.subsystems.files.core.SystemIFileProperties; import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; -import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeRegistry; import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; @@ -111,7 +111,9 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PlatformUI; /** - * Utility class for doing file transfers on universal systems + * Utility class for doing file transfers on universal systems. + * + * Clients may use this class, but not instantiate or subclass it. */ public class UniversalFileTransferUtility { @@ -825,7 +827,7 @@ public class UniversalFileTransferUtility long remoteModifiedStamp = srcFileOrFolder.lastModified(); boolean usedBin = properties.getUsedBinaryTransfer(); - boolean shouldUseBin = SystemFileTransferModeRegistry.getInstance().isBinary(srcFileOrFolder); + boolean shouldUseBin = RemoteFileUtility.getSystemFileTransferModeRegistry().isBinary(srcFileOrFolder); if (storedModifiedStamp == remoteModifiedStamp && (usedBin == shouldUseBin)) { return tempFile; @@ -855,7 +857,7 @@ public class UniversalFileTransferUtility } if (tempFile.exists()) { - if (SystemFileTransferModeRegistry.getInstance().isText(srcFileOrFolder)) + if (RemoteFileUtility.getSystemFileTransferModeRegistry().isText(srcFileOrFolder)) { try { @@ -907,7 +909,7 @@ public class UniversalFileTransferUtility } // encoding conversion required if it a text file but not an xml file - boolean isBinary = SystemFileTransferModeRegistry.getInstance().isBinary(file); + boolean isBinary = RemoteFileUtility.getSystemFileTransferModeRegistry().isBinary(file); boolean isEncodingConversionRequired = !isBinary; inputStream = new FileInputStream(file); @@ -1595,7 +1597,7 @@ public class UniversalFileTransferUtility String srcCharSet = null; - boolean isText = SystemFileTransferModeRegistry.getInstance().isText(newPath); + boolean isText = RemoteFileUtility.getSystemFileTransferModeRegistry().isText(newPath); if (isText) { try diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/UniversalPreferencePage.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/UniversalPreferencePage.java index d31c2bf8942..9fe8130fb07 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/UniversalPreferencePage.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/UniversalPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved. + * Copyright (c) 2002, 2008 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 @@ -16,6 +16,7 @@ * David McKnight (IBM) - [208951] no longer used editor registry for file type associations * David McKnight (IBM) - [203114] Usability improvements for file transfer mode prefs * David McKnight (IBM) - [210142] for accessibility need transfer mode toggle button + * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal ********************************************************************************/ package org.eclipse.rse.internal.files.ui.propertypages; @@ -44,13 +45,13 @@ import org.eclipse.jface.window.Window; import org.eclipse.rse.internal.files.ui.Activator; import org.eclipse.rse.internal.files.ui.FileResources; import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants; +import org.eclipse.rse.internal.subsystems.files.core.model.SystemFileTransferModeMapping; +import org.eclipse.rse.internal.subsystems.files.core.model.SystemFileTransferModeRegistry; import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessageFile; import org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping; -import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeMapping; -import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeRegistry; import org.eclipse.rse.ui.Mnemonics; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemWidgetHelpers; diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeMapping.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java similarity index 71% rename from rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeMapping.java rename to rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java index cb92832131e..c460bf289d1 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeMapping.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeMapping.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2007 IBM Corporation and others. + * Copyright (c) 2002, 2008 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 @@ -13,15 +13,17 @@ * * Contributors: * David McKnight (IBM) - [208951] new priority field + * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal *******************************************************************************/ -package org.eclipse.rse.subsystems.files.core.model; +package org.eclipse.rse.internal.subsystems.files.core.model; + +import org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping; /** * An internal class. Clients must not instantiate or subclass it. */ - public class SystemFileTransferModeMapping implements ISystemFileTransferModeMapping, Cloneable { public static final int DEFAULT_PRIORITY = Integer.MAX_VALUE; @@ -55,18 +57,17 @@ public class SystemFileTransferModeMapping implements ISystemFileTransferModeMap setExtension(extension); } - - - /** - * @see ISystemFileTransferModeMapping#getExtension() + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping#getExtension() */ public String getExtension() { return extension; } - - /** - * @see ISystemFileTransferModeMapping#getLabel() + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping#getLabel() */ public String getLabel() { @@ -78,31 +79,30 @@ public class SystemFileTransferModeMapping implements ISystemFileTransferModeMap } } - - /** - * @see ISystemFileTransferModeMapping#getName() + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping#getName() */ public String getName() { return name; } - - /** - * @see ISystemFileTransferModeMapping#isBinary() + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping#isBinary() */ public boolean isBinary() { return isBinary; } - - /** - * @see ISystemFileTransferModeMapping#isText() + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping#isText() */ public boolean isText() { return !isBinary(); } - /** * Set whether transfer mode is binary */ @@ -110,14 +110,12 @@ public class SystemFileTransferModeMapping implements ISystemFileTransferModeMap isBinary = true; } - /** * Set whether transfer mode is text */ public void setAsText() { isBinary = false; } - /** * Set the name @@ -126,7 +124,6 @@ public class SystemFileTransferModeMapping implements ISystemFileTransferModeMap this.name = name; } - /** * Set the extension */ @@ -136,27 +133,28 @@ public class SystemFileTransferModeMapping implements ISystemFileTransferModeMap /** * Set the priority - the smaller the number, the higher priority - * @param priority + * @param priority priority to set. */ public void setPriority(int priority) { this.priority = priority; } - /** - * Gets the priority - the smaller the number, the higher priority - * @return the priority + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping#getPriority() */ public int getPriority() { return this.priority; } - /** - * Clone this object + * Clone this object. + * + * Subclasses must ensure that such a deep copy operation is always + * possible, so their state must always be cloneable. */ public Object clone() { - try { return super.clone(); } diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeRegistry.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeRegistry.java similarity index 96% rename from rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeRegistry.java rename to rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeRegistry.java index e2b2dff2005..9252d945408 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/SystemFileTransferModeRegistry.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/model/SystemFileTransferModeRegistry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2007 IBM Corporation and others. + * Copyright (c) 2002, 2008 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 @@ -14,8 +14,9 @@ * Contributors: * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin * David McKnight (IBM) - [208951] Use remoteFileTypes extension point to determine file types + * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal *******************************************************************************/ -package org.eclipse.rse.subsystems.files.core.model; +package org.eclipse.rse.internal.subsystems.files.core.model; import java.io.File; import java.io.FileInputStream; @@ -37,6 +38,8 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants; import org.eclipse.rse.services.clientserver.SystemEncodingUtil; +import org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeMapping; +import org.eclipse.rse.subsystems.files.core.model.ISystemFileTransferModeRegistry; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemBasePlugin; @@ -67,7 +70,7 @@ public class SystemFileTransferModeRegistry implements ISystemFileTransferModeRe private static final String MODE_ATTRIBUTE = "mode"; //$NON-NLS-1$ private static final String BINARY_VALUE = "binary"; //$NON-NLS-1$ private static final String TEXT_VALUE = "text"; //$NON-NLS-1$ - private static final String PRIORITY_ATTRIBUTE = "priority"; + private static final String PRIORITY_ATTRIBUTE = "priority"; //$NON-NLS-1$ /** * Constructor for SystemFileTransferModeRegistry @@ -141,10 +144,10 @@ public class SystemFileTransferModeRegistry implements ISystemFileTransferModeRe } int priority = SystemFileTransferModeMapping.DEFAULT_PRIORITY; - String priorityStr = element.getAttribute("priority"); + String priorityStr = element.getAttribute("priority"); //$NON-NLS-1$ try { - if (priorityStr != null && !priorityStr.equals("")){ + if (priorityStr != null && !priorityStr.equals("")){ //$NON-NLS-1$ priority = Integer.parseInt(priorityStr); } } diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/RemoteFileFilterString.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/RemoteFileFilterString.java index 1760c6e1c34..ff2c687b313 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/RemoteFileFilterString.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/model/RemoteFileFilterString.java @@ -46,6 +46,11 @@ import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConf *

* It is invalid to have both a comma and an asterisk in the same filter string. * It is also invalid to have both a comma and a period in the same filter string. + * + * Clients may use or subclass this class. When subclassing, clients need to + * ensure that the subclass is always capable of performing a deep clone + * operation with the {@link #clone()} method, so if they add fields of + * complex type, these need to be dealt with by overriding {@link #clone()}. */ public class RemoteFileFilterString implements Cloneable { @@ -69,6 +74,7 @@ public class RemoteFileFilterString implements Cloneable subdirs = true; files = true; } + /** * Constructor to use when there is no existing filter string. *

@@ -86,6 +92,7 @@ public class RemoteFileFilterString implements Cloneable subdirs = true; files = true; } + /** * Constructor to use when an absolute filter string already exists. */ @@ -94,6 +101,7 @@ public class RemoteFileFilterString implements Cloneable this(subsysFactory); parse(null, input); } + /** * Constructor to use when you have a path and filename filter or comma-separated file types list. * In the latter case, the last char must be a TYPE_SEP or comma, even for a single type. @@ -108,6 +116,7 @@ public class RemoteFileFilterString implements Cloneable { PATH_SEP = subsysFactory.getSeparator(); } + /** * Set the file name filter. You either call this or setTypes! */ @@ -115,6 +124,7 @@ public class RemoteFileFilterString implements Cloneable { file = obj; } + /** * Set the path to list files and/or folders in */ @@ -122,6 +132,7 @@ public class RemoteFileFilterString implements Cloneable { this.path = path; } + /** * Set the file types to subset by. These are extensions, without the dot, as * in java, class, gif, etc. @@ -132,6 +143,7 @@ public class RemoteFileFilterString implements Cloneable this.types = types; filterByTypes = (types != null); } + /** * Allow files? */ @@ -139,6 +151,7 @@ public class RemoteFileFilterString implements Cloneable { files = set; } + /** * Allow subdirs? */ @@ -168,6 +181,7 @@ public class RemoteFileFilterString implements Cloneable return getTypesString(types); } } + /** * Concatenate the given file types as a single string, each type comma-separated */ @@ -178,6 +192,7 @@ public class RemoteFileFilterString implements Cloneable typesBuffer.append(typesArray[idx]+","); //$NON-NLS-1$ return typesBuffer.toString(); } + /** * For file types filters, returns the types as a string of concatenated types, * comma-delimited. For file name filters, returns null; @@ -204,13 +219,15 @@ public class RemoteFileFilterString implements Cloneable { return types; } + /** - * Subdirs allowed? + * Should the filter show individual files? */ public boolean getShowFiles() { return files; } + /** * Subdirs allowed? */ @@ -218,6 +235,7 @@ public class RemoteFileFilterString implements Cloneable { return subdirs; } + /** * Return true if this filter string filters by file types versus by file name */ @@ -243,7 +261,6 @@ public class RemoteFileFilterString implements Cloneable return toStringNoSwitches().equals("/*"); //$NON-NLS-1$ } - /** * */ @@ -313,6 +330,7 @@ public class RemoteFileFilterString implements Cloneable //this.path = fileObj.getAbsolutePath(); // happens for root drives //this.file = fileObj.getName(); } + /** * Parse the non-folder part of the filter string. Will either be a * generic name or comma-separated list of types. @@ -333,6 +351,7 @@ public class RemoteFileFilterString implements Cloneable else file = filter; } + /** * Parse a comma-separated list of strings into an array of strings */ @@ -353,7 +372,7 @@ public class RemoteFileFilterString implements Cloneable } /** - * De-hydrate into a string capturing all the attributes + * Serialize into a string capturing all the attributes */ public String toString() { @@ -364,6 +383,7 @@ public class RemoteFileFilterString implements Cloneable fs += SWITCH_NOFILES; return fs; } + /** * Return the filter as a string, without the switches for no-files, no-folders */ @@ -379,24 +399,25 @@ public class RemoteFileFilterString implements Cloneable else fs = path+getFileOrTypes(); return fs; - } + } + /** * Clone this into another filter string object with the same attributes. + * + * Subclasses must ensure that such a deep copy operation is always + * possible, so their state must always be cloneable. */ public Object clone() { - RemoteFileFilterString copy = new RemoteFileFilterString(); - copy.path = path; - copy.file = file; - copy.subdirs = subdirs; - copy.files = files; - copy.PATH_SEP = PATH_SEP; - copy.filterByTypes = filterByTypes; - if (types!=null) - { - copy.types = new String[types.length]; - for (int idx=0; idxnull if + * no file subsystem is configured with the given connection. + */ public static IRemoteFileSubSystem getFileSubSystem(IHost connection) { ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); @@ -49,6 +61,11 @@ public class RemoteFileUtility return null; } + /** + * Return the list of file subsystems associated with a connection. + * @param connection the connection to query. + * @return a list of IRemoteFileSubSystem instances (may be empty). + */ public static IRemoteFileSubSystem[] getFileSubSystems(IHost connection) { List results = new ArrayList(); @@ -65,6 +82,12 @@ public class RemoteFileUtility return (IRemoteFileSubSystem[])results.toArray(new IRemoteFileSubSystem[results.size()]); } + /** + * Return the first remote file subsystem configuration associated with a system type. + * @param systemType the system type to query. + * @return an IRemoteFileSubSystemConfiguration instance, or null if + * no file subsystem is configured with the given system type. + */ public static IRemoteFileSubSystemConfiguration getFileSubSystemConfiguration(IRSESystemType systemType) { ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); @@ -78,5 +101,14 @@ public class RemoteFileUtility } return null; } + + /** + * Return the global SystemFileTransferModeRegistry. + * @return the global SystemFileTransferModeRegistry. + */ + public static ISystemFileTransferModeRegistry getSystemFileTransferModeRegistry() + { + return SystemFileTransferModeRegistry.getInstance(); + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java index 6321ceea0c3..8f7f47d5cf0 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java @@ -31,6 +31,7 @@ * David Dykstal (IBM) - [217556] remove service subsystem types * Martin Oberhuber (Wind River) - [219098][api] FileServiceSubSystem should not be final * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible + * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.servicesubsystem; @@ -68,7 +69,7 @@ import org.eclipse.rse.services.search.IHostSearchResultConfiguration; import org.eclipse.rse.services.search.IHostSearchResultSet; import org.eclipse.rse.services.search.ISearchService; import org.eclipse.rse.subsystems.files.core.ILanguageUtilityFactory; -import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeRegistry; +import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; import org.eclipse.rse.subsystems.files.core.subsystems.IHostFileToRemoteFileAdapter; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileContext; @@ -537,7 +538,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe protected boolean isBinary(String localEncoding, String hostEncoding, String remotePath) { - return SystemFileTransferModeRegistry.getInstance().isBinary(remotePath); + return RemoteFileUtility.getSystemFileTransferModeRegistry().isBinary(remotePath); } protected boolean isBinary(IRemoteFile source) diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java index 55a7537f568..2f2bb4cf59d 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFile.java @@ -17,6 +17,7 @@ * David McKnight (IBM) - [186363] get rid of obsolete calls to ISubSystem.connect() * David McKnight (IBM) - [209660] use parent encoding as default, rather than system encoding * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files + * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.subsystems; @@ -48,7 +49,7 @@ import org.eclipse.rse.services.files.IHostFile; import org.eclipse.rse.services.files.IHostFilePermissions; import org.eclipse.rse.services.files.IHostFilePermissionsContainer; import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString; -import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeRegistry; +import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.swt.widgets.Display; @@ -68,20 +69,16 @@ import org.eclipse.swt.widgets.Display; * that creates this object must call the setter methods to * prefill this object with the core required information: *

+ * A concrete implementation which extends this class, also needs to ensure + * that information is properly set by some means such that the {@link IRemoteFile#exists()}, + * {@link IRemoteFile#getAbsolutePath()}, {@link IRemoteFile#getLength()} + * and similar methods can be implemented. */ -public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable, Cloneable +public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable { - - - protected IRemoteFileContext _context; - protected String fullyQualifiedName; protected String _label; protected Object remoteObj; @@ -346,13 +343,6 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable return ss.getHost(); } - /** - * @see IRemoteFile#getAbsolutePath() - */ - public String getAbsolutePath() - { - return fullyQualifiedName; - } /** * Get fully qualified connection and file name: connection:\path\file * Note the separator character between the profile name and the connection name is always '.' @@ -388,7 +378,7 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable if (isDirectory()) return false; else - return SystemFileTransferModeRegistry.getInstance().isBinary(this); + return RemoteFileUtility.getSystemFileTransferModeRegistry().isBinary(this); } /** @@ -399,7 +389,7 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable if (isDirectory()) return false; else - return SystemFileTransferModeRegistry.getInstance().isText(this); + return RemoteFileUtility.getSystemFileTransferModeRegistry().isText(this); } @@ -528,8 +518,9 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable return this.getAbsolutePathPlusConnection().startsWith(file.getAbsolutePathPlusConnection() + separator); } - /** - * @see org.eclipse.rse.core.subsystems.IRemoteContainer#hasContents(java.lang.String) + /* + * (non-Javadoc) + * @see org.eclipse.rse.core.model.ISystemContainer#hasContents(org.eclipse.rse.core.model.ISystemContentsType) */ public boolean hasContents(ISystemContentsType contentsType) { @@ -552,8 +543,9 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable return result; } - /** - * @see org.eclipse.rse.core.subsystems.IRemoteContainer#hasContents(java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * @see org.eclipse.rse.core.subsystems.IRemoteContainer#hasContents(org.eclipse.rse.core.model.ISystemContentsType, java.lang.String) */ public boolean hasContents(ISystemContentsType contentsType, String filter) { HashMap filters = (HashMap)(_contents.get(contentsType)); @@ -616,8 +608,9 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable return false; } - /** - * @see org.eclipse.rse.core.subsystems.IRemoteContainer#getContents(java.lang.String) + /* + * (non-Javadoc) + * @see org.eclipse.rse.core.model.ISystemContainer#getContents(org.eclipse.rse.core.model.ISystemContentsType) */ public Object[] getContents(ISystemContentsType contentsType) { @@ -641,6 +634,7 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable return result.toArray(new IRemoteFile[result.size()]); } + /* private Object[] getFiles(Object[] filesAndFolders) { List results = new ArrayList(); @@ -655,6 +649,7 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable } return results.toArray(); } + */ private Object[] getFolders(Object[] filesAndFolders) { @@ -672,8 +667,9 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable } - /** - * @see org.eclipse.rse.core.subsystems.IRemoteContainer#getContents(java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * @see org.eclipse.rse.core.subsystems.IRemoteContainer#getContents(org.eclipse.rse.core.model.ISystemContentsType, java.lang.String) */ public Object[] getContents(ISystemContentsType contentsType, String filter) { @@ -801,7 +797,7 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable */ private boolean isFilterForFileTypes(String filter) { - if (filter.endsWith(",")) { + if (filter.endsWith(",")) { //$NON-NLS-1$ return true; } else { @@ -839,8 +835,9 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable - /** - * @see org.eclipse.rse.core.subsystems.IRemoteContainer#setContents(java.lang.String, java.lang.String, java.lang.Object[]) + /* + * (non-Javadoc) + * @see org.eclipse.rse.core.subsystems.IRemoteContainer#setContents(org.eclipse.rse.core.model.ISystemContentsType, java.lang.String, java.lang.Object[]) */ public void setContents(ISystemContentsType contentsType, String filter, Object[] con) { @@ -1163,7 +1160,7 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable /** * Returns the encoding of the remote file. If a user specified value does not exist, then we check * it's ancestry for an encoding. Otherwise the encoding of the parent subsystem is returned. - * @see com.ibm.etools.systems.subsystems.IRemoteFile#getEncoding() + * @see IRemoteFile#getEncoding() */ public String getEncoding() { String hostName = getParentRemoteFileSubSystem().getHost().getHostName(); diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileEmpty.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileEmpty.java index 642fdd12f38..5869d55eb08 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileEmpty.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileEmpty.java @@ -12,7 +12,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.subsystems; @@ -26,16 +26,18 @@ import org.eclipse.rse.services.files.IHostFilePermissions; */ public class RemoteFileEmpty extends RemoteFile { - - /** - * Constructor for RemoteFileEmptyImpl + * Constructor for RemoteFileEmpty */ public RemoteFileEmpty() { super(new RemoteFileContext(null,null,null)); } + public String getAbsolutePath() + { + return ""; //$NON-NLS-1$ + } public String getName() diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileRoot.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileRoot.java index 02a9094ee82..4a660b67bf0 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileRoot.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileRoot.java @@ -12,7 +12,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.subsystems; @@ -36,9 +36,13 @@ public class RemoteFileRoot extends RemoteFile public RemoteFileRoot(IRemoteFile rootFile) { super(new RemoteFileContext(null,null,null)); + setRootFile(rootFile); } + /** - * Constructor when root is not known + * Constructor when root is not known. + * Client must call {@link #setRootFile(IRemoteFile)} before any + * get.. calls in this class are actually used. */ public RemoteFileRoot() { @@ -163,6 +167,11 @@ public class RemoteFileRoot extends RemoteFile return rootFile.getClassification(); } + public String getAbsolutePath() + { + return rootFile.getAbsolutePath(); + } + public String getCanonicalPath() { return rootFile.getCanonicalPath(); diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/subsystems/files/dstore/DStoreFileSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/subsystems/files/dstore/DStoreFileSubSystemConfiguration.java index 9cf87fcb918..563973c02ce 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/subsystems/files/dstore/DStoreFileSubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/subsystems/files/dstore/DStoreFileSubSystemConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2008 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 @@ -15,6 +15,7 @@ * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Kushal Munir (IBM) - [189352] Set whether file service is Unix-style system or not * David McKnight (IBM) - [206755] upload and download buffer should be in kbytes, not bytes + * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal *******************************************************************************/ package org.eclipse.rse.subsystems.files.dstore; @@ -39,7 +40,7 @@ import org.eclipse.rse.services.search.IHostSearchResultConfiguration; import org.eclipse.rse.services.search.IHostSearchResultSet; import org.eclipse.rse.services.search.ISearchService; import org.eclipse.rse.subsystems.files.core.ILanguageUtilityFactory; -import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeRegistry; +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.FileServiceSubSystemConfiguration; import org.eclipse.rse.subsystems.files.core.subsystems.IHostFileToRemoteFileAdapter; @@ -136,7 +137,7 @@ public class DStoreFileSubSystemConfiguration extends FileServiceSubSystemConfig public IFileService createFileService(IHost host) { DStoreConnectorService connectorService = (DStoreConnectorService)getConnectorService(host); - DStoreFileService service = new DStoreFileService(connectorService, SystemFileTransferModeRegistry.getInstance(), RSEUIPlugin.getDefault()); + DStoreFileService service = new DStoreFileService(connectorService, RemoteFileUtility.getSystemFileTransferModeRegistry(), RSEUIPlugin.getDefault()); service.setIsUnixStyle(isUnixStyle()); IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/subsystems/files/local/LocalFileSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/subsystems/files/local/LocalFileSubSystemConfiguration.java index d36cb143005..266bcea31b0 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/subsystems/files/local/LocalFileSubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/subsystems/files/local/LocalFileSubSystemConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2008 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,6 +14,7 @@ * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Martin Oberhuber (Wind River) - [186997] No deferred queries in Local Files * Kevin Doyle (IBM) - [199871] LocalFileService needs to implement getMessage() + * Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal ********************************************************************************/ package org.eclipse.rse.subsystems.files.local; @@ -41,7 +42,7 @@ import org.eclipse.rse.services.search.IHostSearchResultSet; import org.eclipse.rse.services.search.ISearchService; import org.eclipse.rse.subsystems.files.core.ILanguageUtilityFactory; import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString; -import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeRegistry; +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.FileServiceSubSystemConfiguration; import org.eclipse.rse.subsystems.files.core.subsystems.IHostFileToRemoteFileAdapter; @@ -224,7 +225,7 @@ public class LocalFileSubSystemConfiguration extends FileServiceSubSystemConfigu public IFileService createFileService(IHost host) { - return new LocalFileService(SystemFileTransferModeRegistry.getInstance(), RSEUIPlugin.getDefault()); + return new LocalFileService(RemoteFileUtility.getSystemFileTransferModeRegistry(), RSEUIPlugin.getDefault()); } public ISearchService createSearchService(IHost host)