Package services.publix.workers
Class GeneralSingleCookieService
- java.lang.Object
-
- services.publix.workers.GeneralSingleCookieService
-
@Singleton public class GeneralSingleCookieService extends java.lang.ObjectManages the GeneralSingle cookie. This cookie exists only with GeneralSingle workers. In this cookie is stored which studies where done in the browser where the cookie originates. This provides an easy way to check whether a GeneralSingle worker tries to run the same study a second time (which is not allowed). Note, that it is easy to get around this mechanism by deleting the cookie in the browser. A GeneralSingle cookie consists of a list of tuples storing the study ID and worker ID. With the cookie's data it is possible to determine whether in this browser this study was done already with a GeneralSingle worker and by which worker it was done.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOOKIE_NAME
-
Constructor Summary
Constructors Constructor Description GeneralSingleCookieService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringaddStudy(Study study, Worker worker, play.mvc.Http.Cookie generalSingleCookie)If the cookie is not null it adds a new tuple (study's UUID and worker ID) to the cookie's value and returns it.java.lang.LongfetchWorkerIdByStudy(Study study)Returns the worker ID of the GeneralSingleWorker that belongs to the given study - or null, if it doesn't exist.voidset(java.lang.String cookieValue)Sets the cookieValue as the new GeneralSingle cookie.voidset(Study study, Worker worker)Sets the cookie in the response.
-
-
-
Field Detail
-
COOKIE_NAME
public static final java.lang.String COOKIE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
fetchWorkerIdByStudy
public java.lang.Long fetchWorkerIdByStudy(Study study)
Returns the worker ID of the GeneralSingleWorker that belongs to the given study - or null, if it doesn't exist. If the study was run before the study UUID has been stored together with the worker ID in the cookie.
-
set
public void set(java.lang.String cookieValue)
Sets the cookieValue as the new GeneralSingle cookie. This cookie is HTTP only and has an expire date in the far future.
-
set
public void set(Study study, Worker worker)
Sets the cookie in the response. The cookie will contain all GeneralSingle studies done in this browser and adds the given study (and worker). This cookie is HTTP only and has an expire date in the far future.
-
addStudy
public java.lang.String addStudy(Study study, Worker worker, play.mvc.Http.Cookie generalSingleCookie)
If the cookie is not null it adds a new tuple (study's UUID and worker ID) to the cookie's value and returns it. If the cookie is null (this browser never did a general single run) it returns the new cookie's value which is just the tuple.
-
-