Class ProcessFormAction
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.acting.AbstractAction
org.apache.cocoon.acting.ServiceableAction
org.ametys.plugins.forms.processing.ProcessFormAction
- All Implemented Interfaces:
Component
,Contextualizable
,LogEnabled
,Serviceable
,Action
Action that processes the user submitted data on a form.
-
Field Summary
Modifier and TypeFieldDescriptionprotected AmetysObjectResolver
The ametys object resolverprotected Context
The contextprotected CurrentUserProvider
current user providerprotected static final DateFormat
The date format pattern.protected static final Pattern
The integer validation pattern.protected static final DateFormat
The date and time format pattern.protected static final Pattern
The integer validation pattern.protected static final Pattern
The email validation pattern.protected static final Pattern
The integer validation pattern.protected FormPropertiesManager
Form properties manager.protected FormTableManager
Form table manager.protected static final Pattern
The integer validation pattern.protected static final Pattern
The phone validation pattern.protected String
The plugin name.protected URIPrefixHandler
The URI prefix handlerprotected RightManager
Rights managerprotected SiteManager
The site manager.protected SourceResolver
The source resolver.protected SQLDatabaseTypeExtensionPoint
The SQLDatabaseTypeExtensionPoint instanceprotected static final DateFormat
The time format pattern.protected static final Pattern
The integer validation pattern.protected WorkflowHelper
The workflow helper componentprotected WorkflowProvider
The workflow providerprotected static final String
The content ID parameter.protected static final String
The form ID parameter.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 TypeMethodDescriptionprotected Collection<FieldValue>
_getEntriesToInsert
(Collection<FieldValue> entries) Retain only the entries that are to be inserted in the database.protected FieldValue
_getFileEntry
(Request request, Field field, String id, String name, FormErrors errors) Get a file entry from the request.protected Collection<File>
_getFiles
(Map<String, FieldValue> input) Get the files of a user input.protected Map<String,
FieldValue> _getInput
(Form form, Request request, FormErrors errors) Get the user input.protected String
Get a mail pipeline's content.protected boolean
_insertInput
(Form form, Map<String, FieldValue> input, Map objectModel) Insert the user submission in the database.protected void
_sendEmails
(Form form, Map<String, FieldValue> input, Site site, Integer totalSubmissions) Send the receipt and notification emails.protected void
_sendLimitEmail
(Form form, Map<String, FieldValue> input, String sender) Send the limit email.protected void
_sendNotificationEmails
(Form form, Map<String, FieldValue> input, String sender) Send the notification emails.protected void
_sendReceiptEmail
(Form form, Map<String, FieldValue> input, String sender) Send the receipt email.protected void
_setParameters
(Form form, Map<String, FieldValue> input, PreparedStatement stmt, String dbType) Set the parameters into the prepared statement.protected List<I18nizableText>
_validateCaptcha
(FieldValue entry, Request request) Validate a captcha.protected List<I18nizableText>
_validateCheckbox
(FieldValue entry, Request request) Validate a checkbox input.protected List<I18nizableText>
_validateConfirmation
(FieldValue entry, Request request, String keyPrefix) Validate a confirmation.protected List<I18nizableText>
_validateFile
(FieldValue entry, Request request) Validate a file input.protected void
_validateInput
(Form form, Map<String, FieldValue> input, FormErrors errors, Request request) Validate the user input.protected List<I18nizableText>
_validateMandatory
(FieldValue entry, String keyPrefix) Validate a mandatory field.protected List<I18nizableText>
_validatePassword
(FieldValue entry, Request request) Validate a password field.protected List<I18nizableText>
_validateRadio
(FieldValue entry, Request request) Validate a radio input.protected List<I18nizableText>
_validateSelect
(FieldValue entry, Request request) Validate a select input.protected List<I18nizableText>
_validateTextarea
(FieldValue entry, Request request) Validate a textarea.protected List<I18nizableText>
_validateTextField
(FieldValue entry, Request request) Validate a text field.act
(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) void
contextualize
(Context context) void
service
(ServiceManager serviceManager) Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
PARAM_FORM_ID
The form ID parameter.- See Also:
-
PARAM_CONTENT_ID
The content ID parameter.- See Also:
-
_INT_PATTERN
The integer validation pattern. -
_FLOAT_PATTERN
The integer validation pattern. -
_DATE_PATTERN
The integer validation pattern. -
_TIME_PATTERN
The integer validation pattern. -
_DATETIME_PATTERN
The integer validation pattern. -
_EMAIL_PATTERN
The email validation pattern. -
_PHONE_PATTERN
The phone validation pattern. -
_DATE_FORMAT
The date format pattern. -
_TIME_FORMAT
The time format pattern. -
_DATETIME_FORMAT
The date and time format pattern. -
_formPropertiesManager
Form properties manager. -
_formTableManager
Form table manager. -
_sourceResolver
The source resolver. -
_ametysObjectResolver
The ametys object resolver -
_siteManager
The site manager. -
_pluginName
The plugin name. -
_prefixHandler
The URI prefix handler -
_workflowProvider
The workflow provider -
_workflowHelper
The workflow helper component -
_sqlDatabaseTypeExtensionPoint
The SQLDatabaseTypeExtensionPoint instance -
_context
The context -
_rightManager
Rights manager -
_currentUserProvied
current user provider
-
-
Constructor Details
-
ProcessFormAction
public ProcessFormAction()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
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 -
_getInput
Get the user input.- Parameters:
form
- the Form object.request
- the user request.errors
- the input errors.- Returns:
- the user data as a Map of column name -> column entry.
-
_getFileEntry
protected FieldValue _getFileEntry(Request request, Field field, String id, String name, FormErrors errors) Get a file entry from the request.- Parameters:
request
- the user request.field
- the field.id
- the entry ID.name
- the field name.errors
- the form errors.- Returns:
- the file entry.
-
_insertInput
protected boolean _insertInput(Form form, Map<String, FieldValue> input, Map objectModel) throws com.opensymphony.workflow.WorkflowException, InvalidModificationExceptionInsert the user submission in the database.- Parameters:
form
- the Form object.input
- the user input.objectModel
- The object model- Returns:
- true if the insertion has succeed
- Throws:
com.opensymphony.workflow.WorkflowException
- if an exception occurs while initializing a workflow instance for a form entryInvalidModificationException
- If an error occurs
-
_setParameters
protected void _setParameters(Form form, Map<String, FieldValue> input, PreparedStatement stmt, String dbType) throws SQLException, com.opensymphony.workflow.WorkflowExceptionSet the parameters into the prepared statement.- Parameters:
form
- the form.input
- the user input.stmt
- the prepared statement.dbType
- the database type.- Throws:
SQLException
- if a SQL error occurs.com.opensymphony.workflow.WorkflowException
- if an exception occurs while initializing a workflow instance for a form entry
-
_validateInput
protected void _validateInput(Form form, Map<String, FieldValue> input, FormErrors errors, Request request) Validate the user input.- Parameters:
form
- the Form object.input
- the user input.errors
- the FormErrors object to fill.request
- the user request.
-
_validateTextField
Validate a text field.- Parameters:
entry
- the text field entry.request
- the user request.- Returns:
- the list of error messages.
-
_validatePassword
Validate a password field.- Parameters:
entry
- the password field entry.request
- the user request.- Returns:
- the list of error messages.
-
_validateSelect
Validate a select input.- Parameters:
entry
- the select input entry.request
- the user request.- Returns:
- the list of error messages.
-
_validateTextarea
Validate a textarea.- Parameters:
entry
- the textarea entry.request
- the user request.- Returns:
- the list of error messages.
-
_validateRadio
Validate a radio input.- Parameters:
entry
- the radio input entry.request
- the user request.- Returns:
- the list of error messages.
-
_validateCheckbox
Validate a checkbox input.- Parameters:
entry
- the checkbox entry.request
- the user request.- Returns:
- the list of error messages.
-
_validateFile
Validate a file input.- Parameters:
entry
- the file input entry.request
- the user request.- Returns:
- the list of error messages.
-
_validateCaptcha
Validate a captcha.- Parameters:
entry
- the captcha entry.request
- the user request.- Returns:
- the list of error messages.
-
_validateMandatory
Validate a mandatory field.- Parameters:
entry
- the field valuekeyPrefix
- the key profix- Returns:
- the list of error messages.
-
_validateConfirmation
protected List<I18nizableText> _validateConfirmation(FieldValue entry, Request request, String keyPrefix) Validate a confirmation.- Parameters:
entry
- the field valuerequest
- the requestkeyPrefix
- the key prefix- Returns:
- the list of error messages.
-
_getEntriesToInsert
Retain only the entries that are to be inserted in the database.- Parameters:
entries
- the entries to filter.- Returns:
- the entries to insert in the database.
-
_sendEmails
protected void _sendEmails(Form form, Map<String, FieldValue> input, Site site, Integer totalSubmissions) Send the receipt and notification emails.- Parameters:
form
- the Form object.input
- the user input.site
- the site.totalSubmissions
- total number of submissions. Can be null if the form don't have limits.
-
_sendNotificationEmails
Send the notification emails.- Parameters:
form
- the form.input
- the user input.sender
- the sender e-mail.
-
_sendReceiptEmail
Send the receipt email.- Parameters:
form
- the form.input
- the user input.sender
- the sender e-mail.
-
_sendLimitEmail
Send the limit email.- Parameters:
form
- the form.input
- the user input.sender
- the sender e-mail.
-
_getMail
protected String _getMail(String resource, Form form, Map<String, FieldValue> input) throws IOExceptionGet a mail pipeline's content.- Parameters:
resource
- the mail resource pipeline (i.e. "results.html" or "receipt.txt").form
- the Form.input
- the user input.- Returns:
- the mail content.
- Throws:
IOException
- if an error occurs.
-
_getFiles
Get the files of a user input.- Parameters:
input
- the user input.- Returns:
- the files submitted by the user.
-