Package org.ametys.plugins.survey.answer
Class ProcessInputAction
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.acting.AbstractAction
org.apache.cocoon.acting.ServiceableAction
org.ametys.plugins.survey.answer.ProcessInputAction
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,Action
- Direct Known Subclasses:
ProcessMiniSurveyAction
Process the user answers to the survey.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Survey session with answers.class
Class representing a survey answer, i.e. -
Field Summary
Modifier and TypeFieldDescriptionprotected SurveyAccessHelper
The survey access helperprotected SurveyAnswerDao
The ametys object resolver.protected String
The plugin nameprotected URIPrefixHandler
The uri prefix handler.protected AmetysObjectResolver
The ametys object resolver.protected CurrentUserProvider
The user provider.static final String
The name of the cookie storing the taken surveys.Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionact
(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 surveyprotected 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 userprotected final String
getClientIp
(Request request) Get a forwarded client IP address if available.protected ProcessInputAction.SurveyInput
Get the user input.protected String
getPluginName
(Request request) Get the plugin namegetValues
(SurveyQuestion question, Request request) Get an answer value from the request.protected boolean
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
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.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
COOKIE_NAME
The name of the cookie storing the taken surveys.- See Also:
-
_resolver
The ametys object resolver. -
_answerDao
The ametys object resolver. -
_userProvider
The user provider. -
_prefixHandler
The uri prefix handler. -
_accessHelper
The survey access helper -
_pluginName
The plugin name
-
-
Constructor Details
-
ProcessInputAction
public ProcessInputAction()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableAction
- Throws:
ServiceException
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception - Throws:
Exception
-
getPluginName
Get the plugin name- Parameters:
request
- The request- Returns:
- The plugin name
-
checkAccess
Check if user can answer to the survey- Parameters:
survey
- The surveyrequest
- The requesterrors
- The survey errors- Returns:
- false if the access failed
-
getAuthenticatedUser
Get the authenticated user- Parameters:
request
- The request- Returns:
- The authenticated user
-
getInput
Get the user input.- Parameters:
survey
- the survey.request
- the request.- Returns:
- the user input.
-
getValues
Get an answer value from the request.- Parameters:
question
- the corresponding question.request
- the request.- Returns:
- the answer value.
-
validateInput
protected void validateInput(Survey survey, ProcessInputAction.SurveyInput input, SurveyErrors errors, Request request) Validate the user input.- Parameters:
survey
- the survey.input
- the user input.errors
- the errors.request
- the request.
-
processPage
Test if a page is to be processed, depending on the rule.- Parameters:
page
- the page to test.rule
- the rule to execute.- Returns:
- true to process the page, false otherwise.
-
evaluateTextRules
protected SurveyRule evaluateTextRules(SurveyQuestion question, ProcessInputAction.SurveyInputAnswer answer) Evaluate rules on a text question.- Parameters:
question
- the text question.answer
- the user answer to the question.- Returns:
- the matched rule.
-
evaluateChoiceRules
protected SurveyRule evaluateChoiceRules(SurveyQuestion question, ProcessInputAction.SurveyInputAnswer answer) Evaluate rules on a choice question.- Parameters:
question
- the choice question.answer
- the user answer to the question.- Returns:
- the matched rule.
-
evaluateMatrixRules
protected SurveyRule evaluateMatrixRules(SurveyQuestion question, ProcessInputAction.SurveyInputAnswer answer) Evaluate rules on a matrix question.- Parameters:
question
- the matrix question.answer
- the user answer to the question.- Returns:
- the matched rule.
-
validateText
protected List<I18nizableText> validateText(ProcessInputAction.SurveyInputAnswer answer, Request request) Validate a text field.- Parameters:
answer
- the user answer to the question.request
- the request.- Returns:
- the error list.
-
validateChoice
protected List<I18nizableText> validateChoice(ProcessInputAction.SurveyInputAnswer answer, Request request) Validate a choice question answer.- Parameters:
answer
- the user answer to the question.request
- the request.- Returns:
- the error list.
-
validateMatrix
protected List<I18nizableText> validateMatrix(ProcessInputAction.SurveyInputAnswer answer, Request request) Validate a matrix question answer.- Parameters:
answer
- the user answer to the question.request
- the request.- Returns:
- the error list.
-
validatePattern
protected List<I18nizableText> validatePattern(ProcessInputAction.SurveyInputAnswer answer, String keyPrefix) Validate an answer against a pattern.- Parameters:
answer
- the user answer to the question.keyPrefix
- the error i18n key prefix.- Returns:
- the error list.
-
isBlank
Test if the answer is empty.- Parameters:
answer
- the user answer.- Returns:
- true if the answer is empty.
-
setCookie
Indicate in a cookie that the survey was taken.- Parameters:
request
- the request.response
- the response.surveyId
- the ID of the survey that was just taken.
-
getClientIp
Get a forwarded client IP address if available.- Parameters:
request
- The servlet request object.- Returns:
- The HTTP
X-Forwarded-For
header value if present, or the default remote address if not.
-