public class ProcessFormAction extends ServiceableAction implements Contextualizable
Modifier and Type | Field and Description |
---|---|
private static String |
__FORM_ENTRY_PATTERN |
protected AmetysObjectResolver |
_ametysObjectResolver
The ametys object resolver
|
protected Context |
_context
The context
|
protected static DateFormat |
_DATE_FORMAT
The date format pattern.
|
protected static Pattern |
_DATE_PATTERN
The integer validation pattern.
|
protected static DateFormat |
_DATETIME_FORMAT
The date and time format pattern.
|
protected static Pattern |
_DATETIME_PATTERN
The integer validation pattern.
|
protected static Pattern |
_EMAIL_PATTERN
The email validation pattern.
|
protected static Pattern |
_FLOAT_PATTERN
The integer validation pattern.
|
protected FormPropertiesManager |
_formPropertiesManager
Form properties manager.
|
protected FormTableManager |
_formTableManager
Form table manager.
|
protected static Pattern |
_INT_PATTERN
The integer validation pattern.
|
protected static Pattern |
_PHONE_PATTERN
The phone validation pattern.
|
protected String |
_pluginName
The plugin name.
|
protected URIPrefixHandler |
_prefixHandler
The URI prefix handler
|
protected SiteConfigurationExtensionPoint |
_siteConfiguration
The site configuration.
|
protected SourceResolver |
_sourceResolver
The source resolver.
|
protected SQLDatabaseTypeExtensionPoint |
_sqlDatabaseTypeExtensionPoint
The SQLDatabaseTypeExtensionPoint instance
|
protected static DateFormat |
_TIME_FORMAT
The time format pattern.
|
protected static Pattern |
_TIME_PATTERN
The integer validation pattern.
|
protected WorkflowHelper |
_workflowHelper
The workflow helper component
|
protected WorkflowProvider |
_workflowProvider
The workflow provider
|
private static String |
ANTIVIRUS_RESULT_OK |
protected static String |
PARAM_CONTENT_ID
The content ID parameter.
|
protected static String |
PARAM_FORM_ID
The form ID parameter.
|
manager
EMPTY_MAP
Constructor and Description |
---|
ProcessFormAction() |
Modifier and Type | Method and Description |
---|---|
private boolean |
_analyseFile(File fileToAnalyse)
Antivirus analysis.
|
private void |
_createWorkflow(Form form,
Map objectModel,
String tableName,
Connection connection,
String dbType) |
private Date |
_getDate(String stringValue,
Date defaultValue,
DateFormat format) |
protected 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.
|
private Float |
_getFloat(String stringValue,
Float defaultValue) |
protected Map<String,FieldValue> |
_getInput(Form form,
Request request,
FormErrors errors)
Get the user input.
|
private Integer |
_getInteger(String stringValue,
Integer defaultValue) |
protected String |
_getMail(String resource,
Form form,
Map<String,FieldValue> input)
Get a mail pipeline's content.
|
private Pattern |
_getPattern(String jsRegexp)
Parses a JS pattern (i.e.
|
private String |
_getSiteNameFromSharedContent(SharedContent sharedContent) |
protected void |
_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,
String siteName)
Send the receipt and notification emails.
|
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.
|
private void |
_updateWorkflowId(String formId,
String entryId,
long workflowId) |
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.
|
private List<I18nizableText> |
_validateCustomRegexp(FieldValue entry,
String keyPrefix) |
private List<I18nizableText> |
_validateDate(FieldValue entry,
String keyPrefix) |
private List<I18nizableText> |
_validateDateTime(FieldValue entry,
String keyPrefix) |
protected List<I18nizableText> |
_validateFile(FieldValue entry,
Request request)
Validate a file input.
|
private List<I18nizableText> |
_validateFloat(FieldValue entry,
String keyPrefix) |
protected void |
_validateInput(Form form,
Map<String,FieldValue> input,
FormErrors errors,
Request request)
Validate the user input.
|
private List<I18nizableText> |
_validateInteger(FieldValue entry,
String keyPrefix) |
protected List<I18nizableText> |
_validateMandatory(FieldValue entry,
String keyPrefix)
Validate a mandatory field.
|
private void |
_validateNonblankRegexp(FieldValue entry,
List<I18nizableText> errors,
String value,
String textPrefix,
String regexpType) |
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.
|
private List<I18nizableText> |
_validateTextLength(FieldValue entry,
String keyPrefix) |
private List<I18nizableText> |
_validateTime(FieldValue entry,
String keyPrefix) |
Map |
act(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String source,
Parameters parameters) |
void |
contextualize(Context context) |
void |
service(ServiceManager serviceManager) |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
protected static final String PARAM_FORM_ID
protected static final String PARAM_CONTENT_ID
protected static final Pattern _INT_PATTERN
protected static final Pattern _FLOAT_PATTERN
protected static final Pattern _DATE_PATTERN
protected static final Pattern _TIME_PATTERN
protected static final Pattern _DATETIME_PATTERN
protected static final Pattern _EMAIL_PATTERN
protected static final Pattern _PHONE_PATTERN
protected static final DateFormat _DATE_FORMAT
protected static final DateFormat _TIME_FORMAT
protected static final DateFormat _DATETIME_FORMAT
private static final String __FORM_ENTRY_PATTERN
private static final String ANTIVIRUS_RESULT_OK
protected FormPropertiesManager _formPropertiesManager
protected FormTableManager _formTableManager
protected SourceResolver _sourceResolver
protected AmetysObjectResolver _ametysObjectResolver
protected SiteConfigurationExtensionPoint _siteConfiguration
protected String _pluginName
protected URIPrefixHandler _prefixHandler
protected WorkflowProvider _workflowProvider
protected WorkflowHelper _workflowHelper
protected SQLDatabaseTypeExtensionPoint _sqlDatabaseTypeExtensionPoint
public ProcessFormAction()
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
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
private String _getSiteNameFromSharedContent(SharedContent sharedContent)
private boolean _analyseFile(File fileToAnalyse)
fileToAnalyse
- the file to analyseprotected Map<String,FieldValue> _getInput(Form form, Request request, FormErrors errors)
form
- the Form object.request
- the user request.errors
- the input errors.protected FieldValue _getFileEntry(Request request, Field field, String id, String name, FormErrors errors)
request
- the user request.field
- the field.id
- the entry ID.name
- the field name.errors
- the form errors.protected void _insertInput(Form form, Map<String,FieldValue> input, Map objectModel) throws FormsException, com.opensymphony.workflow.WorkflowException, InvalidModificationException
form
- the Form object.input
- the user input.objectModel
- The object modelFormsException
- if an error occurs.com.opensymphony.workflow.WorkflowException
- if an exception occurs while initializing a workflow instance for a form entryInvalidModificationException
- If an error occursprivate void _createWorkflow(Form form, Map objectModel, String tableName, Connection connection, String dbType) throws SQLException, InvalidModificationException, com.opensymphony.workflow.InvalidActionException, com.opensymphony.workflow.InvalidRoleException, com.opensymphony.workflow.InvalidInputException, com.opensymphony.workflow.InvalidEntryStateException, com.opensymphony.workflow.WorkflowException, FormsException
SQLException
InvalidModificationException
com.opensymphony.workflow.InvalidActionException
com.opensymphony.workflow.InvalidRoleException
com.opensymphony.workflow.InvalidInputException
com.opensymphony.workflow.InvalidEntryStateException
com.opensymphony.workflow.WorkflowException
FormsException
private void _updateWorkflowId(String formId, String entryId, long workflowId) throws FormsException
FormsException
protected void _setParameters(Form form, Map<String,FieldValue> input, PreparedStatement stmt, String dbType) throws SQLException, com.opensymphony.workflow.WorkflowException
form
- the form.input
- the user input.stmt
- the prepared statement.dbType
- the database type.SQLException
- if a SQL error occurs.com.opensymphony.workflow.WorkflowException
- if an exception occurs while initializing a workflow instance for a form entryprotected void _validateInput(Form form, Map<String,FieldValue> input, FormErrors errors, Request request)
form
- the Form object.input
- the user input.errors
- the FormErrors object to fill.request
- the user request.protected List<I18nizableText> _validateTextField(FieldValue entry, Request request)
entry
- the text field entry.request
- the user request.private void _validateNonblankRegexp(FieldValue entry, List<I18nizableText> errors, String value, String textPrefix, String regexpType)
protected List<I18nizableText> _validatePassword(FieldValue entry, Request request)
entry
- the password field entry.request
- the user request.protected List<I18nizableText> _validateSelect(FieldValue entry, Request request)
entry
- the select input entry.request
- the user request.protected List<I18nizableText> _validateTextarea(FieldValue entry, Request request)
entry
- the textarea entry.request
- the user request.protected List<I18nizableText> _validateRadio(FieldValue entry, Request request)
entry
- the radio input entry.request
- the user request.protected List<I18nizableText> _validateCheckbox(FieldValue entry, Request request)
entry
- the checkbox entry.request
- the user request.protected List<I18nizableText> _validateFile(FieldValue entry, Request request)
entry
- the file input entry.request
- the user request.protected List<I18nizableText> _validateCaptcha(FieldValue entry, Request request)
entry
- the captcha entry.request
- the user request.protected List<I18nizableText> _validateMandatory(FieldValue entry, String keyPrefix)
entry
- the field valuekeyPrefix
- the key profixprotected List<I18nizableText> _validateConfirmation(FieldValue entry, Request request, String keyPrefix)
entry
- the field valuerequest
- the requestkeyPrefix
- the key prefixprivate List<I18nizableText> _validateTextLength(FieldValue entry, String keyPrefix)
private List<I18nizableText> _validateInteger(FieldValue entry, String keyPrefix)
private List<I18nizableText> _validateFloat(FieldValue entry, String keyPrefix)
private List<I18nizableText> _validateDate(FieldValue entry, String keyPrefix)
private List<I18nizableText> _validateTime(FieldValue entry, String keyPrefix)
private List<I18nizableText> _validateDateTime(FieldValue entry, String keyPrefix)
private List<I18nizableText> _validateCustomRegexp(FieldValue entry, String keyPrefix)
private Pattern _getPattern(String jsRegexp)
jsRegexp
- the JS regexp stringprivate Integer _getInteger(String stringValue, Integer defaultValue)
private Date _getDate(String stringValue, Date defaultValue, DateFormat format)
protected Collection<FieldValue> _getEntriesToInsert(Collection<FieldValue> entries)
entries
- the entries to filter.protected void _sendEmails(Form form, Map<String,FieldValue> input, String siteName)
form
- the Form object.input
- the user input.siteName
- the site name.protected void _sendNotificationEmails(Form form, Map<String,FieldValue> input, String sender)
form
- the form.input
- the user input.sender
- the sender e-mail.protected void _sendReceiptEmail(Form form, Map<String,FieldValue> input, String sender)
form
- the form.input
- the user input.sender
- the sender e-mail.protected String _getMail(String resource, Form form, Map<String,FieldValue> input) throws IOException
resource
- the mail resource pipeline (i.e. "results.html" or
"receipt.txt").form
- the Form.input
- the user input.IOException
- if an error occurs.protected Collection<File> _getFiles(Map<String,FieldValue> input)
input
- the user input.