Interface FileSystem

All Known Implementing Classes:
IndexedLocalFileSystem, IndexedV1LocalFileSystem, LocalFileSystem, MangledLocalFileSystem, RemoteFileSystem

public interface FileSystem
FileSystem provides a hierarchical view and management of a set of files and folders.
  • Field Details

    • SEPARATOR_CHAR

      static final char SEPARATOR_CHAR
      Character used to separate folder and item names within a path string.
      See Also:
    • SEPARATOR

      static final String SEPARATOR
  • Method Details

    • getUserName

      String getUserName()
      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.
      Returns:
      user name used to authenticate or null if not-applicable
    • isVersioned

      boolean isVersioned()
      Returns true if the file-system requires check-outs when modifying folder items..
      Returns:
      true if the file-system requires check-outs when modifying folder items.
    • isOnline

      boolean isOnline()
      Returns true if file-system is on-line..
      Returns:
      true if file-system is on-line.
    • isReadOnly

      boolean isReadOnly() throws IOException
      Returns true if file-system is read-only..
      Returns:
      true if file-system is read-only.
      Throws:
      IOException - if IO error occurs
    • getItemCount

      int getItemCount() throws IOException, UnsupportedOperationException
      Returns the number of folder items contained within this file-system..
      Returns:
      the number of folder items contained within this file-system.
      Throws:
      IOException - if an IO error occurs
      UnsupportedOperationException - if file-system does not support this operation
    • getItemNames

      String[] getItemNames(String folderPath) throws IOException
      Returns a list of the folder item names contained in the given folder..
      Parameters:
      folderPath - the path of the folder.
      Returns:
      a list of the folder item names contained in the given folder.
      Throws:
      IOException - if an IO error occurs
    • getItems

      FolderItem[] getItems(String folderPath) throws IOException
      Returns a list of the folder items contained in the given folder.
      Parameters:
      folderPath - the path of the folder.
      Returns:
      a list of folder items. Null items may exist if index contained item name while storage was not found. An UnknownFolderItem may be returned if unsupported item storage encountered.
      Throws:
      IOException - if an IO error occurs
    • getItem

      FolderItem getItem(String folderPath, String name) throws IOException
      Returns the FolderItem in the given folder with the given name
      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

      Returns the FolderItem specified by its unique File-ID
      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

      String[] getFolderNames(String folderPath) throws IOException
      Return a list of subfolders (by name) that are stored within the specified folder path.
      Parameters:
      folderPath - folder path
      Returns:
      subfolders names
      Throws:
      FileNotFoundException - if folder path does not exist.
      IOException - if IO error occurs.
    • createFolder

      void createFolder(String parentPath, String folderName) throws InvalidNameException, IOException
      Creates a new subfolder within the specified parent folder.
      Parameters:
      parentPath - folder path of parent
      folderName - name of new subfolder
      Throws:
      DuplicateFileException - if a folder exists with this name
      InvalidNameException - if the name does not have all alphanumerics
      IOException - thrown if an IO error occurs.
    • isSupportedItemType

      boolean isSupportedItemType(FolderItem folderItem)
      Determine if the specified folder item is supported by this filesystem's interface and storage. This method primarily exists to determine if a remote server can support the specified content. This can come into play as new storage formats are added to a LocalFileSystem but may not be supported by a connected RemoteFileSystem.
      Parameters:
      folderItem - folder item
      Returns:
      true if folder item storage is supported
    • createDatabase

      DatabaseItem createDatabase(String parentPath, String name, String fileID, BufferFile bufferFile, String comment, String contentType, boolean resetDatabaseId, TaskMonitor monitor, String user) throws InvalidNameException, IOException, CancelledException
      Create a new database item within the specified parent folder using the contents of the specified BufferFile.
      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:
      FileNotFoundException - thrown if parent folder does not exist.
      DuplicateFileException - if a folder item exists with this name
      InvalidNameException - if the name does not have all alphanumerics
      IOException - if an IO error occurs.
      CancelledException - if cancelled by monitor
    • createDatabase

      ManagedBufferFile createDatabase(String parentPath, String name, String fileID, String contentType, int bufferSize, String user, String projectPath) throws InvalidNameException, IOException
      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.
      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:
      FileNotFoundException - thrown if parent folder does not exist.
      DuplicateFileException - if a folder item exists with this name
      InvalidNameException - if the name has illegal characters.
      IOException - if an IO error occurs.
    • createDataFile

      DataFileItem createDataFile(String parentPath, String name, InputStream istream, String comment, String contentType, TaskMonitor monitor) throws InvalidNameException, IOException, CancelledException
      Creates a new empty data file within the specified parent folder.
      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:
      DuplicateFileException - Thrown if a folderItem with that name already exists.
      InvalidNameException - if the name has illegal characters.
      IOException - if an IO error occurs.
      CancelledException - if cancelled by monitor
    • createTextDataItem

      TextDataItem createTextDataItem(String parentPath, String name, String fileID, String contentType, String textData, String comment, String user) throws InvalidNameException, IOException
      Creates a new text data file within the specified parent folder.
      Parameters:
      parentPath - folder path of parent
      name - new data file name
      fileID - file ID to be associated with new file or null
      contentType - application defined content type
      textData - text data (required)
      comment - file comment (may be null, only used if versioning is enabled)
      user - name of user creating item (required for local versioned item)
      Returns:
      new data file
      Throws:
      DuplicateFileException - Thrown if a folderItem with that name already exists.
      InvalidNameException - if the name has illegal characters.
      IOException - if an IO error occurs.
    • createFile

      FolderItem createFile(String parentPath, String name, File packedFile, TaskMonitor monitor, String user) throws InvalidNameException, IOException, CancelledException
      Creates a new file item from a packed file. The content/item type must be determined from the input stream.
      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

      void deleteFolder(String folderPath) throws IOException
      Delete the specified folder.
      Parameters:
      folderPath - path of folder to be deleted
      Throws:
      FolderNotEmptyException - Thrown if the folder is not empty.
      FileNotFoundException - if there is no folder with the given path name.
      IOException - if error occurred during delete.
    • moveFolder

      void moveFolder(String parentPath, String folderName, String newParentPath) throws InvalidNameException, IOException
      Move the specified folder to the path specified by newFolderPath. The moved folder must not be an ancestor of the new Parent.
      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:
      FileNotFoundException - if the moved folder does not exist.
      DuplicateFileException - if folder with the same name exists within the new parent folder
      FileInUseException - if any file within this folder or its descendants are in-use or checked-out
      IOException - if an IO error occurs.
      InvalidNameException - if the new FolderPath contains an illegal file name.
      IllegalArgumentException - if new Parent is invalid.
    • renameFolder

      void renameFolder(String parentPath, String folderName, String newFolderName) throws InvalidNameException, IOException
      Renames the specified folder to a new name.
      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:
      FileNotFoundException - if the folder to be renamed does not exist.
      DuplicateFileException - if folder with the new name already exists.
      FileInUseException - if any file within this folder or its descendants are in-use or checked-out
      IOException - if an IO error occurs.
      InvalidNameException - if the new FolderName contains an illegal file name.
    • moveItem

      void moveItem(String folderPath, String name, String newFolderPath, String newName) throws IOException, InvalidNameException
      Moves the specified item to a new folder.
      Parameters:
      folderPath - path of folder containing the item.
      name - name of the item to be moved.
      newFolderPath - path of folder where item is to be moved to.
      newName - new item name to be applied
      Throws:
      FileNotFoundException - if the item does not exist.
      DuplicateFileException - if item with the same name exists within the new parent folder.
      FileInUseException - if the item is in-use or checked-out
      IOException - if an IO error occurs.
      InvalidNameException - if the newName is invalid
    • addFileSystemListener

      void addFileSystemListener(FileSystemListener listener)
      Adds a file system listener to be notified of file system changes.
      Parameters:
      listener - the listener to be added.
    • removeFileSystemListener

      void removeFileSystemListener(FileSystemListener listener)
      Removes a file system listener from being notified of file system changes.
      Parameters:
      listener - file system listener
    • folderExists

      boolean folderExists(String folderPath) throws IOException
      Returns true if the folder specified by the path exists.
      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

      boolean fileExists(String folderPath, String name) throws IOException
      Returns true if the file exists.
      Parameters:
      folderPath - the folderPath of the folder that may contain the file.
      name - the name of the file to check for existence.
      Returns:
      true if the file exists
      Throws:
      IOException - if an IO error occurs.
    • isShared

      boolean isShared()
      Returns true if this file system is shared.
      Returns:
      true if this file system is shared
    • dispose

      void dispose()
      Cleanup and release resources
    • normalizePath

      static String normalizePath(String path) throws IllegalArgumentException
      Normalize an absolute path, removing all "." and ".." use.

      NOTE: This method does not consider possible linked folder traversal which may get ignored when flattening/simplifying path.

      Parameters:
      path - absolute filesystem path which may contain "." or ".." path elements.
      Returns:
      normalized path
      Throws:
      IllegalArgumentException - if an absolute path starting with SEPARATOR was not specified or an illegal path was specified.