Class BlueMindSession

java.lang.Object
org.exoplatform.bluemind.client.BlueMindSession
All Implemented Interfaces:
AutoCloseable

public final class BlueMindSession extends Object implements AutoCloseable
An open session, as a job of BlueMindRestClient.call(org.exoplatform.bluemind.client.BlueMindAccountSource, java.util.function.Function<org.exoplatform.bluemind.client.BlueMindSession, T>) or the holder of BlueMindRestClient.open(org.exoplatform.bluemind.client.BlueMindAccountSource) sees it: the REST root and the key every call carries, and who BlueMind says the session is — never the key itself. Paths are given relative to the root and must start with /api/; a query may follow, and is never named in a message. Any other path is refused before anything is sent, and so is one whose address would not be the session's own scheme, host and port: the key the request carries goes to the server the session was opened at, and to no other.

Not thread-safe, and not to be kept past the job or the operation it was opened for: it is one view of one session, closed when that ends.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the session when this holder is the only one that ever held it: the source could not be keyed, the store had no room for it, or another thread's session took its place.
    delete(String path)
    A DELETE.
    The uid of the domain the authenticated account belongs to: the {domainUid} segment of BlueMind's per-user REST paths.
    get(String path)
    A GET.
    The account BlueMind says the session belongs to, for diagnosis — never compared with the login that was asked for.
    named(String path)
    The address a message may name for a path: root and path, without the query.
    post(String path, String body, String contentType)
    A POST with a body.
    put(String path, String body, String contentType)
    A PUT with a body.
    The authenticated user's time zone, as BlueMind's login answered it.
    Names the session without its key — safe in logs.
    The directory entry uid BlueMind authenticated this session as, the segment of the account's DAV principal /dav/principals/__uids__/<uid>/ and of its mailbox path.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • userUid

      public String userUid()
      The directory entry uid BlueMind authenticated this session as, the segment of the account's DAV principal /dav/principals/__uids__/<uid>/ and of its mailbox path.
      Returns:
      the uid, or null when the login answer named none
    • domainUid

      public String domainUid()
      The uid of the domain the authenticated account belongs to: the {domainUid} segment of BlueMind's per-user REST paths.
      Returns:
      the domain uid, or null when the login answer named none
    • latd

      public String latd()
      The account BlueMind says the session belongs to, for diagnosis — never compared with the login that was asked for.
      Returns:
      the account in BlueMind's own spelling, or null
    • timeZone

      public String timeZone()
      The authenticated user's time zone, as BlueMind's login answered it.
      Returns:
      the zone id, or null when the answer named none
    • get

      public BlueMindAnswer get(String path)
      A GET.
      Parameters:
      path - the path under the root, query included if any
      Returns:
      the answer
    • post

      public BlueMindAnswer post(String path, String body, String contentType)
      A POST with a body.
      Parameters:
      path - the path under the root
      body - the body text
      contentType - its media type, sent exactly as given
      Returns:
      the answer
    • put

      public BlueMindAnswer put(String path, String body, String contentType)
      A PUT with a body.
      Parameters:
      path - the path under the root
      body - the body text
      contentType - its media type, sent exactly as given
      Returns:
      the answer
    • delete

      public BlueMindAnswer delete(String path)
      A DELETE.
      Parameters:
      path - the path under the root, query included if any
      Returns:
      the answer
    • named

      public URI named(String path)
      The address a message may name for a path: root and path, without the query.
      Parameters:
      path - the path under the root
      Returns:
      the address, query stripped
      Throws:
      BlueMindException - when the path is not one of the REST API's on this session's server
    • toString

      public String toString()
      Names the session without its key — safe in logs.
      Overrides:
      toString in class Object
      Returns:
      the session described by its address and its authenticated user
    • close

      public void close()
      Closes the session when this holder is the only one that ever held it: the source could not be keyed, the store had no room for it, or another thread's session took its place. A session the store keeps is left open for the next caller, and a session BlueMind refused is already closed on its side. A second close sends nothing.
      Specified by:
      close in interface AutoCloseable