RSE
Release 1.0

org.eclipse.rse.services.dstore.files
Class DStoreFileService

java.lang.Object
  extended byorg.eclipse.rse.services.dstore.AbstractDStoreService
      extended byorg.eclipse.rse.services.dstore.files.DStoreFileService
All Implemented Interfaces:
IDStoreService, IFileService, IService, IServiceConstants, IUniversalDataStoreConstants

public class DStoreFileService
extends AbstractDStoreService
implements IFileService, IUniversalDataStoreConstants


Field Summary
protected  Map _fileElementMap
           
protected  ISystemFileTypes _fileTypeRegistry
           
protected  org.eclipse.dstore.core.model.DataElement _uploadLogElement
           
 
Fields inherited from class org.eclipse.rse.services.dstore.AbstractDStoreService
_cmdDescriptorMap, _dataStoreProvider, _initializeStatus, _minerElement, _msgProvider, _statusMonitor
 
Fields inherited from interface org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants
BINARY_MODE, BUFFER_SIZE, C_COPY, C_COPY_BATCH, C_CREATE_FILE, C_CREATE_FOLDER, C_DELETE, C_DELETE_BATCH, C_DOWNLOAD_FILE, C_QUERY_GET_REMOTE_OBJECT, C_QUERY_QUALIFIED_CLASSNAME, C_QUERY_ROOTS, C_QUERY_UNUSED_PORT, C_QUERY_VIEW_ALL, C_QUERY_VIEW_FILES, C_QUERY_VIEW_FOLDERS, C_RENAME, C_SYSTEM_ENCODING, DOWNLOAD_RESULT_EXCEPTION, DOWNLOAD_RESULT_FILE_NOT_FOUND_EXCEPTION, DOWNLOAD_RESULT_IO_EXCEPTION, DOWNLOAD_RESULT_SUCCESS_MESSAGE, DOWNLOAD_RESULT_SUCCESS_TYPE, DOWNLOAD_RESULT_UNEXPECTED_ERROR, DOWNLOAD_RESULT_UNSUPPORTED_ENCODING_EXCEPTION, KB_IN_BYTES, MESSAGE_DESCRIPTOR, NUM_OF_KB, TEXT_MODE, TYPE_QUALIFIED_CLASSNAME, UNIVERSAL_ARCHIVE_FILE_DESCRIPTOR, UNIVERSAL_FILE_DESCRIPTOR, UNIVERSAL_FILESYSTEM_MINER, UNIVERSAL_FILTER_DESCRIPTOR, UNIVERSAL_FOLDER_DESCRIPTOR, UNIVERSAL_NODE_DESCRIPTOR, UNIVERSAL_TEMP_DESCRIPTOR, UNIVERSAL_VIRTUAL_FILE_DESCRIPTOR, UNIVERSAL_VIRTUAL_FOLDER_DESCRIPTOR
 
Fields inherited from interface org.eclipse.rse.services.clientserver.IServiceConstants
FAILED, FAILED_TO_DELETE_DIR, FAILED_WITH_DOES_NOT_EXIST, FAILED_WITH_EXCEPTION, FAILED_WITH_EXIST, FAILED_WITH_SECURITY, SUCCESS, TOKEN_SEPARATOR, UNEXPECTED_ERROR, VERSION_1
 
Constructor Summary
DStoreFileService(org.eclipse.dstore.core.model.IDataStoreProvider dataStoreProvider, ISystemFileTypes fileTypeRegistry, ISystemMessageProvider msgProvider)
           
 
Method Summary
protected  IHostFile convertToHostFile(org.eclipse.dstore.core.model.DataElement element)
           
protected  IHostFile[] convertToHostFiles(org.eclipse.dstore.core.model.DataElement[] elements)
           
 boolean copy(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName)
          Copy the file or folder to the specified destination
 boolean copyBatch(IProgressMonitor monitor, String[] srcParents, String[] srcNames, String tgtParent)
          Copy a set of files or folders to the specified destination
 IHostFile createFile(IProgressMonitor monitor, String remoteParent, String fileName)
          Create a file on the host
 IHostFile createFolder(IProgressMonitor monitor, String remoteParent, String folderName)
          Create a folder on the host
 boolean delete(IProgressMonitor monitor, String remoteParent, String fileName)
          Deletes a file or folder on the host
 boolean deleteBatch(IProgressMonitor monitor, String[] remoteParents, String[] fileNames)
          Deletes a set of files or folders on the host.
 boolean download(IProgressMonitor monitor, String remoteParent, String remoteFile, File localFile, boolean isBinary, String encoding)
          Copy a file from the remote file system to the local system.
