コード例 #1
0
  public void deleteUser(Session session, final IPentahoUser user)
      throws NotFoundException, RepositoryException {
    if (canDeleteUser(session, user)) {
      User jackrabbitUser = getJackrabbitUser(user.getTenant(), user.getUsername(), session);
      if (jackrabbitUser != null
          && TenantUtils.isAccessibleTenant(
              tenantedUserNameUtils.getTenant(jackrabbitUser.getID()))) {

        // [BISERVER-9215] Adding new user with same user name as a previously deleted user,
        // defaults to all previous roles
        Iterator<Group> currentGroups = jackrabbitUser.memberOf();
        while (currentGroups.hasNext()) {
          currentGroups.next().removeMember(jackrabbitUser);
        }
        // [BISERVER-9215]

        jackrabbitUser.remove();
      } else {
        throw new NotFoundException(""); // $NON-NLS-1$
      }
    } else {
      throw new RepositoryException(
          Messages.getInstance()
              .getString(
                  "AbstractJcrBackedUserRoleDao.ERROR_0004_LAST_USER_NEEDED_IN_ROLE",
                  tenantAdminRoleName));
    }
  }
コード例 #2
0
 public List<IPentahoUser> getUsers(
     Session session, final ITenant theTenant, boolean includeSubtenants)
     throws RepositoryException {
   ArrayList<IPentahoUser> users = new ArrayList<IPentahoUser>();
   if (TenantUtils.isAccessibleTenant(theTenant)) {
     UserManager userMgr = getUserManager(theTenant, session);
     pPrincipalName = ((SessionImpl) session).getJCRName(P_PRINCIPAL_NAME);
     Iterator<Authorizable> it =
         userMgr.findAuthorizables(pPrincipalName, null, UserManager.SEARCH_TYPE_USER);
     while (it.hasNext()) {
       User user = (User) it.next();
       IPentahoUser pentahoUser = convertToPentahoUser(user);
       if (includeSubtenants) {
         users.add(pentahoUser);
       } else {
         if (pentahoUser.getTenant() != null && pentahoUser.getTenant().equals(theTenant)) {
           users.add(pentahoUser);
         }
       }
     }
   }
   return users;
 }