Package fr.gouv.vitam.common.model

# Class VitamSession

java.lang.Object
fr.gouv.vitam.common.model.VitamSession

public class VitamSession extends 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.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VitamSession(VitamThreadFactory.VitamThread owningThread)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `checkValidRequestId()`
  Check if the session contains a valid request id
  `void`
  `erase()`
  Erase the content of the VitamSession
  `static VitamSession`
  `from(VitamSession origin)`
  Build a clone of the original VitamSession, attached to the same thread.
  `String`
  `getApplicationSessionId()`
  Get vitam application session id
  `String`
  `getContextId()`
  Get vitam security context id
  `AccessContractModel`
  `getContract()`
  `String`
  `getContractId()`
  `String`
  `getInternalRequestId()`
  Get the server request id
  `Object`
  `getOther()`
  `String`
  `getPersonalCertificate()`
  Get personalCertificate
  `String`
  `getRequestId()`
  `String`
  `getSecurityProfileIdentifier()`
  Get securityProfileIdentifier
  `Integer`
  `getTenantId()`
  `void`
  `initIfAbsent(Integer tenantId)`
  `void`
  `mutateFrom(@NotNull VitamSession newSession)`
  Get the content of a given VitamSession and copy its internal values to the current instance
  `void`
  `setApplicationSessionId(String applicationSessionId)`
  Set vitam application session id
  `void`
  `setContextId(String contextId)`
  Set vitam security context id
  `void`
  `setContract(AccessContractModel contract)`
  `void`
  `setContractId(String contractId)`
  `void`
  `setInternalRequestId(String newRequestId)`
  Set the server request id
  `VitamSession`
  `setOther(Object other)`
  `void`
  `setPersonalCertificate(String personalCertificate)`
  Set personalCertificate
  `void`
  `setRequestId(GUID guid)`
  Sets the request id from the guid
  `void`
  `setRequestId(String newRequestId)`
  Set the request id and saves it to the MDC
  `void`
  `setSecurityProfileIdentifier(String securityProfileIdentifier)`
  Set securityProfileIdentifier
  `void`
  `setTenantId(Integer newTenantId)`
  Sets the tenantId
  `String`
  `toString()`

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

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

- ## Constructor Details

  - ### VitamSession

    public VitamSession(VitamThreadFactory.VitamThread owningThread)
    Parameters:
      `owningThread` - the owning thread

- ## Method Details

  - ### 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 Object getOther()
    Returns:
      the other

  - ### setOther

    public VitamSession setOther(Object other)
    Parameters:
      `other` - the other to set
    Returns:
      this

  - ### getRequestId

    public String getRequestId()
    Returns:
      the current X-Request-Id

  - ### setRequestId

    public void setRequestId(String newRequestId)
    Set the request id and saves it to the MDC
    Parameters:
      `newRequestId` - the request id

  - ### setInternalRequestId

    public void setInternalRequestId(String newRequestId)
    Set the server request id
    Parameters:
      `newRequestId` - the request id

  - ### getInternalRequestId

    public String getInternalRequestId()
    Get the server request id
    Returns:
      internalRequestId

  - ### getTenantId

    public Integer getTenantId()
    Returns:
      the current X-Tenant-Id

  - ### setTenantId

    public void setTenantId(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 String getContractId()
    Returns:
      contract Id

  - ### setContractId

    public void setContractId(String contractId)
    Parameters:
      `contractId` -

  - ### getContract

    public AccessContractModel getContract()
    Returns:
      AccessContractModel

  - ### setContract

    public void setContract(AccessContractModel contract)
    Parameters:
      `contract` -

  - ### getContextId

    public String getContextId()
    Get vitam security context id
    Returns:
      contextId

  - ### setContextId

    public void setContextId(String contextId)
    Set vitam security context id
    Parameters:
      `contextId` -

  - ### getSecurityProfileIdentifier

    public String getSecurityProfileIdentifier()
    Get securityProfileIdentifier
    Returns:
      securityProfileIdentifier

  - ### setSecurityProfileIdentifier

    public void setSecurityProfileIdentifier(String securityProfileIdentifier)
    Set securityProfileIdentifier
    Parameters:
      `securityProfileIdentifier` -

  - ### getApplicationSessionId

    public String getApplicationSessionId()
    Get vitam application session id
    Returns:
      applicationSessionId

  - ### setApplicationSessionId

    public void setApplicationSessionId(String applicationSessionId)
    Set vitam application session id
    Parameters:
      `applicationSessionId` -

  - ### getPersonalCertificate

    public String getPersonalCertificate()
    Get personalCertificate
    Returns:
      personalCertificate

  - ### setPersonalCertificate

    public void setPersonalCertificate(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:
      `IllegalArgumentException`

  - ### initIfAbsent

    public void initIfAbsent(Integer tenantId)

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`