Index: src/web/src/org/opennms/web/graph/PrefabGraph.java =================================================================== RCS file: /cvsroot/opennms/opennms/src/web/src/org/opennms/web/graph/PrefabGraph.java,v retrieving revision 1.8 diff -U3 -r1.8 PrefabGraph.java --- src/web/src/org/opennms/web/graph/PrefabGraph.java 22 Mar 2005 05:49:26 -0000 1.8 +++ src/web/src/org/opennms/web/graph/PrefabGraph.java 27 Jan 2006 23:37:27 -0000 @@ -32,15 +32,90 @@ package org.opennms.web.graph; +import java.io.File; +import java.io.FileInputStream; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Properties; +import org.opennms.core.resource.Vault; import org.opennms.core.utils.BundleLists; public class PrefabGraph extends Object implements Comparable { public static final String DEFAULT_GRAPH_LIST_KEY = "reports"; + static public class Config extends Object { + public Map prefabGraphs; + public Properties rawProps; + } + /* * + * Return a PrefabGraph.Config, + * + * Parses the specified file (baseConfigName is relative to ONMS home dir), and + * merges in any properties files in the baseConfigName".d" directory. + * + * rawProps will contain the raw merged Properties object (so caller can pull + * out any non-report parameters + * + * prefabGraphs is a Map of PrefabGraph objects keyed on the name as specified + * in the config file. + */ + + public static PrefabGraph.Config getPrefabGraphConfiguration(String baseConfigName) throws IOException { + PrefabGraph.Config result = new PrefabGraph.Config(); + String homeDir = Vault.getHomeDir(); + Properties props = new java.util.Properties(); + String baseFilename=homeDir+baseConfigName; + + props.load(new FileInputStream(baseFilename)); + File propsDir=new File(baseFilename+".d"); + + if(propsDir.exists()) { + //FInd all *.properties files in propsDir + File[] subPropFiles=propsDir.listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + return name.endsWith(".properties"); + } + }); + + for(int i=0; i