public boolean matchUserAttributesToUserGroup(StorageOSUserDAO user,UserGroup roleAssignmentUserGroup){
  boolean isUserGroupMatchesUserAttributes=false;
  if (roleAssignmentUserGroup == null || user == null) {
    _log.error("Invalid user {} or user group {}",user,roleAssignmentUserGroup);
    return isUserGroupMatchesUserAttributes;
  }
  Set<String> userGroupDoNotMatch=new HashSet<String>();
  for (  String roleAssignmentUserAttributeString : roleAssignmentUserGroup.getAttributes()) {
    if (StringUtils.isBlank(roleAssignmentUserAttributeString)) {
      _log.debug("Invalid user attributes param string");
      continue;
    }
    boolean isUserGroupMatchesUserAttribute=false;
    UserAttributeParam roleAssignmentUserAttribute=UserAttributeParam.fromString(roleAssignmentUserAttributeString);
    if (roleAssignmentUserAttribute == null) {
      _log.warn("Failed to convert user attributes param string {} to object.",roleAssignmentUserAttributeString);
      continue;
    }
    for (    String userAttributeString : user.getAttributes()) {
      UserAttributeParam userAttribute=UserAttributeParam.fromString(userAttributeString);
      if (userAttribute == null) {
        _log.info("Failed to convert user attributes param string {} to object.",userAttributeString);
        continue;
      }
      _log.debug("Comparing user attributes {} with user group attribute {}",userAttributeString,roleAssignmentUserAttributeString);
      if (userAttribute.containsAllAttributeValues(roleAssignmentUserAttribute)) {
        _log.debug("Found user attributes {} matching with user group attributes {}",userAttributeString,roleAssignmentUserAttributeString);
        isUserGroupMatchesUserAttribute=true;
        break;
      }
    }
    if (isUserGroupMatchesUserAttribute == false) {
      _log.debug("Adding user group {} to the do not match list",roleAssignmentUserAttributeString);
      userGroupDoNotMatch.add(roleAssignmentUserAttributeString);
    }
  }
  if (CollectionUtils.isEmpty(userGroupDoNotMatch)) {
    isUserGroupMatchesUserAttributes=true;
  }
  return isUserGroupMatchesUserAttributes;
}

public boolean matchUserAttributesToUserGroup ( StorageOSUserDAO user , UserGroup roleAssignmentUserGroup ) { boolean isUserGroupMatchesUserAttributes = false ; if ( roleAssignmentUserGroup == null || user == null ) { _log . error ( "Invalid user {} or user group {}" , user , roleAssignmentUserGroup ) ; return isUserGroupMatchesUserAttributes ; } Set < String > userGroupDoNotMatch = new HashSet < String > ( ) ; for ( String roleAssignmentUserAttributeString : roleAssignmentUserGroup . getAttributes ( ) ) { if ( StringUtils . isBlank ( roleAssignmentUserAttributeString ) ) { _log . debug ( "Invalid user attributes param string" ) ; continue ; } boolean isUserGroupMatchesUserAttribute = false ; UserAttributeParam roleAssignmentUserAttribute = UserAttributeParam . fromString ( roleAssignmentUserAttributeString ) ; if ( roleAssignmentUserAttribute == null ) { _log . warn ( "Failed to convert user attributes param string {} to object." , roleAssignmentUserAttributeString ) ; continue ; } for ( String userAttributeString : user . getAttributes ( ) ) { UserAttributeParam userAttribute = UserAttributeParam . fromString ( userAttributeString ) ; if ( userAttribute == null ) { _log . info ( "Failed to convert user attributes param string {} to object." , userAttributeString ) ; continue ; } _log . debug ( "Comparing user attributes {} with user group attribute {}" , userAttributeString , roleAssignmentUserAttributeString ) ; if ( userAttribute . containsAllAttributeValues ( roleAssignmentUserAttribute ) ) { _log . debug ( "Found user attributes {} matching with user group attributes {}" , userAttributeString , roleAssignmentUserAttributeString ) ; isUserGroupMatchesUserAttribute = true ; break ; } } if ( isUserGroupMatchesUserAttribute == false ) { _log . debug ( "Adding user group {} to the do not match list" , roleAssignmentUserAttributeString ) ; userGroupDoNotMatch . add ( roleAssignmentUserAttributeString ) ; } } if ( CollectionUtils . isEmpty ( userGroupDoNotMatch ) ) { isUserGroupMatchesUserAttributes = true ; } return isUserGroupMatchesUserAttributes ; }
compare the user group with the list of user ' s attributes .