protected  IHostFile[] fetch(IProgressMonitor monitor, String remoteParent, String fileFilter, String queryType)
           
protected  org.eclipse.dstore.core.model.DataElement findUploadLog()
           
protected  org.eclipse.dstore.core.model.DataElement getAttributes(String fileNameFilter, boolean showHidden)
           
protected  int getBufferDownloadSize()
           
protected  int getBufferUploadSize()
           
protected  String getByteStreamHandlerId()
           
protected  String getDataStoreRoot()
           
 String getDescription()
           
protected  org.eclipse.dstore.core.model.DataElement getElementFor(String path)
           
 IHostFile getFile(IProgressMonitor monitor, String remoteParent, String name)
           
 IHostFile[] getFiles(IProgressMonitor monitor, String remoteParent, String fileFilter)
           
 IHostFile[] getFilesAndFolders(IProgressMonitor monitor, String remoteParent, String fileFilter)
           
 IHostFile[] getFolders(IProgressMonitor monitor, String remoteParent, String fileFilter)
           
protected  String getMinerId()
           
 String getName()
           
 IHostFile[] getRoots(IProgressMonitor monitor)
           
protected  String getSeparator(String parentPath)
          Returns what the next part of the path should be, given the current path as parentPath.
 IHostFile getUserHome()
           
 boolean isCaseSensitive()
          Indicates whether the file system is case sensitive
protected  boolean isSpecialChar(char c)
          Checks whether the given character is a special character in the shell.
 boolean move(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName)
          Move the file or folder specified
protected  String prepareForDownload(String localPath)
           
 boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName)
          Renames a file or folder on the host
 boolean rename(IProgressMonitor monitor, String remoteParent, String oldName, String newName, IHostFile oldFile)
          Renames a file or folder on the host
 void setBufferDownloadSize(int size)
           
 void setBufferUploadSize(int size)
           
protected  void setDataStoreRoot(String root)
           
 void uninitService(IProgressMonitor monitor)
           
 boolean upload(IProgressMonitor monitor, File file, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding)
          Copy a file to the remote file system.
 boolean upload(IProgressMonitor monitor, InputStream inputStream, String remoteParent, String remoteFile, boolean isBinary, String hostEncoding)
          Copy a file to the remote file system.
 
Methods inherited from class org.eclipse.rse.services.dstore.AbstractDStoreService
checkHostJVM, dsQueryCommand, dsQueryCommand, dsStatusCommand, dsStatusCommand, getCommandDescriptor, getDataStore, getMessage, getMinerElement, getMinerElement, getServerMinor, getServerVersion, getStatusMonitor, initMiner, initService, isInitialized, waitForInitialize
 
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.services.IService
getMessage, initService
 

Field Detail

_uploadLogElement

protected org.eclipse.dstore.core.model.DataElement _uploadLogElement

_fileElementMap

protected Map _fileElementMap

_fileTypeRegistry

protected ISystemFileTypes _fileTypeRegistry
Constructor Detail

DStoreFileService

public DStoreFileService(org.eclipse.dstore.core.model.IDataStoreProvider dataStoreProvider,
                         ISystemFileTypes fileTypeRegistry,
                         ISystemMessageProvider msgProvider)
Method Detail

uninitService

public void uninitService(IProgressMonitor monitor)
Specified by:
uninitService in interface IService
Overrides:
uninitService in class AbstractDStoreService

getName

public String getName()
Specified by:
getName in interface IService

getDescription

public String getDescription()
Specified by:
getDescription in interface IService

setBufferUploadSize

public void setBufferUploadSize(int size)

setBufferDownloadSize

public void setBufferDownloadSize(int size)

getBufferUploadSize

protected int getBufferUploadSize()

getBufferDownloadSize

protected int getBufferDownloadSize()

getMinerId

protected String getMinerId()
Specified by:
getMinerId in class AbstractDStoreService

getByteStreamHandlerId

protected String getByteStreamHandlerId()

getDataStoreRoot

protected String getDataStoreRoot()

prepareForDownload

protected String prepareForDownload(String localPath)

setDataStoreRoot

protected void setDataStoreRoot(String root)

findUploadLog

protected org.eclipse.dstore.core.model.DataElement findUploadLog()

getAttributes

protected org.eclipse.dstore.core.model.DataElement getAttributes(String fileNameFilter,
                                                                  boolean showHidden)

upload

public boolean upload(IProgressMonitor monitor,
                      InputStream inputStream,
                      String remoteParent,
                      String remoteFile,
                      boolean isBinary,
                      String hostEncoding)
