package org.wookie.qti.util; import java.io.FileInputStream; import org.apache.log4j.Logger; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Properties; /** * Properties reading helper class * @author Raido Kuli */ public class PropertiesHelper { private Properties pHandler; private Logger logger = Logger.getLogger(PropertiesHelper.class.getName()); public PropertiesHelper() { this.pHandler = new Properties(); try { String basePath = System.getProperty("catalina.base"); pHandler.load(new FileInputStream(basePath+"/local.wookie_qti_api.properties")); } catch (FileNotFoundException e1) { logger.fatal("Properties file \"local.wookie_qti_api.properties\" not found."); } catch (IOException e1) { logger.fatal("Can't read properties file: \"local.wookie_qti_api.properties\""); } } /** * Return r2q2.router.ws.location from properties file * @return String r2q2.router.ws.location */ public String getR2Q2WsPath() { String r2q2Location = (String) this.pHandler.get("r2q2.router.ws.location"); if(r2q2Location == null) { logger.fatal("Could not load property \"r2q2.router.ws.location\" from properties file"); return ""; } return r2q2Location; } /** * Return waramu.ws.location from properties file * @return String waramu.ws.location */ public String getWaramuWsPath() { String wLocation = (String) this.pHandler.get("waramu.ws.location"); if(wLocation == null) { logger.fatal("Could not load property \"waramu.ws.location\" from properties file"); return ""; } return wLocation; } public String getWaramuUsername() { String wUsername = (String) this.pHandler.get("waramu.username"); if(wUsername == null) { logger.fatal("Could not load property \"waramu.username\" from properties file"); return ""; } return wUsername; } public String getWaramuPassword() { String wPasswd = (String) this.pHandler.get("waramu.password"); if(wPasswd == null) { logger.fatal("Could not load property \"waramu.password\" from properties file"); return ""; } return wPasswd; } public String getWaramuQueryXmlns() { String qXmlns = (String) this.pHandler.get("waramu.query.xmlns"); if(qXmlns == null) { logger.fatal("Could not load property \"waramu.query.xmlns\" from properties file"); return ""; } return qXmlns; } }