From 75202327c2679926c80d1803b508a1779b588b38 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Mon, 22 Feb 2021 14:59:48 +0000 Subject: Fix exception thrown in ToscaElementOperation This is caused by the absence of the metadataKeys property in the category definitions already in the DB Signed-off-by: MichaelMorris Issue-ID: SDC-3486 Change-Id: I58062955f3d79ca2b9496ce60f9d0c09aa6147fa --- .../jsonjanusgraph/operations/ToscaElementOperation.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'catalog-model/src/main') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java index 5dbce38ee2..32f7e14e00 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java @@ -27,6 +27,7 @@ import com.google.gson.reflect.TypeToken; import fj.data.Either; import java.lang.reflect.Type; import java.util.ArrayList; +import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; import java.util.HashSet; @@ -1041,7 +1042,10 @@ public abstract class ToscaElementOperation extends BaseOperation { Type listTypeSubcat = new TypeToken>() { }.getType(); - List metadataKeys = getGson().fromJson((String) subCategoryV.property(GraphPropertyEnum.METADATA_KEYS.getProperty()).value(), listTypeSubcat); + List metadataKeys = + subCategoryV.property(GraphPropertyEnum.METADATA_KEYS.getProperty()).isPresent() ? getGson().fromJson( + (String) subCategoryV.property(GraphPropertyEnum.METADATA_KEYS.getProperty()).value(), + listTypeSubcat) : Collections.emptyList(); subcategory.setMetadataKeys(metadataKeys); Either parentVertex = janusGraphDao.getParentVertex(subCategoryV, EdgeLabelEnum.SUB_CATEGORY, JsonParseFlagEnum.NoParse); @@ -1077,7 +1081,10 @@ public abstract class ToscaElementOperation extends BaseOperation { Type listTypeCat = new TypeToken>() { }.getType(); - List metadataKeys = getGson().fromJson((String) categoryV.property(GraphPropertyEnum.METADATA_KEYS.getProperty()).value(), listTypeCat); + List metadataKeys = + categoryV.property(GraphPropertyEnum.METADATA_KEYS.getProperty()).isPresent() ? getGson().fromJson( + (String) categoryV.property(GraphPropertyEnum.METADATA_KEYS.getProperty()).value(), listTypeCat) + : Collections.emptyList(); category.setMetadataKeys(metadataKeys); categories.add(category); -- cgit 1.2.3-korg