Class LimitedEntriesHelper

java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.forms.helper.LimitedEntriesHelper
All Implemented Interfaces:
LogEnabled, Component, Serviceable

The helper to handler limited entries
  • Field Details

  • Constructor Details

  • Method Details

    • service

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

      Get the form properties relevant for limiting entries number
      Parameters:
      formId - Id of the current form
      Returns:
      a map of the form properties
    • setEntriesLimitProperties

      Set the form properties relevant for limiting entries number
      Parameters:
      limitParameters - the limit parameters
      Returns:
      the map of results
    • canUserSubmit

      public boolean canUserSubmit(Form form, UserIdentity user, String clientIp)
      true if the user can submit the form depending of the form limitation
      Parameters:
      form - the form
      user - the user. Can be null if the form is anonymous
      clientIp - the client ip of the user
      Returns:
      true if the user can submit the form depending of the form limitation
    • hasUserAlreadyAnswer

      public boolean hasUserAlreadyAnswer(Form form, UserIdentity user, String clientIp)
      true if the user has already answer to the form
      Parameters:
      form - the form
      user - the user. Can be null if the form is anonymous
      clientIp - the client ip of the user
      Returns:
      true if the user has already answer to the form
    • getClientIp

      public String getClientIp(Request request)
      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.
    • isInQueue

      public boolean isInQueue(FormEntry entry)
      true if the entry is in queue
      Parameters:
      entry - the entry
      Returns:
      true if the entry is in queue
    • deactivateEntry

      public void deactivateEntry(String entryId)
      Deactivate an entry handling the form limitation
      Parameters:
      entryId - the entry id
    • _getQueue

      protected List<FormEntry> _getQueue(Form form)
      Get the waiting list sort by the submiting date
      Parameters:
      form - the form
      Returns:
      the waiting list
    • isFormLimitIsReached

      public boolean isFormLimitIsReached(Form form)
      true if the form limit is reach
      Parameters:
      form - the form
      Returns:
      true if the form limit is reach