boolean addIndexEntry(String resourceName,String policyName){
  Iterator iter=topLevelEntries.iterator();
  boolean processed=false;
  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 currentEntries=new HashSet();
    currentEntries.addAll(topLevelEntries);
    Iterator iter1=currentEntries.iterator();
    while (iter1.hasNext()) {
      ResourceIndexEntry rie=(ResourceIndexEntry)iter1.next();
      ResourceMatch rm=resourceType.compare(resourceName,rie.getResourceName(),false);
      if (rm.equals(ResourceMatch.SUB_RESOURCE_MATCH)) {
        rie.setParent(resourceIndexEntry);
        topLevelEntries.remove(rie);
      }
    }
    topLevelEntries.add(resourceIndexEntry);
    processed=true;
  }
  return processed;
}

boolean addIndexEntry ( String resourceName , String policyName ) { Iterator iter = topLevelEntries . iterator ( ) ; boolean processed = false ; 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 currentEntries = new HashSet ( ) ; currentEntries . addAll ( topLevelEntries ) ; Iterator iter1 = currentEntries . iterator ( ) ; while ( iter1 . hasNext ( ) ) { ResourceIndexEntry rie = ( ResourceIndexEntry ) iter1 . next ( ) ; ResourceMatch rm = resourceType . compare ( resourceName , rie . getResourceName ( ) , false ) ; if ( rm . equals ( ResourceMatch . SUB_RESOURCE_MATCH ) ) { rie . setParent ( resourceIndexEntry ) ; topLevelEntries . remove ( rie ) ; } } topLevelEntries . add ( resourceIndexEntry ) ; processed = true ; } return processed ; }
adds or updates an index entry
