} else {
//Only create organization if user is System Admin
User user = userService.getUserFromSecurityContext();
if (!user.isSystemAdmin()) {
String[] codes = {"desktop.manager.organization.generic.error"};
ObjectError error = new ObjectError("organizationForm", codes, null, null);
bindingResult.addError(error);
return addOrganization(model);
}
Organization organization = organizationService.createOrganization(organizationForm);
if (organization == null || organization.getId() == null || organization.getId() <= 0) {
String[] codes = {"desktop.manager.organization.create.error"};
ObjectError error = new ObjectError("organizationForm", codes, null, null);
bindingResult.addError(error);
return addOrganization(model);
}
categoryService.createDefaultCategories(organization.getId());
orgId = organization.getId();