fix inputs declaration on complex type 02/89102/2
authortalio <tali.orenbach@amdocs.com>
Sun, 2 Jun 2019 13:15:10 +0000 (16:15 +0300)
committerOren Kleks <orenkle@amdocs.com>
Mon, 3 Jun 2019 05:55:00 +0000 (05:55 +0000)
Change-Id: I86172caf032f4936f98525830ed8aac2ea30567f
Issue-ID: SDC-2347
Signed-off-by: talio <tali.orenbach@amdocs.com>
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyDefinition.java

index 49dd3d6..643b946 100644 (file)
@@ -764,7 +764,7 @@ public abstract class BaseBusinessLogic {
         for (PropertyDefinition propertyDefinition : propertyDefinitions) {
             if (propertyDefinition.getName().equals(anInputPathArr)) {
                 if (ToscaType.isPrimitiveType(propertyDefinition.getType())) {
-                    constraints.addAll(propertyDefinition.getConstraints());
+                    constraints.addAll(propertyDefinition.safeGetConstraints());
                 } else {
                     type = propertyDefinition.getType();
                 }
index 7336859..15bef3b 100644 (file)
 
 package org.openecomp.sdc.be.dao.utils;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Set;
 
 public final class CollectionUtils {
     private CollectionUtils() {
     }
 
+    public static <T> List<T> safeGetList(List<T> listToCheck) {
+        return org.apache.commons.collections.CollectionUtils.isNotEmpty(listToCheck) ? listToCheck : Collections.emptyList();
+    }
+
     /**
      * Add the content of the 'source' Set to the 'target' set and return the
      * union set.
index e09fe41..6d37cc3 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.openecomp.sdc.be.model;
 
+import org.openecomp.sdc.be.dao.utils.CollectionUtils;
 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
 
 import java.util.List;
@@ -119,6 +120,10 @@ public class PropertyDefinition extends PropertyDataDefinition
         return constraints;
     }
 
+    public List<PropertyConstraint> safeGetConstraints() {
+        return CollectionUtils.safeGetList(constraints);
+    }
+
     public void setConstraints(List<PropertyConstraint> constraints) {
         this.constraints = constraints;
     }