boolean addIndexEntry(ServiceType resourceType,String resourceName,String policyName){
  boolean processed=false;
  ResourceMatch resourceMatch=resourceType.compare(this.resourceName,resourceName,false);
  if (resourceMatch.equals(ResourceMatch.EXACT_MATCH)) {
    policyNames.add(policyName);
    processed=true;
  }
 else   if (resourceMatch.equals(ResourceMatch.SUB_RESOURCE_MATCH)) {
    Iterator iter=childEntries.iterator();
    while (!processed && (iter.hasNext())) {
      ResourceIndexEntry resourceIndexEntry=(ResourceIndexEntry)iter.next();
      if (resourceIndexEntry.addIndexEntry(resourceType,resourceName,policyName)) {
        processed=true;
      }
    }
    if (!processed) {
      ResourceIndexEntry resourceIndexEntry=new ResourceIndexEntry(resourceName,policyName);
      Set children=new HashSet();
      children.addAll(childEntries);
      Iterator iter1=children.iterator();
      while (iter1.hasNext()) {
        ResourceIndexEntry rie=(ResourceIndexEntry)iter1.next();
        ResourceMatch rm=resourceType.compare(resourceName,rie.resourceName,false);
        if (rm.equals(ResourceMatch.SUB_RESOURCE_MATCH)) {
          rie.setParent(resourceIndexEntry);
        }
      }
      childEntries.add(resourceIndexEntry);
      processed=true;
    }
  }
  return processed;
}

boolean addIndexEntry ( ServiceType resourceType , String resourceName , String policyName ) { boolean processed = false ; ResourceMatch resourceMatch = resourceType . compare ( this . resourceName , resourceName , false ) ; if ( resourceMatch . equals ( ResourceMatch . EXACT_MATCH ) ) { policyNames . add ( policyName ) ; processed = true ; } else if ( resourceMatch . equals ( ResourceMatch . SUB_RESOURCE_MATCH ) ) { Iterator iter = childEntries . iterator ( ) ; while ( ! processed && ( iter . hasNext ( ) ) ) { ResourceIndexEntry resourceIndexEntry = ( ResourceIndexEntry ) iter . next ( ) ; if ( resourceIndexEntry . addIndexEntry ( resourceType , resourceName , policyName ) ) { processed = true ; } } if ( ! processed ) { ResourceIndexEntry resourceIndexEntry = new ResourceIndexEntry ( resourceName , policyName ) ; Set children = new HashSet ( ) ; children . addAll ( childEntries ) ; Iterator iter1 = children . iterator ( ) ; while ( iter1 . hasNext ( ) ) { ResourceIndexEntry rie = ( ResourceIndexEntry ) iter1 . next ( ) ; ResourceMatch rm = resourceType . compare ( resourceName , rie . resourceName , false ) ; if ( rm . equals ( ResourceMatch . SUB_RESOURCE_MATCH ) ) { rie . setParent ( resourceIndexEntry ) ; } } childEntries . add ( resourceIndexEntry ) ; processed = true ; } } return processed ; }
adds a new index entry or updates an existing index entry
