Fix outstanding Sonar issues
[aai/babel.git] / src / main / java / org / onap / aai / babel / xml / generator / api / AaiArtifactGenerator.java
index 19b3d80..57e8a67 100644 (file)
@@ -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) {