summaryrefslogtreecommitdiffstats
path: root/models-tosca/src/main/java
diff options
context:
space:
mode:
authorsaul.gill <saul.gill@est.tech>2021-08-31 09:33:32 +0100
committerAjith Sreekumar <ajith.sreekumar@bell.ca>2021-09-02 09:01:17 +0000
commita5e71e426f1d11b381dff8ddda0adfcc9f6f7571 (patch)
tree81e09fac18cc2789ea97b7ae44c6b0b691ee4d38 /models-tosca/src/main/java
parent263f2bd07273cef4bc103f5198fa36e1e04297e5 (diff)
Add check for null for policies and policy types
Add check when reading policies and policy types from db Issue-ID: POLICY-3606 Change-Id: I7a1d96e4be1841243619e89c31dabc3e761dd17a Signed-off-by: saul.gill <saul.gill@est.tech>
Diffstat (limited to 'models-tosca/src/main/java')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java
index 98efd1991..919d187de 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java
@@ -104,13 +104,16 @@ public class ToscaEntity implements PfNameVersion {
// Declare the return map
Map<ToscaEntityKey, T> entityMap = new LinkedHashMap<>();
+ if (listOfMapsOfEntities == null) {
+ return entityMap;
+ }
+
for (Map<String, T> mapOfEntities : listOfMapsOfEntities) {
for (T entityEntry : mapOfEntities.values()) {
if (entityMap.containsKey(entityEntry.getKey())) {
throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
- "list of map of entities contains more than one entity with key " + entityEntry.getKey());
+ "list of map of entities contains more than one entity with key " + entityEntry.getKey());
}
-
entityMap.put(entityEntry.getKey(), entityEntry);
}
}
@@ -129,10 +132,14 @@ public class ToscaEntity implements PfNameVersion {
// Declare the return map
Map<ToscaEntityKey, T> entityMap = new LinkedHashMap<>();
+ if (mapOfEntities == null) {
+ return entityMap;
+ }
+
for (T entityEntry : mapOfEntities.values()) {
if (entityMap.containsKey(entityEntry.getKey())) {
throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
- "list of map of entities contains more than one entity with key " + entityEntry.getKey());
+ "list of map of entities contains more than one entity with key " + entityEntry.getKey());
}
entityMap.put(entityEntry.getKey(), entityEntry);