aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src/main/java')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java38
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java9
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java27
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java21
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java37
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java20
6 files changed, 62 insertions, 90 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java
index d0f86c722e..d59984bb52 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java
@@ -6,12 +6,14 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -52,21 +54,25 @@ public final class ASDCStatusCallBack implements IStatusCallback {
try {
- if (iStatus.getStatus() != null) {
- if (iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK)
- || iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) {
- WatchdogDistributionStatus watchdogDistributionStatus = watchdogDistributionStatusRepository
- .findById(iStatus.getDistributionID()).orElseGet(() -> null);
- if (watchdogDistributionStatus == null) {
- watchdogDistributionStatus = new WatchdogDistributionStatus();
- watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID());
- watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
- }
- logger.debug(event);
- toscaInstaller.installTheComponentStatus(iStatus);
-
- }
+ if (iStatus.getStatus() == null) {
+ logger.info("Missing status on Status Object. ");
+ return;
+ }
+ if (!iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK)
+ && !iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) {
+ logger.info("Status is not 'Component Done OK' or 'Component Done Error'");
+ return;
}
+ WatchdogDistributionStatus watchdogDistributionStatus =
+ watchdogDistributionStatusRepository.findById(iStatus.getDistributionID()).orElseGet(() -> null);
+ if (watchdogDistributionStatus == null) {
+ watchdogDistributionStatus = new WatchdogDistributionStatus();
+ watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID());
+ watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
+ }
+ logger.debug(event);
+ toscaInstaller.installTheComponentStatus(iStatus);
+
} catch (ArtifactInstallerException e) {
logger.error("Error in ASDCStatusCallback {}", e.getMessage(), e);
logger.debug("Error in ASDCStatusCallback {}", e.getMessage());
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java
index 13cace404e..0a1b1c531e 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,7 +39,6 @@ public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage
public FinalDistributionStatusMessage(String distributionId, final DistributionStatusEnum distributionStatusEnum,
final long timestampL, String consumerId) {
- // componentName = componentname;
consumerID = consumerId;
distributionID = distributionId;
status = distributionStatusEnum;
@@ -68,6 +69,7 @@ public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage
this.timestamp = timestamp;
}
+ @Override
public String getComponentName() {
return componentName;
}
@@ -76,6 +78,7 @@ public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage
this.componentName = componentName;
}
+ @Override
public String getConsumerID() {
return consumerID;
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java
index 7bd9c752a4..34f21ab813 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java
@@ -4,12 +4,14 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,43 +52,37 @@ public class JsonStatusData implements IStatusData {
@Override
public String getDistributionID() {
- // return (String)this.attributesMap.get("distributionID");
return "35120a87-1f82-4276-9735-f6de5a244d65";
}
@Override
public String getConsumerID() {
- // return (String)this.attributesMap.get("consumerID");
return "mso.123456";
}
@Override
public String getComponentName() {
- // return (String)this.attributesMap.get("componentName");
return "SDN-C";
}
@Override
public Long getTimestamp() {
- // return (String)this.attributesMap.get("timestamp");
return null;
}
@Override
public String getArtifactURL() {
- // return (String)this.attributesMap.get("artifactURL");
return "/sdc/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml";
}
@Override
public DistributionStatusEnum getStatus() {
- // return (DistributionStatusEnum)this.attributesMap.get(DistributionStatusEnum.DEPLOY_OK);
return DistributionStatusEnum.COMPONENT_DONE_OK;
}
/**
* Method instantiate a INotificationData implementation from a JSON file.
- *
+ *
* @param notifFilePath The file path in String
* @return A JsonNotificationData instance
* @throws IOException in case of the file is not readable or not accessible
@@ -96,19 +92,6 @@ public class JsonStatusData implements IStatusData {
InputStream is = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(notifFilePath + "status-structure.json");
- // String fileLocation = System.getProperty("mso.config.path") + "notif-structure.json";
-
- // String source = fileLocation;
- // InputStream is = IOUtils.toInputStream(source, "UTF-8");
-
- // String myString = IOUtils.toString(is, "UTF-8");
-
-
- // System.out.println(myString);
-
- if (is == null) {
- // throw new FileExistsException("Resource Path does not exist: "+notifFilePath);
- }
return mapper.readValue(is, JsonStatusData.class);
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java
index 36d6ab96c0..11c1cc33cf 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -25,8 +27,6 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import org.onap.sdc.api.notification.IVfModuleMetadata;
-import org.onap.so.asdc.client.ASDCConfiguration;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
import org.onap.so.db.catalog.beans.VfModule;
@@ -73,23 +73,6 @@ public final class VfModuleStructure {
}
}
- public List<VfModuleArtifact> getOrderedArtifactList() {
-
- List<VfModuleArtifact> artifactsList = new LinkedList<>();
-
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT));
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV));
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
-
- artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_NESTED)));
-
- artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT)));
-
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
-
- return null;
- }
-
public IVfModuleData getVfModuleMetadata() {
return vfModuleMetadata;
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
index f954fe0c5a..f5b0e17cf5 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
@@ -7,6 +7,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -77,39 +79,38 @@ public class VfResourceStructure extends ResourceStructure {
private Service catalogService;
- public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) {
- super(notificationdata, resourceinstance);
+ public VfResourceStructure(INotificationData notificationData, IResourceInstance resourceInstance) {
+ super(notificationData, resourceInstance);
this.resourceType = ResourceType.VF_RESOURCE;
vfModulesStructureList = new LinkedList<>();
vfModulesMetadataList = new ArrayList<>();
}
- public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
+ public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactInfo,
IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
- this.addArtifactToStructure(distributionClient, artifactinfo, clientResult, null);
+ this.addArtifactToStructure(artifactInfo, clientResult, null);
}
- public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
- IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate)
- throws UnsupportedEncodingException {
- VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo, clientResult, modifiedHeatTemplate);
- addArtifactByType(artifactinfo, clientResult, vfModuleArtifact);
- if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactinfo.getArtifactType())) {
+ public void addArtifactToStructure(IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult,
+ String modifiedHeatTemplate) throws UnsupportedEncodingException {
+ VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactInfo, clientResult, modifiedHeatTemplate);
+ addArtifactByType(artifactInfo, clientResult, vfModuleArtifact);
+ if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactInfo.getArtifactType())) {
logger.debug("VF_MODULE_ARTIFACT: " + new String(clientResult.getArtifactPayload(), "UTF-8"));
logger.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(vfModulesMetadataList));
}
}
- public void addWorkflowArtifactToStructure(IArtifactInfo artifactinfo,
+ public void addWorkflowArtifactToStructure(IArtifactInfo artifactInfo,
IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
- WorkflowArtifact workflowArtifact = new WorkflowArtifact(artifactinfo, clientResult);
- workflowArtifactsMapByUUID.put(artifactinfo.getArtifactUUID(), workflowArtifact);
+ WorkflowArtifact workflowArtifact = new WorkflowArtifact(artifactInfo, clientResult);
+ workflowArtifactsMapByUUID.put(artifactInfo.getArtifactUUID(), workflowArtifact);
}
- protected void addArtifactByType(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult,
+ protected void addArtifactByType(IArtifactInfo artifactInfo, IDistributionClientDownloadResult clientResult,
VfModuleArtifact vfModuleArtifact) {
- switch (artifactinfo.getArtifactType()) {
+ switch (artifactInfo.getArtifactType()) {
case ASDCConfiguration.HEAT:
case ASDCConfiguration.HEAT_ENV:
case ASDCConfiguration.HEAT_VOL:
@@ -118,7 +119,7 @@ public class VfResourceStructure extends ResourceStructure {
case ASDCConfiguration.HEAT_NET:
case ASDCConfiguration.OTHER:
case ASDCConfiguration.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT:
- artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact);
+ artifactsMapByUUID.put(artifactInfo.getArtifactUUID(), vfModuleArtifact);
break;
case ASDCConfiguration.VF_MODULES_METADATA:
vfModulesMetadataList = this.decodeVfModuleArtifact(clientResult.getArtifactPayload());
@@ -196,9 +197,7 @@ public class VfResourceStructure extends ResourceStructure {
public List<IVfModuleData> decodeVfModuleArtifact(byte[] arg0) {
try {
- List<IVfModuleData> listVFModuleMetaData =
- new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {});
- return listVFModuleMetaData;
+ return new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {});
} catch (JsonParseException e) {
logger.debug("JsonParseException : ", e);
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java
index 195aa7e302..db75c31b08 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java
@@ -6,6 +6,8 @@
* ================================================================================
* Modifications Copyright (c) 2019 Samsung
* ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -27,6 +29,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
@@ -107,18 +110,15 @@ public class BpmnInstaller {
logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), csarFilePath,
ex.getMessage(), ErrorCode.DataError.getValue(), "ASDC reading CSAR with workflows failed");
}
- return;
}
public boolean containsWorkflows(String csarFilePath) {
- boolean workflowsInCsar = false;
try (ZipFile zipFile = new ZipFile(csarFilePath)) {
Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
while (zipEntries.hasMoreElements()) {
String fileName = zipEntries.nextElement().getName();
if (fileName.endsWith(BPMN_SUFFIX)) {
- workflowsInCsar = true;
- break;
+ return true;
}
}
} catch (Exception e) {
@@ -126,10 +126,11 @@ public class BpmnInstaller {
logger.error(LoggingAnchor.FIVE, MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), csarFilePath,
e.getMessage(), ErrorCode.DataError.getValue(), "ASDC Unable to check CSAR entries");
}
- return workflowsInCsar;
+ return false;
}
- protected HttpResponse sendDeploymentRequest(String bpmnFileName, String version) throws Exception {
+ protected HttpResponse sendDeploymentRequest(String bpmnFileName, String version)
+ throws IOException, URISyntaxException {
HttpClient client = HttpClientBuilder.create().build();
URI deploymentUri = new URI(this.env.getProperty(CAMUNDA_URL) + CREATE_DEPLOYMENT_PATH);
HttpPost post = new HttpPost(deploymentUri);
@@ -141,7 +142,7 @@ public class BpmnInstaller {
return client.execute(post);
}
- protected HttpEntity buildMimeMultipart(String bpmnFileName, String version) throws Exception {
+ protected HttpEntity buildMimeMultipart(String bpmnFileName, String version) throws IOException {
FileInputStream bpmnFileStream = new FileInputStream(
Paths.get(getMsoConfigPath(), "ASDC", version, bpmnFileName).normalize().toString());
@@ -182,17 +183,14 @@ public class BpmnInstaller {
return requestEntity;
}
- /* protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) throws IOException */
protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) {
String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", fileName).normalize().toString();
- /* BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath)); */
try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath))) {
byte[] bytesIn = new byte[4096];
- int read = 0;
+ int read;
while ((read = zipIn.read(bytesIn)) != -1) {
outputStream.write(bytesIn, 0, read);
}
- /* outputStream.close(); */
} catch (IOException e) {
logger.error("Unable to open file.", e);
}