List of usage examples for org.springframework.validation BindingResult rejectValue
void rejectValue(@Nullable String field, String errorCode);
From source file:easycare.web.user.UsersPermissionsController.java
private void validateInterpretingPhysicianFields(User user, UserPermissionsForm form, BindingResult result) { if (form.isInterpretingPhysician() && (isBlank(user.getEmail()) || isBlank(user.getLicenseNumber()))) { result.rejectValue(USER_ROLES, INTERPRETING_PHYSICIAN_ERROR); }/*from www. j a va2s . co m*/ }
From source file:eu.europa.ec.grow.espd.controller.EspdController.java
private String reuseRequestAsCA(MultipartFile attachment, Model model, BindingResult result) throws IOException { try (InputStream is = attachment.getInputStream()) { Optional<EspdDocument> espd = exchangeMarshaller.importEspdRequest(is); if (espd.isPresent()) { model.addAttribute("espd", espd.get()); return redirectToPage(REQUEST_CA_PROCEDURE_PAGE); }//from w w w. j a v a 2 s . c o m } result.rejectValue("attachments", "espd_upload_request_error"); return "filter"; }
From source file:eu.europa.ec.grow.espd.controller.EspdController.java
private String reviewResponseAsCA(MultipartFile attachment, Model model, BindingResult result) throws IOException { try (InputStream is = attachment.getInputStream()) { Optional<EspdDocument> espd = exchangeMarshaller.importEspdResponse(is); if (espd.isPresent()) { model.addAttribute("espd", espd.get()); return redirectToPage(PRINT_PAGE); }/*from w w w .j a va 2s . c o m*/ } result.rejectValue("attachments", "espd_upload_response_error"); return "filter"; }
From source file:eu.europa.ec.grow.espd.controller.EspdController.java
private String importEspdAsEo(Country country, MultipartFile attachment, Model model, BindingResult result) throws IOException { try (InputStream is = attachment.getInputStream()) { Optional<EspdDocument> wrappedEspd = exchangeMarshaller.importAmbiguousEspdFile(is); // how can wrappedEspd be null??? if (wrappedEspd != null && wrappedEspd.isPresent()) { EspdDocument espd = wrappedEspd.get(); if (espd.getEconomicOperator() == null) { espd.setEconomicOperator(new EconomicOperatorImpl()); }//from www .j a v a 2s . co m if (needsToLoadProcurementProcedureInformation(espd)) { // in this case we need to contact TED again to load the procurement information copyTedInformation(espd); } espd.getEconomicOperator().setCountry(country); model.addAttribute("espd", espd); return redirectToPage(RESPONSE_EO_PROCEDURE_PAGE); } } result.rejectValue("attachments", "espd_upload_error"); return "filter"; }
From source file:eu.europa.ec.grow.espd.controller.EspdController.java
private String mergeTwoEspds(List<MultipartFile> attachments, Model model, BindingResult result) throws IOException { try (InputStream reqIs = attachments.get(1).getInputStream(); InputStream respIs = attachments.get(2).getInputStream()) { Optional<EspdDocument> wrappedEspd = exchangeMarshaller.mergeEspdRequestAndResponse(reqIs, respIs); if (wrappedEspd.isPresent()) { model.addAttribute("espd", wrappedEspd.get()); return redirectToPage(RESPONSE_EO_PROCEDURE_PAGE); }// ww w. j a va 2 s . co m } result.rejectValue("attachments", "espd_upload_error"); return "filter"; }
From source file:org.commonwl.view.workflow.WorkflowController.java
/** * Create a new workflow from the given URL in the form * @param workflowForm The data submitted from the form * @param bindingResult Spring MVC Binding Result object * @return The workflow view with new workflow as a model *//* ww w. j av a 2 s. com*/ @PostMapping("/workflows") public ModelAndView createWorkflow(@Valid WorkflowForm workflowForm, BindingResult bindingResult) { // Run validator which checks the git URL is valid GitDetails gitInfo = workflowFormValidator.validateAndParse(workflowForm, bindingResult); if (bindingResult.hasErrors() || gitInfo == null) { // Go back to index if there are validation errors return new ModelAndView("index"); } else { // Get workflow or create if does not exist Workflow workflow = workflowService.getWorkflow(gitInfo); if (workflow == null) { try { if (gitInfo.getPath().endsWith(".cwl")) { QueuedWorkflow result = workflowService.createQueuedWorkflow(gitInfo); if (result.getWorkflowList() == null) { workflow = result.getTempRepresentation(); } else { if (result.getWorkflowList().size() == 1) { gitInfo.setPackedId(result.getWorkflowList().get(0).getFileName()); } return new ModelAndView("redirect:" + gitInfo.getInternalUrl()); } } else { return new ModelAndView("redirect:" + gitInfo.getInternalUrl()); } } catch (TransportException ex) { logger.warn("git.sshError " + workflowForm, ex); bindingResult.rejectValue("url", "git.sshError"); return new ModelAndView("index"); } catch (GitAPIException ex) { logger.error("git.retrievalError " + workflowForm, ex); bindingResult.rejectValue("url", "git.retrievalError"); return new ModelAndView("index"); } catch (WorkflowNotFoundException ex) { logger.warn("git.notFound " + workflowForm, ex); bindingResult.rejectValue("url", "git.notFound"); return new ModelAndView("index"); } catch (Exception ex) { logger.warn("url.parsingError " + workflowForm, ex); bindingResult.rejectValue("url", "url.parsingError"); return new ModelAndView("index"); } } gitInfo = workflow.getRetrievedFrom(); // Redirect to the workflow return new ModelAndView("redirect:" + gitInfo.getInternalUrl()); } }
From source file:org.egov.bpa.web.controller.application.NewApplicationController.java
private void validateDocuments(final List<ApplicationDocument> applicationDocs, final ApplicationDocument applicationDocument, final int i, final BindingResult resultBinder) { Iterator<MultipartFile> stream = null; if (ArrayUtils.isNotEmpty(applicationDocument.getFiles())) stream = Arrays.asList(applicationDocument.getFiles()).stream().filter(file -> !file.isEmpty()) .iterator();// w ww . j a v a 2 s . c om if (stream == null) { final String fieldError = "applicationDocs[" + i + "].files"; resultBinder.rejectValue(fieldError, "files.required"); } else applicationDocs.add(applicationDocument); }
From source file:org.egov.council.web.controller.CouncilDataEntryController.java
private void validateNumber(MeetingMOM meetingMOM, BindingResult errors) { if (StringUtils.isNotBlank(meetingMOM.getAgenda().getAgendaNumber()) && !councilAgendaService.findByAgendaNo(meetingMOM.getAgenda().getAgendaNumber()).isEmpty()) { errors.rejectValue("agenda.agendaNumber", "err.agenda.alreadyexists"); }//from w w w . j av a 2 s. c o m if (StringUtils.isNotBlank(meetingMOM.getMeeting().getMeetingNumber()) && councilMeetingService.findByMeetingNumber(meetingMOM.getMeeting().getMeetingNumber()) != null) { errors.rejectValue("meeting.meetingNumber", "err.meeting.no.alreadyexists"); } }
From source file:org.egov.council.web.controller.CouncilPreambleController.java
public void validatePreamble(final CouncilPreamble councilPreamble, final BindingResult errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "department", "notempty.preamble.department"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "gistOfPreamble", "notempty.preamble.gistOfPreamble"); if (councilPreamble.getAttachments().getSize() == 0 && councilPreamble.getFilestoreid() == null) errors.rejectValue("attachments", "notempty.preamble.attachments"); }
From source file:org.egov.egf.web.controller.BudgetGroupController.java
@RequestMapping(value = "/create", method = RequestMethod.POST) public String create(@Valid @ModelAttribute final BudgetGroup budgetGroup, final BindingResult errors, final RedirectAttributes redirectAttrs, final Model model) { if (budgetGroup.getMajorCode() == null && budgetGroup.getMinCode() == null && budgetGroup.getMaxCode() == null) errors.rejectValue("majorCode", "budgetgroup.select.accountcode"); if (budgetGroup.getMajorCode() != null && (budgetGroup.getMinCode() != null || budgetGroup.getMaxCode() != null)) errors.rejectValue("majorCode", "budgetgroup.invalid.mapping"); if (budgetGroup.getMajorCode() == null && (budgetGroup.getMinCode() != null || budgetGroup.getMaxCode() != null)) { if (budgetGroup.getMinCode() == null) errors.rejectValue("minCode", "budgetgroup.invalidminorcode.mapping"); else if (budgetGroup.getMaxCode() == null) errors.rejectValue("maxCode", "budgetgroup.invalidmajorcode.mapping"); }/*from w w w .j a va 2 s . co m*/ String validationMessage = budgetGroupService.validate(budgetGroup, errors); if (errors.hasErrors() || !StringUtils.isEmpty(validationMessage)) { prepareNewForm(model); model.addAttribute("majorCode", validationMessage); return BUDGETGROUP_NEW; } budgetGroupService.create(budgetGroup); redirectAttrs.addFlashAttribute("message", messageSource.getMessage("msg.budgetGroup.success", null, Locale.ENGLISH)); return "redirect:/budgetgroup/result/" + budgetGroup.getId(); }