private void validateGroupAcls(DBGroup targetGroup,List<DBAcl> acls) throws InvalidRequestException, SQLException {
  if (acls.isEmpty()) {
    throw new InvalidRequestException("acls must not be empty");
  }
  HashSet<Integer> uniqueMemberIdentities=new HashSet<>();
  HashSet<Integer> uniqueMemberGroups=new HashSet<>();
  for (  DBAcl acl : acls) {
    if (acl.getGroupId().getId() != targetGroup.getId()) {
      throw new InvalidRequestException("acl applies to the wrong group");
    }
    boolean isIdentityAcl=acl.getMemberIdentityId() != null;
    boolean isGroupAcl=acl.getMemberGroupId() != null;
    if (!(isIdentityAcl ^ isGroupAcl)) {
      throw new InvalidRequestException("acl must apply to exactly one identity or group; " + "specifies identity: " + isIdentityAcl + "; specifies group: "+ isGroupAcl);
    }
    if (isIdentityAcl) {
      assert !isGroupAcl;
      if (!uniqueMemberIdentities.add(acl.getMemberIdentityId().getId())) {
        throw new InvalidRequestException("duplicate identity: " + acl.getMemberIdentityId().getId());
      }
    }
 else {
      assert !isIdentityAcl;
      if (!uniqueMemberGroups.add(acl.getMemberGroupId().getId())) {
        throw new InvalidRequestException("duplicate group: " + acl.getMemberGroupId().getId());
      }
    }
  }
  if (!uniqueMemberIdentities.isEmpty()) {
    if (DBIdentity.getUserNamesFromIds(manager,uniqueMemberIdentities).size() != uniqueMemberIdentities.size()) {
      throw new InvalidRequestException("some identities do not exist");
    }
  }
  if (!uniqueMemberGroups.isEmpty()) {
    QueryBuilder<DBGroup,Integer> groupQuery=getDirectlyAccessibleGroupsQuery(uniqueMemberGroups);
    if (groupQuery.countOf() != uniqueMemberGroups.size()) {
      throw new InvalidRequestException("some groups are not accessible");
    }
  }
}

private void validateGroupAcls ( DBGroup targetGroup , List < DBAcl > acls ) throws InvalidRequestException , SQLException { if ( acls . isEmpty ( ) ) { throw new InvalidRequestException ( "acls must not be empty" ) ; } HashSet < Integer > uniqueMemberIdentities = new HashSet < > ( ) ; HashSet < Integer > uniqueMemberGroups = new HashSet < > ( ) ; for ( DBAcl acl : acls ) { if ( acl . getGroupId ( ) . getId ( ) != targetGroup . getId ( ) ) { throw new InvalidRequestException ( "acl applies to the wrong group" ) ; } boolean isIdentityAcl = acl . getMemberIdentityId ( ) != null ; boolean isGroupAcl = acl . getMemberGroupId ( ) != null ; if ( ! ( isIdentityAcl ^ isGroupAcl ) ) { throw new InvalidRequestException ( "acl must apply to exactly one identity or group; " + "specifies identity: " + isIdentityAcl + "; specifies group: " + isGroupAcl ) ; } if ( isIdentityAcl ) { assert ! isGroupAcl ; if ( ! uniqueMemberIdentities . add ( acl . getMemberIdentityId ( ) . getId ( ) ) ) { throw new InvalidRequestException ( "duplicate identity: " + acl . getMemberIdentityId ( ) . getId ( ) ) ; } } else { assert ! isIdentityAcl ; if ( ! uniqueMemberGroups . add ( acl . getMemberGroupId ( ) . getId ( ) ) ) { throw new InvalidRequestException ( "duplicate group: " + acl . getMemberGroupId ( ) . getId ( ) ) ; } } } if ( ! uniqueMemberIdentities . isEmpty ( ) ) { if ( DBIdentity . getUserNamesFromIds ( manager , uniqueMemberIdentities ) . size ( ) != uniqueMemberIdentities . size ( ) ) { throw new InvalidRequestException ( "some identities do not exist" ) ; } } if ( ! uniqueMemberGroups . isEmpty ( ) ) { QueryBuilder < DBGroup , Integer > groupQuery = getDirectlyAccessibleGroupsQuery ( uniqueMemberGroups ) ; if ( groupQuery . countOf ( ) != uniqueMemberGroups . size ( ) ) { throw new InvalidRequestException ( "some groups are not accessible" ) ; } } }
throws an exception if the acl list is not valid : - must not be empty - must apply to targetgroup . - members must be an identity or a group , not both . - identities must already exist in the database . - groups must be accessible by this user and exist . - no duplicate users or groups
