From 1f60fa9f12b8a0ac2eaadd6f03b2c0218cabe4b4 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Wed, 13 Oct 2021 17:04:22 +0200 Subject: [PATCH] Removing filed with key mapped as none --- .../grsf_publish_ws/utils/HelperMethods.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/HelperMethods.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/HelperMethods.java index 78d03d4..9e65058 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/HelperMethods.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/HelperMethods.java @@ -70,6 +70,9 @@ public abstract class HelperMethods { public static final String PREVALIDATE_CONTEX_KEY = "PreValidateVRE"; public static final String PUBLIC_CONTEX_KEY = "PublicVRE"; private static final String PATH_SEPARATOR = "/"; + + // This key is used in replaceFieldsKey() function to indicate to remove the metadata field + private static final String NONE_KEY = "none"; // caches private static CacheInterface userEmailCache = new CacheImpl(1000 * 60 * 60 * 24); @@ -571,16 +574,18 @@ public abstract class HelperMethods { if(namespaces.containsKey(entry.getKey())){ usedKey = namespaces.get(entry.getKey()); - } - else{ + } else{ usedKey = entry.getKey(); } - if(isSourceRecord) + if(isSourceRecord) { usedKey = usedKey.replace("GRSF", "").trim(); + } - toReturn.put(usedKey, entry.getValue()); - + // When the replaced key is none the metadata field must be removed + if(usedKey.compareTo(NONE_KEY)!=0) { + toReturn.put(usedKey, entry.getValue()); + } } return toReturn;