summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnParam.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClient.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/resource/ResourceRequestBuilder.java7
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/appc/payload/PayloadClientTest.java81
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/util/CryptoHandlerTest.java42
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java83
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy69
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy32
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy4
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy10
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy5
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/PnfReadyEventHandler.java28
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java12
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java3
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumer.java96
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java23
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java13
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/resources/dmaap.properties7
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/resources/processengine.properties20
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn3
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml14
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/web.xml10
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java11
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumerTest.java68
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/test/resources/dmaapTest.properties7
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/test/resources/springConfig_PnfEventReadyConsumer.xml19
-rw-r--r--common/src/main/java/org/openecomp/mso/client/sdno/dmaap/PnfReadyEventConsumer.java93
-rw-r--r--common/src/test/java/org/openecomp/mso/client/dmaap/PnfReadyEventConsumerTest.java85
28 files changed, 543 insertions, 306 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnParam.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnParam.java
index f4ebd0615a..4b58b51560 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnParam.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnParam.java
@@ -41,7 +41,7 @@ public class BpmnParam {
return value;
}
- @JsonProperty("type")
+ @JsonProperty("value")
public void setValue(String value) {
this.value = value;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClient.java
index e43af18ceb..016afa8537 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClient.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClient.java
@@ -181,6 +181,7 @@ public class BpmnRestClient {
requestIdInput.setValue(requestId);
requestActionInput.setValue(requestAction);
serviceInstanceIdInput.setValue(serviceInstanceId);
+ serviceTypeInput.setValue(serviceType);
recipeParamsInput.setValue(recipeParams);
resourceInput.setValue(requestDetails);
recipeRequest.setHost(host);
@@ -189,6 +190,7 @@ public class BpmnRestClient {
recipeRequest.setServiceInstanceId(serviceInstanceIdInput);
recipeRequest.setServiceType(serviceTypeInput);
recipeRequest.setRecipeParams(recipeParamsInput);
+ recipeRequest.setResourceInput(resourceInput);
jsonReq = recipeRequest.toString();
msoLogger.debug("request body is " + jsonReq);
} catch(Exception e) {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/resource/ResourceRequestBuilder.java
index 36585717fa..74a3252768 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/resource/ResourceRequestBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/resource/ResourceRequestBuilder.java
@@ -55,7 +55,7 @@ public class ResourceRequestBuilder {
public static String CUSTOMIZATION_UUID = "customizationUUID";
- public static String SERVICE_URL_TOSCA_CSAR = "http://localhost:8080/ecomp/mso/catalog/v3/serviceToscaCsar?serviceModelUuid=";
+ public static String SERVICE_URL_TOSCA_CSAR = "http://mso:8080/ecomp/mso/catalog/v3/serviceToscaCsar?serviceModelUuid=";
private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
@@ -69,9 +69,10 @@ public class ResourceRequestBuilder {
* "requestInputs":{K,V}
* }
* <br>
- *
+ *
+ * @param execution Execution context
* @param serviceUuid The service template uuid
- * @param resourceucstomizationUuid The resource customization uuid
+ * @param resourceCustomizationUuid The resource customization uuid
* @param serviceParameters the service parameters passed from the API
* @return the resource instantiate parameters
* @since ONAP Beijing Release
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/appc/payload/PayloadClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/appc/payload/PayloadClientTest.java
new file mode 100644
index 0000000000..95af260ac6
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/appc/payload/PayloadClientTest.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 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.openecomp.mso.bpmn.appc.payload;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Optional;
+
+import org.json.JSONObject;
+import org.junit.Test;
+
+public class PayloadClientTest {
+
+ @Test
+ public void upgradeFormatTest() throws Exception {
+ String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"existing-software-version\":\"existingVersion\",\"new-software-version\":\"newVersion\"}}";
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("existing-software-version", "existingVersion");
+ jsonObject.put("new-software-version", "newVersion");
+ Optional<String> payload = Optional.of(jsonObject.toString());
+ Optional<String> payloadClient = PayloadClient.upgradeFormat(payload, "vnfName1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+ @Test
+ public void resumeTrafficFormatTest() throws Exception {
+ String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\"}}";
+ Optional<String> payloadClient = PayloadClient.resumeTrafficFormat("vnfName1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+ @Test
+ public void quiesceTrafficFormatTest() throws Exception {
+ String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"operations_timeout\":\"operationTimeout\"}}";
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("operations-timeout", "operationTimeout");
+ Optional<String> payload = Optional.of(jsonObject.toString());
+ Optional<String> payloadClient = PayloadClient.quiesceTrafficFormat(payload, "vnfName1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+ @Test
+ public void startStopFormatTest() throws Exception {
+ String payloadResult = "{\" AICIdentity \":\"aicIdentity1\"}";
+ Optional<String> payloadClient = PayloadClient.startStopFormat("aicIdentity1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+ @Test
+ public void healthCheckFormatTest() throws Exception {
+ String payloadResult = "{\"request-parameters\":{\"vnf-name\":\"vnfName1\"},\"configuration-parameters\":{\"vnf_name\":\"vnfName1\"}}";
+ Optional<String> payloadClient = PayloadClient.healthCheckFormat("vnfName1", "vnfHostIpAddress1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+ @Test
+ public void snapshotFormatTest() throws Exception {
+ String payloadResult = "{\"vm-id\":\"vmId1\",\"identity-url\":\"identityUrl1\"}";
+ Optional<String> payloadClient = PayloadClient.snapshotFormat("vmId1", "identityUrl1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/util/CryptoHandlerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/util/CryptoHandlerTest.java
new file mode 100644
index 0000000000..724d3edf4d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/util/CryptoHandlerTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 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.openecomp.mso.bpmn.common.util;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class CryptoHandlerTest {
+
+ @Test
+ public void test() throws Exception {
+ String plainPswd = "mso0206";
+ String encryptPwd = "C1FC4A39E16419DD41DFC1212843F440";
+ CryptoHandler cryptoHandler = new CryptoHandler();
+ String aaiPassword = cryptoHandler.getMsoAaiPassword();
+ assertEquals(plainPswd, aaiPassword);
+ String encryptPassword = cryptoHandler.encryptMsoPassword(plainPswd);
+ assertEquals(encryptPwd, encryptPassword);
+ String decryptPassword = cryptoHandler.decryptMsoPassword(encryptPwd);
+ assertEquals(plainPswd, decryptPassword);
+ }
+
+} \ No newline at end of file
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java
new file mode 100644
index 0000000000..90cb7362cf
--- /dev/null
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/openecomp/mso/bpmn/core/domain/CompareModelsResultTest.java
@@ -0,0 +1,83 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : SO
+* ================================================================================
+* Copyright (C) 2018 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.openecomp.mso.bpmn.core.domain;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class CompareModelsResultTest {
+
+ private CompareModelsResult modelsResult;
+ private List<ResourceModelInfo> addedResourceList;
+ private List<ResourceModelInfo> deletedResourceList;
+ private ResourceModelInfo resourceModelInfo1;
+ private ResourceModelInfo resourceModelInfo2;
+ private List<String> requestInputs;
+
+ @Before
+ public void before() {
+ resourceModelInfo1 = new ResourceModelInfo();
+ resourceModelInfo1.setResourceCustomizationUuid("f1d563e8-e714-4393-8f99-cc480144a05e");
+ resourceModelInfo1.setResourceInvariantUuid("e1d563e8-e714-4393-8f99-cc480144a05f");
+ resourceModelInfo1.setResourceName("resourceName1");
+ resourceModelInfo1.setResourceUuid("f1d563e8-e714-4393-8f99-cc480144a05g");
+ resourceModelInfo2 = new ResourceModelInfo();
+ resourceModelInfo2.setResourceCustomizationUuid("a1d563e8-e714-4393-8f99-cc480144a05d");
+ resourceModelInfo2.setResourceInvariantUuid("b1d563e8-e714-4393-8f99-cc480144a05e");
+ resourceModelInfo2.setResourceName("resourceName2");
+ resourceModelInfo2.setResourceUuid("c1d563e8-e714-4393-8f99-cc480144a05f");
+ }
+
+ @Test
+ public void testSetAddedResourceList() {
+ addedResourceList = new ArrayList<ResourceModelInfo>();
+ addedResourceList.add(resourceModelInfo1);
+ addedResourceList.add(resourceModelInfo2);
+ modelsResult = new CompareModelsResult();
+ modelsResult.setAddedResourceList(addedResourceList);
+ assertEquals(addedResourceList, modelsResult.getAddedResourceList());
+ }
+
+ @Test
+ public void testSetDeletedResourceList() {
+ deletedResourceList = new ArrayList<ResourceModelInfo>();
+ deletedResourceList.add(resourceModelInfo1);
+ deletedResourceList.add(resourceModelInfo2);
+ modelsResult = new CompareModelsResult();
+ modelsResult.setDeletedResourceList(deletedResourceList);
+ assertEquals(deletedResourceList, modelsResult.getDeletedResourceList());
+ }
+
+ @Test
+ public void testSetRequestInputs() {
+ requestInputs = new ArrayList<String>();
+ requestInputs.add("requestInput1");
+ requestInputs.add("requestInput2");
+ modelsResult = new CompareModelsResult();
+ modelsResult.setRequestInputs(requestInputs);
+ assertEquals(requestInputs, modelsResult.getRequestInputs());
+ }
+
+}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy
index c70c971bc7..3652d56303 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy
@@ -101,32 +101,49 @@ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcess
if (isBlank(serviceInstanceId)) {
msg = "Input serviceInstanceId' is null"
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- /*
- * Extracting User Parameters from incoming Request and converting into a Map
- */
- def jsonSlurper = new JsonSlurper()
- def jsonOutput = new JsonOutput()
-
- Map reqMap = jsonSlurper.parseText(siRequest)
-
- //InputParams
- def userParams = reqMap.requestDetails?.requestParameters?.userParams
-
- Map<String, String> inputMap = [:]
- if (userParams) {
- userParams.each {
- userParam -> inputMap.put(userParam.name, userParam.value.toString())
- }
}
- execution.setVariable("operationType", "CompareModel")
- utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled)
- execution.setVariable("serviceInputParams", inputMap)
-
- } catch (BpmnError e) {
- throw e;
+ //subscriberInfo
+ String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "globalSubscriberId")
+ if (isBlank(globalSubscriberId)) {
+ msg = "Input globalSubscriberId' is null"
+ utils.log("INFO", msg, isDebugEnabled)
+ } else {
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ }
+
+ //subscriptionServiceType
+ String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "serviceType")
+ if (isBlank(subscriptionServiceType)) {
+ msg = "Input subscriptionServiceType is null"
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("serviceType", subscriptionServiceType)
+ }
+
+ //modelInvariantIdTarget
+ String modelInvariantIdTarget = jsonUtil.getJsonValue(siRequest, "modelInvariantIdTarget")
+ if (isBlank(modelInvariantIdTarget)) {
+ msg = "Input modelInvariantIdTarget' is null"
+ utils.log("INFO", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("modelInvariantIdTarget", modelInvariantIdTarget)
+ }
+
+ //modelVersionIdTarget
+ String modelVersionIdTarget = jsonUtil.getJsonValue(siRequest, "modelVersionIdTarget")
+ if (isBlank(modelVersionIdTarget)) {
+ msg = "Input modelVersionIdTarget is null"
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ } else {
+ execution.setVariable("modelVersionIdTarget", modelVersionIdTarget)
+ }
+
+ execution.setVariable("operationType", "CompareModel")
+
} catch (Exception ex){
msg = "Exception in preProcessRequest " + ex.getMessage()
utils.log("INFO", msg, isDebugEnabled)
@@ -143,13 +160,13 @@ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcess
CompareModelsResult compareModelsResult = execution.getVariable("compareModelsResult")
// RESTResponse (for API Handler(APIH) Reply Task)
- String syncResponse = compareModelsResult.toString()
+ String syncResponse = compareModelsResult.toJsonStringNoRootName()
utils.log("INFO", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)
sendWorkflowResponse(execution, 202, syncResponse)
} catch (Exception ex) {
String msg = "Exception in sendSyncResponse: " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
utils.log("INFO"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
index 0279c2cbc8..b29c4dc101 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
@@ -28,7 +28,6 @@ import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
import org.openecomp.mso.bpmn.core.WorkflowException
import org.openecomp.mso.bpmn.core.json.JsonUtils
import org.openecomp.mso.rest.APIResponse
-
import java.util.UUID;
import org.camunda.bpm.engine.delegate.BpmnError
@@ -62,24 +61,36 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
* generate the nsParameters
*/
public void preProcessRequest (DelegateExecution execution) {
+ JsonUtils jsonUtil = new JsonUtils()
+
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
String msg = ""
utils.log("INFO", " *** preProcessRequest() *** ", isDebugEnabled)
try {
//deal with nsName and Description
- String nsServiceName = execution.getVariable("nsServiceName")
+ String resourceInput = execution.getVariable("resourceInput")
+
+ // get service name
+ String resourceName = jsonUtil.getJsonValue(resourceInput, "resourceInstanceName")
+ String nsServiceName = resourceName.substring(resourceName.indexOf("_") + 1)
+ execution.setVariable("nsServiceName", nsServiceName)
+
String nsServiceDescription = execution.getVariable("nsServiceDescription")
utils.log("INFO", "nsServiceName:" + nsServiceName + " nsServiceDescription:" + nsServiceDescription, isDebugEnabled)
//deal with operation key
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String globalSubscriberId = jsonUtil.getJsonValue(resourceInput, "globalSubscriberId")
utils.log("INFO", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)
+
String serviceType = execution.getVariable("serviceType")
utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)
- String serviceId = execution.getVariable("serviceId")
+
+ String serviceId = execution.getVariable("serviceInstanceId")
utils.log("INFO", "serviceId:" + serviceId, isDebugEnabled)
- String operationId = execution.getVariable("operationId")
+
+ String operationId = execution.getVariable("requestId")
utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)
- String nodeTemplateUUID = execution.getVariable("resourceUUID")
+
+ String nodeTemplateUUID = jsonUtil.getJsonValue(resourceInput, "resourceModelInfo.modelCustomizationUuid")
utils.log("INFO", "nodeTemplateUUID:" + nodeTemplateUUID, isDebugEnabled)
/*
* segmentInformation needed as a object of segment
@@ -92,7 +103,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
* }
* }
*/
- String nsParameters = execution.getVariable("resourceParameters")
+ String nsParameters = jsonUtil.getJsonValue(resourceInput, "resourceParameters")
utils.log("INFO", "nsParameters:" + nsParameters, isDebugEnabled)
String nsOperationKey = """{
"globalSubscriberId":"${globalSubscriberId}",
@@ -125,11 +136,16 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
String nsParameters = execution.getVariable("nsParameters");
String nsServiceName = execution.getVariable("nsServiceName")
String nsServiceDescription = execution.getVariable("nsServiceDescription")
+ String locationConstraints = jsonUtil.getJsonValue(nsParameters, "locationConstraints")
+ String requestInputs = jsonUtil.getJsonValue(nsParameters, "requestInputs")
String reqBody ="""{
"nsServiceName":"${nsServiceName}",
"nsServiceDescription":"${nsServiceDescription}",
"nsOperationKey":${nsOperationKey},
- "nsParameters":${nsParameters}
+ "nsParameters":{
+ "locationConstraints":${locationConstraints},
+ "additionalParamForNs":${requestInputs}
+ }
}"""
APIResponse apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody)
String returnCode = apiResponse.getStatusCode()
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy
index a49a0664e8..77b0657514 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy
@@ -149,7 +149,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
"modelUuid":"${modelUuid}",
"modelVersion":""
}"""
- execution.setVariable("serviceModelInfo", serviceModelInfo)
+
execution.setVariable("serviceModelInfo_Target", serviceModelInfo)
utils.log("DEBUG", " ***** Completed prepareDecomposeService_Target of update generic e2e service ***** ", isDebugEnabled)
@@ -187,7 +187,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
"modelUuid":"${modelUuid}",
"modelVersion":""
}"""
- execution.setVariable("serviceModelInfo", serviceModelInfo)
+
execution.setVariable("serviceModelInfo_Original", serviceModelInfo)
utils.log("DEBUG", " ***** Completed prepareDecomposeService_Original of update generic e2e service ***** ", isDebugEnabled)
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
index 30db8c53eb..0172402185 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy
@@ -34,6 +34,7 @@ import org.openecomp.mso.bpmn.common.scripts.AaiUtil
import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
+import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder
import org.openecomp.mso.bpmn.core.RollbackData
import org.openecomp.mso.bpmn.core.WorkflowException
import org.openecomp.mso.rest.APIResponse;
@@ -84,13 +85,12 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce
JsonUtils jsonUtil = new JsonUtils()
public void preProcessRequest (DelegateExecution execution) {
- execution.setVariable("isDebugLogEnabled","true")
def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
utils.log("INFO","Entered " + method, isDebugEnabled)
String msg = ""
- utils.log("INFO"," ***** Enter CompareModelofE2EServiceInstance preProcessRequest *****", isDebugEnabled)
+ utils.log("INFO"," ***** Enter DoCompareModelofE2EServiceInstance preProcessRequest *****", isDebugEnabled)
execution.setVariable("prefix", Prefix)
//Inputs
@@ -121,14 +121,14 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
- String modelInvariantUuid = execution.getVariable('modelInvariantIdTarget')
+ String modelInvariantUuid = execution.getVariable("modelInvariantIdTarget")
if (isBlank(modelInvariantUuid)){
msg = "Input modelInvariantUuid is null"
utils.log("INFO", msg, isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
- String modelUuid = execution.getVariable('modelVersionIdTarget')
+ String modelUuid = execution.getVariable("modelVersionIdTarget")
if (isBlank(modelUuid)){
msg = "Input modelUuid is null"
utils.log("INFO", msg, isDebugEnabled)
@@ -238,7 +238,7 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce
requestInputs.addAll(resourceParameters.keySet())
}
- for(Resource rc : deletedResourceList) {
+ for(Resource rc : delResourceList) {
mi = rc.getModelInfo()
String resourceCustomizationUuid = mi.getModelCustomizationUuid()
ResourceModelInfo rmodel = new ResourceModelInfo()
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy
index 93f86592ab..5dd33c9181 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy
@@ -182,6 +182,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor
resourceInput.setResourceModelInfo(currentResource.getModelInfo());
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo());
+ def String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid();
String incomingRequest = execution.getVariable("uuiRequest")
//set the requestInputs from tempalte To Be Done
@@ -203,10 +204,10 @@ public class DoCreateResources extends AbstractServiceTaskProcessor
String requestAction = resourceInput.getOperationType()
JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceInput.getResourceModelInfo().getModelUuid(), requestAction)
String recipeUri = resourceRecipe.getString("orchestrationUri")
- String recipeTimeOut = resourceRecipe.getString("recipeTimeout")
+ int recipeTimeOut = resourceRecipe.getInt("recipeTimeout")
String recipeParamXsd = resourceRecipe.get("paramXSD")
HttpResponse resp = BpmnRestClient.post(recipeUri, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd)
-
+ utils.log("INFO", "======== end executeResourceRecipe Process ======== ", isDebugEnabled)
}
public void postConfigRequest(DelegateExecution execution){
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/PnfReadyEventHandler.java b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/PnfReadyEventHandler.java
deleted file mode 100644
index f89b6a7a58..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/PnfReadyEventHandler.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.openecomp.mso.bpmn.infrastructure.scripts;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
-import org.openecomp.mso.client.dmaap.DmaapConsumer;
-import org.openecomp.mso.client.sdno.dmaap.PnfReadyEventConsumer;
-
-public class PnfReadyEventHandler {
-
- private ExceptionUtil exceptionUtil;
-
- private static final String TOPIC_NAME = "VES event";
-
- public PnfReadyEventHandler() {
- exceptionUtil = new ExceptionUtil();
- }
-
- public void getPnfReadyEventFromDmaap (DelegateExecution execution) throws Exception {
- Object correlationIdVar = execution.getVariable("correlationId");
- if (!(correlationIdVar instanceof String)) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "correlationId variable is not String type");
- }
- String correlationId = (String) correlationIdVar;
- DmaapConsumer dmaapConsumer = new PnfReadyEventConsumer(correlationId);
- dmaapConsumer.consume();
- // TODO inform camunda process that event has been received
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java
index f4483f5923..417bb4668e 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java
@@ -28,6 +28,7 @@ import java.io.IOException;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiConnection;
import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.AaiResponse;
import org.openecomp.mso.bpmn.infrastructure.pnf.implementation.CheckAaiForCorrelationIdImplementation;
@@ -58,21 +59,16 @@ public class CheckAaiForCorrelationIdDelegate implements JavaDelegate {
public void execute(DelegateExecution execution) throws Exception {
String correlationId = (String) execution.getVariable(CORRELATION_ID);
if (correlationId == null) {
- //todo: fix Execution -> DelegateExecution in ALL groovy scripts
-// new ExceptionUtil().buildAndThrowWorkflowException(execution, 500, CORRELATION_ID + " is not set");
- throw new BpmnError("MSOWorkflowException");
+ new ExceptionUtil().buildAndThrowWorkflowException(execution, 500, CORRELATION_ID + " is not set");
}
try {
AaiResponse aaiResponse = implementation.check(correlationId, aaiConnection);
execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, aaiResponse.getContainsInfoAboutPnf());
- aaiResponse.getContainsInfoAboutIp().ifPresent(
- isIp -> execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, isIp)
- );
+ execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_IP, aaiResponse.getContainsInfoAboutIp());
} catch (IOException e) {
- //todo: log this
- throw new BpmnError("MSOWorkflowException");
+ new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, e.getMessage());
}
}
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
index 6b49908a0f..0d64f2c8b7 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java
@@ -23,6 +23,9 @@ package org.openecomp.mso.bpmn.infrastructure.pnf.delegate;
@SuppressWarnings("ALL")
public class ExecutionVariableNames {
+ private ExecutionVariableNames() {
+ }
+
public final static String CORRELATION_ID = "correlationId";
public final static String AAI_CONTAINS_INFO_ABOUT_PNF = "aaiContainsInfoAboutPnf";
public final static String AAI_CONTAINS_INFO_ABOUT_IP = "aaiContainsInfoAboutIp";
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumer.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumer.java
new file mode 100644
index 0000000000..e6019f73f0
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumer.java
@@ -0,0 +1,96 @@
+/*-
+ * ============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.openecomp.mso.bpmn.infrastructure.pnf.dmaap;
+
+import java.io.IOException;
+import java.net.URI;
+import javax.ws.rs.core.UriBuilder;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.HttpClientBuilder;
+
+public class PnfEventReadyConsumer {
+
+ private static final String JSON_PATH_CORRELATION_ID = "$.pnfRegistrationFields.correlationId";
+ private HttpClient httpClient;
+
+ private String dmaapHost;
+ private int dmaapPort;
+ private String dmaapProtocol;
+ private String dmaapUriPathPrefix;
+ private String dmaapTopicName;
+ private String consumerId;
+ private String consumerGroup;
+
+ public PnfEventReadyConsumer() {
+ httpClient = HttpClientBuilder.create().build();
+ }
+
+ public void notifyWhenPnfReady(String correlationId)
+ throws IOException {
+ HttpGet getRequest = new HttpGet(buildURI(consumerGroup, consumerId));
+ HttpResponse response = httpClient.execute(getRequest);
+ checkIfResponseIsAccepted(response, correlationId);
+ }
+
+ private boolean checkIfResponseIsAccepted(HttpResponse response, String correlationId) {
+ // TODO parse response if contains proper correlationId
+ return false;
+ }
+
+ private URI buildURI(String consumerGroup, String consumerId) {
+ return UriBuilder.fromUri(dmaapUriPathPrefix)
+ .scheme(dmaapProtocol)
+ .host(dmaapHost)
+ .port(dmaapPort).path(dmaapTopicName)
+ .path(consumerGroup).path(consumerId).build();
+ }
+
+ public void setDmaapHost(String dmaapHost) {
+ this.dmaapHost = dmaapHost;
+ }
+
+ public void setDmaapPort(int dmaapPort) {
+ this.dmaapPort = dmaapPort;
+ }
+
+ public void setDmaapProtocol(String dmaapProtocol) {
+ this.dmaapProtocol = dmaapProtocol;
+ }
+
+ public void setDmaapUriPathPrefix(String dmaapUriPathPrefix) {
+ this.dmaapUriPathPrefix = dmaapUriPathPrefix;
+ }
+
+ public void setDmaapTopicName(String dmaapTopicName) {
+ this.dmaapTopicName = dmaapTopicName;
+ }
+
+ public void setConsumerId(String consumerId) {
+ this.consumerId = consumerId;
+ }
+
+ public void setConsumerGroup(String consumerGroup) {
+ this.consumerGroup = consumerGroup;
+ }
+
+}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java
index bbb7adc143..5fb7a43e00 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/AaiResponse.java
@@ -24,28 +24,25 @@ import java.util.Optional;
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
-public class AaiResponse {
+public enum AaiResponse {
+ NO_ENTRY(false, false),
+ ENTRY_NO_IP(true, false),
+ ENTRY_WITH_IP(true, true);
- private Boolean containsInfoAboutPnf;
- private Boolean containsInfoAboutIp;
- private String ipAddress;
+ private boolean containsInfoAboutPnf;
+ private boolean containsInfoAboutIp;
- public AaiResponse(@NotNull Boolean containsInfoAboutPnf, @Nullable Boolean containsInfoAboutIp,
- @Nullable String ipAddress) {
+ AaiResponse(boolean containsInfoAboutPnf, boolean containsInfoAboutIp) {
this.containsInfoAboutPnf = containsInfoAboutPnf;
this.containsInfoAboutIp = containsInfoAboutIp;
- this.ipAddress = ipAddress;
}
- public Boolean getContainsInfoAboutPnf() {
+ public boolean getContainsInfoAboutPnf() {
return containsInfoAboutPnf;
}
- public Optional<Boolean> getContainsInfoAboutIp() {
- return Optional.ofNullable(containsInfoAboutIp);
+ public boolean getContainsInfoAboutIp() {
+ return containsInfoAboutIp;
}
- public Optional<String> getIpAddress() {
- return Optional.ofNullable(ipAddress);
- }
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java
index 353a3bd5d3..b982a693da 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/implementation/CheckAaiForCorrelationIdImplementation.java
@@ -29,15 +29,14 @@ public class CheckAaiForCorrelationIdImplementation {
public AaiResponse check(String correlationId, AaiConnection aaiConnection) throws IOException {
Optional<Pnf> pnf = aaiConnection.getEntryFor(correlationId);
if (!pnf.isPresent()) {
- return new AaiResponse(false, null, null);
+ return AaiResponse.NO_ENTRY;
}
- Optional<String> ip = extractIp(pnf.get());
- return ip.map(
- s -> new AaiResponse(true, true, s)
- ).orElseGet(
- () -> new AaiResponse(true, false, null)
- );
+ if(extractIp(pnf.get()).isPresent()) {
+ return AaiResponse.ENTRY_WITH_IP;
+ } else {
+ return AaiResponse.ENTRY_NO_IP;
+ }
}
private Optional<String> extractIp(Pnf pnf) {
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/dmaap.properties b/bpmn/MSOInfrastructureBPMN/src/main/resources/dmaap.properties
new file mode 100644
index 0000000000..3c4dca49cf
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/dmaap.properties
@@ -0,0 +1,7 @@
+dmaapHost=HOSTNAME
+dmaapPort=3905
+dmaapProtocol=http
+dmaapUriPathPrefix = events
+eventReadyTopicName=pnfEventReady
+consumerId=consumerId
+consumerGroup=group
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/processengine.properties b/bpmn/MSOInfrastructureBPMN/src/main/resources/processengine.properties
deleted file mode 100644
index d071fdabf8..0000000000
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/processengine.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ECOMP MSO
-# ================================================================================
-# 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=========================================================
-###
-processEngineName=infrastructure
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn
index 5772faadf0..8fe6b70d1a 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn
@@ -200,7 +200,7 @@ dcsi.doServiceHoming(execution)]]></bpmn2:script>
<camunda:in source="nsServiceDescription" target="nsServiceDescription" />
<camunda:in source="globalSubscriberId" target="globalSubscriberId" />
<camunda:in source="serviceType" target="serviceType" />
- <camunda:in source="serviceId" target="serviceId" />
+ <camunda:in source="serviceInstanceId" target="serviceInstanceId" />
<camunda:in source="operationId" target="operationId" />
<camunda:in source="resourceType" target="resourceType" />
<camunda:in source="resourceUUID" target="resourceUUID" />
@@ -210,6 +210,7 @@ dcsi.doServiceHoming(execution)]]></bpmn2:script>
<camunda:in source="serviceInstanceName" target="serviceInstanceName" />
<camunda:in source="serviceDecomposition" target="serviceDecomposition" />
<camunda:in source="uuiRequest" target="uuiRequest" />
+ <camunda:in source="msoRequestId" target="msoRequestId" />
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_0bf6bzp</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_0d0c20n</bpmn2:outgoing>
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml b/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml
index 46cea5da63..f46cd065ed 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/applicationContext.xml
@@ -14,4 +14,18 @@
<property name="aaiConnection" ref="aaiConnection"/>
</bean>
+ <bean id="pnfEventReadyConsumer" class="org.openecomp.mso.bpmn.infrastructure.pnf.dmaap.PnfEventReadyConsumer">
+ <property name="dmaapHost" value="${dmaapHost}" />
+ <property name="dmaapPort" value="${dmaapPort}"/>
+ <property name="dmaapProtocol" value="${dmaapProtocol}"/>
+ <property name="dmaapUriPathPrefix" value="${dmaapUriPathPrefix}"/>
+ <property name="dmaapTopicName" value="${eventReadyTopicName}"/>
+ <property name= "consumerGroup" value="${consumerGroup}"/>
+ <property name="consumerId" value="${consumerId}"/>
+ </bean>
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="locations" value="classpath:dmaap.properties"/>
+ </bean>
+
</beans>
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/web.xml b/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/web.xml
index 62a2748c8c..cd688479a5 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/web.xml
+++ b/bpmn/MSOInfrastructureBPMN/src/main/webapp/WEB-INF/web.xml
@@ -48,9 +48,19 @@
<param-name>resteasy.resources</param-name>
<param-value>org.openecomp.mso.logger.MsoLoggingServlet,org.openecomp.mso.bpmn.core.HealthCheckHandler</param-value>
</context-param>
+ <context-param>
+ <param-name>mso.configuration</param-name>
+ <param-value>MSO_PROP_APIHANDLER_INFRA=mso.apihandler-infra.properties</param-value>
+ </context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
+
+ <context-param>
+ <param-name>resteasy.jndi.resources</param-name>
+ <param-value>java:module/MsoPropertiesFactory</param-value>
+ </context-param>
<filter>
<filter-name>LogFilter</filter-name>
<filter-class>org.openecomp.mso.logger.LogFilter</filter-class>
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
index d98a395838..75a7450434 100644
--- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
+++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java
@@ -21,10 +21,11 @@
package org.openecomp.mso.bpmn.infrastructure.pnf.delegate;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.DEFAULT_IP;
import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITHOUT_ENTRY;
import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY_AND_IP;
import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY_NO_IP;
@@ -38,6 +39,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
+import org.openecomp.mso.bpmn.core.WorkflowException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -60,8 +62,7 @@ public class CheckAaiForCorrelationIdDelegateTest {
when(execution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
// when, then
assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class);
- // todo: uncomment line below after fixing Execution -> DelecateExecution in groovy scripts
-// verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class));
+ verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class));
}
@Test
@@ -118,12 +119,14 @@ public class CheckAaiForCorrelationIdDelegateTest {
private CheckAaiForCorrelationIdDelegate delegate;
@Test
- public void shouldThrowExceptionWhenSSADFDSADSFDS() throws Exception {
+ public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() throws Exception {
// given
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable(CORRELATION_ID)).thenReturn(ID_WITH_ENTRY_NO_IP);
+ when(execution.getVariable("testProcessKey")).thenReturn("testProcessKey");
// when, then
assertThatThrownBy(() -> delegate.execute(execution)).isInstanceOf(BpmnError.class);
+ verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class));
}
}
} \ No newline at end of file
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumerTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumerTest.java
new file mode 100644
index 0000000000..2f6a00db66
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/dmaap/PnfEventReadyConsumerTest.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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.openecomp.mso.bpmn.infrastructure.pnf.dmaap;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.lang.reflect.Field;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@ContextConfiguration({"classpath:springConfig_PnfEventReadyConsumer.xml"})
+public class PnfEventReadyConsumerTest {
+
+ @Autowired
+ private PnfEventReadyConsumer pnfEventReadyConsumer;
+
+ private HttpClient httpClientMock;
+
+ @Before
+ public void init() throws NoSuchFieldException, IllegalAccessException {
+ httpClientMock = mock(HttpClient.class);
+ setPrivateField();
+ }
+
+ @Test
+ public void restClientInvokesWithProperURI() throws Exception {
+ ArgumentCaptor<HttpGet> captor1 = ArgumentCaptor.forClass(HttpGet.class);
+ pnfEventReadyConsumer.notifyWhenPnfReady("correlationId");
+ verify(httpClientMock).execute(captor1.capture());
+ assertThat(captor1.getValue().getURI()).hasHost("hostTest").hasPort(1234).hasScheme("http")
+ .hasPath("/eventsForTesting/eventTopicTest/consumerGroupTest/consumerTestId");
+ }
+
+ private void setPrivateField() throws NoSuchFieldException, IllegalAccessException {
+ Field field = pnfEventReadyConsumer.getClass().getDeclaredField("httpClient");
+ field.setAccessible(true);
+ field.set(pnfEventReadyConsumer, httpClientMock);
+ }
+
+}
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/dmaapTest.properties b/bpmn/MSOInfrastructureBPMN/src/test/resources/dmaapTest.properties
new file mode 100644
index 0000000000..a8df15c5df
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/dmaapTest.properties
@@ -0,0 +1,7 @@
+dmaapHost=hostTest
+dmaapPort=1234
+dmaapProtocol=http
+dmaapUriPathPrefix = eventsForTesting
+eventReadyTopicName=eventTopicTest
+consumerId=consumerTestId
+consumerGroup=consumerGroupTest \ No newline at end of file
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/springConfig_PnfEventReadyConsumer.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/springConfig_PnfEventReadyConsumer.xml
new file mode 100644
index 0000000000..5abee9dfd9
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/springConfig_PnfEventReadyConsumer.xml
@@ -0,0 +1,19 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="pnfEventReadyConsumer" class="org.openecomp.mso.bpmn.infrastructure.pnf.dmaap.PnfEventReadyConsumer">
+ <property name="dmaapHost" value="${dmaapHost}" />
+ <property name="dmaapPort" value="${dmaapPort}"/>
+ <property name="dmaapProtocol" value="${dmaapProtocol}"/>
+ <property name="dmaapUriPathPrefix" value="${dmaapUriPathPrefix}"/>
+ <property name="dmaapTopicName" value="${eventReadyTopicName}"/>
+ <property name= "consumerGroup" value="${consumerGroup}"/>
+ <property name="consumerId" value="${consumerId}"/>
+ </bean>
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="locations" value="classpath:dmaapTest.properties"/>
+ </bean>
+
+</beans>
diff --git a/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/PnfReadyEventConsumer.java b/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/PnfReadyEventConsumer.java
deleted file mode 100644
index 08e35f62f8..0000000000
--- a/common/src/main/java/org/openecomp/mso/client/sdno/dmaap/PnfReadyEventConsumer.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * ============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.openecomp.mso.client.sdno.dmaap;
-
-import java.io.IOException;
-import java.util.Optional;
-import javax.ws.rs.NotSupportedException;
-import org.openecomp.mso.client.dmaap.DmaapConsumer;
-import org.openecomp.mso.jsonpath.JsonPathUtil;
-
-public class PnfReadyEventConsumer extends DmaapConsumer {
-
- private static final String JSON_PATH_CORRELATION_ID = "$.pnfRegistrationFields.correlationId";
-
- private boolean continuePolling = true;
- private String correlationId;
-
- public PnfReadyEventConsumer(String correlationId) throws IOException {
- this.correlationId = correlationId;
- }
-
- @Override
- public boolean continuePolling() {
- return continuePolling;
- }
-
- @Override
- public void processMessage(String message) {
- }
-
- @Override
- public boolean isAccepted(String message) {
- Optional<String> correlationIdOpt = JsonPathUtil.getInstance().locateResult(message, JSON_PATH_CORRELATION_ID);
- if (correlationIdOpt.isPresent()) {
- continuePolling = false;
- return correlationIdOpt.get().equals(correlationId);
- }
- return false;
- }
-
- @Override
- public boolean isFailure(String message) {
- throw new NotSupportedException();
- }
-
- @Override
- public void stopProcessingMessages() {
- continuePolling = false;
- }
-
- @Override
- public String getRequestId() {
- throw new NotSupportedException();
- }
-
- @Override
- public String getUserName() {
- throw new NotSupportedException();
- }
-
- @Override
- public String getPassword() {
- throw new NotSupportedException();
- }
-
- @Override
- public String getTopic() {
- throw new NotSupportedException();
- }
-
- @Override
- public Optional<String> getHost() {
- throw new NotSupportedException();
- }
-}
diff --git a/common/src/test/java/org/openecomp/mso/client/dmaap/PnfReadyEventConsumerTest.java b/common/src/test/java/org/openecomp/mso/client/dmaap/PnfReadyEventConsumerTest.java
deleted file mode 100644
index 1561f75140..0000000000
--- a/common/src/test/java/org/openecomp/mso/client/dmaap/PnfReadyEventConsumerTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei 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.openecomp.mso.client.dmaap;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Optional;
-import org.junit.Test;
-import org.openecomp.mso.client.sdno.dmaap.PnfReadyEventConsumer;
-
-public class PnfReadyEventConsumerTest {
-
- private static final String CORRELATION_ID = "correlation_id_test";
-
- private static final String JSON_WITH_CORRELATION_ID = " {\"pnfRegistrationFields\": {\n"
- + " \"correlationId\": \"correlation_id_test\"\n"
- + " }}";
-
- @Test
- public void eventIsFoundForGivenCorrelationId2() throws Exception {
- PnfReadyEventConsumerForTesting testedObjectSpy = spy(new PnfReadyEventConsumerForTesting(CORRELATION_ID));
- Consumer consumerMock = mock(Consumer.class);
- when(testedObjectSpy.getConsumer()).thenReturn(consumerMock);
- when(consumerMock.fetch()).thenReturn(Arrays.asList(JSON_WITH_CORRELATION_ID));
- testedObjectSpy.consume();
- assertThat(testedObjectSpy.continuePolling()).isFalse();
- }
-
- // TODO this is temporary class, when methods are defined, it will be deleted
- private class PnfReadyEventConsumerForTesting extends PnfReadyEventConsumer {
-
- public PnfReadyEventConsumerForTesting(String correlationId) throws IOException {
- super(correlationId);
- }
-
- @Override
- public String getUserName(){
- return "userNameTest";
- }
- @Override
- public String getPassword(){
- return "passTest";
- }
- @Override
- public String getTopic(){
- return "topicTest";
- }
- @Override
- public Optional<String> getHost(){
- return Optional.of("http://localhost");
- }
- @Override
- public boolean isFailure(String message) {
- return false;
- }
- @Override
- public String getRequestId() {
- return "requestTest";
- }
- }
-
-}