return "ajaxFailureHarness";
} else {
if (waf.getName().trim().equals("")) {
result.rejectValue("name", null, null, "This field cannot be blank");
} else {
Waf databaseWaf = wafService.loadWaf(waf.getName().trim());
if (databaseWaf != null) {
result.rejectValue("name", MessageConstants.ERROR_NAMETAKEN);
}
}
if (waf.getWafType() == null) {
result.rejectValue("wafType.id", MessageConstants.ERROR_REQUIRED, new String [] { "WAF Type" }, null );
} else if (wafService.loadWafType(waf.getWafType().getId()) == null) {
result.rejectValue("wafType.id", MessageConstants.ERROR_INVALID, new String [] { waf.getWafType().getId().toString() }, null );
} else {
waf.setWafType(wafService.loadWafType(waf.getWafType().getId()));
}
if (result.hasErrors()) {
model.addAttribute("contentPage", "wafs/forms/createWafForm.jsp");
return "ajaxFailureHarness";
}
wafService.storeWaf(waf);
String currentUser = SecurityContextHolder.getContext().getAuthentication().getName();
log.debug(currentUser + " has created a WAF with the name " + waf.getName() +
", the type " + waf.getWafType().getName() +
" and ID " + waf.getId() + ".");
model.addAttribute(wafService.loadAll());
model.addAttribute("newWaf", new Waf());
model.addAttribute("waf", new Waf());
model.addAttribute("wafPage", true);
PermissionUtils.addPermissions(model, null, null, Permission.CAN_MANAGE_WAFS);
return "SUCCESS";
}