aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java5
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java48
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java28
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java23
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java57
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CloudRegion.java8
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java4
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java1
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java9
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java96
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java32
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java48
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java120
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java97
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java18
-rw-r--r--common/pom.xml4
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIRestClient.java28
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java7
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/Relationships.java110
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryRestClient.java77
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryRelationships.java137
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java15
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java12
34 files changed, 778 insertions, 253 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java
index ffbe1b4c46..d1f952c829 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackServiceData.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -20,7 +22,6 @@
package org.onap.so.adapters.audit;
-import java.util.Collections;
import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
@@ -82,7 +83,7 @@ public class AuditStackServiceData {
}
private void setupMDC(ExternalTask externalTask) {
- String msoRequestId = (String)externalTask.getVariable("mso-request-id");
+ String msoRequestId = externalTask.getVariable("mso-request-id");
if(msoRequestId != null && !msoRequestId.isEmpty())
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
}
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 cd9a121ddb..59030e6c22 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
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -31,7 +33,6 @@ import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
-
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -110,32 +111,29 @@ public class BpmnInstaller {
ex.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "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 = ((ZipEntry) zipEntries.nextElement()).getName();
- if (fileName.endsWith(BPMN_SUFFIX)) {
- workflowsInCsar = true;
- break;
- }
- }
- }
- catch (Exception e) {
- LOGGER.debug("Exception :",e);
+ 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;
+ }
+ }
+ } catch (Exception e) {
+ LOGGER.debug("Exception :", e);
LOGGER.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC,
- csarFilePath,
- "",
- "",
- e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "ASDC Unable to check CSAR entries");
- }
- return workflowsInCsar;
- }
-
+ csarFilePath,"","",
+ e.getMessage(), "", "",
+ MsoLogger.ErrorCode.DataError, "ASDC Unable to check CSAR entries");
+ }
+ return workflowsInCsar;
+ }
+
protected HttpResponse sendDeploymentRequest(String bpmnFileName) throws Exception {
HttpClient client = HttpClientBuilder.create().build();
URI deploymentUri = new URI(this.env.getProperty(CAMUNDA_URL) + CREATE_DEPLOYMENT_PATH);
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 f8d9d6c96c..d13fff4801 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
@@ -1481,8 +1481,8 @@ public class ToscaResourceInstaller {
cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
}
- cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfTemplate, "nf_naming_code"));
+ cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
+ cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
cvnfcCustomization.setVnfResourceCustomization(vnfResource);
@@ -1510,7 +1510,7 @@ public class ToscaResourceInstaller {
}
VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = createVfCnvfConfigCustomization(fabricTemplate, toscaResourceStructure,
- vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate);
+ vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig, vfTemplate, vfModuleMemberName);
vnfVfmoduleCvnfcConfigurationCustomizations.add(vnfVfmoduleCvnfcConfigurationCustomization);
}
@@ -1531,7 +1531,7 @@ public class ToscaResourceInstaller {
protected VnfVfmoduleCvnfcConfigurationCustomization createVfCnvfConfigCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
- ConfigurationResource configResource, NodeTemplate vfTemplate) {
+ ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
Metadata fabricMetadata = fabricTemplate.getMetaData();
@@ -1550,14 +1550,20 @@ public class ToscaResourceInstaller {
if(policyList != null){
for(Policy policy : policyList){
- Map<String, Object> propMap = policy.getPolicyProperties();
+ for(String policyCvfcTarget : policy.getTargets()){
+
+ if(policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)){
+
+ Map<String, Object> propMap = policy.getPolicyProperties();
- if(propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")){
- vfModuleToCvnfc.setPolicyName(propMap.get("name").toString());
- }
- }
- }
-
+ if(propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")){
+ vfModuleToCvnfc.setPolicyName(propMap.get("name").toString());
+ }
+ }
+ }
+ }
+ }
+
vfModuleToCvnfc.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
vfModuleToCvnfc.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
vfModuleToCvnfc.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
index f886ce7a3e..de28ca2446 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
@@ -35,6 +35,7 @@ import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.elements.Metadata;
import org.onap.so.asdc.installer.IVfModuleData;
import org.onap.so.asdc.installer.ToscaResourceStructure;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
public class ASDCNotificationLogging {
@@ -426,7 +427,27 @@ public class ASDCNotificationLogging {
buffer.append(System.lineSeparator());
buffer.append("Description:");
buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+
+
+ buffer.append(System.lineSeparator());
+ buffer.append("NETWORK Customization Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("CustomizationUUID:");
+ buffer.append(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Technology:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Type:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Role:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Scope:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
+ buffer.append(System.lineSeparator());
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java
index c572097103..e780a259ea 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -21,9 +23,15 @@
package org.onap.so.asdc.installer.bpmn;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import java.io.File;
import java.io.FileInputStream;
@@ -31,9 +39,7 @@ import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-
import javax.transaction.Transactional;
-
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -42,6 +48,7 @@ import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.message.BasicStatusLine;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -49,22 +56,31 @@ import org.junit.rules.TemporaryFolder;
@Transactional
public class BpmnInstallerTest {
-
+
private BpmnInstaller bpmnInstaller = new BpmnInstaller();
-
+
+ private static final String TEST_CSAR = "src/test/resources/resource-examples/WorkflowBpmn/service-CxSvc-csar.csar";
+ private Path tempDirectoryPath;
+
@Rule
- public TemporaryFolder folder= new TemporaryFolder();
+ public TemporaryFolder folder = new TemporaryFolder();
@Before
public void init() throws Exception {
- System.setProperty("mso.config.path", folder.getRoot().toString());
+ System.setProperty("mso.config.path", folder.getRoot().toString());
+ // we need to have this directory created for InstallBPMN test success
+ tempDirectoryPath = Paths.get(folder.getRoot().toString(), "ASDC");
+ Files.createDirectories(tempDirectoryPath);
+ }
+
+ @AfterClass
+ public static void cleanup() {
+ System.clearProperty("mso.config.path");
}
@Test
public void buildMimeMultiPart_Test() throws Exception {
- Path tempDirectoryPath = Paths.get(folder.getRoot().toString(), "ASDC");
Path tempFilePath = Paths.get(tempDirectoryPath.toAbsolutePath().toString(), "TestBB.bpmn");
- Files.createDirectories(tempDirectoryPath);
Files.createFile(tempFilePath);
HttpEntity entity = bpmnInstaller.buildMimeMultipart("TestBB.bpmn");
String mimeMultipartBodyFilePath = "src/test/resources" + "/mime-multipart-body.txt";
@@ -79,11 +95,24 @@ public class BpmnInstallerTest {
@Test
public void installBpmn_Test() throws Exception {
- HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, ""));
- HttpClient httpClient = mock(HttpClient.class);
- String csarPath = "src/test/resources" + "/resource-examples/WorkflowBpmn/service-CxSvc-csar.csar";
- doReturn(response).when(httpClient).execute(any(HttpPost.class));
- bpmnInstaller.installBpmn(csarPath);
+ BpmnInstaller bpmnInstallerSpy = spy(bpmnInstaller);
+ HttpResponse response = new BasicHttpResponse(
+ new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, ""));
+ HttpClient httpClient = mock(HttpClient.class);
+ doReturn(response).when(httpClient).execute(any(HttpPost.class));
+ bpmnInstallerSpy.installBpmn(TEST_CSAR);
+ verify(bpmnInstallerSpy, times(1)).sendDeploymentRequest(anyString());
+ }
+
+ @Test
+ public void containsWorkflowsSuccess() {
+ boolean result = bpmnInstaller.containsWorkflows(TEST_CSAR);
+ assertTrue(result);
+ }
+
+ @Test
+ public void containsWorkflowsFailure() {
+ boolean result = bpmnInstaller.containsWorkflows("DOESNOTEXIST.csar");
+ assertFalse(result);
}
-
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java
index a2e6804a7f..c457a349c2 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java
@@ -28,10 +28,10 @@ import org.onap.so.bpmn.common.BuildingBlockExecution;
public interface FlowValidator {
/**
- * Names of items to be validated
+ * Should this validator run for given bb
* @return
*/
- public Set<String> forItems();
+ public boolean shouldRunFor(String bbName);
/**
* Determines whether or not the workflow should be executed
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java
index 9e6ea53a47..636c8e32cf 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java
@@ -122,7 +122,7 @@ public abstract class FlowValidatorRunner<S extends FlowValidator, E extends Flo
protected List<FlowValidator> filterValidators(List<? extends FlowValidator> validators, String bbName) {
return validators.stream()
.filter(item -> {
- return item.forItems().contains(bbName);
+ return item.shouldRunFor(bbName);
})
.sorted(Comparator.comparing(item -> {
Priority p = Optional.ofNullable(item.getClass().getAnnotation(Priority.class)).orElse(new Priority() {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CloudRegion.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CloudRegion.java
index f39253e6aa..df1eeae1b6 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CloudRegion.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CloudRegion.java
@@ -45,6 +45,8 @@ public class CloudRegion implements Serializable, ShallowCopy<CloudRegion> {
private String complex;
@JsonProperty("cloud-region-version")
private String cloudRegionVersion;
+ @JsonProperty("orchestration-disabled")
+ private Boolean orchestrationDisabled;
public String getLcpCloudRegionId() {
return lcpCloudRegionId;
@@ -88,6 +90,12 @@ public class CloudRegion implements Serializable, ShallowCopy<CloudRegion> {
public void setComplex(String complex) {
this.complex = complex;
}
+ public Boolean getOrchestrationDisabled() {
+ return orchestrationDisabled;
+ }
+ public void setOrchestrationDisabled(Boolean orchestrationDisabled) {
+ this.orchestrationDisabled = orchestrationDisabled;
+ }
@Override
public boolean equals(final Object other) {
if (!(other instanceof CloudRegion)) {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
index fbd709b058..af45a129e2 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
@@ -31,8 +31,8 @@ import org.springframework.stereotype.Component;
public class MyPreValidatorFour implements PreBuildingBlockValidator {
@Override
- public Set<String> forItems() {
- return Collections.singleton("test2");
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test2").contains(bbName);
}
@Override
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
index f642f915b7..d1d50e2a89 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
@@ -31,9 +31,9 @@ import org.springframework.stereotype.Component;
public class MyPreValidatorOne implements PreBuildingBlockValidator {
@Override
- public Set<String> forItems() {
+ public boolean shouldRunFor(String bbName) {
- return Collections.singleton("test");
+ return Collections.singleton("test").contains(bbName);
}
@Override
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
index 780fb43c2a..363020de71 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
@@ -31,8 +31,8 @@ import org.springframework.stereotype.Component;
public class MyPreValidatorThree implements PreBuildingBlockValidator {
@Override
- public Set<String> forItems() {
- return Collections.singleton("test2");
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test2").contains(bbName);
}
@Override
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
index c8ff6ef848..4d78f4e458 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
@@ -34,8 +34,8 @@ import org.springframework.stereotype.Component;
public class MyPreValidatorTwo implements PreBuildingBlockValidator {
@Override
- public Set<String> forItems() {
- return Collections.singleton("test");
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test").contains(bbName);
}
@Override
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java
index bfe3ec06a3..891496fa2b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java
@@ -31,9 +31,9 @@ import org.springframework.stereotype.Component;
public class WorkflowPreValidatorOne implements PreWorkflowValidator {
@Override
- public Set<String> forItems() {
+ public boolean shouldRunFor(String bbName) {
- return Collections.singleton("test");
+ return Collections.singleton("test").contains(bbName);
}
@Override
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java
index ddf5f22f00..80b55df8f5 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java
@@ -34,8 +34,8 @@ import org.springframework.stereotype.Component;
public class WorkflowPreValidatorTwo implements PreWorkflowValidator {
@Override
- public Set<String> forItems() {
- return Collections.singleton("test");
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test").contains(bbName);
}
@Override
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
index 1407cb9211..c5caea5f2f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
@@ -33,4 +33,5 @@ public class ExecutionVariableNames {
public final static String DMAAP_MESSAGE = "dmaapMessage";
public final static String TIMEOUT_FOR_NOTIFICATION = "timeoutForPnfEntryNotification";
public final static String PNF_UUID = "pnfUuid";
+ public final static String SERVICE_INSTANCE_ID = "serviceInstanceId";
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
index c1ddf2e04e..a975339e58 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputs.java
@@ -24,6 +24,7 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
import com.google.common.base.Strings;
@@ -53,6 +54,7 @@ public class PnfCheckInputs implements JavaDelegate {
validateCorrelationId(execution);
validatePnfUuid(execution);
validateTimeout(execution);
+ validateServiceInstanceId(execution);
}
private void validateCorrelationId(DelegateExecution execution) {
@@ -83,4 +85,11 @@ public class PnfCheckInputs implements JavaDelegate {
execution.setVariable(TIMEOUT_FOR_NOTIFICATION, defaultTimeout);
}
}
+
+ private void validateServiceInstanceId(DelegateExecution execution) {
+ String serviceInstanceId = (String) execution.getVariable(SERVICE_INSTANCE_ID);
+ if (Strings.isNullOrEmpty(serviceInstanceId)) {
+ new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "serviceInstanceId variable not defined");
+ }
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
index 1888831e2e..1637b1a97f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID;
import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION;
import java.util.UUID;
@@ -38,71 +39,100 @@ public class PnfCheckInputsTest {
private static final String DEFAULT_TIMEOUT = "P1D";
private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
private static final String RESERVED_UUID = new UUID(0, 0).toString();
+ private static final String DEFAULT_SERVICE_INSTANCE_ID = "da7d07d9-b71c-4128-809d-2ec01c807169";
+ private static final String DEFAULT_CORRELATION_ID = "testCorrelationId";
- private DelegateExecution delegateExecution;
+ private DelegateExecutionBuilder delegateExecutionBuilder;
@Before
public void setUp() {
- delegateExecution = new DelegateExecutionFake();
- delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
+ delegateExecutionBuilder = new DelegateExecutionBuilder();
}
@Test
public void shouldThrowException_whenCorrelationIdNotSet() {
- PnfCheckInputs testedObject = prepareExecutionForCorrelationId(null);
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
+ DelegateExecution execution = delegateExecutionBuilder.setCorrelationId(null).setPnfUuid(VALID_UUID).build();
+ assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(BpmnError.class);
}
@Test
public void shouldThrowException_whenTimeoutIsEmptyStringAndDefaultIsNotDefined() {
- PnfCheckInputs testedObject = prepareExecutionForTimeout(null, "");
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ PnfCheckInputs testedObject = new PnfCheckInputs(null);
+ DelegateExecution execution = delegateExecutionBuilder.setTimeoutForNotification("").build();
+ assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(BpmnError.class);
}
@Test
public void shouldSetDefaultTimeout_whenTimeoutIsNotSet() {
- PnfCheckInputs testedObject = prepareExecutionForTimeout(DEFAULT_TIMEOUT, null);
- testedObject.execute(delegateExecution);
- assertThat(delegateExecution.getVariable(TIMEOUT_FOR_NOTIFICATION)).isEqualTo(DEFAULT_TIMEOUT);
+ PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
+ DelegateExecution execution = delegateExecutionBuilder.setTimeoutForNotification(null).build();
+ testedObject.execute(execution);
+ assertThat(execution.getVariable(TIMEOUT_FOR_NOTIFICATION)).isEqualTo(DEFAULT_TIMEOUT);
}
@Test
public void shouldThrowException_whenPnfUuidIsNotSet() {
- PnfCheckInputs testedObject = prepareExecutionForUuid(null);
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
+ DelegateExecution execution = delegateExecutionBuilder.setPnfUuid(null).build();
+ assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(BpmnError.class);
}
@Test
public void shouldThrowException_whenPnfUuidIsEmptyString() {
- PnfCheckInputs testedObject = prepareExecutionForUuid("");
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
+ PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
+ DelegateExecution execution = delegateExecutionBuilder.setPnfUuid("").build();
+ assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(BpmnError.class);
}
@Test
public void shouldThrowException_whenPnfUuidIsReservedUuid() {
- PnfCheckInputs testedObject = prepareExecutionForUuid(RESERVED_UUID);
- assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
- }
-
- private PnfCheckInputs prepareExecutionForCorrelationId(String correlationId) {
PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
- delegateExecution.setVariable(CORRELATION_ID, correlationId);
- delegateExecution.setVariable(PNF_UUID, VALID_UUID);
- return testedObject;
+ DelegateExecution execution = delegateExecutionBuilder.setPnfUuid(RESERVED_UUID).build();
+ assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(BpmnError.class);
}
- private PnfCheckInputs prepareExecutionForTimeout(String defaultTimeout, String timeout) {
- PnfCheckInputs testedObject = new PnfCheckInputs(defaultTimeout);
- delegateExecution.setVariable(CORRELATION_ID, "testCorrelationId");
- delegateExecution.setVariable(PNF_UUID, VALID_UUID);
- delegateExecution.setVariable(TIMEOUT_FOR_NOTIFICATION, timeout);
- return testedObject;
+ @Test
+ public void shouldThrowException_whenServiceInstanceIdIsNotSet() {
+ PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
+ DelegateExecution execution = delegateExecutionBuilder.setServiceInstanceId(null).build();
+ assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(BpmnError.class);
}
- private PnfCheckInputs prepareExecutionForUuid(String uuid) {
- PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
- delegateExecution.setVariable(CORRELATION_ID, "testCorrelationId");
- delegateExecution.setVariable(PNF_UUID, uuid);
- return testedObject;
+ private static class DelegateExecutionBuilder {
+ private String correlationId = DEFAULT_CORRELATION_ID;
+ private String pnfUuid = VALID_UUID;
+ private String serviceInstanceId = DEFAULT_SERVICE_INSTANCE_ID;
+ private String timeoutForNotification;
+
+ public DelegateExecutionBuilder setCorrelationId(String correlationId) {
+ this.correlationId = correlationId;
+ return this;
+ }
+
+ public DelegateExecutionBuilder setPnfUuid(String pnfUuid) {
+ this.pnfUuid = pnfUuid;
+ return this;
+ }
+
+ public DelegateExecutionBuilder setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ return this;
+ }
+
+ public DelegateExecutionBuilder setTimeoutForNotification(String timeoutForNotification) {
+ this.timeoutForNotification = timeoutForNotification;
+ return this;
+ }
+
+ public DelegateExecution build() {
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable("testProcessKey", "testProcessKeyValue");
+ execution.setVariable(CORRELATION_ID, this.correlationId);
+ execution.setVariable(PNF_UUID, this.pnfUuid);
+ execution.setVariable(SERVICE_INSTANCE_ID, this.serviceInstanceId);
+ execution.setVariable(TIMEOUT_FOR_NOTIFICATION, this.timeoutForNotification);
+ return execution;
+ }
}
}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn
index 3940dece12..c8a5cf03cd 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateVcpeResCustService_simplified.bpmn
@@ -362,6 +362,7 @@ CreateVcpeResCustService.processDecomposition(execution)</bpmn2:script>
<camunda:in source="correlationId" target="correlationId" />
<camunda:in businessKey="#{execution.processBusinessKey}" />
<camunda:in source="pnfUuid" target="pnfUuid" />
+ <camunda:in source="serviceInstanceId" target="serviceInstanceId" />
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_1yojilk</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_0clhseq</bpmn2:outgoing>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java
index 798837fa7d..e0cbb82484 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -21,23 +23,20 @@
package org.onap.so.bpmn.infrastructure.appc.tasks;
import java.util.HashMap;
-import java.util.List;
import java.util.Optional;
-
-import org.camunda.bpm.engine.delegate.BpmnError;
+import org.onap.appc.client.lcm.model.Action;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
-import org.onap.so.db.catalog.client.CatalogDbClient;
-import org.onap.so.db.catalog.beans.ControllerSelectionReference;
+import org.onap.so.client.appc.ApplicationControllerAction;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.exception.ExceptionBuilder;
-import org.onap.appc.client.lcm.model.Action;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
-import org.onap.so.client.appc.ApplicationControllerAction;
+import org.onap.so.db.catalog.beans.ControllerSelectionReference;
+import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -84,13 +83,20 @@ public class AppcRunTasks {
} catch (BBObjectNotFoundException e) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "No valid VNF exists");
}
- String vnfId = vnf.getVnfId();
+ String vnfId = null;
+ String vnfName = null;
+ String vnfType = null;
+ String vnfHostIpAddress = null;
+
+ if (vnf != null) {
+ vnfId = vnf.getVnfId();
+ vnfName = vnf.getVnfName();
+ vnfType = vnf.getVnfType();
+ vnfHostIpAddress = vnf.getIpv4OamAddress();
+ }
String msoRequestId = gBBInput.getRequestContext().getMsoRequestId();
- String vnfName = vnf.getVnfName();
- String vnfType = vnf.getVnfType();
-
+
String aicIdentity = execution.getVariable("aicIdentity");
- String vnfHostIpAddress = vnf.getIpv4OamAddress();
String vmIdList = execution.getVariable("vmIdList");
String vserverIdList = execution.getVariable("vserverIdList");
String identityUrl = execution.getVariable("identityUrl");
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java
new file mode 100644
index 0000000000..7a433c06a6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java
@@ -0,0 +1,48 @@
+package org.onap.so.bpmn.infrastructure.validations;
+
+import java.util.Optional;
+import java.util.regex.Pattern;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.validation.PreBuildingBlockValidator;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CloudRegionOrchestrationValidator implements PreBuildingBlockValidator {
+
+ private static Logger logger = LoggerFactory.getLogger(CloudRegionOrchestrationValidator.class);
+ private final Pattern pattern = Pattern.compile("(?:Activate|Assign|Create|Deactivate|Delete|Unassign|Update)(?:Network|Vnf|VfModule|VolumeGroup|FabricConfiguration)BB");
+
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
+
+ @Override
+ public boolean shouldRunFor(String bbName) {
+ return pattern.matcher(bbName).find();
+ }
+
+ @Override
+ public Optional<String> validate(BuildingBlockExecution execution) {
+ String msg = null;
+ try {
+ CloudRegion cloudRegion = execution.getGeneralBuildingBlock().getCloudRegion();
+ if (Boolean.TRUE.equals(cloudRegion.getOrchestrationDisabled())) {
+ msg = String.format("Error: The request has failed due to orchestration currently disabled for the target cloud region %s for cloud owner %s",
+ cloudRegion.getLcpCloudRegionId(), cloudRegion.getCloudOwner());
+ logger.error(msg);
+ return Optional.ofNullable(msg);
+ }
+ }
+ catch(Exception e) {
+ logger.error("failed to validate", e);
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+ return Optional.empty();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 99bda80e4f..8a3a778b06 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -1050,9 +1050,11 @@ public class WorkflowAction {
executeBuildingBlock.setRequestDetails(requestDetails);
if(isConfiguration){
ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys();
- configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
- configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
- configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
+ if (resource != null){
+ configurationResourceKeys.setCvnfcCustomizationUUID(resource.getCvnfModuleCustomizationId());
+ configurationResourceKeys.setVfModuleCustomizationUUID(resource.getVfModuleCustomizationId());
+ configurationResourceKeys.setVnfResourceCustomizationUUID(resource.getVnfCustomizationId());
+ }
executeBuildingBlock.setConfigurationResourceKeys(configurationResourceKeys);
}
return executeBuildingBlock;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java
index 114066aae3..7495cc1e8d 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasksTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
@@ -20,19 +22,32 @@
package org.onap.so.bpmn.infrastructure.appc.tasks;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
+import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import org.junit.Test;
+import org.mockito.InjectMocks;
import org.onap.appc.client.lcm.model.Action;
+import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.db.catalog.beans.ControllerSelectionReference;
-public class AppcRunTasksTest {
+public class AppcRunTasksTest extends BaseTaskTest {
-
+ @InjectMocks
private AppcRunTasks appcRunTasks = new AppcRunTasks();
+
@Test
public void mapRollbackVariablesTest() {
@@ -53,4 +68,101 @@ public class AppcRunTasksTest {
appcRunTasks.mapRollbackVariables(mock, Action.ResumeTraffic, "0");
verify(mock, times(1)).setVariable("rollbackQuiesceTraffic", false);
}
+
+ @Test
+ public void runAppcCommandVnfNull() throws BBObjectNotFoundException {
+ execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "NULL-TEST");
+ fillRequiredAppcExecutionFields();
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID), eq("NULL-TEST")))
+ .thenReturn(null);
+ when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(
+ isNull(), eq(Action.Lock.toString()))).
+ thenThrow(new IllegalArgumentException("name or values is null"));
+
+ appcRunTasks.runAppcCommand(execution, Action.Lock);
+
+ // if vnf = null -> vnfType = null ->
+ // IllegalArgumentException will be thrown in catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory
+ verify(exceptionUtil, times(1)).
+ buildAndThrowWorkflowException(
+ any(BuildingBlockExecution.class), eq(1002), eq("name or values is null"));
+ }
+
+ @Test
+ public void runAppcCommandBBObjectNotFoundException() throws BBObjectNotFoundException {
+ execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "EXCEPTION-TEST");
+ fillRequiredAppcExecutionFields();
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID), eq("EXCEPTION-TEST")))
+ .thenThrow(new BBObjectNotFoundException());
+
+ appcRunTasks.runAppcCommand(execution, Action.Lock);
+
+ verify(exceptionUtil, times(1)).
+ buildAndThrowWorkflowException(
+ any(BuildingBlockExecution.class), eq(7000), eq("No valid VNF exists"));
+ }
+
+ @Test
+ public void runAppcCommandVfModuleNull() throws BBObjectNotFoundException {
+ execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "SUCCESS-TEST");
+ fillRequiredAppcExecutionFields();
+ GenericVnf genericVnf = getTestGenericVnf();
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID), eq("SUCCESS-TEST")))
+ .thenReturn(genericVnf);
+ mockReferenceResponse();
+ execution.getLookupMap().put(ResourceKey.VF_MODULE_ID, "VF-MODULE-ID-TEST");
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID), eq("VF-MODULE-ID-TEST")))
+ .thenReturn(null);
+ when(appCClient.getErrorCode()).thenReturn("0");
+
+ appcRunTasks.runAppcCommand(execution, Action.Lock);
+
+ assertEquals(true, execution.getVariable("rollbackVnfLock"));
+ }
+
+ @Test
+ public void runAppcCommand() throws BBObjectNotFoundException {
+ execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "SUCCESS-TEST");
+ fillRequiredAppcExecutionFields();
+ GenericVnf genericVnf = getTestGenericVnf();
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID), eq("SUCCESS-TEST")))
+ .thenReturn(genericVnf);
+ mockReferenceResponse();
+ execution.getLookupMap().put(ResourceKey.VF_MODULE_ID, "VF-MODULE-ID-TEST");
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("VF-MODULE-ID");
+ when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID), eq("VF-MODULE-ID-TEST")))
+ .thenReturn(vfModule);
+ when(appCClient.getErrorCode()).thenReturn("0");
+
+ appcRunTasks.runAppcCommand(execution, Action.Lock);
+
+ assertEquals(true, execution.getVariable("rollbackVnfLock"));
+ }
+
+ private void mockReferenceResponse() {
+ ControllerSelectionReference reference = new ControllerSelectionReference();
+ reference.setControllerName("TEST-CONTROLLER-NAME");
+ when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(
+ eq("TEST-VNF-TYPE"), eq(Action.Lock.toString()))).thenReturn(reference);
+ }
+
+ private void fillRequiredAppcExecutionFields() {
+ RequestContext context = new RequestContext();
+ context.setMsoRequestId("TEST-MSO-ID");
+ execution.setVariable("aicIdentity", "AIC-TEST");
+ execution.setVariable("vmIdList", "VM-ID-LIST-TEST");
+ execution.setVariable("vserverIdList", "VSERVER-ID-LIST");
+ execution.setVariable("identityUrl", "IDENTITY-URL-TEST");
+ execution.getGeneralBuildingBlock().setRequestContext(context);
+ }
+
+ private GenericVnf getTestGenericVnf() {
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("TEST-VNF-ID");
+ genericVnf.setVnfType("TEST-VNF-TYPE");
+ genericVnf.setVnfName("TEST-VNF-NAME");
+ genericVnf.setIpv4OamAddress("129.0.0.1");
+ return genericVnf;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java
new file mode 100644
index 0000000000..f6988fdcd4
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidatorTest.java
@@ -0,0 +1,97 @@
+package org.onap.so.bpmn.infrastructure.validations;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import java.util.Optional;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+
+public class CloudRegionOrchestrationValidatorTest {
+
+ private BuildingBlockExecution mockExecution;
+ private CloudRegion cloudRegion;
+
+ @Before
+ public void setUp() {
+ cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("CloudOwner");
+ cloudRegion.setLcpCloudRegionId("my-region-id");
+ GeneralBuildingBlock gbb = new GeneralBuildingBlock();
+ gbb.setCloudRegion(cloudRegion);
+ mockExecution = mock(BuildingBlockExecution.class);
+ doReturn(gbb).when(mockExecution).getGeneralBuildingBlock();
+ }
+
+ @Test
+ public void validateDisabledTest() {
+ cloudRegion.setOrchestrationDisabled(true);
+ CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
+ Optional<String> result = validation.validate(mockExecution);
+ assertEquals("Error: The request has failed due to orchestration currently disabled for the target cloud region my-region-id for cloud owner CloudOwner",
+ result.get());
+ }
+
+ @Test
+ public void validateNotDisabledTest() {
+ cloudRegion.setOrchestrationDisabled(false);
+ CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
+ Optional<String> result = validation.validate(mockExecution);
+ assertFalse(result.isPresent());
+ }
+
+ @Test
+ public void validateDisabledIsNullTest() {
+ CloudRegionOrchestrationValidator validation = new CloudRegionOrchestrationValidator();
+ Optional<String> result = validation.validate(mockExecution);
+ assertFalse(result.isPresent());
+ }
+
+ @Test
+ public void shouldRunForTest() {
+ CloudRegionOrchestrationValidator validator = new CloudRegionOrchestrationValidator();
+ assertTrue(validator.shouldRunFor("ActivateNetworkBB"));
+ assertTrue(validator.shouldRunFor("AssignNetworkBB"));
+ assertTrue(validator.shouldRunFor("CreateNetworkBB"));
+ assertTrue(validator.shouldRunFor("DeactivateNetworkBB"));
+ assertTrue(validator.shouldRunFor("DeleteNetworkBB"));
+ assertTrue(validator.shouldRunFor("UnassignNetworkBB"));
+ assertTrue(validator.shouldRunFor("UpdateNetworkBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateVnfBB"));
+ assertTrue(validator.shouldRunFor("AssignVnfBB"));
+ assertTrue(validator.shouldRunFor("UnassignVnfBB"));
+ assertTrue(validator.shouldRunFor("DeactivateVnfBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateVfModuleBB"));
+ assertTrue(validator.shouldRunFor("AssignVfModuleBB"));
+ assertTrue(validator.shouldRunFor("CreateVfModuleBB"));
+ assertTrue(validator.shouldRunFor("DeactivateVfModuleBB"));
+ assertTrue(validator.shouldRunFor("DeleteVfModuleBB"));
+ assertTrue(validator.shouldRunFor("UnassignVfModuleBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("AssignVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("CreateVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("DeactivateVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("DeleteVolumeGroupBB"));
+ assertTrue(validator.shouldRunFor("UnassignVolumeGroupBB"));
+
+ assertTrue(validator.shouldRunFor("ActivateFabricConfigurationBB"));
+ assertTrue(validator.shouldRunFor("AssignFabricConfigurationBB"));
+ assertTrue(validator.shouldRunFor("UnassignFabricConfigurationBB"));
+ assertTrue(validator.shouldRunFor("DeactivateFabricConfigurationBB"));
+
+ assertFalse(validator.shouldRunFor("AssignServiceInstanceBB"));
+ assertFalse(validator.shouldRunFor("AAICheckVnfInMaintBB"));
+ assertFalse(validator.shouldRunFor("ChangeModelVfModuleBB"));
+ assertFalse(validator.shouldRunFor("CreateNetworkCollectionBB"));
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index c74f590e6b..93d4b413f8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -24,10 +24,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.isA;
@@ -1329,6 +1326,19 @@ public class WorkflowActionTest extends BaseTaskTest {
execution.getVariable("WorkflowActionErrorMessage"));
}
+ @Test
+ public void verifyLackOfNullPointerExceptionForNullResource(){
+ ExecuteBuildingBlock result = null;
+ try {
+ result = workflowAction
+ .buildExecuteBuildingBlock(new OrchestrationFlow(), null, null, null, null, null, false,
+ null, null, null, false, null, true);
+ }catch (NullPointerException e){
+ fail("NullPointerException should not be thrown when 'resource' is null");
+ }
+ assertNotNull(result);
+ }
+
private List<OrchestrationFlow> createFlowList (String... flowNames){
List<OrchestrationFlow> result = new ArrayList<>();
for(String flowName : flowNames){
diff --git a/common/pom.xml b/common/pom.xml
index 51c9ed3bcb..6bd142ddb2 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -47,9 +47,9 @@
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
- <groupId>org.onap.aai.aai-common</groupId>
+ <groupId>org.onap.aai.schema-service</groupId>
<artifactId>aai-schema</artifactId>
- <version>1.4.1-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
index a2651195ee..30d1b040e2 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
@@ -27,20 +27,17 @@ import java.util.Optional;
import javax.ws.rs.core.Response;
import org.onap.so.client.ResponseExceptionMapper;
-import org.onap.so.client.RestClientSSL;
import org.onap.so.client.graphinventory.GraphInventoryPatchConverter;
+import org.onap.so.client.graphinventory.GraphInventoryRestClient;
import org.onap.so.client.policy.CommonObjectMapperProvider;
import org.onap.so.utils.TargetEntity;
-public class AAIRestClient extends RestClientSSL {
+public class AAIRestClient extends GraphInventoryRestClient {
private final AAIProperties aaiProperties;
- private static final AAICommonObjectMapperProvider standardProvider = new AAICommonObjectMapperProvider();
- private final GraphInventoryPatchConverter patchConverter = new GraphInventoryPatchConverter();
-
protected AAIRestClient(AAIProperties props, URI uri) {
- super(props, Optional.of(uri));
+ super(props, uri);
this.aaiProperties = props;
}
@@ -67,27 +64,8 @@ public class AAIRestClient extends RestClientSSL {
return Optional.of(new AAIClientResponseExceptionMapper());
}
- @Override
- protected CommonObjectMapperProvider getCommonObjectMapperProvider() {
- return standardProvider;
- }
-
- @Override
- public Response patch(Object obj) {
- return super.patch(convertToPatchFormat(obj));
- }
-
- @Override
- public <T> T patch(Object obj, Class<T> resultClass) {
- return super.patch(convertToPatchFormat(obj), resultClass);
- }
-
protected GraphInventoryPatchConverter getPatchConverter() {
return this.patchConverter;
}
-
- protected String convertToPatchFormat(Object obj) {
- return getPatchConverter().convertPatchFormat(obj);
- }
}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
index 9b3f98baa4..5ce81ce879 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
@@ -26,7 +26,7 @@ import org.onap.so.client.graphinventory.entities.GraphInventoryResultWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class AAIResultWrapper extends GraphInventoryResultWrapper implements Serializable {
+public class AAIResultWrapper extends GraphInventoryResultWrapper<Relationships> implements Serializable {
private static final long serialVersionUID = 5895841925807816737L;
private final static transient Logger logger = LoggerFactory.getLogger(AAIResultWrapper.class);
@@ -38,4 +38,9 @@ public class AAIResultWrapper extends GraphInventoryResultWrapper implements Ser
public AAIResultWrapper(Object aaiObject) {
super(aaiObject, logger);
}
+
+ @Override
+ protected Relationships createRelationships(String json) {
+ return new Relationships(json);
+ }
}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
index e907bc97d7..61a2f4b8fa 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
@@ -20,117 +20,55 @@
package org.onap.so.client.aai.entities;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.function.Predicate;
import javax.ws.rs.core.UriBuilder;
-import org.onap.so.client.aai.AAICommonObjectMapperProvider;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.GraphInventoryObjectName;
-import org.onap.so.jsonpath.JsonPathUtil;
+import org.onap.so.client.graphinventory.entities.GraphInventoryRelationships;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.base.CaseFormat;
+public class Relationships extends GraphInventoryRelationships<AAIResultWrapper, AAIResourceUri, AAIObjectType>{
-public class Relationships {
-
- private final ObjectMapper mapper;
- private Map<String, Object> map;
- private final String jsonBody;
public Relationships(String json) {
- this.jsonBody = json;
- this.mapper = new AAICommonObjectMapperProvider().getMapper();
- try {
- this.map = mapper.readValue(json, new TypeReference<Map<String, Object>>() {});
- } catch (IOException e) {
- this.map = new HashMap<>();
- }
- }
-
- public List<AAIResultWrapper> getByType(GraphInventoryObjectName type) {
-
- return this.getAll(Optional.of(type));
- }
-
- public List<AAIResultWrapper> getAll() {
-
- return this.getAll(Optional.empty());
- }
-
-
- public List<String> getRelatedLinks() {
- return this.getRelatedLinks(Optional.empty());
- }
-
- public List<String> getRelatedLinks(GraphInventoryObjectName type) {
- return this.getRelatedLinks(Optional.of(type));
+ super(json);
}
+ @Deprecated
+ /**
+ * Use getRelatedUris instead
+ * @return
+ */
public List<AAIResourceUri> getRelatedAAIUris() {
- return this.getRelatedAAIUris(x -> true);
+ return this.getRelatedUris();
}
+ @Deprecated
+ /**
+ * Use getRelatedUris instead
+ * @return
+ */
public List<AAIResourceUri> getRelatedAAIUris(GraphInventoryObjectName type) {
- return this.getRelatedAAIUris(x -> type.typeName().equals(x));
- }
- protected List<AAIResourceUri> getRelatedAAIUris(Predicate<String> p) {
- List<AAIResourceUri> result = new ArrayList<>();
- if (map.containsKey("relationship")) {
- List<Map<String, Object>> relationships = (List<Map<String, Object>>)map.get("relationship");
- for (Map<String, Object> relationship : relationships) {
- final String relatedTo = (String)relationship.get("related-to");
- if (p.test(relatedTo)) {
- AAIObjectType type;
- type = AAIObjectType.fromTypeName(relatedTo);
- final String relatedLink = (String)relationship.get("related-link");
-
- result.add(AAIUriFactory.createResourceFromExistingURI(type, UriBuilder.fromPath(relatedLink).build()));
- }
- }
- }
- return result;
+ return this.getRelatedUris(type);
}
-
- protected List<AAIResultWrapper> getAll(final Optional<GraphInventoryObjectName> type) {
- List<AAIResourceUri> relatedLinks;
- if (type.isPresent()) {
- relatedLinks = this.getRelatedAAIUris(type.get());
- } else {
- relatedLinks = this.getRelatedAAIUris();
- }
- ArrayList<AAIResultWrapper> result = new ArrayList<>();
- for (AAIResourceUri link : relatedLinks) {
- result.add(this.get(link));
- }
- return result;
- }
-
protected AAIResultWrapper get(AAIResourceUri uri) {
return new AAIResourcesClient().get(uri);
}
-
- protected List<String> getRelatedLinks(Optional<GraphInventoryObjectName> type) {
- String matcher = "";
- if (type.isPresent()) {
- matcher = "[?(@.related-to=='" + type.get() + "')]";
- }
- return JsonPathUtil.getInstance().locateResultList(this.jsonBody, String.format("$.relationship%s.related-link", matcher));
+
+ @Override
+ protected AAIResourceUri createUri(AAIObjectType type, String relatedLink) {
+
+ return AAIUriFactory.createResourceFromExistingURI(type, UriBuilder.fromPath(relatedLink).build());
}
-
- public String getJson() {
- return this.jsonBody;
+
+ @Override
+ protected AAIObjectType fromTypeName(String name) {
+ return AAIObjectType.fromTypeName(name);
}
}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryRestClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryRestClient.java
new file mode 100644
index 0000000000..10c06634dc
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryRestClient.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.graphinventory;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Optional;
+
+import javax.ws.rs.core.Response;
+
+import org.onap.so.client.ResponseExceptionMapper;
+import org.onap.so.client.RestClientSSL;
+import org.onap.so.client.RestProperties;
+import org.onap.so.client.policy.CommonObjectMapperProvider;
+import org.onap.so.utils.TargetEntity;
+
+public abstract class GraphInventoryRestClient extends RestClientSSL {
+
+ protected static final GraphInventoryCommonObjectMapperProvider standardProvider = new GraphInventoryCommonObjectMapperProvider();
+
+ protected final GraphInventoryPatchConverter patchConverter = new GraphInventoryPatchConverter();
+
+ protected GraphInventoryRestClient(RestProperties props, URI uri) {
+ super(props, Optional.of(uri));
+ }
+
+ @Override
+ public abstract TargetEntity getTargetEntity();
+
+ @Override
+ protected abstract void initializeHeaderMap(Map<String, String> headerMap);
+
+ @Override
+ protected abstract Optional<ResponseExceptionMapper> addResponseExceptionMapper();
+
+ @Override
+ protected CommonObjectMapperProvider getCommonObjectMapperProvider() {
+ return standardProvider;
+ }
+
+ @Override
+ public Response patch(Object obj) {
+ return super.patch(convertToPatchFormat(obj));
+ }
+
+ @Override
+ public <T> T patch(Object obj, Class<T> resultClass) {
+ return super.patch(convertToPatchFormat(obj), resultClass);
+ }
+
+ protected GraphInventoryPatchConverter getPatchConverter() {
+ return this.patchConverter;
+ }
+
+ protected String convertToPatchFormat(Object obj) {
+ return getPatchConverter().convertPatchFormat(obj);
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryRelationships.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryRelationships.java
new file mode 100644
index 0000000000..759fad7e54
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryRelationships.java
@@ -0,0 +1,137 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.client.graphinventory.entities;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Predicate;
+
+import org.onap.so.client.aai.AAICommonObjectMapperProvider;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.so.client.graphinventory.GraphInventoryObjectName;
+import org.onap.so.client.graphinventory.GraphInventoryObjectType;
+import org.onap.so.client.graphinventory.entities.uri.GraphInventoryResourceUri;
+import org.onap.so.jsonpath.JsonPathUtil;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public abstract class GraphInventoryRelationships<Wrapper extends GraphInventoryResultWrapper, Uri extends GraphInventoryResourceUri, Type extends GraphInventoryObjectType> {
+
+ protected final ObjectMapper mapper;
+ protected Map<String, Object> map;
+ protected final String jsonBody;
+
+ public GraphInventoryRelationships(String json) {
+ this.jsonBody = json;
+ this.mapper = new GraphInventoryCommonObjectMapperProvider().getMapper();
+ try {
+ this.map = mapper.readValue(json, new TypeReference<Map<String, Object>>() {});
+ } catch (IOException e) {
+ this.map = new HashMap<>();
+ }
+ }
+
+ public List<Wrapper> getByType(GraphInventoryObjectName type) {
+
+ return this.getAll(Optional.of(type));
+ }
+
+ public List<Wrapper> getAll() {
+
+ return this.getAll(Optional.empty());
+ }
+
+
+ public List<String> getRelatedLinks() {
+ return this.getRelatedLinks(Optional.empty());
+ }
+
+ public List<String> getRelatedLinks(GraphInventoryObjectName type) {
+ return this.getRelatedLinks(Optional.of(type));
+ }
+
+ public List<Uri> getRelatedUris() {
+ return this.getRelatedUris(x -> true);
+ }
+
+ public List<Uri> getRelatedUris(GraphInventoryObjectName type) {
+ return this.getRelatedUris(x -> type.typeName().equals(x));
+ }
+ protected List<Uri> getRelatedUris(Predicate<String> p) {
+ List<Uri> result = new ArrayList<>();
+ if (map.containsKey("relationship")) {
+ List<Map<String, Object>> relationships = (List<Map<String, Object>>)map.get("relationship");
+ for (Map<String, Object> relationship : relationships) {
+ final String relatedTo = (String)relationship.get("related-to");
+ if (p.test(relatedTo)) {
+ Type type;
+ type = fromTypeName(relatedTo);
+ final String relatedLink = (String)relationship.get("related-link");
+
+ result.add(createUri(type, relatedLink));
+ }
+ }
+ }
+ return result;
+ }
+
+
+
+ protected List<Wrapper> getAll(final Optional<GraphInventoryObjectName> type) {
+ List<Uri> relatedLinks;
+ if (type.isPresent()) {
+ relatedLinks = this.getRelatedUris(type.get());
+ } else {
+ relatedLinks = this.getRelatedUris();
+ }
+ ArrayList<Wrapper> result = new ArrayList<>();
+ for (Uri link : relatedLinks) {
+ result.add(this.get(link));
+ }
+ return result;
+ }
+
+ protected abstract Wrapper get(Uri uri);
+
+ protected abstract Uri createUri(Type type, String relatedLink);
+
+ protected abstract Type fromTypeName(String name);
+
+ protected List<String> getRelatedLinks(Optional<GraphInventoryObjectName> type) {
+ String matcher = "";
+ if (type.isPresent()) {
+ matcher = "[?(@.related-to=='" + type.get() + "')]";
+ }
+ return JsonPathUtil.getInstance().locateResultList(this.jsonBody, String.format("$.relationship%s.related-link", matcher));
+ }
+
+ public String getJson() {
+ return this.jsonBody;
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java
index 2f71358f04..c5651c0d26 100644
--- a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java
@@ -28,17 +28,15 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
-import org.onap.so.client.aai.AAICommonObjectMapperProvider;
-import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.jsonpath.JsonPathUtil;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class GraphInventoryResultWrapper implements Serializable {
+public abstract class GraphInventoryResultWrapper<R extends GraphInventoryRelationships<?, ?, ?>> implements Serializable {
private static final long serialVersionUID = 5895841925807816727L;
protected final String jsonBody;
@@ -47,12 +45,12 @@ public class GraphInventoryResultWrapper implements Serializable {
protected GraphInventoryResultWrapper(String json, Logger logger) {
this.jsonBody = json;
- this.mapper = new AAICommonObjectMapperProvider().getMapper();
+ this.mapper = new GraphInventoryCommonObjectMapperProvider().getMapper();
this.logger = logger;
}
protected GraphInventoryResultWrapper(Object aaiObject, Logger logger) {
- this.mapper = new AAICommonObjectMapperProvider().getMapper();
+ this.mapper = new GraphInventoryCommonObjectMapperProvider().getMapper();
this.jsonBody = mapObjectToString(aaiObject);
this.logger = logger;
}
@@ -65,18 +63,19 @@ public class GraphInventoryResultWrapper implements Serializable {
return "{}";
}
}
- public Optional<Relationships> getRelationships() {
+ public Optional<R> getRelationships() {
final String path = "$.relationship-list";
if (isEmpty()) {
return Optional.empty();
}
Optional<String> result = JsonPathUtil.getInstance().locateResult(jsonBody, path);
if (result.isPresent()) {
- return Optional.of(new Relationships(result.get()));
+ return Optional.of(createRelationships(result.get()));
} else {
return Optional.empty();
}
}
+ protected abstract R createRelationships(String json);
public String getJson() {
if(jsonBody == null) {
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java
index dc4179a86f..1b8844116a 100644
--- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java
@@ -33,7 +33,6 @@ import java.util.Set;
import javax.ws.rs.core.UriBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.onap.so.client.aai.entities.uri.AAIUri;
import org.onap.so.client.graphinventory.Format;
import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals;
import org.onap.so.client.graphinventory.GraphInventoryObjectType;
@@ -212,8 +211,8 @@ public class SimpleUri implements GraphInventoryResourceUri, Serializable {
@Override
public boolean equals(Object o) {
- if (o instanceof AAIUri) {
- return this.build().equals(((AAIUri)o).build());
+ if (o instanceof GraphInventoryUri) {
+ return this.build().equals(((GraphInventoryUri)o).build());
}
return false;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 312db9a338..e3b218b90a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -110,6 +110,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
+import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.net.URL;
import java.security.GeneralSecurityException;
@@ -1178,7 +1179,7 @@ public class ServiceInstances {
String requestId = duplicateRecord.getRequestId();
String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
String targetUrl = env.getProperty("mso.camundaURL") + path;
- HttpHeaders headers = setHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
+ HttpHeaders headers = setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
try{
@@ -1202,7 +1203,7 @@ public class ServiceInstances {
}
return false;
}
- private HttpHeaders setHeaders(String auth, String msoKey) {
+ protected HttpHeaders setCamundaHeaders(String auth, String msoKey) {
HttpHeaders headers = new HttpHeaders();
List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>();
acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON);
@@ -1210,7 +1211,7 @@ public class ServiceInstances {
try {
String userCredentials = CryptoUtils.decrypt(auth, msoKey);
if(userCredentials != null) {
- headers.add(HttpHeaders.AUTHORIZATION, userCredentials);
+ headers.add(HttpHeaders.AUTHORIZATION, "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()));
}
} catch(GeneralSecurityException e) {
msoLogger.error("Security exception", e);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index 5603ee8380..83b5a49e8c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -2620,4 +2620,16 @@ public class ServiceInstancesTest extends BaseTest{
String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
assertEquals(serviceType, "networkModelName");
}
+ @Test
+ public void setCamundaHeadersTest()throws ContactCamundaException, RequestDbFailureException{
+ String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password
+ String key = "07a7159d3bf51a0e53be7a8f89699be7";
+ HttpHeaders headers = servInstances.setCamundaHeaders(encryptedAuth, key);
+ List<org.springframework.http.MediaType> acceptedType = headers.getAccept();
+ String expectedAcceptedType = "application/json";
+ assertEquals(expectedAcceptedType, acceptedType.get(0).toString());
+ String basicAuth = headers.getFirst(HttpHeaders.AUTHORIZATION);
+ String expectedBasicAuth = "Basic dXNlcjpwYXNzd29yZA==";
+ assertEquals(expectedBasicAuth, basicAuth);
+ }
}