/**
* Load configuration values, setup mailbox
*/
public void init() {
DAOFactory factory = DAOFactory.instance(DAOFactory.DEFAULT);
ConfigDAO configDAO = factory.getConfigDAO();
// possible locations for smtp_server.xml
String propertyfile = System.getProperty("sjs.smtpserver.propertyfile");
File option1 = null;
if (propertyfile != null) {
option1 = new File(propertyfile);
}
File option2 = new File("../property_files/smtp_server.xml");
File option3 = new File("~/.sjs/smtp_server.xml");
File option4 = new File("./property_files/smtp_server.xml");
// determine which location is correct, else throw exception
String smtpServerXML = "";
if (option1 != null && option1.exists()) {
try {
smtpServerXML = option1.getCanonicalPath();
} catch (IOException e) {
throw new RuntimeException("Cannot find smtp_server.xml!");
}
} else if (option2 != null && option2.exists()) {
smtpServerXML = "../property_files/smtp_server.xml";
} else if (option3 != null && option3.exists()) {
smtpServerXML = "~/.sjs/smtp_server.xml";
} else if (option4 != null && option4.exists()) {
smtpServerXML = "./property_files/smtp_server.xml";
} else {
throw new RuntimeException("Cannot find smtp_server.xml!");
}
// load the xml
config = configDAO.loadConfig(smtpServerXML);
// on error, throw new exception
if (config == null) {
throw new RuntimeException("Error retrieving smtp_server.xml!");
} // end if