if (StringUtils.equalsIgnoreCase(syncType, "none")) return;
String src_fullurl = getSrcReplicationUrl(true);
// create a continous replication
CouchDbConnector rep_db = localCouchManager.getCouchConnector("_replicator", instance);
try {
ObjectMapper mapper = new ObjectMapper();
if (StringUtils.equalsIgnoreCase(syncType, "bi-directional") || StringUtils.equalsIgnoreCase(syncType, "pull")) {
ObjectNode pull = mapper.createObjectNode();
pull.put("_id", "couchapp-takeout-" + localDbName + "-pull");
pull.put("source", src_fullurl);
pull.put("target", localDbName);
pull.put("continuous", true);
if (StringUtils.isNotEmpty(pullFilter)) {
pull.put("filter", pullFilter);
}
rep_db.create(pull);
}
if (StringUtils.equalsIgnoreCase(syncType, "bi-directional") || StringUtils.equalsIgnoreCase(syncType, "push")) {
// other direction
ObjectNode push = mapper.createObjectNode();
push.put("_id", "couchapp-takeout-" + localDbName + "-push");
push.put("target", src_fullurl);
push.put("source", localDbName);
push.put("continuous", true);
if (StringUtils.isNotEmpty(pushFilter)) {
push.put("filter", pushFilter);
}
rep_db.create(push);
}
} catch(org.ektorp.UpdateConflictException uce) {
// the entry exists already in the replicator.
} catch (Exception e) {
// something else...no replicator db