public String submitUserEditChanges() { Set<UserAuthority> newAuthorities = new HashSet<UserAuthority>(); for (String s : editedUserAuthorities) { UserAuthority authority = new UserAuthority(); authority.setSystemUser(editedUser); authority.setRight(superUserService.getRight(Integer.parseInt(s))); newAuthorities.add(authority); } try { editedUser.setUserAuthorities(newAuthorities); superUserService.updateUserAuthoritiesAndSaveUser(editedUser, newAuthorities); } catch (DataAccessException exception) { message = "Database error, try again later"; } catch (TransactionException exception) { message = "Database error, try again later"; } catch (Exception e) { message = "Sorry, service is currently unavailable"; } return "return"; }
public String submitNewUser() { Set<UserAuthority> userAuthorities = new HashSet<UserAuthority>(); for (String s : editedUserAuthorities) { UserAuthority authority = new UserAuthority(); authority.setSystemUser(editedUser); authority.setRight(superUserService.getRight(Integer.parseInt(s))); userAuthorities.add(authority); } try { editedUser.setActive(true); editedUser.setUserAuthorities(userAuthorities); superUserService.saveOrUpdate(editedUser); return "return"; } catch (DataAccessException exception) { message = "Database error, try again later"; } catch (TransactionException exception) { message = "Database error, try again later"; } catch (Exception e) { message = "Sorry, service is currently unavailable"; } return "fail"; }
public void editSystemUser(ActionEvent actionEvent) { editedUser = (SystemUser) actionEvent.getComponent().getAttributes().get("binding"); editedUserAuthorities = new ArrayList<String>(); try { for (UserAuthority authority : superUserService.getUserAuthorities(editedUser.getId())) { editedUserAuthorities.add(authority.getRight().getId().toString()); } } catch (DataAccessException exception) { message = "Database error, try again later"; } catch (TransactionException exception) { message = "Database error, try again later"; } catch (Exception e) { message = "Sorry, service is currently unavailable"; } }
public void validateLogin(FacesContext context, UIComponent toValidate, Object value) { String login = (String) value; try { if (!superUserService.validateNewLogin(login)) { ((UIInput) toValidate).setValid(false); FacesMessage message = new FacesMessage("This login already exist"); context.addMessage(toValidate.getClientId(context), message); } } catch (DataAccessException exception) { message = "Database error, try again later"; } catch (TransactionException exception) { message = "Database error, try again later"; } catch (Exception e) { message = "Sorry, service is currently unavailable"; } }
@SuppressWarnings("unused") @PostConstruct private void init() { selectRights = new ArrayList<SelectItem>(); try { for (Right right : superUserService.getAllRights()) { if (right.getName().equals("ROLE_SUPER")) { continue; } SelectItem selectItem = new SelectItem(); selectItem.setLabel(right.getName()); selectItem.setValue(right.getId().toString()); selectRights.add(selectItem); } } catch (DataAccessException exception) { message = "Database error, try again later"; } catch (TransactionException exception) { message = "Database error, try again later"; } catch (Exception e) { message = "Sorry, service is currently unavailable"; } }
public List<SystemUser> getSystemUsersList() { Collection<SystemUser> result = superUserService.findAllNotSuperSystemUsers(); return (List<SystemUser>) result; }