Example #1
0
  @Override
  protected boolean processFormSubmit(
      AjaxRequestTarget target, AdminBackingBean backingBean, AjaxEventType type) throws Exception {
    UserManageBackingBean userManageBackingBean = (UserManageBackingBean) backingBean;

    boolean eventHandled;

    try {
      User user = userManageBackingBean.getUser();
      eventHandled = false;

      if (type == USER_CREATED) {
        userService.persistNewUser(user, user.getPassword());
      } else if (type == USER_UPDATED) {
        userService.persistEditedUser(user);

        String password = user.getPassword();
        if (StringUtils.isNotBlank(password)) {
          userService.changePassword(user.getUsername(), password);
        }
      } else if (type == USER_DELETED) {
        deleteUser(userManageBackingBean);
      }
    } catch (ObjectNotUniqueException obnu) {
      backingBean.setServerMessage(obnu.getMessage());
      target.add(this);
      eventHandled = true;
    }

    return !eventHandled;
  }
Example #2
0
  private List<User> getUsers() {
    List<User> users =
        currentFilter == null
            ? userService.getActiveUsers()
            : userService.getUsers(currentFilter.isActivateToggle());

    System.out.println("cf:" + currentFilter);

    Collections.sort(users, new UserComparator(false));

    return users;
  }
Example #3
0
  protected List<UserDepartment> getUserDepartments() {
    List<UserDepartment> departments = userService.getUserDepartments();

    Collections.sort(departments, new UserDepartmentComparator());

    return departments;
  }
Example #4
0
  /**
   * Get all the roles from the backend
   *
   * @return
   */
  private List<UserRole> getUserRoles() {
    if (roles == null) {
      roles = userService.getUserRoles();
    }

    return roles;
  }
Example #5
0
  @Before
  public void setup_userservice() throws Exception {
    super.setUp();
    getMockContext().putBean("userService", userService);

    List<User> users = new ArrayList<User>();
    user = new User();
    user.setFirstName("thies");
    user.setUserId(1);
    user.setLastName("Edeling");
    user.setUserRoles(Sets.newHashSet(UserRole.ADMIN));
    users.add(user);

    when(userService.getActiveUsers()).thenReturn(users);
    when(userService.getUserRoles()).thenReturn(new ArrayList<UserRole>());
    when(userService.getUserDepartments()).thenReturn(new ArrayList<UserDepartment>());
  }
Example #6
0
  /**
   * Get all departments from the backend
   *
   * @return
   */
  private List<UserDepartment> getUserDepartments() {
    if (departments == null) {
      departments = userService.getUserDepartments();
    }

    Collections.sort(departments, new UserDepartmentComparator());

    return departments;
  }
Example #7
0
  @Override
  protected void processFormSubmit(
      AjaxRequestTarget target, AdminBackingBean backingBean, AjaxEventType type) throws Exception {
    UserBackingBean userBackingBean = (UserBackingBean) backingBean;

    if (type == UserEditAjaxEventType.USER_UPDATED) {
      if (userBackingBean.getAdminAction() == AdminAction.NEW) {
        userService.newUser(userBackingBean.getUser(), userBackingBean.getUser().getPassword());
      } else {
        userService.editUser(userBackingBean.getUser());

        String password = userBackingBean.getUser().getPassword();
        if (StringUtils.isNotBlank(password)) {
          userService.changePassword(userBackingBean.getUser().getUsername(), password);
        }
      }
    } else if (type == UserEditAjaxEventType.USER_DELETED) {
      deleteUser(userBackingBean);
    }
  }
Example #8
0
  @Test
  public void use_read_only_when_manager_views_admin() throws ObjectNotFoundException {
    getConfig().setSplitAdminRole(true);
    when(userService.getUserAndCheckDeletability(1)).thenReturn(user);

    webApp.setAuthorizedRoles(new Roles(UserRole.ROLE_MANAGER));
    super.startTester();

    tester.startPage(ManageUserPage.class);

    tester.executeAjaxEvent(
        "userSelection:border:border_body:entrySelectorFrame:entrySelectorFrame:blueBorder:blueBorder_body:itemListHolder:itemList:0",
        "click");

    tester.assertComponent("tabs:panel", ManageUserReadOnlyPanel.class);
  }
Example #9
0
  private List<UserRole> getUserRoles() {
    List<UserRole> roles = userService.getUserRoles();

    roles.remove(UserRole.PROJECTMANAGER);

    User user = EhourWebSession.getUser();

    if (!SecurityRules.isAdmin(user)) {
      roles.remove(UserRole.ADMIN);
    }

    if (!EhourWebSession.getEhourConfig().isSplitAdminRole()) {
      roles.remove(UserRole.MANAGER);
    }

    return roles;
  }
Example #10
0
 private void deleteUser(UserManageBackingBean userManageBackingBean) {
   userService.deleteUser(userManageBackingBean.getUser().getUserId());
 }
Example #11
0
  /**
   * Get the user departments from the backend
   *
   * @return
   */
  private List<UserDepartment> getUserDepartments() {
    List<UserDepartment> userDepartments = userService.getUserDepartments();
    Collections.sort(userDepartments, new UserDepartmentComparator());

    return userDepartments;
  }
Example #12
0
 @Override
 @Transactional
 public void validatePMRoles(Project project) {
   userService.validateProjectManagementRoles(
       project.getProjectManager() == null ? null : project.getProjectManager().getUserId());
 }