edu.ucsb.nceas.metacat.service

## Class SessionService

- java.lang.Object
- - edu.ucsb.nceas.metacat.shared.BaseService
  - - edu.ucsb.nceas.metacat.service.SessionService

-     public class SessionService
      extends BaseService

- - ### Field Summary

    - ### Fields inherited from class edu.ucsb.nceas.metacat.shared.BaseService

      `_serviceName`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `doRefresh()`
    `static SessionService` | `getInstance()` Get the single instance of SessionService.
    `SessionData` | `getPublicSession()` Get the public session from the session hash table.
    `SessionData` | `getRegisteredSession(java.lang.String sessionId)` Get a registered session from the session hash table.
    `boolean` | `isSessionRegistered(java.lang.String sessionId)` Check if a session is registered in the session hash table.
    `boolean` | `refreshable()`
    `void` | `registerSession(SessionData sessionData)` Register a session in the session hash table.
    `void` | `registerSession(java.lang.String sessionId, java.lang.String userName, java.lang.String[] groupNames, java.lang.String password, java.lang.String name)` Register a session in the session hash table.
    `void` | `stop()`
    `void` | `touchSession(java.lang.String sessionId)` Keep a session active by updating its last accessed time.
    `void` | `unRegisterAllSessions()` Unregister all sessions from the session hash table except the public session.
    `void` | `unRegisterSession(java.lang.String sessionId)` Unregister a session from the session hash table.
    `boolean` | `validateSession(java.lang.String sessionId)` Check if a session is registered in the session hash table.
    `void` | `validateSession(java.io.Writer out, javax.servlet.http.HttpServletResponse response, java.lang.String sessionId)` Check if a session is registered in the session hash table.

    - ### Methods inherited from class edu.ucsb.nceas.metacat.shared.BaseService

      `refresh`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getInstance

          public static SessionService getInstance()

      Get the single instance of SessionService.
      Returns:
        the single instance of SessionService

    - #### refreshable

          public boolean refreshable()

      Specified by:
        `refreshable` in class `BaseService`

    - #### doRefresh

          public void doRefresh()
                         throws ServiceException

      Specified by:
        `doRefresh` in class `BaseService`
      Throws:
        `ServiceException`

    - #### stop

          public void stop()
                    throws ServiceException

      Specified by:
        `stop` in class `BaseService`
      Throws:
        `ServiceException`

    - #### registerSession

          public void registerSession(java.lang.String sessionId,
                                      java.lang.String userName,
                                      java.lang.String[] groupNames,
                                      java.lang.String password,
                                      java.lang.String name)
                               throws ServiceException

      Register a session in the session hash table. This uses the parameters passed in to create a SessionData object.
      Parameters:
        `sessionId` - the ID of the session to register
        `userName` - the user name of the session
        `groupNames` - the group names for the session
        `password` - the password for the session
      Throws:
        `ServiceException`

    - #### registerSession

          public void registerSession(SessionData sessionData)
                               throws ServiceException

      Register a session in the session hash table.
      Parameters:
        `sessionData` - the session data object to add to the session hash
      Throws:
        `ServiceException`

    - #### unRegisterSession

          public void unRegisterSession(java.lang.String sessionId)

      Unregister a session from the session hash table.
      Parameters:
        `sessionId` - the id of the session to remove.

    - #### unRegisterAllSessions

          public void unRegisterAllSessions()

      Unregister all sessions from the session hash table except the public session.
      Parameters:
        `sessionId` - the id of the session to remove.

    - #### isSessionRegistered

          public boolean isSessionRegistered(java.lang.String sessionId)

      Check if a session is registered in the session hash table.
      Parameters:
        `sessionId` - the id of the session to look for.

    - #### validateSession

          public void validateSession(java.io.Writer out,
                                      javax.servlet.http.HttpServletResponse response,
                                      java.lang.String sessionId)
                               throws java.io.IOException

      Check if a session is registered in the session hash table. Write results in XML format to output.
      Parameters:
        `out` - the output stream to write to.
        `sessionId` - the id of the session to look for.
      Throws:
        `java.io.IOException`

    - #### validateSession

          public boolean validateSession(java.lang.String sessionId)

      Check if a session is registered in the session hash table. Return true if the session is valid and false otherwise.
      Parameters:
        `sessionId` - the id of the session to look for.

    - #### getRegisteredSession

          public SessionData getRegisteredSession(java.lang.String sessionId)

      Get a registered session from the session hash table. TODO MCD need to time sessions out
      Parameters:
        `sessionId` - the id of the session to retrieve.

    - #### getPublicSession

          public SessionData getPublicSession()

      Get the public session from the session hash table.

    - #### touchSession

          public void touchSession(java.lang.String sessionId)

      Keep a session active by updating its last accessed time.
      Parameters:
        `sessionId` - the id of the session to update.

Copyright © 2023 Regents of the University of California. All Rights Reserved.