Package fr.igred.omero.client
Interface ConnectionHandler
-
- All Known Subinterfaces:
Client
- All Known Implementing Classes:
GatewayWrapper
public interface ConnectionHandler
Interface to handle the connection to an OMERO server through aGateway
for a given user and in a specificSecurityContext
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
connect(java.lang.String hostname, int port, java.lang.String sessionId)
Connects to OMERO using a session ID.default void
connect(java.lang.String hostname, int port, java.lang.String username, char[] password)
Connects the user to OMERO.default void
connect(java.lang.String hostname, int port, java.lang.String username, char[] password, java.lang.Long groupID)
Connects the user to OMERO.void
connect(LoginCredentials credentials)
Connects the user to OMERO.void
disconnect()
Disconnects the userSecurityContext
getCtx()
Returns the currentSecurityContext
.default long
getCurrentGroupId()
Gets the current group ID.Gateway
getGateway()
Returns theGateway
used for the connection.default long
getId()
Gets the user id.default OMEROMetadataStoreClient
getImportStore()
Creates or recycles the import store.default java.lang.String
getSessionId()
Get the ID of the current sessionExperimenter
getUser()
Returns the current user.default boolean
isConnected()
Check if the client is still connected to the serverConnectionHandler
sudo(java.lang.String username)
Returns a ConnectionHandler associated with the given username.void
switchGroup(long groupId)
Change the current group used by the current user;
-
-
-
Method Detail
-
getUser
Experimenter getUser()
Returns the current user.- Returns:
- See above.
-
getCtx
SecurityContext getCtx()
Returns the currentSecurityContext
.- Returns:
- See above
-
getId
default long getId()
Gets the user id.- Returns:
- The user ID.
-
getCurrentGroupId
default long getCurrentGroupId()
Gets the current group ID.- Returns:
- The group ID.
-
getSessionId
default java.lang.String getSessionId() throws ServiceException
Get the ID of the current session- Returns:
- See above
- Throws:
ServiceException
- If the connection is broken, or not logged in
-
isConnected
default boolean isConnected()
Check if the client is still connected to the server- Returns:
- See above.
-
connect
default void connect(java.lang.String hostname, int port, java.lang.String sessionId) throws ServiceException
Connects to OMERO using a session ID.- Parameters:
hostname
- Name of the host.port
- Port used by OMERO.sessionId
- The session ID.- Throws:
ServiceException
- Cannot connect to OMERO.
-
connect
default void connect(java.lang.String hostname, int port, java.lang.String username, char[] password, java.lang.Long groupID) throws ServiceException
Connects the user to OMERO.Uses the argument to connect to the gateway.
Connects to the group specified in the argument.
- Parameters:
hostname
- Name of the host.port
- Port used by OMERO.username
- Username of the user.password
- Password of the user.groupID
- ID of the group to connect.- Throws:
ServiceException
- Cannot connect to OMERO.
-
connect
default void connect(java.lang.String hostname, int port, java.lang.String username, char[] password) throws ServiceException
Connects the user to OMERO.Uses the argument to connect to the gateway.
Connects to the default group of the user.
- Parameters:
hostname
- Name of the host.port
- Port used by OMERO.username
- Username of the user.password
- Password of the user.- Throws:
ServiceException
- Cannot connect to OMERO.
-
connect
void connect(LoginCredentials credentials) throws ServiceException
Connects the user to OMERO. Gets the SecurityContext and the BrowseFacility.- Parameters:
credentials
- User credentials.- Throws:
ServiceException
- Cannot connect to OMERO.
-
disconnect
void disconnect()
Disconnects the user
-
switchGroup
void switchGroup(long groupId)
Change the current group used by the current user;- Parameters:
groupId
- The group ID.
-
getImportStore
default OMEROMetadataStoreClient getImportStore() throws ServiceException
Creates or recycles the import store.- Returns:
- See above.
- Throws:
ServiceException
- Cannot connect to OMERO.
-
sudo
ConnectionHandler sudo(java.lang.String username) throws ServiceException, AccessException, java.util.concurrent.ExecutionException
Returns a ConnectionHandler associated with the given username.All actions realized with the returned ConnectionHandler will be considered as his.
The user calling this function needs to have administrator rights.
- Parameters:
username
- The user name.- Returns:
- The connection and context corresponding to the new user.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.java.util.concurrent.ExecutionException
- A Facility can't be retrieved or instantiated.java.util.NoSuchElementException
- The requested user does not exist.
-
-