Skip to content
Snippets Groups Projects
Commit dc06e767 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Merge branch 'fix-designdoc-creation' into 'master'

Fix design doc creation

See merge request !69
parents 136134c1 6836d3dd
1 merge request!69Fix design doc creation
Pipeline #9330 passed with stages
in 2 minutes and 21 seconds
......@@ -17,6 +17,8 @@ public class PersistanceConfig {
@Value("${couchdb.name}") private String couchDbName;
@Value("${couchdb.host}") private String couchDbHost;
@Value("${couchdb.port}") private int couchDbPort;
@Value("${couchdb.username:}") private String couchDbUsername;
@Value("${couchdb.password:}") private String couchDbPassword;
@Bean
public CouchDbConnector couchDbConnector() throws Exception {
......@@ -33,6 +35,10 @@ public class PersistanceConfig {
final HttpClientFactoryBean factory = new HttpClientFactoryBean();
factory.setHost(couchDbHost);
factory.setPort(couchDbPort);
if (!couchDbUsername.isEmpty()) {
factory.setUsername(couchDbUsername);
factory.setPassword(couchDbPassword);
}
return factory;
}
......
......@@ -2,6 +2,7 @@ package de.thm.arsnova.persistance.couchdb;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.ektorp.CouchDbInstance;
import org.ektorp.DocumentNotFoundException;
import org.ektorp.impl.ObjectMapperFactory;
import org.ektorp.impl.StdCouchDbConnector;
import org.slf4j.Logger;
......@@ -62,12 +63,12 @@ public class InitializingCouchDbConnector extends StdCouchDbConnector implements
logger.warn("Failed to serialize design doc.", e);
}
}
String rev = getCurrentRevision((String) doc.get("_id"));
if (rev == null) {
create(doc);
} else {
try {
String rev = getCurrentRevision((String) doc.get("_id"));
doc.put("_rev", rev);
update(doc);
} catch (DocumentNotFoundException e) {
create(doc);
}
});
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment