Package fr.gouv.vitam.common.model
Class VitamSession
- java.lang.Object
-
- fr.gouv.vitam.common.model.VitamSession
-
public class VitamSession extends java.lang.ObjectGeneric VitamSession object ; used to store thread context information.
Only one instance of this class must be used per thread. In fact, only
VitamThreadFactory.VitamThreadshould 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
IllegalStateExceptionwhen mutating its state.
-
-
Constructor Summary
Constructors Constructor Description VitamSession(VitamThreadFactory.VitamThread owningThread)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckValidRequestId()Check if the session contains a valid request idvoiderase()Erase the content of the VitamSessionstatic VitamSessionfrom(VitamSession origin)Build a clone of the original VitamSession, attached to the same thread.java.lang.StringgetApplicationSessionId()Get vitam application session idjava.lang.StringgetContextId()Get vitam security context idAccessContractModelgetContract()java.lang.StringgetContractId()java.lang.StringgetInternalRequestId()Get the server request idjava.lang.ObjectgetOther()java.lang.StringgetPersonalCertificate()Get personalCertificatejava.lang.StringgetRequestId()java.lang.StringgetSecurityProfileIdentifier()Get securityProfileIdentifierjava.lang.IntegergetTenantId()voidinitIfAbsent(java.lang.Integer tenantId)voidmutateFrom(@NotNull VitamSession newSession)Get the content of a given VitamSession and copy its internal values to the current instancevoidsetApplicationSessionId(java.lang.String applicationSessionId)Set vitam application session idvoidsetContextId(java.lang.String contextId)Set vitam security context idvoidsetContract(AccessContractModel contract)voidsetContractId(java.lang.String contractId)voidsetInternalRequestId(java.lang.String newRequestId)Set the server request idVitamSessionsetOther(java.lang.Object other)voidsetPersonalCertificate(java.lang.String personalCertificate)Set personalCertificatevoidsetRequestId(GUID guid)Sets the request id from the guidvoidsetRequestId(java.lang.String newRequestId)Set the request id and saves it to the MDCvoidsetSecurityProfileIdentifier(java.lang.String securityProfileIdentifier)Set securityProfileIdentifiervoidsetTenantId(java.lang.Integer newTenantId)Sets the tenantIdjava.lang.StringtoString()
-
-
-
Constructor Detail
-
VitamSession
public VitamSession(VitamThreadFactory.VitamThread owningThread)
- Parameters:
owningThread- the owning thread
-
-
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-
-
getContract
public AccessContractModel getContract()
- Returns:
- AccessContractModel
-
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:
toStringin classjava.lang.Object
-
-