Skip to content

Commit 5c20556

Browse files
committed
OGC API Records / Items / DCAT / NPE fix
Fix NPE on DCAT item response eg. http://localhost:9901/collections/main/items/f946d4e0-710b-11dc-83f9-000086f6a62e?f=dcat ``` 2024-11-19 11:15:29.659 ERROR 547670 --- [nio-9901-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: java.lang.NullPointerException] with root cause java.lang.NullPointerException: null at org.fao.geonet.index.converter.DcatConverter.convert(DcatConverter.java:128) ~[classes/:na] at org.fao.geonet.ogcapi.records.controller.ItemApiController.collectionsCollectionIdItemsRecordIdGetAsJsonLd(ItemApiController.java:365) ~[classes/:na] at org.fao.geonet.ogcapi.records.controller.ItemApiController.collectionsCollectionIdItemsRecordIdGet(ItemApiController.java:191) ~[classes/:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE] a ``` DCAT conversion is for now based on Elasticsearch index document which is properly returned for search but not for the items operation with now the new GeoJSON document with `doc.get("properties").get("gn-elastic-index-record")` which can be used for the conversion. DCAT will be better supported with formatters geonetwork/geonetwork#72 but for 4.4.6, this is relevant to be fixed. Related to #118
1 parent aac3835 commit 5c20556

File tree

1 file changed

+5
-1
lines changed
  • modules/library/common-index-model/src/main/java/org/fao/geonet/index/converter

1 file changed

+5
-1
lines changed

modules/library/common-index-model/src/main/java/org/fao/geonet/index/converter/DcatConverter.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,13 @@ public CatalogRecord convert(JsonNode doc) {
123123
Dataset dcatDataset = null;
124124
DataService dcatService = null;
125125
try {
126+
JsonNode indexSource = doc.get(IndexRecordFieldNames.source);
127+
126128
IndexRecord record = new ObjectMapper()
127129
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
128-
.readValue(doc.get(IndexRecordFieldNames.source).toString(), IndexRecord.class);
130+
.readValue(
131+
indexSource != null ? indexSource.toString() :
132+
doc.get("properties").get("gn-elastic-index-record").toString(), IndexRecord.class);
129133

130134
String recordIdentifier = record.getMetadataIdentifier();
131135
String recordUri = formatterConfiguration.buildLandingPageLink(

0 commit comments

Comments
 (0)