private boolean maskHasInitiatorsBasedOnExportType(ExportGroup exportGroup,ExportMask mask,Set<URI> otherMaskURIs,List<String> portsForComputeResource,Set<URI> partialMasks){
  Set<String> foundPorts=new HashSet<>();
  if (exportGroup.forHost() || exportGroup.forCluster()) {
    if (ExportMaskUtils.hasExactlyTheseInitiators(mask,portsForComputeResource,_dbClient)) {
      return true;
    }
    if (mask.hasAnyInitiators() && ExportMaskUtils.hasExactlySubsetOfTheseInitiators(mask,portsForComputeResource,_dbClient)) {
      if (exportGroup.forCluster() && maskAppliesToMultipleHosts(mask)) {
        return true;
      }
 else       if (exportGroup.forHost()) {
        return !maskAppliesToMultipleHosts(mask);
      }
      foundPorts.addAll(ExportUtils.getExportMaskAllInitiatorPorts(mask,_dbClient));
      partialMasks.add(mask.getId());
    }
 else {
      return false;
    }
    List<ExportMask> otherMasks=_dbClient.queryObject(ExportMask.class,otherMaskURIs);
    for (    ExportMask otherMask : otherMasks) {
      if (!exportGroup.forCluster() || !maskAppliesToMultipleHosts(otherMask)) {
        if (otherMask.hasAnyInitiators() && ExportMaskUtils.hasExactlySubsetOfTheseInitiators(otherMask,portsForComputeResource,_dbClient)) {
          partialMasks.add(otherMask.getId());
          foundPorts.addAll(ExportUtils.getExportMaskAllInitiatorPorts(otherMask,_dbClient));
        }
      }
    }
    if (foundPorts.size() == portsForComputeResource.size()) {
      return true;
    }
  }
  partialMasks.clear();
  return false;
}

private boolean maskHasInitiatorsBasedOnExportType ( ExportGroup exportGroup , ExportMask mask , Set < URI > otherMaskURIs , List < String > portsForComputeResource , Set < URI > partialMasks ) { Set < String > foundPorts = new HashSet < > ( ) ; if ( exportGroup . forHost ( ) || exportGroup . forCluster ( ) ) { if ( ExportMaskUtils . hasExactlyTheseInitiators ( mask , portsForComputeResource , _dbClient ) ) { return true ; } if ( mask . hasAnyInitiators ( ) && ExportMaskUtils . hasExactlySubsetOfTheseInitiators ( mask , portsForComputeResource , _dbClient ) ) { if ( exportGroup . forCluster ( ) && maskAppliesToMultipleHosts ( mask ) ) { return true ; } else if ( exportGroup . forHost ( ) ) { return ! maskAppliesToMultipleHosts ( mask ) ; } foundPorts . addAll ( ExportUtils . getExportMaskAllInitiatorPorts ( mask , _dbClient ) ) ; partialMasks . add ( mask . getId ( ) ) ; } else { return false ; } List < ExportMask > otherMasks = _dbClient . queryObject ( ExportMask . class , otherMaskURIs ) ; for ( ExportMask otherMask : otherMasks ) { if ( ! exportGroup . forCluster ( ) || ! maskAppliesToMultipleHosts ( otherMask ) ) { if ( otherMask . hasAnyInitiators ( ) && ExportMaskUtils . hasExactlySubsetOfTheseInitiators ( otherMask , portsForComputeResource , _dbClient ) ) { partialMasks . add ( otherMask . getId ( ) ) ; foundPorts . addAll ( ExportUtils . getExportMaskAllInitiatorPorts ( otherMask , _dbClient ) ) ; } } } if ( foundPorts . size ( ) == portsForComputeResource . size ( ) ) { return true ; } } partialMasks . clear ( ) ; return false ; }
if the exportgroup . type is host or cluster , we need to check if the exportmask has all the compute resource ' s initiators . if it does , it ' s a match . if the exportgroup . type is initiator , then we just need to verify that the initiator is in it for it be considered a match .
