Package ghidra.framework.store.remote
Class RemoteFileSystem
- java.lang.Object
-
- ghidra.framework.store.remote.RemoteFileSystem
-
- All Implemented Interfaces:
RemoteAdapterListener,FileSystem
public class RemoteFileSystem extends java.lang.Object implements FileSystem, RemoteAdapterListener
RemoteFileSystemprovides 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.
-
-
Field Summary
-
Fields inherited from interface ghidra.framework.store.FileSystem
SEPARATOR, SEPARATOR_CHAR
-
-
Constructor Summary
Constructors Constructor Description RemoteFileSystem(RepositoryAdapter repository)Construct a new remote file system which corresponds to a remote repository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFileSystemListener(FileSystemListener listener)Adds the given listener to be notified of file system changes.voidconnectionStateChanged(java.lang.Object adapter)Callback notification indicating the remote object connection state has changed.DatabaseItemcreateDatabase(java.lang.String parentPath, java.lang.String name, java.lang.String fileID, BufferFile bufferFile, java.lang.String comment, java.lang.String contentType, boolean resetDatabaseId, TaskMonitor monitor, java.lang.String user)Create a new database item within the specified parent folder using the contents of the specified BufferFile.ManagedBufferFilecreateDatabase(java.lang.String parentPath, java.lang.String name, java.lang.String fileID, java.lang.String contentType, int bufferSize, java.lang.String user, java.lang.String projectPath)Create a new empty database item within the specified parent folder.DataFileItemcreateDataFile(java.lang.String parentPath, java.lang.String name, java.io.InputStream istream, java.lang.String comment, java.lang.String contentType, TaskMonitor monitor)Creates a new empty data file within the specified parent folder.FolderItemcreateFile(java.lang.String parentPath, java.lang.String name, java.io.File packedFile, TaskMonitor monitor, java.lang.String user)Creates a new file item from a packed file.voidcreateFolder(java.lang.String parentPath, java.lang.String folderName)Creates a new subfolder within the specified parent folder.voiddeleteFolder(java.lang.String folderPath)Delete the specified folder.voiddispose()Cleanup & release resourcesbooleanfileExists(java.lang.String folderPath, java.lang.String itemName)Returns true if the file existsbooleanfolderExists(java.lang.String folderPath)Returns true if the folder specified by the path exists.java.lang.String[]getFolderNames(java.lang.String parentPath)Return a list of subfolders (by name) that are stored within the specified folder path.FolderItemgetItem(java.lang.String fileID)Returns the FolderItem specified by its unique File-IDFolderItemgetItem(java.lang.String folderPath, java.lang.String name)Returns the FolderItem in the given folder with the given nameintgetItemCount()Returns the number of folder items contained within this file-system.java.lang.String[]getItemNames(java.lang.String folderPath)Returns a list of the folder item names contained in the given folder.java.lang.StringgetUserName()Get user name associated with this filesystem.booleanisOnline()Returns true if file-system is on-line.booleanisReadOnly()Returns true if file-system is read-only.booleanisShared()Returns true if this file system is sharedbooleanisVersioned()Returns true if the file-system requires check-outs when modifying folder items.voidmoveFolder(java.lang.String parentPath, java.lang.String folderName, java.lang.String newParentPath)Move the specified folder to the path specified by newFolderPath.voidmoveItem(java.lang.String parentPath, java.lang.String name, java.lang.String newParentPath, java.lang.String newName)Moves the specified item to a new folder.voidremoveFileSystemListener(FileSystemListener listener)Removes the listener from being notified of file system changes.voidrenameFolder(java.lang.String parentPath, java.lang.String folderName, java.lang.String newFolderName)Renames the specified folder to a new name.
-
-
-
Constructor Detail
-
RemoteFileSystem
public RemoteFileSystem(RepositoryAdapter repository)
Construct a new remote file system which corresponds to a remote repository.- Parameters:
repository- remote Repository- Throws:
java.io.IOException
-
-
Method Detail
-
getUserName
public java.lang.String getUserName()
Description copied from interface:FileSystemGet 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:
getUserNamein interfaceFileSystem
-
addFileSystemListener
public void addFileSystemListener(FileSystemListener listener)
Description copied from interface:FileSystemAdds the given listener to be notified of file system changes.- Specified by:
addFileSystemListenerin interfaceFileSystem- Parameters:
listener- the listener to be added.
-
removeFileSystemListener
public void removeFileSystemListener(FileSystemListener listener)
Description copied from interface:FileSystemRemoves the listener from being notified of file system changes.- Specified by:
removeFileSystemListenerin interfaceFileSystem
-
isVersioned
public boolean isVersioned()
Description copied from interface:FileSystemReturns true if the file-system requires check-outs when modifying folder items.- Specified by:
isVersionedin interfaceFileSystem
-
isOnline
public boolean isOnline()
Description copied from interface:FileSystemReturns true if file-system is on-line.- Specified by:
isOnlinein interfaceFileSystem
-
isReadOnly
public boolean isReadOnly() throws java.io.IOExceptionDescription copied from interface:FileSystemReturns true if file-system is read-only.- Specified by:
isReadOnlyin interfaceFileSystem- Throws:
java.io.IOException
-
isShared
public boolean isShared()
Description copied from interface:FileSystemReturns true if this file system is shared- Specified by:
isSharedin interfaceFileSystem
-
getItemCount
public int getItemCount() throws java.io.IOException, java.lang.UnsupportedOperationExceptionDescription copied from interface:FileSystemReturns the number of folder items contained within this file-system.- Specified by:
getItemCountin interfaceFileSystem- Throws:
java.io.IOExceptionjava.lang.UnsupportedOperationException- if file-system does not support this operation
-
getItemNames
public java.lang.String[] getItemNames(java.lang.String folderPath) throws java.io.IOExceptionDescription copied from interface:FileSystemReturns a list of the folder item names contained in the given folder.- Specified by:
getItemNamesin interfaceFileSystem- Parameters:
folderPath- the path of the folder.- Returns:
- a list of folder item names.
- Throws:
java.io.IOException
-
getItem
public FolderItem getItem(java.lang.String folderPath, java.lang.String name) throws java.io.IOException
Description copied from interface:FileSystemReturns the FolderItem in the given folder with the given name- Specified by:
getItemin interfaceFileSystem- 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:
java.io.IOException- if IO error occurs.
-
getItem
public FolderItem getItem(java.lang.String fileID) throws java.io.IOException, java.lang.UnsupportedOperationException
Description copied from interface:FileSystemReturns the FolderItem specified by its unique File-ID- Specified by:
getItemin interfaceFileSystem- Parameters:
fileID- the items unique file ID- Returns:
- the FolderItem with the given folderPath and name, or null if it doesn't exist.
- Throws:
java.io.IOException- if IO error occurs.java.lang.UnsupportedOperationException- if file-system does not support this operation
-
getFolderNames
public java.lang.String[] getFolderNames(java.lang.String parentPath) throws java.io.IOExceptionDescription copied from interface:FileSystemReturn a list of subfolders (by name) that are stored within the specified folder path.- Specified by:
getFolderNamesin interfaceFileSystem- Throws:
java.io.FileNotFoundException- if folder path does not exist.java.io.IOException- if IO error occurs.
-
createFolder
public void createFolder(java.lang.String parentPath, java.lang.String folderName)Description copied from interface:FileSystemCreates a new subfolder within the specified parent folder.- Specified by:
createFolderin interfaceFileSystem- Parameters:
parentPath- folder path of parentfolderName- name of new subfolder
-
createDatabase
public ManagedBufferFile createDatabase(java.lang.String parentPath, java.lang.String name, java.lang.String fileID, java.lang.String contentType, int bufferSize, java.lang.String user, java.lang.String projectPath) throws InvalidNameException, java.io.IOException
Description copied from interface:FileSystemCreate 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:
createDatabasein interfaceFileSystem- Parameters:
parentPath- folder path of parentname- new database namefileID- file ID to be associated with new database or nullcontentType- application defined content typebufferSize- 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 alphanumericsjava.io.FileNotFoundException- thrown if parent folder does not exist.DuplicateFileException- if a folder item exists with this namejava.io.IOException- if an IO error occurs.
-
createDatabase
public DatabaseItem createDatabase(java.lang.String parentPath, java.lang.String name, java.lang.String fileID, BufferFile bufferFile, java.lang.String comment, java.lang.String contentType, boolean resetDatabaseId, TaskMonitor monitor, java.lang.String user) throws InvalidNameException, java.io.IOException, CancelledException
Description copied from interface:FileSystemCreate a new database item within the specified parent folder using the contents of the specified BufferFile.- Specified by:
createDatabasein interfaceFileSystem- Parameters:
parentPath- folder path of parentname- new database namefileID- file ID to be associated with new database or nullbufferFile- data sourcecomment- version comment (used for versioned file system only)contentType- application defined content typeresetDatabaseId- if true database ID will be reset for new Databasemonitor- 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 alphanumericsjava.io.FileNotFoundException- thrown if parent folder does not exist.DuplicateFileException- if a folder item exists with this namejava.io.IOException- if an IO error occurs.CancelledException- if cancelled by monitor
-
createDataFile
public DataFileItem createDataFile(java.lang.String parentPath, java.lang.String name, java.io.InputStream istream, java.lang.String comment, java.lang.String contentType, TaskMonitor monitor) throws InvalidNameException, java.io.IOException, CancelledException
Description copied from interface:FileSystemCreates a new empty data file within the specified parent folder.- Specified by:
createDataFilein interfaceFileSystem- Parameters:
parentPath- folder path of parentname- new data file namecomment- version comment (used for versioned file system only)contentType- application defined content typemonitor- 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 alphanumericsDuplicateFileException- Thrown if a folderItem with that name already exists.java.io.IOException- if an IO error occurs.CancelledException- if cancelled by monitor
-
createFile
public FolderItem createFile(java.lang.String parentPath, java.lang.String name, java.io.File packedFile, TaskMonitor monitor, java.lang.String user) throws InvalidNameException, java.io.IOException, CancelledException
Description copied from interface:FileSystemCreates a new file item from a packed file. The content/item type must be determined from the input stream.- Specified by:
createFilein interfaceFileSystem- Parameters:
parentPath- folder path of parentname- new data file namepackedFile- packed file datamonitor- 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 alphanumericsjava.io.IOException- if an IO error occurs.CancelledException- if cancelled by monitor
-
deleteFolder
public void deleteFolder(java.lang.String folderPath) throws java.io.IOExceptionDescription copied from interface:FileSystemDelete the specified folder.- Specified by:
deleteFolderin interfaceFileSystem- Parameters:
folderPath- path of folder to be deleted- Throws:
FolderNotEmptyException- Thrown if the folder is not empty.java.io.FileNotFoundException- if there is no folder with the given path name.java.io.IOException- if error occured during delete.
-
moveFolder
public void moveFolder(java.lang.String parentPath, java.lang.String folderName, java.lang.String newParentPath) throws InvalidNameException, java.io.IOExceptionDescription copied from interface:FileSystemMove the specified folder to the path specified by newFolderPath. The moved folder must not be an ancestor of the new Parent.- Specified by:
moveFolderin interfaceFileSystem- 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.java.io.FileNotFoundException- if the moved folder does not exist.DuplicateFileException- if folder with the same name exists within the new parent folderFileInUseException- if any file within this folder or its decendents are in-use or checked-outjava.io.IOException- if an IO error occurs.
-
renameFolder
public void renameFolder(java.lang.String parentPath, java.lang.String folderName, java.lang.String newFolderName) throws InvalidNameException, java.io.IOExceptionDescription copied from interface:FileSystemRenames the specified folder to a new name.- Specified by:
renameFolderin interfaceFileSystem- 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.java.io.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 decendents are in-use or checked-outjava.io.IOException- if an IO error occurs.
-
moveItem
public void moveItem(java.lang.String parentPath, java.lang.String name, java.lang.String newParentPath, java.lang.String newName) throws InvalidNameException, java.io.IOExceptionDescription copied from interface:FileSystemMoves the specified item to a new folder.- Specified by:
moveItemin interfaceFileSystem- 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 invalidjava.io.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-outjava.io.IOException- if an IO error occurs.
-
folderExists
public boolean folderExists(java.lang.String folderPath) throws java.io.IOExceptionDescription copied from interface:FileSystemReturns true if the folder specified by the path exists.- Specified by:
folderExistsin interfaceFileSystem- Parameters:
folderPath- the name of the folder to check for existence.- Returns:
- true if the folder exists.
- Throws:
java.io.IOException- if an IO error occurs.
-
fileExists
public boolean fileExists(java.lang.String folderPath, java.lang.String itemName) throws java.io.IOExceptionDescription copied from interface:FileSystemReturns true if the file exists- Specified by:
fileExistsin interfaceFileSystem- Parameters:
folderPath- the folderPath of the folder that may contain the file.itemName- the name of the file to check for existence.- Throws:
java.io.IOException- if an IO error occurs.
-
connectionStateChanged
public void connectionStateChanged(java.lang.Object adapter)
Description copied from interface:RemoteAdapterListenerCallback notification indicating the remote object connection state has changed.- Specified by:
connectionStateChangedin interfaceRemoteAdapterListener- Parameters:
adapter- remote interface adapter (e.g., RepositoryServerAdapter).
-
dispose
public void dispose()
Description copied from interface:FileSystemCleanup & release resources- Specified by:
disposein interfaceFileSystem
-
-