int totalSteps = 3;
if (haveToInstallCouch) {
step++;
totalSteps = 4; // one extra step
EventBus.publish(new LoadingMessage(step++, totalSteps, "Installing DB...", 0, 0, "Starting..." ));
localCouchManager.installCouchDbEmbedded();
}
couchDbInstance = localCouchManager.getCouchInstance();
CouchDbConnector db = localCouchManager.getCouchConnector(localDbName, couchDbInstance);
try {
db.createDatabaseIfNotExists();
} catch (org.ektorp.DbAccessException dae) {
// we need to login to the db
promptForCredientials(true);
localCouchManager.setCredentials(local_username, local_password);
couchDbInstance = localCouchManager.getCouchInstance();
db = localCouchManager.getCouchConnector(localDbName, couchDbInstance);
db.createDatabaseIfNotExists();
}
// handle design docs very differently.
EventBus.publish(new LoadingMessage(step++, totalSteps, "Downloading Data", 0, 0, "Copy data from " + getSrcReplicationUrl(false) ));
copyDesignDocs(getSrcConnector(), db);
// init one time replicate
setupReplication(couchDbInstance, db);
EventBus.publish(new LoadingMessage(totalSteps, totalSteps, "Downloading Data", 4, 4, "Complete!"));
return db;
}