예제 #1
0
 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";
 }
예제 #2
0
 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";
 }
예제 #3
0
 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";
   }
 }
예제 #4
0
 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";
   }
 }
예제 #5
0
 @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";
   }
 }
예제 #6
0
 public List<SystemUser> getSystemUsersList() {
   Collection<SystemUser> result = superUserService.findAllNotSuperSystemUsers();
   return (List<SystemUser>) result;
 }