示例#1
0
 @RequiresXsrfCheck
 protected String doExecute() throws Exception {
   if (TextUtils.stringSet(assign)) {
     groupService.addUsersToGroups(
         getJiraServiceContext(), Arrays.asList(selectedGroupsStr), getUsersToAssign());
   } else if (TextUtils.stringSet(unassign)) {
     groupService.removeUsersFromGroups(getJiraServiceContext(), getGroupRemoveUserMapper());
   }
   return redirectToView();
 }
示例#2
0
  public void doValidation() {
    super.doValidation();

    // Common validation for both add/remove
    if (selectedGroupsStr == null || selectedGroupsStr.length == 0) {
      addErrorMessage(getText("admin.bulkeditgroups.error.no.group.selected"));
      return;
    }

    // Perform the add specific validation
    if (TextUtils.stringSet(assign)) {
      if (getUsersToAssign() == null || getUsersToAssign().isEmpty()) {
        addErrorMessage(getText("admin.bulkeditgroups.error.no.users.to.add"));
        return;
      }

      GroupService.BulkEditGroupValidationResult bulkEditGroupValidationResult =
          groupService.validateAddUsersToGroup(
              getJiraServiceContext(), Arrays.asList(selectedGroupsStr), getUsersToAssign());

      if (!bulkEditGroupValidationResult.isSuccess()) {
        Collection<String> validUsers = new HashSet<String>(getUsersToAssign());
        validUsers.removeAll(bulkEditGroupValidationResult.getInvalidChildren());
        prunedUsersToAssign = validUsers;
      }
    }
    // Perform the remove specific validation
    else if (TextUtils.stringSet(unassign)) {
      if (usersToUnassign == null || usersToUnassign.length <= 0) {
        addErrorMessage(getText("admin.bulkeditgroups.error.no.users.to.remove"));
        return;
      }

      groupService.validateRemoveUsersFromGroups(
          getJiraServiceContext(), getGroupRemoveUserMapper());
    }
  }