Class VitamSession


  • public class VitamSession
    extends java.lang.Object

    Generic VitamSession object ; used to store thread context information.

    Only one instance of this class must be used per thread. In fact, only VitamThreadFactory.VitamThread should be allowed to create one.

    Finally, this class is NOT threadsafe ; only the thread "owning" the instance should be used to access it. Any other thread will cause an IllegalStateException when mutating its state.

    • Method Detail

      • from

        public static VitamSession from​(VitamSession origin)
        Build a clone of the original VitamSession, attached to the same thread.
        Parameters:
        origin - VitamSession to clone
        Returns:
        A new session
      • getOther

        public java.lang.Object getOther()
        Returns:
        the other
      • setOther

        public VitamSession setOther​(java.lang.Object other)
        Parameters:
        other - the other to set
        Returns:
        this
      • getRequestId

        public java.lang.String getRequestId()
        Returns:
        the current X-Request-Id
      • setRequestId

        public void setRequestId​(java.lang.String newRequestId)
        Set the request id and saves it to the MDC
        Parameters:
        newRequestId - the request id
      • setInternalRequestId

        public void setInternalRequestId​(java.lang.String newRequestId)
        Set the server request id
        Parameters:
        newRequestId - the request id
      • getInternalRequestId

        public java.lang.String getInternalRequestId()
        Get the server request id
        Returns:
        internalRequestId
      • getTenantId

        public java.lang.Integer getTenantId()
        Returns:
        the current X-Tenant-Id
      • setTenantId

        public void setTenantId​(java.lang.Integer newTenantId)
        Sets the tenantId
        Parameters:
        newTenantId -
      • setRequestId

        public void setRequestId​(GUID guid)
        Sets the request id from the guid
        Parameters:
        guid - the guid
      • getContractId

        public java.lang.String getContractId()
        Returns:
        contract Id
      • setContractId

        public void setContractId​(java.lang.String contractId)
        Parameters:
        contractId -
      • setContract

        public void setContract​(AccessContractModel contract)
        Parameters:
        contract -
      • getContextId

        public java.lang.String getContextId()
        Get vitam security context id
        Returns:
        contextId
      • setContextId

        public void setContextId​(java.lang.String contextId)
        Set vitam security context id
        Parameters:
        contextId -
      • getSecurityProfileIdentifier

        public java.lang.String getSecurityProfileIdentifier()
        Get securityProfileIdentifier
        Returns:
        securityProfileIdentifier
      • setSecurityProfileIdentifier

        public void setSecurityProfileIdentifier​(java.lang.String securityProfileIdentifier)
        Set securityProfileIdentifier
        Parameters:
        securityProfileIdentifier -
      • getApplicationSessionId

        public java.lang.String getApplicationSessionId()
        Get vitam application session id
        Returns:
        applicationSessionId
      • setApplicationSessionId

        public void setApplicationSessionId​(java.lang.String applicationSessionId)
        Set vitam application session id
        Parameters:
        applicationSessionId -
      • getPersonalCertificate

        public java.lang.String getPersonalCertificate()
        Get personalCertificate
        Returns:
        personalCertificate
      • setPersonalCertificate

        public void setPersonalCertificate​(java.lang.String personalCertificate)
        Set personalCertificate
        Parameters:
        personalCertificate -
      • mutateFrom

        public void mutateFrom​(@NotNull
                               @NotNull VitamSession newSession)
        Get the content of a given VitamSession and copy its internal values to the current instance
        Parameters:
        newSession - Source session
      • erase

        public void erase()
        Erase the content of the VitamSession
      • checkValidRequestId

        public void checkValidRequestId()
        Check if the session contains a valid request id
        Throws:
        java.lang.IllegalArgumentException
      • initIfAbsent

        public void initIfAbsent​(java.lang.Integer tenantId)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object