[SDC-DIST] Upgrade asdc-controller to use client version 2.0.0
[so.git] / asdc-controller / src / main / java / org / onap / so / asdc / client / ASDCController.java
index 61c0cdb..8e3c5f4 100644 (file)
@@ -39,10 +39,7 @@ import java.nio.charset.StandardCharsets;
 import java.nio.file.Paths;
 import java.util.List;
 import java.util.Optional;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.so.asdc.util.ZipParser;
-import org.onap.so.logger.LoggingAnchor;
+import org.onap.logging.filter.base.ErrorCode;
 import org.onap.logging.ref.slf4j.ONAPLogConstants;
 import org.onap.sdc.api.IDistributionClient;
 import org.onap.sdc.api.consumer.IDistributionStatusMessage;
@@ -53,6 +50,8 @@ import org.onap.sdc.api.notification.IResourceInstance;
 import org.onap.sdc.api.results.IDistributionClientDownloadResult;
 import org.onap.sdc.api.results.IDistributionClientResult;
 import org.onap.sdc.impl.DistributionClientFactory;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
 import org.onap.sdc.utils.DistributionActionResultEnum;
 import org.onap.sdc.utils.DistributionStatusEnum;
 import org.onap.so.asdc.activity.DeployActivitySpecs;
@@ -70,11 +69,12 @@ import org.onap.so.asdc.installer.heat.ToscaResourceInstaller;
 import org.onap.so.asdc.tenantIsolation.DistributionStatus;
 import org.onap.so.asdc.tenantIsolation.WatchdogDistribution;
 import org.onap.so.asdc.util.ASDCNotificationLogging;
+import org.onap.so.asdc.util.ZipParser;
 import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
 import org.onap.so.db.request.beans.WatchdogDistributionStatus;
 import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
 import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
-import org.onap.logging.filter.base.ErrorCode;
+import org.onap.so.logger.LoggingAnchor;
 import org.onap.so.logger.MessageEnum;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -147,6 +147,10 @@ public class ASDCController {
         this.controllerName = controllerConfigName;
     }
 
+    public ASDCConfiguration getASDCConfiguration() {
+        return asdcConfig;
+    }
+
     public int getNbOfNotificationsOngoing() {
         return nbOfNotificationsOngoing;
     }
@@ -953,7 +957,7 @@ public class ASDCController {
      */
     public String getAddress() {
         if (asdcConfig != null) {
-            return asdcConfig.getAsdcAddress();
+            return asdcConfig.getSdcAddress();
         }
         return UNKNOWN;
     }
@@ -971,12 +975,14 @@ public class ASDCController {
     private void processNsstNotification(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
         Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
         try {
-            if (serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY).equalsIgnoreCase("NSST")) {
-
+            String category = serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+            boolean isNeedInital = (category.contains("NSST") || category.equalsIgnoreCase("TN Network Requirement"))
+                    && iNotif.getResources().isEmpty();
+            if (isNeedInital) {
                 String artifactContent = null;
                 List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
                 Optional<IArtifactInfo> artifactOpt = serviceArtifacts.stream()
-                        .filter(e -> e.getArtifactType().equalsIgnoreCase("OTHER")).findFirst();
+                        .filter(e -> e.getArtifactType().equalsIgnoreCase("WORKFLOW")).findFirst();
                 if (artifactOpt.isPresent()) {
                     IArtifactInfo artifactInfo = artifactOpt.get();
                     logger.debug("Ready to parse this serviceArtifactUUID:  " + artifactInfo.getArtifactUUID());
@@ -986,14 +992,18 @@ public class ASDCController {
                     artifactContent = zipParserInstance.parseJsonForZip(filePath);
                     logger.debug(
                             "serviceArtifact parsing success! serviceArtifactUUID: " + artifactInfo.getArtifactUUID());
+
+                    ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
+                    resourceStructure.setResourceType(ResourceType.OTHER);
+                    toscaInstaller.installNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure,
+                            artifactContent);
                 } else {
                     logger.debug("serviceArtifact is null");
+                    toscaInstaller.installNsstService(toscaResourceStructure, null, null);
                 }
-                ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
-                resourceStructure.setResourceType(ResourceType.OTHER);
-                toscaInstaller.installTheNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure,
-                        artifactContent);
+
             }
+
         } catch (IOException e) {
             logger.error("serviceArtifact parse failure for service uuid:  "
                     + serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));