Example #1
0
  public void updateUserDetails(CustomUser cu) throws UsernameNotFoundException {
    CustomItem elevator = userDAO.getUserElevator(cu.getId());
    if (elevator == null) {
      throw new UsernameNotFoundException("Elevator not found");
    }

    CustomItem div = userDAO.getUserDiv(cu.getId());
    if (div == null || div.getLabel() == null) {
      throw new UsernameNotFoundException("DIV not found");
    }

    Integer type = userDAO.getUserScaleType(cu.getId());
    String str = userDAO.getUserRole(cu.getId());
    if (!str.isEmpty()) {
      WebRole role = WebRole.valueOf(str);
      if (role != null) cu.setLevel(role);
      else {
        throw new UsernameNotFoundException("WebRole doesn't exist");
      }
    } else {
      throw new UsernameNotFoundException("WebRole not found");
    }

    cu.setScaleType(type);
    cu.setElevator(elevator);
    cu.setDiv(div);
  }