diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/service/wfs/WfsServer.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/service/wfs/WfsServer.java index 25654bc2..32da6b1c 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/service/wfs/WfsServer.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/service/wfs/WfsServer.java @@ -261,11 +261,6 @@ public List filterLayersByWfsLinks(String collectionId, List link.getAiGroup().contains(WFS_LINK_MARKER)) .toList(); - if (wfsLinks.isEmpty()) { - log.warn("Return empty layers if as no WFS links found for collection {}", collectionId); - return Collections.emptyList(); - } - // Filter WMS layers based on matching with WFS links List filteredLayers = new ArrayList<>(); diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/service/wms/WmsServer.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/service/wms/WmsServer.java index b35f1958..d0731fc7 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/service/wms/WmsServer.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/service/wms/WmsServer.java @@ -577,7 +577,9 @@ public List fetchCapabilitiesLayersByUrl(String wmsServerUrl) { return Collections.emptyList(); } /** - * Get filtered layers from WMS GetCapabilities for a specific collection + * Get filtered layers from WMS GetCapabilities for a specific collection, we use this function because we do not + * trust the WMS layer value because it can be wrong, we use the WFS link to infer the layer and therefore the layer + * name return will be operational with WFS function. * First fetches all layers (cached by URL), then filters by WFS links (cached by UUID) * * @param collectionId - The uuid @@ -585,7 +587,7 @@ public List fetchCapabilitiesLayersByUrl(String wmsServerUrl) { * @return - List of LayerInfo objects filtered by WFS link matching */ public List getCapabilitiesLayers(String collectionId, FeatureRequest request) { - Optional mapServerUrl = getMapServerUrl(collectionId, request); + Optional mapServerUrl = getMapServerUrl(collectionId, null); if (mapServerUrl.isPresent()) { // Fetch all layers from GetCapabilities (this call is cached by URL) @@ -594,7 +596,23 @@ public List getCapabilitiesLayers(String collectionId, FeatureRequest if (!allLayers.isEmpty()) { // Filter layers based on WFS link matching List filteredLayers = wfsServer.filterLayersByWfsLinks(collectionId, allLayers); - log.debug("Returning filteredLayers {}", filteredLayers); + + // If filteredLayers empty, that means no layer have wfs operation, but that does not mean + // the layer cannot serve for display only. + if(filteredLayers.isEmpty() && request.getLayerName() != null) { + DescribeLayerResponse dr = describeLayer(collectionId, request); + if(dr != null) { + // That means at least layer is valid just not operational + return List.of( + LayerInfo.builder() + .name(dr.getLayerDescription().getName()) + .title(dr.getLayerDescription().getName()) + .queryable("0") + .build() + ); + } + } + log.debug("Returning layers {}", filteredLayers); return filteredLayers; } diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/features/RestServices.java b/server/src/main/java/au/org/aodn/ogcapi/server/features/RestServices.java index c8ba41ce..702e2626 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/features/RestServices.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/features/RestServices.java @@ -1,6 +1,7 @@ package au.org.aodn.ogcapi.server.features; import au.org.aodn.ogcapi.features.model.Collection; +import au.org.aodn.ogcapi.server.core.exception.DownloadableFieldsNotFoundException; import au.org.aodn.ogcapi.server.core.model.ogc.FeatureRequest; import au.org.aodn.ogcapi.server.core.model.ogc.wms.FeatureInfoResponse; import au.org.aodn.ogcapi.server.core.model.ogc.wms.LayerInfo; @@ -122,14 +123,18 @@ public ResponseEntity getWmsDownloadableFields(String collectionId, FeatureRe return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); } else { - List result = wmsServer.getDownloadableFields(collectionId, request); + try { + List result = wmsServer.getDownloadableFields(collectionId, request); - return result.isEmpty() ? - ResponseEntity.notFound().build() : - ResponseEntity.ok(result); + return result.isEmpty() ? + ResponseEntity.notFound().build() : + ResponseEntity.ok(result); + } + catch(DownloadableFieldsNotFoundException nfe) { + return ResponseEntity.notFound().build(); + } } } - /** * This is used to get all available layers from WMS GetCapabilities * @@ -144,7 +149,6 @@ public ResponseEntity getWmsLayers(String collectionId, FeatureRequest reques ResponseEntity.notFound().build() : ResponseEntity.ok(result); } - /** * @param collectionID - uuid * @param from -