Skip to content

Commit 7f3388a

Browse files
authored
Merge pull request #197 from overture-stack/develop
release 3.8.0 - add ability to customize server url in spring doc swagger to support reverse proxy rewrite path - ISO format dates in painless script to avoid date transformer issue in es rest client
2 parents cff45fc + 9a71f01 commit 7f3388a

File tree

7 files changed

+46
-8
lines changed

7 files changed

+46
-8
lines changed

.mvn/maven.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
-Drevision=3.7.0
1+
-Drevision=3.8.0
22
-Dsha1=
33
-Dchangelist=-SNAPSHOT

maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/AnalysisCentricElasticSearchAdapter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.fasterxml.jackson.databind.ObjectMapper;
1616
import com.fasterxml.jackson.databind.ObjectWriter;
1717
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
18+
import com.fasterxml.jackson.databind.util.StdDateFormat;
1819
import io.github.resilience4j.retry.Retry;
1920
import io.github.resilience4j.retry.RetryConfig;
2021
import java.io.IOException;
@@ -146,16 +147,15 @@ private List<AnalysisCentricDocument> getAnalysisCentricDocuments(
146147
private UpdateRequest mapAnalysisToUpsertRepositoryQuery(
147148
AnalysisCentricDocument analysisCentricDocument) {
148149
val mapper = new ObjectMapper().setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
149-
150150
val paramsBuilder = new HashMap<String, Object>();
151151
paramsBuilder.put(
152152
"repository",
153153
mapper.convertValue(analysisCentricDocument.getRepositories().get(0), Map.class));
154154
paramsBuilder.put("analysis_state", analysisCentricDocument.getAnalysisState());
155-
paramsBuilder.put("updated_at", analysisCentricDocument.getUpdatedAt());
155+
paramsBuilder.put("updated_at", getDateIso(analysisCentricDocument.getUpdatedAt()));
156156
if (analysisCentricDocument.getPublishedAt()
157157
!= null) { // Nullable as may not have been published
158-
paramsBuilder.put("published_at", analysisCentricDocument.getPublishedAt());
158+
paramsBuilder.put("published_at", getDateIso(analysisCentricDocument.getPublishedAt()));
159159
}
160160

161161
val parameters = unmodifiableMap(paramsBuilder);

maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/ElasticSearchConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ CommandLineRunner analysisElasticsearchBootstrapper(AnalysisCentricElasticSearch
7272
return (args) -> adapter.initialize();
7373
}
7474

75-
@Bean
75+
@Bean("ES_CLIENT")
7676
RestHighLevelClient client(ApplicationProperties properties) {
7777
val httpHostArrayList =
7878
new ArrayList<HttpHost>(

maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/FileCentricElasticSearchAdapter.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,21 @@ private List<FileCentricDocument> getFileCentricDocuments(
266266
private UpdateRequest mapFileToUpsertRepositoryQuery(FileCentricDocument fileCentricDocument) {
267267
val mapper = new ObjectMapper().setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
268268

269+
// this ISO date format is added because in one instance where maestro was deployed
270+
// an error to transform java.util.date was raised:
271+
// cannot write time value xcontent for unknown value of type class java.util.Date
272+
// there seem to be a class loader issue that cannot load the date transfomers in
273+
// org.elasticsearch.common.xcontent.XContentBuilder
274+
// root cause not found.
269275
val paramsBuilder = new HashMap<String, Object>();
270276
paramsBuilder.put(
271277
"repository", mapper.convertValue(fileCentricDocument.getRepositories().get(0), Map.class));
272278
paramsBuilder.put("analysis_state", fileCentricDocument.getAnalysis().getAnalysisState());
273-
paramsBuilder.put("updated_at", fileCentricDocument.getAnalysis().getUpdatedAt());
279+
paramsBuilder.put("updated_at", getDateIso(fileCentricDocument.getAnalysis().getUpdatedAt()));
274280
if (fileCentricDocument.getAnalysis().getPublishedAt()
275281
!= null) { // Nullable as may not have been published
276-
paramsBuilder.put("published_at", fileCentricDocument.getAnalysis().getPublishedAt());
282+
paramsBuilder.put(
283+
"published_at", getDateIso(fileCentricDocument.getAnalysis().getPublishedAt()));
277284
}
278285

279286
val parameters = unmodifiableMap(paramsBuilder);

maestro-app/src/main/java/bio/overture/maestro/app/infra/adapter/outbound/indexing/elasticsearch/SearchAdapterHelper.java

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import io.github.resilience4j.retry.RetryConfig;
88
import io.vavr.control.Try;
99
import java.io.IOException;
10+
import java.text.DateFormat;
11+
import java.text.SimpleDateFormat;
1012
import java.time.Duration;
1113
import java.util.*;
1214
import java.util.function.Function;
@@ -234,4 +236,11 @@ private static UpdateRequest prepareUpdate(UpdateRequest req) {
234236
Assert.notNull(req.id(), "No Id define for Query");
235237
return req;
236238
}
239+
240+
static String getDateIso(Date date)
241+
{
242+
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
243+
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
244+
return dateFormat.format(date);
245+
}
237246
}

maestro-app/src/main/java/bio/overture/maestro/app/infra/config/RootConfiguration.java

+14
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@
2929
import bio.overture.maestro.app.infra.config.properties.PropertiesConfig;
3030
import bio.overture.maestro.domain.api.DomainApiConfig;
3131
import com.fasterxml.jackson.databind.ObjectMapper;
32+
import io.swagger.v3.oas.models.OpenAPI;
33+
import io.swagger.v3.oas.models.servers.Server;
34+
import org.springframework.beans.factory.annotation.Value;
35+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
3236
import org.springframework.context.annotation.Bean;
3337
import org.springframework.context.annotation.Configuration;
3438
import org.springframework.context.annotation.Import;
3539
import org.springframework.context.annotation.Primary;
3640
import org.springframework.web.reactive.function.client.WebClient;
3741

42+
import java.util.List;
43+
3844
/** Aggregates all configuration in one place */
3945
@Configuration
4046
@Import({
@@ -97,4 +103,12 @@ class WebConfig {
97103
public ObjectMapper objectMapper() {
98104
return new ObjectMapper();
99105
}
106+
107+
@Bean
108+
@ConditionalOnProperty(name = "springdoc.serverOverride.enabled", havingValue = "true")
109+
public OpenAPI maestroOpenApi(@Value("${springdoc.serverOverride.value}") String serverOverride) {
110+
return new OpenAPI()
111+
.servers(List.of(new Server().url(serverOverride)));
112+
}
113+
100114
}

maestro-app/src/main/resources/config/application.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,13 @@ spring:
172172
maxAttempts: 1
173173

174174
springdoc:
175+
## The reason this was added to support reverse proxy url rewrites like: http://xyz.com/maestro
176+
## otherwise the swagger urls will not be sent to the correct url since swagger ui depends
177+
## on the server definition and springdoc needs forward headers to be enabled by spring
178+
## enabling forward headers in maestro caused it to conflict with disabling kafka
179+
## and forced an autoconfigure for kafka client.
180+
serverOverride:
181+
enabled: false
182+
value: http://localhost:11235/custom
175183
swagger-ui:
176-
path: /api-docs
184+
path: /api-docs

0 commit comments

Comments
 (0)