@Override
public void onStart(Application app) {
debug("Global.onStart() called");
//Orient.instance().shutdown();
ODatabaseRecordTx db =null;
try{
if (justCreated){
try {
//we MUST use admin/admin because the db was just created
db = DbHelper.open( BBConfiguration.getAPPCODE(),"admin", "admin");
DbHelper.setupDb();
info("Initializing session manager");
ISessionTokenProvider stp = SessionTokenProvider.getSessionTokenProvider();
stp.setTimeout(com.baasbox.configuration.Application.SESSION_TOKENS_TIMEOUT.getValueAsInteger()*1000);
}catch (Throwable e){
error("!! Error initializing BaasBox!", e);
error(ExceptionUtils.getFullStackTrace(e));
throw e;
} finally {
if (db!=null && !db.isClosed()) db.close();
}
justCreated=false;
}
}catch (Throwable e){
error("!! Error initializing BaasBox!", e);
error("Abnormal BaasBox termination.");
System.exit(-1);
}
info("Updating default users passwords...");
try {
db = DbHelper.open( BBConfiguration.getAPPCODE(), BBConfiguration.getBaasBoxAdminUsername(), BBConfiguration.getBaasBoxAdminPassword());
DbHelper.evolveDB(db);
DbHelper.updateDefaultUsers();
String bbid=Internal.INSTALLATION_ID.getValueAsString();
if (bbid==null) throw new Exception ("Unique id not found! Hint: could the DB be corrupted?");
info ("BaasBox unique id is " + bbid);
} catch (Exception e) {
error("!! Error initializing BaasBox!", e);
error("Abnormal BaasBox termination.");
System.exit(-1);
} finally {
if (db!=null && !db.isClosed()) db.close();
}
try{
db = DbHelper.open( BBConfiguration.getAPPCODE(), BBConfiguration.getBaasBoxAdminUsername(), BBConfiguration.getBaasBoxAdminPassword());
IosCertificateHandler.init();
}catch (Exception e) {
error("!! Error initializing BaasBox!", e);
error("Abnormal BaasBox termination.");
System.exit(-1);
} finally {
if (db!=null && !db.isClosed()) db.close();
}
info ("...done");
overrideSettings();