Class FormPropertiesManager
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.plugins.forms.content.jcr.FormPropertiesManager
- All Implemented Interfaces:
PluginAware
,Component
,LogEnabled
,Serviceable
public class FormPropertiesManager
extends AbstractLogEnabled
implements Serviceable, Component, PluginAware
Form properties manager : stores and retrieves form properties.
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The plugin name.protected javax.jcr.Repository
The JCR repository.protected AmetysObjectResolver
The resolver for ametys objectsprotected SiteManager
The Site manager.static final String
"ID" field property name.static final String
"Label" field property name.static final String
"Name" field property name.static final String
Field properties prefix.static final String
"Type" field property name.static final String
"Emails" property name.static final String
"ID" property name.static final String
"Label" property name.static final String
"Limit" property name.static final String
"No remaining places" property name.static final String
"Receipt field ID" property name.static final String
"Receipt field ID" property name.static final String
"Receipt field ID" property name.static final String
"Receipt field ID" property name.static final String
The uuid of the page where to redirect tostatic final String
"Remaining places" property name.static final String
"Workflow name" property name.static final String
Forms node name.static final String
Language propertystatic final Pattern
Pattern for options valuestatic final String
Plugins root node name.static final String
The avalon component ROLE.static final String
JCR relative path to root node.static final String
Site property -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected javax.jcr.Node
_createOrGetFormsNode
(javax.jcr.Node baseNode) Get or create the forms node in a content node.protected Field
_extractField
(javax.jcr.Node fieldNode) Extracts a field from a JCR Node.protected void
_extractFields
(javax.jcr.Node formNode, Form form) Extracts a form from a JCR Node.protected Form
_extractForm
(javax.jcr.Node formNode) Extracts a form from a JCR Node.protected void
_fillFieldNode
(javax.jcr.Node fieldNode, Field field) Fill a field node.protected void
_fillFormNode
(javax.jcr.Node formNode, Form form) Fill a form node._getFieldProperties
(javax.jcr.Node node) Get additional configuration from properties.protected Collection<String>
_getMultipleProperty
(javax.jcr.Node node, String propertyName) Get the values of a string array property.protected String
_getNotExistingNodeName
(javax.jcr.Node container, String baseName) Get a name for a node which doesn't already exist in this node.protected String
_getSingleProperty
(javax.jcr.Node node, String propertyName, String defaultValue) Get a single property value.protected javax.jcr.Node
_storeField
(javax.jcr.Node formNode, Field field) Store a field node.protected javax.jcr.Node
_storeForm
(javax.jcr.Node contentNode, Form form) Persist the form in a repository node.protected void
_updateFields
(Form form, javax.jcr.Node formNode) Update the field nodes of a form.void
createForm
(String siteName, Form form, Content content) Store the properties of a form in the repository.getDisplayValue
(Field field, String value) Get the value for displayGet a form from the repository.Get a form from the repository.getFormContent
(String formId) Get the content containing the form with the given idList<javax.jcr.Node>
getFormContentNodes
(String siteName, String language) Get all the contents containing at least one form of the given site with the given languagegetForms
(javax.jcr.Node node) Extract all the form objects from a nodeGet the forms in a specified content.javax.jcr.Node
getMostRecentFormFrozenContent
(String formId) Get the most recent frozen node that contain the form of the given idvoid
Remove a formvoid
service
(ServiceManager serviceManager) void
setPluginInfo
(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.void
updateForm
(String siteName, Form form, Content content) Update the properties of a form in the repository.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
OPTION_VALUE_PATTERN
Pattern for options value -
ROLE
The avalon component ROLE. -
ROOT_REPO
JCR relative path to root node.- See Also:
-
PLUGINS_NODE
Plugins root node name.- See Also:
-
FORMS_NODE
Forms node name.- See Also:
-
LANGUAGE_PROPERTY
Language property- See Also:
-
SITE_PROPERTY
Site property- See Also:
-
FORM_PROPERTY_ID
"ID" property name.- See Also:
-
FORM_PROPERTY_LABEL
"Label" property name.- See Also:
-
FORM_PROPERTY_RECEIPT_FIELD_ID
"Receipt field ID" property name.- See Also:
-
FORM_PROPERTY_RECEIPT_FROM_ADDRESS
"Receipt field ID" property name.- See Also:
-
FORM_PROPERTY_RECEIPT_SUBJECT
"Receipt field ID" property name.- See Also:
-
FORM_PROPERTY_RECEIPT_BODY
"Receipt field ID" property name.- See Also:
-
FORM_PROPERTY_REDIRECT_TO
The uuid of the page where to redirect to- See Also:
-
FORM_PROPERTY_EMAILS
"Emails" property name.- See Also:
-
FORM_PROPERTY_WORKFLOW_NAME
"Workflow name" property name.- See Also:
-
FIELD_PROPERTY_ID
"ID" field property name.- See Also:
-
FIELD_PROPERTY_TYPE
"Type" field property name.- See Also:
-
FIELD_PROPERTY_NAME
"Name" field property name.- See Also:
-
FIELD_PROPERTY_LABEL
"Label" field property name.- See Also:
-
FIELD_PROPERTY_PREFIX
Field properties prefix.- See Also:
-
FORM_PROPERTY_LIMIT
"Limit" property name.- See Also:
-
FORM_PROPERTY_REMAINING_PLACES
"Remaining places" property name.- See Also:
-
FORM_PROPERTY_NO_REMAINING_PLACES
"No remaining places" property name.- See Also:
-
_repository
The JCR repository. -
_siteManager
The Site manager. -
_resolver
The resolver for ametys objects -
_pluginName
The plugin name.
-
-
Constructor Details
-
FormPropertiesManager
public FormPropertiesManager()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
setPluginInfo
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
getForm
Get a form from the repository.- Parameters:
id
- the form ID.- Returns:
- the Form or null if no form with this ID exists.
- Throws:
FormsException
- if an error occurs.
-
getForm
Get a form from the repository.- Parameters:
siteName
- the site name.id
- the form ID.- Returns:
- the Form or null if no form with this ID exists.
- Throws:
FormsException
- if an error occurs.
-
getMostRecentFormFrozenContent
Get the most recent frozen node that contain the form of the given id- Parameters:
formId
- the id of the form- Returns:
- the list of frozen content nodes containing the form
- Throws:
FormsException
- if an error occurs while retrieving the forms' frozen content nodes
-
getForms
Get the forms in a specified content.- Parameters:
content
- the content.- Returns:
- the forms as a list.
- Throws:
FormsException
- if an error occurs.
-
getFormContentNodes
public List<javax.jcr.Node> getFormContentNodes(String siteName, String language) throws FormsException Get all the contents containing at least one form of the given site with the given language- Parameters:
siteName
- the site name.language
- the language- Returns:
- the forms' list or null if none was found
- Throws:
FormsException
- if an error occurs.
-
getFormContent
Get the content containing the form with the given id- Parameters:
formId
- the id of the form- Returns:
- the
Content
containing the form ornull
if not found - Throws:
FormsException
- if something goes wrong when either querying the form JCR node or finding its parentContent
-
getForms
public List<Form> getForms(javax.jcr.Node node) throws FormsException, javax.jcr.RepositoryException Extract all the form objects from a node- Parameters:
node
- the node- Returns:
- the forms list of this node
- Throws:
FormsException
- if an error occursjavax.jcr.RepositoryException
- if an error occurs when getting the properties of a node
-
createForm
Store the properties of a form in the repository.- Parameters:
siteName
- the site name.form
- the form object.content
- the form content.- Throws:
FormsException
- if an error occurs storing the form.
-
updateForm
Update the properties of a form in the repository.- Parameters:
siteName
- the site name.form
- the form object.content
- the form content.- Throws:
FormsException
- if an error occurs storing the form.
-
getDisplayValue
Get the value for display- Parameters:
field
- The fieldvalue
- The value- Returns:
- The value to display
-
_extractForm
Extracts a form from a JCR Node.- Parameters:
formNode
- the form node.- Returns:
- the Form object.
- Throws:
javax.jcr.RepositoryException
- if a repository error occurs.
-
_extractFields
protected void _extractFields(javax.jcr.Node formNode, Form form) throws javax.jcr.RepositoryException Extracts a form from a JCR Node.- Parameters:
formNode
- the form node.form
- the form object.- Throws:
javax.jcr.RepositoryException
- if a repository error occurs.
-
_extractField
Extracts a field from a JCR Node.- Parameters:
fieldNode
- the field node.- Returns:
- the Field object.
- Throws:
javax.jcr.RepositoryException
- if a repository error occurs.
-
_storeForm
protected javax.jcr.Node _storeForm(javax.jcr.Node contentNode, Form form) throws javax.jcr.RepositoryException Persist the form in a repository node.- Parameters:
contentNode
- the content node in which the form is to be stored.form
- the form object to persist.- Returns:
- the newly created form node.
- Throws:
javax.jcr.RepositoryException
- if a repository error occurs while filling the node.
-
_fillFormNode
protected void _fillFormNode(javax.jcr.Node formNode, Form form) throws javax.jcr.RepositoryException, FormsException Fill a form node.- Parameters:
formNode
- the form node.form
- the form object.- Throws:
javax.jcr.RepositoryException
- if a repository error occurs while filling the node.FormsException
- if a forms error occurs while filling the node.
-
_storeField
protected javax.jcr.Node _storeField(javax.jcr.Node formNode, Field field) throws javax.jcr.RepositoryException, FormsException Store a field node.- Parameters:
formNode
- the form node.field
- the field.- Returns:
- the newly created field node.
- Throws:
javax.jcr.RepositoryException
- if a repository error occurs while filling the node.FormsException
- if a forms error occurs while filling the node.
-
_fillFieldNode
protected void _fillFieldNode(javax.jcr.Node fieldNode, Field field) throws javax.jcr.RepositoryException, FormsException Fill a field node.- Parameters:
fieldNode
- the field node.field
- the field object.- Throws:
javax.jcr.RepositoryException
- if a repository error occurs while filling the node.FormsException
- if a forms error occurs while filling the node.
-
_updateFields
protected void _updateFields(Form form, javax.jcr.Node formNode) throws javax.jcr.RepositoryException, FormsException Update the field nodes of a form.- Parameters:
form
- the new form object.formNode
- the node of the form to update.- Throws:
javax.jcr.RepositoryException
- if a repository error occurs while updating the fields.FormsException
- if a forms error occurs while updating the fields.
-
_getNotExistingNodeName
protected String _getNotExistingNodeName(javax.jcr.Node container, String baseName) throws javax.jcr.RepositoryException Get a name for a node which doesn't already exist in this node.- Parameters:
container
- the container node.baseName
- the base wanted node name.- Returns:
- the name, free to be taken.
- Throws:
javax.jcr.RepositoryException
- if a repository error occurs.
-
_getSingleProperty
protected String _getSingleProperty(javax.jcr.Node node, String propertyName, String defaultValue) throws javax.jcr.RepositoryException Get a single property value.- Parameters:
node
- the JCR node.propertyName
- the name of the property to get.defaultValue
- the default value if the property does not exist.- Returns:
- the single property value.
- Throws:
javax.jcr.RepositoryException
- if a repository error occurs.
-
_getMultipleProperty
protected Collection<String> _getMultipleProperty(javax.jcr.Node node, String propertyName) throws javax.jcr.RepositoryException Get the values of a string array property.- Parameters:
node
- the node.propertyName
- the name of the property to get.- Returns:
- the values.
- Throws:
javax.jcr.RepositoryException
- if a repository error occurs.
-
_getFieldProperties
protected Map<String,String> _getFieldProperties(javax.jcr.Node node) throws javax.jcr.RepositoryException Get additional configuration from properties.- Parameters:
node
- the JCR node.- Returns:
- the additional configuration as a Map.
- Throws:
javax.jcr.RepositoryException
- if a repository error occurs.
-
remove
Remove a form- Parameters:
form
- The form to removecontent
- The content holding the form- Throws:
FormsException
- of an exception occurs when manipulating the forms' repository nodes
-
_createOrGetFormsNode
protected javax.jcr.Node _createOrGetFormsNode(javax.jcr.Node baseNode) throws javax.jcr.RepositoryException Get or create the forms node in a content node.- Parameters:
baseNode
- the content base node.- Returns:
- the forms node.
- Throws:
javax.jcr.RepositoryException
- if an error occurs.
-