aboutsummaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org
diff options
context:
space:
mode:
authorRamya Balaji <rb111y@att.com>2018-01-02 21:58:59 -0500
committerSkip Wonnell <skip@att.com>2018-01-04 21:10:36 +0000
commit13b9505921e2cbbd4b155a78bfdaa5caa3375ec0 (patch)
tree7c661f5c3c8b7895cad1d4c3c90b9077ba74c1fd /appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org
parent9ebb5ddcb60345dea668049c73f5f2d9c3cdf731 (diff)
Updated SDC listener and dependent bundles
Changes related to SDC adapter.Also includes sequence generator changes and changes to appc-dg-shared. Issue-ID: APPC-355 Change-Id: Ib8a0b1d304199db6d2595291539b266885842d63 Signed-off-by: Ramya Balaji <rb111y@att.com>
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org')
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyManager.java4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyType.java4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/helper/DependencyModelParser.java43
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImpl.java4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/ResourceDependency.java4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowBuilder.java3
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowStrategy.java3
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/exception/InvalidDependencyModelException.java (renamed from appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/exception/InvalidDependencyModel.java)4
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/helper/Graph.java2
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/AbstractFlowStrategy.java31
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/FlowBuilderImpl.java3
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ForwardFlowStrategy.java8
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ReverseFlowStrategy.java8
13 files changed, 61 insertions, 60 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyManager.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyManager.java
index 8d04cea11..481d4dcad 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyManager.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyManager.java
@@ -25,12 +25,12 @@
package org.onap.appc.dg.dependencymanager;
import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.objects.DependencyTypes;
import org.onap.appc.dg.objects.VnfcDependencyModel;
import org.onap.appc.metadata.objects.DependencyModelIdentifier;
public interface DependencyManager {
- VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier, DependencyTypes dependencyType) throws InvalidDependencyModel, DependencyModelNotFound;
+ VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier, DependencyTypes dependencyType) throws InvalidDependencyModelException, DependencyModelNotFound;
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyType.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyType.java
index 15717f06b..7d2b0677f 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyType.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/DependencyType.java
@@ -25,11 +25,11 @@
package org.onap.appc.dg.dependencymanager;
import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.objects.VnfcDependencyModel;
import org.onap.appc.metadata.objects.DependencyModelIdentifier;
public interface DependencyType {
- VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier) throws InvalidDependencyModel, DependencyModelNotFound;
+ VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier) throws InvalidDependencyModelException, DependencyModelNotFound;
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/helper/DependencyModelParser.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/helper/DependencyModelParser.java
index 187020028..ea00f09ec 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/helper/DependencyModelParser.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/helper/DependencyModelParser.java
@@ -31,7 +31,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.apache.commons.lang3.StringUtils;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.objects.Node;
import org.onap.appc.dg.objects.VnfcDependencyModel;
import org.onap.appc.domainmodel.Vnfc;
@@ -39,18 +39,19 @@ import org.onap.appc.domainmodel.Vnfc;
import java.io.IOException;
import java.util.*;
-
public class DependencyModelParser {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(DependencyModelParser.class);
- private static Map<String, String> dependencyMap;
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(DependencyModelParser.class);
+
private static final String PROPERTIES = "properties";
private static final String ACTIVE_ACTIVE = "Active-Active";
private static final String ACTIVE_PASSIVE = "Active-Passive";
private static final String HIGH_AVAILABLITY = "high_availablity";
private static final String MANDATORY = "mandatory";
private static final String TOPOLOGY_TEMPLATE = "topology_template";
+ private static final String RELATIONSHIP="relationship";
+ private static Map<String, String> dependencyMap;
static {
Map<String, String> dependencyTypeMappingMap =new HashMap<>();
dependencyTypeMappingMap.put("geo-activeactive", ACTIVE_ACTIVE);
@@ -60,17 +61,17 @@ public class DependencyModelParser {
dependencyMap = Collections.unmodifiableMap(dependencyTypeMappingMap);
}
- public VnfcDependencyModel generateDependencyModel(String vnfModel,String vnfType) {
+ public VnfcDependencyModel generateDependencyModel(String vnfModel,String vnfType) throws InvalidDependencyModelException {
Set<Node<Vnfc>> dependencies = new HashSet<>();
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
boolean mandatory;
String resilienceType;
- String prefix = "org.openecomp.resource.vfc."+vnfType+".abstract.nodes.";
+ String prefix = "org.onap.resource.vfc."+vnfType+".abstract.nodes.";
try {
ObjectNode root = (ObjectNode) mapper.readTree(vnfModel);
if(root.get(TOPOLOGY_TEMPLATE) == null || root.get(TOPOLOGY_TEMPLATE).get("node_templates") == null) {
- throw new InvalidDependencyModel("Dependency model is missing 'topology_template' or 'node_templates' elements");
+ throw new InvalidDependencyModelException("Dependency model is missing 'topology_template' or 'node_templates' elements");
}
JsonNode topologyTemplateNode = root.get(TOPOLOGY_TEMPLATE);
@@ -81,7 +82,7 @@ public class DependencyModelParser {
String fullvnfcType = itretor.next().getValue().get("type").textValue();
String vnfcType= getQualifiedVnfcType(fullvnfcType);
String type = yamlNode.get("type").textValue();
- type = type.substring(0,type.lastIndexOf(".")+1);
+ type = type.substring(0,type.lastIndexOf('.')+1);
if(type.concat(vnfcType).toLowerCase().startsWith(prefix.concat(vnfcType).toLowerCase())) {
if(yamlNode.get(PROPERTIES).findValue(HIGH_AVAILABLITY) == null || yamlNode.get(PROPERTIES).findValue(HIGH_AVAILABLITY).asText().isEmpty()) {
@@ -110,7 +111,7 @@ public class DependencyModelParser {
} else {
logger.debug("Creating dependency node for : " + vnfcType);
- vnfcNode = new Node<>(new Vnfc(vnfcType, resilienceType, null, mandatory));
+ vnfcNode = new Node<>(createVnfc(mandatory, resilienceType, vnfcType));
if (parentList != null && parentList.length > 0)
addDependencies(dependencies, vnfcNode, parentList);
logger.debug("Adding VNFC to dependency model : " + vnfcNode);
@@ -121,13 +122,21 @@ public class DependencyModelParser {
} catch (IOException e) {
logger.error("Error parsing dependency model : " + vnfModel);
logger.error("Error message : " + e);
- throw new InvalidDependencyModel("Error parsing dependency model. " + e.getMessage());
+ throw new InvalidDependencyModelException("Error parsing dependency model. " + e.getMessage());
}
return new VnfcDependencyModel(dependencies);
}
+ private Vnfc createVnfc(boolean mandatory, String resilienceType, String vnfcType) {
+ Vnfc vnfc = new Vnfc();
+ vnfc.setMandatory(mandatory);
+ vnfc.setResilienceType(resilienceType);
+ vnfc.setVnfcType(vnfcType);
+ return vnfc;
+ }
+
private String getQualifiedVnfcType(String fullvnfcType) {
- return fullvnfcType.substring(fullvnfcType.lastIndexOf(".")+1,fullvnfcType.length());
+ return fullvnfcType.substring(fullvnfcType.lastIndexOf('.')+1,fullvnfcType.length());
}
private void addDependencies(Set<Node<Vnfc>> nodes, Node node, String[] parentList) {
@@ -139,7 +148,7 @@ public class DependencyModelParser {
node.addParent(parentNode.getChild());
} else {
logger.debug("VNFC does not exist for VNFC type: " + parentType + ". Creating new VNFC ");
- parentNode = new Node<>(new Vnfc(parentType, null));
+ parentNode = new Node<>(createVnfc(false,null,parentType));
node.addParent(parentNode.getChild());
logger.debug("Adding VNFC to dependency model : " + parentNode);
nodes.add(parentNode);
@@ -147,20 +156,20 @@ public class DependencyModelParser {
}
}
- private String[] getDependencyArray(JsonNode node, JsonNode nodeTemplateNode) {
+ private String[] getDependencyArray(JsonNode node, JsonNode nodeTemplateNode) throws InvalidDependencyModelException {
JsonNode requirementsNode = node.get("requirements");
- List<String> dependencyList = new ArrayList();
+ Set<String> dependencyList = new HashSet<>();
if(requirementsNode!=null) {
for (JsonNode internalNode : requirementsNode) {
//TODO : In this release we are supporting both relationship = tosca.capabilities.Node and relationship =tosca.relationships.DependsOn we need to remove one of them in next release post confirming with SDC team
if (nodeNullCheck(internalNode) &&"tosca.capabilities.Node".equalsIgnoreCase(internalNode.findValue("capability").asText())
- && ("tosca.relationships.DependsOn".equalsIgnoreCase(internalNode.findValue("relationship").asText()) || "tosca.capabilities.Node".equalsIgnoreCase(internalNode.findValue("relationship").asText()))) {
+ && ("tosca.relationships.DependsOn".equalsIgnoreCase(internalNode.findValue(RELATIONSHIP).asText()) || "tosca.capabilities.Node".equalsIgnoreCase(internalNode.findValue(RELATIONSHIP).asText()))) {
if(internalNode.findValue("node") != null) {
String nodeName = internalNode.findValue("node").asText();
String fullVnfcName = nodeTemplateNode.get(nodeName).get("type").asText();
dependencyList.add(getQualifiedVnfcType(fullVnfcName));
}else{
- throw new InvalidDependencyModel("Error parsing dependency model. " + "Dependent Node not found for "+ node.get("type"));
+ throw new InvalidDependencyModelException("Error parsing dependency model. " + "Dependent Node not found for "+ node.get("type"));
}
}
}
@@ -171,7 +180,7 @@ public class DependencyModelParser {
}
private boolean nodeNullCheck(JsonNode internalNode) {
- return internalNode.get("dependency") != null && internalNode.findValue("capability") != null && internalNode.findValue("relationship") != null;
+ return internalNode.get("dependency") != null && internalNode.findValue("capability") != null && internalNode.findValue(RELATIONSHIP) != null;
}
private Node<Vnfc> getNode(Set<Node<Vnfc>> nodes, String vnfcType) {
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImpl.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImpl.java
index 31ea46cc6..e4261f8d4 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImpl.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/DependencyManagerImpl.java
@@ -27,7 +27,7 @@ package org.onap.appc.dg.dependencymanager.impl;
import org.onap.appc.dg.dependencymanager.DependencyManager;
import org.onap.appc.dg.dependencymanager.DependencyType;
import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.objects.DependencyTypes;
import org.onap.appc.dg.objects.VnfcDependencyModel;
@@ -47,7 +47,7 @@ public class DependencyManagerImpl implements DependencyManager {
cache = MetadataCacheFactory.getInstance().getMetadataCache();
}
- public VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier,DependencyTypes dependencyType) throws InvalidDependencyModel, DependencyModelNotFound {
+ public VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier,DependencyTypes dependencyType) throws InvalidDependencyModelException, DependencyModelNotFound {
if (logger.isTraceEnabled()) {
logger.trace("Entering to getVnfcDependencyModel with DependencyModelIdentifier = "+ modelIdentifier
+ " , DependencyTypes = " + dependencyType);
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/ResourceDependency.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/ResourceDependency.java
index 73792d3ad..484241639 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/ResourceDependency.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/dependencymanager/impl/ResourceDependency.java
@@ -32,7 +32,7 @@ import com.att.eelf.configuration.EELFManager;
import org.onap.appc.dg.dependencymanager.DependencyType;
import org.onap.appc.dg.dependencymanager.exception.DependencyModelNotFound;
import org.onap.appc.dg.dependencymanager.helper.DependencyModelParser;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.objects.VnfcDependencyModel;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
@@ -68,7 +68,7 @@ public class ResourceDependency implements DependencyType{
this.metadataService = metadataService;
}
- public VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier) throws InvalidDependencyModel, DependencyModelNotFound {
+ public VnfcDependencyModel getVnfcDependencyModel(DependencyModelIdentifier modelIdentifier) throws InvalidDependencyModelException, DependencyModelNotFound {
if (logger.isTraceEnabled()) {
logger.trace("Entering to getVnfcDependencyModel with DependencyModelIdentifier = "+ modelIdentifier);
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowBuilder.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowBuilder.java
index 78dacd105..2c572516a 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowBuilder.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowBuilder.java
@@ -24,11 +24,12 @@
package org.onap.appc.dg.flowbuilder;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.objects.InventoryModel;
import org.onap.appc.dg.objects.VnfcDependencyModel;
import org.onap.appc.dg.objects.VnfcFlowModel;
public interface FlowBuilder {
- VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel,InventoryModel inventoryModel);
+ VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel,InventoryModel inventoryModel) throws InvalidDependencyModelException;
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowStrategy.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowStrategy.java
index e2c292776..dcea86197 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowStrategy.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/FlowStrategy.java
@@ -24,6 +24,7 @@
package org.onap.appc.dg.flowbuilder;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.objects.InventoryModel;
import org.onap.appc.dg.objects.VnfcDependencyModel;
import org.onap.appc.dg.objects.VnfcFlowModel;
@@ -31,5 +32,5 @@ import org.onap.appc.dg.objects.VnfcFlowModel;
public interface FlowStrategy {
- VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel);
+ VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws InvalidDependencyModelException;
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/exception/InvalidDependencyModel.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/exception/InvalidDependencyModelException.java
index 9f4cfed93..a4a674b8a 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/exception/InvalidDependencyModel.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/exception/InvalidDependencyModelException.java
@@ -25,8 +25,8 @@
package org.onap.appc.dg.flowbuilder.exception;
-public class InvalidDependencyModel extends RuntimeException {
- public InvalidDependencyModel(String message){
+public class InvalidDependencyModelException extends Exception {
+ public InvalidDependencyModelException(String message){
super(message);
}
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/helper/Graph.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/helper/Graph.java
index 95e0b6675..3b409a70e 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/helper/Graph.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/helper/Graph.java
@@ -26,8 +26,6 @@ package org.onap.appc.dg.flowbuilder.helper;
import java.util.*;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
-
public class Graph<T> {
private int size;
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/AbstractFlowStrategy.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/AbstractFlowStrategy.java
index fbb2d5d67..8d3eab3e9 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/AbstractFlowStrategy.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/AbstractFlowStrategy.java
@@ -32,7 +32,7 @@ import java.util.List;
import java.util.Set;
import org.onap.appc.dg.flowbuilder.FlowStrategy;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.flowbuilder.helper.Graph;
import org.onap.appc.dg.objects.*;
import org.onap.appc.domainmodel.Vnfc;
@@ -40,11 +40,11 @@ import org.onap.appc.domainmodel.Vnfc;
public abstract class AbstractFlowStrategy implements FlowStrategy {
- protected Graph<Vnfc> graph;
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractFlowStrategy.class);
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractFlowStrategy.class);
+ Graph<Vnfc> graph;
- public VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) {
+ public VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws InvalidDependencyModelException {
if(logger.isTraceEnabled()){
logger.trace("Entering into buildFlowModel with dependency model = " + dependencyModel
+ "inventory model = " +inventoryModel);
@@ -54,7 +54,7 @@ public abstract class AbstractFlowStrategy implements FlowStrategy {
|| dependencyModel.getDependencies() ==null
|| dependencyModel.getDependencies().size() ==0){
logger.debug("Dependency model not available, building flow model with sequence");
- throw new InvalidDependencyModel("Dependency model either null or does not contain any dependency");
+ throw new InvalidDependencyModelException("Dependency model either null or does not contain any dependency");
}
VnfcFlowModel flowModel = buildFlowModel(dependencyModel);
@@ -72,7 +72,7 @@ public abstract class AbstractFlowStrategy implements FlowStrategy {
}
private void populateFlowModel(VnfcFlowModel flowModel, InventoryModel inventoryModel) {
- Iterator<List<Vnfc>> flowIterator = null;
+ Iterator<List<Vnfc>> flowIterator;
for(Vnfc vnfcFromInventory:inventoryModel.getVnf().getVnfcs()){
flowIterator = flowModel.getModelIterator();
@@ -81,7 +81,7 @@ public abstract class AbstractFlowStrategy implements FlowStrategy {
for(Vnfc vnfcFromFlowModel:flowIterator.next() ){
if(vnfcType.equalsIgnoreCase(vnfcFromFlowModel.getVnfcType())){
vnfcFromFlowModel.setVnfcName(vnfcFromInventory.getVnfcName());
- vnfcFromFlowModel.addVms(vnfcFromInventory.getVserverList());
+ vnfcFromFlowModel.setVserverList(vnfcFromInventory.getVserverList());
}
}
}
@@ -90,7 +90,8 @@ public abstract class AbstractFlowStrategy implements FlowStrategy {
}
- private VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel) throws InvalidDependencyModel {
+ @SuppressWarnings("unchecked")
+ private VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel) throws InvalidDependencyModelException {
Set<Node<Vnfc>> dependencies = dependencyModel.getDependencies();
graph = new Graph(dependencies.size());
@@ -116,21 +117,11 @@ public abstract class AbstractFlowStrategy implements FlowStrategy {
count++;
}
if(flowModelSize != dependencies.size()){
- throw new InvalidDependencyModel("Cycle detected in the VNFC dependencies");
+ throw new InvalidDependencyModelException("Cyclic dependency detected between the VNFC's");
}
return builder.build();
}
- protected abstract List<List<Vnfc>> orderDependencies();
-
- /*private VnfcFlowModel buildFlowModelWithoutSequence(InventoryModel inventoryModel) {
- VnfcFlowModel.VnfcFlowModelBuilder builder = new VnfcFlowModel.VnfcFlowModelBuilder();
-
- for(Vnfc vnfc:inventoryModel.getVnf().getVnfcs()){
- builder = builder.addMetadata(0,vnfc);
- }
-
- return builder.build();
- }*/
+ protected abstract List<List<Vnfc>> orderDependencies() throws InvalidDependencyModelException;
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/FlowBuilderImpl.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/FlowBuilderImpl.java
index 59d1e4bf9..e57e2d38a 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/FlowBuilderImpl.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/FlowBuilderImpl.java
@@ -24,6 +24,7 @@
package org.onap.appc.dg.flowbuilder.impl;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.flowbuilder.FlowBuilder;
import org.onap.appc.dg.flowbuilder.FlowStrategy;
import org.onap.appc.dg.objects.InventoryModel;
@@ -44,7 +45,7 @@ public class FlowBuilderImpl implements FlowBuilder {
this.strategy = strategy;
}
- public VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) {
+ public VnfcFlowModel buildFlowModel(VnfcDependencyModel dependencyModel, InventoryModel inventoryModel) throws InvalidDependencyModelException{
return strategy.buildFlowModel(dependencyModel, inventoryModel);
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ForwardFlowStrategy.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ForwardFlowStrategy.java
index 9c5aae64f..053981989 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ForwardFlowStrategy.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ForwardFlowStrategy.java
@@ -26,13 +26,13 @@ package org.onap.appc.dg.flowbuilder.impl;
import java.util.*;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.domainmodel.Vnfc;
public class ForwardFlowStrategy extends AbstractFlowStrategy {
@Override
- protected List<List<Vnfc>> orderDependencies() {
+ protected List<List<Vnfc>> orderDependencies() throws InvalidDependencyModelException{
ArrayList<List<Vnfc>> arrayList = new ArrayList<>();
Queue<Vnfc> queue1 = new LinkedList();
@@ -53,7 +53,7 @@ public class ForwardFlowStrategy extends AbstractFlowStrategy {
}
}
if(queue1.isEmpty()){
- throw new InvalidDependencyModel("There seems to be no Root/Independent node for Vnfc dependencies");
+ throw new InvalidDependencyModelException("There seems to be no Root/Independent node for Vnfc dependencies");
}
arrayList.add((List<Vnfc>)queue1);
queue1 = new LinkedList<>(queue1);
@@ -86,7 +86,7 @@ public class ForwardFlowStrategy extends AbstractFlowStrategy {
if(arrayList.size()>graph.getSize()){
// dependency list cannot be larger than total number of nodes
// if it happens indicates cycle in the dependency
- throw new InvalidDependencyModel("Cycle detected in the VNFC dependencies");
+ throw new InvalidDependencyModelException("Cycle detected in the VNFC dependencies");
}
queue1.addAll(queue2);
queue2 = new LinkedHashSet<>();
diff --git a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ReverseFlowStrategy.java b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ReverseFlowStrategy.java
index 79cd4420c..72b88f6e5 100644
--- a/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ReverseFlowStrategy.java
+++ b/appc-dg/appc-dg-shared/appc-dg-dependency-model/src/main/java/org/onap/appc/dg/flowbuilder/impl/ReverseFlowStrategy.java
@@ -26,14 +26,14 @@ package org.onap.appc.dg.flowbuilder.impl;
import java.util.*;
-import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModel;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.domainmodel.Vnfc;
public class ReverseFlowStrategy extends AbstractFlowStrategy {
@Override
- protected List<List<Vnfc>> orderDependencies() {
+ protected List<List<Vnfc>> orderDependencies() throws InvalidDependencyModelException{
ArrayList<List<Vnfc>> arrayList = new ArrayList<>();
Queue<Vnfc> queue1 = new LinkedList();
@@ -54,7 +54,7 @@ public class ReverseFlowStrategy extends AbstractFlowStrategy {
}
}
if(queue1.isEmpty()){
- throw new InvalidDependencyModel("There seems to be no leaf node for Vnfc dependencies");
+ throw new InvalidDependencyModelException("There seems to be no leaf node for Vnfc dependencies");
}
arrayList.add((List<Vnfc>)queue1);
queue1 = new LinkedList<>(queue1);
@@ -87,7 +87,7 @@ public class ReverseFlowStrategy extends AbstractFlowStrategy {
if(arrayList.size()>graph.getSize()){
// dependency list cannot be larger than total number of nodes
// if it happens indicates cycle in the dependency
- throw new InvalidDependencyModel("Cycle detected in the VNFC dependencies");
+ throw new InvalidDependencyModelException("Cyclic dependency detected between the VNFCs");
}
queue1.addAll(queue2);
queue2 = new LinkedHashSet<>();