Commit e523bf10 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

Merge branch 'v4.1-dev' into 'v4.x-master'

434: Fix mongodb configuration bias (OPENED)

See merge request !25
parents 0ca2377c a519dcc9
Pipeline #24703 passed with stages
in 7 minutes and 45 seconds
......@@ -9,7 +9,7 @@ allprojects {
apply plugin: 'eclipse'
group = 'eu.dariah.de.minfba'
version = '4.1.2-SNAPSHOT'
version = '4.1.3-SNAPSHOT'
repositories {
mavenLocal()
......
......@@ -38,7 +38,6 @@ public class UpdateServiceImpl implements InitializingBean {
private final static String versionHashPrefix = "GenericSearch";
private String backupsBasePath;
private String database;
private final MessageDigest md;
......@@ -47,10 +46,9 @@ public class UpdateServiceImpl implements InitializingBean {
@Autowired private VersionDao versionDao;
public UpdateServiceImpl(String backupsBasePath, String database) throws NoSuchAlgorithmException {
public UpdateServiceImpl(String backupsBasePath) throws NoSuchAlgorithmException {
this.md = MessageDigest.getInstance("MD5");
this.backupsBasePath = backupsBasePath;
this.database = database;
}
public UpdateServiceImpl() throws NoSuchAlgorithmException {
......@@ -145,7 +143,7 @@ public class UpdateServiceImpl implements InitializingBean {
Files.createDirectories(Paths.get(new File(backupPath).toURI()), new FileAttribute<?>[0]);
try {
Runtime.getRuntime().exec(String.format("mongodump --out %s --db %s", backupPath, database));
Runtime.getRuntime().exec(String.format("mongodump --out %s --db %s", backupPath, mongoTemplate.getDb().getName()));
} catch (Exception e) {
log.error("Failed to create mongodb backup", e);
throw e;
......
......@@ -15,6 +15,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.mongodb.config.MongoConfigurationSupport;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -34,7 +35,6 @@ import lombok.EqualsAndHashCode;
@ConfigurationProperties
public class MainConfig extends MainConfigProperties {
@Autowired MongoConfig mongoConfig;
@Autowired ResourceLoader resourceLoader;
@PostConstruct
......@@ -122,7 +122,7 @@ public class MainConfig extends MainConfigProperties {
@Bean
public UpdateServiceImpl updateService() throws NoSuchAlgorithmException {
return new UpdateServiceImpl(paths.getBackups(), mongoConfig.getDatabase());
return new UpdateServiceImpl(paths.getBackups());
}
@Bean
......
package eu.dariah.de.search.config;
import java.util.Collection;
import java.util.Collections;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import com.mongodb.ConnectionString;
import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@Getter
@Setter
@Slf4j
@Configuration
@ConfigurationProperties(prefix = "mongo")
@EnableMongoRepositories(basePackages = "eu.dariah.de.search.dao.db")
public class MongoConfig extends AbstractMongoClientConfiguration {
private String host = "localhost";
private Integer port = 27017;
private String database = "search";
@Override
protected String getDatabaseName() {
return database;
}
@Override
public MongoClient mongoClient() {
String connectionString = String.format("mongodb://%s:%s/%s", host, port, database);
log.debug("Mongo client initializing with connection: {}", connectionString);
ConnectionString connectionStringObj = new ConnectionString(connectionString);
MongoClientSettings mongoClientSettings = MongoClientSettings.builder()
.applyConnectionString(connectionStringObj)
.build();
return MongoClients.create(mongoClientSettings);
}
@Override
public Collection<String> getMappingBasePackages() {
return Collections.singleton("eu.dariah.de.search.model");
}
}
......@@ -17,11 +17,6 @@ localization:
theme: dariah-theme
mongo:
host: 127.0.0.1
port: 27017
database: search
contextPath: /search
baseUrl: http://localhost:8393${contextPath:/}
#baseUrl: https://externally.visible.example.com${contextPath:/}
......@@ -31,7 +26,12 @@ spring:
view:
prefix: /WEB-INF/views/
suffix: .jsp
data:
mongodb:
host: 127.0.0.1
port: 27017
database: search
#logging:
# level:
# web: DEBUG
......
......@@ -88,12 +88,6 @@ theme: tutorial-finder-theme
# width: 150
# height: 150
mongo:
host: 127.0.0.1
port: 27017
database: search_boot
#contextPath: /contextpath
#baseUrl: http://localhost:8080${contextPath:/}
......@@ -104,7 +98,12 @@ spring:
view:
prefix: /WEB-INF/views/
suffix: .jsp
data:
mongodb:
host: 127.0.0.1
port: 27017
database: search
#logging:
# level:
# web: DEBUG
......
Subproject commit ca479bb95e8f7dac66ac4718192f1374710bb06e
Subproject commit 11e3a70be8ceffdcf95b0e6429f3cee814349daa
Supports Markdown
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