Description copied from interface: IFileService
Copy a file to the remote file system. The remote target is denoted by a string representing the parent and a string representing the file.

Specified by:
upload in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
inputStream - input stream to transfer
remoteParent - - a string designating the parent folder of the target for this file.
remoteFile - - a string designating the name of the file to be written on the remote system.
isBinary - - indicates whether the file is text or binary
hostEncoding - - the tgt encoding of the file (if text)
Returns:
true if the file was uploaded

upload

public boolean upload(IProgressMonitor monitor,
                      File file,
                      String remoteParent,
                      String remoteFile,
                      boolean isBinary,
                      String srcEncoding,
                      String hostEncoding)
Description copied from interface: IFileService
Copy a file to the remote file system. The remote target is denoted by a string representing the parent and a string representing the file.

Specified by:
upload in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
file - - a real file in the local file system.
remoteParent - - a string designating the parent folder of the target for this file.
remoteFile - - a string designating the name of the file to be written on the remote system.
isBinary - - indicates whether the file is text or binary
srcEncoding - - the src encoding of the file (if text)
hostEncoding - - the tgt encoding of the file (if text)
Returns:
true if the file was uploaded

download

public boolean download(IProgressMonitor monitor,
                        String remoteParent,
                        String remoteFile,
                        File localFile,
                        boolean isBinary,
                        String encoding)
                 throws SystemMessageException
Description copied from interface: IFileService
Copy a file from the remote file system to the local system.

Specified by:
download in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - - a String designating the remote parent.
remoteFile - - a String designating the remote file residing in the parent.
localFile - - The file that is to be written. If the file exists it is overwritten.
isBinary - - indicates whether the file is text on binary
encoding - - the encoding on the host (if text)
Returns:
true if the file was copied from the remote system.
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

getFile

public IHostFile getFile(IProgressMonitor monitor,
                         String remoteParent,
                         String name)
Specified by:
getFile in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent -
name -
Returns:
the host file given the parent path and file name

getSeparator

protected String getSeparator(String parentPath)
Returns what the next part of the path should be, given the current path as parentPath. Returns different separators based on whether the path appears to be a windows, linux, or virtual path. Pass in null to just get the default separator.


convertToHostFile

protected IHostFile convertToHostFile(org.eclipse.dstore.core.model.DataElement element)

convertToHostFiles

protected IHostFile[] convertToHostFiles(org.eclipse.dstore.core.model.DataElement[] elements)

getUserHome

public IHostFile getUserHome()
Specified by:
getUserHome in interface IFileService
Returns:
the String containing the name of the user's home directory on this connection that would be contained in implementations of this service.

createFile

public IHostFile createFile(IProgressMonitor monitor,
                            String remoteParent,
                            String fileName)
                     throws SystemMessageException
Description copied from interface: IFileService
Create a file on the host

Specified by:
createFile in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - the parent directory
fileName - the name of the new file
Returns:
the newly created file
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

createFolder

public IHostFile createFolder(IProgressMonitor monitor,
                              String remoteParent,
                              String folderName)
                       throws SystemMessageException
Description copied from interface: IFileService
Create a folder on the host

Specified by:
createFolder in interface IFileService
Parameters:
monitor - the progress monitor
remoteParent - the parent directory
folderName - the name of the new folder
Returns:
the newly created folder
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

delete

public boolean delete(IProgressMonitor monitor,
                      String remoteParent,
                      String fileName)
               throws SystemMessageException
Description copied from interface: IFileService
Deletes a file or folder on the host

Specified by:
delete in interface IFileService
Parameters:
monitor - the progress monitor
remoteParent - the folder containing the file to delete
fileName - the name of the file or folder to delete
Returns:
true if successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

deleteBatch

public boolean deleteBatch(IProgressMonitor monitor,
                           String[] remoteParents,
                           String[] fileNames)
                    throws SystemMessageException
Description copied from interface: IFileService
Deletes a set of files or folders on the host. Should throw an exception if some files and folders were deleted and others were not due to an exception during the operation. Without an exception thrown in such cases, views may not be refreshed correctly to account for deleted resources.

Specified by:
deleteBatch in interface IFileService
Parameters:
monitor - the progress monitor
remoteParents - the array of folders containing the files to delete
fileNames - the names of the files or folders to delete
Returns:
true iff all deletes are successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

rename

public boolean rename(IProgressMonitor monitor,
                      String remoteParent,
                      String oldName,
                      String newName)
               throws SystemMessageException
Description copied from interface: IFileService
Renames a file or folder on the host

