Class FormPropertiesManager

java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.plugins.forms.jcr.FormPropertiesManager
All Implemented Interfaces:
PluginAware, Component, LogEnabled, Serviceable

Form properties manager : stores and retrieves form properties.
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager serviceManager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • setPluginInfo

      public void setPluginInfo(String pluginName, String featureName, String id)
      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 interface PluginAware
      Parameters:
      pluginName - Unique identifier for the plugin hosting the extension
      featureName - Unique feature identifier (unique for a given pluginName)
      id - Unique identifier of this component
    • getForm

      public Form getForm(String id) throws FormsException
      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

      public Form getForm(String siteName, String id) throws FormsException
      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

      public javax.jcr.Node getMostRecentFormFrozenContent(String formId) throws FormsException
      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

      public List<Form> getForms(Content content) throws FormsException
      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

      public Content getFormContent(String formId) throws FormsException
      Get the content containing the form with the given id
      Parameters:
      formId - the id of the form
      Returns:
      the Content containing the form or null if not found
      Throws:
      FormsException - if something goes wrong when either querying the form JCR node or finding its parent Content
    • 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 occurs
      javax.jcr.RepositoryException - if an error occurs when getting the properties of a node
    • createForm

      public void createForm(String siteName, Form form, Content content) throws FormsException
      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

      public void updateForm(String siteName, Form form, Content content) throws FormsException
      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

      public String getDisplayValue(Field field, String value)
      Get the value for display
      Parameters:
      field - The field
      value - The value
      Returns:
      The value to display
    • _extractForm

      protected Form _extractForm(javax.jcr.Node formNode) throws javax.jcr.RepositoryException
      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

      protected Field _extractField(javax.jcr.Node fieldNode) throws javax.jcr.RepositoryException
      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

      public void remove(Form form, Content content) throws FormsException
      Remove a form
      Parameters:
      form - The form to remove
      content - 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.