Package ghidra.framework.client
Class RepositoryAdapter
- java.lang.Object
-
- ghidra.framework.client.RepositoryAdapter
-
- All Implemented Interfaces:
RemoteAdapterListener
public class RepositoryAdapter extends java.lang.Object implements RemoteAdapterListener
RepositoryAdapterprovides a persistent wrapper for a remote RepositoryHandle which may become invalid if the remote connection were to fail. Connection recovery is provided by any method call which must communicate with the server.
-
-
Constructor Summary
Constructors Constructor Description RepositoryAdapter(RepositoryServerAdapter serverAdapter, java.lang.String name)Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(RemoteAdapterListener listener)Add a listener to this remote adapterbooleananonymousAccessAllowed()ItemCheckoutStatuscheckout(java.lang.String folderPath, java.lang.String itemName, CheckoutType checkoutType, java.lang.String projectPath)voidconnect()Attempt to connect to the server.voidconnectionStateChanged(java.lang.Object adapter)Notification callback when server connection state changes.ManagedBufferFileAdaptercreateDatabase(java.lang.String parentPath, java.lang.String itemName, int bufferSize, java.lang.String contentType, java.lang.String fileID, java.lang.String projectPath)voidcreateDataFile(java.lang.String parentPath, java.lang.String itemName)voiddeleteItem(java.lang.String parentPath, java.lang.String itemName, int version)voiddisconnect()booleanfileExists(java.lang.String folderPath, java.lang.String itemName)booleanfolderExists(java.lang.String folderPath)ItemCheckoutStatusgetCheckout(java.lang.String parentPath, java.lang.String itemName, long checkoutId)ItemCheckoutStatus[]getCheckouts(java.lang.String parentPath, java.lang.String itemName)RepositoryItemgetItem(java.lang.String fileID)RepositoryItemgetItem(java.lang.String folderPath, java.lang.String itemName)intgetItemCount()RepositoryItem[]getItemList(java.lang.String folderPath)longgetLength(java.lang.String parentPath, java.lang.String itemName)java.lang.StringgetName()Returns repository nameintgetOpenFileHandleCount()RepositoryServerAdaptergetServer()Returns server adapterServerInfogetServerInfo()Returns server informationjava.lang.String[]getServerUserList()Returns list of all users known to server.java.lang.String[]getSubfolderList(java.lang.String folderPath)UsergetUser()Returns repository user object.User[]getUserList()Returns list of repository users.Version[]getVersions(java.lang.String parentPath, java.lang.String itemName)booleanhadUnexpectedDisconnect()Returns true if connection recently was lost unexpectedlybooleanhasCheckouts(java.lang.String parentPath, java.lang.String itemName)booleanisCheckinActive(java.lang.String parentPath, java.lang.String itemName)booleanisConnected()Returns true if connected.voidmoveFolder(java.lang.String oldParentPath, java.lang.String newParentPath, java.lang.String oldFolderName, java.lang.String newFolderName)voidmoveItem(java.lang.String oldParentPath, java.lang.String newParentPath, java.lang.String oldItemName, java.lang.String newItemName)ManagedBufferFileAdapteropenDatabase(java.lang.String parentPath, java.lang.String itemName, int version, int minChangeDataVer)ManagedBufferFileAdapteropenDatabase(java.lang.String parentPath, java.lang.String itemName, long checkoutId)DataFileHandleopenDataFile(java.lang.String parentPath, java.lang.String itemName, int version)voidremoveListener(RemoteAdapterListener listener)Remove a listener from this remote adaptervoidsetFileSystemListener(FileSystemListener fsListener)Set the file system listener associated with the remote repository.voidsetUserList(User[] users, boolean anonymousAccessAllowed)Set the list of authorized users for this repository.voidterminateCheckout(java.lang.String folderPath, java.lang.String itemName, long checkoutId, boolean notify)java.lang.StringtoString()voidupdateCheckoutVersion(java.lang.String parentPath, java.lang.String itemName, long checkoutId, int checkoutVersion)booleanverifyConnection()Verify that the connection is still valid.
-
-
-
Constructor Detail
-
RepositoryAdapter
public RepositoryAdapter(RepositoryServerAdapter serverAdapter, java.lang.String name)
Construct.- Parameters:
serverAdapter- persistent server adaptername- repository name
-
-
Method Detail
-
hadUnexpectedDisconnect
public boolean hadUnexpectedDisconnect()
Returns true if connection recently was lost unexpectedly
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setFileSystemListener
public void setFileSystemListener(FileSystemListener fsListener)
Set the file system listener associated with the remote repository.- Parameters:
fsListener- file system listener
-
addListener
public void addListener(RemoteAdapterListener listener)
Add a listener to this remote adapter- Parameters:
listener-
-
removeListener
public void removeListener(RemoteAdapterListener listener)
Remove a listener from this remote adapter- Parameters:
listener-
-
connectionStateChanged
public void connectionStateChanged(java.lang.Object adapter)
Notification callback when server connection state changes.- Specified by:
connectionStateChangedin interfaceRemoteAdapterListener- Parameters:
adapter- remote interface adapter (e.g., RepositoryServerAdapter).- See Also:
RemoteAdapterListener.connectionStateChanged(java.lang.Object)
-
isConnected
public boolean isConnected()
Returns true if connected.
-
connect
public void connect() throws java.io.IOExceptionAttempt to connect to the server.- Throws:
java.io.IOException
-
getName
public java.lang.String getName()
Returns repository name
-
getServer
public RepositoryServerAdapter getServer()
Returns server adapter
-
getServerInfo
public ServerInfo getServerInfo()
Returns server information
-
getUser
public User getUser() throws java.io.IOException
Returns repository user object.- Throws:
UserAccessException- user no longer has any permission to use repository.NotConnectedException- if server/repository connection is down (user already informed)java.io.IOException- See Also:
RepositoryHandle.getUser()
-
anonymousAccessAllowed
public boolean anonymousAccessAllowed() throws java.io.IOException- Returns:
- true if anonymous access allowed by this repository
- Throws:
java.io.IOException
-
getUserList
public User[] getUserList() throws java.io.IOException
Returns list of repository users.- Throws:
java.io.IOExceptionUserAccessException- user no longer has any permission to use repository.NotConnectedException- if server/repository connection is down (user already informed)- See Also:
RepositoryHandle.getUserList()
-
getServerUserList
public java.lang.String[] getServerUserList() throws java.io.IOExceptionReturns list of all users known to server.- Throws:
java.io.IOExceptionUserAccessException- user no longer has any permission to use repository.NotConnectedException- if server/repository connection is down (user already informed)- See Also:
RepositoryHandle.getServerUserList()
-
setUserList
public void setUserList(User[] users, boolean anonymousAccessAllowed) throws java.io.IOException
Set the list of authorized users for this repository.- Parameters:
users- list of user and access permissions.anonymousAccessAllowed- true to permit anonymous access (also requires anonymous access to be enabled for server)- Throws:
UserAccessExceptionjava.io.IOExceptionNotConnectedException- if server/repository connection is down (user already informed)- See Also:
ghidra.framework.remote.RemoteRepositoryHandle#setUserList(ghidra.framework.remote.User[])
-
createDatabase
public ManagedBufferFileAdapter createDatabase(java.lang.String parentPath, java.lang.String itemName, int bufferSize, java.lang.String contentType, java.lang.String fileID, java.lang.String projectPath) throws java.io.IOException, InvalidNameException
- Throws:
java.io.IOExceptionInvalidNameException
-
openDatabase
public ManagedBufferFileAdapter openDatabase(java.lang.String parentPath, java.lang.String itemName, int version, int minChangeDataVer) throws java.io.IOException
- Throws:
java.io.IOException
-
openDatabase
public ManagedBufferFileAdapter openDatabase(java.lang.String parentPath, java.lang.String itemName, long checkoutId) throws java.io.IOException
- Throws:
java.io.IOException
-
createDataFile
public void createDataFile(java.lang.String parentPath, java.lang.String itemName) throws java.io.IOException- Throws:
java.io.IOException
-
openDataFile
public DataFileHandle openDataFile(java.lang.String parentPath, java.lang.String itemName, int version) throws java.io.IOException
- Throws:
java.io.IOException
-
getSubfolderList
public java.lang.String[] getSubfolderList(java.lang.String folderPath) throws java.io.IOException- Throws:
java.io.IOException
-
getItemCount
public int getItemCount() throws java.io.IOException- Throws:
java.io.IOException
-
getItemList
public RepositoryItem[] getItemList(java.lang.String folderPath) throws java.io.IOException
- Throws:
java.io.IOException
-
getItem
public RepositoryItem getItem(java.lang.String folderPath, java.lang.String itemName) throws java.io.IOException
- Throws:
java.io.IOException
-
getItem
public RepositoryItem getItem(java.lang.String fileID) throws java.io.IOException
- Throws:
java.io.IOException
-
getVersions
public Version[] getVersions(java.lang.String parentPath, java.lang.String itemName) throws java.io.IOException
- Throws:
java.io.IOException
-
deleteItem
public void deleteItem(java.lang.String parentPath, java.lang.String itemName, int version) throws java.io.IOException- Throws:
java.io.IOException
-
moveFolder
public void moveFolder(java.lang.String oldParentPath, java.lang.String newParentPath, java.lang.String oldFolderName, java.lang.String newFolderName) throws InvalidNameException, java.io.IOException- Throws:
InvalidNameExceptionjava.io.IOException
-
moveItem
public void moveItem(java.lang.String oldParentPath, java.lang.String newParentPath, java.lang.String oldItemName, java.lang.String newItemName) throws InvalidNameException, java.io.IOException- Throws:
InvalidNameExceptionjava.io.IOException
-
checkout
public ItemCheckoutStatus checkout(java.lang.String folderPath, java.lang.String itemName, CheckoutType checkoutType, java.lang.String projectPath) throws java.io.IOException
- Throws:
java.io.IOException
-
terminateCheckout
public void terminateCheckout(java.lang.String folderPath, java.lang.String itemName, long checkoutId, boolean notify) throws java.io.IOException- Throws:
java.io.IOException
-
getCheckout
public ItemCheckoutStatus getCheckout(java.lang.String parentPath, java.lang.String itemName, long checkoutId) throws java.io.IOException
- Throws:
java.io.IOException
-
getCheckouts
public ItemCheckoutStatus[] getCheckouts(java.lang.String parentPath, java.lang.String itemName) throws java.io.IOException
- Throws:
java.io.IOException
-
folderExists
public boolean folderExists(java.lang.String folderPath) throws java.io.IOException- Throws:
java.io.IOException
-
fileExists
public boolean fileExists(java.lang.String folderPath, java.lang.String itemName) throws java.io.IOException- Throws:
java.io.IOException
-
getLength
public long getLength(java.lang.String parentPath, java.lang.String itemName) throws java.io.IOException- Throws:
java.io.IOException
-
hasCheckouts
public boolean hasCheckouts(java.lang.String parentPath, java.lang.String itemName) throws java.io.IOException- Throws:
java.io.IOException
-
isCheckinActive
public boolean isCheckinActive(java.lang.String parentPath, java.lang.String itemName) throws java.io.IOException- Throws:
java.io.IOException
-
updateCheckoutVersion
public void updateCheckoutVersion(java.lang.String parentPath, java.lang.String itemName, long checkoutId, int checkoutVersion) throws java.io.IOException- Throws:
java.io.IOException
-
verifyConnection
public boolean verifyConnection()
Verify that the connection is still valid.- Returns:
- true if the connection is valid; false if the connection needs to be reestablished
-
disconnect
public void disconnect()
-
getOpenFileHandleCount
public int getOpenFileHandleCount()
-
-