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

427: Make grammar compilation available from within container (OPENED)

Task-Url: #427
parent a79cf0f1
......@@ -19,8 +19,8 @@ allprojects {
}
ext {
coreVersion = "6.2-SNAPSHOT"
gtfVersion = "2.0.0-SNAPSHOT"
processingVersion = "4.1.0-SNAPSHOT"
gtfVersion = "2.1.0-SNAPSHOT"
processingVersion = "4.2.0-SNAPSHOT"
colregModelVersion = "4.3.4-RELEASE"
dariahSpVersion = "2.1.6-RELEASE"
......
......@@ -11,6 +11,4 @@ public interface IndexClient extends BaseEsClient {
public String[] getIndexNames();
public String getIndexNameForDatamodelId(String modelId);
public String getIndexConfigPath();
}
......@@ -30,11 +30,7 @@ public class IndexClientImpl extends BaseEsClientImpl implements IndexClient, In
private Pattern indexNamePattern;
@Autowired private File indexConfigFile;
@Override public String getIndexConfigPath() {
return indexConfigFile.getAbsolutePath();
}
@Autowired private Settings indexConfigSettings;
@Override
public void afterPropertiesSet() throws Exception {
......@@ -55,20 +51,13 @@ public class IndexClientImpl extends BaseEsClientImpl implements IndexClient, In
@Override
public boolean createIndex(String indexName) {
Assert.notNull(indexName, "Index name cannot be null");
Settings settings = null;
try {
if (this.indexExists(indexName)) {
throw new ElasticsearchAdminException(String.format("Index [%s] already exists and needs to be deleted manually", indexName));
}
if (this.getIndexConfigPath()!=null) {
settings = Settings.builder().loadFromPath(Paths.get(getIndexConfigPath())).build();
}
CreateIndexRequest request = new CreateIndexRequest(indexName);
if (settings==null) {
logger.warn("No index configuration available. Please check configuration of this search instance");
}
request.settings(settings);
request.settings(indexConfigSettings);
return client.indices().create(request, RequestOptions.DEFAULT).isAcknowledged();
} catch (Exception e) {
logger.error("Failed to create index settings", e);
......
......@@ -29,6 +29,6 @@ public class BaseEsClientTest extends BaseEsIntegrationTest {
@BeforeEach
public void setup() throws Exception {
Mockito.when(indexClient.getIndexConfigPath()).thenReturn(indexConfig.getAbsolutePath());
//Mockito.when(indexClient.getIndexConfigPath()).thenReturn(indexConfig.getAbsolutePath());
}
}
......@@ -9,6 +9,7 @@ import java.security.NoSuchAlgorithmException;
import javax.annotation.PostConstruct;
import org.elasticsearch.common.settings.Settings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
......@@ -111,15 +112,12 @@ public class MainConfig extends MainConfigProperties {
}
@Bean
public File indexConfigFile() throws ConfigurationException, IOException {
public Settings indexConfigSettings() throws ConfigurationException, IOException {
File indexConfig = new File(this.getPaths().getConfig() + File.separator + this.getIndexing().getIndexConfigFile());
if (!indexConfig.exists()) {
indexConfig = resourceLoader.getResource("classpath:conf/" + this.getIndexing().getIndexConfigFile()).getFile();
if (indexConfig.exists()) {
return Settings.builder().loadFromPath(Paths.get(indexConfig.getAbsolutePath())).build();
}
if (!indexConfig.exists()) {
throw new ConfigurationException("Index config (index_config.json) not provided or does not exist");
}
return indexConfig;
return Settings.builder().loadFromStream("index_config.json", resourceLoader.getResource("classpath:conf/" + this.getIndexing().getIndexConfigFile()).getInputStream(), true).build();
}
@Bean
......
......@@ -62,11 +62,11 @@ public class WebConfig implements WebMvcConfigurer {
@Bean
public Navigation navigation(ObjectMapper objectMapper) throws IOException {
File navigation = new File(mainConfig.getPaths().getConfig() + File.separator + "navigation.json");
if (!navigation.exists()) {
navigation = resourceLoader.getResource("classpath:conf/navigation.json").getFile();
}
if (navigation.exists()) {
return objectMapper.readValue(navigation, Navigation.class);
}
return objectMapper.readValue(resourceLoader.getResource("classpath:conf/navigation.json").getInputStream(), Navigation.class);
}
@Bean
public ThemeManagerImpl themeManagerImpl() {
......
Markdown is supported
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