Package fr.gouv.vitam.common.model
Class VitamSession
java.lang.Object
fr.gouv.vitam.common.model.VitamSession
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Check if the session contains a valid request idvoid
erase()
Erase the content of the VitamSessionstatic VitamSession
from
(VitamSession origin) Build a clone of the original VitamSession, attached to the same thread.Get vitam application session idGet vitam security context idGet the server request idgetOther()
Get personalCertificateGet securityProfileIdentifiervoid
initIfAbsent
(Integer tenantId) void
mutateFrom
(@NotNull VitamSession newSession) Get the content of a given VitamSession and copy its internal values to the current instancevoid
setApplicationSessionId
(String applicationSessionId) Set vitam application session idvoid
setContextId
(String contextId) Set vitam security context idvoid
setContract
(AccessContractModel contract) void
setContractId
(String contractId) void
setInternalRequestId
(String newRequestId) Set the server request idvoid
setPersonalCertificate
(String personalCertificate) Set personalCertificatevoid
setRequestId
(GUID guid) Sets the request id from the guidvoid
setRequestId
(String newRequestId) Set the request id and saves it to the MDCvoid
setSecurityProfileIdentifier
(String securityProfileIdentifier) Set securityProfileIdentifiervoid
setTenantId
(Integer newTenantId) Sets the tenantIdtoString()
-
Constructor Details
-
VitamSession
- Parameters:
owningThread
- the owning thread
-
-
Method Details
-
from
Build a clone of the original VitamSession, attached to the same thread.- Parameters:
origin
- VitamSession to clone- Returns:
- A new session
-
getOther
- Returns:
- the other
-
setOther
- Parameters:
other
- the other to set- Returns:
- this
-
getRequestId
- Returns:
- the current X-Request-Id
-
setRequestId
Set the request id and saves it to the MDC- Parameters:
newRequestId
- the request id
-
setInternalRequestId
Set the server request id- Parameters:
newRequestId
- the request id
-
getInternalRequestId
Get the server request id- Returns:
- internalRequestId
-
getTenantId
- Returns:
- the current X-Tenant-Id
-
setTenantId
Sets the tenantId- Parameters:
newTenantId
-
-
setRequestId
Sets the request id from the guid- Parameters:
guid
- the guid
-
getContractId
- Returns:
- contract Id
-
setContractId
- Parameters:
contractId
-
-
getContract
- Returns:
- AccessContractModel
-
setContract
- Parameters:
contract
-
-
getContextId
Get vitam security context id- Returns:
- contextId
-
setContextId
Set vitam security context id- Parameters:
contextId
-
-
getSecurityProfileIdentifier
Get securityProfileIdentifier- Returns:
- securityProfileIdentifier
-
setSecurityProfileIdentifier
Set securityProfileIdentifier- Parameters:
securityProfileIdentifier
-
-
getApplicationSessionId
Get vitam application session id- Returns:
- applicationSessionId
-
setApplicationSessionId
Set vitam application session id- Parameters:
applicationSessionId
-
-
getPersonalCertificate
Get personalCertificate- Returns:
- personalCertificate
-
setPersonalCertificate
Set personalCertificate- Parameters:
personalCertificate
-
-
mutateFrom
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
-
toString
-