Package services.publix.idcookie
Class IdCookieService
- java.lang.Object
-
- services.publix.idcookie.IdCookieService
-
@Singleton public class IdCookieService extends java.lang.ObjectService class for JATOS ID cookie handling. It generates, extracts and discards ID cookies. An ID cookie is used by the JATOS server to tell jatos.js about several IDs the current study run has (e.g. worker ID, study ID, study result ID). This cookie is created when the study run is started and discarded when it's done. If all possible cookies are used, the start of a new study will cause the oldest ID cookie to be overwritten.
-
-
Constructor Summary
Constructors Constructor Description IdCookieService(IdCookieAccessor idCookieAccessor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddiscardIdCookie(java.lang.Long studyResultId)Discards the ID cookie if the given study result ID is equal to the one in the cookie.IdCookieModelgetIdCookie(java.lang.Long studyResultId)Returns the IdCookieModel that corresponds to the given study result ID.IdCookieModelgetOldestIdCookie()Checks the creation time of each ID cookie in the given IdCookieCollection and returns the oldest one.java.lang.LonggetStudyResultIdFromOldestIdCookie()Checks the creation time of each ID cookie in the given IdCookieCollection and returns the study result ID of the oldest one.booleanhasIdCookie(java.lang.Long studyResultId)booleanmaxIdCookiesReached()Returns true if the max number of ID cookies has been reached and false otherwise.booleanoneIdCookieHasThisStudyAssets(java.lang.String studyAssets)Returns true if the study assets of at least one ID cookie is equal to the given study assets.voidwriteIdCookie(StudyResult studyResult)Generates an ID cookie from the given parameters and sets it in the response object.voidwriteIdCookie(StudyResult studyResult, JatosPublix.JatosRun jatosRun)Generates an ID cookie from the given parameters and sets it in the response object.voidwriteIdCookie(StudyResult studyResult, ComponentResult componentResult)Generates an ID cookie from the given parameters and sets it in the response object.voidwriteIdCookie(StudyResult studyResult, ComponentResult componentResult, JatosPublix.JatosRun jatosRun)Generates an ID cookie from the given parameters and sets it in the Response object.
-
-
-
Constructor Detail
-
IdCookieService
@Inject public IdCookieService(IdCookieAccessor idCookieAccessor)
-
-
Method Detail
-
hasIdCookie
public boolean hasIdCookie(java.lang.Long studyResultId) throws InternalServerErrorPublixException
-
getIdCookie
public IdCookieModel getIdCookie(java.lang.Long studyResultId) throws BadRequestPublixException, InternalServerErrorPublixException
Returns the IdCookieModel that corresponds to the given study result ID. If the cookie doesn't exist it throws a BadRequestPublixException.
-
oneIdCookieHasThisStudyAssets
public boolean oneIdCookieHasThisStudyAssets(java.lang.String studyAssets) throws InternalServerErrorPublixExceptionReturns true if the study assets of at least one ID cookie is equal to the given study assets. Otherwise, returns false.
-
writeIdCookie
public void writeIdCookie(StudyResult studyResult) throws InternalServerErrorPublixException
Generates an ID cookie from the given parameters and sets it in the response object.
-
writeIdCookie
public void writeIdCookie(StudyResult studyResult, ComponentResult componentResult) throws InternalServerErrorPublixException
Generates an ID cookie from the given parameters and sets it in the response object.
-
writeIdCookie
public void writeIdCookie(StudyResult studyResult, JatosPublix.JatosRun jatosRun) throws InternalServerErrorPublixException
Generates an ID cookie from the given parameters and sets it in the response object.
-
writeIdCookie
public void writeIdCookie(StudyResult studyResult, ComponentResult componentResult, JatosPublix.JatosRun jatosRun) throws InternalServerErrorPublixException
Generates an ID cookie from the given parameters and sets it in the Response object. Checks if there is an existing ID cookie with the same study result ID and if so overwrites it. If there isn't it writes a new one. It expects a free spot in the cookie collection and if not throws an InternalServerErrorPublixException (should never happen). The deletion of the oldest cookie must have happened beforehand.
-
discardIdCookie
public void discardIdCookie(java.lang.Long studyResultId) throws InternalServerErrorPublixExceptionDiscards the ID cookie if the given study result ID is equal to the one in the cookie.
-
maxIdCookiesReached
public boolean maxIdCookiesReached() throws InternalServerErrorPublixExceptionReturns true if the max number of ID cookies has been reached and false otherwise.
-
getOldestIdCookie
public IdCookieModel getOldestIdCookie() throws InternalServerErrorPublixException
Checks the creation time of each ID cookie in the given IdCookieCollection and returns the oldest one. Returns null if the IdCookieCollection is empty.
-
getStudyResultIdFromOldestIdCookie
public java.lang.Long getStudyResultIdFromOldestIdCookie() throws InternalServerErrorPublixExceptionChecks the creation time of each ID cookie in the given IdCookieCollection and returns the study result ID of the oldest one. Returns null if the IdCookieCollection is empty.
-
-