public class ProcessInputAction extends ServiceableAction
Modifier and Type | Class and Description |
---|---|
protected class |
ProcessInputAction.SurveyInput
Survey session with answers.
|
protected class |
ProcessInputAction.SurveyInputAnswer
Class representing a survey answer, i.e.
|
Modifier and Type | Field and Description |
---|---|
protected SurveyAccessHelper |
_accessHelper
The survey access helper
|
protected SurveyAnswerDao |
_answerDao
The ametys object resolver.
|
protected String |
_pluginName
The plugin name
|
protected URIPrefixHandler |
_prefixHandler
The uri prefix handler.
|
protected AmetysObjectResolver |
_resolver
The ametys object resolver.
|
private RightManager |
_rightManager |
protected CurrentUserProvider |
_userProvider
The user provider.
|
static String |
COOKIE_NAME
The name of the cookie storing the taken surveys.
|
manager
EMPTY_MAP
Constructor and Description |
---|
ProcessInputAction() |
Modifier and Type | Method and Description |
---|---|
Map |
act(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String source,
Parameters parameters) |
protected boolean |
checkAccess(Survey survey,
Request request,
SurveyErrors errors)
Check if user can answer to the survey
|
protected SurveyRule |
evaluateChoiceRules(SurveyQuestion question,
ProcessInputAction.SurveyInputAnswer answer)
Evaluate rules on a choice question.
|
protected SurveyRule |
evaluateMatrixRules(SurveyQuestion question,
ProcessInputAction.SurveyInputAnswer answer)
Evaluate rules on a matrix question.
|
protected SurveyRule |
evaluateTextRules(SurveyQuestion question,
ProcessInputAction.SurveyInputAnswer answer)
Evaluate rules on a text question.
|
protected UserIdentity |
getAuthenticatedUser(Request request)
Get the authenticated user
|
protected String |
getClientIp(Request request)
Get a forwarded client IP address if available.
|
protected ProcessInputAction.SurveyInput |
getInput(Survey survey,
Request request)
Get the user input.
|
protected String |
getPluginName(Request request)
Get the plugin name
|
protected Map<String,Set<String>> |
getValues(SurveyQuestion question,
Request request)
Get an answer value from the request.
|
protected boolean |
isBlank(ProcessInputAction.SurveyInputAnswer answer)
Test if the answer is empty.
|
protected boolean |
processPage(SurveyPage page,
SurveyRule rule)
Test if a page is to be processed, depending on the rule.
|
void |
service(ServiceManager serviceManager) |
protected void |
setCookie(Request request,
Response response,
String surveyId)
Indicate in a cookie that the survey was taken.
|
protected List<I18nizableText> |
validateChoice(ProcessInputAction.SurveyInputAnswer answer,
Request request)
Validate a choice question answer.
|
protected void |
validateInput(Survey survey,
ProcessInputAction.SurveyInput input,
SurveyErrors errors,
Request request)
Validate the user input.
|
protected List<I18nizableText> |
validateMatrix(ProcessInputAction.SurveyInputAnswer answer,
Request request)
Validate a matrix question answer.
|
protected List<I18nizableText> |
validatePattern(ProcessInputAction.SurveyInputAnswer answer,
String keyPrefix)
Validate an answer against a pattern.
|
protected List<I18nizableText> |
validateText(ProcessInputAction.SurveyInputAnswer answer,
Request request)
Validate a text field.
|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
public static final String COOKIE_NAME
protected AmetysObjectResolver _resolver
protected SurveyAnswerDao _answerDao
protected CurrentUserProvider _userProvider
protected URIPrefixHandler _prefixHandler
protected SurveyAccessHelper _accessHelper
protected String _pluginName
private RightManager _rightManager
public ProcessInputAction()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
service
in class ServiceableAction
ServiceException
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception
Exception
protected String getPluginName(Request request)
request
- The requestprotected boolean checkAccess(Survey survey, Request request, SurveyErrors errors)
survey
- The surveyrequest
- The requesterrors
- The survey errorsprotected UserIdentity getAuthenticatedUser(Request request)
request
- The requestprotected ProcessInputAction.SurveyInput getInput(Survey survey, Request request)
survey
- the survey.request
- the request.protected Map<String,Set<String>> getValues(SurveyQuestion question, Request request)
question
- the corresponding question.request
- the request.protected void validateInput(Survey survey, ProcessInputAction.SurveyInput input, SurveyErrors errors, Request request)
survey
- the survey.input
- the user input.errors
- the errors.request
- the request.protected boolean processPage(SurveyPage page, SurveyRule rule)
page
- the page to test.rule
- the rule to execute.protected SurveyRule evaluateTextRules(SurveyQuestion question, ProcessInputAction.SurveyInputAnswer answer)
question
- the text question.answer
- the user answer to the question.protected SurveyRule evaluateChoiceRules(SurveyQuestion question, ProcessInputAction.SurveyInputAnswer answer)
question
- the choice question.answer
- the user answer to the question.protected SurveyRule evaluateMatrixRules(SurveyQuestion question, ProcessInputAction.SurveyInputAnswer answer)
question
- the matrix question.answer
- the user answer to the question.protected List<I18nizableText> validateText(ProcessInputAction.SurveyInputAnswer answer, Request request)
answer
- the user answer to the question.request
- the request.protected List<I18nizableText> validateChoice(ProcessInputAction.SurveyInputAnswer answer, Request request)
answer
- the user answer to the question.request
- the request.protected List<I18nizableText> validateMatrix(ProcessInputAction.SurveyInputAnswer answer, Request request)
answer
- the user answer to the question.request
- the request.protected List<I18nizableText> validatePattern(ProcessInputAction.SurveyInputAnswer answer, String keyPrefix)
answer
- the user answer to the question.keyPrefix
- the error i18n key prefix.protected boolean isBlank(ProcessInputAction.SurveyInputAnswer answer)
answer
- the user answer.protected void setCookie(Request request, Response response, String surveyId)
request
- the request.response
- the response.surveyId
- the ID of the survey that was just taken.protected final String getClientIp(Request request)
request
- The servlet request object.X-Forwarded-For
header value if present,
or the default remote address if not.