summaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2021-02-22 14:59:48 +0000
committerMichael Morris <michael.morris@est.tech>2021-02-24 10:38:15 +0000
commit75202327c2679926c80d1803b508a1779b588b38 (patch)
tree56fdae79f5020019663b4374e867f5c8986dcba2 /catalog-model
parentb6d953c506c08a5369c0be7242ef3ce3ec888452 (diff)
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 <michael.morris@est.tech> Issue-ID: SDC-3486 Change-Id: I58062955f3d79ca2b9496ce60f9d0c09aa6147fa
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java11
1 files changed, 9 insertions, 2 deletions
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<List<MetadataKeyDataDefinition>>() {
}.getType();
- List<MetadataKeyDataDefinition> metadataKeys = getGson().fromJson((String) subCategoryV.property(GraphPropertyEnum.METADATA_KEYS.getProperty()).value(), listTypeSubcat);
+ List<MetadataKeyDataDefinition> 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<Vertex, JanusGraphOperationStatus> parentVertex = janusGraphDao.getParentVertex(subCategoryV, EdgeLabelEnum.SUB_CATEGORY, JsonParseFlagEnum.NoParse);
@@ -1077,7 +1081,10 @@ public abstract class ToscaElementOperation extends BaseOperation {
Type listTypeCat = new TypeToken<List<MetadataKeyDataDefinition>>() {
}.getType();
- List<MetadataKeyDataDefinition> metadataKeys = getGson().fromJson((String) categoryV.property(GraphPropertyEnum.METADATA_KEYS.getProperty()).value(), listTypeCat);
+ List<MetadataKeyDataDefinition> 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);