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