From 494ff222891fc9dcef17c5b14391a0149ace4032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Garc=C3=ADa?= Date: Mon, 2 Dec 2024 15:44:16 +0100 Subject: [PATCH] Check protocol match simple values instead of exact match --- .../entities/helper/DocumentLink.java | 22 +++++++++++++++++-- ...essor_PostProcessDatasetDocumentEvent.java | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/services/linkchecker/src/main/java/net/geocat/database/linkchecker/entities/helper/DocumentLink.java b/services/linkchecker/src/main/java/net/geocat/database/linkchecker/entities/helper/DocumentLink.java index 5392813..418baa4 100644 --- a/services/linkchecker/src/main/java/net/geocat/database/linkchecker/entities/helper/DocumentLink.java +++ b/services/linkchecker/src/main/java/net/geocat/database/linkchecker/entities/helper/DocumentLink.java @@ -90,6 +90,7 @@ public DocumentLink() { "wms", "http://www.opengis.net/def/serviceType/ogc/wms".toLowerCase(), "OGC Web Map Service".toLowerCase(), + "Web Map Service (WMS)".toLowerCase(), "OGC:WMS".toLowerCase(), "http://www.opengeospatial.org/standards/wms", "wmts", @@ -103,6 +104,7 @@ public DocumentLink() { "wfs", "http://www.opengis.net/def/serviceType/ogc/wfs".toLowerCase(), "OGC Web Feature Service".toLowerCase(), + "Web Feature Service (WFS)".toLowerCase(), "OGC:WFS".toLowerCase(), "http://www.opengeospatial.org/standards/wfs", "atom", @@ -111,9 +113,13 @@ public DocumentLink() { "INSPIRE Atom".toLowerCase(), "wcs", "OGC:WCS".toLowerCase(), + "http://www.opengis.net/def/serviceType/ogc/wcs".toLowerCase(), "api features", "OGC - API Features".toLowerCase(), "OGC:OGC-API-Features-items".toLowerCase(), + "HTTP:OGC:API-Features".toLowerCase(), + "http://www.opengis.net/def/interface/ogcapi-features".toLowerCase(), + "SensorThings".toLowerCase(), "sos", "OGC:SOS".toLowerCase(), "http://www.opengis.net/def/serviceType/ogc/sos".toLowerCase() @@ -136,6 +142,12 @@ public DocumentLink() { "http://inspire.ec.europa.eu/metadata-codelist/SpatialDataServiceType/view".toLowerCase() }); + public static final String VALID_PROTOCOLS_VIEW_REGEX = "(.*wms.*|.*wmts.*|.*web map service.*)"; + + public static final String VALID_PROTOCOLS_DOWNLOAD_REGEX = "(.*wfs.*|.*atom.*|.*wcs.*|.*sos.*|.*api.*feature.*|.*sensorthings.*|.*web feature service.*)"; + + public static final String VALID_PROTOCOLS_REGEX = "(.*wfs.*|.*atom.*|.*wcs.*|.*sos.*|.*api.*feature.*|.*sensorthings.*|.*wms.*|.*wmts.*|.*web map service.*|.*web feature service.*)"; + public boolean isInspireSimplifiedLink() { // Relax the check to process links with the applicationProfile information if ((rawURL == null) || (protocol == null)) @@ -143,12 +155,18 @@ public boolean isInspireSimplifiedLink() { if (rawURL.isEmpty() || protocol.isEmpty()) return false; - if (!validProtocols.contains(protocol.toLowerCase())) - return false; + if (!validProtocols.contains(protocol.toLowerCase())) { + // Check protocol match "simple" values instead of exact match + if (!protocol.toLowerCase().matches(VALID_PROTOCOLS_REGEX)) { + return false; + } + } + return true; } + /*public boolean isInspireSimplifiedLink() { if ((rawURL == null) || (protocol == null) || (applicationProfile == null)) if ((rawURL == null) || (protocol == null)) diff --git a/services/linkchecker/src/main/java/net/geocat/eventprocessor/processors/postprocess/EventProcessor_PostProcessDatasetDocumentEvent.java b/services/linkchecker/src/main/java/net/geocat/eventprocessor/processors/postprocess/EventProcessor_PostProcessDatasetDocumentEvent.java index 7d0981b..beb4df8 100644 --- a/services/linkchecker/src/main/java/net/geocat/eventprocessor/processors/postprocess/EventProcessor_PostProcessDatasetDocumentEvent.java +++ b/services/linkchecker/src/main/java/net/geocat/eventprocessor/processors/postprocess/EventProcessor_PostProcessDatasetDocumentEvent.java @@ -331,7 +331,7 @@ private void process() { // Dataset link simplification if (!localDatasetMetadataRecord.getDocumentLinks().isEmpty()) { List viewLinksMetadataOnlineResources = localDatasetMetadataRecord.getDocumentLinks().stream() - .filter(x -> (x.getLinkState().equals(LinkState.Complete) && x.getLinkHTTPStatusCode() == 200) && (DocumentLink.validViewProtocols.contains(x.getProtocol().toLowerCase()))) + .filter(x -> (x.getLinkState().equals(LinkState.Complete) && x.getLinkHTTPStatusCode() == 200) && (DocumentLink.validViewProtocols.contains(x.getProtocol().toLowerCase()) || x.getProtocol().toLowerCase().matches(DocumentLink.VALID_PROTOCOLS_VIEW_REGEX))) .collect(Collectors.toList()); if (!viewLinksMetadataOnlineResources.isEmpty()) { @@ -348,7 +348,7 @@ private void process() { // Dataset link simplification if (!localDatasetMetadataRecord.getDocumentLinks().isEmpty()) { List downloadLinksMetadataOnlineResources = localDatasetMetadataRecord.getDocumentLinks().stream() - .filter(x -> (x.getLinkState().equals(LinkState.Complete) && x.getLinkHTTPStatusCode() == 200) && (DocumentLink.validDownloadProtocols.contains(x.getProtocol().toLowerCase()))) + .filter(x -> (x.getLinkState().equals(LinkState.Complete) && x.getLinkHTTPStatusCode() == 200) && (DocumentLink.validDownloadProtocols.contains(x.getProtocol().toLowerCase()) || x.getProtocol().toLowerCase().matches(DocumentLink.VALID_PROTOCOLS_DOWNLOAD_REGEX))) .collect(Collectors.toList()); if (!downloadLinksMetadataOnlineResources.isEmpty()) {