diff --git a/.mvn/maven.config b/.mvn/maven.config index 6d72037a..7b5e7953 100644 --- a/.mvn/maven.config +++ b/.mvn/maven.config @@ -1,3 +1,3 @@ --Drevision=3.7.0 +-Drevision=3.8.0 -Dsha1= -Dchangelist=-SNAPSHOT diff --git a/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/AnalysisCentricElasticSearchAdapter.java b/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/AnalysisCentricElasticSearchAdapter.java index b8439bee..dd455e7a 100644 --- a/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/AnalysisCentricElasticSearchAdapter.java +++ b/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/AnalysisCentricElasticSearchAdapter.java @@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.util.StdDateFormat; import io.github.resilience4j.retry.Retry; import io.github.resilience4j.retry.RetryConfig; import java.io.IOException; @@ -146,16 +147,15 @@ private List getAnalysisCentricDocuments( private UpdateRequest mapAnalysisToUpsertRepositoryQuery( AnalysisCentricDocument analysisCentricDocument) { val mapper = new ObjectMapper().setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); - val paramsBuilder = new HashMap(); paramsBuilder.put( "repository", mapper.convertValue(analysisCentricDocument.getRepositories().get(0), Map.class)); paramsBuilder.put("analysis_state", analysisCentricDocument.getAnalysisState()); - paramsBuilder.put("updated_at", analysisCentricDocument.getUpdatedAt()); + paramsBuilder.put("updated_at", getDateIso(analysisCentricDocument.getUpdatedAt())); if (analysisCentricDocument.getPublishedAt() != null) { // Nullable as may not have been published - paramsBuilder.put("published_at", analysisCentricDocument.getPublishedAt()); + paramsBuilder.put("published_at", getDateIso(analysisCentricDocument.getPublishedAt())); } val parameters = unmodifiableMap(paramsBuilder); diff --git a/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/ElasticSearchConfig.java b/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/ElasticSearchConfig.java index bb89fa59..97bbb6f5 100644 --- a/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/ElasticSearchConfig.java +++ b/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/ElasticSearchConfig.java @@ -72,7 +72,7 @@ CommandLineRunner analysisElasticsearchBootstrapper(AnalysisCentricElasticSearch return (args) -> adapter.initialize(); } - @Bean + @Bean("ES_CLIENT") RestHighLevelClient client(ApplicationProperties properties) { val httpHostArrayList = new ArrayList( diff --git a/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/FileCentricElasticSearchAdapter.java b/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/FileCentricElasticSearchAdapter.java index cbf3d029..a9e25ff7 100644 --- a/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/FileCentricElasticSearchAdapter.java +++ b/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/FileCentricElasticSearchAdapter.java @@ -266,14 +266,21 @@ private List getFileCentricDocuments( private UpdateRequest mapFileToUpsertRepositoryQuery(FileCentricDocument fileCentricDocument) { val mapper = new ObjectMapper().setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE); + // this ISO date format is added because in one instance where maestro was deployed + // an error to transform java.util.date was raised: + // cannot write time value xcontent for unknown value of type class java.util.Date + // there seem to be a class loader issue that cannot load the date transfomers in + // org.elasticsearch.common.xcontent.XContentBuilder + // root cause not found. val paramsBuilder = new HashMap(); paramsBuilder.put( "repository", mapper.convertValue(fileCentricDocument.getRepositories().get(0), Map.class)); paramsBuilder.put("analysis_state", fileCentricDocument.getAnalysis().getAnalysisState()); - paramsBuilder.put("updated_at", fileCentricDocument.getAnalysis().getUpdatedAt()); + paramsBuilder.put("updated_at", getDateIso(fileCentricDocument.getAnalysis().getUpdatedAt())); if (fileCentricDocument.getAnalysis().getPublishedAt() != null) { // Nullable as may not have been published - paramsBuilder.put("published_at", fileCentricDocument.getAnalysis().getPublishedAt()); + paramsBuilder.put( + "published_at", getDateIso(fileCentricDocument.getAnalysis().getPublishedAt())); } val parameters = unmodifiableMap(paramsBuilder); diff --git a/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/SearchAdapterHelper.java b/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/SearchAdapterHelper.java index d2ab8dfa..4144ad9b 100644 --- a/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/SearchAdapterHelper.java +++ b/maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/SearchAdapterHelper.java @@ -7,6 +7,8 @@ import io.github.resilience4j.retry.RetryConfig; import io.vavr.control.Try; import java.io.IOException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.time.Duration; import java.util.*; import java.util.function.Function; @@ -234,4 +236,11 @@ private static UpdateRequest prepareUpdate(UpdateRequest req) { Assert.notNull(req.id(), "No Id define for Query"); return req; } + + static String getDateIso(Date date) + { + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + return dateFormat.format(date); + } } diff --git a/maestro-app/src/main/java/bio/overture/maestro/app/infra/config/RootConfiguration.java b/maestro-app/src/main/java/bio/overture/maestro/app/infra/config/RootConfiguration.java index 7b36b823..1d4376d4 100644 --- a/maestro-app/src/main/java/bio/overture/maestro/app/infra/config/RootConfiguration.java +++ b/maestro-app/src/main/java/bio/overture/maestro/app/infra/config/RootConfiguration.java @@ -29,12 +29,18 @@ import bio.overture.maestro.app.infra.config.properties.PropertiesConfig; import bio.overture.maestro.domain.api.DomainApiConfig; import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.servers.Server; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; import org.springframework.web.reactive.function.client.WebClient; +import java.util.List; + /** Aggregates all configuration in one place */ @Configuration @Import({ @@ -97,4 +103,12 @@ class WebConfig { public ObjectMapper objectMapper() { return new ObjectMapper(); } + + @Bean + @ConditionalOnProperty(name = "springdoc.serverOverride.enabled", havingValue = "true") + public OpenAPI maestroOpenApi(@Value("${springdoc.serverOverride.value}") String serverOverride) { + return new OpenAPI() + .servers(List.of(new Server().url(serverOverride))); + } + } diff --git a/maestro-app/src/main/resources/config/application.yml b/maestro-app/src/main/resources/config/application.yml index d6f3bf3e..720e0940 100644 --- a/maestro-app/src/main/resources/config/application.yml +++ b/maestro-app/src/main/resources/config/application.yml @@ -172,5 +172,13 @@ spring: maxAttempts: 1 springdoc: + ## The reason this was added to support reverse proxy url rewrites like: http://xyz.com/maestro + ## otherwise the swagger urls will not be sent to the correct url since swagger ui depends + ## on the server definition and springdoc needs forward headers to be enabled by spring + ## enabling forward headers in maestro caused it to conflict with disabling kafka + ## and forced an autoconfigure for kafka client. + serverOverride: + enabled: false + value: http://localhost:11235/custom swagger-ui: - path: /api-docs \ No newline at end of file + path: /api-docs