Package fr.igred.omero
Class GatewayWrapper
- java.lang.Object
-
- fr.igred.omero.GatewayWrapper
-
- Direct Known Subclasses:
Client
public abstract class GatewayWrapper extends java.lang.Object
Basic class, contains the gateway, the security context, and multiple facilities.Allows the user to connect to OMERO and browse through all the data accessible to the user.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GatewayWrapper(Gateway gateway, SecurityContext ctx, ExperimenterWrapper user)
Abstract constructor of the GatewayWrapper class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
connect(java.lang.String hostname, int port, java.lang.String sessionId)
Connects to OMERO using a session ID.void
connect(java.lang.String hostname, int port, java.lang.String username, char[] password)
Connects the user to OMERO.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 cred)
Connects the user to OMERO.void
deleteFile(java.lang.Long id)
Deletes a file from OMEROvoid
disconnect()
Disconnects the userjava.util.List<IObject>
findByQuery(java.lang.String query)
Finds objects on OMERO through a database query.AdminFacility
getAdminFacility()
Gets the AdminFacility linked to the gateway to use admin specific function.BrowseFacility
getBrowseFacility()
Gets the BrowseFacility used to access the data from OMERO.SecurityContext
getCtx()
Contains the permissions of the user in the group.long
getCurrentGroupId()
Gets the current group ID.DataManagerFacility
getDm()
Gets the DataManagerFacility to handle/write data on OMERO.Gateway
getGateway()
Returns the Gateway.long
getId()
Gets the user id.OMEROMetadataStoreClient
getImportStore()
Creates or recycles the import store.MetadataFacility
getMetadata()
Gets the MetadataFacility used to manipulate annotations from OMERO.ROIFacility
getRoiFacility()
Gets the ROIFacility used to manipulate ROI from OMERO.java.lang.String
getSessionId()
Get the ID of the current sessionTablesFacility
getTablesFacility()
Gets the TablesFacility used to manipulate table from OMERO.ExperimenterWrapper
getUser()
Returns the current user.boolean
isConnected()
Check if the client is still connected to the serverIObject
save(IObject object)
Saves an object on OMERO.void
switchGroup(long groupId)
Change the current group used by the current user;java.lang.String
toString()
Overridden to return the host name, the group ID, the username and the connection status.
-
-
-
Constructor Detail
-
GatewayWrapper
protected GatewayWrapper(Gateway gateway, SecurityContext ctx, ExperimenterWrapper user)
Abstract constructor of the GatewayWrapper class.Null arguments will be replaced with default empty objects.
- Parameters:
gateway
- The Gateway.ctx
- The Security Context.user
- The connected user.
-
-
Method Detail
-
getGateway
public Gateway getGateway()
Returns the Gateway.- Returns:
- The Gateway.
-
getUser
public ExperimenterWrapper getUser()
Returns the current user.- Returns:
- The current user.
-
getCtx
public SecurityContext getCtx()
Contains the permissions of the user in the group.- Returns:
- the
SecurityContext
of the user.
-
getId
public long getId()
Gets the user id.- Returns:
- The user ID.
-
getCurrentGroupId
public long getCurrentGroupId()
Gets the current group ID.- Returns:
- The group ID.
-
getSessionId
public 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
public boolean isConnected()
Check if the client is still connected to the server- Returns:
- See above.
-
connect
public 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
public 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
public 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
public void connect(LoginCredentials cred) throws ServiceException
Connects the user to OMERO. Gets the SecurityContext and the BrowseFacility.- Parameters:
cred
- User credential.- Throws:
ServiceException
- Cannot connect to OMERO.
-
disconnect
public void disconnect()
Disconnects the user
-
switchGroup
public void switchGroup(long groupId)
Change the current group used by the current user;- Parameters:
groupId
- The group ID.
-
getBrowseFacility
public BrowseFacility getBrowseFacility() throws java.util.concurrent.ExecutionException
Gets the BrowseFacility used to access the data from OMERO.- Returns:
- the
BrowseFacility
linked to the gateway. - Throws:
java.util.concurrent.ExecutionException
- A Facility can't be retrieved or instantiated.
-
getDm
public DataManagerFacility getDm() throws java.util.concurrent.ExecutionException
Gets the DataManagerFacility to handle/write data on OMERO. A- Returns:
- the
DataManagerFacility
linked to the gateway. - Throws:
java.util.concurrent.ExecutionException
- If the DataManagerFacility can't be retrieved or instantiated.
-
getMetadata
public MetadataFacility getMetadata() throws java.util.concurrent.ExecutionException
Gets the MetadataFacility used to manipulate annotations from OMERO.- Returns:
- the
MetadataFacility
linked to the gateway. - Throws:
java.util.concurrent.ExecutionException
- If the MetadataFacility can't be retrieved or instantiated.
-
getRoiFacility
public ROIFacility getRoiFacility() throws java.util.concurrent.ExecutionException
Gets the ROIFacility used to manipulate ROI from OMERO.- Returns:
- the
ROIFacility
linked to the gateway. - Throws:
java.util.concurrent.ExecutionException
- If the ROIFacility can't be retrieved or instantiated.
-
getTablesFacility
public TablesFacility getTablesFacility() throws java.util.concurrent.ExecutionException
Gets the TablesFacility used to manipulate table from OMERO.- Returns:
- the
TablesFacility
linked to the gateway. - Throws:
java.util.concurrent.ExecutionException
- If the TablesFacility can't be retrieved or instantiated.
-
getAdminFacility
public AdminFacility getAdminFacility() throws java.util.concurrent.ExecutionException
Gets the AdminFacility linked to the gateway to use admin specific function.- Returns:
- the
AdminFacility
linked to the gateway. - Throws:
java.util.concurrent.ExecutionException
- If the AdminFacility can't be retrieved or instantiated.
-
getImportStore
public OMEROMetadataStoreClient getImportStore() throws ServiceException
Creates or recycles the import store.- Returns:
- config.
- Throws:
ServiceException
- Cannot connect to OMERO.
-
findByQuery
public java.util.List<IObject> findByQuery(java.lang.String query) throws ServiceException, OMEROServerError
Finds objects on OMERO through a database query.- Parameters:
query
- The database query.- Returns:
- A list of OMERO objects.
- Throws:
ServiceException
- Cannot connect to OMERO.OMEROServerError
- Server error.
-
save
public IObject save(IObject object) throws ServiceException, AccessException, java.util.concurrent.ExecutionException
Saves an object on OMERO.- Parameters:
object
- The OMERO object.- Returns:
- The saved OMERO object
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.java.util.concurrent.ExecutionException
- A Facility can't be retrieved or instantiated.
-
deleteFile
public void deleteFile(java.lang.Long id) throws ServiceException, AccessException, java.util.concurrent.ExecutionException, OMEROServerError, java.lang.InterruptedException
Deletes a file from OMERO- Parameters:
id
- ID of the file to delete.- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.java.util.concurrent.ExecutionException
- A Facility can't be retrieved or instantiated.OMEROServerError
- Server error.java.lang.InterruptedException
- If block(long) does not return.
-
toString
public java.lang.String toString()
Overridden to return the host name, the group ID, the username and the connection status.- Overrides:
toString
in classjava.lang.Object
- Returns:
- See above.
-
-