Package fr.gouv.vitam.common.model
Class VitamSession
- java.lang.Object
-
- fr.gouv.vitam.common.model.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.
-
-
Constructor Summary
Constructors Constructor Description VitamSession(VitamThreadFactory.VitamThread owningThread)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkValidRequestId()
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.java.lang.String
getApplicationSessionId()
Get vitam application session idjava.lang.String
getContextId()
Get vitam security context idAccessContractModel
getContract()
java.lang.String
getContractId()
java.lang.String
getInternalRequestId()
Get the server request idjava.lang.Object
getOther()
java.lang.String
getPersonalCertificate()
Get personalCertificatejava.lang.String
getRequestId()
java.lang.String
getSecurityProfileIdentifier()
Get securityProfileIdentifierjava.lang.Integer
getTenantId()
void
initIfAbsent(java.lang.Integer tenantId)
void
mutateFrom(@NotNull VitamSession newSession)
Get the content of a given VitamSession and copy its internal values to the current instancevoid
setApplicationSessionId(java.lang.String applicationSessionId)
Set vitam application session idvoid
setContextId(java.lang.String contextId)
Set vitam security context idvoid
setContract(AccessContractModel contract)
void
setContractId(java.lang.String contractId)
void
setInternalRequestId(java.lang.String newRequestId)
Set the server request idVitamSession
setOther(java.lang.Object other)
void
setPersonalCertificate(java.lang.String personalCertificate)
Set personalCertificatevoid
setRequestId(GUID guid)
Sets the request id from the guidvoid
setRequestId(java.lang.String newRequestId)
Set the request id and saves it to the MDCvoid
setSecurityProfileIdentifier(java.lang.String securityProfileIdentifier)
Set securityProfileIdentifiervoid
setTenantId(java.lang.Integer newTenantId)
Sets the tenantIdjava.lang.String
toString()
-
-
-
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:
toString
in classjava.lang.Object
-
-