Class RemoteFileSystem

java.lang.Object
ghidra.framework.store.remote.RemoteFileSystem
All Implemented Interfaces:
RemoteAdapterListener, FileSystem

public class RemoteFileSystem extends Object implements FileSystem, RemoteAdapterListener
RemoteFileSystem provides access to versioned FolderItem's which exist within a Repository-based directory structure. FolderItem caching is provided by the remote implementation which is intended to be shared across multiple clients.

FolderItem's must be checked-out to create new versions.

FileSystemListener's will be notified of all changes made within the Repository.

  • Constructor Details

    • RemoteFileSystem

      public RemoteFileSystem(RepositoryAdapter repository)
      Construct a new remote file system which corresponds to a remote repository.
      Parameters:
      repository - remote Repository
  • Method Details

    • getUserName

      public String getUserName()
      Description copied from interface: FileSystem
      Get user name associated with this filesystem. In the case of a remote filesystem this will correspond to the name used during login/authentication. A null value may be returned if user name unknown.
      Specified by:
      getUserName in interface FileSystem
    • addFileSystemListener

      public void addFileSystemListener(FileSystemListener listener)
      Description copied from interface: FileSystem
      Adds the given listener to be notified of file system changes.
      Specified by:
      addFileSystemListener in interface FileSystem
      Parameters:
      listener - the listener to be added.
    • removeFileSystemListener

      public void removeFileSystemListener(FileSystemListener listener)
      Description copied from interface: FileSystem
      Removes the listener from being notified of file system changes.
      Specified by:
      removeFileSystemListener in interface FileSystem
      Parameters:
      listener -
    • isVersioned

      public boolean isVersioned()
      Description copied from interface: FileSystem
      Returns true if the file-system requires check-outs when modifying folder items.
      Specified by:
      isVersioned in interface FileSystem
    • isOnline

      public boolean isOnline()
      Description copied from interface: FileSystem
      Returns true if file-system is on-line.
      Specified by:
      isOnline in interface FileSystem
    • isReadOnly

      public boolean isReadOnly() throws IOException
      Description copied from interface: FileSystem
      Returns true if file-system is read-only.
      Specified by:
      isReadOnly in interface FileSystem
      Throws:
      IOException
    • isShared

      public boolean isShared()
      Description copied from interface: FileSystem
      Returns true if this file system is shared
      Specified by:
      isShared in interface FileSystem
    • getItemCount

      public int getItemCount() throws IOException, UnsupportedOperationException
      Description copied from interface: FileSystem
      Returns the number of folder items contained within this file-system.
      Specified by:
      getItemCount in interface FileSystem
      Throws:
      IOException
      UnsupportedOperationException - if file-system does not support this operation
    • getItemNames

      public String[] getItemNames(String folderPath) throws IOException
      Description copied from interface: FileSystem
      Returns a list of the folder item names contained in the given folder.
      Specified by:
      getItemNames in interface FileSystem
      Parameters:
      folderPath - the path of the folder.
      Returns:
      a list of folder item names.
      Throws:
      IOException
    • getItems

      public FolderItem[] getItems(String folderPath) throws IOException
      Description copied from interface: FileSystem
      Returns a list of the folder items contained in the given folder.
      Specified by:
      getItems in interface FileSystem
      Parameters:
      folderPath - the path of the folder.
      Returns:
      a list of folder items.
      Throws:
      IOException
    • getItem

      public FolderItem getItem(String folderPath, String name) throws IOException
      Description copied from interface: FileSystem
      Returns the FolderItem in the given folder with the given name
      Specified by:
      getItem in interface FileSystem
      Parameters:
      folderPath - the folder path containing the item.
      name - the name of the item.
      Returns:
      the FolderItem with the given folderPath and name, or null if it doesn't exist.
      Throws:
      IOException - if IO error occurs.
    • getItem

      Description copied from interface: FileSystem
      Returns the FolderItem specified by its unique File-ID
      Specified by:
      getItem in interface FileSystem
      Parameters:
      fileID - the items unique file ID
      Returns:
      the FolderItem with the given folderPath and name, or null if it doesn't exist.
      Throws:
      IOException - if IO error occurs.
      UnsupportedOperationException - if file-system does not support this operation
    • getFolderNames

      public String[] getFolderNames(String parentPath) throws IOException
      Description copied from interface: FileSystem
      Return a list of subfolders (by name) that are stored within the specified folder path.
      Specified by:
      getFolderNames in interface FileSystem
      Throws:
      IOException - if IO error occurs.
    • createFolder

      public void createFolder(String parentPath, String folderName)
      Description copied from interface: FileSystem
      Creates a new subfolder within the specified parent folder.
      Specified by:
      createFolder in interface FileSystem
      Parameters:
      parentPath - folder path of parent
      folderName - name of new subfolder
    • createDatabase

      public ManagedBufferFile createDatabase(String parentPath, String name, String fileID, String contentType, int bufferSize, String user, String projectPath) throws InvalidNameException, IOException
      Description copied from interface: FileSystem
      Create a new empty database item within the specified parent folder. If this is a versioned file-system, the associated item is checked-out. The resulting checkoutId can be obtained from the returned buffer file.
      Specified by:
      createDatabase in interface FileSystem
      Parameters:
      parentPath - folder path of parent
      name - new database name
      fileID - file ID to be associated with new database or null
      contentType - application defined content type
      bufferSize - buffer size. If copying an existing BufferFile, the buffer size must be the same as the source file.
      user - name of user creating item (required for versioned item)
      projectPath - path of project in which database is checked-out (required for versioned item)
      Returns:
      an empty BufferFile open for read-write.
      Throws:
      InvalidNameException - if the name does not have all alphanumerics
      IOException - if an IO error occurs.
    • createDatabase

      public DatabaseItem createDatabase(String parentPath, String name, String fileID, BufferFile bufferFile, String comment, String contentType, boolean resetDatabaseId, TaskMonitor monitor, String user) throws InvalidNameException, IOException, CancelledException
      Description copied from interface: FileSystem
      Create a new database item within the specified parent folder using the contents of the specified BufferFile.
      Specified by:
      createDatabase in interface FileSystem
      Parameters:
      parentPath - folder path of parent
      name - new database name
      fileID - file ID to be associated with new database or null
      bufferFile - data source
      comment - version comment (used for versioned file system only)
      contentType - application defined content type
      resetDatabaseId - if true database ID will be reset for new Database
      monitor - allows the database copy to be monitored and cancelled.
      user - name of user creating item (required for versioned item)
      Returns:
      new DatabaseItem
      Throws:
      InvalidNameException - if the name does not have all alphanumerics
      IOException - if an IO error occurs.
      CancelledException - if cancelled by monitor
    • createDataFile

      public DataFileItem createDataFile(String parentPath, String name, InputStream istream, String comment, String contentType, TaskMonitor monitor) throws InvalidNameException, IOException, CancelledException
      Description copied from interface: FileSystem
      Creates a new empty data file within the specified parent folder.
      Specified by:
      createDataFile in interface FileSystem
      Parameters:
      parentPath - folder path of parent
      name - new data file name
      istream - source data
      comment - version comment (used for versioned file system only)
      contentType - application defined content type
      monitor - progress monitor (used for cancel support, progress not used since length of input stream is unknown)
      Returns:
      new data file
      Throws:
      InvalidNameException - if the name has illegal characters. all alphanumerics
      IOException - if an IO error occurs.
      CancelledException - if cancelled by monitor
    • createFile

      public FolderItem createFile(String parentPath, String name, File packedFile, TaskMonitor monitor, String user) throws InvalidNameException, IOException, CancelledException
      Description copied from interface: FileSystem
      Creates a new file item from a packed file. The content/item type must be determined from the input stream.
      Specified by:
      createFile in interface FileSystem
      Parameters:
      parentPath - folder path of parent
      name - new data file name
      packedFile - packed file data
      monitor - progress monitor (used for cancel support, progress not used since length of input stream is unknown)
      user - name of user creating item (required for versioned item)
      Returns:
      new item
      Throws:
      InvalidNameException - if the name has illegal characters. all alphanumerics
      IOException - if an IO error occurs.
      CancelledException - if cancelled by monitor
    • deleteFolder

      public void deleteFolder(String folderPath) throws IOException
      Description copied from interface: FileSystem
      Delete the specified folder.
      Specified by:
      deleteFolder in interface FileSystem
      Parameters:
      folderPath - path of folder to be deleted
      Throws:
      IOException - if error occurred during delete.
    • moveFolder

      public void moveFolder(String parentPath, String folderName, String newParentPath) throws InvalidNameException, IOException
      Description copied from interface: FileSystem
      Move the specified folder to the path specified by newFolderPath. The moved folder must not be an ancestor of the new Parent.
      Specified by:
      moveFolder in interface FileSystem
      Parameters:
      parentPath - path of parent folder that the moving folder currently resides in.
      folderName - name of the folder within the parentPath to be moved.
      newParentPath - path to where the folder is to be moved.
      Throws:
      InvalidNameException - if the new FolderPath contains an illegal file name.
      IOException - if an IO error occurs.
    • renameFolder

      public void renameFolder(String parentPath, String folderName, String newFolderName) throws InvalidNameException, IOException
      Description copied from interface: FileSystem
      Renames the specified folder to a new name.
      Specified by:
      renameFolder in interface FileSystem
      Parameters:
      parentPath - the parent folder of the folder to be renamed.
      folderName - the current name of the folder to be renamed.
      newFolderName - the name the folder to be renamed to.
      Throws:
      InvalidNameException - if the new FolderName contains an illegal file name.
      IOException - if an IO error occurs.
    • moveItem

      public void moveItem(String parentPath, String name, String newParentPath, String newName) throws InvalidNameException, IOException
      Description copied from interface: FileSystem
      Moves the specified item to a new folder.
      Specified by:
      moveItem in interface FileSystem
      Parameters:
      parentPath - path of folder containing the item.
      name - name of the item to be moved.
      newParentPath - path of folder where item is to be moved.
      Throws:
      InvalidNameException - if the newName is invalid
      IOException - if an IO error occurs.
    • folderExists

      public boolean folderExists(String folderPath) throws IOException
      Description copied from interface: FileSystem
      Returns true if the folder specified by the path exists.
      Specified by:
      folderExists in interface FileSystem
      Parameters:
      folderPath - the name of the folder to check for existence.
      Returns:
      true if the folder exists.
      Throws:
      IOException - if an IO error occurs.
    • fileExists

      public boolean fileExists(String folderPath, String itemName) throws IOException
      Description copied from interface: FileSystem
      Returns true if the file exists
      Specified by:
      fileExists in interface FileSystem
      Parameters:
      folderPath - the folderPath of the folder that may contain the file.
      itemName - the name of the file to check for existence.
      Throws:
      IOException - if an IO error occurs.
    • connectionStateChanged

      public void connectionStateChanged(Object adapter)
      Description copied from interface: RemoteAdapterListener
      Callback notification indicating the remote object connection state has changed.
      Specified by:
      connectionStateChanged in interface RemoteAdapterListener
      Parameters:
      adapter - remote interface adapter (e.g., RepositoryServerAdapter).
    • dispose

      public void dispose()
      Description copied from interface: FileSystem
      Cleanup and release resources
      Specified by:
      dispose in interface FileSystem