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
RepositoryAdapter
provides 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 void
addListener(RemoteAdapterListener listener)
Add a listener to this remote adapterboolean
anonymousAccessAllowed()
ItemCheckoutStatus
checkout(java.lang.String folderPath, java.lang.String itemName, CheckoutType checkoutType, java.lang.String projectPath)
void
connect()
Attempt to connect to the server.void
connectionStateChanged(java.lang.Object adapter)
Notification callback when server connection state changes.ManagedBufferFileAdapter
createDatabase(java.lang.String parentPath, java.lang.String itemName, int bufferSize, java.lang.String contentType, java.lang.String fileID, java.lang.String projectPath)
void
createDataFile(java.lang.String parentPath, java.lang.String itemName)
void
deleteItem(java.lang.String parentPath, java.lang.String itemName, int version)
void
disconnect()
boolean
fileExists(java.lang.String folderPath, java.lang.String itemName)
boolean
folderExists(java.lang.String folderPath)
ItemCheckoutStatus
getCheckout(java.lang.String parentPath, java.lang.String itemName, long checkoutId)
ItemCheckoutStatus[]
getCheckouts(java.lang.String parentPath, java.lang.String itemName)
RepositoryItem
getItem(java.lang.String fileID)
RepositoryItem
getItem(java.lang.String folderPath, java.lang.String itemName)
int
getItemCount()
RepositoryItem[]
getItemList(java.lang.String folderPath)
long
getLength(java.lang.String parentPath, java.lang.String itemName)
java.lang.String
getName()
Returns repository nameint
getOpenFileHandleCount()
RepositoryServerAdapter
getServer()
Returns server adapterServerInfo
getServerInfo()
Returns server informationjava.lang.String[]
getServerUserList()
Returns list of all users known to server.java.lang.String[]
getSubfolderList(java.lang.String folderPath)
User
getUser()
Returns repository user object.User[]
getUserList()
Returns list of repository users.Version[]
getVersions(java.lang.String parentPath, java.lang.String itemName)
boolean
hadUnexpectedDisconnect()
Returns true if connection recently was lost unexpectedlyboolean
hasCheckouts(java.lang.String parentPath, java.lang.String itemName)
boolean
isCheckinActive(java.lang.String parentPath, java.lang.String itemName)
boolean
isConnected()
Returns true if connected.void
moveFolder(java.lang.String oldParentPath, java.lang.String newParentPath, java.lang.String oldFolderName, java.lang.String newFolderName)
void
moveItem(java.lang.String oldParentPath, java.lang.String newParentPath, java.lang.String oldItemName, java.lang.String newItemName)
ManagedBufferFileAdapter
openDatabase(java.lang.String parentPath, java.lang.String itemName, int version, int minChangeDataVer)
ManagedBufferFileAdapter
openDatabase(java.lang.String parentPath, java.lang.String itemName, long checkoutId)
DataFileHandle
openDataFile(java.lang.String parentPath, java.lang.String itemName, int version)
void
removeListener(RemoteAdapterListener listener)
Remove a listener from this remote adaptervoid
setFileSystemListener(FileSystemListener fsListener)
Set the file system listener associated with the remote repository.void
setUserList(User[] users, boolean anonymousAccessAllowed)
Set the list of authorized users for this repository.void
terminateCheckout(java.lang.String folderPath, java.lang.String itemName, long checkoutId, boolean notify)
java.lang.String
toString()
void
updateCheckoutVersion(java.lang.String parentPath, java.lang.String itemName, long checkoutId, int checkoutVersion)
boolean
verifyConnection()
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:
toString
in 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:
connectionStateChanged
in 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.IOException
Attempt 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:
RemoteRepositoryHandle.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.IOException
UserAccessException
- user no longer has any permission to use repository.NotConnectedException
- if server/repository connection is down (user already informed)- See Also:
RemoteRepositoryHandle.getUserList()
-
getServerUserList
public java.lang.String[] getServerUserList() throws java.io.IOException
Returns list of all users known to server.- Throws:
java.io.IOException
UserAccessException
- user no longer has any permission to use repository.NotConnectedException
- if server/repository connection is down (user already informed)- See Also:
RemoteRepositoryHandle.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:
UserAccessException
java.io.IOException
NotConnectedException
- if server/repository connection is down (user already informed)- See Also:
RemoteRepositoryHandle.setUserList(User[], boolean)
-
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.IOException
InvalidNameException
- See Also:
RepositoryHandle.createDatabase(String, String, String, int, String, String)
-
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:
InvalidNameException
java.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:
InvalidNameException
java.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()
-
-