aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2019-02-19 19:09:00 +0000
committermark.j.leonard <mark.j.leonard@gmail.com>2019-02-19 19:09:00 +0000
commitbe30876e3a3872a7274c944995544836ff31913c (patch)
tree8901f10cf66eee34d9ca72adcd8c201051c3df5d /src/main/java
parentfc779f51a624bfddc68328bf3fd3c74594ef31f6 (diff)
Fix outstanding Sonar issues
Change-Id: I9699ee13321f136b4460d5c85d49ab13378f52b4 Issue-ID: AAI-2121 Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java43
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java24
-rw-r--r--src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java5
3 files changed, 39 insertions, 33 deletions
diff --git a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java
index 50c6edf..3fb77be 100644
--- a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java
+++ b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java
@@ -85,7 +85,7 @@ public class ArtifactGeneratorToscaParser {
* Constructs using csarHelper
*
* @param csarHelper
- * The csar helper
+ * The csar helper
*/
public ArtifactGeneratorToscaParser(ISdcCsarHelper csarHelper) {
this.csarHelper = csarHelper;
@@ -95,7 +95,7 @@ public class ArtifactGeneratorToscaParser {
* Get or create the artifact description.
*
* @param model
- * the artifact model
+ * the artifact model
* @return the artifact model's description
*/
public static String getArtifactDescription(Model model) {
@@ -136,9 +136,9 @@ public class ArtifactGeneratorToscaParser {
* Initialises the group filtering and TOSCA mapping configuration.
*
* @param configLocation
- * the pathname to the JSON config file
+ * the pathname to the JSON config file
* @throws FileNotFoundException
- * if the file cannot be opened for reading
+ * if the file cannot be opened for reading
*/
public static void initToscaMappingsConfiguration(String configLocation) throws FileNotFoundException {
log.debug("Getting TOSCA Mappings Configuration");
@@ -181,9 +181,9 @@ public class ArtifactGeneratorToscaParser {
* duplicate keys then the TOSCA Property value takes precedence.
*
* @param stringProps
- * initial Map of String property values (e.g. from the TOSCA YAML metadata section)
+ * initial Map of String property values (e.g. from the TOSCA YAML metadata section)
* @param toscaProps
- * Map of TOSCA Property Type Object values to merge in (or overwrite)
+ * Map of TOSCA Property Type Object values to merge in (or overwrite)
* @return a Map of the property values converted to String
*/
public Map<String, String> mergeProperties(Map<String, String> stringProps, Map<String, Property> toscaProps) {
@@ -253,13 +253,12 @@ public class ArtifactGeneratorToscaParser {
String metaDataType = Optional.ofNullable(metadata).map(m -> m.getValue("type")).orElse(nodeTypeName);
Resource model = Model.getModelFor(nodeTypeName, metaDataType);
- if (metadata != null && hasAllottedResource(metadata.getAllProperties())) {
- if (model.getWidgetType() == Type.VSERVER) {
- model = new Resource(Type.ALLOTTED_RESOURCE, false);
- Map<String, Object> props = new HashMap<>();
- props.put("providingService", true);
- model.setProperties(props);
- }
+ if (metadata != null && hasAllottedResource(metadata.getAllProperties())
+ && model.getWidgetType() == Type.VSERVER) {
+ model = new Resource(Type.ALLOTTED_RESOURCE, false);
+ Map<String, Object> props = new HashMap<>();
+ props.put("providingService", true);
+ model.setProperties(props);
}
foundProvidingService |= processModel(resourceModel, metadata, model, resourceNodeTemplate.getProperties());
@@ -276,13 +275,13 @@ public class ArtifactGeneratorToscaParser {
* Create an Instance Group Model and populate it with the supplied data.
*
* @param resourceModel
- * the Resource node template Model
+ * the Resource node template Model
* @param memberNodes
- * the Resources and Widgets belonging to the Group
+ * the Resources and Widgets belonging to the Group
* @param metaProperties
- * the metadata of the Group
+ * the metadata of the Group
* @param properties
- * the properties of the Group
+ * the properties of the Group
* @return the Instance Group and Member resource models
*/
private List<Resource> processInstanceGroup(Model resourceModel, ArrayList<NodeTemplate> memberNodes,
@@ -385,7 +384,7 @@ public class ArtifactGeneratorToscaParser {
* Create a Map of property name against String property value from the input Map
*
* @param inputMap
- * The input Map
+ * The input Map
* @return Map of property name against String property value
*/
private Map<String, String> populateStringProperties(Map<String, Property> inputMap) {
@@ -398,13 +397,13 @@ public class ArtifactGeneratorToscaParser {
* is ProvidingService then return true, otherwise return false.
*
* @param resourceModel
- * parent Resource
+ * parent Resource
* @param metaData
- * for populating the Resource IDs
+ * for populating the Resource IDs
* @param resourceNode
- * any Model (will be ignored if not a Resource)
+ * any Model (will be ignored if not a Resource)
* @param nodeProperties
- * the node properties
+ * the node properties
* @return whether or not a ProvidingService was processed
*/
private boolean processModel(Model resourceModel, Metadata metaData, Resource resourceNode,
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java
index 19b3d80..57e8a67 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java
@@ -112,7 +112,7 @@ public class AaiArtifactGenerator implements ArtifactGenerator {
*
* @param serviceVersion
* @param csarHelper
- * interface to the TOSCA parser
+ * interface to the TOSCA parser
* @return the generated Artifacts (containing XML models)
*/
private GenerationData generateAllArtifacts(final String serviceVersion, ISdcCsarHelper csarHelper) {
@@ -229,10 +229,9 @@ public class AaiArtifactGenerator implements ArtifactGenerator {
if (model != null) {
Metadata metadata = nodeTemplate.getMetaData();
- if (metadata != null && parser.hasAllottedResource(metadata.getAllProperties())) {
- if (model.getWidgetType() == Type.VF) {
- model = new Resource(Type.ALLOTTED_RESOURCE, true);
- }
+ if (metadata != null && parser.hasAllottedResource(metadata.getAllProperties())
+ && model.getWidgetType() == Type.VF) {
+ model = new Resource(Type.ALLOTTED_RESOURCE, true);
}
}
@@ -242,6 +241,11 @@ public class AaiArtifactGenerator implements ArtifactGenerator {
private void generateResourceModel(ISdcCsarHelper csarHelper, List<Resource> resources,
ArtifactGeneratorToscaParser parser, NodeTemplate nodeTemplate) {
Resource resourceModel = getModelFor(parser, nodeTemplate);
+ if (resourceModel == null) {
+ log.info(ApplicationMsgs.DISTRIBUTION_EVENT, "Could not generate resource model");
+ return;
+ }
+
Map<String, String> serviceMetadata = nodeTemplate.getMetaData().getAllProperties();
resourceModel.populateModelIdentificationInformation(serviceMetadata);
@@ -296,7 +300,7 @@ public class AaiArtifactGenerator implements ArtifactGenerator {
* Method to generate the artifact name for an AAI model.
*
* @param model
- * AAI artifact model
+ * AAI artifact model
* @return Model artifact name
*/
private String getArtifactName(Model model) {
@@ -320,9 +324,9 @@ public class AaiArtifactGenerator implements ArtifactGenerator {
* Create Resource artifact model from the AAI xml model string.
*
* @param resourceModel
- * Model of the resource artifact
+ * Model of the resource artifact
* @param aaiResourceModel
- * AAI model as string
+ * AAI model as string
* @return Generated {@link Artifact} model for the resource
*/
private Artifact getResourceArtifact(Model resourceModel, String aaiResourceModel) {
@@ -352,9 +356,9 @@ public class AaiArtifactGenerator implements ArtifactGenerator {
* Create Service artifact model from the AAI XML model.
*
* @param serviceModel
- * Model of the service artifact
+ * Model of the service artifact
* @param aaiServiceModel
- * AAI model as string
+ * AAI model as string
* @return Generated {@link Artifact} model for the service
*/
private Artifact getServiceArtifact(Service serviceModel, String aaiServiceModel) {
diff --git a/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java b/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java
index d6a9405..d655ca6 100644
--- a/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java
+++ b/src/main/java/org/onap/aai/babel/xml/generator/model/Resource.java
@@ -57,14 +57,17 @@ public class Resource extends Model {
return false;
}
+ @Override
public boolean getDeleteFlag() {
return deleteFlag;
}
+ @Override
public String getWidgetInvariantId() {
return Widget.getWidget(getWidgetType()).getWidgetId();
}
+ @Override
public String getWidgetId() {
return Widget.getWidget(getWidgetType()).getId();
}
@@ -100,7 +103,7 @@ public class Resource extends Model {
* Adds a Widget.
*
* @param widget
- * the widget
+ * the widget
* @return the boolean
*/
@Override