summaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src/main')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java28
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java21
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java23
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java24
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java6
5 files changed, 97 insertions, 5 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
index ca1d0331fd..7a02f47d3f 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
@@ -28,6 +28,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Paths;
import java.util.List;
+import java.util.Optional;
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.api.consumer.IDistributionStatusMessage;
@@ -55,11 +56,16 @@ import org.onap.so.asdc.util.ASDCNotificationLogging;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
import org.onap.so.logger.MessageEnum;
-
import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
@Component
public class ASDCController {
@@ -555,6 +561,22 @@ public class ASDCController {
LOGGER.recordMetricEvent (subStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully sent Final notification to ASDC", "ASDC", null, null);
}
+ private Optional<String> getNotificationJson(INotificationData iNotif) {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ mapper.setSerializationInclusion(Include.NON_EMPTY);
+ mapper.setSerializationInclusion(Include.NON_ABSENT);
+ mapper.enable(MapperFeature.USE_ANNOTATIONS);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ Optional<String> returnValue = Optional.empty();
+ try {
+ returnValue = Optional.of(mapper.writeValueAsString(iNotif));
+ } catch (JsonProcessingException e) {
+ LOGGER.error("Error converting incoming ASDC notification to JSON" , e);
+ }
+ return returnValue;
+ }
+
public void treatNotification (INotificationData iNotif) {
int noOfArtifacts = 0;
@@ -571,7 +593,9 @@ public class ASDCController {
LOGGER.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif));
LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, iNotif.getServiceUUID(), "ASDC", "treatNotification");
this.changeControllerStatus(ASDCControllerStatus.BUSY);
- toscaInstaller.processWatchdog(iNotif.getDistributionID(),iNotif.getServiceUUID());
+ Optional<String> notificationMessage = getNotificationJson(iNotif);
+ toscaInstaller.processWatchdog(iNotif.getDistributionID(), iNotif.getServiceUUID(), notificationMessage,
+ asdcConfig.getConsumerID());
// Process only the Resource artifacts in MSO
this.processResourceNotification(iNotif);
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java
index 7dab49f82a..ed97f5bdea 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java
@@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.List;
import org.onap.sdc.api.notification.IArtifactInfo;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.EqualsBuilder;
public class ArtifactInfoImpl implements IArtifactInfo {
@@ -168,4 +170,23 @@ public class ArtifactInfoImpl implements IArtifactInfo {
public void setRelatedArtifacts(List<ArtifactInfoImpl> relatedArtifacts) {
this.relatedArtifactsImpl = relatedArtifacts;
}
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof ArtifactInfoImpl)) {
+ return false;
+ }
+ ArtifactInfoImpl castOther = (ArtifactInfoImpl) other;
+ return new EqualsBuilder().append(artifactUUID, castOther.artifactUUID)
+ .append(artifactVersion, castOther.artifactVersion).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(artifactName).append(artifactType).append(artifactURL)
+ .append(artifactChecksum).append(artifactDescription).append(artifactTimeout).append(artifactVersion)
+ .append(artifactUUID).append(generatedFromUUID).append(generatedArtifact).append(relatedArtifactsInfo)
+ .append(relatedArtifactsImpl).toHashCode();
+ }
+
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
index 294221352c..a1c660f75f 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
@@ -23,11 +23,15 @@ package org.onap.so.asdc.client.test.emulators;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.notification.IResourceInstance;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
@Component
public class NotificationDataImpl implements INotificationData {
@@ -114,6 +118,7 @@ public class NotificationDataImpl implements INotificationData {
return ret;
}
+ @JsonIgnore
public List<ResourceInfoImpl> getResourcesImpl(){
return resources;
}
@@ -172,4 +177,22 @@ public class NotificationDataImpl implements INotificationData {
}
return ret;
}
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof NotificationDataImpl)) {
+ return false;
+ }
+ NotificationDataImpl castOther = (NotificationDataImpl) other;
+ return new EqualsBuilder().append(serviceUUID, castOther.serviceUUID)
+ .append(serviceVersion, castOther.serviceVersion).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(distributionID).append(serviceName).append(serviceVersion)
+ .append(serviceUUID).append(serviceDescription).append(serviceInvariantUUID).append(resources)
+ .append(serviceArtifacts).append(workloadContext).toHashCode();
+ }
+
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
index eb4764dec1..dad7e64931 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
@@ -23,9 +23,13 @@ package org.onap.so.asdc.client.test.emulators;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.IResourceInstance;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
public class ResourceInfoImpl implements IResourceInstance{
ResourceInfoImpl (){}
private String resourceInstanceName;
@@ -120,7 +124,8 @@ public class ResourceInfoImpl implements IResourceInstance{
this.artifacts = artifacts;
}
- public List<ArtifactInfoImpl> getArtifactsImpl(){
+ @JsonIgnore
+ public List<ArtifactInfoImpl> getArtifactsImpl() {
return artifacts;
}
@@ -155,4 +160,21 @@ public class ResourceInfoImpl implements IResourceInstance{
public void setSubcategory(String subcategory) {
this.subcategory = subcategory;
}
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof ResourceInfoImpl)) {
+ return false;
+ }
+ ResourceInfoImpl castOther = (ResourceInfoImpl) other;
+ return new EqualsBuilder().append(resourceUUID, castOther.resourceUUID)
+ .append(resourceVersion, castOther.resourceVersion).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(resourceInstanceName).append(resourceCustomizationUUID).append(resourceName)
+ .append(resourceVersion).append(resourceType).append(resourceUUID).append(resourceInvariantUUID)
+ .append(category).append(subcategory).append(artifacts).toHashCode();
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index ebc705ce30..2f4d5ea6a1 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -689,8 +689,10 @@ public class ToscaResourceInstaller {
}
}
- public void processWatchdog(String distributionId, String servideUUID) {
- WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId,servideUUID);
+ public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
+ String consumerId) {
+ WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID,
+ distributionNotification, consumerId);
watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);