Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions docs/GLIDERS_MISSION_CATALOGUE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
The API reads the version 1 catalogue produced by
[aodn/data-services PR #1276](https://github.com/aodn/data-services/pull/1276).
It uses `REMOTE_BASE_URL` + `REMOTE_RESOURCE_PATH` +
`gliders/gliders-catalogue.json`. The caller cannot override the source URL.
`api/gliders-catalogue.json`. The caller cannot override the source URL.
This catalogue is independent of image inventories and Elasticsearch.
Merging the upstream generator does not run or schedule it: an upstream operator
must generate and publish the JSON before the API can serve catalogue data.
The generator uses the existing publication pipeline and schedule. This extension
does not introduce another endpoint or scheduler.

## Endpoints and parameters

Expand Down Expand Up @@ -52,7 +52,12 @@ Illustrative response (fixture data, not a statement of current availability):
"glider_id": "Slocum-1",
"visualisations": {
"details": [{"label": "4", "url": "https://oceancurrent.aodn.org.au/gliders/TwoRocks20260327/4.html"}],
"animations": []
"animations": [],
"latest_images": {
"4d": "/gliders/TwoRocks20260327_4d/2026041300.gif",
"12d": null,
"30d": null
}
},
"temperature_salinity_url": null,
"scientific_data_url": null
Expand Down Expand Up @@ -145,3 +150,27 @@ Local isolated checks:
The fixture in `src/test/resources/gliders/catalogue-v1.json` follows the merged
generator's schema and includes multiple versions, NRT, null optional values and
orders with different membership. These tests require no Elasticsearch or Docker.

## Latest image rollout and resource contract

Deploy API optional-field support first, then the updated catalogue generator.
The catalogue stays at schema version 1. Older catalogues without
`visualisations.latest_images`, and windows with absent/null URLs, remain valid;
both existing endpoints serialize all three keys with null defaults. Missing
images alone never cause HTTP 503. The API does not probe GIF resources.

Non-null values are website-root-relative resource paths. A browser prepends
`/resource`, for example `/resource/gliders/TwoRocks20260327_4d/2026041300.gif`.
The catalogue generator only exposes the displayed GIF verified in the linked
mission-window's legacy page, not a guessed most-recent filename.

After deployment, wait for publication and the configured API cache refresh,
compare `latest_images` on `/api/v1/gliders/missions` and an exact ID lookup with
`/resource/api/gliders-catalogue.json`, then GET each non-null path through
`/resource` and confirm HTTP 200 with GIF content. Include missions with missing
windows and NRT records. Do this through the normal deployment process; this
implementation does not deploy automatically.

NRT freshness depends on the upstream legacy frame selection and file transfer,
the unchanged publication schedule, API refresh and HTTP caches. A latest frame
may be old; no recency guarantee, image-date inference or new polling is added.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package au.org.aodn.oceancurrent.model.gliders;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

Expand All @@ -12,6 +13,14 @@ public record GliderMission(
Double latitude, Double longitude, Double durationDays, Double distanceTravelledKm,
String gliderId, Visualisations visualisations, String temperatureSalinityUrl,
String scientificDataUrl) {
public record Visualisations(List<Link> details, List<Link> animations) {}
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record Visualisations(List<Link> details, List<Link> animations, LatestImages latestImages) {
public Visualisations {
if (latestImages == null) latestImages = new LatestImages(null, null, null);
}
}
public record LatestImages(@JsonProperty("4d") String fourDay,
@JsonProperty("12d") String twelveDay,
@JsonProperty("30d") String thirtyDay) {}
public record Link(String label, String url) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ private void validateMission(JsonNode node) {
require(node.has(field) && (node.get(field).isNull() || node.get(field).isNumber()),
"Invalid mission " + field);
}
JsonNode latest = node.path("visualisations").path("latest_images");
require(latest.isMissingNode() || latest.isNull() || latest.isObject(), "Invalid latest_images");
if (latest.isObject()) {
for (String window : List.of("4d", "12d", "30d")) {
JsonNode image = latest.path(window);
require(image.isMissingNode() || image.isNull() || text(image), "Invalid latest image");
}
}
for (String kind : List.of("details", "animations")) {
JsonNode links = node.path("visualisations").path(kind);
require(links.isArray(), "Missing visualisations " + kind);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,43 @@ void defaultsAndResponseContract() throws Exception {
.andExpect(jsonPath("$.missions[0].is_nrt").value(false));
}

@ParameterizedTest
@ValueSource(strings = {"old", "new", "missing", "partial"})
void serializesLatestImagesOnBothEndpoints(String format) throws Exception {
var mapper = new ObjectMapper();
var root = mapper.readTree(new ClassPathResource("gliders/catalogue-v1.json")
.getContentAsString(java.nio.charset.StandardCharsets.UTF_8));
for (var mission : root.path("missions")) {
if (!format.equals("old")) {
var latest = ((com.fasterxml.jackson.databind.node.ObjectNode) mission.path("visualisations"))
.putObject("latest_images");
if (format.equals("new")) {
latest.put("4d", "/gliders/TwoRocks20260327_4d/2026041300.gif");
} else {
latest.putNull("4d");
}
if (!format.equals("partial")) {
latest.putNull("12d");
latest.putNull("30d");
}
}
}
when(remote.getForEntity(URL, String.class)).thenReturn(ResponseEntity.ok(root.toString()));
for (String endpoint : new String[]{"/gliders/missions", "/gliders/missions/TwoRocks20260327@5.00"}) {
String path = endpoint.endsWith("missions") ? "$.missions[0]" : "$";
var result = mvc.perform(get(endpoint)).andExpect(status().isOk())
.andExpect(jsonPath(path + ".visualisations.latest_images").isMap())
.andExpect(jsonPath(path + ".visualisations.latest_images['12d']").value(org.hamcrest.Matchers.nullValue()))
.andExpect(jsonPath(path + ".visualisations.latest_images['30d']").value(org.hamcrest.Matchers.nullValue()));
if (format.equals("new")) {
result.andExpect(jsonPath(path + ".visualisations.latest_images['4d']")
.value("/gliders/TwoRocks20260327_4d/2026041300.gif"));
} else {
result.andExpect(jsonPath(path + ".visualisations.latest_images['4d']").value(org.hamcrest.Matchers.nullValue()));
}
}
}

@Test
void filtersOrdersAndPages() throws Exception {
mvc.perform(get("/gliders/missions").param("order", "mission_name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void filtersBeforePaginationAndHandlesEmptyAndDistantPages() {
}

@ParameterizedTest
@ValueSource(strings = {"version", "overflow-version", "missing-missions", "missing-orders", "bad-order", "unknown-reference", "duplicate-reference", "missing-id", "duplicate-id", "unstable-id", "numeric-version", "bad-visualisations", "missing-nrt"})
@ValueSource(strings = {"version", "overflow-version", "missing-missions", "missing-orders", "bad-order", "unknown-reference", "duplicate-reference", "missing-id", "duplicate-id", "unstable-id", "numeric-version", "bad-visualisations", "missing-nrt", "bad-latest", "bad-image"})
void rejectsInvalidSchema(String problem) throws Exception {
ObjectNode root = (ObjectNode) mapper.readTree(json);
ObjectNode mission = (ObjectNode) root.path("missions").get(0);
Expand All @@ -117,6 +117,9 @@ void rejectsInvalidSchema(String problem) throws Exception {
case "numeric-version" -> mission.put("processing_version", 3.0);
case "bad-visualisations" -> mission.remove("visualisations");
case "missing-nrt" -> mission.remove("is_nrt");
case "bad-latest" -> ((ObjectNode) mission.path("visualisations")).put("latest_images", "wrong");
case "bad-image" -> ((ObjectNode) mission.path("visualisations"))
.putObject("latest_images").put("4d", 123);
}
respond(root.toString());
assertThatThrownBy(() -> service.mission(ID)).isInstanceOf(GlidersCatalogueUnavailableException.class);
Expand Down
Loading