From 06cf2100e86440109b94012d478f77537b3c6584 Mon Sep 17 00:00:00 2001 From: redmitry Date: Tue, 30 Apr 2024 14:00:09 +0200 Subject: [PATCH] be loosy with entryTypes names --- .../engine/BeaconEndpointsMatcher.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/es/bsc/inb/ga4gh/beacon/network/engine/BeaconEndpointsMatcher.java b/src/main/java/es/bsc/inb/ga4gh/beacon/network/engine/BeaconEndpointsMatcher.java index 2dfc96c..a89f481 100644 --- a/src/main/java/es/bsc/inb/ga4gh/beacon/network/engine/BeaconEndpointsMatcher.java +++ b/src/main/java/es/bsc/inb/ga4gh/beacon/network/engine/BeaconEndpointsMatcher.java @@ -9,7 +9,9 @@ import jakarta.servlet.http.HttpServletRequest; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; /** * @author Dmitry Repchevsky @@ -28,8 +30,8 @@ public Map> match(HttpServletRequest request) final StringBuffer url = request.getRequestURL(); - final String endpointType = getEndpointType(url.toString()); - if (endpointType == null) { + final Set endpointTypes = getEndpointTypes(url.toString()); + if (endpointTypes.isEmpty()) { return Collections.EMPTY_MAP; } @@ -41,7 +43,7 @@ public Map> match(HttpServletRequest request) for (Map.Entry> entry : all_endpoints.entrySet()) { final Map urls = entry.getValue(); for (Map.Entry urlEntry : urls.entrySet()) { - if (endpointType.equals(urlEntry.getKey()) && + if (endpointTypes.contains(urlEntry.getKey()) && match(path, urlEntry.getValue())) { matched_endpoints.put(entry.getKey(), urlEntry); } @@ -56,10 +58,12 @@ public Map> match(HttpServletRequest request) * * @param path current request URL path * - * @return typed endpoint (e.g. 'genomicVariant', + * @return a set of typed endpoints (e.g. 'genomicVariant', * 'genomicVariant:genomicVariant', 'genomicVariant:analysis') or null */ - private String getEndpointType(String path) { + private Set getEndpointTypes(String path) { + final Set types = new HashSet(); + final BeaconMap map = map_response.maps().getResponse(); if (map != null) { final Map endpoints = map.getEndpointSets(); @@ -72,10 +76,12 @@ private String getEndpointType(String path) { } if (match(path, endpoint.getRootUrl())) { - return entryType; + types.add(entryType); + continue; } if (match(path, endpoint.getSingleEntryUrl())) { - return entryType + ":" + entryType; + types.add(entryType + ":" + entryType); + continue; } final Map related_endpont = endpoint.getEndpoints(); @@ -87,14 +93,16 @@ private String getEndpointType(String path) { if (relEntryType == null) { relEntryType = rel_entry.getKey(); } - return entryType + ":" + relEntryType; + types.add(entryType + ":" + relEntryType); + break; } } } } } } - return null; + + return types; } /**