Skip to content

Commit f3df52d

Browse files
committed
Merge branch 'main' into feature/5235-reference-stacmodel-from-codeartifact
2 parents 3477176 + 9bc37c5 commit f3df52d

39 files changed

Lines changed: 889 additions & 300 deletions

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@
105105
<artifactId>gt-referencing</artifactId>
106106
<version>${org.geotools.version}</version>
107107
</dependency>
108+
<dependency>
109+
<groupId>org.geotools</groupId>
110+
<artifactId>gt-wfs-ng</artifactId>
111+
<version>${org.geotools.version}</version>
112+
</dependency>
113+
<dependency>
114+
<groupId>org.geotools</groupId>
115+
<artifactId>gt-xml</artifactId>
116+
<version>${org.geotools.version}</version>
117+
</dependency>
108118
<!--
109119
https://mvnrepository.com/artifact/org.geotools/gt-epsg-hsql
110120
it is use to lookup EPSG values

server/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@
154154
<groupId>org.geotools</groupId>
155155
<artifactId>gt-epsg-hsql</artifactId>
156156
</dependency>
157+
<dependency>
158+
<groupId>org.geotools</groupId>
159+
<artifactId>gt-wfs-ng</artifactId>
160+
</dependency>
161+
<dependency>
162+
<groupId>org.geotools</groupId>
163+
<artifactId>gt-xml</artifactId>
164+
</dependency>
157165
<dependency>
158166
<groupId>org.locationtech.spatial4j</groupId>
159167
<artifactId>spatial4j</artifactId>
@@ -229,6 +237,11 @@
229237
<version>1.5.0</version>
230238
<scope>test</scope>
231239
</dependency>
240+
<dependency>
241+
<groupId>org.xmlunit</groupId>
242+
<artifactId>xmlunit-core</artifactId>
243+
<scope>test</scope>
244+
</dependency>
232245
</dependencies>
233246
<build>
234247
<plugins>

