@Component
public class RegisterRest
extends java.lang.Object
The RegisterRest class contains different restful services for operations related to phone i)getSessionKeyForCoupon- This Restful WebService will take three three query parameters couponNumber,IMEI,phoneHash and will return the sessionkey on successful registration ii)getQuestionsFromQuestionsTable-This Restful WebService is used to get all the questions for the study iii)getRecentQuestionsFromQuestionsTable-This Restful WebService is used to get the recent questions for the study iv)putAnswer-This Restful WebService is used to insert new answer into the answers table for the particular study v)putAnswers-This Restful WebService is used to insert multiple answers into the answers table for the particular study
Constructor and Description |
---|
RegisterRest() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getQuestions(java.lang.String keyAsString,
java.lang.String isRulesNeeded)
This Restful Web Service takes two query parameters keyAsString and isRulesNeeded
This is used to get all the questions from the questions table for the particular study
RestFul End Point URI: http://host:port/ResearcherService/rest/PhoneService/getQuestionsFromQuestionsTable
REQUEST TYPE: GET
|
java.lang.String |
getSessionKeyForCoupon(java.lang.String couponNumber,
java.lang.String token,
java.lang.String IMEI,
java.lang.String hashPhone,
java.lang.String phoneModel,
java.lang.String osVersion,
java.lang.String apkVersion,
int sleepInterval,
java.lang.String phoneDetails)
This Restful Web Service takes 9 query parameters couponNumber, token, IMEI, hashPhone, phoneModel, apkVersion, osVersion, sleepInterval, phoneDetails
This Rest WebService will generate the sessionkey, if they successfully registered
EndPoint URI: http://host:port/ResearcherService/rest/PhoneService/getSessionKey
REQUEST TYPE: GET
|
java.lang.String |
putAnswers(java.lang.String keyAsString,
java.sql.Timestamp timeOfPhone,
java.lang.String phoneTimeZone,
AnswersList answers)
This Restful Web Service takes three query parameters keyAsString, timeOfPhone,phoneTimeZone and one body param answers object
This is used to insert answer into answer table of particular study related database
RestFul End Point URI: http://host:port/PhoneAppService/rest/PhoneService/putAnswers
REQUEST TYPE: POST
|
java.lang.String |
testNetwork(java.lang.String keyAsString) |
public java.lang.String getSessionKeyForCoupon(java.lang.String couponNumber, java.lang.String token, java.lang.String IMEI, java.lang.String hashPhone, java.lang.String phoneModel, java.lang.String osVersion, java.lang.String apkVersion, int sleepInterval, java.lang.String phoneDetails)
This Restful Web Service takes 9 query parameters couponNumber, token, IMEI, hashPhone, phoneModel, apkVersion, osVersion, sleepInterval, phoneDetails This Rest WebService will generate the sessionkey, if they successfully registered EndPoint URI: http://host:port/ResearcherService/rest/PhoneService/getSessionKey REQUEST TYPE: GET
couponNumber
- - 10 digit unique coupon number entered by study participanttoken
- - token generated by phone for subscribing to aws sns topicIMEI
- - imei of phonehashPhone
- - hash of phone numberphoneModel
- - phone modelapkVersion
- - version of the apk that is using for registrationosVersion
- - os version of phonesleepInterval
- - sleep interval display settings in phone (it says in how many seconds that phone screen will lock if the phone is not active)phoneDetails
- - phoneDetails string can contains any other information related to phone like gps status or wifi statusi)If study is not found for the given coupon then returns json object with fields {"code":500,"message":"sentinel SessionKey encoding error - no such study"} ii)If the study is in preparing state, then returns json object with fields {"code":500,"message":"Study is still preparing-no phones can register"} iii)If the study is completed,then returns json object with fields {"code":500,"message":"Study is Completed-no phones can register"} iv)If the user is registering again with different IMEI/phoneHash then returns json object with fields {"code":500,"message":"Sentinel SessionKey encoding error - duplicate registration attempt"} v) If any of the given parameters is null then returns json object with fields {"code":500,"message":invalid input - can not give null values in query parameters"} vi)If the user registered successfully,then returns json object with fields {jsonResult ={PhoneSessionKey} objects,"code":200,"message":"ok"} vii)If any error occurs then returns json object with fields(code="500",message="error") viii)If couponNumber is invalid then returns json object with fields (code=404, message="error")
public java.lang.String getQuestions(java.lang.String keyAsString, java.lang.String isRulesNeeded)
This Restful Web Service takes two query parameters keyAsString and isRulesNeeded This is used to get all the questions from the questions table for the particular study RestFul End Point URI: http://host:port/ResearcherService/rest/PhoneService/getQuestionsFromQuestionsTable REQUEST TYPE: GET
keyAsString
- - phone session keyisRulesNeeded
- - true or false (String)If session key is invalid, returns json object with fields("code":404,"message":"error") If study is completed, returns json object with fields("code":600,"message":"study is completed") If consent not agreed, returns json object with fields("code":600,"message":"consent not agreed") If study not exists, returns json object with fields ("code":700,message":"study not exists") If session key is valid i)If isRulesNeeded is true, then returns questions json object with fields (jsonResult={questionid,questiontext,c,r},code=200,message="ok") where c is choices of list (questionid, choiceid, choicetext) and r is rules of list (ruleid, questionid, ruletype, ruletext, ruletextcompilable, disablepostfire, maxanswertime,ruleRegistrationPlatform,disabled) ii)If isRulesNeeded is false, then returns questions json object with fields (jsonResult={questionid,questiontext,c},code=200,message="ok") where c is choices of list(questionid, choiceid, choicetext) iii)If any exception occurs then results json object with fields (code=500,message="error")
public java.lang.String putAnswers(java.lang.String keyAsString, java.sql.Timestamp timeOfPhone, java.lang.String phoneTimeZone, AnswersList answers)
This Restful Web Service takes three query parameters keyAsString, timeOfPhone,phoneTimeZone and one body param answers object This is used to insert answer into answer table of particular study related database RestFul End Point URI: http://host:port/PhoneAppService/rest/PhoneService/putAnswers REQUEST TYPE: POST
keyAsString
- PHONE SESSION KEYtimeOfPhone
- current time of phone in timestampphoneTimeZone
- time zone of phoneanswer
- AnswersList OBJECT - json object with field (answers) where answers is a list which contains fields (questionID,choiceID,time,sequenceNumber)If session key is invalid, returns json object with fields("code":404,"message":"error") If study is completed, returns json object with fields("code":600,"message":"study is completed") If consent not agreed, returns json object with fields("code":600,"message":"consent not agreed") If study not exists, returns json object with fields ("code":700,message":"study not exists") If session key is valid - If all answers inserted successfully then returns json object with fields("jsonResult":[listofallanswers],"code":200,"message":"all answers inserted successfully") - If all answers failed to insert then returns json object with fields(code":501,"message":"all answers not inserted") - If some of the answers not inserted then returns json object with fields("jsonResult":[UnsuccesfulAnswers],"code":502,"message":"some answers not inserted") -If any exception occurs then returns json object with fields (code=500,message="error")
public java.lang.String testNetwork(java.lang.String keyAsString)