if (newMod == rQFileLastMod) { if (log.isDebugEnabled()) { log.debug("Not re-reading unmodified " + RecipeComponent.RECIPE_QUERY_FILE);
if (availQueries == null || newMod != rQFileLastMod) { availQueries = new HashSet(); rQFileLastMod = 0l; DBProperties dbp = null;     try { dbp = DBProperties.readQueryFile(PDbBase.QUERY_FILE); } catch (IOException ioe) { if (log.isDebugEnabled()) { log.debug("Couldn't read " + PDbBase.QUERY_FILE); }
  private static Set getAvailableQueries() {    Logger log = CSMART.createLogger("org.cougaar.tools.csmart.recipe.RecipeQueryProperty");    Set returnQ = new HashSet(); // list to return    // Read PopDB for recipe queries exactly once    if (popDBQueries == null) {      try {        popDBQueries = new HashSet();        // Get the base queries        for (Iterator i = DBProperties.readQueryFile(PDbBase.QUERY_FILE).keySet().iterator();             i.hasNext(); ) {          String s = i.next().toString();          if (s.startsWith("recipeQuery"))            popDBQueries.add(new StringRange(s));        }      } catch (IOException ioe) {        if(log.isErrorEnabled()) {          log.error("Exception", ioe);        }        popDBQueries = Collections.EMPTY_SET;      }    }    // The returned list includes at least those from popDB    returnQ.addAll(popDBQueries);    // Get the last modified date of the recipeQueries file.    // If it's the same now as it was before, dont re-read    File rqfile = ConfigFinder.getInstance().locateFile(RecipeComponent.RECIPE_QUERY_FILE);    long newMod = 0l;    if (rqfile != null) {      try {	newMod = rqfile.lastModified();      } catch (SecurityException se) {      }    }    // If file wasnt modified, use what we have    if (newMod == rQFileLastMod) {      if (log.isDebugEnabled()) {	log.debug("Not re-reading unmodified " + RecipeComponent.RECIPE_QUERY_FILE);      }      if (recipeQQueries != null)	returnQ.addAll(recipeQQueries);      return returnQ;    }    // If we get here, we're going to re-parse the recipeQueries.q file    if (recipeQQueries == null)      recipeQQueries = new HashSet();    else      recipeQQueries.clear();    // (Re-)read recipeQueries.q, allowing user to edit the query names there    try {      // FIXME: Note that cause DBProperties is caching,      // Old query names will remain,      // until we have a real reRead method in DBProperties      // Must reRead -- calling addQueryFile effectively handles adding additional      // queries, but not removing (renaming) queries      // Alternatively, have a reRead method in DBProperties      DBProperties dbp = DBProperties.readQueryFile(RecipeComponent.RECIPE_QUERY_FILE);      dbp.addQueryFile(RecipeComponent.RECIPE_QUERY_FILE);            // Only reset lastmod timestamp after succesfully reparsing      rQFileLastMod = newMod;            for (Iterator i = dbp.keySet().iterator();	   i.hasNext(); ) {	String s = i.next().toString();	if (s.startsWith("recipeQuery")) {	  // Add only if not already present	  if (! recipeQQueries.contains(new StringRange(s)))	    recipeQQueries.add(new StringRange(s));	}      }    } catch (FileNotFoundException e) {      // this is normal if a user has no separate recipe query file.      if (log.isDebugEnabled()) {	log.debug("No " + RecipeComponent.RECIPE_QUERY_FILE + " to parse.");      }    } catch (IOException ioe) {      if(log.isErrorEnabled()) {	log.error("Exception", ioe);      }    }    returnQ.addAll(recipeQQueries);    return returnQ;  }