Class FormsResponseUtils

java.lang.Object
fr.paris.lutece.plugins.forms.util.FormsResponseUtils

public class FormsResponseUtils extends Object
  • Method Details

    • isAuthorized

      public static boolean isAuthorized(FormResponse formResponse, fr.paris.lutece.portal.service.security.LuteceUser user)
      Check that a given user is allowed to access for manage the formResponse
      Parameters:
      formResponse - the formsResponse
      user - the user trying to access the resource
      Returns:
      true if the user can access for manage the given resource, false otherwise
    • isAuthorized

      public static boolean isAuthorized(FormResponse formResponse, fr.paris.lutece.portal.service.security.LuteceUser user, Form form)
      Check that a given user is allowed to access for manage the formResponse
      Parameters:
      formResponse - the formsResponse
      user - the user trying to access the resource
      form - the form
      Returns:
      true if the user can access for manage the given resource, false otherwise
    • filterFormResponseForLuteceUser

      public static List<FormResponse> filterFormResponseForLuteceUser(List<FormResponse> formResponseList, fr.paris.lutece.portal.service.security.LuteceUser user)
      Filter formResponse by access rights for LuteceUser
      Parameters:
      formResponseList - the list of fromResponse objects
      user - the luteceUser
      Returns:
      list of FormResponse objects filtered
    • filterFormResponseListForLuteceUser

      public static List<FormResponseData> filterFormResponseListForLuteceUser(List<FormResponse> formResponseList, fr.paris.lutece.portal.service.security.LuteceUser user)
      Filter and build formResponseData by access rights for LuteceUser
      Parameters:
      formResponseList - the list of fromResponse objects
      user - the luteceUser
      Returns:
      list of FormResponseData objects builded
    • getFormResponseListByRoleAndGuid

      public static List<FormResponse> getFormResponseListByRoleAndGuid(fr.paris.lutece.portal.service.security.LuteceUser user)
      Get FormResponse list By Role And Guid
      Parameters:
      user - the LuteceUser
      Returns:
      FormResponse objects list
    • buildFormResponseData

      public static FormResponseData buildFormResponseData(FormResponse formResponse, Optional<Form> form)
      Build FormResponseData
      Parameters:
      formResponse - the from response
      form - the form
      Returns:
      the FormResponseData builded
    • getNextStep

      public static Step getNextStep(int nIdCurrentStep, List<String> errorMessageList, FormResponseManager formResponseManager, Locale locale)
      Build next Step object
      Parameters:
      nIdCurrentStep - the id current step
      errorMessageList - the error message list
      formResponseManager - the formResponseManager
      Returns:
      Step object
    • populateFormWithLogoAndNumberResponse

      public static void populateFormWithLogoAndNumberResponse(Form form)
      Populate form with Physical File logo and number of response
      Parameters:
      form - the form object
    • fillResponseManagerWithResponses

      public static void fillResponseManagerWithResponses(jakarta.servlet.http.HttpServletRequest request, boolean bValidateQuestionStep, FormResponseManager formResponseManager, List<Question> listQuestionStep, boolean displayInBO) throws QuestionValidationException
      Parameters:
      request - The Http request
      bValidateQuestionStep - valid question ton next step
      Throws:
      QuestionValidationException - if there is at least one question not valid
    • checkNumberMaxResponseForm

      public static boolean checkNumberMaxResponseForm(Form form)
      Check whether the given form can still accept new responses. The count is read live from the database on every call: we do not cache it in memory because that cache cannot be kept consistent across a multi-instance deployment. Callers that need to serialise concurrent submissions against the quota must wrap this check + the actual insert inside a distributed lock (see FormsDistributedLockManager).
      Parameters:
      form - the form
      Returns:
      true if a new response can still be accepted, false if the quota is reached
    • checkIfUserResponseForm

      public static boolean checkIfUserResponseForm(Form form, String strGuid)
      check if user can answer the form again
      Parameters:
      form - the form
      strGuid - the guid of the current user
      Returns:
      true if the user is still allowed to submit, false otherwise
    • buildStepsHtml

      public static List<String> buildStepsHtml(jakarta.servlet.http.HttpServletRequest request, List<Step> listStep, FormResponseManager formResponseManager, boolean frontOffice)
      Builds the HTML for the specified list of steps
      Parameters:
      request - The request
      listStep - The list of steps
      Returns:
      the list of HTML
    • getLocaleFO

      public static Locale getLocaleFO(jakarta.servlet.http.HttpServletRequest request)
    • buildFileUrl

      public static String buildFileUrl(int nIdFormQuestionResponse, int nIdFile)
      Build FormsResponse file url. This url is only used for FO
      Parameters:
      nIdFormQuestionResponse - the forms question response
      nIdFile - the file id
      Returns:
      the url builded
    • buildFormsResponseFOUrl

      public static String buildFormsResponseFOUrl(int nIdFormResponse)
      Build FormsResponse FO url.
      Parameters:
      nIdFormQuestionResponse - the forms question response
      nIdFile - the file id
      Returns:
      the url builded
    • getRootUrl

      public static String getRootUrl()
      Return the url of the Root of the webapp
      Returns:
      strBase the webapp url