server/src/main/java/au/org/aodn/ogcapi/server/core/configuration/CacheConfig.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
import au.org.aodn.ogcapi.server.core.service.CacheNoLandGeometry;
44
import au.org.aodn.ogcapi.server.core.service.CacheWarm;
5-
import au.org.aodn.ogcapi.server.core.service.wfs.WfsServer;
6-
import au.org.aodn.ogcapi.server.core.service.wms.WmsServer;
5+
import au.org.aodn.ogcapi.server.core.service.geoserver.wfs.WfsServer;
6+
import au.org.aodn.ogcapi.server.core.service.geoserver.wms.WmsServer;
77
import au.org.aodn.ogcapi.server.core.util.GeometryUtils;
88
import org.ehcache.config.builders.*;
99
import org.ehcache.config.units.MemoryUnit;
10+
import org.ehcache.impl.config.persistence.DefaultPersistenceConfiguration;
1011
import org.ehcache.jsr107.EhcacheCachingProvider;
1112
import org.locationtech.jts.geom.Geometry;
1213
import org.locationtech.jts.geom.prep.PreparedGeometry;
@@ -19,6 +20,7 @@
1920
import javax.cache.Caching;
2021
import java.io.File;
2122
import java.io.IOException;
23+
import java.math.BigInteger;
2224
import java.nio.file.Files;
2325
import java.nio.file.Path;
2426
import java.time.Duration;
@@ -31,7 +33,10 @@ public class CacheConfig {
3133
public static final String CACHE_WMS_MAP_TILE = "cache-wms-map_tile";
3234
public static final String GET_CAPABILITIES_WMS_LAYERS = "get-capabilities-wms-layers";
3335
public static final String GET_CAPABILITIES_WFS_FEATURE_TYPES = "get-capabilities-wfs-feature-types";
36+
3437
public static final String DOWNLOADABLE_FIELDS = "downloadable-fields";
38+
public static final String DOWNLOADABLE_SIZE = "downloadable-size";
39+
3540
public static final String ALL_NO_LAND_GEOMETRY = "all-noland-geometry";
3641
public static final String ALL_PARAM_VOCABS = "parameter-vocabs";
3742
public static final String ELASTIC_SEARCH_UUID_ONLY = "elastic-search-uuid-only";
@@ -53,7 +58,7 @@ public JCacheCacheManager cacheManager() throws IOException {
5358

5459
org.ehcache.config.Configuration config = ConfigurationBuilder
5560
.newConfigurationBuilder()
56-
.withService(new org.ehcache.impl.config.persistence.DefaultPersistenceConfiguration(storagePath))
61+
.withService(new DefaultPersistenceConfiguration(storagePath))
5762
.withCache(CACHE_WMS_MAP_TILE,
5863
CacheConfigurationBuilder.newCacheConfigurationBuilder(
5964
Object.class, byte[].class,
@@ -81,6 +86,12 @@ public JCacheCacheManager cacheManager() throws IOException {
8186
ResourcePoolsBuilder.heap(200)
8287
).withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofHours(24)))
8388
)
89+
.withCache(DOWNLOADABLE_SIZE,
90+
CacheConfigurationBuilder.newCacheConfigurationBuilder(
91+
Object.class, BigInteger.class,
92+
ResourcePoolsBuilder.heap(100)
93+
).withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofHours(24)))
94+
)
8495
.withCache(ELASTIC_SEARCH_UUID_ONLY,
8596
CacheConfigurationBuilder.newCacheConfigurationBuilder(
8697
Object.class, Object.class,
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package au.org.aodn.ogcapi.server.core.configuration;
2+
3+
import au.org.aodn.ogcapi.server.core.service.Search;
4+
import au.org.aodn.ogcapi.server.core.service.geoserver.wfs.DownloadWfsDataService;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import au.org.aodn.ogcapi.server.core.service.geoserver.wfs.WfsDefaultParam;
7+
import au.org.aodn.ogcapi.server.core.service.geoserver.wfs.WfsServer;
8+
import au.org.aodn.ogcapi.server.core.service.geoserver.wms.WmsServer;
9+
import au.org.aodn.ogcapi.server.core.util.RestTemplateUtils;
10+
import jakarta.annotation.Nonnull;
11+
import org.springframework.beans.factory.annotation.Qualifier;
12+
import org.springframework.beans.factory.annotation.Value;
13+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
14+
import org.springframework.context.annotation.Bean;
15+
import org.springframework.context.annotation.Configuration;
16+
import org.springframework.context.annotation.Lazy;
17+
import org.springframework.http.HttpEntity;
18+
import org.springframework.http.HttpHeaders;
19+
import org.springframework.http.HttpStatusCode;
20+
import org.springframework.http.client.ClientHttpResponse;
21+
import org.springframework.web.client.RestTemplate;
22+
23+
import java.io.IOException;
24+
import java.io.InputStream;
25+
import java.util.ArrayList;
26+
27+
@Configuration
28+
public class GeoServerConfig {
29+
30+
/**
31+
* Some wfs request contains non standard minetype which is not allow by the default rest template
32+
*/
33+
static class WfsCustomResponseWrapper implements ClientHttpResponse {
34+
private final ClientHttpResponse delegate;
35+
36+
public WfsCustomResponseWrapper(ClientHttpResponse delegate) {
37+
this.delegate = delegate;
38+
}
39+
40+
@Override
41+
@Nonnull
42+
public HttpStatusCode getStatusCode() throws IOException {
43+
return delegate.getStatusCode();
44+
}
45+
46+
@Override
47+
@Nonnull
48+
public String getStatusText() throws IOException {
49+
return delegate.getStatusText();
50+
}
51+
52+
@Override
53+
public void close() {
54+
delegate.close();
55+
}
56+
57+
@Override
58+
@Nonnull
59+
public InputStream getBody() throws IOException {
60+
return delegate.getBody();
61+
}
62+
63+
@Override
64+
@Nonnull
65+
public HttpHeaders getHeaders() {
66+
HttpHeaders headers = new HttpHeaders();
67+
headers.putAll(delegate.getHeaders());
68+
String ct = headers.getFirst(HttpHeaders.CONTENT_TYPE);
69+
if (ct != null && ct.contains("subtype=")) {
70+
headers.set(HttpHeaders.CONTENT_TYPE, "text/xml");
71+
}
72+
return headers;
73+
}
74+
}
75+
76+
@ConditionalOnMissingBean(name = "pretendUserEntity")
77+
@Bean("pretendUserEntity")
78+
public HttpEntity<?> createPretendUserEntity() {
79+
// Some server do not allow program to scrap the content, so we need to pretend to be a client
80+
HttpHeaders headers = new HttpHeaders();
81+
headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36");
82+
83+
return new HttpEntity<>(headers);
84+
}
85+
86+
@Bean
87+
public WfsServer createWfsServer(Search search,
88+
RestTemplate restTemplate,
89+
RestTemplateUtils restTemplateUtils,
90+
@Qualifier("pretendUserEntity") HttpEntity<?> entity,
91+
WfsDefaultParam wfsDefaultParam) {
92+
return new WfsServer(search, restTemplate, restTemplateUtils, entity, wfsDefaultParam);
93+
}
94+
95+
@Bean
96+
public WmsServer createWmsServer(Search search, @Lazy WfsServer wfsServer, @Qualifier("pretendUserEntity") HttpEntity<?> entity) {
97+
return new WmsServer(search, wfsServer, entity);
98+
}
99+
100+
@Bean
101+
@ConditionalOnMissingBean(DownloadWfsDataService.class)
102+
public DownloadWfsDataService createDownloadWfsDataService(WfsServer wfsServer,
103+
RestTemplate restTemplate,
104+
@Qualifier("pretendUserEntity") HttpEntity<?> pretendUserEntity,
105+
@Value("${app.sse.chunkSize:16384}") int chunkSize,
106+
ObjectMapper objectMapper) {
107+
108+
RestTemplate clone = new RestTemplate(restTemplate.getRequestFactory());
109+
clone.setInterceptors(new ArrayList<>(restTemplate.getInterceptors()));
110+
clone.getInterceptors().add((request, body, execution) -> {
111+
ClientHttpResponse resp = execution.execute(request, body);
112+
return new WfsCustomResponseWrapper(resp);
113+
});
114+
115+
clone.setMessageConverters(new ArrayList<>(restTemplate.getMessageConverters()));
116+
clone.setErrorHandler(restTemplate.getErrorHandler());
117+
118+
return new DownloadWfsDataService(wfsServer, clone, pretendUserEntity, chunkSize, objectMapper);
119+
}
120+
}

server/src/main/java/au/org/aodn/ogcapi/server/core/configuration/WfsWmsConfig.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

server/src/main/java/au/org/aodn/ogcapi/server/core/mapper/Converter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ default <D extends StacCollectionModel> Collection getCollection(D m, Filter fil
231231
if (m.getSummaries().getParameterVocabs() != null && !m.getSummaries().getParameterVocabs().isEmpty()) {
232232
collection.getProperties().put(CollectionProperty.parameterVocabs, m.getSummaries().getParameterVocabs());
233233
}
234+
235+
if (m.getSummaries().getAiParameterVocabs() != null && !m.getSummaries().getAiParameterVocabs().isEmpty()) {
236+
collection.getProperties().put(CollectionProperty.aiParameterVocabs, m.getSummaries().getAiParameterVocabs());
237+
}
234238
}
235239

236240
return collection;

server/src/main/java/au/org/aodn/ogcapi/server/core/model/ConceptModel.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package au.org.aodn.ogcapi.server.core.model;
22

3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
35
import lombok.AllArgsConstructor;
46
import lombok.Builder;
57
import lombok.Data;
@@ -14,4 +16,8 @@ public class ConceptModel {
1416
protected String url;
1517
protected String description;
1618
protected String title;
19+
20+
@JsonInclude(JsonInclude.Include.NON_NULL)
21+
@JsonProperty("ai:description")
22+
protected String aiDescription;
1723
}

server/src/main/java/au/org/aodn/ogcapi/server/core/model/SummariesModel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ public class SummariesModel {
5151

5252
@JsonProperty("parameter_vocabs")
5353
protected List<String> parameterVocabs;
54+
55+
@JsonProperty("ai:parameter_vocabs")
56+
protected List<String> aiParameterVocabs;
5457
}

server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/CQLFields.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,18 @@ public enum CQLFields implements CQLFieldsInterface {
149149
null,
150150
null
151151
),
152+
ai_parameter_vocabs(
153+
StacSummeries.AiParameterVocabs.searchField,
154+
StacSummeries.AiParameterVocabs.displayField,
155+
null,
156+
null
157+
),
158+
ai_platform_vocabs(
159+
StacSummeries.AiPlatformVocabs.searchField,
160+
StacSummeries.AiPlatformVocabs.displayField,
161+
null,
162+
null
163+
),
152164
organisation_vocabs(
153165
StacBasicField.OrganisationVocabs.searchField,
154166
StacBasicField.OrganisationVocabs.displayField,

server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/CollectionProperty.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public enum CollectionProperty {
2525
aiDescription("ai:description"),
2626
aiUpdateFrequency("ai:update_frequency"),
2727
scope("scope"),
28-
parameterVocabs("parameter_vocabs");
28+
parameterVocabs("parameter_vocabs"),
29+
aiParameterVocabs("ai:parameter_vocabs");
2930

3031
private final String value;
3132

0 commit comments

Comments
 (0)