@Api(name="SurveyPortlet services",
description="Methods for managing surveys")
@Controller
@RequestMapping(value="/v1/surveys",
produces="application/json")
public class SurveyRestController
extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
REQUEST_ROOT |
| Constructor and Description |
|---|
SurveyRestController() |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.http.ResponseEntity<QuestionDTO> |
addQuestion(QuestionDTO question)
Create a new question that is not associated with a survey.
|
org.springframework.http.ResponseEntity<ResponseDTO> |
addResponse(ResponseDTO response,
Principal principal)
Create a user's response (answers)
|
org.springframework.http.ResponseEntity<SurveyDTO> |
addSurvey(SurveyDTO survey,
Principal principal)
Create a survey
|
org.springframework.http.ResponseEntity<ITextGroup> |
addTextGroup(TextGroupImpl textGroup)
Create a text group
|
org.springframework.http.ResponseEntity<List<SurveyDTO>> |
getAllSurveys()
Search for all surveys
|
org.springframework.http.ResponseEntity<ResponseDTO> |
getResponse(Long responseId,
javax.servlet.http.HttpServletRequest req,
Principal principal)
Fetch a user's answers by id
|
org.springframework.http.ResponseEntity<ResponseDTO> |
getResponseBySurveyAndUser(Long surveyId,
javax.servlet.http.HttpServletRequest req,
Principal principal)
Fetch one's own answers for the specified survey
|
org.springframework.http.ResponseEntity<SurveyDTO> |
getSurvey(Long survey)
Fetch a survey by id
|
org.springframework.http.ResponseEntity<SurveyDTO> |
getSurvey(String surveyName)
Fetch a survey by name
|
org.springframework.http.ResponseEntity<List<SurveyQuestionDTO>> |
getSurveyQuestions(Long survey)
Search for questions/answers that are associated with the specified survey.
|
org.springframework.web.servlet.ModelAndView |
getSurveyReport(Long responseId,
javax.servlet.http.HttpServletRequest req,
Principal principal)
Provides a visual (HTML) report based an individual user's responses to
a survey.
|
org.springframework.http.ResponseEntity<SurveySummaryDTO> |
getSurveySummary(Long survey)
Return summary of user responses for a survey.
|
org.springframework.http.ResponseEntity<ITextGroup> |
getTextGroup(String textKey)
Fetch method for getting text detail by key.
|
org.springframework.http.ResponseEntity<Boolean> |
linkQuestionToSurvey(Long survey,
Long question,
SurveyQuestionDTO surveyQuestion)
Associate an existing question to an existing survey
|
org.springframework.http.ResponseEntity<QuestionDTO> |
updateQuestion(Long questionId,
QuestionDTO question)
Update a question
|
org.springframework.http.ResponseEntity<ResponseDTO> |
updateResponse(Long responseId,
String body,
javax.servlet.http.HttpServletRequest req,
Principal principal)
Update user's answers
|
org.springframework.http.ResponseEntity<SurveyDTO> |
updateSurvey(Long surveyId,
SurveyDTO survey,
Principal principal)
Update survey
|
public static final String REQUEST_ROOT
@PreAuthorize(value="hasRole(\'SURVEY_ADMIN\')")
@ApiMethod(description="Create a new question that is not associated with a survey.",
responsestatuscode="201 - Created")
@RequestMapping(method=POST,
value="/questions")
@ApiResponseObject
public org.springframework.http.ResponseEntity<QuestionDTO> addQuestion(@ApiBodyObject @RequestBody
QuestionDTO question)
Security: Requires SURVEY_ADMIN.
question - @PreAuthorize(value="hasRole(\'SURVEY_ADMIN\')")
@ApiMethod(description="Create a survey",
responsestatuscode="201")
@RequestMapping(method=POST,
value="/")
@ApiResponseObject
public org.springframework.http.ResponseEntity<SurveyDTO> addSurvey(@ApiBodyObject @RequestBody
SurveyDTO survey,
Principal principal)
Security: Requires SURVEY_ADMIN.
survey - @PreAuthorize(value="hasRole(\'SURVEY_ADMIN\')")
@ApiMethod(description="Create a text group",
responsestatuscode="201")
@RequestMapping(method=POST,
value="/textGroup")
@ApiResponseObject
public org.springframework.http.ResponseEntity<ITextGroup> addTextGroup(@ApiBodyObject @RequestBody
TextGroupImpl textGroup)
Security: Requires SURVEY_ADMIN.
@PreAuthorize(value="hasRole(\'SURVEY_USER\')")
@ApiMethod(description="Fetch all surveys",
responsestatuscode="201")
@RequestMapping(method=GET,
value="/")
@ApiResponseObject
public org.springframework.http.ResponseEntity<List<SurveyDTO>> getAllSurveys()
Security: Requires SURVEY_USER.
@PreAuthorize(value="hasRole(\'SURVEY_USER\')")
@ApiMethod(description="Fetch a survey by id",
responsestatuscode="201")
@RequestMapping(method=GET,
value="/{survey}")
@ApiResponseObject
public org.springframework.http.ResponseEntity<SurveyDTO> getSurvey(@ApiPathParam(name="survey") @PathVariable
Long survey)
Security: Requires SURVEY_USER.
@PreAuthorize(value="hasRole(\'SURVEY_USER\')")
@ApiMethod(description="Fetch a survey by name",
responsestatuscode="201")
@RequestMapping(method=GET,
value="/surveyByName/{surveyName}")
public org.springframework.http.ResponseEntity<SurveyDTO> getSurvey(@ApiPathParam(name="surveyName") @PathVariable
String surveyName)
Security: Requires SURVEY_USER.
@PreAuthorize(value="hasRole(\'SURVEY_USER\')")
@ApiMethod
@RequestMapping(method=GET,
value="/{survey}/questions")
public org.springframework.http.ResponseEntity<List<SurveyQuestionDTO>> getSurveyQuestions(@ApiPathParam(name="survey") @PathVariable
Long survey)
Security: Requires SURVEY_USER.
@PreAuthorize(value="hasRole(\'SURVEY_USER\')")
@ApiMethod(description="Fetch a text group by key",
responsestatuscode="201")
@RequestMapping(method=GET,
value="/textGroup/{textKey}")
public org.springframework.http.ResponseEntity<ITextGroup> getTextGroup(@PathVariable
String textKey)
Security: Requires SURVEY_USER.
@PreAuthorize(value="hasRole(\'SURVEY_ADMIN\')")
@ApiMethod(description="Associate an existing question to an existing survey",
responsestatuscode="201")
@RequestMapping(method=POST,
value="/{survey}/questions/{question}")
@ApiResponseObject
public org.springframework.http.ResponseEntity<Boolean> linkQuestionToSurvey(@ApiPathParam(name="survey") @PathVariable
Long survey,
@ApiPathParam(name="question") @PathVariable
Long question,
@ApiBodyObject @RequestBody
SurveyQuestionDTO surveyQuestion)
Security: Requires SURVEY_ADMIN.
@PreAuthorize(value="hasRole(\'SURVEY_ADMIN\')")
@ApiMethod(description="Update a question",
responsestatuscode="201 - Created")
@RequestMapping(method=PUT,
value="/questions/{questionId}")
public org.springframework.http.ResponseEntity<QuestionDTO> updateQuestion(@ApiPathParam(name="questionId") @PathVariable
Long questionId,
@ApiBodyObject @RequestBody
QuestionDTO question)
Security: Requires SURVEY_ADMIN.
@PreAuthorize(value="hasRole(\'SURVEY_ADMIN\')")
@ApiMethod(description="Update survey",
responsestatuscode="201 - Created")
@RequestMapping(method=PUT,
value="/{surveyId}")
public org.springframework.http.ResponseEntity<SurveyDTO> updateSurvey(@ApiPathParam(name="surveyId") @PathVariable
Long surveyId,
@ApiBodyObject @RequestBody
SurveyDTO survey,
Principal principal)
Security: Requires SURVEY_ADMIN.
@PreAuthorize(value="hasRole(\'SURVEY_USER\')")
@ApiMethod(description="Fetch a user\'s answers for the specified survey",
responsestatuscode="201")
@RequestMapping(method=GET,
value="/surveyAnswers")
@ApiResponseObject
public org.springframework.http.ResponseEntity<ResponseDTO> getResponseBySurveyAndUser(@RequestParam(value="survey")
Long surveyId,
javax.servlet.http.HttpServletRequest req,
Principal principal)
Security: Requires SURVEY_USER.
@PreAuthorize(value="hasRole(\'SURVEY_USER\')")
@ApiMethod(description="Fetch a user\'s answers by id",
responsestatuscode="201")
@RequestMapping(method=GET,
value="/surveyAnswers/{responseId}")
@ApiResponseObject
public org.springframework.http.ResponseEntity<ResponseDTO> getResponse(@ApiPathParam(name="responseId") @PathVariable
Long responseId,
javax.servlet.http.HttpServletRequest req,
Principal principal)
Security: Requires SURVEY_USER. Users may GET their own ResponseDTO; to obtain a ResponseDTO for another user, you must belong to one of viewOtherUsersResponseRoles.
@PreAuthorize(value="hasRole(\'SURVEY_USER\')")
@ApiMethod(description="Create a user\'s response (answers)",
responsestatuscode="201")
@RequestMapping(method=POST,
value="/surveyAnswers")
@ApiResponseObject
public org.springframework.http.ResponseEntity<ResponseDTO> addResponse(@ApiBodyObject @RequestBody
ResponseDTO response,
Principal principal)
Security: Requires SURVEY_USER.
@PreAuthorize(value="hasRole(\'SURVEY_USER\')")
@ApiMethod(description="Update user\'s answers",
responsestatuscode="201")
@RequestMapping(method=PUT,
value="/surveyAnswers/{responseId}")
@ApiResponseObject
public org.springframework.http.ResponseEntity<ResponseDTO> updateResponse(@ApiPathParam(name="responseId") @PathVariable
Long responseId,
@ApiBodyObject @RequestBody
String body,
javax.servlet.http.HttpServletRequest req,
Principal principal)
Security: Requires SURVEY_USER. Can only PUT data owned by the currently authenticated Principal.
@PreAuthorize(value="hasRole(\'SURVEY_ADMIN\')")
@ApiMethod(description="Return summary of user response for a survey",
responsestatuscode="201")
@RequestMapping(method=GET,
value="/{survey}/summary")
@ApiResponseObject
public org.springframework.http.ResponseEntity<SurveySummaryDTO> getSurveySummary(@ApiPathParam(name="survey") @PathVariable
Long survey)
Security: Requires SURVEY_ADMIN. (Should it?)
@PreAuthorize(value="hasRole(\'SURVEY_USER\')")
@ApiMethod(description="Fetch the post-survey report that was generated based on the user\'s answers",
responsestatuscode="201")
@RequestMapping(method=GET,
value="/surveyReport/{responseId}")
@ApiResponseObject
public org.springframework.web.servlet.ModelAndView getSurveyReport(@ApiPathParam(name="responseId") @PathVariable
Long responseId,
javax.servlet.http.HttpServletRequest req,
Principal principal)
Security: Requires SURVEY_USER. Users may GET their own report; to obtain a report for another user, you must belong to one of viewOtherUsersResponseRoles.
Copyright © 2016 Jasig. All rights reserved.