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 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"; }