if (bindingResult.hasErrors()) {
redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.domainRegionForm", bindingResult);
redirectAttributes.addFlashAttribute("domainRegionForm", domainRegionForm);
} else {
Region region;
if (domainRegionForm.getId() == null || domainRegionForm.getId() <= 0) {
region = regionService.createRegion(domainRegionForm);
} else {
region = regionService.editRegion(domainRegionForm);
}
if (region != null && region.getId() != null && region.getId() > 0) {
redirectAttributes.addFlashAttribute("updateSuccess", true);
} else {
log.info(String.format("Unable to save Region for domain: Domain Id: %s", domainRegionForm.getDomainId()));
String[] codes = {"desktop.manager.domainRegions.generic.error"};
ObjectError error = new ObjectError("domainRegionForm", codes, null, null);