Skip to content

Commit

Permalink
Adding dc:date in opensearch entry output
Browse files Browse the repository at this point in the history
  • Loading branch information
aaime committed May 3, 2017
1 parent c2c9c86 commit 54a9faa
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
}

private boolean requestNeedsWrapper(HttpServletRequest requestHTTP) {
return "GET".equalsIgnoreCase(requestHTTP.getMethod()) && !(new CaseInsensitiveMap(requestHTTP.getParameterMap()).containsKey("service"))
&& (requestHTTP.getPathInfo().endsWith("search") || requestHTTP.getPathInfo().endsWith("description"));
String pathInfo = requestHTTP.getPathInfo();
Map<String, String[]> parameterMap = requestHTTP.getParameterMap();
return pathInfo != null && parameterMap != null
&& "GET".equalsIgnoreCase(requestHTTP.getMethod())
&& !(new CaseInsensitiveMap(parameterMap).containsKey("service"))
&& (pathInfo.endsWith("search") || pathInfo.endsWith("description"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,24 @@ private void encodeGenericEntryContents(Feature feature, String name,
element("id", identifierLink);
element("title", name);
element("dc:identifier", name);
// TODO: need an actual update column
Date updated = (Date) value(feature, "timeStart");
if (updated != null) {
Date start = (Date) value(feature, "timeStart");
Date end = (Date) value(feature, "timeEnd");
if(start != null || end != null) {
// TODO: need an actual update column
Date updated = end == null ? start : end;
String formattedUpdated = DateTimeFormatter.ISO_INSTANT.format(updated.toInstant());
element("updated", formattedUpdated);

// dc:date, can be a range
String spec;
if(start != null && end != null && start.equals(end)) {
spec = DateTimeFormatter.ISO_INSTANT.format(start.toInstant());
} else {
spec = start != null ? DateTimeFormatter.ISO_INSTANT.format(start.toInstant()) : "";
spec += "/";
spec += end != null ? DateTimeFormatter.ISO_INSTANT.format(end.toInstant()) : "";
}
element("dc:date", spec);
}
Geometry footprint = (Geometry) value(feature, "footprint");
if (footprint != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testAllCollection() throws Exception {
assertEquals(200, response.getStatus());

Document dom = dom(new ByteArrayInputStream(response.getContentAsByteArray()));
// print(dom);
print(dom);

// basics
assertThat(dom, hasXPath("/at:feed/os:totalResults", equalTo("3")));
Expand All @@ -50,7 +50,7 @@ public void testAllCollection() throws Exception {
assertThat(dom, hasXPath("/at:feed/os:Query[@startIndex='1']"));
assertThat(dom, hasXPath("/at:feed/at:author/at:name", equalTo("GeoServer")));
assertThat(dom, hasXPath("/at:feed/at:updated"));
assertThat(dom, hasXPath("/at:feed/at:link[@rel='search']/@href",
assertThat(dom, hasXPath("/at:feed/at:link[@rel='search']/@href",
equalTo("http://localhost:8080/geoserver/oseo/search/description")));

assertNoResults(dom);
Expand All @@ -68,6 +68,8 @@ public void testAllCollection() throws Exception {
"http://localhost:8080/geoserver/oseo/search?uid=SENTINEL2&httpAccept=application%2Fatom%2Bxml")));
assertThat(dom,
hasXPath("/at:feed/at:entry[1]/at:updated", equalTo("2016-02-26T09:20:21Z")));
assertThat(dom,
hasXPath("/at:feed/at:entry[1]/dc:date", equalTo("2015-07-01T08:20:21Z/2016-02-26T09:20:21Z")));
// ... mind the lat/lon order
assertThat(dom,
hasXPath(
Expand Down Expand Up @@ -375,6 +377,8 @@ public void testSpecificProduct() throws Exception {
assertThat(dom, hasXPath("count(/at:feed/at:entry)", equalTo("1")));
assertThat(dom, hasXPath("/at:feed/at:entry/at:title",
equalTo("S2A_OPER_MSI_L1C_TL_MTI__20170308T220244_A008933_T11SLT_N02.04")));
assertThat(dom, hasXPath("/at:feed/at:entry/at:updated", equalTo("2017-03-08T17:54:21.026Z")));
assertThat(dom, hasXPath("/at:feed/at:entry/dc:date", equalTo("2017-03-08T17:54:21.026Z")));

// ... the links (self, metadata)
assertThat(dom, hasXPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ VALUES(17, 'SENTINEL2', NULL, '<table>
<a href="${ISO_METADATA_LINK}" title="ISO format">ISO</a>
</td>
</tr>
</table>', ST_GeomFromText('POLYGON((-179 89,179 89,179 -89,-179 -89,-179 89))', 4326), '2016-02-26 10:20:21.000', '2015-07-01 10:20:21.000', NULL, NULL, 'SENTINEL2', 'S2MSI1C', 'Sentinel-2', 'A', 'MSI', 'OPTICAL', NULL, 'Level-1C', 'LEO', NULL, NULL, NULL, NULL, NULL);
</table>', ST_GeomFromText('POLYGON((-179 89,179 89,179 -89,-179 -89,-179 89))', 4326), '2015-07-01 10:20:21.000', '2016-02-26 10:20:21.000', NULL, NULL, 'SENTINEL2', 'S2MSI1C', 'Sentinel-2', 'A', 'MSI', 'OPTICAL', NULL, 'Level-1C', 'LEO', NULL, NULL, NULL, NULL, NULL);
INSERT INTO collection
("id", "name", "primary", "htmlDescription", "footprint", "timeStart", "timeEnd", "productCqlFilter", "masked", "eoIdentifier", "eoProductType", "eoPlatform", "eoPlatformSerialIdentifier", "eoInstrument", "eoSensorType", "eoCompositeType", "eoProcessingLevel", "eoOrbitType", "eoSpectralRange", "eoWavelength", "eoSecurityConstraints", "eoDissemination", "eoAcquisitionStation")
VALUES(32, 'SENTINEL1', NULL, '<table>
Expand Down Expand Up @@ -86,7 +86,7 @@ VALUES(32, 'SENTINEL1', NULL, '<table>
<a href="${ISO_METADATA_LINK}" title="ISO format">ISO</a>
</td>
</tr>
</table>', ST_GeomFromText('POLYGON((-179 89,179 89,179 -89,-179 -89,-179 89))', 4326), '2015-02-26 10:20:21.000', '2014-05-01 10:20:21.000', NULL, NULL, 'SENTINEL1', NULL, 'Sentinel-1', NULL, 'SAR', 'RADAR', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
</table>', ST_GeomFromText('POLYGON((-179 89,179 89,179 -89,-179 -89,-179 89))', 4326), '2015-02-26 10:20:21.000', NULL , NULL, NULL, 'SENTINEL1', NULL, 'Sentinel-1', NULL, 'SAR', 'RADAR', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO collection
("id", "name", "primary", "htmlDescription", "footprint", "timeStart", "timeEnd", "productCqlFilter", "masked", "eoIdentifier", "eoProductType", "eoPlatform", "eoPlatformSerialIdentifier", "eoInstrument", "eoSensorType", "eoCompositeType", "eoProcessingLevel", "eoOrbitType", "eoSpectralRange", "eoWavelength", "eoSecurityConstraints", "eoDissemination", "eoAcquisitionStation")
VALUES(31, 'LANDSAT8', NULL, '<table>
Expand Down

0 comments on commit 54a9faa

Please sign in to comment.