Interface ConnectionHandler

  • All Known Subinterfaces:
    Client
    All Known Implementing Classes:
    GatewayWrapper

    public interface ConnectionHandler
    Interface to handle the connection to an OMERO server through a Gateway for a given user and in a specific SecurityContext.
    • Method Detail

      • getGateway

        Gateway getGateway()
        Returns the Gateway used for the connection.
        Returns:
        See above.
      • getUser

        Experimenter getUser()
        Returns the current user.
        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.
      • 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.