Specified by:
rename in interface IFileService
Parameters:
monitor - the progress monitor
remoteParent - the folder containing the file to rename
oldName - the old name of the file or folder to rename
newName - the new name for the file
Returns:
true if successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

rename

public boolean rename(IProgressMonitor monitor,
                      String remoteParent,
                      String oldName,
                      String newName,
                      IHostFile oldFile)
               throws SystemMessageException
Description copied from interface: IFileService
Renames a file or folder on the host

Specified by:
rename in interface IFileService
Parameters:
monitor - the progress monitor
remoteParent - the folder containing the file to rename
oldName - the old name of the file or folder to rename
newName - the new name for the file
oldFile - the file to update with the change
Returns:
true if successful
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

move

public boolean move(IProgressMonitor monitor,
                    String srcParent,
                    String srcName,
                    String tgtParent,
                    String tgtName)
             throws SystemMessageException
Description copied from interface: IFileService
Move the file or folder specified

Specified by:
move in interface IFileService
Parameters:
monitor - the progress monitor
srcParent - the folder containing the file or folder to move
srcName - the new of the file or folder to move
tgtParent - the destination folder for the move
tgtName - the name of the moved file or folder
Returns:
true if the file was moved
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

isSpecialChar

protected boolean isSpecialChar(char c)
Checks whether the given character is a special character in the shell. A special character is '$', '`', '"' and '\'.

Parameters:
c - the character to check.
Returns:
true if the character is a special character, false otherwise.

copy

public boolean copy(IProgressMonitor monitor,
                    String srcParent,
                    String srcName,
                    String tgtParent,
                    String tgtName)
             throws SystemMessageException
Description copied from interface: IFileService
Copy the file or folder to the specified destination

Specified by:
copy in interface IFileService
Parameters:
monitor - the progress monitor
srcParent - the folder containing the file or folder to copy
srcName - the new of the file or folder to copy
tgtParent - the destination folder for the copy
tgtName - the name of the copied file or folder
Returns:
true if the file was copied successfully
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

copyBatch

public boolean copyBatch(IProgressMonitor monitor,
                         String[] srcParents,
                         String[] srcNames,
                         String tgtParent)
                  throws SystemMessageException
Description copied from interface: IFileService
Copy a set of files or folders to the specified destination

Specified by:
copyBatch in interface IFileService
Parameters:
monitor - the progress monitor
srcParents - the folders containing each file or folder to copy
srcNames - the names of the files or folders to copy
tgtParent - the destination folder for the copy
Returns:
true if all files were copied
Throws:
SystemMessageException - if an error occurs. Typically this would be one of those in the RemoteFileException family.

getRoots

public IHostFile[] getRoots(IProgressMonitor monitor)
Specified by:
getRoots in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation Return the list of roots for this system
Returns:
the list of host files.

getFolders

public IHostFile[] getFolders(IProgressMonitor monitor,
                              String remoteParent,
                              String fileFilter)
Specified by:
getFolders in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - - the name of the parent directory on the remote file system from which to retrieve the child list.
fileFilter - - a string that can be used to filter the children. Only those files matching the filter make it into the list. The interface does not dictate where the filtering occurs.
Returns:
the list of host files.

getFiles

public IHostFile[] getFiles(IProgressMonitor monitor,
                            String remoteParent,
                            String fileFilter)
Specified by:
getFiles in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - - the name of the parent directory on the remote file system from which to retrieve the child list.
fileFilter - - a string that can be used to filter the children. Only those files matching the filter make it into the list. The interface does not dictate where the filtering occurs.
Returns:
the list of host files.

getFilesAndFolders

public IHostFile[] getFilesAndFolders(IProgressMonitor monitor,
                                      String remoteParent,
                                      String fileFilter)
Specified by:
getFilesAndFolders in interface IFileService
Parameters:
monitor - the monitor for this potentially long running operation
remoteParent - - the name of the parent directory on the remote file system from which to retrieve the child list.
fileFilter - - a string that can be used to filter the children. Only those files matching the filter make it into the list. The interface does not dictate where the filtering occurs.
Returns:
the list of host files.

getElementFor

protected org.eclipse.dstore.core.model.DataElement getElementFor(String path)

fetch

protected IHostFile[] fetch(IProgressMonitor monitor,
                            String remoteParent,
                            String fileFilter,
                            String queryType)

isCaseSensitive

public boolean isCaseSensitive()
Description copied from interface: IFileService
Indicates whether the file system is case sensitive

Specified by:
isCaseSensitive in interface IFileService
Returns:
true if the file system has case sensitive file names

RSE
Release 1.0

Copyright (c) IBM Corporation and others 2000, 2006. All Rights Reserved.