diff options
21 files changed, 574 insertions, 281 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java index c15b0d9df1..facdd2f4ca 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java @@ -77,9 +77,9 @@ public class QueryGroups extends CatalogQuery { if (instanceGroup != null) { put(valueMap, "MODEL_NAME", instanceGroup.getModelName()); - put(valueMap, "MODEL_UUID", instanceGroup.getModelInvariantUUID()); + put(valueMap, "MODEL_UUID", instanceGroup.getModelUUID()); put(valueMap, "MODEL_INVARIANT_ID", instanceGroup.getModelInvariantUUID()); - put(valueMap, "MODEL_VERSION", instanceGroup.getModelUUID()); + put(valueMap, "MODEL_VERSION", instanceGroup.getModelVersion()); } String subItem = new QueryVnfcs(vnfcCustomizationNull ? null : o.getVnfcCustomizations()).JSON2(true, true); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index 589f119337..f2e0762a79 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -48,6 +48,7 @@ import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs; import org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule; import org.onap.so.db.catalog.beans.AllottedResource; import org.onap.so.db.catalog.beans.AllottedResourceCustomization; +import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.Recipe; @@ -55,11 +56,13 @@ import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ToscaCsar; import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.db.catalog.beans.VnfResource; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.AllottedResourceRepository; import org.onap.so.db.catalog.data.repository.ArRecipeRepository; +import org.onap.so.db.catalog.data.repository.InstanceGroupRepository; import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceRepository; @@ -120,6 +123,9 @@ public class CatalogDbAdapterRest { @Autowired private AllottedResourceRepository arResourceRepo; + @Autowired + private InstanceGroupRepository instanceGroupRepository; + private static final String NO_MATCHING_PARAMETERS = "no matching parameters"; public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) { @@ -536,6 +542,16 @@ public class CatalogDbAdapterRest { arResource.getModelVersion()); } } + + if (null == recipe) { + InstanceGroup grpResource = instanceGroupRepository.findByModelUUID(rmUuid); + if (grpResource != null) { + recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndActionAndVersionStr( + grpResource.getModelName(), action, grpResource.getModelVersion()); + } + + } + if (recipe != null) { QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe); entity = resourceRecipe.JSON2(false, false); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java index 3508810e04..57d31bf308 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditStackService.java @@ -50,23 +50,32 @@ public class AuditStackService { private AuditDeleteStackService auditDeleteStack; @PostConstruct - public void auditAddAAIInventory() { - String auth = ""; - try { - auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey")); - } catch (IllegalStateException | GeneralSecurityException e) { - logger.error("Error Decrypting Password", e); + public void auditAddAAIInventory() throws Exception { + for (int i = 0; i < getMaxClients(); i++) { + ExternalTaskClient client = createExternalTaskClient(); + client.subscribe("InventoryAddAudit").lockDuration(60000).handler(auditCreateStack::executeExternalTask) + .open(); } - ClientRequestInterceptor interceptor = - new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), auth); + } + + @PostConstruct + public void auditDeleteAAIInventory() throws Exception { + for (int i = 0; i < getMaxClients(); i++) { + ExternalTaskClient client = createExternalTaskClient(); + client.subscribe("InventoryDeleteAudit").lockDuration(60000).handler(auditDeleteStack::executeExternalTask) + .open(); + } + } + + protected ExternalTaskClient createExternalTaskClient() throws Exception { + ClientRequestInterceptor interceptor = createClientRequestInterceptor(); ExternalTaskClient client = ExternalTaskClient.create() .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor) - .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build(); - client.subscribe("InventoryAddAudit").lockDuration(60000).handler(auditCreateStack::executeExternalTask).open(); + .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(10000, 2, 120000)).build(); + return client; } - @PostConstruct - public void auditDeleteAAIInventory() { + protected ClientRequestInterceptor createClientRequestInterceptor() { String auth = ""; try { auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey")); @@ -75,11 +84,12 @@ public class AuditStackService { } ClientRequestInterceptor interceptor = new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"), auth); - ExternalTaskClient client = ExternalTaskClient.create() - .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor) - .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build(); - client.subscribe("InventoryDeleteAudit").lockDuration(60000).handler(auditDeleteStack::executeExternalTask) - .open(); + return interceptor; + } + + protected int getMaxClients() { + return Integer.parseInt(env.getProperty("workflow.topics.maxClients", "10")); } + } diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml index 1982961ae7..470bb31b19 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml @@ -4,7 +4,7 @@ server: port: 8080 tomcat: - max-threads: 50 + max-threads: 75 mso: logPath: ./logs/openstack diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java new file mode 100644 index 0000000000..2eb8d8ef39 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/audit/AuditStackServiceTest.java @@ -0,0 +1,71 @@ +package org.onap.so.adapters.audit; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import org.camunda.bpm.client.ExternalTaskClient; +import org.camunda.bpm.client.interceptor.ClientRequestInterceptor; +import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.utils.CryptoUtils; +import org.springframework.core.env.Environment; + +@RunWith(MockitoJUnitRunner.class) +public class AuditStackServiceTest { + + @Spy + @InjectMocks + AuditStackService auditStackService; + + @Mock + Environment mockEnvironment; + + + @Before + public void before() { + Mockito.doReturn("5").when(mockEnvironment).getProperty("workflow.topics.maxClients", "10"); + Mockito.doReturn("6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436") + .when(mockEnvironment).getRequiredProperty("mso.auth"); + Mockito.doReturn("07a7159d3bf51a0e53be7a8f89699be7").when(mockEnvironment).getRequiredProperty("mso.msoKey"); + Mockito.doReturn("something").when(mockEnvironment).getRequiredProperty("mso.config.cadi.aafId"); + Mockito.doReturn("host.com").when(mockEnvironment).getRequiredProperty("mso.workflow.endpoint"); + } + + @Test + public void testGetMaxClients() throws Exception { + int actual = auditStackService.getMaxClients(); + assertEquals(5, actual); + } + + @Test + public void testCreateClientRequestInterceptor() throws Exception { + String auth = CryptoUtils.decrypt( + "6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436", + "07a7159d3bf51a0e53be7a8f89699be7"); + ClientRequestInterceptor expected = new BasicAuthProvider("something", auth); + ClientRequestInterceptor actual = auditStackService.createClientRequestInterceptor(); + assertThat(actual, sameBeanAs(expected)); + + } + + @Test + public void testCreateExternalTaskClient() throws Exception { + String auth = CryptoUtils.decrypt( + "6B466C603A260F3655DBF91E53CE54667041C01406D10E8CAF9CC24D8FA5388D06F90BFE4C852052B436", + "07a7159d3bf51a0e53be7a8f89699be7"); + ClientRequestInterceptor inter = new BasicAuthProvider("something", auth); + Mockito.doReturn(inter).when(auditStackService).createClientRequestInterceptor(); + ExternalTaskClient actual = auditStackService.createExternalTaskClient(); + assertNotNull(actual); + Mockito.verify(auditStackService, Mockito.times(1)).createClientRequestInterceptor(); + + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java index 8aab4ec818..18a46dda99 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java @@ -37,6 +37,11 @@ import javax.ws.rs.core.UriBuilder; import org.apache.commons.lang.StringUtils; import org.camunda.bpm.engine.runtime.Execution; import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.bpmn.core.domain.GroupResource; +import org.onap.so.bpmn.core.domain.Resource; +import org.onap.so.bpmn.core.domain.ResourceType; +import org.onap.so.bpmn.core.domain.VnfResource; +import org.onap.so.bpmn.core.domain.VnfcResource; import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.client.HttpClient; import org.onap.so.client.HttpClientFactory; @@ -87,52 +92,65 @@ public class ResourceRequestBuilder { * * @param execution Execution context * - * @param serviceUuid The service template uuid + * @param currentResource The current Service Resource Object * - * @param resourceCustomizationUuid The resource customization uuid + * @param uuiServiceParameters the service parameters passed from the API * - * @param serviceParameters the service parameters passed from the API + * @param currentVFData The object to hold the sequence of execution level for fetching data from UUI inputs * * @return the resource instantiate parameters * * @since ONAP Beijing Release */ @SuppressWarnings("unchecked") - public static String buildResourceRequestParameters(Execution execution, String serviceUuid, - String resourceCustomizationUuid, String serviceParameters, Map<String, Object> currentVFData) { - List<String> resourceList = - jsonUtil.StringArrayToList(execution, (String) JsonUtils.getJsonValue(serviceParameters, "resources")); + public static String buildResourceRequestParameters(Execution execution, Resource currentResource, + String uuiServiceParameters, Map<String, Object> currentVFData) { + List<String> resourceList = jsonUtil.StringArrayToList(execution, + (String) JsonUtils.getJsonValue(uuiServiceParameters, "resources")); // Get the right location str for resource. default is an empty array. String locationConstraints = "[]"; String resourceInputsFromUui = ""; - for (String resource : resourceList) { - String resCusUuid = (String) JsonUtils.getJsonValue(resource, "resourceCustomizationUuid"); - if (resourceCustomizationUuid.equals(resCusUuid)) { - String resourceParameters = JsonUtils.getJsonValue(resource, "parameters"); - locationConstraints = JsonUtils.getJsonValue(resourceParameters, "locationConstraints"); - resourceInputsFromUui = JsonUtils.getJsonValue(resourceParameters, "requestInputs"); + if (currentResource.getResourceType() == ResourceType.VNF) { + for (String resource : resourceList) { + String resCusUuid = (String) JsonUtils.getJsonValue(resource, "resourceCustomizationUuid"); + if ((null != resCusUuid) + && resCusUuid.equals(currentResource.getModelInfo().getModelCustomizationUuid())) { + String resourceParameters = JsonUtils.getJsonValue(resource, "parameters"); + locationConstraints = JsonUtils.getJsonValue(resourceParameters, "locationConstraints"); + } } } - Map<String, Object> serviceInput = null; - if (JsonUtils.getJsonValue(serviceParameters, "requestInputs") != null) { - serviceInput = - getJsonObject((String) JsonUtils.getJsonValue(serviceParameters, "requestInputs"), Map.class); - } - Map<String, Object> resourceInputsFromUuiMap = getJsonObject(resourceInputsFromUui, Map.class); + Map<String, Object> uuiRequestInputs = null; + if (JsonUtils.getJsonValue(uuiServiceParameters, "requestInputs") != null) { + uuiRequestInputs = + getJsonObject((String) JsonUtils.getJsonValue(uuiServiceParameters, "requestInputs"), Map.class); + } - if (serviceInput == null) { - serviceInput = new HashMap(); + if (uuiRequestInputs == null) { + uuiRequestInputs = new HashMap(); + } + String resourceInputStr = null; + ResourceLevel resourceLevel = null; + switch (currentResource.getResourceType()) { + case VNF: + resourceInputStr = ((VnfResource) currentResource).getResourceInput(); + resourceLevel = ResourceLevel.FIRST; + break; + case GROUP: + resourceInputStr = ((GroupResource) currentResource).getVnfcs().get(0).getResourceInput(); + resourceLevel = ResourceLevel.SECOND; + break; } - if (resourceInputsFromUuiMap == null) { - resourceInputsFromUuiMap = new HashMap(); + Map<String, Object> resourceInputsAfterMerge = new HashMap<>(); + + if (StringUtils.isNotEmpty(resourceInputStr) && (null != resourceLevel)) { + resourceInputsAfterMerge = + getResourceInput(resourceInputStr, uuiRequestInputs, resourceLevel, currentVFData); } - Map<String, Object> resourceInputsFromServiceDeclaredLevel = - buildResouceRequest(serviceUuid, resourceCustomizationUuid, serviceInput, currentVFData); - resourceInputsFromUuiMap.putAll(resourceInputsFromServiceDeclaredLevel); - String resourceInputsStr = getJsonString(resourceInputsFromUuiMap); + String resourceInputsStr = getJsonString(resourceInputsAfterMerge); String result = "{\n" + "\"locationConstraints\":" + locationConstraints + ",\n" + "\"requestInputs\":" + resourceInputsStr + "\n" + "}"; return result; @@ -191,9 +209,9 @@ public class ResourceRequestBuilder { if (modelInfo.get("modelCustomizationUuid").equalsIgnoreCase(resCustomizationUuid)) { resourceInputMap.put("resourceInput", (String) resource.get("resourceInput")); String nodeType = ResourceLevel.FIRST.toString(); - if (((String) resource.get("toscaNodeType")).contains(".vf.")) { + if (((String) resource.get("resourceType")).equalsIgnoreCase("VNF")) { nodeType = ResourceLevel.FIRST.toString(); - } else if (((String) resource.get("toscaNodeType")).contains(".vfc.")) { + } else if (((String) resource.get("resourceType")).equals("GROUP")) { nodeType = ResourceLevel.SECOND.toString(); } resourceInputMap.put("nodeType", nodeType); @@ -204,178 +222,182 @@ public class ResourceRequestBuilder { } // this method combines resource input with service input - private static Map<String, Object> getResourceInput(String resourceInputStr, Map<String, Object> serviceInputs, + private static Map<String, Object> getResourceInput(String resourceInputStr, Map<String, Object> uuiRequestInputs, ResourceLevel resourceLevel, Map<String, Object> currentVFData) { - Gson gson = new Gson(); - Type type = new TypeToken<Map<String, String>>() {}.getType(); - Map<String, Object> resourceInput = gson.fromJson(resourceInputStr, type); - JsonParser parser = new JsonParser(); - - Map<String, Object> uuiServiceInput = serviceInputs; - - int firstLevelIndex = 0; - int secondLevelIndex = 0; - String firstLevelKey = null; - String secondLevelKey = null; - boolean levelKeyNameUpdated = false; - int indexToPick = 0; - - if (null != currentVFData) { - firstLevelIndex = getIntValue(currentVFData.get("currentFirstLevelIndex"), 0); - secondLevelIndex = getIntValue(currentVFData.get("currentSecondLevelIndex"), 0); - final String lastFirstLevelKey = firstLevelKey = (String) currentVFData.get("currentFirstLevelKey"); - final String lastSecondLevelKey = secondLevelKey = (String) currentVFData.get("currentSecondLevelKey"); - - if (null != currentVFData.get("lastNodeTypeProcessed")) { - ResourceLevel lastResourceLevel = - ResourceLevel.valueOf(currentVFData.get("lastNodeTypeProcessed").toString()); - switch (resourceLevel) { - case FIRST: - // if it is next request for same group then increment first level index - switch (lastResourceLevel) { - case FIRST: - boolean isSameLevelRequest = resourceInput.values().stream().anyMatch(item -> { - JsonElement tree = parser.parse(((String) item).split("\\|")[0]); - return tree.isJsonArray() && tree.getAsJsonArray().get(0).getAsString() - .equalsIgnoreCase(lastFirstLevelKey); - }); - if (isSameLevelRequest) { - firstLevelIndex++; - } - break; - case SECOND: + try { + Gson gson = new Gson(); + Type type = new TypeToken<Map<String, String>>() {}.getType(); + Map<String, Object> resourceInput = gson.fromJson(resourceInputStr, type); + JsonParser parser = new JsonParser(); + + Map<String, Object> uuiServiceInput = uuiRequestInputs; + + int firstLevelIndex = 0; + int secondLevelIndex = 0; + String firstLevelKey = null; + String secondLevelKey = null; + boolean levelKeyNameUpdated = false; + int indexToPick = 0; + + if (null != currentVFData) { + firstLevelIndex = getIntValue(currentVFData.get("currentFirstLevelIndex"), 0); + secondLevelIndex = getIntValue(currentVFData.get("currentSecondLevelIndex"), 0); + final String lastFirstLevelKey = firstLevelKey = (String) currentVFData.get("currentFirstLevelKey"); + final String lastSecondLevelKey = secondLevelKey = (String) currentVFData.get("currentSecondLevelKey"); + + if (null != currentVFData.get("lastNodeTypeProcessed")) { + ResourceLevel lastResourceLevel = + ResourceLevel.valueOf(currentVFData.get("lastNodeTypeProcessed").toString()); + switch (resourceLevel) { + case FIRST: + // if it is next request for same group then increment first level index + boolean isSameLevelRequest = resourceInput.values().stream().anyMatch(item -> { + JsonElement tree = parser.parse(((String) item).split("\\|")[0]); + return tree.isJsonArray() && tree.getAsJsonArray().get(0).getAsString() + .equalsIgnoreCase(lastFirstLevelKey); + }); + if (isSameLevelRequest) { + firstLevelIndex++; + } else { firstLevelIndex = 0; + } + if (lastResourceLevel == ResourceLevel.SECOND) { secondLevelKey = null; - break; + } + indexToPick = firstLevelIndex; + break; + case SECOND: + // if it is next request for same group then increment second level index + switch (lastResourceLevel) { + case FIRST: + secondLevelIndex = 0; + break; + case SECOND: + boolean isSameSecondLevelRequest = + resourceInput.values().stream().anyMatch(item -> { + JsonElement tree = parser.parse(((String) item).split("\\|")[0]); + return tree.isJsonArray() && tree.getAsJsonArray().get(0).getAsString() + .equalsIgnoreCase(lastSecondLevelKey); + }); + if (isSameSecondLevelRequest) { + secondLevelIndex++; + } + break; + } + // get actual parent object to search for second level objects + if (null != lastFirstLevelKey) { + Object currentObject = uuiRequestInputs.get(lastFirstLevelKey); + if ((null != currentObject) && (currentObject instanceof List)) { + List currentFirstLevelList = (List) currentObject; + if (currentFirstLevelList.size() > firstLevelIndex) { + uuiServiceInput = + (Map<String, Object>) currentFirstLevelList.get(firstLevelIndex); + } - } - indexToPick = firstLevelIndex; - break; - case SECOND: - // if it is next request for same group then increment second level index - switch (lastResourceLevel) { - case FIRST: - secondLevelIndex = 0; - break; - case SECOND: - boolean isSameLevelRequest = resourceInput.values().stream().anyMatch(item -> { - JsonElement tree = parser.parse(((String) item).split("\\|")[0]); - return tree.isJsonArray() && tree.getAsJsonArray().get(0).getAsString() - .equalsIgnoreCase(lastSecondLevelKey); - }); - if (isSameLevelRequest) { - secondLevelIndex++; } - break; - } - // get actual parent object to search for second level objects - if (null != lastFirstLevelKey) { - Object currentObject = serviceInputs.get(lastFirstLevelKey); - if ((null != currentObject) && (currentObject instanceof List)) { - List currentFirstLevelList = (List) currentObject; - if (currentFirstLevelList.size() > firstLevelIndex) { - uuiServiceInput = (Map<String, Object>) currentFirstLevelList.get(firstLevelIndex); - } - } - } - indexToPick = secondLevelIndex; - break; + indexToPick = secondLevelIndex; + break; + } } - } - - - } - // replace value if key is available in service input - for (String key : resourceInput.keySet()) { - String value = (String) resourceInput.get(key); - if (value.contains("|")) { - - // check which level - - // node it type of getinput - String[] split = value.split("\\|"); - String tmpKey = split[0]; - - JsonElement jsonTree = parser.parse(tmpKey); + } - // check if it is a list type - if (jsonTree.isJsonArray()) { - JsonArray jsonArray = jsonTree.getAsJsonArray(); - boolean matchFound = false; - if (jsonArray.size() == 3) { - String keyName = jsonArray.get(0).getAsString(); - String keyType = jsonArray.get(2).getAsString(); - if (!levelKeyNameUpdated) { - switch (resourceLevel) { - case FIRST: - firstLevelKey = keyName; - break; - case SECOND: - secondLevelKey = keyName; - break; + // replace value if key is available in service input + for (String key : resourceInput.keySet()) { + String value = (String) resourceInput.get(key); + + if (value.contains("|")) { + + // check which level + + // node it type of getinput + String[] split = value.split("\\|"); + String tmpKey = split[0]; + + JsonElement jsonTree = parser.parse(tmpKey); + + // check if it is a list type + if (jsonTree.isJsonArray()) { + JsonArray jsonArray = jsonTree.getAsJsonArray(); + boolean matchFound = false; + if (jsonArray.size() == 3) { + String keyName = jsonArray.get(0).getAsString(); + String keyType = jsonArray.get(2).getAsString(); + if (!levelKeyNameUpdated) { + switch (resourceLevel) { + case FIRST: + firstLevelKey = keyName; + break; + case SECOND: + secondLevelKey = keyName; + break; + } + levelKeyNameUpdated = true; } - levelKeyNameUpdated = true; - } - if (uuiServiceInput.containsKey(keyName)) { - Object vfcLevelObject = uuiServiceInput.get(keyName); - // it will be always list - if (vfcLevelObject instanceof List) { - List vfcObject = (List) vfcLevelObject; - if (vfcObject.size() > indexToPick) { - Map<String, Object> vfMap = (Map<String, Object>) vfcObject.get(indexToPick); - if (vfMap.containsKey(keyType)) { - if (vfMap.get(keyType) instanceof String) { - value = (String) vfMap.get(keyType); - } else { - value = getJsonString(vfMap.get(keyType)); + if (uuiServiceInput.containsKey(keyName)) { + Object vfcLevelObject = uuiServiceInput.get(keyName); + // it will be always list + if (vfcLevelObject instanceof List) { + List vfcObject = (List) vfcLevelObject; + if (vfcObject.size() > indexToPick) { + Map<String, Object> vfMap = (Map<String, Object>) vfcObject.get(indexToPick); + if (vfMap.containsKey(keyType)) { + if (vfMap.get(keyType) instanceof String) { + value = (String) vfMap.get(keyType); + } else { + value = getJsonString(vfMap.get(keyType)); + } + matchFound = true; } - matchFound = true; } } } } - } - if (!matchFound) { - if (split.length == 1) { // means value is empty e.g. "a":"key1|" - value = ""; - } else { - value = split[1]; + if (!matchFound) { + if (split.length == 1) { // means value is empty e.g. "a":"key1|" + value = ""; + } else { + value = split[1]; + } } - } - - } else { - // if not a list type - if (uuiServiceInput.containsKey(tmpKey)) { - value = (String) uuiServiceInput.get(tmpKey); } else { - if (split.length == 1) { // means value is empty e.g. "a":"key1|" - value = ""; + + // if not a list type + if (uuiServiceInput.containsKey(tmpKey)) { + value = (String) uuiServiceInput.get(tmpKey); } else { - value = split[1]; + if (split.length == 1) { // means value is empty e.g. "a":"key1|" + value = ""; + } else { + value = split[1]; + } } } - } + } + resourceInput.put(key, value); } - resourceInput.put(key, value); - } - // store current processed details into map - if (null != currentVFData) { - currentVFData.put("currentFirstLevelKey", firstLevelKey); - currentVFData.put("currentFirstLevelIndex", firstLevelIndex); - currentVFData.put("currentSecondLevelKey", secondLevelKey); - currentVFData.put("currentSecondLevelIndex", secondLevelIndex); - currentVFData.put("lastNodeTypeProcessed", resourceLevel.toString()); - } + // store current processed details into map + if (null != currentVFData) { + currentVFData.put("currentFirstLevelKey", firstLevelKey); + currentVFData.put("currentFirstLevelIndex", firstLevelIndex); + currentVFData.put("currentSecondLevelKey", secondLevelKey); + currentVFData.put("currentSecondLevelIndex", secondLevelIndex); + currentVFData.put("lastNodeTypeProcessed", resourceLevel.toString()); + } + + return resourceInput; - return resourceInput; + } catch (Exception e) { + logger.error("not able to parse and modify service resource input value against UUI ", e); + } + return new HashMap(); } private static int getIntValue(Object inputObj, int defaultValue) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index 0a7a75c89b..122e71851f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -9,9 +9,9 @@ * 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. @@ -81,14 +81,13 @@ public class ExecuteBuildingBlockRainyDay { String serviceType = ASTERISK; boolean aLaCarte = (boolean) execution.getVariable("aLaCarte"); boolean suppressRollback = (boolean) execution.getVariable("suppressRollback"); - String handlingCode = ""; WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); - try { - // Extract error data to be returned to WorkflowAction + if (workflowException != null) { execution.setVariable("WorkflowExceptionErrorMessage", workflowException.getErrorMessage()); - } catch (Exception e) { - logger.error("No WorkflowException Found", e); + } else { + logger.debug("WorkflowException is null, unable to set WorkflowExceptionErrorMessage"); } + String handlingCode = ""; if (suppressRollback) { handlingCode = "Abort"; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index b69ab151c4..dabfc81e1f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -152,7 +152,7 @@ public class ExceptionBuilder { .getProcessDefinition(execution.getProcessDefinitionId()).getKey(); } - public void processAuditException(DelegateExecutionImpl execution) { + public void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue) { logger.info("Building a WorkflowException for Subflow"); StringBuilder errorMessage = new StringBuilder(); @@ -203,11 +203,15 @@ public class ExceptionBuilder { errorMessage.append( "Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops."); - WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString()); - execution.setVariable("WorkflowException", exception); - execution.setVariable("WorkflowExceptionErrorMessage", errorMessage); - logger.info("Outgoing WorkflowException is {}", exception); - logger.info("Throwing MSOWorkflowException"); - throw new BpmnError("AAIInventoryFailure"); + if (flowShouldContinue) { + execution.setVariable("StatusMessage", errorMessage.toString()); + } else { + WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString()); + execution.setVariable("WorkflowException", exception); + execution.setVariable("WorkflowExceptionErrorMessage", errorMessage.toString()); + logger.info("Outgoing WorkflowException is {}", exception); + logger.info("Throwing MSOWorkflowException"); + throw new BpmnError("AAIInventoryFailure"); + } } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java index adfee796f2..1350a4bcc0 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java @@ -91,7 +91,7 @@ public class ResourceRequestBuilderTest extends BaseTest { + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" + "\t\t\"nfFunction\" \t: null,\n" + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," - + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"resourceType\" \t\t: \"VNF\",\n" + "\t\t\"nfRole\" \t\t: null,\n" + "\t\t\"nfNamingCode\" \t: null,\n" + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n" @@ -114,7 +114,7 @@ public class ResourceRequestBuilderTest extends BaseTest { + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + "\t\t\t},\n" + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" + "\t\t\"nfFunction\" \t: null,\n" - + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"resourceType\" \t\t: \"VNF\",\n" + "\t\t\"nfRole\" \t\t: null,\n" + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," + "\t\t\"nfNamingCode\" \t: null,\n" @@ -185,7 +185,7 @@ public class ResourceRequestBuilderTest extends BaseTest { + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + "\t\t\t},\n" + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" + "\t\t\"nfFunction\" \t: null,\n" - + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"resourceType\" \t\t: \"VNF\",\n" + "\t\t\"nfRole\" \t\t: null,\n" + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," + "\t\t\"nfNamingCode\" \t: null,\n" @@ -256,7 +256,7 @@ public class ResourceRequestBuilderTest extends BaseTest { + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + "\t\t\t},\n" + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" + "\t\t\"nfFunction\" \t: null,\n" - + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"resourceType\" \t\t: \"VNF\",\n" + "\t\t\"nfRole\" \t\t: null,\n" + "\"resourceInput\":\"{\\\"a\\\":\\\"value\\\"}\"," + "\t\t\"nfNamingCode\" \t: null,\n" @@ -397,7 +397,7 @@ public class ResourceRequestBuilderTest extends BaseTest { + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" + "\t\t\"nfFunction\" \t: null,\n" + "\"resourceInput\":\"{\\\"a\\\":\\\"key1|\\\"}\"," - + "\t\t\"nfType\" \t\t: null,\n" + + "\t\t\"resourceType\" \t\t: \"VNF\",\n" + "\t\t\"nfRole\" \t\t: null,\n" + "\t\t\"nfNamingCode\" \t: null,\n" + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n" @@ -472,19 +472,45 @@ public class ResourceRequestBuilderTest extends BaseTest { assertEquals("20000", stringObjectMap.get("postcode")); assertEquals("single_gateway", stringObjectMap.get("type")); assertEquals("vCPE", stringObjectMap.get("deviceName")); + assertEquals("DHCP", stringObjectMap.get("ipMode")); + + // VFC request again + stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88cb1f1", this.userInputMap, currentVFData); + assertEquals("Huawei Private Cloud", stringObjectMap.get("address")); + assertEquals("20000", stringObjectMap.get("postcode")); + assertEquals("single_gateway", stringObjectMap.get("type")); assertEquals("20.20.20.1", stringObjectMap.get("systemip")); assertEquals("default_ipv6", stringObjectMap.get("systemipv6")); + assertEquals("VNF", stringObjectMap.get("devclass")); + // VF level request + stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88ca1c3", this.userInputMap, currentVFData); + assertEquals("Huawei Public Cloud", stringObjectMap.get("address")); + assertEquals("dsvpn_hub", stringObjectMap.get("role")); + assertTrue(((String) stringObjectMap.get("wanlist")).contains("[")); + assertTrue(((String) stringObjectMap.get("devlist")).contains("[")); + + // VFC request + stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88cb1a4", this.userInputMap, currentVFData); + assertEquals("Huawei Public Cloud", stringObjectMap.get("address")); + assertEquals("20001", stringObjectMap.get("postcode")); + assertEquals("multiple_gateway", stringObjectMap.get("type")); + assertEquals("CPE_Beijing", stringObjectMap.get("deviceName")); + assertEquals("Static", stringObjectMap.get("ipMode")); // VFC request again - /* - * stringObjectMap = ResourceRequestBuilder.buildResouceRequest( "c3954379-4efe-431c-8258-f84905b158e5", - * "e776449e-2b10-45c5-9217-2775c88cb1f1", this.userInputMap, currentVFData); - * assertEquals("Huawei Public Cloud", stringObjectMap.get("address")); assertEquals("20001", - * stringObjectMap.get("postcode")); assertEquals("multiple_gateway", stringObjectMap.get("type")); - * assertEquals("CPE_Beijing", stringObjectMap.get("deviceName")); assertEquals("20.20.20.2", - * stringObjectMap.get("systemip")); - */ + stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5", + "e776449e-2b10-45c5-9217-2775c88cb1f5", this.userInputMap, currentVFData); + assertEquals("Huawei Public Cloud", stringObjectMap.get("address")); + assertEquals("20001", stringObjectMap.get("postcode")); + assertEquals("multiple_gateway", stringObjectMap.get("type")); + assertEquals("20.20.20.2", stringObjectMap.get("systemip")); + assertEquals("default_ipv6", stringObjectMap.get("systemipv6")); + assertEquals("PNF", stringObjectMap.get("devclass")); + } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java index 4ade9dbe32..549f16b6f6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java @@ -22,6 +22,7 @@ package org.onap.so.client.exception; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import org.camunda.bpm.engine.delegate.BpmnError; @@ -131,7 +132,7 @@ public class ExceptionBuilderTest extends BaseTest { public void processAuditExceptionTest() { try { Mockito.doReturn(extractPojosForBB).when(exceptionBuilder).getExtractPojosForBB(); - exceptionBuilder.processAuditException((DelegateExecutionImpl) execution); + exceptionBuilder.processAuditException((DelegateExecutionImpl) execution, false); } catch (BpmnError bpmnException) { assertEquals("AAIInventoryFailure", bpmnException.getErrorCode()); WorkflowException we = execution.getVariable("WorkflowException"); @@ -142,4 +143,19 @@ public class ExceptionBuilderTest extends BaseTest { } } + @Test + public void processAuditExceptionContinueTest() { + try { + Mockito.doReturn(extractPojosForBB).when(exceptionBuilder).getExtractPojosForBB(); + exceptionBuilder.processAuditException((DelegateExecutionImpl) execution, true); + String sm = execution.getVariable("StatusMessage"); + assertNotNull(sm); + assertEquals( + "create VF-Module testVfModuleId1 failed due to incomplete A&AI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that AIC RO did not create vserver testVServerId in AAI. Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops.", + sm); + } catch (BpmnError bpmnException) { + fail(); + } + } + } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json index 938b45e5a4..4803fca355 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json @@ -25,7 +25,7 @@ "toscaNodeType": "org.openecomp.resource.vf.15968a6e2fe541bfA481", "nfFunction": null, "resourceInput": "{\"a\":\"b\",\"topology\":\"[sdwanvpnresource_list,INDEX,sdwanvpn_topology]|default_topo\",\"name\":\"[sdwanvpnresource_list,INDEX,sdwanvpn_name]|default_name\",\"sitelist\":\"[sdwanvpnresource_list,INDEX,sdwansitelan_list]|default_sitelist\"}", - "nfType": null, + "resourceType": "VNF", "nfRole": null, "nfNamingCode": null, "multiStageDesign": "false", @@ -55,7 +55,7 @@ }, "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f", "nfFunction": null, - "nfType": null, + "resourceType": "GROUP", "nfRole": null, "resourceInput": "{\"a\":\"b|\",\"portswitch\":\"[sdwansitelan_list,INDEX,portSwitch]|default_portswitch\",\"ipAddress\":\"[sdwansitelan_list,INDEX,ipAddress]|default_ipAddress\",\"deviceName\":\"[sdwansitelan_list,INDEX,deviceName]|default_deviceName\"}", "nfNamingCode": null, @@ -86,7 +86,7 @@ }, "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f", "nfFunction": null, - "nfType": null, + "resourceType": "GROUP", "nfRole": null, "resourceInput": "{\"a\":\"b|\",\"portswitch\":\"[sdwansitelan_list,INDEX,portSwitch]|default_portswitch\",\"ipAddress\":\"[sdwansitelan_list,INDEX,ipAddress]|default_ipAddress\",\"deviceName\":\"[sdwansitelan_list,INDEX,deviceName]|default_deviceName\"}", "nfNamingCode": null, @@ -117,7 +117,7 @@ }, "toscaNodeType": "org.openecomp.resource.vf.F971106a248f42029d1f", "nfFunction": null, - "nfType": null, + "resourceType": "VNF", "nfRole": null, "resourceInput": "{\"address\":\"[sdwansiteresource_list,INDEX,sdwansite_address]|default_address\",\"role\":\"[sdwansiteresource_list,INDEX,sdwansite_role]|default_role\",\"wanlist\":\"[sdwansiteresource_list,INDEX,sdwansitewan_list]|default_wanlist\",\"devlist\":\"[sdwansiteresource_list,INDEX,sdwandevice_list]|default_devlist\"}", "nfNamingCode": null, @@ -148,9 +148,9 @@ }, "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f", "nfFunction": null, - "nfType": null, + "resourceType": "GROUP", "nfRole": null, - "resourceInput": "{\"address\":\"sdwansite_address|default_address\", \"postcode\":\"sdwansite_postcode|default_postcode\",\"type\":\"sdwansite_type|default_role\",\"deviceName\":\"[sdwansitewan_list,INDEX,deviceName]|default_deviceName\",\"systemip\":\"[sdwandevice_list,INDEX,systemIp]|default_systemip\", \"systemipv6\":\"[sdwandevice_list,INDEX,systemIpv6]|default_ipv6\"}", + "resourceInput": "{\"address\":\"sdwansite_address|default_address\", \"postcode\":\"sdwansite_postcode|default_postcode\",\"type\":\"sdwansite_type|default_role\",\"deviceName\":\"[sdwansitewan_list,INDEX,deviceName]|default_deviceName\",\"ipMode\":\"[sdwansitewan_list,INDEX,ipMode]|default_ipMode\"}", "nfNamingCode": null, "multiStageDesign": "false", "vfModules": [{ @@ -179,9 +179,9 @@ }, "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d3f", "nfFunction": null, - "nfType": null, + "resourceType": "GROUP", "nfRole": null, - "resourceInput": "{\"address\":\"sdwansite_address|default_address\", \"postcode\":\"sdwansite_postcode|default_postcode\",\"type\":\"sdwansite_type|default_role\",\"deviceName\":\"[sdwansitewan_list,INDEX,deviceName]|default_deviceName\",\"systemip\":\"[sdwandevice_list,INDEX,systemIp]|default_systemip\"}", + "resourceInput": "{\"address\":\"sdwansite_address|default_address\", \"postcode\":\"sdwansite_postcode|default_postcode\",\"type\":\"sdwansite_type|default_role\",\"systemip\":\"[sdwandevice_list,INDEX,systemIp]|default_systemip\", \"systemipv6\":\"[sdwandevice_list,INDEX,systemIpv6]|default_ipv6\", \"devclass\":\"[sdwandevice_list,INDEX,class]|default_class\"}", "nfNamingCode": null, "multiStageDesign": "false", "vfModules": [{ @@ -197,6 +197,99 @@ "initialCount": 1, "hasVolumeGroup": true }] + }, + + { + "modelInfo": { + "modelName": "f971106a-248f-4202-9d23", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add83", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89c3", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88ca1c3", + "modelInstanceName": "f971106a-248f-4202-9d23 0" + }, + "toscaNodeType": "org.openecomp.resource.vf.F971106a248f42029d1f", + "nfFunction": null, + "resourceType": "VNF", + "nfRole": null, + "resourceInput": "{\"address\":\"[sdwansiteresource_list,INDEX,sdwansite_address]|default_address\",\"role\":\"[sdwansiteresource_list,INDEX,sdwansite_role]|default_role\",\"wanlist\":\"[sdwansiteresource_list,INDEX,sdwansitewan_list]|default_wanlist\",\"devlist\":\"[sdwansiteresource_list,INDEX,sdwandevice_list]|default_devlist\"}", + "nfNamingCode": null, + "multiStageDesign": "false", + "vfModules": [{ + "modelInfo": { + "modelName": "F971106a248f42029d1f..base_vpkg..module-0", + "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35", + "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15", + "modelVersion": "1", + "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc" + }, + "isBase": true, + "vfModuleLabel": "base_vpkg", + "initialCount": 1, + "hasVolumeGroup": true + }] + }, + + { + "modelInfo": { + "modelName": "f971106a-248f-4202-9d34", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add94", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89f4", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88cb1a4", + "modelInstanceName": "f971106a-248f-4202-9d34 0" + }, + "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f", + "nfFunction": null, + "resourceType": "GROUP", + "nfRole": null, + "resourceInput": "{\"address\":\"sdwansite_address|default_address\", \"postcode\":\"sdwansite_postcode|default_postcode\",\"type\":\"sdwansite_type|default_role\",\"deviceName\":\"[sdwansitewan_list,INDEX,deviceName]|default_deviceName\",\"ipMode\":\"[sdwansitewan_list,INDEX,ipMode]|default_ipMode\"}", + "nfNamingCode": null, + "multiStageDesign": "false", + "vfModules": [{ + "modelInfo": { + "modelName": "F971106a248f42029d1f..base_vpkg..module-0", + "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35", + "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15", + "modelVersion": "1", + "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc" + }, + "isBase": true, + "vfModuleLabel": "base_vpkg", + "initialCount": 1, + "hasVolumeGroup": true + }] + }, + + { + "modelInfo": { + "modelName": "f971106a-248f-4202-9d55", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add35", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe8395", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88cb1f5", + "modelInstanceName": "f971106a-248f-4202-9d55 0" + }, + "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d3f", + "nfFunction": null, + "resourceType": "GROUP", + "nfRole": null, + "resourceInput": "{\"address\":\"sdwansite_address|default_address\", \"postcode\":\"sdwansite_postcode|default_postcode\",\"type\":\"sdwansite_type|default_role\",\"systemip\":\"[sdwandevice_list,INDEX,systemIp]|default_systemip\", \"systemipv6\":\"[sdwandevice_list,INDEX,systemIpv6]|default_ipv6\", \"devclass\":\"[sdwandevice_list,INDEX,class]|default_class\"}", + "nfNamingCode": null, + "multiStageDesign": "false", + "vfModules": [{ + "modelInfo": { + "modelName": "F971106a248f42029d1f..base_vpkg..module-0", + "modelUuid": "47d5273a-7456-4786-9035-b3911944cc35", + "modelInvariantUuid": "0ea3e57e-ac7a-425a-928b-b4aee8806c15", + "modelVersion": "1", + "modelCustomizationUuid": "9ed9fef6-d3f8-4433-9807-7e23393a16bc" + }, + "isBase": true, + "vfModuleLabel": "base_vpkg", + "initialCount": 1, + "hasVolumeGroup": true + }] } ], diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn index 435d85d032..ff37874978 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivateVfModuleBB.bpmn @@ -69,7 +69,7 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_19gbhlj" sourceRef="catchInventoryException" targetRef="processAuditException" /> <bpmn:sequenceFlow id="SequenceFlow_0l4jzc5" sourceRef="processAuditException" targetRef="EndEvent_067jv1n" /> - <bpmn:serviceTask id="processAuditException" name="Proccess Error" camunda:expression="${ExceptionBuilder.processAuditException(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="processAuditException" name="Proccess Error" camunda:expression="${ExceptionBuilder.processAuditException(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), false)}"> <bpmn:incoming>SequenceFlow_19gbhlj</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0l4jzc5</bpmn:outgoing> </bpmn:serviceTask> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn index 41c3966626..b774c052cc 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteVfModuleBB.bpmn @@ -109,19 +109,19 @@ <bpmn:outgoing>SequenceFlow_1ut7n32</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:subProcess id="SubProcess_0grvkj2" name="Audit Exception Sub Process" triggeredByEvent="true"> - <bpmn:startEvent id="StartEvent_1euiddy"> - <bpmn:outgoing>SequenceFlow_0xuodpy</bpmn:outgoing> - <bpmn:errorEventDefinition errorRef="Error_0jjnve8" /> - </bpmn:startEvent> <bpmn:endEvent id="EndEvent_1gzq57j"> <bpmn:incoming>SequenceFlow_1fhst92</bpmn:incoming> </bpmn:endEvent> - <bpmn:serviceTask id="ServiceTask_1isbxvo" name="Proccess Error" camunda:expression="${ExceptionBuilder.processAuditException(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="ServiceTask_1isbxvo" name="Proccess Error" camunda:expression="${ExceptionBuilder.processAuditException(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), true)}"> <bpmn:incoming>SequenceFlow_0xuodpy</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1fhst92</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0xuodpy" sourceRef="StartEvent_1euiddy" targetRef="ServiceTask_1isbxvo" /> <bpmn:sequenceFlow id="SequenceFlow_1fhst92" sourceRef="ServiceTask_1isbxvo" targetRef="EndEvent_1gzq57j" /> + <bpmn:startEvent id="StartEvent_1euiddy" isInterrupting="false"> + <bpmn:outgoing>SequenceFlow_0xuodpy</bpmn:outgoing> + <bpmn:escalationEventDefinition escalationRef="Escalation_130je8j" camunda:escalationCodeVariable="test" /> + </bpmn:startEvent> </bpmn:subProcess> <bpmn:sequenceFlow id="SequenceFlow_179btn2" sourceRef="aaiCatch" targetRef="DeleteNetworkPolicies" /> <bpmn:intermediateThrowEvent id="aaiThrow" name="Update AAI"> @@ -132,26 +132,29 @@ <bpmn:outgoing>SequenceFlow_179btn2</bpmn:outgoing> <bpmn:linkEventDefinition name="AAI" /> </bpmn:intermediateCatchEvent> - <bpmn:exclusiveGateway id="auditSuccessfulCheck" name="Audit Successful?" default="SequenceFlow_17cd9e2"> - <bpmn:incoming>SequenceFlow_0qfmmgt</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_17cd9e2</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_1gdyk9j</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_17cd9e2" name="Yes" sourceRef="auditSuccessfulCheck" targetRef="ExclusiveGateway_1pydilb" /> + <bpmn:sequenceFlow id="SequenceFlow_17cd9e2" name="Yes/No" sourceRef="auditSuccessfulCheck" targetRef="ExclusiveGateway_1pydilb"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditIsSuccessful") == false || execution.getVariable("auditIsSuccessful") == true}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1gdyk9j" name="No" sourceRef="auditSuccessfulCheck" targetRef="EndEvent_0b0ocu0"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditIsSuccessful") == false}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:endEvent id="EndEvent_0b0ocu0"> - <bpmn:incoming>SequenceFlow_1gdyk9j</bpmn:incoming> - <bpmn:errorEventDefinition errorRef="Error_0jjnve8" /> - </bpmn:endEvent> <bpmn:inclusiveGateway id="ExclusiveGateway_1yvh16a"> <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming> <bpmn:incoming>SequenceFlow_1ut7n32</bpmn:incoming> <bpmn:outgoing>SequenceFlow_14bu4ys</bpmn:outgoing> </bpmn:inclusiveGateway> + <bpmn:inclusiveGateway id="auditSuccessfulCheck" name="Audit Successful?"> + <bpmn:incoming>SequenceFlow_0qfmmgt</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17cd9e2</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1gdyk9j</bpmn:outgoing> + </bpmn:inclusiveGateway> + <bpmn:endEvent id="EndEvent_0b0ocu0"> + <bpmn:incoming>SequenceFlow_1gdyk9j</bpmn:incoming> + <bpmn:escalationEventDefinition escalationRef="Escalation_130je8j" /> + </bpmn:endEvent> </bpmn:process> <bpmn:error id="Error_0jjnve8" name="Error_3k24na6" errorCode="AAIInventoryFailure" /> + <bpmn:escalation id="Escalation_130je8j" name="audit" escalationCode="audit1" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeleteVfModuleBB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="DeleteVfModuleBB_Start"> @@ -375,12 +378,6 @@ <bpmndi:BPMNShape id="SubProcess_0grvkj2_di" bpmnElement="SubProcess_0grvkj2" isExpanded="true"> <dc:Bounds x="231" y="642" width="350" height="200" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="StartEvent_1euiddy_di" bpmnElement="StartEvent_1euiddy"> - <dc:Bounds x="262" y="725" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="189" y="765" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1gzq57j_di" bpmnElement="EndEvent_1gzq57j"> <dc:Bounds x="510" y="725" width="36" height="36" /> <bpmndi:BPMNLabel> @@ -394,7 +391,7 @@ <di:waypoint xsi:type="dc:Point" x="298" y="743" /> <di:waypoint xsi:type="dc:Point" x="353" y="743" /> <bpmndi:BPMNLabel> - <dc:Bounds x="237" y="722" width="90" height="12" /> + <dc:Bounds x="280.5" y="722" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1fhst92_di" bpmnElement="SequenceFlow_1fhst92"> @@ -423,39 +420,45 @@ <dc:Bounds x="150" y="530" width="55" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_187bfld_di" bpmnElement="auditSuccessfulCheck" isMarkerVisible="true"> - <dc:Bounds x="779.6431784107947" y="108" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="775" y="162" width="60" height="24" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_17cd9e2_di" bpmnElement="SequenceFlow_17cd9e2"> <di:waypoint xsi:type="dc:Point" x="830" y="133" /> <di:waypoint xsi:type="dc:Point" x="868" y="133" /> <di:waypoint xsi:type="dc:Point" x="868" y="174" /> <bpmndi:BPMNLabel> - <dc:Bounds x="838" y="114" width="19" height="12" /> + <dc:Bounds x="830" y="114" width="36" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1gdyk9j_di" bpmnElement="SequenceFlow_1gdyk9j"> <di:waypoint xsi:type="dc:Point" x="805" y="108" /> <di:waypoint xsi:type="dc:Point" x="805" y="56" /> <bpmndi:BPMNLabel> - <dc:Bounds x="812" y="77.49056603773585" width="14" height="12" /> + <dc:Bounds x="812" y="77" width="14" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="EndEvent_1wydovd_di" bpmnElement="EndEvent_0b0ocu0"> - <dc:Bounds x="787" y="20" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="805" y="59.13043478260869" width="0" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="InclusiveGateway_0cjvlht_di" bpmnElement="ExclusiveGateway_1yvh16a"> <dc:Bounds x="900" y="259" width="50" height="50" /> <bpmndi:BPMNLabel> <dc:Bounds x="879" y="312" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="InclusiveGateway_0i6rdd1_di" bpmnElement="auditSuccessfulCheck"> + <dc:Bounds x="780" y="108" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="775" y="162" width="60" height="24" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_04qhoba_di" bpmnElement="StartEvent_1euiddy"> + <dc:Bounds x="262" y="725" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="189" y="765" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1onxfk1_di" bpmnElement="EndEvent_0b0ocu0"> + <dc:Bounds x="787" y="20" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="760" y="59" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn index 83363d48ba..0a6a7731ce 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.2"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> <bpmn:process id="ExecuteBuildingBlock" name="ExecuteBuildingBlock" isExecutable="true"> <bpmn:startEvent id="Start_ExecuteBuildingBlock" name="start"> <bpmn:outgoing>SequenceFlow_0rq4c5r</bpmn:outgoing> @@ -10,6 +10,7 @@ <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:in source="mso-request-id" target="mso-request-id" /> <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" /> + <camunda:out source="StatusMessage" target="StatusMessage" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_19wuics</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01h9qmz</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index 76ca2a89cc..35b77d9189 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@ -22,6 +22,7 @@ <camunda:out source="orchestrationStatusValidationResult" target="orchestrationStatusValidationResult" /> <camunda:out source="RetryDuration" target="RetryDuration" /> <camunda:in source="suppressRollback" target="suppressRollback" /> + <camunda:out source="StatusMessage" target="StatusMessage" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0mew9im</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1hsqed1</bpmn:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java index e88df73f39..d9166c9138 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DeleteVfModuleBBTest.java @@ -37,6 +37,7 @@ public class DeleteVfModuleBBTest extends BaseBPMNTest { @Before public void before() { variables.put("auditInventoryNeeded", true); + variables.put("auditIsSuccessful", true); } @Test diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy index fd698d486f..ea25904cf3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy @@ -90,7 +90,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ } // this method will convert resource list to instance_resource_list - void prepareInstanceResourceList(DelegateExecution execution) { + public void prepareInstanceResourceList(DelegateExecution execution) { String uuiRequest = execution.getVariable("uuiRequest") List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") @@ -134,7 +134,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ // then we would like to add it twice for processing // e.g. S{ V1{G1, G2, G1}} --> S{ V1{G1, G1, G2}} if (resource instanceof VnfResource) { - if (resource.getGroups() != null) { + if (resource.getGroupOrder() != null && !StringUtils.isEmpty(resource.getGroupOrder())) { String[] grpSequence = resource.getGroupOrder().split(",") for (String grpType in grpSequence) { for (GroupResource gResource in resource.getGroups()) { @@ -251,20 +251,19 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ def currentIndex = execution.getVariable("currentResourceIndex") List<Resource> sequencedResourceList = execution.getVariable("instanceResourceList") Resource currentResource = sequencedResourceList.get(currentIndex) - resourceInput.setResourceModelInfo(currentResource.getModelInfo()); + resourceInput.setResourceModelInfo(currentResource.getModelInfo()) + resourceInput.getResourceModelInfo().setModelType(currentResource.getResourceType().toString()) ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()); - def String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid(); + resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()) String incomingRequest = execution.getVariable("uuiRequest") //set the requestInputs from tempalte To Be Done - String serviceModelUuid = jsonUtil.getJsonValue(incomingRequest,"service.serviceUuid") - String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters") + String uuiServiceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters") Map<String, Object> currentVFData = (Map) execution.getVariable("currentVFData"); if (null == currentVFData) { currentVFData = new HashMap<>(); } - String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters, currentVFData) + String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, currentResource, uuiServiceParameters, currentVFData) resourceInput.setResourceParameters(resourceParameters) resourceInput.setRequestsInputs(incomingRequest) execution.setVariable("resourceInput", resourceInput.toString()) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java index 4fc4d85b97..5f357f5478 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java @@ -20,6 +20,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; +import java.sql.Timestamp; import java.util.Optional; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; @@ -53,6 +54,10 @@ public class WorkflowActionBBFailure { errorMsg = "Failed to determine error message"; } request.setStatusMessage(errorMsg); + request.setProgress(Long.valueOf(100)); + request.setRequestStatus("FAILED"); + request.setLastModifiedBy("CamundaBPMN"); + request.setEndTime(new Timestamp(System.currentTimeMillis())); requestDbclient.updateInfraActiveRequests(request); } catch (Exception e) { logger.error( @@ -113,6 +118,7 @@ public class WorkflowActionBBFailure { request.setProgress(Long.valueOf(100)); request.setRequestStatus("FAILED"); request.setLastModifiedBy("CamundaBPMN"); + request.setEndTime(new Timestamp(System.currentTimeMillis())); requestDbclient.updateInfraActiveRequests(request); } catch (Exception e) { workflowAction.buildAndThrowException(execution, "Error Updating Request Database", e); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index f0a102dfeb..753a050c03 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -7,9 +7,9 @@ * 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. @@ -227,11 +227,16 @@ public class WorkflowActionBBTasks { final String action = (String) execution.getVariable(G_ACTION); final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); final String resourceName = (String) execution.getVariable("resourceName"); + String statusMessage = (String) execution.getVariable("StatusMessage"); String macroAction = ""; - if (aLaCarte) { - macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly."; + if (statusMessage == null) { + if (aLaCarte) { + macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly."; + } else { + macroAction = "Macro-" + resourceName + "-" + action + " request was executed correctly."; + } } else { - macroAction = "Macro-" + resourceName + "-" + action + " request was executed correctly."; + macroAction = statusMessage; } execution.setVariable("finalStatusMessage", macroAction); Timestamp endTime = new Timestamp(System.currentTimeMillis()); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java index a6ce88f164..52a2cf7223 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java @@ -23,11 +23,14 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; +import java.sql.Timestamp; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -84,6 +87,7 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest { Mockito.verify(reqMock, Mockito.times(1)).setRequestStatus("FAILED"); Mockito.verify(reqMock, Mockito.times(1)).setProgress(Long.valueOf(100)); Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN"); + Mockito.verify(reqMock, Mockito.times(1)).setEndTime(any(Timestamp.class)); } @Test @@ -142,4 +146,20 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest { String errorMsg = (String) execution.getVariable("ErrorMessage"); assertEquals("error in test case", errorMsg); } + + @Test + public void updateRequestErrorStatusMessageTest() { + String reqId = "reqId123"; + execution.setVariable("mso-request-id", reqId); + WorkflowException we = new WorkflowException("WorkflowAction", 1231, "Error Case"); + execution.setVariable("WorkflowException", we); + + doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); + workflowActionBBFailure.updateRequestErrorStatusMessage(execution); + Mockito.verify(reqMock, Mockito.times(1)).setStatusMessage("Error Case"); + Mockito.verify(reqMock, Mockito.times(1)).setRequestStatus("FAILED"); + Mockito.verify(reqMock, Mockito.times(1)).setProgress(Long.valueOf(100)); + Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN"); + Mockito.verify(reqMock, Mockito.times(1)).setEndTime(any(Timestamp.class)); + } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/RainyDayHandlerStatusRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/RainyDayHandlerStatusRepository.java index 91ae10236b..6819657b78 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/RainyDayHandlerStatusRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/RainyDayHandlerStatusRepository.java @@ -32,7 +32,7 @@ public interface RainyDayHandlerStatusRepository extends JpaRepository<RainyDayH @Query(value = "SELECT * FROM rainy_day_handler_macro WHERE (FLOW_NAME = :flowName ) AND SERVICE_TYPE IN (:serviceType ,'*') " + " AND VNF_TYPE IN ( :vnfType , '*') AND ERROR_CODE IN (:errorCode ,'*') AND WORK_STEP IN (:workStep , '*' ) " + " AND ( :errorMessage REGEXP rainy_day_handler_macro.REG_EX_ERROR_MESSAGE OR REG_EX_ERROR_MESSAGE = '*') " - + " ORDER BY CASE WHEN 'asdf' REGEXP REG_EX_ERROR_MESSAGE THEN 0 WHEN ERROR_CODE != '*' THEN 1 WHEN VNF_TYPE != '*' THEN 2 WHEN SERVICE_TYPE != '*' THEN 3 ELSE 4 END LIMIT 1;", + + " ORDER BY CASE WHEN :errorMessage REGEXP REG_EX_ERROR_MESSAGE THEN 0 WHEN ERROR_CODE != '*' THEN 1 WHEN VNF_TYPE != '*' THEN 2 WHEN SERVICE_TYPE != '*' THEN 3 ELSE 4 END LIMIT 1;", nativeQuery = true) RainyDayHandlerStatus findRainyDayHandler(@Param("flowName") String flowName, @Param("serviceType") String serviceType, @Param("vnfType") String vnfType, |