コード例 #1
0
ファイル: UserFormPanel.java プロジェクト: RobKuipers/ehour
  @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;
  }
コード例 #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;
  }
コード例 #3
0
ファイル: UserFormPanel.java プロジェクト: RobKuipers/ehour
  protected List<UserDepartment> getUserDepartments() {
    List<UserDepartment> departments = userService.getUserDepartments();

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

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

    return roles;
  }
コード例 #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>());
  }
コード例 #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;
  }
コード例 #7
0
ファイル: UserAdminFormPanel.java プロジェクト: ralevuk/ehour
  @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);
    }
  }
コード例 #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);
  }
コード例 #9
0
ファイル: UserFormPanel.java プロジェクト: RobKuipers/ehour
  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;
  }
コード例 #10
0
ファイル: UserFormPanel.java プロジェクト: RobKuipers/ehour
 private void deleteUser(UserManageBackingBean userManageBackingBean) {
   userService.deleteUser(userManageBackingBean.getUser().getUserId());
 }
コード例 #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;
  }
コード例 #12
0
 @Override
 @Transactional
 public void validatePMRoles(Project project) {
   userService.validateProjectManagementRoles(
       project.getProjectManager() == null ? null : project.getProjectManager().getUserId());
 }