Class FormsResponseUtils


  • public class FormsResponseUtils
    extends Object
    • Method Detail

      • 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)
        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​(javax.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
      • getLockOnForm

        public static Object getLockOnForm​(Form form)
      • increaseNumberResponse

        public static void increaseNumberResponse​(Form form)
        Increase the number of response of the Form
        Parameters:
        form -
      • checkNumberMaxResponseForm

        public static boolean checkNumberMaxResponseForm​(Form form)
        check if form is reached the number max of response
        Parameters:
        form - the form
        request - the request
        Throws:
        fr.paris.lutece.portal.service.message.SiteMessageException - the exception
      • checkIfUserResponseForm

        public static boolean checkIfUserResponseForm​(Form form,
                                                      String strGuid)
        check if user can answer the form again
        Parameters:
        form - the form
        request - the request
        Throws:
        fr.paris.lutece.portal.service.message.SiteMessageException
      • buildStepsHtml

        public static List<String> buildStepsHtml​(javax.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​(javax.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