|
RSE Release 3.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.rse.core.model.RSEPersistableObject
org.eclipse.rse.core.model.PropertySetContainer
org.eclipse.rse.core.model.RSEModelObject
org.eclipse.rse.core.subsystems.SubSystem
org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem
public abstract class RemoteFileSubSystem
Specialization for file subsystem factories.
It is subclassed via use of a Rose model and MOF/EMF, or better yet
by subclassing FileServiceSubSystem
.
For your convenience, there is built-in name filtering support. To use it, call:
setListValues(int, String)
or setListValues(int, String, String)
to set the filter criteria
accept(String, boolean)
to test a given name for a match
This class returns instances of RemoteFile
objects.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.eclipse.rse.core.subsystems.SubSystem |
---|
SubSystem.ChangeStatusJob, SubSystem.ConnectJob, SubSystem.DisconnectJob, SubSystem.DisplayErrorMessageJob, SubSystem.GetPropertiesJob, SubSystem.GetPropertyJob, SubSystem.ResolveAbsoluteJob, SubSystem.ResolveAbsolutesJob, SubSystem.ResolveRelativeJob, SubSystem.SetPropertiesJob, SubSystem.SetPropertyJob, SubSystem.SubSystemOperationJob, SubSystem.SystemMessageDialogRunnable |
Field Summary | |
---|---|
protected HashMap |
_cachedRemoteFiles
|
protected ArrayList |
_searchHistory
|
protected RemoteFileFilterString |
currFilterString
|
protected RemoteFileContext |
DEFAULT_CONTEXT
|
protected RemoteFileContext |
DEFAULT_CONTEXT_NOFILTERSTRING
|
protected RemoteFileFilterString |
FILTERSTRING_LISTROOTS
|
protected NamePatternMatcher |
folderNameMatcher
|
protected IMatcher |
matcher
|
String |
osCmdShell
|
String |
osName
|
boolean |
osVarsSet
|
boolean |
osWindows
|
boolean |
osWindows95
|
boolean |
osWindowsNT
|
Fields inherited from interface org.eclipse.rse.core.model.IRSEPersistableContainer |
---|
NO_CHILDREN |
Constructor Summary | |
---|---|
RemoteFileSubSystem(IHost host,
IConnectorService connectorService)
Default constructor. |
Method Summary | |
---|---|
protected boolean |
accept(String name,
boolean isFile)
Method to decide if a given folder or file name matches the present criteria. |
protected void |
addResolvedFilterStringObjects(Vector allChildrenSoFar,
Object[] childrenForThisFilterString,
String[] allFilterStrings,
int currFilterStringIndex)
Overridable parent extension point for adding the results of a filter string to the overall list of results. |
void |
cacheRemoteFile(IRemoteFile file)
Store the IRemoteFile in a hashmap to quick subsequent retrieval |
void |
cacheRemoteFile(IRemoteFile file,
String path)
Store the IRemoteFile in a hashmap to quick subsequent retrieval |
void |
cancelSearch(IHostSearchResultConfiguration searchConfig)
Deprecated. Do not call this method directly since it is not implemented. |
void |
communicationsStateChange(CommunicationsEvent e)
This method is invoked whenever the communications state is invoked immediately before and after the state of the communications changes. |
boolean |
doesFilterMatch(ISystemFilter filter,
String remoteObjectAbsoluteName)
Return true if the given remote object name will pass the filtering criteria for any of the filter strings in this filter. |
boolean |
doesFilterStringListContentsOf(ISystemFilterString filterString,
String remoteObjectAbsoluteName)
Return true if the given filter string lists the contents of the given remote object. |
boolean |
doesFilterStringMatch(String filterString,
String remoteObjectAbsoluteName,
boolean caseSensitive)
Return true if the given remote object name will pass the filtering criteria for the given filter string. |
IRemoteFile |
getCachedRemoteFile(String path)
Returns the cached remote file with the specified path. |
protected RemoteFileContext |
getContext(IRemoteFile parent)
|
protected RemoteFileContext |
getContext(IRemoteFile parent,
RemoteFileFilterString rffs)
|
protected RemoteFileFilterString |
getCurrentFilterString()
|
protected RemoteFileContext |
getDefaultContext()
|
protected RemoteFileContext |
getDefaultContextNoFilterString()
|
protected RemoteFileFilterString |
getFilterStringListRoots()
|
protected String |
getFirstParentFilterString(Object parent)
Called by parent when we defer getting a filter string until later, where we query it from the parent. |
String |
getLineSeparator()
Return as a string the line separator. |
InetAddress |
getLocalAddress()
Returns the address found by calling InetAddress.getLocalHost() . |
Object |
getObjectWithAbsoluteName(String key,
IProgressMonitor monitor)
Return the object within the subsystem that corresponds to the specified unique ID. |
String |
getParentFolderName(IRemoteFile folderOrFile)
Given a folder or file, return its parent folder name, fully qualified |
IRemoteFileSubSystemConfiguration |
getParentRemoteFileSubSystemConfiguration()
Return parent subsystem factory, cast to a RemoteFileSubSystemConfiguration Assumes SubSystem.setSubSystemConfiguration(ISubSystemConfiguration) has already been called. |
String |
getPathSeparator()
Return in string format the character used to separate paths. |
char |
getPathSeparatorChar()
Return in char format the character used to separate paths. |
PropertyPage |
getPropertyPage(Composite parent)
Return the single property page to show in the tabbed notebook for the for SubSystem property of the parent Connection. |
String |
getRemoteEncoding()
Returns the local platform encoding if the default encoding of the host was not set. |
IRemoteFile[] |
getRemoteFileObjects(String[] folderOrFileNames,
IProgressMonitor monitor)
Given a set of fully qualified file or folder names, return an ISystemResourceSet object for it. |
IRemoteSearchResult |
getRemoteSearchResultObject(String key)
Given a key, returns a search result object for it. |
String |
getSeparator()
Return in string format the character used to separate folders. |
char |
getSeparatorChar()
Return in character format the character used to separate folders. |
Object |
getTargetForFilter(ISystemFilterReference filterRef)
Returns the parent object associated with a filter reference. |
int |
getUnusedPort()
Returns -1 by default. |
void |
initializeSubSystem(IProgressMonitor monitor)
Initialize this subsystem instance after the corresponding IConnectorService connect method finishes. |
protected Object[] |
internalResolveFilterString(Object parent,
String filterString,
IProgressMonitor monitor)
Actually resolve a relative filter string. |
protected Object[] |
internalResolveFilterString(String filterString,
IProgressMonitor monitor)
Actually resolve an absolute filter string. |
Object[] |
internalResolveFilterStrings(String[] filterStrings,
IProgressMonitor monitor)
Resolves filter strings. |
protected Object[] |
internalResolveOneFilterString(Object parent,
RemoteFileFilterString fs,
boolean sort,
IProgressMonitor monitor)
Do one filter string relative resolve |
boolean |
isCaseSensitive()
Return true if file names are case-sensitive. |
boolean |
isPassiveCommunicationsListener()
This method determines if the communications listener is a passive or active listener. |
boolean |
isPrimarySubSystem()
|
IRemoteFile[] |
list(IRemoteFile parent,
int fileType,
IProgressMonitor monitor)
Return a list of all remote folders and files in the given folder. |
IRemoteFile[] |
list(IRemoteFile parent,
IProgressMonitor monitor)
Return a list of all remote folders and files in the given folder. |
IRemoteFile[] |
list(IRemoteFile parent,
String fileNameFilter,
int fileType,
IProgressMonitor monitor)
Return a list of remote folders and files in the given folder. |
IRemoteFile[] |
listMultiple(IRemoteFile[] parents,
int[] fileTypes,
IProgressMonitor monitor)
Return a list of all remote folders and files in the given folder. |
IRemoteFile[] |
listMultiple(IRemoteFile[] parents,
int fileType,
IProgressMonitor monitor)
Return a list of all remote folders and files in the given folder. |
IRemoteFile[] |
listRoots(IProgressMonitor monitor)
Return a list of roots/drives on the remote system |
protected void |
removeCachedRemoteFile(IRemoteFile file)
|
protected void |
removeCachedRemoteFile(String path)
|
static int |
runLocalCommand(String cmd,
Vector lines)
helper method to run an external command |
protected void |
setListValues(int includeFilesOrFolders,
String nameFilter)
Method to set variables to affect the folder content subsetting. |
protected void |
setListValues(int includeFilesOrFolders,
String folderNameFilter,
String fileNameFilter)
Overloaded method to set variables to affect the folder content subsetting, when there is separate filters for both folder names and filter names. |
Object[] |
sortResolvedFilterStringObjects(Object[] children)
Sort the concatenated list of all objects returned by resolving one or more filter strings. |
void |
uninitializeSubSystem(IProgressMonitor monitor)
Uninitialize this subsystem just after disconnect. |
Methods inherited from class org.eclipse.rse.core.model.RSEModelObject |
---|
getDescription |
Methods inherited from class org.eclipse.rse.core.model.PropertySetContainer |
---|
addPropertySet, addPropertySets, createPropertySet, createPropertySet, getPropertySet, getPropertySets, removePropertySet |
Methods inherited from class org.eclipse.rse.core.model.RSEPersistableObject |
---|
compareStrings, isDirty, isTainted, setDirty, setTainted, setWasRestored, wasRestored |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem |
---|
copy, copyBatch, createFile, createFolder, createFolders, delete, deleteBatch, download, downloadMultiple, getInputStream, getLanguageUtilityFactory, getOutputStream, getOutputStream, getParentFolder, getRemoteFileObject, getRemoteFileObject, list, listMultiple, listMultiple, listRoots, move, rename, search, setLastModified, setReadOnly, supportsEncodingConversion, upload, upload, uploadMultiple, uploadMultiple |
Methods inherited from interface org.eclipse.rse.core.subsystems.IRemoteObjectResolver |
---|
getObjectWithAbsoluteName |
Methods inherited from interface org.eclipse.core.runtime.jobs.ISchedulingRule |
---|
contains, isConflicting |
Methods inherited from interface org.eclipse.rse.core.model.IRSEModelObject |
---|
getDescription |
Methods inherited from interface org.eclipse.rse.core.model.IPropertySetContainer |
---|
addPropertySet, addPropertySets, createPropertySet, createPropertySet, getPropertySet, getPropertySets, removePropertySet |
Methods inherited from interface org.eclipse.rse.core.model.IRSEPersistableContainer |
---|
commit, getPersistableChildren, getPersistableParent, isDirty, isTainted, setDirty, setTainted, setWasRestored, wasRestored |
Field Detail |
---|
public boolean osVarsSet
public boolean osWindows
public boolean osWindows95
public boolean osWindowsNT
public String osName
public String osCmdShell
protected IMatcher matcher
protected NamePatternMatcher folderNameMatcher
protected RemoteFileFilterString currFilterString
protected RemoteFileFilterString FILTERSTRING_LISTROOTS
protected RemoteFileContext DEFAULT_CONTEXT
protected RemoteFileContext DEFAULT_CONTEXT_NOFILTERSTRING
protected ArrayList _searchHistory
protected HashMap _cachedRemoteFiles
Constructor Detail |
---|
public RemoteFileSubSystem(IHost host, IConnectorService connectorService)
SubSystem.setSubSystemConfiguration(ISubSystemConfiguration)
.
Method Detail |
---|
public boolean isPrimarySubSystem()
isPrimarySubSystem
in interface ISubSystem
isPrimarySubSystem
in class SubSystem
IConnectorService
public IRemoteFileSubSystemConfiguration getParentRemoteFileSubSystemConfiguration()
SubSystem.setSubSystemConfiguration(ISubSystemConfiguration)
has already been called.
getParentRemoteFileSubSystemConfiguration
in interface IRemoteFileSubSystem
public boolean isCaseSensitive()
isCaseSensitive
in interface IRemoteFileSubSystem
protected RemoteFileFilterString getCurrentFilterString()
protected RemoteFileFilterString getFilterStringListRoots()
protected RemoteFileContext getDefaultContext()
protected RemoteFileContext getDefaultContextNoFilterString()
protected RemoteFileContext getContext(IRemoteFile parent)
protected RemoteFileContext getContext(IRemoteFile parent, RemoteFileFilterString rffs)
public String getSeparator()
getParentRemoteFileSubSystemConfiguration()
.getSeparator()
getSeparator
in interface IRemoteFileSubSystem
public char getSeparatorChar()
getParentRemoteFileSubSystemConfiguration()
.getSeparatorChar()
getSeparatorChar
in interface IRemoteFileSubSystem
public String getPathSeparator()
getParentRemoteFileSubSystemConfiguration()
.getPathSeparator()
getPathSeparator
in interface IRemoteFileSubSystem
public char getPathSeparatorChar()
getParentRemoteFileSubSystemConfiguration()
.getPathSeparatorChar()
getPathSeparatorChar
in interface IRemoteFileSubSystem
public String getLineSeparator()
getParentRemoteFileSubSystemConfiguration()
.getLineSeparator()
getLineSeparator
in interface IRemoteFileSubSystem
public PropertyPage getPropertyPage(Composite parent)
getPropertyPage
in class SubSystem
public boolean doesFilterMatch(ISystemFilter filter, String remoteObjectAbsoluteName)
SubSystem
Subclasses do not need to override this method. Rather, this method walks each filter string and calls doesFilterStringMatch(...), and that is the method that child classes must override.
doesFilterMatch
in interface ISubSystem
doesFilterMatch
in class SubSystem
SubSystem.doesFilterMatch(org.eclipse.rse.core.filters.ISystemFilter, java.lang.String)
public boolean doesFilterStringMatch(String filterString, String remoteObjectAbsoluteName, boolean caseSensitive)
Subclasses need to override this. If in doubt, return true.
There is a hack here if you want to tell us the absolute name is that of a folder: append " -folder" to the name!
doesFilterStringMatch
in interface ISubSystem
doesFilterStringMatch
in class SubSystem
public boolean doesFilterStringListContentsOf(ISystemFilterString filterString, String remoteObjectAbsoluteName)
This should only return true if the filter string directly lists the contents of the given object, versus indirectly.
Subclasses should override this.
doesFilterStringListContentsOf
in interface ISubSystem
doesFilterStringListContentsOf
in class SubSystem
public Object[] internalResolveFilterStrings(String[] filterStrings, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
internalResolveFilterString(String, IProgressMonitor)
.
If the result for each filter string is a SystemMessage (e.g. an error), then the messages are returned.
If the result for any filter string is not a message (i.e. an array of children), then the children are returned,
and the messages are not. This avoids mixing chuldren as a result of successful resolution of a filter string with
messages that might result for other filter strings.
So the returned results are always the successful results, or messages (never a mix of the two).
internalResolveFilterStrings
in class SubSystem
filterStrings
- array of filter patterns for objects to return.monitor
- the progress monitor we are running under
InvocationTargetException
InterruptedException
SubSystem.internalResolveFilterStrings(java.lang.String[], org.eclipse.core.runtime.IProgressMonitor)
protected void addResolvedFilterStringObjects(Vector allChildrenSoFar, Object[] childrenForThisFilterString, String[] allFilterStrings, int currFilterStringIndex)
Can be used to filter out redundant entries in the concatenated list, if this is desired.
addResolvedFilterStringObjects
in class SubSystem
protected Object[] internalResolveFilterString(String filterString, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
internalResolveFilterString
in class SubSystem
InvocationTargetException
InterruptedException
SubSystem.internalResolveFilterString(String,IProgressMonitor)
public Object[] sortResolvedFilterStringObjects(Object[] children)
sortResolvedFilterStringObjects
in class SubSystem
protected String getFirstParentFilterString(Object parent)
getFirstParentFilterString
in class SubSystem
protected Object[] internalResolveFilterString(Object parent, String filterString, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
As per IRunnableWithProgress rules:
internalResolveFilterString
in class SubSystem
InvocationTargetException
InterruptedException
protected Object[] internalResolveOneFilterString(Object parent, RemoteFileFilterString fs, boolean sort, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, SystemMessageException
InvocationTargetException
InterruptedException
SystemMessageException
public IRemoteFile[] listRoots(IProgressMonitor monitor) throws InterruptedException
listRoots
in interface IRemoteFileSubSystem
InterruptedException
public IRemoteFile[] listMultiple(IRemoteFile[] parents, int[] fileTypes, IProgressMonitor monitor) throws SystemMessageException
listMultiple
in interface IRemoteFileSubSystem
parents
- The parent folders to list folders and files infileTypes
- - indicates whether to query files, folders, both or
some other typemonitor
- the progress monitor
SystemMessageException
public IRemoteFile[] listMultiple(IRemoteFile[] parents, int fileType, IProgressMonitor monitor) throws SystemMessageException
listMultiple
in interface IRemoteFileSubSystem
parents
- The parent folders to list folders and files infileType
- - indicates whether to query files, folders, both or some
other typemonitor
- the progress monitor
SystemMessageException
public IRemoteFile[] list(IRemoteFile parent, IProgressMonitor monitor) throws SystemMessageException
list
in interface IRemoteFileSubSystem
parent
- The parent folder to list folders and files inmonitor
- the progress monitor
SystemMessageException
public IRemoteFile[] list(IRemoteFile parent, int fileType, IProgressMonitor monitor) throws SystemMessageException
list
in interface IRemoteFileSubSystem
parent
- The parent folder to list folders and files infileType
- the type of filemonitor
- the monitor
SystemMessageException
public IRemoteFile[] list(IRemoteFile parent, String fileNameFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException
The files part of the list is subsetted by the given file name filter. It can be null for no subsetting.
list
in interface IRemoteFileSubSystem
parent
- The parent folder to list folders and files infileNameFilter
- The name pattern to subset the file list by, or
null to return all files.fileType
- the type of filemonitor
- the monitor
SystemMessageException
public String getParentFolderName(IRemoteFile folderOrFile)
getParentFolderName
in interface IRemoteFileSubSystem
folderOrFile
- folder or file to return parent of.public IRemoteSearchResult getRemoteSearchResultObject(String key) throws SystemMessageException
IRemoteFileSubSystem
getRemoteSearchResultObject
in interface IRemoteFileSubSystem
key
- the key that uniquely identifies a search result.
SystemMessageException
public IRemoteFile[] getRemoteFileObjects(String[] folderOrFileNames, IProgressMonitor monitor) throws SystemMessageException
getRemoteFileObjects
in interface IRemoteFileSubSystem
folderOrFileNames
- Fully qualified folder or file namesmonitor
- the progress monitor
SystemMessageException
public Object getObjectWithAbsoluteName(String key, IProgressMonitor monitor) throws Exception
getObjectWithAbsoluteName
in interface IRemoteObjectResolver
getObjectWithAbsoluteName
in class SubSystem
key
- the unique id of the remote object. Must not be
null
.monitor
- the progress monitor
null
if no object is
found with the given id.
Exception
- in case an error occurs contacting the remote system
while retrieving the requested remote object. Extenders are
encouraged to throw SystemMessageException
in order to
support good user feedback in case of errors. Since exceptions
should only occur while retrieving new remote objects during
startup, clients are typically allowed to ignore these exceptions
and treat them as if the remote object were simply not there.SubSystem.getObjectWithAbsoluteName(String, IProgressMonitor)
protected void setListValues(int includeFilesOrFolders, String nameFilter)
includeFilesOrFolders
- A constant from IFileConstants
nameFilter
- The pattern to filter the file or folder names by. Can be null to include all.protected void setListValues(int includeFilesOrFolders, String folderNameFilter, String fileNameFilter)
includeFilesOrFolders
- A constant from IFileConstants
folderNameFilter
- The pattern to filter the folder names by. Can be null to include all foldersfileNameFilter
- The pattern to filter the file names by. Can be null to include all filesprotected boolean accept(String name, boolean isFile)
setListValues(int, String)
or setListValues(int, String, String)
name
- The file or folder name to testisFile
- true if this is a file name, false if it is a folder name.
public static int runLocalCommand(String cmd, Vector lines) throws Exception
Exception
public void initializeSubSystem(IProgressMonitor monitor) throws SystemMessageException
SubSystem
IConnectorService
connect method finishes. This method should be
overridden if any initialization for the subsystem needs to occur at this
time.
The default implementation currently does nothing, but overriding methods should call super before doing any other work.
initializeSubSystem
in interface ISubSystem
initializeSubSystem
in class SubSystem
monitor
- a progress monitor that can be used to show progress
during long-running operation. Cancellation is typically not
supported since it might leave the system in an inconsistent
state.
SystemMessageException
- if an error occurs during initialization.public void uninitializeSubSystem(IProgressMonitor monitor)
SubSystem
uninitializeSubSystem
in interface ISubSystem
uninitializeSubSystem
in class SubSystem
monitor
- a progress monitor that can be used to show progress
during long-running operation. Cancellation is typically not
supported since it might leave the system in an inconsistent
state.public void cacheRemoteFile(IRemoteFile file, String path)
file
- the filepublic void cacheRemoteFile(IRemoteFile file)
file
- the filepublic IRemoteFile getCachedRemoteFile(String path)
path
-
protected void removeCachedRemoteFile(IRemoteFile file)
protected void removeCachedRemoteFile(String path)
public void communicationsStateChange(CommunicationsEvent e)
ICommunicationsListener
communicationsStateChange
in interface ICommunicationsListener
public boolean isPassiveCommunicationsListener()
ICommunicationsListener
isPassiveCommunicationsListener
in interface ICommunicationsListener
ICommunicationsListener.isPassiveCommunicationsListener()
public int getUnusedPort()
getUnusedPort
in interface IRemoteFileSubSystem
IRemoteFileSubSystem.getUnusedPort()
public InetAddress getLocalAddress()
InetAddress.getLocalHost()
. If that
call returns the local loopback address, it returns null
.
Subclasses should reimplement to handle cases where systems have multiple IP addresses due
to multiple network cards or VPN. This method should return an address
that is usable from the remote system to connect back to the local system.
getLocalAddress
in interface IRemoteFileSubSystem
null
if
no address can be resolved.IRemoteFileSubSystem.getLocalAddress()
public Object getTargetForFilter(ISystemFilterReference filterRef)
ISubSystem
getTargetForFilter
in interface ISubSystem
getTargetForFilter
in class SubSystem
filterRef
- the filter reference to determine a target object from.
public void cancelSearch(IHostSearchResultConfiguration searchConfig)
cancelSearch
in interface IRemoteFileSubSystem
searchConfig
- a search configuration.public String getRemoteEncoding()
getRemoteEncoding
in interface IRemoteFileSubSystem
IRemoteFileSubSystem.getRemoteEncoding()
|
RSE Release 3.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |