importPackage( Packages.javax.xml.parsers); importPackage( Packages.org.xml.sax); importPackage( Packages.org.w3c.dom); importPackage( Packages.java.io); function load_document(file) { factory = DocumentBuilderFactory.newInstance(); builder = factory.newDocumentBuilder(); filestream = new FileInputStream( file ); document = builder.parse( new InputSource( filestream )); filestream.close(); return document; } function getTagValue(document, tagName) { nlist = document.getElementsByTagName(tagName); return nlist.item(0).getFirstChild().getNodeValue(); } function find_config() { config_list = Array("conf/metrics.xml", "tomcat/webapps/pkit/WEB-INF/conf/PkitMetrics.xml", "C:/Program Files/methodpark/projectkit/tomcat/webapps/pkit/WEBINF/conf/PkitMetrics.xml", "C:/methodpark/stages/tomcat/webapps/pkit/WEB-INF/conf/PkitMetrics.xml", "K:/PkitMetrics.xml" ); for (var i=0; i<config_list.length; i++) { conf=new File(config_list[i]); if (conf.exists()) { return conf; } } throw "PkitMetrics.xml not found"; } my_conf = find_config(); doc = load_document(my_conf); this.setExtensionProperty("serverUrl",getTagValue(doc, "serverUrl")); this.setExtensionProperty("user",getTagValue(doc, "user")); this.setExtensionProperty("password",getTagValue(doc, "password")); reportContext.setGlobalVariable("serverUrl",this.getExtensionProperty("serverUrl"));