Class FormsResponseUtils
java.lang.Object
fr.paris.lutece.plugins.forms.util.FormsResponseUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildFileUrl(int nIdFormQuestionResponse, int nIdFile) Build FormsResponse file url.static FormResponseDatabuildFormResponseData(FormResponse formResponse, Optional<Form> form) Build FormResponseDatastatic StringbuildFormsResponseFOUrl(int nIdFormResponse) Build FormsResponse FO url.buildStepsHtml(jakarta.servlet.http.HttpServletRequest request, List<Step> listStep, FormResponseManager formResponseManager, boolean frontOffice) Builds the HTML for the specified list of stepsstatic booleancheckIfUserResponseForm(Form form, String strGuid) check if user can answer the form againstatic booleanCheck whether the given form can still accept new responses.static voidfillResponseManagerWithResponses(jakarta.servlet.http.HttpServletRequest request, boolean bValidateQuestionStep, FormResponseManager formResponseManager, List<Question> listQuestionStep, boolean displayInBO) static List<FormResponse>filterFormResponseForLuteceUser(List<FormResponse> formResponseList, fr.paris.lutece.portal.service.security.LuteceUser user) Filter formResponse by access rights for LuteceUserstatic List<FormResponseData>filterFormResponseListForLuteceUser(List<FormResponse> formResponseList, fr.paris.lutece.portal.service.security.LuteceUser user) Filter and build formResponseData by access rights for LuteceUserstatic List<FormResponse>getFormResponseListByRoleAndGuid(fr.paris.lutece.portal.service.security.LuteceUser user) Get FormResponse list By Role And Guidstatic LocalegetLocaleFO(jakarta.servlet.http.HttpServletRequest request) static StepgetNextStep(int nIdCurrentStep, List<String> errorMessageList, FormResponseManager formResponseManager, Locale locale) Build next Step objectstatic StringReturn the url of the Root of the webappstatic booleanisAuthorized(FormResponse formResponse, fr.paris.lutece.portal.service.security.LuteceUser user) Check that a given user is allowed to access for manage the formResponsestatic booleanisAuthorized(FormResponse formResponse, fr.paris.lutece.portal.service.security.LuteceUser user, Form form) Check that a given user is allowed to access for manage the formResponsestatic voidPopulate form with Physical File logo and number of response
-
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 formsResponseuser- 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 formsResponseuser- the user trying to access the resourceform- 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 objectsuser- 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 objectsuser- 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 responseform- 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 steperrorMessageList- the error message listformResponseManager- the formResponseManager- Returns:
- Step object
-
populateFormWithLogoAndNumberResponse
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 requestbValidateQuestionStep- valid question ton next step- Throws:
QuestionValidationException- if there is at least one question not valid
-
checkNumberMaxResponseForm
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 (seeFormsDistributedLockManager).- Parameters:
form- the form- Returns:
trueif a new response can still be accepted,falseif the quota is reached
-
checkIfUserResponseForm
check if user can answer the form again- Parameters:
form- the formstrGuid- the guid of the current user- Returns:
trueif the user is still allowed to submit,falseotherwise
-
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 requestlistStep- The list of steps- Returns:
- the list of HTML
-
getLocaleFO
-
buildFileUrl
Build FormsResponse file url. This url is only used for FO- Parameters:
nIdFormQuestionResponse- the forms question responsenIdFile- the file id- Returns:
- the url builded
-
buildFormsResponseFOUrl
Build FormsResponse FO url.- Parameters:
nIdFormQuestionResponse- the forms question responsenIdFile- the file id- Returns:
- the url builded
-
getRootUrl
Return the url of the Root of the webapp- Returns:
- strBase the webapp url
-