diff options
Diffstat (limited to 'bpmn')
323 files changed, 8110 insertions, 2450 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy index b98e395228..f14e3dcc42 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory import org.onap.so.logger.ErrorCode @@ -134,13 +135,13 @@ class AaiUtil { } logger.debug("Cloud Region value for code='404' of " + backend + " is: " + regionId) }else{ - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Call AAI Cloud Region is NOT Successful.", "BPMN", ErrorCode.UnknownError.getValue()); throw new BpmnError("MSOWorkflowException") } }catch(Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception occured while getting the Cloud Reqion.", "BPMN", ErrorCode.UnknownError.getValue(), e.getMessage()); (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy index e0e85e9629..4df38edcc3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.logger.ErrorCode @@ -195,7 +196,7 @@ class AllottedResourceUtils { AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(aaiARPath).build()) getAAIClient().update(uri,allottedResource) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in updateAR.", "BPMN", ErrorCode.UnknownError.getValue(), e.getMessage()); exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error in updateAROrchStatus.' + e.getMessage()) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy index 4a59b9789a..c843cc35fe 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AppCClient.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.json.JsonUtils @@ -120,7 +121,7 @@ public class AppCClient extends AbstractServiceTaskProcessor{ appcMessage = client.getErrorMessage() } catch (BpmnError e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); appcMessage = e.getMessage() diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy index d5b0b31a39..2bf7298584 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.apache.commons.lang3.StringUtils import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONArray @@ -80,7 +81,7 @@ class CatalogDbUtils { } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in Querying Catalog DB", "BPMN", ErrorCode.UnknownError.getValue(), e.message); throw e @@ -118,7 +119,7 @@ class CatalogDbUtils { return getResponseFromCatalogDb(execution, endPoint) } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in Querying Catalog DB", "BPMN", ErrorCode.UnknownError.getValue(), e.message); throw e @@ -142,7 +143,7 @@ class CatalogDbUtils { } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in Querying Catalog DB", "BPMN", ErrorCode.UnknownError.getValue(), e.message); throw e @@ -168,7 +169,7 @@ class CatalogDbUtils { } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in Querying Catalog DB", "BPMN", ErrorCode.UnknownError.getValue(), e.message); throw e @@ -218,7 +219,7 @@ class CatalogDbUtils { logger.debug("Returning networks JSON: " + modelInfosString) } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in parsing Catalog DB Response", "BPMN", ErrorCode.UnknownError.getValue(), e.message); } @@ -297,7 +298,7 @@ class CatalogDbUtils { logger.debug("Returning vnfs JSON: " + modelInfosString) } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in parsing Catalog DB Response", "BPMN", ErrorCode.UnknownError.getValue(), e.message); } @@ -351,7 +352,7 @@ class CatalogDbUtils { logger.debug("Returning allottedResources JSON: " + modelInfosString) } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in parsing Catalog DB Response", "BPMN", ErrorCode.UnknownError.getValue(), e.message); } @@ -380,7 +381,7 @@ class CatalogDbUtils { logger.debug("Returning serviceResources JSON: " + serviceResourcesObject.toString()) } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in parsing Catalog DB Response", "BPMN", ErrorCode.UnknownError.getValue(), e.message); } @@ -428,7 +429,7 @@ class CatalogDbUtils { modelJson.put("modelInfo", modelInfo) } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception while parsing model information", "BPMN", ErrorCode.UnknownError.getValue(), e.message); } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy index a9e01c7191..7e1280729c 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcess.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.logger.ErrorCode @@ -74,7 +75,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + ' ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) } @@ -236,7 +237,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) @@ -269,7 +270,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { logger.debug("Rethrowing MSOWorkflowException") throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) @@ -307,7 +308,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy index 6a82512d88..b666c8d19d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupName.groovy @@ -24,70 +24,67 @@ package org.onap.so.bpmn.common.scripts -import joptsimple.internal.Strings -import org.onap.so.bpmn.common.scripts.ExceptionUtil -import org.onap.so.logger.ErrorCode -import org.springframework.http.HttpStatus - -import javax.ws.rs.core.UriBuilder - import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroup import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.constants.Defaults +import org.onap.so.logger.ErrorCode +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory +import org.springframework.http.HttpStatus +import joptsimple.internal.Strings public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger( ConfirmVolumeGroupName.class); - def static final Prefix = "CVGN_" - private final ExceptionUtil exceptionUtil - - ConfirmVolumeGroupName(ExceptionUtil exceptionUtil) { - this.exceptionUtil = exceptionUtil - } - - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - execution.setVariable("CVGN_volumeGroupId",null) - execution.setVariable("CVGN_volumeGroupName",null) - execution.setVariable("CVGN_aicCloudRegion", null) - execution.setVariable("CVGN_volumeGroupGetEndpoint",null) - - // ConfirmVolumeGroupName workflow response variable placeholders - execution.setVariable("CVGN_volumeGroupNameMatches", false) - execution.setVariable("CVGN_queryVolumeGroupResponseCode",null) - execution.setVariable("CVGN_queryVolumeGroupResponse","") - execution.setVariable("CVGN_ResponseCode",null) - execution.setVariable("RollbackData", null) - } - - // store the incoming data in the flow DelegateExecution - public void preProcessRequest(DelegateExecution execution) { - def volumeGroupId = execution.getVariable("ConfirmVolumeGroupName_volumeGroupId") - def volumeGroupName= execution.getVariable("ConfirmVolumeGroupName_volumeGroupName") - def aicCloudRegion = execution.getVariable("ConfirmVolumeGroupName_aicCloudRegion") - - initProcessVariables(execution) - execution.setVariable("CVGN_volumeGroupId", volumeGroupId) - execution.setVariable("CVGN_volumeGroupName", volumeGroupName) - execution.setVariable("CVGN_aicCloudRegion", aicCloudRegion) - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) - execution.setVariable("CVGN_volumeGroupGetEndpoint", uri) - } - - // send a GET request to AA&I to retrieve the Volume information based on volume-group-id - // expect a 200 response with the information in the response body or a 404 if the volume group id does not exist - public void queryAAIForVolumeGroupId(DelegateExecution execution) { - AAIResourceUri resourceUri = execution.getVariable("CVGN_volumeGroupGetEndpoint") - - try { - Optional<VolumeGroup> volumeGroupOp = getAAIClient().get(VolumeGroup.class, resourceUri) + def static final Prefix = "CVGN_" + private final ExceptionUtil exceptionUtil + + ConfirmVolumeGroupName(ExceptionUtil exceptionUtil) { + this.exceptionUtil = exceptionUtil + } + + public void initProcessVariables(DelegateExecution execution) { + execution.setVariable("prefix",Prefix) + execution.setVariable("CVGN_volumeGroupId",null) + execution.setVariable("CVGN_volumeGroupName",null) + execution.setVariable("CVGN_aicCloudRegion", null) + execution.setVariable("CVGN_volumeGroupGetEndpoint",null) + + // ConfirmVolumeGroupName workflow response variable placeholders + execution.setVariable("CVGN_volumeGroupNameMatches", false) + execution.setVariable("CVGN_queryVolumeGroupResponseCode",null) + execution.setVariable("CVGN_queryVolumeGroupResponse","") + execution.setVariable("CVGN_ResponseCode",null) + execution.setVariable("RollbackData", null) + } + + // store the incoming data in the flow DelegateExecution + public void preProcessRequest(DelegateExecution execution) { + def volumeGroupId = execution.getVariable("ConfirmVolumeGroupName_volumeGroupId") + def volumeGroupName= execution.getVariable("ConfirmVolumeGroupName_volumeGroupName") + def aicCloudRegion = execution.getVariable("ConfirmVolumeGroupName_aicCloudRegion") + + initProcessVariables(execution) + execution.setVariable("CVGN_volumeGroupId", volumeGroupId) + execution.setVariable("CVGN_volumeGroupName", volumeGroupName) + execution.setVariable("CVGN_aicCloudRegion", aicCloudRegion) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), aicCloudRegion, volumeGroupId) + execution.setVariable("CVGN_volumeGroupGetEndpoint", uri) + } + + // send a GET request to AA&I to retrieve the Volume information based on volume-group-id + // expect a 200 response with the information in the response body or a 404 if the volume group id does not exist + public void queryAAIForVolumeGroupId(DelegateExecution execution) { + AAIResourceUri resourceUri = execution.getVariable("CVGN_volumeGroupGetEndpoint") + + try { + Optional<VolumeGroup> volumeGroupOp = getAAIClient().get(VolumeGroup.class, resourceUri) if(volumeGroupOp.isPresent()){ execution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.OK.value()) execution.setVariable("CVGN_queryVolumeGroupResponse", volumeGroupOp.get()) @@ -95,60 +92,60 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ execution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.NOT_FOUND.value()) execution.setVariable("CVGN_queryVolumeGroupResponse", "Volume Group not Found!") } - } catch (Exception ex) { - logger.debug("Exception occurred while executing AAI GET:" + ex.getMessage()) - execution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.INTERNAL_SERVER_ERROR.value()) - execution.setVariable("CVGN_queryVolumeGroupResponse", "AAI GET Failed:" + ex.getMessage()) - exceptionUtil.buildAndThrowWorkflowException(execution, HttpStatus.INTERNAL_SERVER_ERROR.value(), "AAI GET Failed") - } - } + } catch (Exception ex) { + logger.debug("Exception occurred while executing AAI GET:" + ex.getMessage()) + execution.setVariable("CVGN_queryVolumeGroupResponseCode", HttpStatus.INTERNAL_SERVER_ERROR.value()) + execution.setVariable("CVGN_queryVolumeGroupResponse", "AAI GET Failed:" + ex.getMessage()) + exceptionUtil.buildAndThrowWorkflowException(execution, HttpStatus.INTERNAL_SERVER_ERROR.value(), "AAI GET Failed") + } + } - // process the result from queryAAIVolumeGroupId() + // process the result from queryAAIVolumeGroupId() - public void checkAAIQueryResult(DelegateExecution execution) { + public void checkAAIQueryResult(DelegateExecution execution) { def actualVolumeGroupName = "" if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == HttpStatus.NOT_FOUND.value()) { - logger.debug('volumeGroupId does not exist in AAI') - } - else if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == HttpStatus.OK.value()) { + logger.debug('volumeGroupId does not exist in AAI') + } + else if (execution.getVariable("CVGN_queryVolumeGroupResponseCode") == HttpStatus.OK.value()) { VolumeGroup volumeGroup = execution.getVariable("CVGN_queryVolumeGroupResponse") if (!Strings.isNullOrEmpty(volumeGroup.getVolumeGroupName())) { actualVolumeGroupName = volumeGroup.getVolumeGroupName() - logger.debug("volumeGroupId exists in AAI") - } - } - execution.setVariable("CVGN_volumeGroupNameMatches", false) - def volumeGroupName = execution.getVariable("CVGN_volumeGroupName") - - if (!actualVolumeGroupName.isEmpty() && volumeGroupName.equals(actualVolumeGroupName)) { - logger.debug('Volume Group Name Matches AAI records') - execution.setVariable("CVGN_volumeGroupNameMatches", true) - } - } - - - // generates a WorkflowException if the A&AI query returns a response code other than 200/404 - public void handleAAIQueryFailure(DelegateExecution execution) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "Error occurred attempting to query AAI, Response Code " + execution.getVariable("CVGN_queryVolumeGroupResponseCode"), - "BPMN", ErrorCode.UnknownError.getValue(), - "ErrorResponse is:\n" + execution.getVariable("CVGN_queryVolumeGroupResponse")); - } - - // generates a WorkflowException if the volume group name does not match AAI record for this volume group - public void handleVolumeGroupNameNoMatch(DelegateExecution execution) { - def errorNotAssociated = "Error occurred - volume group id ${execution.getVariable('CVGN_volumeGroupId')} " + - "is not associated with ${execution.getVariable('CVGN_volumeGroupName')}" - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), errorNotAssociated, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, errorNotAssociated) - } - - // sends a successful WorkflowResponse - public void reportSuccess(DelegateExecution execution) { - logger.debug("Sending 200 back to the caller") - def responseXML = "" - execution.setVariable("WorkflowResponse", responseXML) - } + logger.debug("volumeGroupId exists in AAI") + } + } + execution.setVariable("CVGN_volumeGroupNameMatches", false) + def volumeGroupName = execution.getVariable("CVGN_volumeGroupName") + + if (!actualVolumeGroupName.isEmpty() && volumeGroupName.equals(actualVolumeGroupName)) { + logger.debug('Volume Group Name Matches AAI records') + execution.setVariable("CVGN_volumeGroupNameMatches", true) + } + } + + + // generates a WorkflowException if the A&AI query returns a response code other than 200/404 + public void handleAAIQueryFailure(DelegateExecution execution) { + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + "Error occurred attempting to query AAI, Response Code " + execution.getVariable("CVGN_queryVolumeGroupResponseCode"), + "BPMN", ErrorCode.UnknownError.getValue(), + "ErrorResponse is:\n" + execution.getVariable("CVGN_queryVolumeGroupResponse")); + } + + // generates a WorkflowException if the volume group name does not match AAI record for this volume group + public void handleVolumeGroupNameNoMatch(DelegateExecution execution) { + def errorNotAssociated = "Error occurred - volume group id ${execution.getVariable('CVGN_volumeGroupId')} " + + "is not associated with ${execution.getVariable('CVGN_volumeGroupName')}" + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), errorNotAssociated, "BPMN", + ErrorCode.UnknownError.getValue()); + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, errorNotAssociated) + } + + // sends a successful WorkflowResponse + public void reportSuccess(DelegateExecution execution) { + logger.debug("Sending 200 back to the caller") + def responseXML = "" + execution.setVariable("WorkflowResponse", responseXML) + } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy index 7c1c0a0490..569d4b75b9 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroup @@ -105,7 +106,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ }catch(BpmnError b){ throw b }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing queryAAIForVolumeGroup.", "BPMN", ErrorCode.UnknownError.getValue(), e.getMessage()); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in preProcessRequest.") @@ -127,7 +128,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ logger.debug("Volume Heat Stack Id is: " + heatStackId) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing assignVolumeHeatId.", "BPMN", ErrorCode.UnknownError.getValue(), e); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in assignVolumeHeatId.") @@ -147,7 +148,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ exceptionUtil.buildWorkflowException(execution, errorCode, errorMessage) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing assignWorkflowException.", "BPMN", ErrorCode.UnknownError.getValue(), e); } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy index e9e7d1ed7c..163e914238 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.apache.commons.lang.StringUtils import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf @@ -423,7 +424,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ // generates a WorkflowException when the A&AI query returns a response code other than 200 or 404 public void handleAAIQueryFailure(DelegateExecution execution) { - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Error occurred attempting to query AAI, Response Code " + execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") + ", Error Response " + execution.getVariable("CAAIVfMod_queryGenericVnfResponse"), "BPMN", ErrorCode.UnknownError.getValue()); int code = execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") @@ -475,7 +476,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ errorCode = 2000 } - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Error occurred during CreateAAIVfModule flow", "BPMN", ErrorCode.UnknownError.getValue(), errorResponse); exceptionUtil.buildAndThrowWorkflowException(execution, errorCode, errorResponse) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy index 4bce23eff7..4d57b1b26f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModule.groovy @@ -21,6 +21,8 @@ */ package org.onap.so.bpmn.common.scripts + +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf import org.onap.so.client.aai.AAIObjectType @@ -204,7 +206,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // generates a WorkflowException if the A&AI query returns a response code other than 200 public void handleAAIQueryFailure(DelegateExecution execution) { - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Error occurred attempting to query AAI, Response Code " + execution.getVariable("DAAIVfMod_queryGenericVnfResponseCode") + ", Error Response " + execution.getVariable("DAAIVfMod_queryGenericVnfResponse"), "BPMN", ErrorCode.UnknownError.getValue()); def errorCode = 5000 @@ -251,7 +253,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ } } - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Error occurred during DeleteAAIVfModule flow", "BPMN", ErrorCode.UnknownError.getValue(), errorResponse); exceptionUtil.buildAndThrowWorkflowException(execution, errorCode, errorResponse) @@ -261,7 +263,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // generates a WorkflowException if // - the A&AI Generic Vnf DELETE returns a response code other than 200 public void handleDeleteGenericVnfFailure(DelegateExecution execution) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "AAI error occurred deleting the Generic Vnf", "BPMN", ErrorCode.UnknownError.getValue(), execution.getVariable("DAAIVfMod_deleteGenericVnfResponse")); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy index 30dbeb09d5..d95dbe2184 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode import static org.apache.commons.lang3.StringUtils.* @@ -91,7 +92,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { buildWorkflowException(execution, 5000, modifiedErrorMessage) wfex = execution.getVariable("WorkflowException") - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", ErrorCode.UnknownError.getValue(), wfex.errorMessage); return wfex } else { @@ -104,7 +105,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { logger.debug("mappedErrorMessage " + mappedErrorMessage) wfex = execution.getVariable("WorkflowException") - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", ErrorCode.UnknownError.getValue(), wfex.errorMessage); return wfex } catch(Exception ex) { diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy index 2ceec3cb44..ed849755b7 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/FalloutHandler.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.logger.ErrorCode @@ -97,7 +98,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { execution.setVariable("FH_ResponseCode", "") } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) @@ -210,7 +211,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { execution.setVariable("FH_content_type", "text/xml") } } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in" + method) @@ -244,7 +245,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { execution.setVariable("FH_updateRequestPayload", payload) return execution.getVariable("FH_updateRequestPayload") } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) @@ -275,7 +276,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { logger.debug("updateRequestInfraPayload: " + payload) return execution.getVariable("FH_updateRequestInfraPayload") } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) @@ -306,7 +307,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { logger.debug("updateRequestGammaPayload: " + payload) return execution.getVariable("FH_updateRequestGammaPayload") } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) @@ -335,7 +336,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { logger.debug("updateResponseStatusPayload: " + payload) return execution.getVariable("FH_updateResponseStatusPayload") } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) @@ -355,7 +356,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { def errorCode = responseCode == null ? 7000 : 7020 // exceptionUtil.buildWorkflowException(execution, errorCode, errorMessage) } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) @@ -390,7 +391,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { logger.debug("FalloutHandlerResponse =\n" + falloutHandlerResponse) } catch (Exception e) { // Do NOT throw WorkflowException! - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy index f008130c32..3008f77b62 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.client.HttpClientFactory import org.onap.so.logger.ErrorCode @@ -158,7 +159,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAI(): ' + e.getMessage()) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy index 27fe33f5ea..ef4291d18f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode; import static org.apache.commons.lang3.StringUtils.*; @@ -289,7 +290,7 @@ public class ManualHandling extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) @@ -341,11 +342,11 @@ public class ManualHandling extends AbstractServiceTaskProcessor { } catch (BpmnError e) { msg = "BPMN error in createAOTSTicket " + ex.getMessage() - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); } catch (Exception ex){ msg = "Exception in createAOTSTicket " + ex.getMessage() - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); } logger.trace("Exit createAOTSTicket of ManualHandling ") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy index f371ccef4d..a2f5dfbffe 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/MsoUtils.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode import java.text.SimpleDateFormat @@ -294,10 +295,10 @@ class MsoUtils { if ("INFO"==logmode) { logger.info(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), logtxt, "BPMN"); } else if ("WARN"==logmode) { - logger.warn ("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), logtxt, "BPMN", + logger.warn (LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_WARNING.toString(), logtxt, "BPMN", ErrorCode.UnknownError.getValue(), logtxt); } else if ("ERROR"==logmode) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), logtxt, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), logtxt, "BPMN", ErrorCode.UnknownError.getValue(), logtxt); } else { logger.debug(logtxt); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy index a0da6870ae..39e6db4d3f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ReceiveWorkflowMessage.groovy @@ -20,8 +20,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.scripts; +package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor; import groovy.json.* import org.apache.commons.lang3.* @@ -66,7 +67,7 @@ public void preProcessRequest (DelegateExecution execution) { if ((timeout == null) || (timeout.isEmpty())) { String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_timeout\'' logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -77,7 +78,7 @@ public void preProcessRequest (DelegateExecution execution) { if ((messageType == null) || (messageType.isEmpty())) { String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_messageType\'' logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -88,7 +89,7 @@ public void preProcessRequest (DelegateExecution execution) { if ((correlator == null) || (correlator.isEmpty())) { String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_correlator\'' logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -100,7 +101,7 @@ public void preProcessRequest (DelegateExecution execution) { } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy index a7bb707dff..f013fa8698 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapter.groovy @@ -20,7 +20,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.scripts; +package org.onap.so.bpmn.common.scripts + +import org.onap.so.logger.LoggingAnchor; import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.logger.ErrorCode; @@ -73,7 +75,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution)) execution.setVariable("BasicAuthHeaderValue",encodedString) } catch (IOException ex) { - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Unable to encode username password string", "BPMN", ErrorCode.UnknownError.getValue()); } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy index fdd53b2f05..449f4e3222 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory import org.onap.so.logger.ErrorCode @@ -86,7 +87,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { if (sdncAdapterEndpoint == null || sdncAdapterEndpoint.isEmpty()) { String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined' logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -107,7 +108,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { if (sdncRequestId == null || sdncRequestId.isEmpty()) { String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -122,7 +123,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { if (bpNotificationUrl == null || bpNotificationUrl.isEmpty()) { String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -139,7 +140,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { } else { String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -154,7 +155,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { if (basicAuthValue == null || basicAuthValue.isEmpty()) { logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined") - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", ErrorCode.UnknownError.getValue()); } else { @@ -163,7 +164,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString) } catch (IOException ex) { logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter") - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", "BPMN", ErrorCode.UnknownError.getValue(), ex); } @@ -195,7 +196,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -243,7 +244,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { } else { String msg = 'Unsupported HTTP method "' + sdncAdapterMethod + '" in ' + method + ": " + e logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -257,7 +258,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg, e) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -368,7 +369,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -394,7 +395,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy index e56091ad65..62c7bb5adf 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode import java.text.SimpleDateFormat @@ -85,7 +86,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { if (sdncAdapterEndpoint == null || sdncAdapterEndpoint.isEmpty()) { String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined' logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -106,7 +107,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { if (sdncRequestId == null || sdncRequestId.isEmpty()) { String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -121,7 +122,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { if (bpNotificationUrl == null || bpNotificationUrl.isEmpty()) { String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -132,7 +133,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { } else { String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -150,7 +151,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { if (basicAuthValue == null || basicAuthValue.isEmpty()) { logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined") - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", ErrorCode.UnknownError.getValue()); } else { @@ -159,7 +160,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString) } catch (IOException ex) { logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter") - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", "BPMN", ErrorCode.UnknownError.getValue(), ex); } @@ -191,7 +192,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy index eb832224db..f24eda813d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtils.groovy @@ -20,8 +20,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.scripts; +package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.L3Network @@ -257,7 +258,7 @@ class SDNCAdapterUtils { def callbackUrl = (String)UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution) if (callbackUrl == null || callbackUrl.trim() == "") { - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'mso:workflow:sdncadapter:callback URN is not set', "BPMN", ErrorCode.UnknownError.getValue()); workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code? @@ -395,7 +396,7 @@ class SDNCAdapterUtils { def callbackUrl = (String)UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution) if (callbackUrl == null || callbackUrl.trim() == "") { - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'mso:workflow:sdncadapter:callback URN is not set', "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request") @@ -468,7 +469,7 @@ class SDNCAdapterUtils { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error") @@ -973,7 +974,7 @@ class SDNCAdapterUtils { } }else { - logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING, + logger.warn(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_WARNING, 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ', "BPMN", ErrorCode.UnknownError, 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ') @@ -983,7 +984,7 @@ class SDNCAdapterUtils { } if (response == null || response.trim().equals("")) { - logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING, + logger.warn(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_WARNING, 'sdncAdapter workflow response is empty', "BPMN", ErrorCode.UnknownError, 'sdncAdapter workflow response is empty') execution.setVariable("L3HLAB_rollback", true) @@ -996,7 +997,7 @@ class SDNCAdapterUtils { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught ' + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught ' + 'exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable(prefix+"ResponseCode",400) execution.setVariable("L3HLAB_rollback", true) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy index 615c977a1e..30964aa4ec 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtil.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.DelegateExecution import org.apache.commons.lang3.* import org.onap.so.logger.ErrorCode @@ -215,7 +216,7 @@ class TrinityExceptionUtil { if(message != null) { execution.setVariable(prefix+"ErrorResponse",message) - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", ErrorCode.UnknownError.getValue(), execution.getVariable(prefix+"ErrorResponse")); return message @@ -311,7 +312,7 @@ class TrinityExceptionUtil { execution.setVariable(prefix+"err", myErr) execution.setVariable(prefix+"errTxt", messageTxt) execution.setVariable(prefix+"errVariables", msgVars) - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", ErrorCode.UnknownError.getValue(), execution.getVariable(prefix+"ErrorResponse")); return message diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index ebab6ad0ac..8f409fa13e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf @@ -182,7 +183,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { if (newPersonaModelId != null || newPersonaModelVersion != null) { if (newPersonaModelId != genericVnf.getModelInvariantId()) { def msg = 'Can\'t update Generic VNF ' + vnfId + ' since there is \'persona-model-id\' mismatch between the current and new values' - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()) throw new Exception(msg) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy index e261fb9fdd..20aeb11c5f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VfModuleBase.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode; import javax.xml.parsers.DocumentBuilder @@ -110,7 +111,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { } } } catch (Exception e) { - logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), + logger.warn(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_WARNING.toString(), 'Exception transforming network params to vnfNetworks', "BPMN", ErrorCode.UnknownError.getValue(), 'Exception is: \n' + e); } @@ -149,7 +150,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { entries = entries + entry } } catch (Exception e) { - logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), + logger.warn(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_WARNING.toString(), 'Exception transforming params to entries', "BPMN", ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e); } @@ -195,7 +196,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { } } } catch (Exception e) { - logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), + logger.warn(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_WARNING.toString(), 'Exception transforming params to entries', "BPMN", ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e); } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy index 9215eabc57..a769eca3a1 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory import org.onap.so.logger.ErrorCode @@ -78,7 +79,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (messageId == null || messageId.isEmpty()) { String msg = getProcessKey(execution) + ': no messageId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -92,7 +93,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (notificationUrl == null || notificationUrl.isEmpty()) { String msg = getProcessKey(execution) + ': no notificationUrl in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -106,7 +107,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (vnfAdapterEndpoint == null || vnfAdapterEndpoint.isEmpty()) { String msg = getProcessKey(execution) + ': mso:adapters:vnf:rest:endpoint URN mapping is not defined' - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -124,7 +125,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (vnfId == null || vnfId.isEmpty()) { String msg = getProcessKey(execution) + ': no vnfId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -137,7 +138,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (vnfId == null || vnfId.isEmpty()) { String msg = getProcessKey(execution) + ': no vnfId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -146,7 +147,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (vfModuleId == null || vfModuleId.isEmpty()) { String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -160,7 +161,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (vnfId == null || vnfId.isEmpty()) { String msg = getProcessKey(execution) + ': no vnfId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -169,7 +170,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (vfModuleId == null || vfModuleId.isEmpty()) { String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -183,7 +184,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (vfModuleRollbackNode == null) { String msg = getProcessKey(execution) + ': no vfModuleRollback in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -192,7 +193,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (vnfId == null || vnfId.isEmpty()) { String msg = getProcessKey(execution) + ': no vnfId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -201,7 +202,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (vfModuleId == null || vfModuleId.isEmpty()) { String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -222,7 +223,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (volumeGroupId == null || volumeGroupId.isEmpty()) { String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -238,7 +239,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (volumeGroupId == null || volumeGroupId.isEmpty()) { String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -254,7 +255,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (volumeGroupId == null || volumeGroupId.isEmpty()) { String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -267,7 +268,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { } else { String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -284,7 +285,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) if (basicAuthValue == null || basicAuthValue.isEmpty()) { - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", ErrorCode.UnknownError.getValue()); } else { @@ -292,7 +293,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution)) execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString) } catch (IOException ex) { - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": Unable to encode BasicAuth credentials for VnfAdapter", "BPMN", ErrorCode.UnknownError.getValue(), ex); } @@ -303,7 +304,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { throw e } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) @@ -355,7 +356,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { response = httpClient.delete(vnfAdapterRequest) } else { String msg = 'Unsupported HTTP method "' + vnfAdapterMethod + '" in ' + method + ": " + e - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -368,7 +369,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { throw e } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy index c947bf2e65..6cfa2a1a64 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.core.WorkflowException @@ -86,7 +87,7 @@ class VnfAdapterUtils { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, 'Internal Error- Unable to validate VNF Response ' + e.getMessage()) diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BBConstants.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BBConstants.java new file mode 100644 index 0000000000..49ccc7b4a8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BBConstants.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common; + +public class BBConstants { + public static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow"; + public static final String G_ACTION = "requestAction"; + public static final String G_CURRENT_SEQUENCE = "gCurrentSequence"; + public static final String G_REQUEST_ID = "mso-request-id"; + public static final String G_BPMN_REQUEST = "bpmnRequest"; + public static final String G_ALACARTE = "aLaCarte"; + public static final String G_APIVERSION = "apiVersion"; + public static final String G_URI = "requestUri"; + public static final String G_ISTOPLEVELFLOW = "isTopLevelFlow"; + public static final String G_SERVICE_TYPE = "serviceType"; + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java index c087d586e7..248f3b5f1a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java @@ -9,7 +9,7 @@ * 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. @@ -39,4 +39,6 @@ public interface BuildingBlockExecution { public Map<ResourceKey, String> getLookupMap(); public String getFlowToBeCalled(); + + public int getCurrentSequence(); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java index 31fef7c6f7..9aed5e9408 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java @@ -113,8 +113,9 @@ public class DelegateExecutionImpl implements BuildingBlockExecution, Serializab } @JsonIgnore - public DelegateExecution getDelegateExecution() { - return this.execution; + @Override + public int getCurrentSequence() { + return this.get("gCurrentSequence"); } public void setDelegateExecution(final DelegateExecution execution) { @@ -126,6 +127,11 @@ public class DelegateExecutionImpl implements BuildingBlockExecution, Serializab }); } + @JsonIgnore + public DelegateExecution getDelegateExecution() { + return this.execution; + } + @SuppressWarnings("unchecked") protected <T> T get(final String key) { final Object value = this.execution.getVariable(key); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java new file mode 100644 index 0000000000..3c36052dca --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.listener; + +import java.lang.annotation.Annotation; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import javax.annotation.Priority; +import org.onap.so.client.exception.ExceptionBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; + +public abstract class ListenerRunner { + + @Autowired + protected ApplicationContext context; + + @Autowired + protected ExceptionBuilder exceptionBuilder; + + protected <T> List<T> filterListeners(List<T> validators, Predicate<T> predicate) { + return validators.stream().filter(item -> { + return !item.getClass().isAnnotationPresent(Skip.class) && predicate.test(item); + }).sorted(Comparator.comparing(item -> { + Priority p = Optional.ofNullable(item.getClass().getAnnotation(Priority.class)).orElse(new Priority() { + public int value() { + return 1000; + } + + @Override + public Class<? extends Annotation> annotationType() { + return Priority.class; + } + }); + return p.value(); + })).collect(Collectors.toList()); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/Skip.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java index fe03a10795..a0543fd3cc 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/Skip.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulator.java new file mode 100644 index 0000000000..5e2882cb5b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulator.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.listener.flowmanipulator; + +import java.util.List; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; + +public interface FlowManipulator { + + public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution); + + public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, + BuildingBlockExecution execution); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java new file mode 100644 index 0000000000..5f4dc871fb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.listener.flowmanipulator; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.annotation.PostConstruct; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.ListenerRunner; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class FlowManipulatorListenerRunner extends ListenerRunner { + + private static Logger logger = LoggerFactory.getLogger(FlowManipulatorListenerRunner.class); + + protected List<FlowManipulator> flowManipulators; + + @PostConstruct + protected void init() { + + flowManipulators = new ArrayList<>( + Optional.ofNullable(context.getBeansOfType(FlowManipulator.class)).orElse(new HashMap<>()).values()); + + } + + public void modifyFlows(List<ExecuteBuildingBlock> flowsToExecute, BuildingBlockExecution execution) { + + ExecuteBuildingBlock currentBB = flowsToExecute.get(execution.getCurrentSequence()); + List<FlowManipulator> filtered = filterListeners(flowManipulators, + (item -> item.shouldRunFor(currentBB.getBuildingBlock().getBpmnFlowName(), + execution.getCurrentSequence() == 0, execution))); + + logger.info("Running flow manipulators:\n{}", + filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); + filtered.forEach(item -> item.run(flowsToExecute, currentBB, execution)); + + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/BuildingBlockValidatorRunner.java index a8e43c51e5..78d897fd87 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/BuildingBlockValidatorRunner.java @@ -18,26 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; -import java.lang.annotation.Annotation; import java.util.ArrayList; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import javax.annotation.PostConstruct; -import javax.annotation.Priority; -import org.camunda.bpm.engine.delegate.BpmnError; -import org.javatuples.Pair; -import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.client.exception.ExceptionBuilder; -import org.reflections.Reflections; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; @@ -45,9 +32,9 @@ import org.springframework.stereotype.Component; * Controls running all pre and post validation for building blocks. * * To define a validation you must make it a spring bean and implement either - * {@link org.onap.so.bpmn.common.validation.PreBuildingBlockValidator} or - * {@link org.onap.so.bpmn.common.validation.PostBuildingBlockValidator} your validation will automatically be run by - * this class. + * {@link org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator} or + * {@link org.onap.so.bpmn.common.listener.validation.PostBuildingBlockValidator} your validation will automatically be + * run by this class. * */ @Component diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidator.java index 66a8de9f8b..657e1d9539 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidator.java @@ -18,10 +18,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Optional; -import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; public interface FlowValidator { @@ -30,6 +29,7 @@ public interface FlowValidator { * Should this validator run for given bb * * @return + * */ public boolean shouldRunFor(String bbName); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java index 0bdf4e35a2..040522b576 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidatorRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java @@ -18,25 +18,19 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; -import java.lang.annotation.Annotation; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import javax.annotation.Priority; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.client.exception.ExceptionBuilder; -import org.reflections.Reflections; +import org.onap.so.bpmn.common.listener.ListenerRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; @@ -49,14 +43,9 @@ import org.springframework.stereotype.Component; * */ @Component -public abstract class FlowValidatorRunner<S extends FlowValidator, E extends FlowValidator> { +public abstract class FlowValidatorRunner<S extends FlowValidator, E extends FlowValidator> extends ListenerRunner { private static Logger logger = LoggerFactory.getLogger(FlowValidatorRunner.class); - @Autowired - protected ApplicationContext context; - - @Autowired - protected ExceptionBuilder exceptionBuilder; protected List<S> preFlowValidators; protected List<E> postFlowValidators; @@ -114,7 +103,7 @@ public abstract class FlowValidatorRunner<S extends FlowValidator, E extends Flo protected List<Pair<String, Optional<String>>> runValidations(List<? extends FlowValidator> validators, String bbName, BuildingBlockExecution execution) { - List<FlowValidator> filtered = filterValidators(validators, bbName); + List<? extends FlowValidator> filtered = filterListeners(validators, (item -> item.shouldRunFor(bbName))); List<Pair<String, Optional<String>>> results = new ArrayList<>(); filtered.forEach(item -> results.add(new Pair<>(item.getClass().getName(), item.validate(execution)))); @@ -122,38 +111,6 @@ public abstract class FlowValidatorRunner<S extends FlowValidator, E extends Flo return results.stream().filter(item -> item.getValue1().isPresent()).collect(Collectors.toList()); } - protected List<FlowValidator> filterValidators(List<? extends FlowValidator> validators, String bbName) { - return validators.stream().filter(item -> { - return !item.getClass().isAnnotationPresent(Skip.class) && item.shouldRunFor(bbName); - }).sorted(Comparator.comparing(item -> { - Priority p = Optional.ofNullable(item.getClass().getAnnotation(Priority.class)).orElse(new Priority() { - public int value() { - return 1000; - } - - @Override - public Class<? extends Annotation> annotationType() { - return Priority.class; - } - }); - return p.value(); - })).collect(Collectors.toList()); - } - - protected <T> List<T> buildalidatorList(Reflections reflections, Class<T> clazz) { - List<T> result = new ArrayList<>(); - try { - for (Class<? extends T> klass : reflections.getSubTypesOf(clazz)) { - result.add(klass.newInstance()); - } - } catch (InstantiationException | IllegalAccessException e) { - logger.error("failed to build validator list for {}", clazz.getName(), e); - throw new RuntimeException(e); - } - - return result; - } - protected abstract List<S> getPreFlowValidators(); protected abstract List<E> getPostFlowValidators(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostBuildingBlockValidator.java index f26a2ee479..75dc75de43 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostBuildingBlockValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostBuildingBlockValidator.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; public interface PostBuildingBlockValidator extends FlowValidator { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostWorkflowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostWorkflowValidator.java index 9070615a7a..7d5f68a482 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PostWorkflowValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PostWorkflowValidator.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; public interface PostWorkflowValidator extends FlowValidator { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreBuildingBlockValidator.java index fda687e072..fda2d264d8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreBuildingBlockValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreBuildingBlockValidator.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; public interface PreBuildingBlockValidator extends FlowValidator { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreWorkflowValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreWorkflowValidator.java index 0bfbf5602f..a8e8642058 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/PreWorkflowValidator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/PreWorkflowValidator.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; public interface PreWorkflowValidator extends FlowValidator { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowValidatorRunner.java index 6950618953..c6afa16ec2 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/WorkflowValidatorRunner.java @@ -18,25 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; -import java.lang.annotation.Annotation; import java.util.ArrayList; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import javax.annotation.PostConstruct; -import javax.annotation.Priority; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.javatuples.Pair; -import org.onap.so.client.exception.ExceptionBuilder; -import org.reflections.Reflections; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; @@ -44,9 +32,9 @@ import org.springframework.stereotype.Component; * Controls running all pre and post validation for workflows. * * To define a validation you must make it a spring bean and implement either - * {@link org.onap.so.bpmn.common.validation.PreWorkflowValidator} or - * {@link org.onap.so.bpmn.common.validation.PostWorkflowValidator} your validation will automatically be run by this - * class. + * {@link org.onap.so.bpmn.common.listener.validation.PreWorkflowValidator} or + * {@link org.onap.so.bpmn.common.listener.validation.PostWorkflowValidator} your validation will automatically be run + * by this class. * */ @Component diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java index b9200e0640..c98c9ad5da 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java @@ -25,6 +25,7 @@ package org.onap.so.bpmn.common.recipe; import java.io.IOException; import java.security.GeneralSecurityException; import javax.xml.bind.DatatypeConverter; +import org.onap.so.logger.LoggingAnchor; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; @@ -62,16 +63,12 @@ public class BpmnRestClient { public static final String CAMUNDA_AUTH = "mso.camundaAuth"; - private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; @Autowired private UrnPropertiesReader urnPropertiesReader; private static boolean noProperties = true; - // because for NS it will take a long time the time out of the resouce will be 2 hours. - private static final String DEFAULT_TIME_OUT = "7200"; - - public synchronized final boolean getNoPropertiesState() { + public final synchronized boolean getNoPropertiesState() { return noProperties; } @@ -93,7 +90,7 @@ public class BpmnRestClient { */ public HttpResponse post(String recipeUri, String requestId, int recipeTimeout, String requestAction, String serviceInstanceId, String serviceType, String requestDetails, String recipeParamXsd) - throws ClientProtocolException, IOException { + throws IOException { HttpClient client = HttpClientBuilder.create().build(); @@ -163,7 +160,7 @@ public class BpmnRestClient { BpmnParam recipeParamsInput = new BpmnParam(); BpmnIntegerParam recipeTimeoutInput = new BpmnIntegerParam(); recipeTimeoutInput.setValue(recipeTimeout); - // host.setValue(parseURL()); + requestIdInput.setValue(requestId); requestActionInput.setValue(requestAction); serviceInstanceIdInput.setValue(serviceInstanceId); @@ -181,7 +178,7 @@ public class BpmnRestClient { jsonReq = recipeRequest.toString(); logger.trace("request body is {}", jsonReq); } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.APIH_WARP_REQUEST.toString(), "Camunda", "wrapVIDRequest", + logger.error(LoggingAnchor.FIVE, MessageEnum.APIH_WARP_REQUEST.toString(), "Camunda", "wrapVIDRequest", ErrorCode.BusinessProcesssError.getValue(), "Error in APIH Warp request", e); } return jsonReq; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java index 340addcabf..91049a8d0c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java @@ -85,6 +85,30 @@ public class ResourceInput implements Serializable { @JsonProperty("operationType") private String operationType; + @JsonProperty("vfModelInfo") + private ModelInfo vfModelInfo; + + + @JsonProperty("vnf-Id") + private String vnfId; + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public ModelInfo getVfModelInfo() { + return vfModelInfo; + } + + public void setVfModelInfo(ModelInfo vfModelInfo) { + this.vfModelInfo = vfModelInfo; + } + + /** * @return Returns the requestsInputs. */ diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java new file mode 100644 index 0000000000..2b650e1eed --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java @@ -0,0 +1,173 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 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.onap.so.bpmn.common.resource; + +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +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 java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public class InstanceResourceList { + + private InstanceResourceList() { + throw new IllegalStateException("Utility class"); + } + + private static Map<String, List<List<GroupResource>>> convertUUIReqTOStd(final JsonObject reqInputJsonObj, + List<Resource> seqResourceList) { + + Map<String, List<List<GroupResource>>> normalizedRequest = new HashMap<>(); + Resource lastVfProcessed = null; + for (Resource r : seqResourceList) { + + if (r.getResourceType() == ResourceType.VNF) { + String pk = getPrimaryKey(r); + + JsonElement vfNode = reqInputJsonObj.get(pk); + lastVfProcessed = r; + + // if the service property is type of array then it + // means it is a VF resource + if (vfNode instanceof JsonArray) { + + for (int i = 0; i < ((JsonArray) vfNode).size(); i++) { + List<List<GroupResource>> groupsList = normalizedRequest.get(pk); + if (groupsList == null) { + groupsList = new ArrayList<>(); + normalizedRequest.put(pk, groupsList); + } + + groupsList.add(new ArrayList<>()); + } + } + + } else if (r.getResourceType() == ResourceType.GROUP) { + String sk = getPrimaryKey(r); + + // if sk is empty that means it is not list type + if (sk.isEmpty()) { + List<List<GroupResource>> vfList = normalizedRequest.get(getPrimaryKey(lastVfProcessed)); + for (List<GroupResource> grpList : vfList) { + grpList.add((GroupResource) r); + } + continue; + } + + String pk = getPrimaryKey(lastVfProcessed); + JsonArray vfs = reqInputJsonObj.getAsJsonArray(pk); + + for (int i = 0; i < vfs.size(); i++) { + + JsonElement vfcsNode = vfs.get(i).getAsJsonObject().get(sk); + if (vfcsNode instanceof JsonArray) { + + List<GroupResource> groupResources = normalizedRequest.get(pk).get(i); + + if (groupResources == null) { + groupResources = new ArrayList<>(); + normalizedRequest.get(pk).add(i, groupResources); + } + + for (int j = 0; j < ((JsonArray) vfcsNode).size(); j++) { + groupResources.add((GroupResource) r); + } + } + } + + } + } + return normalizedRequest; + } + + // this method returns key from resource input + // e.g. {\"sdwansite_emails\" : \"[sdwansiteresource_list(PK), INDEX, sdwansite_emails]|default\", + // ....} + // it will return sdwansiteresource_list + private static String getPrimaryKey(Resource resource) { + String resourceInput = ""; + if (resource instanceof VnfResource) { + resourceInput = ((VnfResource) resource).getResourceInput(); + } else if (resource instanceof GroupResource) { + resourceInput = ((GroupResource) resource).getVnfcs().get(0).getResourceInput(); + } + + Gson gson = new Gson(); + Type type = new TypeToken<Map<String, String>>() {}.getType(); + Map<String, String> map = gson.fromJson(resourceInput, type); + + if (map != null) { + Optional<String> pkOpt = map.values().stream().filter(e -> e.contains("[")).map(e -> e.replace("[", "")) + .map(e -> e.split(",")[0]).findFirst(); + + return pkOpt.isPresent() ? pkOpt.get() : ""; + } else { + // TODO: handle the case if VNF resource is not list + // e.g. { resourceInput + return ""; + } + } + + private static List<Resource> convertToInstanceResourceList(Map<String, List<List<GroupResource>>> normalizedReq, + List<Resource> seqResourceList) { + List<Resource> flatResourceList = new ArrayList<>(); + for (Resource r : seqResourceList) { + if (r.getResourceType() == ResourceType.VNF) { + String primaryKey = getPrimaryKey(r); + for (String pk : normalizedReq.keySet()) { + + if (primaryKey.equalsIgnoreCase(pk)) { + + List<List<GroupResource>> vfs = normalizedReq.get(pk); + + vfs.stream().forEach(e -> { + flatResourceList.add(r); + flatResourceList.addAll(e); + }); + } + } + } + } + return flatResourceList; + } + + public static List<Resource> getInstanceResourceList(final List<Resource> seqResourceList, + final String uuiRequest) { + + Gson gson = new Gson(); + JsonObject servJsonObject = gson.fromJson(uuiRequest, JsonObject.class); + JsonObject reqInputJsonObj = servJsonObject.getAsJsonObject("service").getAsJsonObject("parameters") + .getAsJsonObject("requestInputs"); + + // this will convert UUI request to normalized form + Map<String, List<List<GroupResource>>> normalizedRequest = convertUUIReqTOStd(reqInputJsonObj, seqResourceList); + return convertToInstanceResourceList(normalizedRequest, seqResourceList); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceLevel.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceLevel.java new file mode 100644 index 0000000000..a3c75dbd41 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceLevel.java @@ -0,0 +1,5 @@ +package org.onap.so.bpmn.common.resource; + +public enum ResourceLevel { + FIRST, SECOND +} 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 0dbf2c2a75..faa3d74dba 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 @@ -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. @@ -22,6 +22,9 @@ package org.onap.so.bpmn.common.resource; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import java.io.IOException; import java.lang.reflect.Type; import java.util.ArrayList; @@ -31,8 +34,13 @@ import java.util.List; import java.util.Map; import javax.ws.rs.core.Response; 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.json.JsonUtils; import org.onap.so.client.HttpClient; import org.onap.so.client.HttpClientFactory; @@ -47,14 +55,16 @@ import org.slf4j.LoggerFactory; public class ResourceRequestBuilder { - private static String CUSTOMIZATION_UUID = "cuserviceResourcesstomizationUUID"; - private static String SERVICE_URL_SERVICE_INSTANCE = "/v2/serviceResources"; private static Logger logger = LoggerFactory.getLogger(ResourceRequestBuilder.class); static JsonUtils jsonUtil = new JsonUtils(); + private ResourceRequestBuilder() { + throw new IllegalStateException("Utility class"); + } + public static List<String> getResourceSequence(String serviceUuid) { List<String> resourceSequence = new ArrayList(); @@ -82,133 +92,275 @@ public class ResourceRequestBuilder { * "requestInputs":{K,V} } <br> * * @param execution Execution context - * - * @param serviceUuid The service template uuid - * - * @param resourceCustomizationUuid The resource customization uuid - * - * @param serviceParameters the service parameters passed from the API - * + * + * @param resource The current Service Resource Object + * + * @param uuiServiceParameters 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) { - List<String> resourceList = - jsonUtil.StringArrayToList(execution, (String) JsonUtils.getJsonValue(serviceParameters, "resources")); + public static String buildResourceRequestParameters(Execution execution, Resource resource, + 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 (resource.getResourceType() == ResourceType.VNF) { + for (String eachResource : resourceList) { + String resCusUuid = JsonUtils.getJsonValue(eachResource, "resourceCustomizationUuid"); + if ((null != resCusUuid) && resCusUuid.equals(resource.getModelInfo().getModelCustomizationUuid())) { + String resourceParameters = JsonUtils.getJsonValue(eachResource, "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); - if (serviceInput == null) { - serviceInput = new HashMap(); + Map<String, Object> uuiRequestInputs = null; + if (JsonUtils.getJsonValue(uuiServiceParameters, "requestInputs") != null) { + uuiRequestInputs = + getJsonObject((String) JsonUtils.getJsonValue(uuiServiceParameters, "requestInputs"), Map.class); } - if (resourceInputsFromUuiMap == null) { - resourceInputsFromUuiMap = new HashMap(); + if (uuiRequestInputs == null) { + uuiRequestInputs = new HashMap(); } - Map<String, Object> resourceInputsFromServiceDeclaredLevel = - buildResouceRequest(serviceUuid, resourceCustomizationUuid, serviceInput); - resourceInputsFromUuiMap.putAll(resourceInputsFromServiceDeclaredLevel); - String resourceInputsStr = getJsonString(resourceInputsFromUuiMap); + Map<String, Object> resourceInputsAfterMerge = + ResourceRequestBuilder.buildResouceRequest(resource, uuiRequestInputs, currentVFData); + + String resourceInputsStr = getJsonString(resourceInputsAfterMerge); String result = "{\n" + "\"locationConstraints\":" + locationConstraints + ",\n" + "\"requestInputs\":" + resourceInputsStr + "\n" + "}"; return result; } @SuppressWarnings("unchecked") - public static Map<String, Object> buildResouceRequest(String serviceUuid, String resourceCustomizationUuid, - Map<String, Object> serviceInputs) { + public static Map<String, Object> buildResouceRequest(Resource resource, Map<String, Object> uuiRequestInputs, + Map<String, Object> currentVFData) { try { - Map<String, Object> serviceInstnace = getServiceInstnace(serviceUuid); - // find match of customization uuid in vnf - Map<String, Map<String, Object>> serviceResources = - (Map<String, Map<String, Object>>) serviceInstnace.get("serviceResources"); - - List<Map<String, Object>> serviceVnfCust = (List<Map<String, Object>>) serviceResources.get("serviceVnfs"); - String resourceInputStr = getResourceInputStr(serviceVnfCust, resourceCustomizationUuid); - - // find match in network resource - if (resourceInputStr == null) { - List<Map<String, Object>> serviceNetworkCust = - (List<Map<String, Object>>) serviceResources.get("serviceNetworks"); - resourceInputStr = getResourceInputStr(serviceNetworkCust, resourceCustomizationUuid); - - // find match in AR resource - if (resourceInputStr == null) { - List<Map<String, Object>> serviceArCust = - (List<Map<String, Object>>) serviceResources.get("serviceAllottedResources"); - resourceInputStr = getResourceInputStr(serviceArCust, resourceCustomizationUuid); - } + String resourceInputStr = null; + // Resource Level is considered as first level by default + ResourceLevel resourceLevel = ResourceLevel.FIRST; + switch (resource.getResourceType()) { + case VNF: + resourceInputStr = ((VnfResource) resource).getResourceInput(); + resourceLevel = ResourceLevel.FIRST; + break; + case GROUP: + resourceInputStr = ((GroupResource) resource).getVnfcs().get(0).getResourceInput(); + resourceLevel = ResourceLevel.SECOND; + break; } - if (resourceInputStr != null && !resourceInputStr.isEmpty()) { - return getResourceInput(resourceInputStr, serviceInputs); + if (StringUtils.isNotEmpty(resourceInputStr)) { + return getResourceInput(resourceInputStr, uuiRequestInputs, resourceLevel, currentVFData); } } catch (Exception e) { - logger.error("not able to retrieve service instance"); + logger.error("not able to retrieve service resource input ", e); } return new HashMap(); } - private static String getResourceInputStr(List<Map<String, Object>> resources, String resCustomizationUuid) { + // this method combines resource input with service input + private static Map<String, Object> getResourceInput(String resourceInputStr, Map<String, Object> uuiRequestInputs, + ResourceLevel resourceLevel, Map<String, Object> currentVFData) { + 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; + } + 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 = secondLevelIndex; + break; + + } + } + + + } - for (Map<String, Object> resource : resources) { - Map<String, String> modelInfo = (Map<String, String>) resource.get("modelInfo"); + // 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; + } + + if ((null != uuiServiceInput) && (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; + } + } + } + } + } + + if (!matchFound) { + if (split.length == 1) { // means value is empty e.g. "a":"key1|" + value = ""; + } else { + value = split[1]; + } + } + + } else { - if (modelInfo.get("modelCustomizationUuid").equalsIgnoreCase(resCustomizationUuid)) { - return (String) resource.get("resourceInput"); + // if not a list type + if ((null != uuiServiceInput) && (uuiServiceInput.containsKey(tmpKey))) { + value = (String) uuiServiceInput.get(tmpKey); + } else { + if (split.length == 1) { // means value is empty e.g. "a":"key1|" + value = ""; + } else { + value = split[1]; + } + } + } + + } + 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()); } + + return resourceInput; + + } catch (Exception e) { + logger.error("not able to parse and modify service resource input value against UUI ", e); } - return null; + return new HashMap(); } - // this method combines resource input with service input - private static Map<String, Object> getResourceInput(String resourceInputStr, Map<String, Object> serviceInputs) { - Gson gson = new Gson(); - Type type = new TypeToken<Map<String, String>>() {}.getType(); - Map<String, Object> resourceInput = gson.fromJson(resourceInputStr, type); - - // replace value if key is available in service input - for (String key : resourceInput.keySet()) { - String value = (String) resourceInput.get(key); - - if (value.contains("|")) { - // node it type of getinput - String[] split = value.split("\\|"); - String tmpKey = split[0]; - if (serviceInputs.containsKey(tmpKey)) { - value = (String) serviceInputs.get(tmpKey); - } else { - if (split.length == 1) { // means value is empty e.g. "a":"key1|" - value = ""; - } else { - value = split[1]; - } + private static int getIntValue(Object inputObj, int defaultValue) { + if (null != inputObj) { + if (inputObj instanceof Integer) { + return ((Integer) inputObj).intValue(); + } + if (StringUtils.isNotEmpty(inputObj.toString())) { + try { + int val = Integer.parseInt(inputObj.toString()); + return val; + } catch (NumberFormatException e) { + logger.warn("Unable to parse to int", e.getMessage()); } } - resourceInput.put(key, value); } - return resourceInput; + return defaultValue; } public static Map<String, Object> getServiceInstnace(String uuid) throws Exception { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java index 33fb78b306..047b1f3930 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java @@ -25,6 +25,7 @@ package org.onap.so.bpmn.common.workflow.context; import java.util.concurrent.DelayQueue; import java.util.concurrent.TimeUnit; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; @@ -130,7 +131,7 @@ public class WorkflowContextHolder { Thread.currentThread().interrupt(); } catch (Exception e) { logger.debug("WorkflowContextHolder timeout thread caught exception: ", e); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", ErrorCode.UnknownError.getValue(), "Error in WorkflowContextHolder timeout thread"); } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Configuration.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Configuration.java index dff5a57040..36262ec800 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Configuration.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Configuration.java @@ -78,6 +78,9 @@ public class Configuration implements Serializable, ShallowCopy<Configuration> { @JsonProperty("l-interface") private LInterface lInterface; + @JsonProperty("vpn-binding") + private VpnBinding vpnBinding; + public ModelInfoConfiguration getModelInfoConfiguration() { return modelInfoConfiguration; } @@ -222,6 +225,14 @@ public class Configuration implements Serializable, ShallowCopy<Configuration> { this.lInterface = lInterface; } + public VpnBinding getVpnBinding() { + return vpnBinding; + } + + public void setVpnBinding(VpnBinding vpnBinding) { + this.vpnBinding = vpnBinding; + } + @Override public boolean equals(final Object other) { if (!(other instanceof Configuration)) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java index 6c3a0c43ed..0803bed574 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java @@ -78,6 +78,12 @@ public class ServiceInstance implements Serializable, ShallowCopy<ServiceInstanc private ModelInfoServiceInstance modelInfoServiceInstance; @JsonProperty("instance-groups") private List<InstanceGroup> instanceGroups = new ArrayList<>(); + @JsonProperty("service-proxies") + private List<ServiceProxy> serviceProxies = new ArrayList<ServiceProxy>(); + + public void setServiceProxies(List<ServiceProxy> serviceProxies) { + this.serviceProxies = serviceProxies; + } public List<GenericVnf> getVnfs() { return vnfs; @@ -211,6 +217,10 @@ public class ServiceInstance implements Serializable, ShallowCopy<ServiceInstanc this.instanceGroups = instanceGroups; } + public List<ServiceProxy> getServiceProxies() { + return serviceProxies; + } + @Override public boolean equals(final Object other) { if (!(other instanceof ServiceInstance)) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java index 087edff7c0..08b1124726 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vnfc.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.servicedecomposition.bbobjects; import java.io.Serializable; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.java new file mode 100644 index 0000000000..1f7f970058 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapper.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects.wrappers; + +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.wrappers.exceptions.ServiceProxyNotFoundException; + +public class ServiceInstanceWrapper { + + private final ServiceInstance serviceInstance; + private static final String SERVICE_PROXY_TRANSPORT = "TRANSPORT"; + + public ServiceInstanceWrapper(ServiceInstance serviceInstance) { + this.serviceInstance = serviceInstance; + } + + public ServiceProxy getTransportServiceProxy() throws ServiceProxyNotFoundException { + ServiceProxy serviceProxy = null; + for (ServiceProxy sp : serviceInstance.getServiceProxies()) { + if (SERVICE_PROXY_TRANSPORT.equalsIgnoreCase(sp.getType())) { + serviceProxy = sp; + break; + } + } + if (serviceProxy == null) { + throw new ServiceProxyNotFoundException("Transport Service Proxy not found for service instance: " + + serviceInstance.getServiceInstanceId()); + } + return serviceProxy; + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.java new file mode 100644 index 0000000000..046299bb13 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/exceptions/ServiceProxyNotFoundException.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects.wrappers.exceptions; + +public class ServiceProxyNotFoundException extends Exception { + + private static final long serialVersionUID = 717577158109655720L; + + public ServiceProxyNotFoundException() { + super(); + } + + public ServiceProxyNotFoundException(String message) { + super(message); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java index af9eb525aa..f1de0cc6f6 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java @@ -35,7 +35,7 @@ public class ExecuteBuildingBlock implements Serializable { private String requestAction; private String vnfType; private Boolean aLaCarte; - private Boolean homing; + private Boolean homing = false; private WorkflowResourceIds workflowResourceIds; private RequestDetails requestDetails; private ConfigurationResourceKeys configurationResourceKeys; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java index 9e95e79b70..8608fee244 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java @@ -21,5 +21,15 @@ package org.onap.so.bpmn.servicedecomposition.entities; public enum ResourceKey { - SERVICE_INSTANCE_ID, GENERIC_VNF_ID, NETWORK_ID, VOLUME_GROUP_ID, VF_MODULE_ID, ALLOTTED_RESOURCE_ID, CONFIGURATION_ID, NETWORK_COLLECTION_ID, VPN_ID, VPN_BONDING_LINK_ID, INSTANCE_GROUP_ID; + SERVICE_INSTANCE_ID, + GENERIC_VNF_ID, + NETWORK_ID, + VOLUME_GROUP_ID, + VF_MODULE_ID, + ALLOTTED_RESOURCE_ID, + CONFIGURATION_ID, + NETWORK_COLLECTION_ID, + VPN_ID, + VPN_BONDING_LINK_ID, + INSTANCE_GROUP_ID; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/SolutionCandidates.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/SolutionCandidates.java index db5c11a954..068fa876ce 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/SolutionCandidates.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/SolutionCandidates.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. @@ -34,9 +34,10 @@ public class SolutionCandidates implements Serializable { private List<Candidate> requiredCandidates = new ArrayList<Candidate>(); @JsonProperty("excludedCandidates") private List<Candidate> excludedCandidates = new ArrayList<Candidate>(); - // TODO figure out best way to do this @JsonProperty("existingCandidates") private List<Candidate> existingCandidates = new ArrayList<Candidate>(); + @JsonProperty("filteringAttributes") + private List<Candidate> filteringAttributes = new ArrayList<Candidate>(); public List<Candidate> getRequiredCandidates() { @@ -59,6 +60,8 @@ public class SolutionCandidates implements Serializable { return existingCandidates; } - + public List<Candidate> getFilteringAttributes() { + return filteringAttributes; + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java index 05cad456d0..bc330eeafd 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java @@ -39,6 +39,10 @@ public class ModelInfoServiceInstance extends ModelInfoMetadata implements Seria private String environmentContext; @JsonProperty("workload-context") private String workloadContext; + @JsonProperty("naming-policy") + private String namingPolicy; + @JsonProperty("onap-generated-naming") + private Boolean onapGeneratedNaming; public String getDescription() { @@ -88,4 +92,21 @@ public class ModelInfoServiceInstance extends ModelInfoMetadata implements Seria public void setWorkloadContext(String workloadContext) { this.workloadContext = workloadContext; } + + + public String getNamingPolicy() { + return namingPolicy; + } + + public void setNamingPolicy(String namingPolicy) { + this.namingPolicy = namingPolicy; + } + + public Boolean getOnapGeneratedNaming() { + return onapGeneratedNaming; + } + + public void setOnapGeneratedNaming(Boolean onapGeneratedNaming) { + this.onapGeneratedNaming = onapGeneratedNaming; + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceProxy.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceProxy.java index b2494384f4..91ff3d623d 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceProxy.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceProxy.java @@ -22,11 +22,31 @@ package org.onap.so.bpmn.servicedecomposition.modelinfo; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; public class ModelInfoServiceProxy extends ModelInfoMetadata implements Serializable { private static final long serialVersionUID = -6256897576261215926L; + @JsonProperty("tosca-node-type") + private String toscaNodeType; + @JsonProperty("description") + private String description; + public String getToscaNodeType() { + return toscaNodeType; + } + + public void setToscaNodeType(String toscaNodeType) { + this.toscaNodeType = toscaNodeType; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/AssignFlows.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/AssignFlows.java index 7ca6076b21..f23f62d763 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/AssignFlows.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/AssignFlows.java @@ -22,10 +22,15 @@ package org.onap.so.bpmn.servicedecomposition.tasks; public enum AssignFlows { - SERVICE_INSTANCE("AssignServiceInstanceBB"), VNF("AssignVnfBB"), VF_MODULE("AssignVfModuleBB"), NETWORK_A_LA_CARTE( - "AssignNetwork1802BB"), NETWORK_MACRO("AssignNetworkBB"), VOLUME_GROUP( - "AssignVolumeGroupBB"), NETWORK_COLLECTION( - "CreateNetworkCollectionBB"), FABRIC_CONFIGURATION("AssignFabricConfigurationBB"); + SERVICE_INSTANCE("AssignServiceInstanceBB"), + VNF("AssignVnfBB"), + VF_MODULE("AssignVfModuleBB"), + NETWORK_A_LA_CARTE("AssignNetwork1802BB"), + NETWORK_MACRO("AssignNetworkBB"), + VOLUME_GROUP("AssignVolumeGroupBB"), + NETWORK_COLLECTION("CreateNetworkCollectionBB"), + FABRIC_CONFIGURATION("AssignFabricConfigurationBB"), + VRF_CONFIGURATION("AssignVrfConfigurationBBV2"); private final String flowName; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 2d066285a4..c7665acc68 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -47,11 +47,13 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -76,6 +78,7 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; @@ -342,7 +345,7 @@ public class BBInputSetup implements JavaDelegate { ModelInfo configurationModelInfo = new ModelInfo(); configurationModelInfo.setModelCustomizationUuid(configurationKey); populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, - configurationId, instanceName, configurationResourceKeys); + configurationId, instanceName, configurationResourceKeys, requestDetails); } else { lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId); this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, @@ -372,7 +375,7 @@ public class BBInputSetup implements JavaDelegate { protected void populateConfiguration(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, - String instanceName, ConfigurationResourceKeys configurationResourceKeys) { + String instanceName, ConfigurationResourceKeys configurationResourceKeys, RequestDetails requestDetails) { Configuration configuration = null; for (Configuration configurationTemp : serviceInstance.getConfigurations()) { if (lookupKeyMap.get(ResourceKey.CONFIGURATION_ID) != null && configurationTemp.getConfigurationId() @@ -385,14 +388,20 @@ public class BBInputSetup implements JavaDelegate { } } } - if (configuration == null && bbName.equalsIgnoreCase(AssignFlows.FABRIC_CONFIGURATION.toString())) { + if (configuration == null && (bbName.equalsIgnoreCase(AssignFlows.FABRIC_CONFIGURATION.toString()) + || bbName.equalsIgnoreCase(AssignFlows.VRF_CONFIGURATION.toString()))) { configuration = this.createConfiguration(lookupKeyMap, instanceName, resourceId); serviceInstance.getConfigurations().add(configuration); } - if (configuration != null) { + if (configuration != null && bbName.contains("Fabric")) { Vnfc vnfc = getVnfcToConfiguration(configurationResourceKeys.getVnfcName()); configuration.setVnfc(vnfc); this.mapCatalogConfiguration(configuration, modelInfo, service, configurationResourceKeys); + } else if (configuration != null && bbName.contains("Vrf")) { + configuration.setModelInfoConfiguration(mapperLayer.mapCatalogConfigurationToConfiguration( + findConfigurationResourceCustomization(modelInfo, service), null)); + configuration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType()); + configuration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole()); } } @@ -1115,15 +1124,67 @@ public class BBInputSetup implements JavaDelegate { ModelInfo configurationModelInfo = new ModelInfo(); configurationModelInfo.setModelCustomizationUuid(key); this.populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, - configurationId, null, executeBB.getConfigurationResourceKeys()); + configurationId, null, executeBB.getConfigurationResourceKeys(), executeBB.getRequestDetails()); } if (executeBB.getWorkflowResourceIds() != null) { this.populateNetworkCollectionAndInstanceGroupAssign(service, bbName, serviceInstance, executeBB.getWorkflowResourceIds().getNetworkCollectionId(), key); } + RelatedInstance relatedVpnBinding = + bbInputSetupUtils.getRelatedInstanceByType(executeBB.getRequestDetails(), ModelType.vpnBinding); + RelatedInstance relatedLocalNetwork = + bbInputSetupUtils.getRelatedInstanceByType(executeBB.getRequestDetails(), ModelType.network); + if (relatedVpnBinding != null && relatedLocalNetwork != null) { + org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = + bbInputSetupUtils.getAAIVpnBinding(relatedVpnBinding.getInstanceId()); + org.onap.aai.domain.yang.L3Network aaiLocalNetwork = + bbInputSetupUtils.getAAIL3Network(relatedLocalNetwork.getInstanceId()); + VpnBinding vpnBinding = mapperLayer.mapAAIVpnBinding(aaiVpnBinding); + L3Network localNetwork = mapperLayer.mapAAIL3Network(aaiLocalNetwork); + Optional<org.onap.aai.domain.yang.VpnBinding> aaiAICVpnBindingOp = + bbInputSetupUtils.getAICVpnBindingFromNetwork(aaiLocalNetwork); + if (aaiAICVpnBindingOp.isPresent()) { + localNetwork.getVpnBindings().add(mapperLayer.mapAAIVpnBinding(aaiAICVpnBindingOp.get())); + } + ServiceProxy serviceProxy = getServiceProxy(service); + gBB.getServiceInstance().getServiceProxies().add(serviceProxy); + gBB.getCustomer().getVpnBindings().add(vpnBinding); + lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId()); + gBB.getServiceInstance().getNetworks().add(localNetwork); + lookupKeyMap.put(ResourceKey.NETWORK_ID, localNetwork.getNetworkId()); + } return gBB; } + protected ServiceProxy getServiceProxy(Service service) { + if (!service.getServiceProxyCustomizations().isEmpty()) { + ServiceProxyResourceCustomization serviceProxyCatalog = getServiceProxyResourceCustomization(service); + ServiceProxy serviceProxy = new ServiceProxy(); + serviceProxy.setModelInfoServiceProxy( + mapperLayer.mapServiceProxyCustomizationToServiceProxy(serviceProxyCatalog)); + Service sourceService = serviceProxyCatalog.getSourceService(); + ServiceInstance sourceServiceShell = new ServiceInstance(); + sourceServiceShell + .setModelInfoServiceInstance(mapperLayer.mapCatalogServiceIntoServiceInstance(sourceService)); + serviceProxy.setServiceInstance(sourceServiceShell); + serviceProxy.setType(sourceService.getServiceType()); + return serviceProxy; + } else { + return null; + } + } + + protected ServiceProxyResourceCustomization getServiceProxyResourceCustomization(Service service) { + ServiceProxyResourceCustomization serviceProxyCatalog = null; + for (ServiceProxyResourceCustomization serviceProxyTemp : service.getServiceProxyCustomizations()) { + if (serviceProxyTemp.getSourceService() != null + && serviceProxyTemp.getSourceService().getServiceType().equalsIgnoreCase("TRANSPORT")) { + serviceProxyCatalog = serviceProxyTemp; + } + } + return serviceProxyCatalog; + } + protected L3Network getVirtualLinkL3Network(Map<ResourceKey, String> lookupKeyMap, String bbName, String key, String networkId, CollectionNetworkResourceCustomization collectionNetworkResourceCust, ServiceInstance serviceInstance) { @@ -1348,7 +1409,7 @@ public class BBInputSetup implements JavaDelegate { findConfigurationResourceCustomization(configurationModelInfo, service); if (configurationCust != null) { this.populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, - configurationId, null, executeBB.getConfigurationResourceKeys()); + configurationId, null, executeBB.getConfigurationResourceKeys(), executeBB.getRequestDetails()); } else { logger.debug("Could not find a configuration customization with key: {}", key); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 6f3710835c..63dd72566b 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -40,6 +40,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Entitlement; import org.onap.so.bpmn.servicedecomposition.bbobjects.Evc; import org.onap.so.bpmn.servicedecomposition.bbobjects.ForwarderEvc; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LagInterface; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; @@ -48,6 +49,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; +import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget; import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; @@ -56,6 +58,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.generalobjects.License; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; @@ -67,6 +70,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResource; @@ -79,6 +83,7 @@ import org.onap.so.db.catalog.beans.InstanceGroupType; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.serviceinstancebeans.CloudConfiguration; @@ -131,7 +136,21 @@ public class BBInputSetupMapperLayer { } protected Subnet mapAAISubnet(org.onap.aai.domain.yang.Subnet aaiSubnet) { - return modelMapper.map(aaiSubnet, Subnet.class); + Subnet subnet = modelMapper.map(aaiSubnet, Subnet.class); + mapAllHostRoutesIntoSubnet(aaiSubnet, subnet); + return subnet; + } + + protected void mapAllHostRoutesIntoSubnet(org.onap.aai.domain.yang.Subnet aaiSubnet, Subnet subnet) { + if (aaiSubnet.getHostRoutes() != null) { + for (org.onap.aai.domain.yang.HostRoute aaiHostRoute : aaiSubnet.getHostRoutes().getHostRoute()) { + subnet.getHostRoutes().add(mapAAIHostRoute(aaiHostRoute)); + } + } + } + + protected HostRoute mapAAIHostRoute(org.onap.aai.domain.yang.HostRoute aaiHostRoute) { + return modelMapper.map(aaiHostRoute, HostRoute.class); } protected License mapAAILicense(org.onap.aai.domain.yang.License aaiLicense) { @@ -502,13 +521,18 @@ public class BBInputSetupMapperLayer { protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration( ConfigurationResourceCustomization configurationResourceCustomization, CvnfcConfigurationCustomization cvnfcConfigurationCustomization) { + ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration(); modelInfoConfiguration .setModelVersionId(configurationResourceCustomization.getConfigurationResource().getModelUUID()); modelInfoConfiguration.setModelCustomizationId(configurationResourceCustomization.getModelCustomizationUUID()); modelInfoConfiguration.setModelInvariantId( configurationResourceCustomization.getConfigurationResource().getModelInvariantUUID()); - modelInfoConfiguration.setPolicyName(cvnfcConfigurationCustomization.getPolicyName()); + modelInfoConfiguration.setConfigurationRole(configurationResourceCustomization.getRole()); + modelInfoConfiguration.setConfigurationType(configurationResourceCustomization.getType()); + if (cvnfcConfigurationCustomization != null) { + modelInfoConfiguration.setPolicyName(cvnfcConfigurationCustomization.getPolicyName()); + } return modelInfoConfiguration; } @@ -534,4 +558,29 @@ public class BBInputSetupMapperLayer { public Vnfc mapAAIVnfc(org.onap.aai.domain.yang.Vnfc vnfcAAI) { return modelMapper.map(vnfcAAI, Vnfc.class); } + + public VpnBinding mapAAIVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding) { + VpnBinding vpnBinding = modelMapper.map(aaiVpnBinding, VpnBinding.class); + mapAllRouteTargetsToAAIVpnBinding(aaiVpnBinding, vpnBinding); + return vpnBinding; + } + + protected void mapAllRouteTargetsToAAIVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding, + VpnBinding vpnBinding) { + if (aaiVpnBinding.getRouteTargets() != null) { + for (org.onap.aai.domain.yang.RouteTarget aaiRouteTarget : aaiVpnBinding.getRouteTargets() + .getRouteTarget()) { + vpnBinding.getRouteTargets().add(mapAAIRouteTarget(aaiRouteTarget)); + } + } + } + + public RouteTarget mapAAIRouteTarget(org.onap.aai.domain.yang.RouteTarget aaiRouteTarget) { + return modelMapper.map(aaiRouteTarget, RouteTarget.class); + } + + protected ModelInfoServiceProxy mapServiceProxyCustomizationToServiceProxy( + ServiceProxyResourceCustomization serviceProxyCustomization) { + return modelMapper.map(serviceProxyCustomization, ModelInfoServiceProxy.class); + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index 5cf2bd7b39..8ac5f6e69b 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -39,6 +39,7 @@ import org.onap.aai.domain.yang.ServiceSubscription; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VolumeGroups; +import org.onap.aai.domain.yang.VpnBinding; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; @@ -60,6 +61,9 @@ import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.CloudConfiguration; +import org.onap.so.serviceinstancebeans.ModelType; +import org.onap.so.serviceinstancebeans.RelatedInstance; +import org.onap.so.serviceinstancebeans.RelatedInstanceList; import org.onap.so.serviceinstancebeans.RequestDetails; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -85,6 +89,20 @@ public class BBInputSetupUtils { @Autowired protected InjectionHelper injectionHelper; + public RelatedInstance getRelatedInstanceByType(RequestDetails requestDetails, ModelType modelType) { + if (requestDetails.getRelatedInstanceList() != null) { + for (RelatedInstanceList relatedInstanceList : requestDetails.getRelatedInstanceList()) { + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + if (relatedInstance != null && relatedInstance.getModelInfo() != null + && relatedInstance.getModelInfo().getModelType() != null + && relatedInstance.getModelInfo().getModelType().equals(modelType)) { + return relatedInstance; + } + } + } + return null; + } + public void updateInfraActiveRequestVnfId(InfraActiveRequests request, String vnfId) { if (request != null) { request.setVnfId(vnfId); @@ -334,6 +352,17 @@ public class BBInputSetupUtils { }); } + public VpnBinding getAAIVpnBinding(String vpnBindingId) { + + return this.injectionHelper.getAaiClient() + .get(VpnBinding.class, + AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBindingId).depth(Depth.ONE)) + .orElseGet(() -> { + logger.debug("No VpnBinding matched by id"); + return null; + }); + } + public VolumeGroup getAAIVolumeGroup(String cloudOwnerId, String cloudRegionId, String volumeGroupId) { return this.injectionHelper.getAaiClient() .get(VolumeGroup.class, AAIUriFactory @@ -463,4 +492,16 @@ public class BBInputSetupUtils { return Optional.of(volumeGroup); } } + + public Optional<org.onap.aai.domain.yang.VpnBinding> getAICVpnBindingFromNetwork( + org.onap.aai.domain.yang.L3Network aaiLocalNetwork) { + AAIResultWrapper networkWrapper = new AAIResultWrapper(aaiLocalNetwork); + if (networkWrapper.getRelationships().isPresent() + && !networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING).isEmpty()) { + return getAAIResourceDepthOne( + networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING).get(0)) + .asBean(org.onap.aai.domain.yang.VpnBinding.class); + } + return Optional.empty(); + } } 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 c8e296d5ac..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,15 +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"; @@ -97,6 +95,9 @@ public class ExecuteBuildingBlockRainyDay { try { serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) .getModelInfoServiceInstance().getServiceType(); + if (serviceType == null || serviceType.isEmpty()) { + serviceType = ASTERISK; + } } catch (Exception ex) { // keep default serviceType value } @@ -118,6 +119,7 @@ public class ExecuteBuildingBlockRainyDay { } catch (Exception ex) { // keep default errorCode value } + try { errorCode = "" + (String) execution.getVariable("WorkflowExceptionCode"); } catch (Exception ex) { @@ -131,29 +133,19 @@ public class ExecuteBuildingBlockRainyDay { // keep default workStep value } - RainyDayHandlerStatus rainyDayHandlerStatus; - rainyDayHandlerStatus = catalogDbClient - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName, - serviceType, vnfType, errorCode, workStep); - if (rainyDayHandlerStatus == null) { - rainyDayHandlerStatus = catalogDbClient - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName, - ASTERISK, ASTERISK, errorCode, ASTERISK); + String errorMessage = ASTERISK; + try { + errorMessage = workflowException.getErrorMessage(); + } catch (Exception ex) { + // keep default workStep value } + RainyDayHandlerStatus rainyDayHandlerStatus; + rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatus(bbName, serviceType, vnfType, + errorCode, workStep, errorMessage); + if (rainyDayHandlerStatus == null) { - rainyDayHandlerStatus = catalogDbClient - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName, - ASTERISK, ASTERISK, ASTERISK, ASTERISK); - if (rainyDayHandlerStatus == null) { - handlingCode = "Abort"; - } else { - if (primaryPolicy) { - handlingCode = rainyDayHandlerStatus.getPolicy(); - } else { - handlingCode = rainyDayHandlerStatus.getSecondaryPolicy(); - } - } + handlingCode = "Abort"; } else { if (primaryPolicy) { handlingCode = rainyDayHandlerStatus.getPolicy(); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/DuplicateNameException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/DuplicateNameException.java new file mode 100644 index 0000000000..6e9eb809aa --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/DuplicateNameException.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks.exceptions; + +public class DuplicateNameException extends Exception { + + private static final long serialVersionUID = -2850043981787600326L; + + public DuplicateNameException() { + super(); + } + + public DuplicateNameException(String message) { + super(message); + } + + public DuplicateNameException(String objectType, String name) { + super(objectType + " with name " + name + " already exists. The name must be unique."); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BadResponseException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BadResponseException.java index 333d99ed2e..7b1066d48c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BadResponseException.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BadResponseException.java @@ -22,10 +22,21 @@ package org.onap.so.client.exception; public class BadResponseException extends Exception { + String responseCode; + public BadResponseException() {} public BadResponseException(String message) { super(message); } + public BadResponseException(String message, String responseCode) { + super(message); + this.responseCode = responseCode; + } + + public String getResponseCode() { + return responseCode; + } + } 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 ae5e41f7ce..d656314fd1 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 @@ -22,21 +22,41 @@ package org.onap.so.client.exception; +import java.io.IOException; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.aai.domain.yang.LInterface; +import org.onap.aai.domain.yang.Vserver; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.logger.ErrorCode; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.logger.MessageEnum; +import org.onap.so.objects.audit.AAIObjectAudit; +import org.onap.so.objects.audit.AAIObjectAuditList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; + @Component public class ExceptionBuilder { private static final Logger logger = LoggerFactory.getLogger(ExceptionBuilder.class); + + protected ExtractPojosForBB getExtractPojosForBB() { + return new ExtractPojosForBB(); + } + public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, Exception exception) { String msg = "Exception in %s.%s "; try { @@ -56,7 +76,7 @@ public class ExceptionBuilder { } } - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), msg.toString()); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { @@ -87,7 +107,7 @@ public class ExceptionBuilder { break; } } - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), msg.toString()); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex) { @@ -132,4 +152,69 @@ public class ExceptionBuilder { return execution.getProcessEngineServices().getRepositoryService() .getProcessDefinition(execution.getProcessDefinitionId()).getKey(); } + + public void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue) { + logger.debug("Processing Audit Results"); + String auditListString = (String) execution.getVariable("auditInventoryResult"); + if (auditListString != null) { + StringBuilder errorMessage = new StringBuilder(); + String processKey = getProcessKey(execution.getDelegateExecution()); + try { + ExtractPojosForBB extractPojosForBB = getExtractPojosForBB(); + VfModule module = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + String cloudRegionId = execution.getGeneralBuildingBlock().getCloudRegion().getLcpCloudRegionId(); + + GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); + AAIObjectAuditList auditList = + objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class); + + errorMessage = errorMessage.append(auditList.getAuditType() + " VF-Module " + module.getVfModuleId() + + " failed due to incomplete AAI vserver inventory population after stack " + + auditList.getHeatStackName() + " was successfully " + auditList.getAuditType() + + "d in cloud region " + cloudRegionId + ". MSO Audit indicates that the following was not " + + auditList.getAuditType() + "d in AAI: "); + + Stream<AAIObjectAudit> vServerLInterfaceAuditStream = auditList.getAuditList().stream() + .filter(auditObject -> auditObject.getAaiObjectType().equals(AAIObjectType.VSERVER.typeName()) + || auditObject.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())); + List<AAIObjectAudit> filteredAuditStream = + vServerLInterfaceAuditStream.filter(a -> !a.isDoesObjectExist()).collect(Collectors.toList()); + + for (AAIObjectAudit object : filteredAuditStream) { + if (object.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())) { + LInterface li = objectMapper.getMapper().convertValue(object.getAaiObject(), LInterface.class); + errorMessage = errorMessage + .append(AAIObjectType.L_INTERFACE.typeName() + " " + li.getInterfaceId() + ", "); + } else { + Vserver vs = objectMapper.getMapper().convertValue(object.getAaiObject(), Vserver.class); + errorMessage = + errorMessage.append(AAIObjectType.VSERVER.typeName() + " " + vs.getVserverId() + ", "); + } + } + + if (errorMessage.length() > 0) { + errorMessage.setLength(errorMessage.length() - 2); + errorMessage = errorMessage.append("."); + } + + } catch (IOException | BBObjectNotFoundException e) { + errorMessage = errorMessage.append("process objects in AAI. "); + } + + 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"); + } + + } else { + logger.debug("Unable to process audit results due to auditInventoryResult being null"); + } + } + } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java new file mode 100644 index 0000000000..9ead1576cb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExpectedDataException.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.exception; + + +public class ExpectedDataException extends Exception { + + public ExpectedDataException() {} + + public ExpectedDataException(String message, String system) { + super("Expected data not found in " + system + ". " + message); + } + + public ExpectedDataException(String message) { + super("Expected data not found. " + message); + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java new file mode 100644 index 0000000000..9ae14a0162 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/UnexpectedDataException.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.exception; + + +public class UnexpectedDataException extends Exception { + + public UnexpectedDataException() {} + + public UnexpectedDataException(String message, String system) { + super("Unexpected data found in " + system + ". " + message); + } + + public UnexpectedDataException(String message) { + super("Unexpected data found. " + message); + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java index 79a94d5298..9e10058ec8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java @@ -247,6 +247,7 @@ public class BuildingBlockTestDataSetup { modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter); configuration.setModelInfoConfiguration(modelInfoConfiguration); + configuration.setVpnBinding(buildVpnBinding()); return configuration; } @@ -325,6 +326,7 @@ public class BuildingBlockTestDataSetup { gBBInput.setCustomer(buildCustomer()); } gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance); + gBBInput.setServiceInstance(serviceInstance); lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId()); return serviceInstance; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java index f13bcb8a93..2c0377d11c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -34,6 +34,12 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.common.listener.validation.BuildingBlockValidatorRunner; +import org.onap.so.bpmn.common.listener.validation.FlowValidator; +import org.onap.so.bpmn.common.listener.validation.MyPreValidatorOne; +import org.onap.so.bpmn.common.listener.validation.MyPreValidatorThree; +import org.onap.so.bpmn.common.listener.validation.MyPreValidatorTwo; +import org.onap.so.bpmn.common.listener.validation.ValidationConfig; import org.onap.so.bpmn.core.WorkflowException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; @@ -57,7 +63,7 @@ public class BuildingBlockValidatorRunnerTest { MyPreValidatorThree three = new MyPreValidatorThree(); List<FlowValidator> validators = Arrays.asList(one, two, three); - List<FlowValidator> result = runner.filterValidators(validators, "test"); + List<FlowValidator> result = runner.filterListeners(validators, (item -> item.shouldRunFor("test"))); List<FlowValidator> expected = Arrays.asList(two, one); @@ -75,7 +81,7 @@ public class BuildingBlockValidatorRunnerTest { } catch (BpmnError e) { WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); assertEquals( - "Failed Validations:\norg.onap.so.bpmn.common.validation.MyPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.MyPreValidatorOne: my-error-one", + "Failed Validations:\norg.onap.so.bpmn.common.listener.validation.MyPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.listener.validation.MyPreValidatorOne: my-error-one", workflowException.getErrorMessage()); } runner.preValidate("test2", mock(BuildingBlockExecution.class)); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java index 07cd790ed1..0143e567af 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -33,7 +33,11 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.FlowValidator; +import org.onap.so.bpmn.common.listener.validation.ValidationConfig; +import org.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorOne; +import org.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorTwo; +import org.onap.so.bpmn.common.listener.validation.WorkflowValidatorRunner; import org.onap.so.bpmn.core.WorkflowException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; @@ -56,7 +60,7 @@ public class WorkflowValidatorRunnerTest { WorkflowPreValidatorTwo two = new WorkflowPreValidatorTwo(); List<FlowValidator> validators = Arrays.asList(one, two); - List<FlowValidator> result = runner.filterValidators(validators, "test"); + List<FlowValidator> result = runner.filterListeners(validators, (item -> item.shouldRunFor("test"))); List<FlowValidator> expected = Arrays.asList(two, one); @@ -74,7 +78,7 @@ public class WorkflowValidatorRunnerTest { } catch (BpmnError e) { WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); assertEquals( - "Failed Validations:\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorOne: my-error-one", + "Failed Validations:\norg.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.listener.validation.WorkflowPreValidatorOne: my-error-one", workflowException.getErrorMessage()); } runner.preValidate("test2", mock(DelegateExecution.class)); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java index 7572e930cd..af64ed2de6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java @@ -18,11 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.Skip; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorFour.java index 85531719d5..f0f27172a5 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorFour.java @@ -18,12 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorOne.java index 989a65fe47..e705bafafe 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorOne.java @@ -18,12 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorThree.java index a51d3836da..3c747dd20f 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorThree.java @@ -18,12 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorTwo.java index 1276d8f1d2..3fb3485c39 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyPreValidatorTwo.java @@ -18,13 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import javax.annotation.Priority; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.springframework.stereotype.Component; @Priority(1) diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java index 90d094ce41..068f433dd5 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java @@ -18,16 +18,16 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; +import org.onap.so.bpmn.common.listener.ListenerRunner; import org.onap.so.client.exception.ExceptionBuilder; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; @Configuration -@ComponentScan(basePackages = {"org.onap.so.bpmn.common.validation"}, basePackageClasses = {ExceptionBuilder.class}, +@ComponentScan(basePackageClasses = {ExceptionBuilder.class, ListenerRunner.class}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class) public class ValidationConfig { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorOne.java index 485aae2fcc..f7aedcfd6f 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorOne.java @@ -18,12 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreWorkflowValidator; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorTwo.java index 9596524a56..99a7e161a9 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/WorkflowPreValidatorTwo.java @@ -18,13 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.common.validation; +package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import java.util.Set; import javax.annotation.Priority; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.validation.PreWorkflowValidator; import org.springframework.stereotype.Component; @Priority(1) diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java new file mode 100644 index 0000000000..3be67c965c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/InstnaceResourceListTest.java @@ -0,0 +1,46 @@ +package org.onap.so.bpmn.common.resource; + +import org.junit.Assert; +import org.junit.Test; +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 java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class InstnaceResourceListTest { + + public static String RESOURCE_PATH = "src/test/resources/__files/InstanceResourceList/"; + + @Test + public void testInstanceResourceList() throws IOException { + String uuiRequest = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "InstanceResourceList" + ".json"))); + List<Resource> instanceResourceList = + InstanceResourceList.getInstanceResourceList(createResourceSequence(), uuiRequest); + Assert.assertEquals(4, instanceResourceList.size()); + Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(0).getResourceType()); + Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(1).getResourceType()); + Assert.assertEquals(ResourceType.VNF, instanceResourceList.get(2).getResourceType()); + Assert.assertEquals(ResourceType.GROUP, instanceResourceList.get(3).getResourceType()); + } + + private List<Resource> createResourceSequence() { + List<Resource> resourceList = new ArrayList<>(); + VnfResource vnfResource = new VnfResource(); + vnfResource.setResourceInput("{\"a\":\"[sdwansiteresource_list,INDEX,sdwansiteresource_list]\"}"); + + VnfcResource vnfcResource = new VnfcResource(); + vnfcResource.setResourceInput("{\"a\":\"[sdwansitewan_list,INDEX,test]\"}"); + + GroupResource groupResource = new GroupResource(); + groupResource.setVnfcs(Arrays.asList(vnfcResource)); + + return Arrays.asList(vnfResource, groupResource); + } +} 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 c7c181744f..557ae6df51 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 @@ -19,232 +19,93 @@ */ package org.onap.so.bpmn.common.resource; +import java.util.ArrayList; +import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.onap.so.BaseTest; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +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.mock.FileUtil; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.ok; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static org.junit.Assert.assertEquals; - +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class ResourceRequestBuilderTest extends BaseTest { - @Test - public void getResourceInputTest() throws Exception { + private Map<String, Object> userInputMap = null; + private Map<String, Object> serviceInput = null; + @Before + public void initializeMockObjects() { - wireMockServer.stubFor(get(urlEqualTo( - "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) - .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n" - + "\t\t\"modelName\" : \"demoVFWCL\",\n" - + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" - + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" - + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n" - + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n" - + "\t\"environmentContext\" : null,\n" + "\t\"resourceOrder\" : \"res1,res2\",\n" - + "\t\"workloadContext\" : \"Production\",\n" + "\t\"serviceVnfs\": [\n" + "\t\n" - + "\t\t{ \"modelInfo\" : {\n" - + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" - + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" - + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" - + "\t\t\t\"modelVersion\" : \"1.0\",\n" - + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" - + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n" - + "\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\"nfRole\" \t\t: null,\n" - + "\t\t\"nfNamingCode\" \t: null,\n" - + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n" - + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n" - + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" - + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" - + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" - + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" - + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" - + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" - + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" - + "\t\t\t\t\t\"initialCount\" : 1,\n" - + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n" - + "\t\t},\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n" - + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" - + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" - + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" - + "\t\t\t\"modelVersion\" : \"1.0\",\n" - + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" - + "\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\"nfRole\" \t\t: null,\n" - + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," - + "\t\t\"nfNamingCode\" \t: null,\n" - + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n" - + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n" - + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" - + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" - + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" - + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" - + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" - + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" - + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" - + "\t\t\t\t\t\"initialCount\" : 1,\n" - + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n" - + "\t\t}\n" + "\t],\n" + "\t\"serviceNetworks\": [],\n" - + "\t\"serviceAllottedResources\": []\n" + "\t}}"))); + if (null == this.userInputMap) { + ObjectMapper mapper = new ObjectMapper(); - // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080"); + try { + String serviceInputRequest = FileUtil.readResourceFile("__files/UUI-SO-REQ.json"); + this.userInputMap = mapper.readValue(serviceInputRequest, new TypeReference<Map<String, Object>>() {}); + } catch (Exception e) { + Assert.fail(e.getMessage()); + } + } + + if (null == this.serviceInput) { + + try { + ObjectMapper mapper = new ObjectMapper(); + String serviceInputRequest = FileUtil.readResourceFile("__files/SERVICE-SO-REQ-INPUT.json"); + this.serviceInput = mapper.readValue(serviceInputRequest, new TypeReference<Map<String, Object>>() {}); + } catch (Exception e) { + Assert.fail(e.getMessage()); + } + } + + } + + @Test + public void getResourceInputTest() throws Exception { + + VnfResource resource = new VnfResource(); + resource.setResourceType(ResourceType.VNF); + resource.setResourceInput("{\"a\":\"key|default_value\"}"); HashMap serviceInput = new HashMap(); serviceInput.put("key", "value"); - Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest( - "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resource, serviceInput, null); assertEquals(stringObjectMap.get("a"), "value"); } @Test public void getResourceInputDefaultValueTest() throws Exception { - - wireMockServer.stubFor(get(urlEqualTo( - "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) - .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n" - + "\t\t\"modelName\" : \"demoVFWCL\",\n" - + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" - + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" - + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n" - + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n" - + "\t\"environmentContext\" : null,\n" + "\t\"workloadContext\" : \"Production\",\n" - + "\t\"serviceVnfs\": [\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n" - + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" - + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" - + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" - + "\t\t\t\"modelVersion\" : \"1.0\",\n" - + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" - + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n" - + "\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\"nfRole\" \t\t: null,\n" - + "\t\t\"nfNamingCode\" \t: null,\n" - + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n" - + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n" - + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" - + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" - + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" - + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" - + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" - + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" - + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" - + "\t\t\t\t\t\"initialCount\" : 1,\n" - + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n" - + "\t\t},\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n" - + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" - + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" - + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" - + "\t\t\t\"modelVersion\" : \"1.0\",\n" - + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" - + "\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\"nfRole\" \t\t: null,\n" - + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," - + "\t\t\"nfNamingCode\" \t: null,\n" - + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n" - + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n" - + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" - + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" - + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" - + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" - + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" - + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" - + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" - + "\t\t\t\t\t\"initialCount\" : 1,\n" - + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n" - + "\t\t}\n" + "\t],\n" + "\t\"serviceNetworks\": [],\n" - + "\t\"serviceAllottedResources\": []\n" + "\t}}"))); - - // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080"); + VnfResource resource = new VnfResource(); + resource.setResourceType(ResourceType.VNF); + resource.setResourceInput("{\"a\":\"key|default_value\"}"); HashMap serviceInput = new HashMap(); serviceInput.put("key1", "value"); - Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest( - "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resource, serviceInput, null); assertEquals(stringObjectMap.get("a"), "default_value"); } @Test public void getResourceInputValueNoDefaultTest() throws Exception { - - wireMockServer.stubFor(get(urlEqualTo( - "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) - .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n" - + "\t\t\"modelName\" : \"demoVFWCL\",\n" - + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" - + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" - + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n" - + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n" - + "\t\"environmentContext\" : null,\n" + "\t\"workloadContext\" : \"Production\",\n" - + "\t\"serviceVnfs\": [\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n" - + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" - + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" - + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" - + "\t\t\t\"modelVersion\" : \"1.0\",\n" - + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" - + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n" - + "\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\"nfRole\" \t\t: null,\n" - + "\t\t\"nfNamingCode\" \t: null,\n" - + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n" - + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n" - + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" - + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" - + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" - + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" - + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" - + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" - + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" - + "\t\t\t\t\t\"initialCount\" : 1,\n" - + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n" - + "\t\t},\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n" - + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" - + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" - + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" - + "\t\t\t\"modelVersion\" : \"1.0\",\n" - + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" - + "\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\"nfRole\" \t\t: null,\n" - + "\"resourceInput\":\"{\\\"a\\\":\\\"value\\\"}\"," - + "\t\t\"nfNamingCode\" \t: null,\n" - + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n" - + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n" - + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" - + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" - + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" - + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" - + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" - + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" - + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" - + "\t\t\t\t\t\"initialCount\" : 1,\n" - + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n" - + "\t\t}\n" + "\t],\n" + "\t\"serviceNetworks\": [],\n" - + "\t\"serviceAllottedResources\": []\n" + "\t}}"))); - - // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080"); + VnfResource resource = new VnfResource(); + resource.setResourceType(ResourceType.VNF); + resource.setResourceInput("{\"a\":\"value\"}"); HashMap serviceInput = new HashMap(); serviceInput.put("key1", "value"); - Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest( - "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resource, serviceInput, null); assertEquals(stringObjectMap.get("a"), "value"); } @@ -322,68 +183,138 @@ public class ResourceRequestBuilderTest extends BaseTest { @Test public void getResourceInputWithEmptyServiceResourcesTest() throws Exception { - wireMockServer.stubFor(get(urlEqualTo( - "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) - .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n" - + "\t\t\"modelName\" : \"demoVFWCL\",\n" - + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" - + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" - + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n" - + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n" - + "\t\"environmentContext\" : null,\n" + "\t\"workloadContext\" : \"Production\",\n" - + "\t\"serviceVnfs\": [], \n" + "\t\"serviceNetworks\": [],\n" - + "\t\"serviceAllottedResources\": []\n" + "\t}}"))); + VnfResource resource = new VnfResource(); + resource.setResourceType(ResourceType.VNF); + resource.setResourceInput(null); HashMap serviceInput = new HashMap(); serviceInput.put("key1", "value"); - Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest( - "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput); + Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resource, serviceInput, null); assertEquals(0, stringObjectMap.size()); } @Test public void testGetResourceInputEmptyValue() { - wireMockServer.stubFor(get(urlEqualTo( - "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5")) - .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n" - + "\t\t\"modelName\" : \"demoVFWCL\",\n" - + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" - + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" - + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n" - + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n" - + "\t\"environmentContext\" : null,\n" + "\t\"resourceOrder\" : \"res1,res2\",\n" - + "\t\"workloadContext\" : \"Production\",\n" + "\t\"serviceVnfs\": [\n" + "\t\n" - + "\t\t{ \"modelInfo\" : {\n" - + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" - + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" - + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" - + "\t\t\t\"modelVersion\" : \"1.0\",\n" - + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" - + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n" - + "\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\"nfRole\" \t\t: null,\n" - + "\t\t\"nfNamingCode\" \t: null,\n" - + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n" - + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n" - + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" - + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" - + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" - + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" - + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" - + "\t\t\t\t\t},\t\t\"isBase\" : true,\n" - + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" - + "\t\t\t\t\t\"initialCount\" : 1,\n" - + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n" - + "\t\t}]}}"))); + + VnfResource resource = new VnfResource(); + resource.setResourceType(ResourceType.VNF); + resource.setResourceInput("{\"a\":\"key1|\"}"); HashMap serviceInput = new HashMap(); serviceInput.put("key2", "value"); - Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest( - "c3954379-4efe-431c-8258-f84905b158e5", "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", serviceInput); + Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(resource, serviceInput, null); assertEquals(stringObjectMap.get("a"), ""); } + @Test + public void getListResourceInputTest() throws Exception { + + List<Map> vnfdata = null; + + List<Resource> resources = new ArrayList<>(); + if (this.serviceInput.containsKey("serviceResources")) { + vnfdata = (List<Map>) ((Map) this.serviceInput.get("serviceResources")).get("serviceVnfs"); + } + assertNotNull(vnfdata); + vnfdata.forEach(e -> { + if (e.get("resourceType").equals("VNF")) { + VnfResource r = new VnfResource(); + r.setResourceInput(e.get("resourceInput").toString()); + resources.add(r); + } else if (e.get("resourceType").equals("GROUP")) { + GroupResource r = new GroupResource(); + VnfcResource vfc = new VnfcResource(); + vfc.setResourceInput(e.get("resourceInput").toString()); + List<VnfcResource> vfcList = new ArrayList(); + vfcList.add(vfc); + r.setVnfcs(vfcList); + resources.add(r); + } + }); + + assertEquals(9, resources.size()); + + // VF level request + Map<String, Object> currentVFData = new HashMap<>(); + Map<String, Object> stringObjectMap = + ResourceRequestBuilder.buildResouceRequest(resources.get(0), this.userInputMap, currentVFData); + assertEquals("b", stringObjectMap.get("a")); + assertEquals("hub_spoke", stringObjectMap.get("topology")); + assertEquals("defaultvpn", stringObjectMap.get("name")); + assertTrue(((String) stringObjectMap.get("sitelist")).contains("[")); + + // vfc level request + stringObjectMap = + ResourceRequestBuilder.buildResouceRequest(resources.get(1), this.userInputMap, currentVFData); + assertEquals("", stringObjectMap.get("a")); + assertEquals("layer3-port", stringObjectMap.get("portswitch")); + assertEquals("192.168.10.1", stringObjectMap.get("ipAddress")); + assertEquals("vCPE", stringObjectMap.get("deviceName")); + + // vfc level request + stringObjectMap = + ResourceRequestBuilder.buildResouceRequest(resources.get(2), this.userInputMap, currentVFData); + assertEquals("", stringObjectMap.get("a")); + assertEquals("layer2-port", stringObjectMap.get("portswitch")); + assertEquals("192.168.11.1", stringObjectMap.get("ipAddress")); + assertEquals("CPE_Beijing", stringObjectMap.get("deviceName")); + + // VF level request + stringObjectMap = + ResourceRequestBuilder.buildResouceRequest(resources.get(3), this.userInputMap, currentVFData); + assertEquals("Huawei Private Cloud", stringObjectMap.get("address")); + assertEquals("dsvpn_hub1", stringObjectMap.get("role")); + assertTrue(((String) stringObjectMap.get("wanlist")).contains("[")); + assertTrue(((String) stringObjectMap.get("devlist")).contains("[")); + + // VFC request + stringObjectMap = + ResourceRequestBuilder.buildResouceRequest(resources.get(4), this.userInputMap, currentVFData); + assertEquals("Huawei Private Cloud", stringObjectMap.get("address")); + 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(resources.get(5), 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(resources.get(6), 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(resources.get(7), 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(resources.get(8), 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/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java new file mode 100644 index 0000000000..fa8de7ff23 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/bbobjects/wrappers/ServiceInstanceWrapperTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects.wrappers; + +import static org.junit.Assert.assertEquals; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.wrappers.exceptions.ServiceProxyNotFoundException; + +public class ServiceInstanceWrapperTest { + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Test + public void getTransportServiceProxyTest() throws ServiceProxyNotFoundException { + ServiceInstance si = buildServiceInstance(); + si.getServiceProxies().add(buildServiceProxy()); + ServiceInstanceWrapper sw = new ServiceInstanceWrapper(si); + ServiceProxy sp = sw.getTransportServiceProxy(); + assertEquals("sp-001", sp.getId()); + assertEquals("transport", sp.getType()); + } + + @Test + public void getTransportServiceProxyExceptionTest() throws ServiceProxyNotFoundException { + expectedException.expect(ServiceProxyNotFoundException.class); + ServiceInstanceWrapper sw = new ServiceInstanceWrapper(buildServiceInstance()); + sw.getTransportServiceProxy(); + } + + private ServiceInstance buildServiceInstance() { + ServiceInstance si = new ServiceInstance(); + si.setServiceInstanceId("si-001"); + si.setServiceInstanceName("Test SI"); + return si; + } + + private ServiceProxy buildServiceProxy() { + ServiceProxy sp = new ServiceProxy(); + sp.setId("sp-001"); + sp.setType("transport"); + return sp; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index 39650a2142..13d2b7d3d3 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -398,10 +398,12 @@ public class BBInputSetupMapperLayerTest { @Test public void testMapAAIL3NetworkIntoL3Network() throws IOException { - L3Network expected = mapper.readValue(new File(RESOURCE_PATH + "l3NetworkExpected.json"), L3Network.class); + L3Network expected = + mapper.readValue(new File(RESOURCE_PATH + "l3NetworkExpectedWithSubnet.json"), L3Network.class); - org.onap.aai.domain.yang.L3Network aaiL3Network = mapper.readValue( - new File(RESOURCE_PATH + "aaiL3NetworkInput.json"), org.onap.aai.domain.yang.L3Network.class); + org.onap.aai.domain.yang.L3Network aaiL3Network = + mapper.readValue(new File(RESOURCE_PATH + "aaiL3NetworkInputWithSubnets.json"), + org.onap.aai.domain.yang.L3Network.class); L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index ad1918e6da..787957dc38 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -65,6 +65,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; @@ -82,6 +83,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.client.aai.AAICommonObjectMapperProvider; import org.onap.so.client.aai.AAIObjectType; @@ -94,14 +96,15 @@ import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.ConfigurationResource; import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; +import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.InstanceGroupType; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.serviceinstancebeans.CloudConfiguration; @@ -1231,19 +1234,19 @@ public class BBInputSetupTest { configResourceKeys.setVnfcName(vnfcName); Vnfc vnfc = new Vnfc(); vnfc.setVnfcName(vnfcName); - + RequestDetails requestDetails = new RequestDetails(); doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName); SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - instanceName, configResourceKeys); + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, null); SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - instanceName, configResourceKeys); + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(2)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); @@ -1255,7 +1258,7 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys); SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - instanceName, configResourceKeys); + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys); } @@ -1307,6 +1310,7 @@ public class BBInputSetupTest { configResourceKeys.setVnfcName(vnfcName); Vnfc vnfc = new Vnfc(); vnfc.setVnfcName(vnfcName); + RequestDetails requestDetails = new RequestDetails(); CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization(); @@ -1319,7 +1323,7 @@ public class BBInputSetupTest { doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName); SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - instanceName, configResourceKeys); + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); } @@ -1972,14 +1976,117 @@ public class BBInputSetupTest { configurationCustList.add(configurationCust); doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), - isA(ConfigurationResourceKeys.class)); + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); executeBB.getBuildingBlock().setBpmnFlowName("AssignFabricConfigurationBB"); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), - isA(ConfigurationResourceKeys.class)); + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + + + } + + @Test + public void testGBBMacroNoUserParamsVrfConfiguration() throws Exception { + GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), + GeneralBuildingBlock.class); + ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), + ExecuteBuildingBlock.class); + RequestDetails requestDetails = mapper + .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacroVrf.json"), RequestDetails.class); + InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId"); + lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId"); + String resourceId = "123"; + String vnfType = "vnfType"; + Service service = Mockito.mock(Service.class); + String requestAction = "createInstance"; + + ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys(); + configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID"); + configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID"); + configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID"); + executeBB.setConfigurationResourceKeys(configResourceKeys); + + executeBB.setRequestDetails(requestDetails); + doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, + requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID)); + doReturn(service).when(SPY_bbInputSetupUtils) + .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid()); + + RelatedInstance relatedVpnBinding = new RelatedInstance(); + relatedVpnBinding.setInstanceId("vpnBindingInstanceId"); + RelatedInstance relatedLocalNetwork = new RelatedInstance(); + relatedLocalNetwork.setInstanceId("localNetworkInstanceId"); + org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = new org.onap.aai.domain.yang.VpnBinding(); + aaiVpnBinding.setVpnId("vpnBindingId"); + org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network(); + aaiLocalNetwork.setNetworkId("localNetworkId"); + Optional<org.onap.aai.domain.yang.VpnBinding> aaiAICVpnBindingOp = + Optional.of(new org.onap.aai.domain.yang.VpnBinding()); + aaiAICVpnBindingOp.get().setVpnId("AICVpnBindingId"); + ServiceProxy proxy = new ServiceProxy(); + proxy.setType("transport"); + proxy.setServiceInstance(new ServiceInstance()); + proxy.getServiceInstance().setModelInfoServiceInstance(new ModelInfoServiceInstance()); + proxy.getServiceInstance().getModelInfoServiceInstance().setModelUuid("sourceServiceModelUUID"); + doReturn(relatedVpnBinding).when(SPY_bbInputSetupUtils).getRelatedInstanceByType(requestDetails, + ModelType.vpnBinding); + doReturn(relatedLocalNetwork).when(SPY_bbInputSetupUtils).getRelatedInstanceByType(requestDetails, + ModelType.network); + doReturn(aaiVpnBinding).when(SPY_bbInputSetupUtils).getAAIVpnBinding(relatedVpnBinding.getInstanceId()); + doReturn(aaiLocalNetwork).when(SPY_bbInputSetupUtils).getAAIL3Network(relatedLocalNetwork.getInstanceId()); + doReturn(aaiAICVpnBindingOp).when(SPY_bbInputSetupUtils).getAICVpnBindingFromNetwork(aaiLocalNetwork); + doReturn(proxy).when(SPY_bbInputSetup).getServiceProxy(service); + + Configuration configuration = new Configuration(); + configuration.setConfigurationId("configurationId"); + gBB.getServiceInstance().getConfigurations().add(configuration); + List<ConfigurationResourceCustomization> configurationCustList = new ArrayList<>(); + ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization(); + configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); + configurationCustList.add(configurationCust); + doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + + executeBB.getBuildingBlock().setBpmnFlowName("AssignVrfConfigurationBB"); + executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); + gBB = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); + verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + assertEquals(gBB.getCustomer().getVpnBindings().get(0).getVpnId(), "vpnBindingId"); + assertEquals(gBB.getServiceInstance().getNetworks().get(0).getNetworkId(), "localNetworkId"); + assertEquals(gBB.getServiceInstance().getNetworks().get(0).getVpnBindings().get(0).getVpnId(), + "AICVpnBindingId"); + assertEquals(gBB.getServiceInstance().getServiceProxies().get(0).getType(), "transport"); + } + + @Test + public void testGetServiceProxy() { + ServiceProxy expected = new ServiceProxy(); + expected.setType("TRANSPORT"); + expected.setModelInfoServiceProxy(new ModelInfoServiceProxy()); + expected.getModelInfoServiceProxy().setModelCustomizationUuid("modelCustomizationUUID"); + expected.setServiceInstance(new ServiceInstance()); + expected.getServiceInstance().setModelInfoServiceInstance(new ModelInfoServiceInstance()); + expected.getServiceInstance().getModelInfoServiceInstance().setModelUuid("modelUUID"); + expected.getServiceInstance().getModelInfoServiceInstance().setServiceType("TRANSPORT"); + Service service = new Service(); + ServiceProxyResourceCustomization serviceProxyCatalog = new ServiceProxyResourceCustomization(); + serviceProxyCatalog.setModelCustomizationUUID("modelCustomizationUUID"); + Service sourceService = new Service(); + sourceService.setModelUUID("modelUUID"); + sourceService.setServiceType("TRANSPORT"); + serviceProxyCatalog.setSourceService(sourceService); + service.setServiceProxyCustomizations(new ArrayList<ServiceProxyResourceCustomization>()); + service.getServiceProxyCustomizations().add(serviceProxyCatalog); + ServiceProxy actual = SPY_bbInputSetup.getServiceProxy(service); + assertThat(actual, sameBeanAs(expected)); } @Test diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index e8d597a823..c5da3cbd51 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -68,6 +68,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { delegateExecution.setVariable("WorkflowException", new WorkflowException("", 7000, "")); delegateExecution.setVariable("buildingBlock", executeBuildingBlock); delegateExecution.setVariable("lookupKeyMap", lookupKeyMap); + + delegateExecution.setVariable("WorkflowException", new WorkflowException("processKey", 7000, "errorMessage")); } @Test @@ -101,12 +103,10 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setPolicy("Rollback"); rainyDayHandlerStatus.setWorkStep(ASTERISK); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); - assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); } @@ -126,15 +126,9 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setPolicy("Rollback"); rainyDayHandlerStatus.setWorkStep(ASTERISK); - doReturn(null).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "st1", "vnft1", "7000", ASTERISK); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", ASTERISK, ASTERISK, ASTERISK, ASTERISK); - + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", ASTERISK, ASTERISK, "errorMessage"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); - assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); assertEquals(5, delegateExecution.getVariable("maxRetries")); } @@ -145,9 +139,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); - doReturn(null).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), - isA(String.class), isA(String.class), isA(String.class), isA(String.class)); + doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatus(isA(String.class), isA(String.class), + isA(String.class), isA(String.class), isA(String.class), isA(String.class)); delegateExecution.setVariable("suppressRollback", false); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -157,9 +150,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { @Test public void queryRainyDayTableExceptionTest() { - doThrow(RuntimeException.class).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), - isA(String.class), isA(String.class), isA(String.class), isA(String.class)); + doThrow(RuntimeException.class).when(MOCK_catalogDbClient).getRainyDayHandlerStatus(isA(String.class), + isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class)); delegateExecution.setVariable("aLaCarte", true); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); delegateExecution.setVariable("suppressRollback", false); @@ -184,9 +176,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setWorkStep(ASTERISK); rainyDayHandlerStatus.setSecondaryPolicy("Abort"); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, false); @@ -210,9 +201,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setWorkStep(ASTERISK); rainyDayHandlerStatus.setSecondaryPolicy("Abort"); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -236,9 +226,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setWorkStep(ASTERISK); rainyDayHandlerStatus.setSecondaryPolicy("Abort"); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); 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 ef066853ca..5f9aef67e6 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 @@ -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. @@ -21,17 +21,67 @@ package org.onap.so.client.exception; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +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; +import org.junit.Before; import org.junit.Test; -import org.onap.so.bpmn.mock.FileUtil; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.onap.aai.domain.yang.Vserver; import org.onap.so.BaseTest; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.core.WorkflowException; +import org.onap.so.bpmn.mock.FileUtil; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import org.onap.so.objects.audit.AAIObjectAudit; +import org.onap.so.objects.audit.AAIObjectAuditList; +import org.springframework.beans.BeanUtils; +import com.fasterxml.jackson.core.JsonProcessingException; public class ExceptionBuilderTest extends BaseTest { private static final String RESOURCE_PATH = "__files/"; private static final String VALID_ERROR_MESSAGE = "{test error message}"; + @Mock + protected ExtractPojosForBB extractPojosForBB; + + @Spy + @InjectMocks + private ExceptionBuilder exceptionBuilder = new ExceptionBuilder(); + + GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); + + @Before + public void before() throws BBObjectNotFoundException, JsonProcessingException { + setCloudRegion(); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))) + .thenReturn(buildVfModule()); + AAIObjectAuditList auditList = new AAIObjectAuditList(); + auditList.setAuditType("create"); + auditList.setHeatStackName("testStackName"); + AAIObjectAudit vserver = new AAIObjectAudit(); + vserver.setAaiObjectType(AAIObjectType.VSERVER.typeName()); + vserver.setDoesObjectExist(false); + Vserver vs = new Vserver(); + vs.setVserverId("testVServerId"); + Vserver vServerShallow = new Vserver(); + BeanUtils.copyProperties(vs, vServerShallow, "LInterfaces"); + vserver.setAaiObject(vServerShallow); + auditList.getAuditList().add(vserver); + + execution.setVariable("auditInventoryResult", objectMapper.getMapper().writeValueAsString(auditList)); + } + @Test public void buildAndThrowWorkflowExceptionTest() { @@ -77,4 +127,35 @@ public class ExceptionBuilderTest extends BaseTest { assertEquals("MSOWorkflowException", bpmnException.getErrorCode()); } } + + @Test + public void processAuditExceptionTest() { + try { + Mockito.doReturn(extractPojosForBB).when(exceptionBuilder).getExtractPojosForBB(); + exceptionBuilder.processAuditException((DelegateExecutionImpl) execution, false); + } catch (BpmnError bpmnException) { + assertEquals("AAIInventoryFailure", bpmnException.getErrorCode()); + WorkflowException we = execution.getVariable("WorkflowException"); + assertNotNull(we); + assertEquals( + "create VF-Module testVfModuleId1 failed due to incomplete AAI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that the following was not created in AAI: vserver testVServerId.", + we.getErrorMessage()); + } + } + + @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 AAI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that the following was not created in AAI: vserver testVServerId.", + sm); + } catch (BpmnError bpmnException) { + fail(); + } + } + } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceMacro.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceMacro.json index 1cc387aaa0..97a230a1db 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceMacro.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceMacro.json @@ -3,7 +3,7 @@ "modelType": "service", "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersion": "10.0" }, "owningEntity": { @@ -31,7 +31,7 @@ "service": { "modelInfo": { "modelType": "service", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceName": "vPE_Service", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceMacroVrf.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceMacroVrf.json new file mode 100644 index 0000000000..32745e19f3 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/RequestDetailsInput_serviceMacroVrf.json @@ -0,0 +1,48 @@ +{ + "modelInfo": { + "modelType": "service", + "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", + "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", + "modelName": "Sample Service Model", + "modelVersion": "10.0" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "projectName" + }, + "subscriberInfo": { + "globalSubscriberId": "subscriberId" + }, + "requestInfo": { + "instanceName": "vPE_Service", + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "source": "VID", + "suppressRollback": true, + "requestorId": "xxxxxx" + }, + "requestParameters": { + "subscriptionServiceType": "VMX", + "aLaCarte": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "vpnBindingId", + "modelInfo": { + "modelType": "vpnBinding" + } + } + }, + { + "relatedInstance": { + "instanceId": "localNetworkId", + "modelInfo": { + "modelType": "network" + } + } + } + ] +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroNetworks.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroNetworks.json index f458d732d2..8d03005a9e 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroNetworks.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroNetworks.json @@ -1,7 +1,7 @@ { "modelInfo": { "modelType": "service", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceName": "vPE_Service", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroNoCloudConfig.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroNoCloudConfig.json index 0c3d8e709e..3201ec1bc0 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroNoCloudConfig.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroNoCloudConfig.json @@ -1,7 +1,7 @@ { "modelInfo": { "modelType": "service", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceName": "vPE_Service", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json index de20a5a963..fd6f8fad6a 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVfModules.json @@ -1,7 +1,7 @@ { "modelInfo": { "modelType": "service", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceName": "vPE_Service", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json index c4ad0ac047..80ea6b34ec 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ServiceMacroVnfs.json @@ -1,7 +1,7 @@ { "modelInfo": { "modelType": "service", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceName": "vPE_Service", diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json new file mode 100644 index 0000000000..418396f290 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json @@ -0,0 +1,73 @@ +{ + "networkId": "networkId", + "networkName": "networkName", + "networkType": null, + "networkRole": null, + "networkTechnology": null, + "neutronNetworkId": null, + "isBoundToVpn": true, + "serviceId": "serviceId", + "networkRoleInstance": 1234, + "resourceVersion": null, + "orchestrationStatus": "Assigned", + "heatStackId": "heatStackId", + "msoCatalogKey": null, + "contrailNetworkFqdn": "contrailNetworkFqdn", + "modelInvariantId": null, + "modelVersionId": null, + "personaModelVersion": null, + "modelCustomizationId": null, + "widgetModelId": "widgetModelId", + "widgetModelVersion": "widgetModelVersion", + "physicalNetworkName": "physicalNetworkName", + "isProviderNetwork": true, + "isSharedNetwork": true, + "isExternalNetwork": true, + "selflink": "selflink", + "operationalStatus": "operationalStatus", + "subnets": { + "subnet": [ + { + "subnetId": "subnetId", + "subnetName": "subnetName", + "neutronSubnetId": "neutronSubnetId", + "gatewayAddress": "10.80.12.1", + "networkStartAddress": "10.80.12.0", + "cidrMask": "23", + "ipVersion": "4", + "orchestrationStatus": "Active", + "dhcpEnabled": true, + "dhcpStart": "10.80.12.3", + "dhcpEnd": "10.80.13.254", + "subnetRole": "s1", + "ipAssignmentDirection": "true", + "resourceVersion": "1557499815393", + "hostRoutes": { + "hostRoute": [ + { + "hostRouteId": "91324351-01bf-43f8-a302-8c873451b4f1", + "routePrefix": "10.0.0.0/16", + "nextHop": "10.80.12.1", + "resourceVersion": "1557499777501" + } + ] + } + } + ] + }, + "ctagAssignments": { + "ctagAssignment": [ + { + "vlanIdInner": 1234 + } + ] + }, + "segmentationAssignments": { + "segmentationAssignment": [ + { + "segmentationId": "segmentationId" + } + ] + }, + "relationshipList": null +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json new file mode 100644 index 0000000000..ccefe195c9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json @@ -0,0 +1,56 @@ +{ + "network-id": "networkId", + "cascaded": null, + "cloud-params": { + + }, + "network-name": "networkName", + "is-bound-to-vpn": true, + "service-id": "serviceId", + "network-role-instance": 1234, + "orchestration-status": "ASSIGNED", + "heat-stack-id": "heatStackId", + "contrail-network-fqdn": "contrailNetworkFqdn", + "widget-model-id": "widgetModelId", + "widget-model-version": "widgetModelVersion", + "physical-network-name": "physicalNetworkName", + "is-provider-network": true, + "is-shared-network": true, + "is-external-network": true, + "self-link": "selflink", + "operational-status": "operationalStatus", + "subnets": [ + { + "subnet-id": "subnetId", + "subnet-name": "subnetName", + "neutron-subnet-id": "neutronSubnetId", + "gateway-address": "10.80.12.1", + "network-start-address": "10.80.12.0", + "cidr-mask": "23", + "ip-version": "4", + "dhcp-enabled": true, + "dhcp-start": "10.80.12.3", + "dhcp-end": "10.80.13.254", + "subnet-role": "s1", + "ip-assignment-direction": "true", + "host-routes": [ + { + "host-route-id": "91324351-01bf-43f8-a302-8c873451b4f1", + "route-prefix": "10.0.0.0/16", + "next-hop": "10.80.12.1" + } + ] + } + ], + "ctag-assignments": [ + { + "vlan-id-inner": 1234 + } + ], + "segmentation-assignments": [ + { + "segmentation-id": "segmentationId" + } + ], + "model-info-network": null +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json new file mode 100644 index 0000000000..0b3d9f0bbe --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/InstanceResourceList/InstanceResourceList.json @@ -0,0 +1,175 @@ +{ + "service":{ + "name":"SiteService", + "description":"SiteService", + "serviceInvariantUuid":"5c13f3fb-2744-4635-9f1f-c59c92dc8f70", + "serviceUuid":"3a76b1f5-fb0d-4b6b-82d5-0e8a4ebc3838", + "globalSubscriberId":"test_custormer", + "serviceType":"example-service-type", + "parameters":{ + "locationConstraints":[ + + ], + "resources":[ + { + "resourceIndex":"1", + "resourceName":"sdwanvpnresource", + "resourceInvariantUuid":"0c0e1cbe-6e01-4f9e-8c45-a9700ebc14df", + "resourceUuid":"4ad2d390-5c51-45f5-9710-b467a4ec7a73", + "resourceCustomizationUuid":"66590e07-0777-415c-af44-36347cf3ddd3", + "parameters":{ + "locationConstraints":[ + + ], + "resources":[ + + ], + "requestInputs":{ + + } + } + }, + { + "resourceIndex":"1", + "resourceName":"sdwansiteresource", + "resourceInvariantUuid":"97a3e552-08c4-4697-aeeb-d8d3e09ce58e", + "resourceUuid":"63d8e1af-32dc-4c71-891d-e3f7b6a976d2", + "resourceCustomizationUuid":"205456e7-3dc0-40c4-8cb0-28e6c1877042", + "parameters":{ + "locationConstraints":[ + + ], + "resources":[ + + ], + "requestInputs":{ + + } + } + }, + { + "resourceIndex":"2", + "resourceName":"sdwansiteresource", + "resourceInvariantUuid":"97a3e552-08c4-4697-aeeb-d8d3e09ce58e", + "resourceUuid":"63d8e1af-32dc-4c71-891d-e3f7b6a976d2", + "resourceCustomizationUuid":"205456e7-3dc0-40c4-8cb0-28e6c1877042", + "parameters":{ + "locationConstraints":[ + + ], + "resources":[ + + ], + "requestInputs":{ + + } + } + } + ], + "requestInputs":{ + "sdwanvpnresource_list":[ + { + "sdwanvpn_topology":"hub_spoke", + "sdwanvpn_name":"defaultvpn", + "sdwansitelan_list":[ + { + "role":"Hub", + "portType":"GE", + "portSwitch":"layer3-port", + "vlanId":"", + "ipAddress":"192.168.10.1", + "deviceName":"vCPE", + "portNumer":"0/0/1" + }, + { + "role":"Hub", + "portType":"GE", + "portSwitch":"layer2-port", + "vlanId":"55", + "ipAddress":"192.168.11.1", + "deviceName":"CPE_Beijing", + "portNumer":"0/0/1" + } + ] + } + ], + "sdwansiteresource_list":[ + { + "sdwansite_emails":"chenchuanyu@huawei.com", + "sdwansite_address":"Huawei Public Cloud", + "sdwansite_description":"DC Site", + "sdwansite_role":"dsvpn_hub", + "sdwansite_postcode":"20000", + "sdwansite_type":"single_gateway", + "sdwansite_latitude":"", + "sdwansite_controlPoint":"", + "sdwansite_longitude":"", + "sdwansitewan_list":[ + { + "providerIpAddress":"", + "portType":"GE", + "inputBandwidth":"1000", + "ipAddress":"", + "name":"10000", + "transportNetworkName":"internet", + "outputBandwidth":"10000", + "deviceName":"vCPE", + "portNumber":"0/0/0", + "ipMode":"DHCP", + "publicIP":"119.3.7.113" + } + ], + "sdwandevice_list":[ + { + "esn":"XXXXXXX", + "vendor":"Huawei", + "name":"vCPE", + "type":"AR1000V", + "version":"1.0", + "class":"VNF", + "systemIp":"20.20.20.1" + } + ] + }, + { + "sdwansite_emails":"chenchuanyu@huawei.com", + "sdwansite_address":"Huawei Public Cloud", + "sdwansite_description":"DC Site", + "sdwansite_role":"dsvpn_hub", + "sdwansite_postcode":"20000", + "sdwansite_type":"single_gateway", + "sdwansite_latitude":"", + "sdwansite_controlPoint":"", + "sdwansite_longitude":"", + "sdwansitewan_list":[ + { + "providerIpAddress":"", + "portType":"GE", + "inputBandwidth":"1000", + "ipAddress":"172.18.1.2/24", + "name":"10000", + "transportNetworkName":"internet", + "outputBandwidth":"10000", + "deviceName":"CPE_Beijing", + "portNumber":"0/0/0", + "ipMode":"Static", + "publicIP":"" + } + ], + "sdwandevice_list":[ + { + "esn":"XXXXXXX", + "vendor":"Huawei", + "name":"CPE_Beijing", + "type":"AR161", + "version":"1.0", + "class":"PNF", + "systemIp":"20.20.20.2" + } + ] + } + ] + } + } + } +}
\ No newline at end of file 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 new file mode 100644 index 0000000000..4803fca355 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/SERVICE-SO-REQ-INPUT.json @@ -0,0 +1,299 @@ +{ + "serviceResources": { + "modelInfo": { + "modelName": "demoVFWCL", + "modelUuid": "c3954379-4efe-431c-8258-f84905b158e5", + "modelInvariantUuid": "0cbff61e-3b0a-4eed-97ce-b1b4faa03493", + "modelVersion": "1.0" + }, + "serviceType": "", + "serviceRole": "", + "environmentContext": null, + "resourceOrder": "res1,res2", + "workloadContext": "Production", + "serviceVnfs": [ + + { + "modelInfo": { + "modelName": "15968a6e-2fe5-41bf-a481", + "modelUuid": "808abda3-2023-4105-92d2-e62644b61d53", + "modelInvariantUuid": "6e4ffc7c-497e-4a77-970d-af966e642d31", + "modelVersion": "1.0", + "modelCustomizationUuid": "a00404d5-d7eb-4c46-b6b6-9cf2d087e545", + "modelInstanceName": "15968a6e-2fe5-41bf-a481 0" + }, + "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\"}", + "resourceType": "VNF", + "nfRole": null, + "nfNamingCode": null, + "multiStageDesign": "false", + "vfModules": [{ + "modelInfo": { + "modelName": "15968a6e2fe541bfA481..base_vfw..module-0", + "modelUuid": "ec7fadde-1e5a-42f7-8255-cb19e475ff45", + "modelInvariantUuid": "61ab8b64-a014-4cf3-8a5a-b5ef388f8819", + "modelVersion": "1", + "modelCustomizationUuid": "123aff6b-854f-4026-ae1e-cc74a3924576" + }, + "isBase": true, + "vfModuleLabel": "base_vfw", + "initialCount": 1, + "hasVolumeGroup": true + }] + }, + + { + "modelInfo": { + "modelName": "f971106a-248f-4202-9d1f", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add7e", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89f3", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88ca1a0", + "modelInstanceName": "f971106a-248f-4202-9d1f 0" + }, + "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f", + "nfFunction": 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, + "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-9d1e", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add7d", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89f2", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88ca1a1", + "modelInstanceName": "f971106a-248f-4202-9d1e 0" + }, + "toscaNodeType": "org.openecomp.resource.vfc.F971106a248f42029d1f", + "nfFunction": 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, + "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-9d2e", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add8d", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89c2", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88ca1c1", + "modelInstanceName": "f971106a-248f-4202-9d2e 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-9d3e", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add9d", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe89f3", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88cb1a1", + "modelInstanceName": "f971106a-248f-4202-9d3e 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-9d5e", + "modelUuid": "4fbc08a4-35ed-4a59-9e47-79975e4add3d", + "modelInvariantUuid": "c669799e-adf1-46ae-8c70-48b326fe8393", + "modelVersion": "1.0", + "modelCustomizationUuid": "e776449e-2b10-45c5-9217-2775c88cb1f1", + "modelInstanceName": "f971106a-248f-4202-9d5e 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 + }] + }, + + { + "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 + }] + } + + ], + "serviceNetworks": [], + "serviceAllottedResources": [] + } +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/UUI-SO-REQ.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/UUI-SO-REQ.json new file mode 100644 index 0000000000..e6161862ae --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/UUI-SO-REQ.json @@ -0,0 +1 @@ +{
"sdwanvpnresource_list":[
{
"sdwanvpn_topology":"hub_spoke",
"sdwanvpn_name":"defaultvpn",
"sdwansitelan_list":[
{
"role":"Hub",
"portType":"GE",
"portSwitch":"layer3-port",
"vlanId":"",
"ipAddress":"192.168.10.1",
"deviceName":"vCPE",
"portNumer":"0/0/1"
},
{
"role":"Hub",
"portType":"GE",
"portSwitch":"layer2-port",
"vlanId":"55",
"ipAddress":"192.168.11.1",
"deviceName":"CPE_Beijing",
"portNumer":"0/0/1"
}
]
}
],
"sdwansiteresource_list":[
{
"sdwansite_emails":"chenchuanyu@huawei.com",
"sdwansite_address":"Huawei Private Cloud",
"sdwansite_description":"DC Site",
"sdwansite_role":"dsvpn_hub1",
"sdwansite_postcode":"20000",
"sdwansite_type":"single_gateway",
"sdwansite_latitude":"",
"sdwansite_controlPoint":"",
"sdwansite_longitude":"",
"sdwansitewan_list":[
{
"providerIpAddress":"",
"portType":"GE",
"inputBandwidth":"1000",
"ipAddress":"",
"name":"10000",
"transportNetworkName":"internet",
"outputBandwidth":"10000",
"deviceName":"vCPE",
"portNumber":"0/0/0",
"ipMode":"DHCP",
"publicIP":"119.3.7.113"
}
],
"sdwandevice_list":[
{
"esn":"XXXXXXX",
"vendor":"Huawei",
"name":"vCPE",
"type":"AR1000V",
"version":"1.0",
"class":"VNF",
"systemIp":"20.20.20.1"
}
]
},
{
"sdwansite_emails":"chenchuanyu@huawei.com",
"sdwansite_address":"Huawei Public Cloud",
"sdwansite_description":"DC Site",
"sdwansite_role":"dsvpn_hub",
"sdwansite_postcode":"20001",
"sdwansite_type":"multiple_gateway",
"sdwansite_latitude":"",
"sdwansite_controlPoint":"",
"sdwansite_longitude":"",
"sdwansitewan_list":[
{
"providerIpAddress":"",
"portType":"GE",
"inputBandwidth":"1000",
"ipAddress":"172.18.1.2/24",
"name":"10000",
"transportNetworkName":"internet",
"outputBandwidth":"10000",
"deviceName":"CPE_Beijing",
"portNumber":"0/0/0",
"ipMode":"Static",
"publicIP":""
}
],
"sdwandevice_list":[
{
"esn":"XXXXXXX",
"vendor":"Huawei",
"name":"CPE_Beijing",
"type":"AR161",
"version":"1.0",
"class":"PNF",
"systemIp":"20.20.20.2"
}
]
}
]
}
\ No newline at end of file diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java index a3f5253765..6f8d34e760 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java @@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory; */ public class ResponseBuilder implements java.io.Serializable { private static final long serialVersionUID = 1L; + private static final String WORKFLOWEXCEPTION = "WorkflowException"; private static final Logger logger = LoggerFactory.getLogger(ResponseBuilder.class); /** @@ -61,7 +62,7 @@ public class ResponseBuilder implements java.io.Serializable { logger.debug("processKey=" + processKey); // See if there"s already a WorkflowException object in the execution. - WorkflowException theException = (WorkflowException) execution.getVariable("WorkflowException"); + WorkflowException theException = (WorkflowException) execution.getVariable(WORKFLOWEXCEPTION); if (theException != null) { logger.debug("Exited " + method + " - propagated " + theException); @@ -138,7 +139,7 @@ public class ResponseBuilder implements java.io.Serializable { // Create a new WorkflowException object theException = new WorkflowException(processKey, intResponseCode, errorResponse); - execution.setVariable("WorkflowException", theException); + execution.setVariable(WORKFLOWEXCEPTION, theException); logger.debug("Exited " + method + " - created " + theException); return theException; } @@ -163,7 +164,7 @@ public class ResponseBuilder implements java.io.Serializable { Object theResponse = null; - WorkflowException theException = (WorkflowException) execution.getVariable("WorkflowException"); + WorkflowException theException = (WorkflowException) execution.getVariable(WORKFLOWEXCEPTION); String errorResponse = trimString(execution.getVariable(prefix + "ErrorResponse"), null); String responseCode = trimString(execution.getVariable(prefix + "ResponseCode"), null); @@ -222,7 +223,7 @@ public class ResponseBuilder implements java.io.Serializable { } String s = String.valueOf(object).trim(); - return s.equals("") ? emptyStringValue : s; + return "".equals(s) ? emptyStringValue : s; } /** diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java index 841eaee675..c37b77d332 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java @@ -22,7 +22,6 @@ package org.onap.so.bpmn.core.domain; import java.util.UUID; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonRootName; /** @@ -35,14 +34,6 @@ public class AllottedResource extends Resource { private static final long serialVersionUID = 1L; /* - * set resourceType for this object - */ - public AllottedResource() { - resourceType = ResourceType.ALLOTTED_RESOURCE; - setResourceId(UUID.randomUUID().toString()); - } - - /* * fields specific to Allotted Resource resource type */ private String allottedResourceType; @@ -60,6 +51,14 @@ public class AllottedResource extends Resource { private String resourceInput; /* + * set resourceType for this object + */ + public AllottedResource() { + resourceType = ResourceType.ALLOTTED_RESOURCE; + setResourceId(UUID.randomUUID().toString()); + } + + /* * GET and SET */ public String getAllottedResourceType() { diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/GroupResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/GroupResource.java new file mode 100644 index 0000000000..79714d0f0e --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/GroupResource.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 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.onap.so.bpmn.core.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import java.util.UUID; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class GroupResource extends Resource { + private static final long serialVersionUID = 1L; + + @JsonProperty("vnfcs") + private List<VnfcResource> vnfcs; + + public GroupResource() { + resourceType = ResourceType.GROUP; + setResourceId(UUID.randomUUID().toString()); + } + + public List<VnfcResource> getVnfcs() { + return vnfcs; + } + + public void setVnfcs(List<VnfcResource> vnfcs) { + this.vnfcs = vnfcs; + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java index 897cbe3573..309b053589 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.core.domain; import java.io.Serializable; -import java.util.List; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonRootName; diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java index 602172f8a4..bf53c880e9 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java @@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory; */ @JsonInclude(Include.NON_NULL) public abstract class JsonWrapper implements Serializable { + private static final String EXCEPTION = "Exception :"; private static final Logger logger = LoggerFactory.getLogger(JsonWrapper.class); @@ -63,7 +64,7 @@ public abstract class JsonWrapper implements Serializable { jsonString = ow.writeValueAsString(this); } catch (Exception e) { - logger.debug("Exception :", e); + logger.debug(EXCEPTION, e); } return jsonString; } @@ -76,14 +77,10 @@ public abstract class JsonWrapper implements Serializable { JSONObject json = new JSONObject(); try { json = new JSONObject(mapper.writeValueAsString(this)); - } catch (JsonGenerationException e) { - logger.debug("Exception :", e); - } catch (JsonMappingException e) { - logger.debug("Exception :", e); - } catch (JSONException e) { - logger.debug("Exception :", e); + } catch (JsonGenerationException | JsonMappingException | JSONException e) { + logger.debug(EXCEPTION, e); } catch (IOException e) { - logger.debug("Exception :", e); + logger.debug(EXCEPTION, e); } return json; } @@ -95,12 +92,10 @@ public abstract class JsonWrapper implements Serializable { String jsonString = ""; try { jsonString = mapper.writeValueAsString(list); - } catch (JsonGenerationException e) { - logger.debug("Exception :", e); - } catch (JsonMappingException e) { - logger.debug("Exception :", e); + } catch (JsonGenerationException | JsonMappingException e) { + logger.debug(EXCEPTION, e); } catch (IOException e) { - logger.debug("Exception :", e); + logger.debug(EXCEPTION, e); } return jsonString; } @@ -118,7 +113,7 @@ public abstract class JsonWrapper implements Serializable { jsonString = ow.writeValueAsString(this); } catch (Exception e) { - logger.debug("Exception :", e); + logger.debug(EXCEPTION, e); } return jsonString; } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/License.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/License.java index 1db360f391..4d70d0f14b 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/License.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/License.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -22,7 +24,6 @@ package org.onap.so.bpmn.core.domain; import java.io.Serializable; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.json.JSONArray; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -40,9 +41,9 @@ public class License extends JsonWrapper implements Serializable { private static final long serialVersionUID = 1L; @JsonInclude(JsonInclude.Include.NON_EMPTY) - private List<String> entitlementPoolList = new ArrayList<String>(); + private List<String> entitlementPoolList = new ArrayList(); @JsonInclude(JsonInclude.Include.NON_EMPTY) - private List<String> licenseKeyGroupList = new ArrayList<String>(); + private List<String> licenseKeyGroupList = new ArrayList<>(); public List<String> getEntitlementPoolList() { diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Request.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Request.java index 6c33d37cfe..eb24c96bca 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Request.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/Request.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,7 +23,6 @@ package org.onap.so.bpmn.core.domain; import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonRootName; /** * This class is used to store instance data of services aka ServiceDecomposition diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceDecomposition.java index b291765252..7dbf97d223 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceDecomposition.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceDecomposition.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -27,7 +29,6 @@ import com.fasterxml.jackson.annotation.JsonIgnore; * Abstract superclass for all individual decomposition resources * */ -// @JsonIgnoreProperties public abstract class ResourceDecomposition extends JsonWrapper implements Serializable { private static final long serialVersionUID = 1L; @@ -74,9 +75,6 @@ public abstract class ResourceDecomposition extends JsonWrapper implements Seria public String getResourceInstanceName() { return this.getInstanceData().getInstanceName(); } - // @JsonIgnore - // public String getResourceHomingSolution() { - // } public void setResourceInstanceId(String newInstanceId) { this.getInstanceData().setInstanceId(newInstanceId); @@ -85,7 +83,4 @@ public abstract class ResourceDecomposition extends JsonWrapper implements Seria public void setResourceInstanceName(String newInstanceName) { this.getInstanceData().setInstanceName(newInstanceName); } - // @JsonIgnore - // public String setResourceHomingSolution() { - // } } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java index a30d0df825..0e17d4c826 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ResourceType.java @@ -22,5 +22,5 @@ package org.onap.so.bpmn.core.domain; public enum ResourceType { - VNF, NETWORK, MODULE, ALLOTTED_RESOURCE, CONFIGURATION // etc. + VNF, NETWORK, MODULE, ALLOTTED_RESOURCE, CONFIGURATION, GROUP, VNFC // etc. } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java index 419f545cdf..3632d187c9 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/ServiceDecomposition.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -24,7 +26,6 @@ package org.onap.so.bpmn.core.domain; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; @@ -32,6 +33,8 @@ import com.fasterxml.jackson.annotation.JsonRootName; import org.json.JSONObject; import org.onap.so.bpmn.core.json.DecomposeJsonUtil; import org.onap.so.bpmn.core.json.JsonDecomposingException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @@ -41,10 +44,10 @@ import org.onap.so.bpmn.core.json.JsonDecomposingException; * resource's decompositon */ @JsonRootName(value = "serviceResources") -// @JsonTypeInfo(include=As.WRAPPER_OBJECT, use=Id.NAME) public class ServiceDecomposition extends JsonWrapper implements Serializable { private static final long serialVersionUID = 1L; + private static final Logger logger = LoggerFactory.getLogger(ServiceDecomposition.class); @JsonProperty("modelInfo") private ModelInfo modelInfo; @@ -245,7 +248,7 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { */ @JsonIgnore public List<Resource> getServiceResources() { - ArrayList serviceResources = new ArrayList(); + ArrayList<Resource> serviceResources = new ArrayList(); if (this.getAllottedResources() != null) { serviceResources.addAll(this.getAllottedResources()); } @@ -315,8 +318,6 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { public String getVnfResource(String resourceObjectId) { for (Resource resource : getServiceResources()) { - // resource.getModelInfo().getModelInvariantId(); - if ("extracted information".equals(resourceObjectId)) { return resource.toJsonString(); } @@ -457,11 +458,11 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { boolean result = false; for (Resource resource : (Iterable<Resource>) resources) { - System.out.println("resource found"); + logger.debug("resource found"); if (resource.resourceType == newResource.resourceType) { - System.out.println("resource type matches"); + logger.debug("resource type matches"); if (resource.getResourceId().equalsIgnoreCase(newResource.getResourceId())) { - System.out.println("resource id matches"); + logger.debug("resource id matches"); // returns TRUE if replacement is a success result = Collections.replaceAll(resources, resource, newResource); } @@ -491,14 +492,12 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { public boolean deleteResource(Resource resource) { List serviceResourceList = getResourceList(resource); for (Resource item : (Iterable<Resource>) serviceResourceList) { - if (item.resourceType == resource.resourceType) { - if (item.getResourceId().equalsIgnoreCase(resource.getResourceId())) { - // returns TRUE if replacement is a success - return serviceResourceList.remove(resource); - } + if (item.resourceType == resource.resourceType + && item.getResourceId().equalsIgnoreCase(resource.getResourceId())) { + // returns TRUE if replacement is a success + return serviceResourceList.remove(resource); } } - return false; } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java index f66ad36058..9688a57630 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java @@ -32,6 +32,7 @@ import com.fasterxml.jackson.annotation.JsonRootName; * Encapsulates VNF resource data set * */ +@JsonIgnoreProperties(ignoreUnknown = true) @JsonRootName("vnfResource") public class VnfResource extends Resource { @@ -50,6 +51,13 @@ public class VnfResource extends Resource { */ @JsonProperty("vfModules") private List<ModuleResource> vfModules; + + @JsonProperty("groups") + private List<GroupResource> groups; + + @JsonProperty("vnfcInstGroupOrder") + private String groupOrder; + private String vnfHostname; private String vnfType; private String nfFunction; @@ -59,7 +67,7 @@ public class VnfResource extends Resource { private String multiStageDesign; private String orchestrationStatus; - @JsonIgnore + @JsonProperty("resourceInput") private String resourceInput; /* @@ -150,6 +158,22 @@ public class VnfResource extends Resource { this.resourceInput = resourceInput; } + public List<GroupResource> getGroups() { + return groups; + } + + public void setGroups(List<GroupResource> groups) { + this.groups = groups; + } + + public String getGroupOrder() { + return groupOrder; + } + + public void setGroupOrder(String groupOrder) { + this.groupOrder = groupOrder; + } + /** * Returns a list of all VfModule objects. Base module is first entry in the list * diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfcResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfcResource.java new file mode 100644 index 0000000000..50bd3e2355 --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfcResource.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 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.onap.so.bpmn.core.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.UUID; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class VnfcResource extends Resource { + private static final long serialVersionUID = 1L; + + @JsonProperty("resourceInput") + private String resourceInput; + + public VnfcResource() { + resourceType = ResourceType.VNFC; + setResourceId(UUID.randomUUID().toString()); + } + + public String getResourceInput() { + return resourceInput; + } + + public void setResourceInput(String resourceInput) { + this.resourceInput = resourceInput; + } +} diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java index 5db277628e..7ef7deea30 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/ServiceDecompositionTest.java @@ -52,6 +52,22 @@ public class ServiceDecompositionTest { configResource.setResourceId("configResourceId"); } + + @Test + public void serviceDecompositionWithGroupandVnfc() throws IOException { + String sericeStr = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "ServiceWithGroupandVnfc.json"))); + ServiceDecomposition serviceDecomposition = new ServiceDecomposition(sericeStr); + + assertEquals(1, serviceDecomposition.getVnfResources().size()); + assertEquals(1, serviceDecomposition.getVnfResources().get(0).getGroups().size()); + assertEquals(1, serviceDecomposition.getVnfResources().get(0).getGroups().get(0).getVnfcs().size()); + + VnfcResource vnfcResource = serviceDecomposition.getVnfResources().get(0).getGroups().get(0).getVnfcs().get(0); + + assertEquals("xfs", vnfcResource.getModelInfo().getModelName()); + assertEquals("22", vnfcResource.getModelInfo().getModelUuid()); + } + @Test public void serviceDecompositionTest() throws JsonProcessingException, IOException { // covering methods not covered by openpojo test diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java index 09bcfe8470..de7b21ed73 100644 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java +++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java @@ -14,12 +14,13 @@ */ package org.onap.so.bpmn.core.domain; -import static org.junit.Assert.*; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Test; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class VnfResourceTest { @@ -58,6 +59,19 @@ public class VnfResourceTest { VnfResource vnfResource = objectMapper.readValue(jsonStr, VnfResource.class); assertTrue(vnfResource != null); + assertEquals("sample", vnfResource.getResourceInput()); + assertEquals("home", vnfResource.getVnfHostname()); + } + + @Test + public void vnfResourceMapperTestNoResourceInput() throws IOException { + String jsonStr = "{\"vnfHostname\": \"home\"}"; + ObjectMapper objectMapper = new ObjectMapper(); + VnfResource vnfResource = objectMapper.readValue(jsonStr, VnfResource.class); + + assertTrue(vnfResource != null); + assertEquals(null, vnfResource.getResourceInput()); + assertEquals("home", vnfResource.getVnfHostname()); } @Test diff --git a/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceWithGroupandVnfc.json b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceWithGroupandVnfc.json new file mode 100644 index 0000000000..9d0326e66a --- /dev/null +++ b/bpmn/MSOCoreBPMN/src/test/resources/json-examples/ServiceWithGroupandVnfc.json @@ -0,0 +1,58 @@ +{ + "serviceResources": { + "modelInfo": { + "modelName": "NSService", + "modelUuid": "0bad8c92-7d22-49f0-b092-b64e6ca564a7", + "modelInvariantUuid": "69161960-515b-4bf3-91f1-313b813f5e1d", + "modelVersion": "1.0" + }, + "serviceType": "", + "serviceRole": "", + "environmentContext": "General_Revenue-Bearing", + "resourceOrder": "NF", + "workloadContext": "Production", + "serviceVnfs": [ + { + "modelInfo": { + "modelName": "", + "modelUuid": "123", + "modelInvariantUuid": "", + "modelVersion": "", + "modelCustomizationUuid": "1234", + "modelInstanceName": "test" + }, + "toscaNodeType": "", + "nfFunction": "", + "nfType": "", + "nfRole": "", + "nfNamingCode": "", + "multiStageDesign": "", + "resourceInput": "", + "vfModules": [], + "groups": [ + { + "modelInfo": { + "modelName": "test", + "modelUuid": "11", + "modelInvariantUuid": "11", + "modelVersion": "2" + }, + "vnfcs": [ + { + "modelInfo": { + "modelName": "xfs", + "modelUuid": "22", + "modelInvariantUuid": "2222", + "modelVersion": "22222", + "modelCustomizationUuid": "2222" + } + } + ] + } + ] + } + ], + "serviceNetworks": [], + "serviceAllottedResources": [] + } +}
\ No newline at end of file diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/DeleteVnfNotification.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/DeleteVnfNotification.java index cd4257ec60..e0760b5d4a 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/DeleteVnfNotification.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/adapter/vnf/DeleteVnfNotification.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -160,12 +162,4 @@ public class DeleteVnfNotification { return deleteVnfNotification; } - /* - * public String toString() { StringWriter writer = new StringWriter(); try { JAXBContext context = JAXBContext - * .newInstance(DeleteVnfNotification.class); Marshaller m = context.createMarshaller(); - * m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(this, writer); - * //System.out.println("toString() - " + writer.getBuffer().toString()); return writer.getBuffer().toString(); } - * catch (JAXBException e) { //System.out.println("JAXBException - " + e.getStackTrace()); return ""; } } - */ - } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java index 7c0c2f20b3..13ba46a852 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.MismatchingMessageCorrelationException; import org.camunda.bpm.engine.OptimisticLockingException; import org.camunda.bpm.engine.RuntimeService; @@ -207,7 +208,7 @@ public class CallbackHandlerService { + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "'; last exception was:" + queryException; logger.debug(msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", ErrorCode.UnknownError.getValue(), msg, queryException); } @@ -245,8 +246,8 @@ public class CallbackHandlerService { String msg = "Caught " + ole.getClass().getSimpleName() + " after receiving " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "': " + ole; logger.debug(msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN CORRELATION ERROR -", - ErrorCode.UnknownError.getValue(), msg, ole); + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), + "BPMN CORRELATION ERROR -", ErrorCode.UnknownError.getValue(), msg, ole); // Retry for OptimisticLocking Exceptions int retryCount = 0; @@ -279,7 +280,7 @@ public class CallbackHandlerService { String strMsg = "Received exception, OptimisticLockingException retry failed, retryCount:" + retryCount + " | exception returned: " + olex; logger.debug(strMsg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", ErrorCode.UnknownError.getValue(), strMsg, olex); } catch (Exception excep) { retryCount = 0; @@ -287,7 +288,7 @@ public class CallbackHandlerService { String strMsg = "Received exception, OptimisticLockingException retry failed, retryCount:" + retryCount + " | exception returned: " + excep; logger.debug(strMsg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", ErrorCode.UnknownError.getValue(), strMsg, excep); } @@ -300,7 +301,7 @@ public class CallbackHandlerService { + " after receiving " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "': " + e; logger.debug(msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", ErrorCode.UnknownError.getValue(), msg, e); } } catch (Exception e) { @@ -309,7 +310,7 @@ public class CallbackHandlerService { String msg = "Caught " + e.getClass().getSimpleName() + " after receiving " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "': " + e; logger.debug(msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN CORRELATION ERROR -", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN CORRELATION ERROR -", ErrorCode.UnknownError.getValue(), msg, e); } @@ -345,10 +346,10 @@ public class CallbackHandlerService { */ protected void logCallbackError(String method, long startTime, String msg, Exception e) { if (e == null) { - logger.error("{} {} {} {}", MessageEnum.BPMN_CALLBACK_EXCEPTION.toString(), "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_CALLBACK_EXCEPTION.toString(), "BPMN", ErrorCode.UnknownError.getValue(), msg); } else { - logger.error("{} {} {} {}", MessageEnum.BPMN_CALLBACK_EXCEPTION.toString(), "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_CALLBACK_EXCEPTION.toString(), "BPMN", ErrorCode.UnknownError.getValue(), msg, e); } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java index 1e9ebdf0b2..f76fde9ef1 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java @@ -32,6 +32,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackError; import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult; import org.onap.so.logger.ErrorCode; @@ -78,7 +79,7 @@ public class WorkflowMessageResource { if (messageType == null || messageType.isEmpty()) { String msg = "Missing message type"; logger.debug(LOGMARKER + " " + msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", ErrorCode.DataError.getValue(), LOGMARKER + ":" + msg); return Response.status(400).entity(msg).build(); } @@ -86,7 +87,7 @@ public class WorkflowMessageResource { if (correlator == null || correlator.isEmpty()) { String msg = "Missing correlator"; logger.debug(LOGMARKER + " " + msg); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", ErrorCode.DataError.getValue(), LOGMARKER + ":" + msg); return Response.status(400).entity(msg).build(); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java index 9d63e8eaf1..20f3eb4fee 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java @@ -36,6 +36,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.HistoryService; import org.camunda.bpm.engine.ProcessEngineException; import org.camunda.bpm.engine.ProcessEngineServices; @@ -195,7 +196,7 @@ public class WorkflowResource extends ProcessEngineAwareService { if (processInstance != null) workflowResponse.setProcessInstanceID(processInstance.getId()); - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "BPMN", MDC.get(processKey), ErrorCode.UnknownError.getValue(), LOGMARKER + workflowResponse.getMessage() + " for processKey: " + processKey + " with response: " + workflowResponse.getResponse()); @@ -581,7 +582,7 @@ public class WorkflowResource extends ProcessEngineAwareService { response.setResponse("Failed to retrieve the variables," + ex.getMessage()); response.setProcessInstanceID(processInstanceId); - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "BPMN", MDC.get(processKey), ErrorCode.UnknownError.getValue(), LOGMARKER + response.getMessage() + " for processKey: " + processKey + " with response: " + response.getResponse()); logger.debug("Exception :", ex); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 296ab64df3..251464a34d 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -22,16 +22,8 @@ package org.onap.so.bpmn.core.plugins; -import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; import org.camunda.bpm.engine.RepositoryService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.ExecutionListener; @@ -39,26 +31,15 @@ import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener; import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener; import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin; import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; -import org.camunda.bpm.engine.impl.context.Context; -import org.camunda.bpm.engine.impl.interceptor.Command; -import org.camunda.bpm.engine.impl.interceptor.CommandContext; import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl; import org.camunda.bpm.engine.impl.pvm.process.TransitionImpl; import org.camunda.bpm.engine.impl.util.xml.Element; import org.camunda.bpm.engine.impl.variable.VariableDeclaration; -import org.camunda.bpm.model.bpmn.impl.instance.FlowNodeImpl; -import org.camunda.bpm.model.bpmn.instance.EndEvent; -import org.camunda.bpm.model.bpmn.instance.FlowNode; -import org.camunda.bpm.model.bpmn.instance.StartEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.AbstractEnvironment; -import org.springframework.core.env.Environment; -import org.springframework.core.env.MapPropertySource; -import org.springframework.core.env.PropertySource; import org.springframework.stereotype.Component; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java index ab21c0807e..42c6ef059f 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java @@ -32,7 +32,6 @@ import org.camunda.bpm.engine.delegate.JavaDelegate; import org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior; import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener; import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener; -import org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration; import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin; import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; @@ -58,6 +57,8 @@ import org.slf4j.LoggerFactory; public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { private static final Logger logger = LoggerFactory.getLogger(WorkflowExceptionPlugin.class); + private static final String WORKFLOW_EXCEPTION = "WorkflowException"; + @Override public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners(); @@ -131,7 +132,7 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { */ public static class WorkflowExceptionResetListener implements ExecutionListener { public void notify(DelegateExecution execution) throws Exception { - Object workflowException = execution.getVariable("WorkflowException"); + Object workflowException = execution.getVariable(WORKFLOW_EXCEPTION); if (workflowException instanceof WorkflowException) { int index = 1; @@ -140,10 +141,10 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { saveName = "SavedWorkflowException" + (++index); } - logger.debug("WorkflowExceptionResetTask is moving WorkflowException to " + saveName); + logger.debug("WorkflowExceptionResetTask is moving WorkflowException to {}", saveName); execution.setVariable(saveName, workflowException); - execution.setVariable("WorkflowException", null); + execution.setVariable(WORKFLOW_EXCEPTION, null); } } } @@ -153,7 +154,7 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { */ public static class WorkflowExceptionTriggerTask implements JavaDelegate { public void execute(DelegateExecution execution) throws Exception { - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { + if (execution.getVariable(WORKFLOW_EXCEPTION) instanceof WorkflowException) { logger.debug("WorkflowExceptionTriggerTask is generating a MSOWorkflowException event"); throw new BpmnError("MSOWorkflowException"); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CamundaDBConfig.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CamundaDBConfig.java new file mode 100644 index 0000000000..686b377727 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CamundaDBConfig.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure; + + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jmx.export.MBeanExporter; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; + +@Configuration +@EnableTransactionManagement +@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", + basePackages = {"org.onap.so.db.catalog.data.repository"}) +@Profile({"!test"}) +public class CamundaDBConfig { + + @Autowired(required = false) + private MBeanExporter mBeanExporter; + + @Bean + @ConfigurationProperties(prefix = "spring.datasource.hikari") + public HikariConfig camundaDbConfig() { + return new HikariConfig(); + } + + @Primary + @Bean(name = "dataSource") + public DataSource dataSource() { + if (mBeanExporter != null) { + mBeanExporter.addExcludedBean("dataSource"); + } + HikariConfig hikariConfig = this.camundaDbConfig(); + return new HikariDataSource(hikariConfig); + } + + @Primary + @Bean(name = "entityManagerFactory") + public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder, + @Qualifier("dataSource") DataSource dataSource) { + return builder.dataSource(dataSource).packages("org.onap.so.db.catalog.beans").persistenceUnit("catalogDB") + .build(); + } + + @Primary + @Bean(name = "transactionManager") + public PlatformTransactionManager transactionManager( + @Qualifier("entityManagerFactory") EntityManagerFactory entityManagerFactory) { + return new JpaTransactionManager(entityManagerFactory); + } + +} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java index 8168d2a4b8..093fba089d 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java @@ -24,6 +24,7 @@ package org.onap.so.bpmn.infrastructure; import java.util.List; import java.util.concurrent.Executor; +import org.onap.so.logger.LoggingAnchor; import javax.annotation.PostConstruct; import org.camunda.bpm.application.PreUndeploy; import org.camunda.bpm.application.ProcessApplicationInfo; @@ -123,7 +124,7 @@ public class MSOInfrastructureApplication { logger.debug("Attempting to deploy custom workflows"); try { List<Workflow> workflows = catalogDbClient.findWorkflowBySource(SDC_SOURCE); - if (workflows != null && workflows.size() != 0) { + if (workflows != null && !workflows.isEmpty()) { for (Workflow workflow : workflows) { String workflowName = workflow.getName(); String workflowBody = workflow.getBody(); @@ -131,12 +132,12 @@ public class MSOInfrastructureApplication { workflowName += BPMN_SUFFIX; } if (workflowBody != null) { - logger.info("{} {}", "Deploying custom workflow", workflowName); + logger.info(LoggingAnchor.TWO, "Deploying custom workflow", workflowName); deploymentBuilder.addString(workflowName, workflowBody); } + deploymentBuilder.enableDuplicateFiltering(true); + deploymentBuilder.deploy(); } - deploymentBuilder.enableDuplicateFiltering(true); - deploymentBuilder.deploy(); } } catch (Exception e) { logger.warn("Unable to deploy custom workflows, " + e.getMessage()); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml index e364981a66..185db168fe 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml +++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml @@ -7,10 +7,13 @@ mso: auditInventory: false spring: datasource: - driver-class-name: org.mariadb.jdbc.Driver - url: jdbc:mariadb://${DB_HOST}:${DB_PORT}/camundabpmn - username: ${DB_ADMIN_USERNAME} - password: ${DB_ADMIN_PASSWORD} + hikari: + jdbcUrl: jdbc:mariadb://${DB_HOST}:${DB_PORT}/camundabpmn + username: ${DB_ADMIN_USERNAME} + password: ${DB_ADMIN_PASSWORD} + driver-class-name: org.mariadb.jdbc.Driver + pool-name: bpmn-pool + registerMbeans: true http: multipart: enabled: false diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java index 3734510eed..3ff240ebc2 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java @@ -34,6 +34,8 @@ import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; import org.junit.Test; import org.onap.so.BaseIntegrationTest; +import org.onap.so.bpmn.common.recipe.ResourceInput; +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder; import org.springframework.beans.factory.annotation.Autowired; public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { @@ -61,6 +63,7 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() { // given variables.put(PNF_CORRELATION_ID, PnfManagementTestImpl.ID_WITH_ENTRY); + variables.put("resourceInput", getUpdateResInputObj("OLT").toString()); // when ProcessInstance instance = runtimeService.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); @@ -79,6 +82,7 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() { // given variables.put(PNF_CORRELATION_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY); + variables.put("resourceInput", getUpdateResInputObj("OLT").toString()); // when ProcessInstance instance = runtimeService.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); @@ -93,4 +97,31 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { Assertions.assertThat(pnfManagementTest.getServiceAndPnfRelationMap()) .containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY)); } + + private ResourceInput getUpdateResInputObj(String modelName) { + + String resourceInput = "{\n" + "\t\"resourceInstanceName\": \"SotnFc-wan-connection_wanconnection-37\",\n" + + "\t\"resourceInstanceDes\": null,\n" + "\t\"globalSubscriberId\": \"sdwandemo\",\n" + + "\t\"serviceType\": \"CCVPN\",\n" + "\t\"operationId\": \"df3387b5-4fbf-41bd-82a0-13a955ac178a\",\n" + + "\t\"serviceModelInfo\": {\n" + "\t\t\"modelName\": \"WanConnectionSvc03\",\n" + + "\t\t\"modelUuid\": \"198b066c-0771-4157-9594-1824adfdda7e\",\n" + + "\t\t\"modelInvariantUuid\": \"43fb5165-7d03-4009-8951-a8f45d3f0148\",\n" + + "\t\t\"modelVersion\": \"1.0\",\n" + "\t\t\"modelCustomizationUuid\": \"\",\n" + + "\t\t\"modelCustomizationName\": \"\",\n" + "\t\t\"modelInstanceName\": \"\",\n" + + "\t\t\"modelType\": \"\"\n" + "\t},\n" + "\t\"resourceModelInfo\": {\n" + "\t\t\"modelName\": \"" + + modelName + "\",\n" + "\t\t\"modelUuid\": \"6a0bf88b-343c-415b-88c1-6f73702452c4\",\n" + + "\t\t\"modelInvariantUuid\": \"50bc3415-2e01-4e50-a9e1-ec9584599bb3\",\n" + + "\t\t\"modelCustomizationUuid\": \"b205d620-84bd-4058-afa0-e3aeee8bb712\",\n" + + "\t\t\"modelCustomizationName\": \"\",\n" + + "\t\t\"modelInstanceName\": \"SotnFc-wan-connection 0\",\n" + "\t\t\"modelType\": \"\"\n" + "\t},\n" + + "\t\"resourceInstancenUuid\": null,\n" + + "\t\"resourceParameters\": \"{\\n\\\"locationConstraints\\\":[],\\n\\\"requestInputs\\\":{\\\"sotnfcspecwanconnection0_route-objective-function\\\":null,\\\"sotnfcspecwanconnection0_colorAware\\\":null,\\\"3rdctlspecwanconnection0_thirdPartyAdaptorRpc\\\":null,\\\"sotnfcspecwanconnection0_couplingFlag\\\":null,\\\"sotnfcspecwanconnection0_pbs\\\":null,\\\"3rdctlspecwanconnection0_thirdPartySdncId\\\":null,\\\"sotnfcspecwanconnection0_cbs\\\":null,\\\"3rdctlspecwanconnection0_thirdpartySdncName\\\":null,\\\"sotnfcspecwanconnection0_total-size\\\":null,\\\"3rdctlspecwanconnection0_templateFileName\\\":\\\"sotn_create_zte_template.json\\\",\\\"fcwanconnection0_type\\\":null,\\\"sotnfcspecwanconnection0_cir\\\":null,\\\"fcwanconnection0_uuid\\\":null,\\\"sotnfcspecwanconnection0_diversity-policy\\\":null,\\\"nf_naming\\\":true,\\\"multi_stage_design\\\":false,\\\"availability_zone_max_count\\\":1,\\\"3rdctlspecwanconnection0_restapiUrl\\\":\\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\\"max_instances\\\":null,\\\"sotnfcspecwanconnection0_reroute\\\":null,\\\"fcwanconnection0_name\\\":null,\\\"sotnfcspecwanconnection0_dualLink\\\":null,\\\"min_instances\\\":null,\\\"sotnfcspecwanconnection0_pir\\\":null,\\\"sotnfcspecwanconnection0_service-type\\\":null}\\n}\",\n" + + "\t\"operationType\": \"createInstance\",\n" + + "\t\"serviceInstanceId\": \"ffa07ae4-f820-45af-9439-1416b3bc1d39\",\n" + + "\t\"requestsInputs\": \"{\\r\\n\\t\\\"service\\\": {\\r\\n\\t\\t\\\"name\\\": \\\"wanconnection-37\\\",\\r\\n\\t\\t\\\"description\\\": \\\"deafe\\\",\\r\\n\\t\\t\\\"serviceInvariantUuid\\\": \\\"43fb5165-7d03-4009-8951-a8f45d3f0148\\\",\\r\\n\\t\\t\\\"serviceUuid\\\": \\\"198b066c-0771-4157-9594-1824adfdda7e\\\",\\r\\n\\t\\t\\\"globalSubscriberId\\\": \\\"sdwandemo\\\",\\r\\n\\t\\t\\\"serviceType\\\": \\\"CCVPN\\\",\\r\\n\\t\\t\\\"parameters\\\": {\\r\\n\\t\\t\\t\\\"resources\\\": [\\r\\n\\t\\t\\t],\\r\\n\\t\\t\\t\\\"requestInputs\\\": {\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sotn_create_zte_template.json\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sdwan_create_zte_template.json\\\",\\\"ont_ont_manufacturer\\\":\\\"huawei\\\",\\\"ont_ont_serial_num\\\":\\\"123\\\"\\r\\n\\t\\t\\t}\\r\\n\\t\\t}\\r\\n\\t}\\r\\n}\"\n" + + "}"; + + ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class); + return resourceInputObj; + } } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java index e7ff69ab3b..dd993bca51 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java @@ -20,7 +20,9 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; +import java.util.HashMap; import java.util.Objects; +import java.util.Optional; import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; @@ -33,7 +35,8 @@ public class DmaapClientTestImpl implements DmaapClient { private Runnable informConsumer; @Override - public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) { + public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, + Optional<HashMap<String, String>> updateInfo) { this.pnfCorrelationId = pnfCorrelationId; this.informConsumer = informConsumer; } diff --git a/bpmn/pom.xml b/bpmn/pom.xml index 85a45db6ba..65af2fd8d5 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -24,8 +24,8 @@ <xmlunit.version>2.4.0</xmlunit.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <sdnc.northbound.version>1.5.1</sdnc.northbound.version> - <appc.client.version>1.5.0</appc.client.version> + <sdnc.northbound.version>1.5.2</sdnc.northbound.version> + <appc.client.version>1.6.0-SNAPSHOT</appc.client.version> </properties> <modules> 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 289ab6e155..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 @@ -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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1"> +<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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> <bpmn:process id="ActivateVfModuleBB" name="ActivateVfModuleBB" isExecutable="true"> <bpmn:startEvent id="ActivateVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_0ieafii</bpmn:outgoing> @@ -9,9 +9,7 @@ <bpmn:incoming>SequenceFlow_0xsp0pv</bpmn:incoming> </bpmn:endEvent> <bpmn:serviceTask id="ActivateVfModule" name=" SDNC Activate (vf module) " camunda:expression="${SDNCActivateTasks.activateVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_07ybdik</bpmn:incoming> - <bpmn:incoming>SequenceFlow_109oxx2</bpmn:incoming> - <bpmn:incoming>SequenceFlow_0arwo1o</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1b63lv4</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1a495wm</bpmn:outgoing> </bpmn:serviceTask> <bpmn:serviceTask id="UpdateVfModuleActiveStatus" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusActivateVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> @@ -40,13 +38,8 @@ <bpmn:incoming>SequenceFlow_0xndboi</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ee42yq</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:exclusiveGateway id="ExclusiveGateway_1v8bmbu" default="SequenceFlow_07ybdik"> - <bpmn:incoming>SequenceFlow_1xqyur9</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_07ybdik</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_0ghzwlo</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_07ybdik" sourceRef="ExclusiveGateway_1v8bmbu" targetRef="ActivateVfModule" /> - <bpmn:sequenceFlow id="SequenceFlow_0ghzwlo" sourceRef="ExclusiveGateway_1v8bmbu" targetRef="Setup_AAI_Inventory_Audit"> + <bpmn:sequenceFlow id="SequenceFlow_07ybdik" name="No" sourceRef="ExclusiveGateway_1v8bmbu" targetRef="ExclusiveGateway_0sqvzll" /> + <bpmn:sequenceFlow id="SequenceFlow_0ghzwlo" name="Yes" sourceRef="ExclusiveGateway_1v8bmbu" targetRef="Setup_AAI_Inventory_Audit"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditInventoryNeeded") == true}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_0ee42yq" sourceRef="Audit_AAI_Inventory" targetRef="ExclusiveGateway_1h8avxn" /> @@ -55,154 +48,252 @@ <bpmn:outgoing>SequenceFlow_1xqyur9</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1xqyur9" sourceRef="CheckAuditVariable" targetRef="ExclusiveGateway_1v8bmbu" /> - <bpmn:exclusiveGateway id="ExclusiveGateway_1h8avxn" default="SequenceFlow_1bo83qk"> - <bpmn:incoming>SequenceFlow_0ee42yq</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_109oxx2</bpmn:outgoing> - <bpmn:outgoing>SequenceFlow_1bo83qk</bpmn:outgoing> - </bpmn:exclusiveGateway> - <bpmn:sequenceFlow id="SequenceFlow_109oxx2" sourceRef="ExclusiveGateway_1h8avxn" targetRef="ActivateVfModule"> + <bpmn:sequenceFlow id="SequenceFlow_109oxx2" name="No" sourceRef="ExclusiveGateway_1h8avxn" targetRef="ExclusiveGateway_0y0ek7t"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditIsSuccessful")== true }]]></bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_1bo83qk" name="If Audit Fails" sourceRef="ExclusiveGateway_1h8avxn" targetRef="Create_AAI_Inventory" /> - <bpmn:sequenceFlow id="SequenceFlow_0arwo1o" sourceRef="Create_AAI_Inventory" targetRef="ActivateVfModule" /> + <bpmn:sequenceFlow id="SequenceFlow_1bo83qk" name="Yes" sourceRef="ExclusiveGateway_1h8avxn" targetRef="Create_AAI_Inventory" /> + <bpmn:sequenceFlow id="SequenceFlow_0arwo1o" sourceRef="Create_AAI_Inventory" targetRef="ExclusiveGateway_0y0ek7t" /> <bpmn:serviceTask id="Create_AAI_Inventory" name="Create A&AI Inventory" camunda:type="external" camunda:topic="InventoryCreate"> <bpmn:incoming>SequenceFlow_1bo83qk</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0arwo1o</bpmn:outgoing> </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1b63lv4" sourceRef="ExclusiveGateway_0sqvzll" targetRef="ActivateVfModule" /> + <bpmn:sequenceFlow id="SequenceFlow_18faffa" sourceRef="ExclusiveGateway_0y0ek7t" targetRef="ExclusiveGateway_0sqvzll" /> + <bpmn:subProcess id="SubProcess_0bpsptg" name="Audit Exception Sub Process" triggeredByEvent="true"> + <bpmn:startEvent id="catchInventoryException"> + <bpmn:outgoing>SequenceFlow_19gbhlj</bpmn:outgoing> + <bpmn:errorEventDefinition errorRef="Error_1s3kxze" /> + </bpmn:startEvent> + <bpmn:endEvent id="EndEvent_067jv1n"> + <bpmn:incoming>SequenceFlow_0l4jzc5</bpmn:incoming> + </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")), false)}"> + <bpmn:incoming>SequenceFlow_19gbhlj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0l4jzc5</bpmn:outgoing> + </bpmn:serviceTask> + </bpmn:subProcess> + <bpmn:inclusiveGateway id="ExclusiveGateway_1v8bmbu" name="Audit Enabled?" default="SequenceFlow_07ybdik"> + <bpmn:incoming>SequenceFlow_1xqyur9</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_07ybdik</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0ghzwlo</bpmn:outgoing> + </bpmn:inclusiveGateway> + <bpmn:inclusiveGateway id="ExclusiveGateway_0sqvzll"> + <bpmn:incoming>SequenceFlow_07ybdik</bpmn:incoming> + <bpmn:incoming>SequenceFlow_18faffa</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1b63lv4</bpmn:outgoing> + </bpmn:inclusiveGateway> + <bpmn:inclusiveGateway id="ExclusiveGateway_1h8avxn" name="Audit Failed?" default="SequenceFlow_1bo83qk"> + <bpmn:incoming>SequenceFlow_0ee42yq</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_109oxx2</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1bo83qk</bpmn:outgoing> + </bpmn:inclusiveGateway> + <bpmn:inclusiveGateway id="ExclusiveGateway_0y0ek7t"> + <bpmn:incoming>SequenceFlow_109oxx2</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0arwo1o</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_18faffa</bpmn:outgoing> + </bpmn:inclusiveGateway> </bpmn:process> <bpmn:error id="Error_0q258vt" errorCode="7000" /> + <bpmn:error id="Error_0zgccif" name="org.onap.so.adapters.inventory.create.InventoryException" errorCode="org.onap.so.adapters.inventory.create.InventoryException" /> + <bpmn:error id="Error_1s3kxze" name="Error_3q664s5" errorCode="AAIInventoryFailure" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ActivateVfModuleBB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="ActivateVfModuleBB_Start"> - <dc:Bounds x="73" y="102" width="36" height="36" /> + <dc:Bounds x="85" y="234" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="46" y="138" width="90" height="12" /> + <dc:Bounds x="58" y="270" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0ieafii_di" bpmnElement="SequenceFlow_0ieafii"> - <di:waypoint xsi:type="dc:Point" x="109" y="120" /> - <di:waypoint xsi:type="dc:Point" x="161" y="120" /> + <di:waypoint xsi:type="dc:Point" x="121" y="252" /> + <di:waypoint xsi:type="dc:Point" x="201" y="252" /> <bpmndi:BPMNLabel> - <dc:Bounds x="90" y="99" width="90" height="12" /> + <dc:Bounds x="116" y="231" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1v967li_di" bpmnElement="ActivateVfModuleBB_End"> - <dc:Bounds x="1104" y="102" width="36" height="36" /> + <dc:Bounds x="1404" y="235" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="935" y="142" width="90" height="12" /> + <dc:Bounds x="1235" y="275" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0hawa84_di" bpmnElement="ActivateVfModule"> - <dc:Bounds x="647" y="80" width="100" height="80" /> + <dc:Bounds x="958" y="212" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_175e9ul_di" bpmnElement="UpdateVfModuleActiveStatus"> - <dc:Bounds x="952" y="80" width="100" height="80" /> + <dc:Bounds x="1214" y="212" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0xsp0pv_di" bpmnElement="SequenceFlow_0xsp0pv"> - <di:waypoint xsi:type="dc:Point" x="1052" y="120" /> - <di:waypoint xsi:type="dc:Point" x="1104" y="120" /> + <di:waypoint xsi:type="dc:Point" x="1314" y="252" /> + <di:waypoint xsi:type="dc:Point" x="1404" y="253" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1033" y="99" width="90" height="12" /> + <dc:Bounds x="1314" y="231.5" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_03jkesd_di" bpmnElement="CallActivity_sdncHandler"> - <dc:Bounds x="794" y="80" width="100" height="80" /> + <dc:Bounds x="1086" y="212" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1a495wm_di" bpmnElement="SequenceFlow_1a495wm"> - <di:waypoint xsi:type="dc:Point" x="747" y="120" /> - <di:waypoint xsi:type="dc:Point" x="794" y="120" /> + <di:waypoint xsi:type="dc:Point" x="1058" y="252" /> + <di:waypoint xsi:type="dc:Point" x="1086" y="252" /> <bpmndi:BPMNLabel> - <dc:Bounds x="725.5" y="99" width="90" height="12" /> + <dc:Bounds x="1027" y="231" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1j4x1ej_di" bpmnElement="SequenceFlow_1j4x1ej"> - <di:waypoint xsi:type="dc:Point" x="894" y="120" /> - <di:waypoint xsi:type="dc:Point" x="952" y="120" /> + <di:waypoint xsi:type="dc:Point" x="1186" y="252" /> + <di:waypoint xsi:type="dc:Point" x="1214" y="252" /> <bpmndi:BPMNLabel> - <dc:Bounds x="878" y="99" width="90" height="12" /> + <dc:Bounds x="1155" y="231" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0xndboi_di" bpmnElement="SequenceFlow_0xndboi"> - <di:waypoint xsi:type="dc:Point" x="365" y="256" /> - <di:waypoint xsi:type="dc:Point" x="408" y="256" /> + <di:waypoint xsi:type="dc:Point" x="491" y="175" /> + <di:waypoint xsi:type="dc:Point" x="513" y="175" /> <bpmndi:BPMNLabel> - <dc:Bounds x="341.5" y="234.5" width="90" height="13" /> + <dc:Bounds x="457" y="153.5" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0krf1ur_di" bpmnElement="Setup_AAI_Inventory_Audit"> - <dc:Bounds x="265" y="216" width="100" height="80" /> + <dc:Bounds x="391" y="135" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_08rxjeb_di" bpmnElement="Audit_AAI_Inventory"> - <dc:Bounds x="408" y="216" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ExclusiveGateway_1v8bmbu_di" bpmnElement="ExclusiveGateway_1v8bmbu" isMarkerVisible="true"> - <dc:Bounds x="290" y="95" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="315" y="148" width="0" height="13" /> - </bpmndi:BPMNLabel> + <dc:Bounds x="513" y="135" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_07ybdik_di" bpmnElement="SequenceFlow_07ybdik"> - <di:waypoint xsi:type="dc:Point" x="340" y="120" /> - <di:waypoint xsi:type="dc:Point" x="647" y="120" /> + <di:waypoint xsi:type="dc:Point" x="355" y="277" /> + <di:waypoint xsi:type="dc:Point" x="355" y="315" /> + <di:waypoint xsi:type="dc:Point" x="881" y="315" /> + <di:waypoint xsi:type="dc:Point" x="881" y="277" /> <bpmndi:BPMNLabel> - <dc:Bounds x="448.5" y="98.5" width="90" height="13" /> + <dc:Bounds x="364" y="294" width="14" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0ghzwlo_di" bpmnElement="SequenceFlow_0ghzwlo"> - <di:waypoint xsi:type="dc:Point" x="315" y="145" /> - <di:waypoint xsi:type="dc:Point" x="315" y="216" /> + <di:waypoint xsi:type="dc:Point" x="355" y="227" /> + <di:waypoint xsi:type="dc:Point" x="355" y="175" /> + <di:waypoint xsi:type="dc:Point" x="391" y="175" /> <bpmndi:BPMNLabel> - <dc:Bounds x="330" y="174" width="0" height="13" /> + <dc:Bounds x="362" y="185" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0ee42yq_di" bpmnElement="SequenceFlow_0ee42yq"> - <di:waypoint xsi:type="dc:Point" x="508" y="256" /> - <di:waypoint xsi:type="dc:Point" x="566" y="256" /> + <di:waypoint xsi:type="dc:Point" x="613" y="175" /> + <di:waypoint xsi:type="dc:Point" x="638" y="175" /> <bpmndi:BPMNLabel> - <dc:Bounds x="492" y="234.5" width="90" height="13" /> + <dc:Bounds x="580.5" y="153.5" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1eg5ryx_di" bpmnElement="CheckAuditVariable"> - <dc:Bounds x="161" y="80" width="100" height="80" /> + <dc:Bounds x="201" y="212" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1xqyur9_di" bpmnElement="SequenceFlow_1xqyur9"> - <di:waypoint xsi:type="dc:Point" x="261" y="120" /> - <di:waypoint xsi:type="dc:Point" x="290" y="120" /> + <di:waypoint xsi:type="dc:Point" x="301" y="252" /> + <di:waypoint xsi:type="dc:Point" x="330" y="252" /> <bpmndi:BPMNLabel> - <dc:Bounds x="275.5" y="98.5" width="0" height="13" /> + <dc:Bounds x="270.5" y="230.5" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ExclusiveGateway_1h8avxn_di" bpmnElement="ExclusiveGateway_1h8avxn" isMarkerVisible="true"> - <dc:Bounds x="566" y="231" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="591" y="284" width="0" height="13" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_109oxx2_di" bpmnElement="SequenceFlow_109oxx2"> - <di:waypoint xsi:type="dc:Point" x="616" y="256" /> - <di:waypoint xsi:type="dc:Point" x="670" y="256" /> - <di:waypoint xsi:type="dc:Point" x="670" y="160" /> + <di:waypoint xsi:type="dc:Point" x="663" y="200" /> + <di:waypoint xsi:type="dc:Point" x="663" y="230" /> + <di:waypoint xsi:type="dc:Point" x="834" y="230" /> + <di:waypoint xsi:type="dc:Point" x="834" y="200" /> <bpmndi:BPMNLabel> - <dc:Bounds x="643" y="234.5" width="0" height="13" /> + <dc:Bounds x="670" y="207" width="14" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1bo83qk_di" bpmnElement="SequenceFlow_1bo83qk"> - <di:waypoint xsi:type="dc:Point" x="591" y="281" /> - <di:waypoint xsi:type="dc:Point" x="591" y="345" /> - <di:waypoint xsi:type="dc:Point" x="656" y="345" /> + <di:waypoint xsi:type="dc:Point" x="663" y="150" /> + <di:waypoint xsi:type="dc:Point" x="663" y="101" /> + <di:waypoint xsi:type="dc:Point" x="691" y="101" /> <bpmndi:BPMNLabel> - <dc:Bounds x="560" y="358" width="61" height="12" /> + <dc:Bounds x="667" y="111" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0arwo1o_di" bpmnElement="SequenceFlow_0arwo1o"> - <di:waypoint xsi:type="dc:Point" x="706" y="305" /> - <di:waypoint xsi:type="dc:Point" x="706" y="160" /> + <di:waypoint xsi:type="dc:Point" x="791" y="101" /> + <di:waypoint xsi:type="dc:Point" x="834" y="101" /> + <di:waypoint xsi:type="dc:Point" x="834" y="150" /> <bpmndi:BPMNLabel> - <dc:Bounds x="721" y="226" width="0" height="13" /> + <dc:Bounds x="767.5" y="79.5" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1eb09gr_di" bpmnElement="Create_AAI_Inventory"> - <dc:Bounds x="656" y="305" width="100" height="80" /> + <dc:Bounds x="691" y="61" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1b63lv4_di" bpmnElement="SequenceFlow_1b63lv4"> + <di:waypoint xsi:type="dc:Point" x="906" y="252" /> + <di:waypoint xsi:type="dc:Point" x="958" y="252" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="887" y="231" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_18faffa_di" bpmnElement="SequenceFlow_18faffa"> + <di:waypoint xsi:type="dc:Point" x="859" y="175" /> + <di:waypoint xsi:type="dc:Point" x="881" y="175" /> + <di:waypoint xsi:type="dc:Point" x="881" y="227" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="825" y="154" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="SubProcess_0mbkb7v_di" bpmnElement="SubProcess_0bpsptg" isExpanded="true"> + <dc:Bounds x="293" y="449" width="350" height="200" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_12r96di_di" bpmnElement="catchInventoryException"> + <dc:Bounds x="324" y="532" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="341.15269461077844" y="571.6127744510978" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_067jv1n_di" bpmnElement="EndEvent_067jv1n"> + <dc:Bounds x="572.1526946107784" y="532" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="590.1526946107784" y="572" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_19gbhlj_di" bpmnElement="SequenceFlow_19gbhlj"> + <di:waypoint xsi:type="dc:Point" x="360" y="550" /> + <di:waypoint xsi:type="dc:Point" x="415" y="550" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="387.5" y="529" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0l4jzc5_di" bpmnElement="SequenceFlow_0l4jzc5"> + <di:waypoint xsi:type="dc:Point" x="515" y="550" /> + <di:waypoint xsi:type="dc:Point" x="572" y="550" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="543.5" y="529" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_08xffml_di" bpmnElement="processAuditException"> + <dc:Bounds x="415" y="510" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="InclusiveGateway_03pi9y4_di" bpmnElement="ExclusiveGateway_1v8bmbu"> + <dc:Bounds x="330" y="227" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="383" y="246" width="73" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="InclusiveGateway_16ap4e3_di" bpmnElement="ExclusiveGateway_0sqvzll"> + <dc:Bounds x="856" y="227" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="836" y="281" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="InclusiveGateway_00n600s_di" bpmnElement="ExclusiveGateway_1h8avxn"> + <dc:Bounds x="638" y="150" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="693" y="169" width="63" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="InclusiveGateway_0xx6c29_di" bpmnElement="ExclusiveGateway_0y0ek7t"> + <dc:Bounds x="809" y="150" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="789" y="204" width="0" height="12" /> + </bpmndi:BPMNLabel> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn index 52b9249468..1ea311549c 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateNetworkBB.bpmn @@ -60,6 +60,7 @@ <camunda:in source="networkAdapterRequest" target="networkAdapterRequest" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:out source="createNetworkResponse" target="createNetworkResponse" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_1fm99t6</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0qpu80i</bpmn2:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn index 74b78ef735..512cb7b45e 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeleteNetworkBB.bpmn @@ -22,6 +22,7 @@ <camunda:in source="networkAdapterRequest" target="networkAdapterRequest" /> <camunda:out source="WorkflowException" target="WorkflowException" /> <camunda:out source="deleteNetworkResponse" target="deleteNetworkResponse" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_16ti327</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0gnafn2</bpmn:outgoing> 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 e1b36cfe65..33335ab2c4 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 @@ -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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1"> +<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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> <bpmn:process id="DeleteVfModuleBB" name="DeleteVfModuleBB" isExecutable="true"> <bpmn:startEvent id="DeleteVfModuleBB_Start"> <bpmn:outgoing>SequenceFlow_1537yw5</bpmn:outgoing> @@ -51,22 +51,22 @@ <bpmn:sequenceFlow id="SequenceFlow_01vfwtp" sourceRef="UpdateVfModuleHeatStackId" targetRef="UpdateVfModuleDeleteStatus" /> <bpmn:sequenceFlow id="SequenceFlow_09l7pcg" sourceRef="UpdateVfModuleDeleteStatus" targetRef="DeleteVfModuleBB_End" /> <bpmn:sequenceFlow id="SequenceFlow_0xyu3pk" sourceRef="DeleteNetworkPolicies" targetRef="UpdateVnfIpv4OamAddress" /> - <bpmn:serviceTask id="DeleteNetworkPolicies" name="AAI Delete (network policies)" camunda:expression="${AAIDeleteTasks.deleteNetworkPolicies(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_14bu4ys</bpmn:incoming> + <bpmn:serviceTask id="DeleteNetworkPolicies" name=" AAI Delete (net policies) " camunda:expression="${AAIDeleteTasks.deleteNetworkPolicies(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_179btn2</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0xyu3pk</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:serviceTask id="UpdateVnfManagementV6Address" name="AAI Update (VNF)" camunda:expression="${AAIUpdateTasks.updateManagementV6AddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="UpdateVnfManagementV6Address" name=" AAI Update (vnf) " camunda:expression="${AAIUpdateTasks.updateManagementV6AddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_0jtem3b</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0khqfnc</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0jtem3b" sourceRef="UpdateVnfIpv4OamAddress" targetRef="UpdateVnfManagementV6Address" /> - <bpmn:serviceTask id="UpdateVnfIpv4OamAddress" name="AAI Update (VNF)" camunda:expression="${AAIUpdateTasks.updateIpv4OamAddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="UpdateVnfIpv4OamAddress" name=" AAI Update (vnf) " camunda:expression="${AAIUpdateTasks.updateIpv4OamAddressVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_0xyu3pk</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0jtem3b</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0khqfnc" sourceRef="UpdateVnfManagementV6Address" targetRef="UpdateVfModuleContrailServiceInstanceFqdn" /> <bpmn:sequenceFlow id="SequenceFlow_0yuz21z" sourceRef="UpdateVfModuleContrailServiceInstanceFqdn" targetRef="UpdateVfModuleHeatStackId" /> - <bpmn:serviceTask id="UpdateVfModuleContrailServiceInstanceFqdn" name="AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateContrailServiceInstanceFqdnVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="UpdateVfModuleContrailServiceInstanceFqdn" name=" AAI Update (vf module) " camunda:expression="${AAIUpdateTasks.updateContrailServiceInstanceFqdnVfModule(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_0khqfnc</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0yuz21z</bpmn:outgoing> </bpmn:serviceTask> @@ -79,15 +79,10 @@ <bpmn:sequenceFlow id="SequenceFlow_032jv5j" name="Yes " sourceRef="ExclusiveGateway_1h2ystu" targetRef="Setup_Audit_Variable"> <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("auditInventoryNeeded") == true}]]></bpmn:conditionExpression> </bpmn:sequenceFlow> - <bpmn:sequenceFlow id="SequenceFlow_0qfmmgt" sourceRef="Audit_Inventory" targetRef="ExclusiveGateway_1pydilb" /> - <bpmn:sequenceFlow id="SequenceFlow_14bu4ys" sourceRef="ExclusiveGateway_1yvh16a" targetRef="DeleteNetworkPolicies" /> - <bpmn:parallelGateway id="ExclusiveGateway_1yvh16a"> - <bpmn:incoming>SequenceFlow_02lpx87</bpmn:incoming> - <bpmn:incoming>SequenceFlow_1ut7n32</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_14bu4ys</bpmn:outgoing> - </bpmn:parallelGateway> + <bpmn:sequenceFlow id="SequenceFlow_0qfmmgt" sourceRef="Audit_Inventory" targetRef="auditSuccessfulCheck" /> + <bpmn:sequenceFlow id="SequenceFlow_14bu4ys" sourceRef="ExclusiveGateway_1yvh16a" targetRef="aaiThrow" /> <bpmn:sequenceFlow id="SequenceFlow_1mgunf3" name="No" sourceRef="ExclusiveGateway_1h2ystu" targetRef="ExclusiveGateway_1pydilb" /> - <bpmn:serviceTask id="Check_Audit" name="Check Audit Variable" camunda:expression="${AuditTasks.isAuditNeeded(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="Check_Audit" name="Check Audit Variable" camunda:expression="${AuditTasks.isDeleteAuditNeeded(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_1v3jgqe</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1odt2wt</bpmn:outgoing> </bpmn:serviceTask> @@ -109,240 +104,359 @@ <bpmn:outgoing>SequenceFlow_1mgunf3</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:exclusiveGateway id="ExclusiveGateway_1pydilb"> - <bpmn:incoming>SequenceFlow_0qfmmgt</bpmn:incoming> <bpmn:incoming>SequenceFlow_1mgunf3</bpmn:incoming> + <bpmn:incoming>SequenceFlow_17cd9e2</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1ut7n32</bpmn:outgoing> </bpmn:exclusiveGateway> + <bpmn:subProcess id="SubProcess_0grvkj2" name="Audit Exception Sub Process" triggeredByEvent="true"> + <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")), 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"> + <bpmn:incoming>SequenceFlow_14bu4ys</bpmn:incoming> + <bpmn:linkEventDefinition name="AAI" /> + </bpmn:intermediateThrowEvent> + <bpmn:intermediateCatchEvent id="aaiCatch" name="Update AAI"> + <bpmn:outgoing>SequenceFlow_179btn2</bpmn:outgoing> + <bpmn:linkEventDefinition name="AAI" /> + </bpmn:intermediateCatchEvent> + <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: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"> - <dc:Bounds x="159" y="241" width="36" height="36" /> + <dc:Bounds x="159" y="266" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="132" y="277" width="90" height="12" /> + <dc:Bounds x="132" y="302" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_16798zf_di" bpmnElement="DeleteVfModuleVnfAdapter"> - <dc:Bounds x="382" y="278" width="100" height="80" /> + <dc:Bounds x="382" y="303" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1537yw5_di" bpmnElement="SequenceFlow_1537yw5"> - <di:waypoint xsi:type="dc:Point" x="195" y="259" /> - <di:waypoint xsi:type="dc:Point" x="282" y="259" /> + <di:waypoint xsi:type="dc:Point" x="195" y="284" /> + <di:waypoint xsi:type="dc:Point" x="282" y="284" /> <bpmndi:BPMNLabel> - <dc:Bounds x="193.5" y="238" width="90" height="12" /> + <dc:Bounds x="194" y="263" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0pbhsub_di" bpmnElement="UpdateVfModuleDeleteStatus"> - <dc:Bounds x="840" y="443" width="100" height="80" /> + <dc:Bounds x="907" y="468" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_08tvhtf_di" bpmnElement="SequenceFlow_08tvhtf"> - <di:waypoint xsi:type="dc:Point" x="482" y="318" /> - <di:waypoint xsi:type="dc:Point" x="511" y="318" /> + <di:waypoint xsi:type="dc:Point" x="482" y="343" /> + <di:waypoint xsi:type="dc:Point" x="511" y="343" /> <bpmndi:BPMNLabel> - <dc:Bounds x="451.5" y="297" width="90" height="12" /> + <dc:Bounds x="452" y="322" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_1rn6yvh_di" bpmnElement="DeleteVfModuleBB_End"> - <dc:Bounds x="1087" y="465" width="36" height="36" /> + <dc:Bounds x="1136" y="490" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1060" y="505" width="90" height="0" /> + <dc:Bounds x="1109" y="530" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="CallActivity_0whogn3_di" bpmnElement="VnfAdapter"> - <dc:Bounds x="511" y="278" width="100" height="80" /> + <dc:Bounds x="511" y="303" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_02lpx87_di" bpmnElement="SequenceFlow_02lpx87"> - <di:waypoint xsi:type="dc:Point" x="611" y="318" /> - <di:waypoint xsi:type="dc:Point" x="836" y="318" /> - <di:waypoint xsi:type="dc:Point" x="836" y="284" /> + <di:waypoint xsi:type="dc:Point" x="611" y="343" /> + <di:waypoint xsi:type="dc:Point" x="925" y="343" /> + <di:waypoint xsi:type="dc:Point" x="925" y="309" /> <bpmndi:BPMNLabel> - <dc:Bounds x="678.5" y="303" width="90" height="0" /> + <dc:Bounds x="723" y="328" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_11p7mrh_di" bpmnElement="SubProcess_11p7mrh" isExpanded="true"> - <dc:Bounds x="294" y="618" width="231" height="135" /> + <dc:Bounds x="290" y="878" width="231" height="135" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="StartEvent_1xp6ewt_di" bpmnElement="StartEvent_1xp6ewt"> - <dc:Bounds x="337" y="680" width="36" height="36" /> + <dc:Bounds x="333" y="940" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="265" y="716" width="90" height="0" /> + <dc:Bounds x="261" y="976" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0guhjau_di" bpmnElement="EndEvent_0guhjau"> - <dc:Bounds x="466" y="680" width="36" height="36" /> + <dc:Bounds x="462" y="940" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="394" y="716" width="90" height="0" /> + <dc:Bounds x="390" y="976" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0h607z0_di" bpmnElement="SequenceFlow_0h607z0"> - <di:waypoint xsi:type="dc:Point" x="373" y="698" /> - <di:waypoint xsi:type="dc:Point" x="466" y="698" /> + <di:waypoint xsi:type="dc:Point" x="369" y="958" /> + <di:waypoint xsi:type="dc:Point" x="462" y="958" /> <bpmndi:BPMNLabel> - <dc:Bounds x="375" y="677" width="90" height="0" /> + <dc:Bounds x="371" y="937" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0vlgqod_di" bpmnElement="UpdateVfModuleHeatStackId"> - <dc:Bounds x="706" y="443" width="100" height="80" /> + <dc:Bounds x="779" y="468" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_01vfwtp_di" bpmnElement="SequenceFlow_01vfwtp"> - <di:waypoint xsi:type="dc:Point" x="806" y="483" /> - <di:waypoint xsi:type="dc:Point" x="840" y="483" /> + <di:waypoint xsi:type="dc:Point" x="879" y="508" /> + <di:waypoint xsi:type="dc:Point" x="907" y="508" /> <bpmndi:BPMNLabel> - <dc:Bounds x="778" y="468" width="90" height="0" /> + <dc:Bounds x="848" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_09l7pcg_di" bpmnElement="SequenceFlow_09l7pcg"> - <di:waypoint xsi:type="dc:Point" x="940" y="483" /> - <di:waypoint xsi:type="dc:Point" x="1087" y="483" /> + <di:waypoint xsi:type="dc:Point" x="1007" y="508" /> + <di:waypoint xsi:type="dc:Point" x="1136" y="508" /> <bpmndi:BPMNLabel> - <dc:Bounds x="968.5" y="468" width="90" height="0" /> + <dc:Bounds x="1027" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0xyu3pk_di" bpmnElement="SequenceFlow_0xyu3pk"> - <di:waypoint xsi:type="dc:Point" x="998" y="259" /> - <di:waypoint xsi:type="dc:Point" x="1072" y="259" /> - <di:waypoint xsi:type="dc:Point" x="1072" y="399" /> - <di:waypoint xsi:type="dc:Point" x="233" y="399" /> - <di:waypoint xsi:type="dc:Point" x="233" y="483" /> - <di:waypoint xsi:type="dc:Point" x="280" y="483" /> + <di:waypoint xsi:type="dc:Point" x="376" y="508" /> + <di:waypoint xsi:type="dc:Point" x="404" y="508" /> <bpmndi:BPMNLabel> - <dc:Bounds x="607.5" y="384" width="90" height="0" /> + <dc:Bounds x="345" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0tty0ac_di" bpmnElement="DeleteNetworkPolicies"> - <dc:Bounds x="898" y="219" width="100" height="80" /> + <dc:Bounds x="276" y="468" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0lrrd16_di" bpmnElement="UpdateVnfManagementV6Address"> - <dc:Bounds x="421" y="443" width="100" height="80" /> + <dc:Bounds x="531" y="468" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0jtem3b_di" bpmnElement="SequenceFlow_0jtem3b"> - <di:waypoint xsi:type="dc:Point" x="380" y="483" /> - <di:waypoint xsi:type="dc:Point" x="421" y="483" /> + <di:waypoint xsi:type="dc:Point" x="504" y="508" /> + <di:waypoint xsi:type="dc:Point" x="531" y="508" /> <bpmndi:BPMNLabel> - <dc:Bounds x="355.5" y="468" width="90" height="0" /> + <dc:Bounds x="473" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0w9805b_di" bpmnElement="UpdateVnfIpv4OamAddress"> - <dc:Bounds x="280" y="443" width="100" height="80" /> + <dc:Bounds x="404" y="468" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0khqfnc_di" bpmnElement="SequenceFlow_0khqfnc"> - <di:waypoint xsi:type="dc:Point" x="521" y="483" /> - <di:waypoint xsi:type="dc:Point" x="561" y="483" /> + <di:waypoint xsi:type="dc:Point" x="631" y="508" /> + <di:waypoint xsi:type="dc:Point" x="654" y="508" /> <bpmndi:BPMNLabel> - <dc:Bounds x="496" y="468" width="90" height="0" /> + <dc:Bounds x="598" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0yuz21z_di" bpmnElement="SequenceFlow_0yuz21z"> - <di:waypoint xsi:type="dc:Point" x="661" y="483" /> - <di:waypoint xsi:type="dc:Point" x="706" y="483" /> + <di:waypoint xsi:type="dc:Point" x="754" y="508" /> + <di:waypoint xsi:type="dc:Point" x="779" y="508" /> <bpmndi:BPMNLabel> - <dc:Bounds x="638.5" y="468" width="90" height="0" /> + <dc:Bounds x="722" y="493" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0v8naz9_di" bpmnElement="UpdateVfModuleContrailServiceInstanceFqdn"> - <dc:Bounds x="561" y="443" width="100" height="80" /> + <dc:Bounds x="654" y="468" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1n8gab5_di" bpmnElement="SequenceFlow_1n8gab5"> - <di:waypoint xsi:type="dc:Point" x="307" y="284" /> - <di:waypoint xsi:type="dc:Point" x="307" y="318" /> - <di:waypoint xsi:type="dc:Point" x="382" y="318" /> + <di:waypoint xsi:type="dc:Point" x="307" y="309" /> + <di:waypoint xsi:type="dc:Point" x="307" y="343" /> + <di:waypoint xsi:type="dc:Point" x="382" y="343" /> <bpmndi:BPMNLabel> - <dc:Bounds x="277" y="294.5" width="90" height="13" /> + <dc:Bounds x="277" y="320" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ParallelGateway_18x6mx2_di" bpmnElement="ExclusiveGateway_0xrgzm7"> - <dc:Bounds x="282" y="234" width="50" height="50" /> + <dc:Bounds x="282" y="259" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="262" y="287" width="90" height="13" /> + <dc:Bounds x="262" y="312" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_032jv5j_di" bpmnElement="SequenceFlow_032jv5j"> - <di:waypoint xsi:type="dc:Point" x="492" y="149" /> - <di:waypoint xsi:type="dc:Point" x="492" y="108" /> - <di:waypoint xsi:type="dc:Point" x="531" y="108" /> + <di:waypoint xsi:type="dc:Point" x="492" y="174" /> + <di:waypoint xsi:type="dc:Point" x="492" y="133" /> + <di:waypoint xsi:type="dc:Point" x="531" y="133" /> <bpmndi:BPMNLabel> - <dc:Bounds x="499" y="114" width="18" height="25" /> + <dc:Bounds x="499" y="139" width="19" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0qfmmgt_di" bpmnElement="SequenceFlow_0qfmmgt"> - <di:waypoint xsi:type="dc:Point" x="754" y="108" /> - <di:waypoint xsi:type="dc:Point" x="784" y="108" /> - <di:waypoint xsi:type="dc:Point" x="784" y="149" /> + <di:waypoint xsi:type="dc:Point" x="754" y="133" /> + <di:waypoint xsi:type="dc:Point" x="780" y="133" /> <bpmndi:BPMNLabel> - <dc:Bounds x="724" y="86.5" width="90" height="13" /> + <dc:Bounds x="722" y="111.5" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_14bu4ys_di" bpmnElement="SequenceFlow_14bu4ys"> - <di:waypoint xsi:type="dc:Point" x="861" y="259" /> - <di:waypoint xsi:type="dc:Point" x="898" y="259" /> + <di:waypoint xsi:type="dc:Point" x="950" y="284" /> + <di:waypoint xsi:type="dc:Point" x="1100" y="283" /> <bpmndi:BPMNLabel> - <dc:Bounds x="834.5" y="237.5" width="90" height="13" /> + <dc:Bounds x="980" y="262" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ParallelGateway_02fjfb8_di" bpmnElement="ExclusiveGateway_1yvh16a"> - <dc:Bounds x="811" y="234" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="790" y="287" width="90" height="13" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1mgunf3_di" bpmnElement="SequenceFlow_1mgunf3"> - <di:waypoint xsi:type="dc:Point" x="492" y="199" /> - <di:waypoint xsi:type="dc:Point" x="492" y="232" /> - <di:waypoint xsi:type="dc:Point" x="784" y="232" /> - <di:waypoint xsi:type="dc:Point" x="784" y="199" /> + <di:waypoint xsi:type="dc:Point" x="492" y="224" /> + <di:waypoint xsi:type="dc:Point" x="492" y="257" /> + <di:waypoint xsi:type="dc:Point" x="868" y="257" /> + <di:waypoint xsi:type="dc:Point" x="868" y="224" /> <bpmndi:BPMNLabel> - <dc:Bounds x="499" y="212" width="15" height="13" /> + <dc:Bounds x="503.9261744966443" y="237" width="14" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1vmz3zo_di" bpmnElement="Check_Audit"> - <dc:Bounds x="339" y="134" width="100" height="80" /> + <dc:Bounds x="339" y="159" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1v3jgqe_di" bpmnElement="SequenceFlow_1v3jgqe"> - <di:waypoint xsi:type="dc:Point" x="307" y="234" /> - <di:waypoint xsi:type="dc:Point" x="307" y="174" /> - <di:waypoint xsi:type="dc:Point" x="339" y="174" /> + <di:waypoint xsi:type="dc:Point" x="307" y="259" /> + <di:waypoint xsi:type="dc:Point" x="307" y="199" /> + <di:waypoint xsi:type="dc:Point" x="339" y="199" /> <bpmndi:BPMNLabel> - <dc:Bounds x="277" y="197.5" width="90" height="13" /> + <dc:Bounds x="277" y="223" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1odt2wt_di" bpmnElement="SequenceFlow_1odt2wt"> - <di:waypoint xsi:type="dc:Point" x="439" y="174" /> - <di:waypoint xsi:type="dc:Point" x="467" y="174" /> + <di:waypoint xsi:type="dc:Point" x="439" y="199" /> + <di:waypoint xsi:type="dc:Point" x="467" y="199" /> <bpmndi:BPMNLabel> - <dc:Bounds x="408" y="152.5" width="90" height="13" /> + <dc:Bounds x="408" y="178" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1swistn_di" bpmnElement="SequenceFlow_1swistn"> - <di:waypoint xsi:type="dc:Point" x="631" y="108" /> - <di:waypoint xsi:type="dc:Point" x="654" y="108" /> + <di:waypoint xsi:type="dc:Point" x="631" y="133" /> + <di:waypoint xsi:type="dc:Point" x="654" y="133" /> <bpmndi:BPMNLabel> - <dc:Bounds x="597.5" y="86.5" width="90" height="13" /> + <dc:Bounds x="598" y="112" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1l8r2a6_di" bpmnElement="Audit_Inventory"> - <dc:Bounds x="654" y="68" width="100" height="80" /> + <dc:Bounds x="654" y="93" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1gttdjr_di" bpmnElement="Setup_Audit_Variable"> - <dc:Bounds x="531" y="68" width="100" height="80" /> + <dc:Bounds x="531" y="93" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1ut7n32_di" bpmnElement="SequenceFlow_1ut7n32"> - <di:waypoint xsi:type="dc:Point" x="809" y="174" /> - <di:waypoint xsi:type="dc:Point" x="836" y="174" /> - <di:waypoint xsi:type="dc:Point" x="836" y="234" /> + <di:waypoint xsi:type="dc:Point" x="893" y="199" /> + <di:waypoint xsi:type="dc:Point" x="925" y="199" /> + <di:waypoint xsi:type="dc:Point" x="925" y="259" /> <bpmndi:BPMNLabel> - <dc:Bounds x="777.5" y="152.5" width="90" height="13" /> + <dc:Bounds x="864" y="177.5" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_1olwkdn_di" bpmnElement="ExclusiveGateway_1h2ystu" isMarkerVisible="true"> - <dc:Bounds x="467" y="149" width="50" height="50" /> + <dc:Bounds x="467" y="174" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="518" y="162" width="47" height="25" /> + <dc:Bounds x="519" y="187" width="45" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_1d1pmqz_di" bpmnElement="ExclusiveGateway_1pydilb" isMarkerVisible="true"> - <dc:Bounds x="759" y="149" width="50" height="50" /> + <dc:Bounds x="843" y="174" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="733" y="227" width="90" height="13" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <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="EndEvent_1gzq57j_di" bpmnElement="EndEvent_1gzq57j"> + <dc:Bounds x="510" y="725" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="438" y="765" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1isbxvo_di" bpmnElement="ServiceTask_1isbxvo"> + <dc:Bounds x="353" y="703" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0xuodpy_di" bpmnElement="SequenceFlow_0xuodpy"> + <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="280.5" y="722" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1fhst92_di" bpmnElement="SequenceFlow_1fhst92"> + <di:waypoint xsi:type="dc:Point" x="453" y="743" /> + <di:waypoint xsi:type="dc:Point" x="510" y="743" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="393" y="722" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_179btn2_di" bpmnElement="SequenceFlow_179btn2"> + <di:waypoint xsi:type="dc:Point" x="195" y="508" /> + <di:waypoint xsi:type="dc:Point" x="276" y="508" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="191" y="487" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="IntermediateThrowEvent_1sftyjz_di" bpmnElement="aaiThrow"> + <dc:Bounds x="1100" y="266" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="1092" y="305" width="55" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="IntermediateCatchEvent_13y483m_di" bpmnElement="aaiCatch"> + <dc:Bounds x="159" y="490" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="150" y="530" width="55" height="12" /> + </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="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" width="14" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <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="694" y="202" width="0" height="13" /> + <dc:Bounds x="760" y="59" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> 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/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java index 5ef4d7ea98..ff987b75d4 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java @@ -36,7 +36,7 @@ import org.junit.runner.RunWith; import org.onap.so.TestApplication; import org.onap.so.bpmn.buildingblock.HomingV2; import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.bpmn.common.validation.BuildingBlockValidatorRunner; +import org.onap.so.bpmn.common.listener.validation.BuildingBlockValidatorRunner; import org.onap.so.bpmn.infrastructure.aai.tasks.AAICommonTasks; import org.onap.so.bpmn.infrastructure.aai.tasks.AAICreateTasks; import org.onap.so.bpmn.infrastructure.aai.tasks.AAIDeleteTasks; 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/ActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy index f4bdde5e80..0338647ce7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy @@ -33,6 +33,8 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ResourceType import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.slf4j.Logger @@ -52,7 +54,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - + MsoUtils msoUtils = new MsoUtils() public void preProcessRequest(DelegateExecution execution) { @@ -83,49 +85,15 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } String sdnc_svcAction = "activate" - switch (resourceInputObj.getResourceModelInfo().getModelName()) { - case ~/[\w\s\W]*SOTNConnectivity[\w\s\W]*/ : - operationType = "SOTNConnectivity" - break - - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : - operationType = "SOTNAttachment" - break - - case ~/[\w\s\W]*SiteVF[\w\s\W]*/ : - operationType = "Site" - break - - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - operationType = "SDWANDevice" - execution.setVariable("isActivateRequired", "true") - break + String sdnc_requestAction = sdnc_svcAction.capitalize() + UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".operation-type") + "Instance" - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - operationType = "SDWANPort" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*SDWANConnectivity[\w\s\W]*/ : - operationType = "SDWANConnectivity" - break - - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - operationType = "SDWANAttachment" - break - - default: - break - } - - String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance" execution.setVariable(Prefix + "svcAction", sdnc_svcAction) execution.setVariable(Prefix + "requestAction", sdnc_requestAction) execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId()) execution.setVariable("mso-request-id", requestId) execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId()) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex){ String msg = "Exception in preProcessRequest " + ex.getMessage() logger.debug(msg) @@ -174,20 +142,20 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } String customizeResourceParam(String networkInputParametersJson) { - List<Map<String, Object>> paramList = new ArrayList(); + List<Map<String, Object>> paramList = new ArrayList() JSONObject jsonObject = new JSONObject(networkInputParametersJson); - Iterator iterator = jsonObject.keys(); + Iterator iterator = jsonObject.keys() while (iterator.hasNext()) { - String key = iterator.next(); - HashMap<String, String> hashMap = new HashMap(); + String key = iterator.next() + HashMap<String, String> hashMap = new HashMap() hashMap.put("name", key); hashMap.put("value", jsonObject.get(key)) paramList.add(hashMap) } - Map<String, List<Map<String, Object>>> paramMap = new HashMap(); - paramMap.put("param", paramList); + Map<String, List<Map<String, Object>>> paramMap = new HashMap() + paramMap.put("param", paramList) - return new JSONObject(paramMap).toString(); + return new JSONObject(paramMap).toString() } public void prepareSDNCRequest (DelegateExecution execution) { @@ -206,7 +174,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { String source = execution.getVariable("source") String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId") ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(execution.getVariable(Prefix + "resourceInput"), ResourceInput.class) - String networkInstanceId = execution.getVariable("networkInstanceId") + String resourceInstanceId = execution.getVariable("resourceInstanceId") String serviceType = resourceInputObj.getServiceType() String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid() String serviceModelUuid = resourceInputObj.getServiceModelInfo().getModelUuid() @@ -224,11 +192,28 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(networkInputParametersJson))) // 1. prepare assign topology via SDNC Adapter SUBFLOW call String sdncTopologyActivateRequest = "" + String modelType = resourceInputObj.getResourceModelInfo().getModelType() + + //When a new resource creation request reaches SO, the parent resources information needs to be provided + //while creating the child resource. + String vnfid = "" + String vnfmodelInvariantUuid = "" + String vnfmodelCustomizationUuid = "" + String vnfmodelUuid = "" + String vnfmodelVersion = "" + String vnfmodelName = "" + if(modelType.equalsIgnoreCase(ResourceType.GROUP.toString())) { + vnfid = resourceInputObj.getVnfId() + ModelInfo vfModelInfo = resourceInputObj.getVfModelInfo() + vnfmodelInvariantUuid = vfModelInfo.getModelInvariantUuid() + vnfmodelCustomizationUuid = vfModelInfo.getModelCustomizationUuid() + vnfmodelUuid = vfModelInfo.getModelUuid() + vnfmodelVersion = vfModelInfo.getModelVersion() + vnfmodelName = vfModelInfo.getModelName() + } - switch (modelName) { - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteVF[\w\s\W]*/: + switch (modelType) { + case "VNF" : sdncTopologyActivateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> @@ -263,7 +248,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> </service-information> <vnf-information> - <vnf-id>${msoUtils.xmlEscape(networkInstanceId)}</vnf-id> + <vnf-id>${msoUtils.xmlEscape(resourceInstanceId)}</vnf-id> <vnf-type></vnf-type> <onap-model-information> <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> @@ -286,17 +271,15 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { </aetgt:SDNCAdapterWorkflowRequest>""".trim() break - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/: - sdncTopologyActivateRequest = - """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" - xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" + case "GROUP" : + sdncTopologyActivateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> <sdncadapter:RequestHeader> <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>connection-attachment-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation> <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> </sdncadapter:RequestHeader> @@ -320,23 +303,34 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { </onap-model-information> <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> + <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> </service-information> - <allotted-resource-information> - <!-- TODO: to be filled as per the request input --> - <allotted-resource-id>${msoUtils.xmlEscape(networkInstanceId)}</allotted-resource-id> - <allotted-resource-type></allotted-resource-type> - <parent-service-instance-id>$parentServiceInstanceId</parent-service-instance-id> + <vnf-information> <onap-model-information> - <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> + <model-invariant-uuid>${msoUtils.xmlEscape(vnfmodelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(vnfmodelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(vnfmodelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(vnfmodelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(vnfmodelName)}</model-name> + </onap-model-information> + <vnf-id>${msoUtils.xmlEscape(vnfid)}</vnf-id> + </vnf-information> + <vf-module-information> + <from-preload>false</from-preload> + <vf-module-id>${msoUtils.xmlEscape(resourceInstanceId)}</vf-module-id> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> <model-name>${msoUtils.xmlEscape(modelName)}</model-name> </onap-model-information> - </allotted-resource-information> - <connection-attachment-request-input> - $netowrkInputParameters - </connection-attachment-request-input> + </vf-module-information> + <vf-module-request-input> + <vf-module-input-parameters> + $netowrkInputParameters + </vf-module-input-parameters> + </vf-module-request-input> </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() break @@ -378,7 +372,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { </service-information> <network-information> <!-- TODO: to be filled by response from create --> - <network-id>${msoUtils.xmlEscape(networkInstanceId)}</network-id> + <network-id>${msoUtils.xmlEscape(resourceInstanceId)}</network-id> <onap-model-information> <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> @@ -434,4 +428,4 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } logger.info("exited send sync Resp") } -} +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy index fa3bfdb0e3..2abee7caaa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy @@ -23,30 +23,28 @@ package org.onap.so.bpmn.infrastructure.scripts -import org.onap.aai.domain.yang.ServiceInstance -import org.onap.so.bpmn.core.domain.ServiceDecomposition -import org.onap.so.bpmn.core.domain.VnfResource -import org.onap.so.client.aai.AAIObjectType -import org.onap.so.client.aai.AAIResourcesClient -import org.onap.so.client.aai.entities.uri.AAIResourceUri -import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode; - import static org.apache.commons.lang3.StringUtils.* - import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.aai.AAIObjectType +import org.onap.so.client.aai.AAIResourcesClient +import org.onap.so.client.aai.entities.uri.AAIResourceUri +import org.onap.so.client.aai.entities.uri.AAIUriFactory +import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils - import groovy.json.* /** @@ -332,7 +330,7 @@ public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor logger.debug("CreateVfModuleInfra Outgoing updateServiceOperStatusRequest Request: " + payload) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index b70797c63b..d431bdc3b4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import com.google.gson.Gson import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution @@ -39,6 +40,8 @@ import org.onap.so.bpmn.common.scripts.AaiUtil import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ResourceType import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.client.aai.AAIObjectPlurals @@ -86,6 +89,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { //Deal with recipeParams String recipeParamsFromWf = execution.getVariable("recipeParamXsd") String resourceName = resourceInputObj.getResourceInstanceName() + //For sdnc requestAction default is "createNetworkInstance" String operationType = "Network" if(!StringUtils.isBlank(recipeParamsFromRequest)){ @@ -97,83 +101,18 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType") } - - //For sdnc, generate svc_action and request_action String sdnc_svcAction = "create" - switch (resourceInputObj.getResourceInstanceName()) { - - case ~/[\w\s\W]*overlay[\w\s\W]*/ : - //This will be resolved in R3. - sdnc_svcAction ="activate" - operationType = "NCINetwork" - break - - case ~/[\w\s\W]*underlay[\w\s\W]*/ : - //This will be resolved in R3. - operationType ="Network" - break - - case ~/[\w\s\W]*SOTNConnectivity[\w\s\W]*/ : - operationType = "SOTNConnectivity" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : - operationType = "SOTNAttachment" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*SiteVF[\w\s\W]*/ : - operationType = "Site" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - operationType = "SDWANDevice" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - operationType = "SDWANPort" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*SDWANConnectivity[\w\s\W]*/ : - operationType = "SDWANConnectivity" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - operationType = "SDWANAttachment" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*wanconnection[\w\s\W]*/ : - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*AccessConnectivity[\w\s\W]*/ : - operationType = "AccessConnectivity" - execution.setVariable("isActivateRequired", "false") - break + String sdnc_requestAction = sdnc_svcAction.capitalize() + UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".operation-type") + "Instance" + String isActivateRequired = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() +".activation-required") + execution.setVariable("isActivateRequired", isActivateRequired) - case ~/[\w\s\W]*InternetProfile[\w\s\W]*/ : - operationType = "InternetProfile" - execution.setVariable("isActivateRequired", "false") - break - - default: - break - } - - String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance" execution.setVariable(Prefix + "svcAction", sdnc_svcAction) execution.setVariable(Prefix + "requestAction", sdnc_requestAction) execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId()) execution.setVariable("mso-request-id", requestId) execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId()) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex){ msg = "Exception in preProcessRequest " + ex.getMessage() logger.debug(msg) @@ -216,7 +155,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { * This method updates the resource input by collecting required info from AAI * @param execution */ - public void updateResourceInput(DelegateExecution execution) { + public ResourceInput updateResourceInput(DelegateExecution execution) { ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(execution.getVariable(Prefix + "resourceInput"), ResourceInput.class) String modelName = resourceInputObj.getResourceModelInfo().getModelName() @@ -225,19 +164,36 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String serInput = jsonUtil.getJsonValue(resourceInputTmp, "requestsInputs") switch (modelName) { - case ~/[\w\s\W]*AccessConnectivity[\w\s\W]*/ : + case ~/[\w\s\W]*OLT[\w\s\W]*/ : // get the required properties and update in resource input def resourceInput = resourceInputObj.getResourceParameters() String incomingRequest = resourceInputObj.getRequestsInputs() String serviceParameters = JsonUtils.getJsonValue(incomingRequest, "service.parameters") String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs") - String cvlan = jsonUtil.getJsonValue(serInput, - "service.parameters.requestInputs.cvlan") - String svlan = jsonUtil.getJsonValue(serInput, - "service.parameters.requestInputs.svlan") - String remoteId = jsonUtil.getJsonValue(serInput, - "service.parameters.requestInputs.edgeinternetprofile_ip_remote_id") + String cvlan + String svlan + String remoteId + + List<Metadatum> metadatum = getMetaDatum(resourceInputObj.getGlobalSubscriberId(), + resourceInputObj.getServiceType(), + resourceInputObj.getServiceInstanceId()) + for(Metadatum datum: metadatum) { + if (datum.getMetaname().equalsIgnoreCase("cvlan")) { + cvlan = datum.getMetaval() + } + + if (datum.getMetaname().equalsIgnoreCase("svlan")) { + svlan = datum.getMetaval() + } + + if (datum.getMetaname().equalsIgnoreCase("remoteId")) { + remoteId = datum.getMetaval() + } + } + + logger.debug("cvlan: "+cvlan+" | svlan: "+svlan+" | remoteId: "+remoteId) + String manufacturer = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_manufacturer") String ontsn = jsonUtil.getJsonValue(serInput, @@ -254,7 +210,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { logger.debug("new resource Input :" + resourceInputObj.toString()) break - case ~/[\w\s\W]*InternetProfile[\w\s\W]*/ : + case ~/[\w\s\W]*EdgeInternetProfile[\w\s\W]*/ : // get the required properties and update in resource input def resourceInput = resourceInputObj.getResourceParameters() String incomingRequest = resourceInputObj.getRequestsInputs() @@ -262,34 +218,37 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs") JSONObject inputParameters = new JSONObject(requestInputs) - String cvlan = jsonUtil.getJsonValue(serInput, - "service.parameters.requestInputs.cvlan") - String svlan = jsonUtil.getJsonValue(serInput, - "service.parameters.requestInputs.svlan") + String cvlan + String svlan + String remoteId String manufacturer = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_manufacturer") - String remoteId = jsonUtil.getJsonValue(serInput, - "service.parameters.requestInputs.edgeinternetprofile_ip_remote_id") + String ontsn = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_serial_num") - String serviceType = jsonUtil.getJsonValue(serInput, - "service.parameters.requestInputs.edgeinternetprofile_ip_service_type") - String macAddr = jsonUtil.getJsonValue(serInput, - "service.parameters.requestInputs.edgeinternetprofile_ip_rg_mac_addr") - String upStream = jsonUtil.getJsonValue(serInput, - "service.parameters.requestInputs.edgeinternetprofile_ip_upstream_speed") - String downStream = jsonUtil.getJsonValue(serInput, - "service.parameters.requestInputs.edgeinternetprofile_ip_downstream_speed") + + List<Metadatum> metadatum = getMetaDatum(resourceInputObj.getGlobalSubscriberId(), + resourceInputObj.getServiceType(), + resourceInputObj.getServiceInstanceId()) + for(Metadatum datum: metadatum) { + if (datum.getMetaname().equalsIgnoreCase("cvlan")) { + cvlan = datum.getMetaval() + } + + if (datum.getMetaname().equalsIgnoreCase("svlan")) { + svlan = datum.getMetaval() + } + + if (datum.getMetaname().equalsIgnoreCase("remoteId")) { + remoteId = datum.getMetaval() + } + } String uResourceInput = jsonUtil.addJsonValue(resourceInput, "requestInputs.c_vlan", cvlan) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.s_vlan", svlan) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.manufacturer", manufacturer) - uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_remote_id", remoteId) + uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_access_id", remoteId) uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ont_sn", ontsn) - uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_service_type", serviceType) - uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_rg_mac_addr", macAddr) - uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_upstream_speed", upStream) - uResourceInput = jsonUtil.addJsonValue(uResourceInput, "requestInputs.ip_downstream_speed", downStream) logger.debug("old resource input:" + resourceInputObj.toString()) resourceInputObj.setResourceParameters(uResourceInput) execution.setVariable(Prefix + "resourceInput", resourceInputObj.toString()) @@ -337,6 +296,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { default: break } + return resourceInputObj } /** @@ -377,12 +337,31 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { //here convert json string to xml string String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(networkInputParametersJson))) // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sdncTopologyCreateRequest = "" + String sdncTopologyCreateRequest = ""; + + + + //When a new resource creation request reaches SO, the parent resources information needs to be provided + //while creating the child resource. + String vnfid = "" + String vnfmodelInvariantUuid = "" + String vnfmodelCustomizationUuid = "" + String vnfmodelUuid = "" + String vnfmodelVersion = "" + String vnfmodelName = "" + String modelType = resourceInputObj.getResourceModelInfo().getModelType() + if(modelType.equalsIgnoreCase(ResourceType.GROUP.toString())) { + vnfid = resourceInputObj.getVnfId() + ModelInfo vfModelInfo = resourceInputObj.getVfModelInfo() + vnfmodelInvariantUuid = vfModelInfo.getModelInvariantUuid() + vnfmodelCustomizationUuid = vfModelInfo.getModelCustomizationUuid() + vnfmodelUuid = vfModelInfo.getModelUuid() + vnfmodelVersion = vfModelInfo.getModelVersion() + vnfmodelName = vfModelInfo.getModelName() + } - switch (modelName) { - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteVF[\w\s\W]*/: + switch (modelType) { + case "VNF" : sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> @@ -417,7 +396,6 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> </service-information> <vnf-information> - <vnf-id></vnf-id> <vnf-type></vnf-type> <onap-model-information> <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> @@ -439,9 +417,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() break - - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : + case "GROUP" : sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> @@ -449,7 +425,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>connection-attachment-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation> <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> </sdncadapter:RequestHeader> @@ -475,22 +451,31 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> </service-information> - <allotted-resource-information> - <!-- TODO: to be filled as per the request input --> - <allotted-resource-id></allotted-resource-id> - <allotted-resource-type></allotted-resource-type> - <parent-service-instance-id>$parentServiceInstanceId</parent-service-instance-id> + <vnf-information> <onap-model-information> - <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> + <model-invariant-uuid>${msoUtils.xmlEscape(vnfmodelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(vnfmodelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(vnfmodelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(vnfmodelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(vnfmodelName)}</model-name> + </onap-model-information> + <vnf-id>${msoUtils.xmlEscape(vnfid)}</vnf-id> + </vnf-information> + <vf-module-information> + <from-preload>false</from-preload> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> <model-name>${msoUtils.xmlEscape(modelName)}</model-name> </onap-model-information> - </allotted-resource-information> - <connection-attachment-request-input> - $netowrkInputParameters - </connection-attachment-request-input> + </vf-module-information> + <vf-module-request-input> + <vf-module-input-parameters> + $netowrkInputParameters + </vf-module-input-parameters> + </vf-module-request-input> </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() break @@ -498,13 +483,70 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { // for SDWANConnectivity and SOTNConnectivity: default: sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" + xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-information> + <request-id>${msoUtils.xmlEscape(hdrRequestId)}</request-id> + <request-action>${msoUtils.xmlEscape(sdnc_requestAction)}</request-action> + <source>${msoUtils.xmlEscape(source)}</source> + <notification-url></notification-url> + <order-number></order-number> + <order-version></order-version> + </request-information> + <service-information> + <service-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-id> + <subscription-service-type>${msoUtils.xmlEscape(serviceType)}</subscription-service-type> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid> + <model-uuid>${msoUtils.xmlEscape(serviceModelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(serviceModelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(serviceModelName)}</model-name> + </onap-model-information> + <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> + <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> + </service-information> + <network-information> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(modelName)}</model-name> + </onap-model-information> + </network-information> + <network-request-input> + <network-input-parameters>$netowrkInputParameters</network-input-parameters> + </network-request-input> + </sdncadapterworkflow:SDNCRequestData> + </aetgt:SDNCAdapterWorkflowRequest>""".trim() + + + } + + + + + //switch (modelName) { + // case ~/[\w\s\W]*deviceVF[\w\s\W]*/ + // case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : + // case ~/[\w\s\W]*SiteVF[\w\s\W]*/: + /* sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId> + <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> </sdncadapter:RequestHeader> @@ -528,8 +570,11 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { </onap-model-information> <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> + <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> </service-information> - <network-information> + <vnf-information> + <vnf-id></vnf-id> + <vnf-type></vnf-type> <onap-model-information> <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> @@ -537,13 +582,147 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> <model-name>${msoUtils.xmlEscape(modelName)}</model-name> </onap-model-information> - </network-information> - <network-request-input> - <network-input-parameters>$netowrkInputParameters</network-input-parameters> - </network-request-input> + </vnf-information> + <vnf-request-input> + <vnf-input-parameters> + $netowrkInputParameters + </vnf-input-parameters> + <request-version></request-version> + <vnf-name></vnf-name> + <vnf-networks> + </vnf-networks> + </vnf-request-input> </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() - } + + + break + + //case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ + //case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : + /* sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" + xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>connection-attachment-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-information> + <request-id>${msoUtils.xmlEscape(hdrRequestId)}</request-id> + <request-action>${msoUtils.xmlEscape(sdnc_requestAction)}</request-action> + <source>${msoUtils.xmlEscape(source)}</source> + <notification-url></notification-url> + <order-number></order-number> + <order-version></order-version> + </request-information> + <service-information> + <service-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-id> + <subscription-service-type>${msoUtils.xmlEscape(serviceType)}</subscription-service-type> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid> + <model-uuid>${msoUtils.xmlEscape(serviceModelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(serviceModelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(serviceModelName)}</model-name> + </onap-model-information> + <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> + <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> + <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> + </service-information><vnf-information> + <vnf-id></vnf-id> + <vnf-type></vnf-type> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(modelName)}</model-name> + </onap-model-information> + </vnf-information> + <vnf-request-input> + <vnf-input-parameters> + $netowrkInputParameters + </vnf-input-parameters> + <request-version></request-version> + <vnf-name></vnf-name> + <vnf-networks> + </vnf-networks> + </vnf-request-input> + <allotted-resource-information> + <!-- TODO: to be filled as per the request input --> + <allotted-resource-id></allotted-resource-id> + <allotted-resource-type></allotted-resource-type> + <parent-service-instance-id>$parentServiceInstanceId</parent-service-instance-id> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(modelName)}</model-name> + </onap-model-information> + </allotted-resource-information> + <connection-attachment-request-input> + $netowrkInputParameters + </connection-attachment-request-input> + </sdncadapterworkflow:SDNCRequestData> + </aetgt:SDNCAdapterWorkflowRequest>""".trim() + break + + // for SDWANConnectivity and SOTNConnectivity: + default: + sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" + xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> + <sdncadapter:RequestHeader> + <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId> + <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> + <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> + <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> + <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-information> + <request-id>${msoUtils.xmlEscape(hdrRequestId)}</request-id> + <request-action>${msoUtils.xmlEscape(sdnc_requestAction)}</request-action> + <source>${msoUtils.xmlEscape(source)}</source> + <notification-url></notification-url> + <order-number></order-number> + <order-version></order-version> + </request-information> + <service-information> + <service-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-id> + <subscription-service-type>${msoUtils.xmlEscape(serviceType)}</subscription-service-type> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid> + <model-uuid>${msoUtils.xmlEscape(serviceModelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(serviceModelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(serviceModelName)}</model-name> + </onap-model-information> + <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> + <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> + </service-information> + <network-information> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(modelName)}</model-name> + </onap-model-information> + </network-information> + <network-request-input> + <network-input-parameters>$netowrkInputParameters</network-input-parameters> + </network-request-input> + </sdncadapterworkflow:SDNCRequestData> + </aetgt:SDNCAdapterWorkflowRequest>""".trim() + } + + **/ String sndcTopologyCreateRequesAsString = utils.formatXml(sdncTopologyCreateRequest) execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyCreateRequesAsString) @@ -634,11 +813,8 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String responseCode = execution.getVariable(Prefix + "sdncCreateReturnCode") String responseObj = execution.getVariable(Prefix + "SuccessIndicator") - def isActivateRequried = execution.getVariable("isActivateRequired") - if (StringUtils.equalsIgnoreCase(isActivateRequried, "true")) { - def instnaceId = getInstnaceId(execution) - execution.setVariable("networkInstanceId", instnaceId) - } + def instnaceId = getInstnaceId(execution) + execution.setVariable("resourceInstanceId", instnaceId) logger.info("response from sdnc, response code :" + responseCode + " response object :" + responseObj) logger.info(" ***** Exit prepareSDNCRequest *****") @@ -651,24 +827,38 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String modelName = resourceInputObj.getResourceModelInfo().getModelName() def val = "" - switch (modelName) { - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - case ~/[\w\s\W]*Site[\w\s\W]*/: - val = response."response-data"."RequestData"."output"."vnf-response-information"."instance-id" - break - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/: - val = response."response-data"."RequestData"."output"."connection-attachment-response-information"."instance-id" - break + //switch (modelName) { + // case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : + // case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : + // case ~/[\w\s\W]*Site[\w\s\W]*/: + // val = response."response-data"."RequestData"."output"."vnf-response-information"."instance-id" + // break + + // case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : + // case ~/[\w\s\W]*sotnvpprepareUpdateAfterCreateSDNCResourcenattachment[\w\s\W]*/: + // val = response."response-data"."RequestData"."output"."connection-attachment-response-information"."instance-id" + // break // for SDWANConnectivity and SOTNConnectivity and default: + // default: + // val = response."response-data"."RequestData"."output"."network-response-information"."instance-id" + // break + //} + + + String modelType = resourceInputObj.getResourceModelInfo().getModelType() + switch (modelType) { + case "VNF" : + val = response."response-data"."RequestData"."output"."vnf-response-information"."instance-id" + break + case "GROUP": + val = response."response-data"."RequestData"."output"."vf-module-response-information"."instance-id" + break default: val = response."response-data"."RequestData"."output"."network-response-information"."instance-id" break } - return val.toString() } @@ -678,7 +868,8 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { try { String operationStatus = "finished" // RESTResponse for main flow - String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim() + String vnfid=execution.getVariable("resourceInstanceId"); + String resourceOperationResp = """{"operationStatus":"${operationStatus}","vnf-id":"${vnfid}"}""".trim() logger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp) sendWorkflowResponse(execution, 202, resourceOperationResp) execution.setVariable("sentSyncResponse", true) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index fa9fe62df4..c9dadf57cb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.v12.GenericVnf; @@ -251,7 +252,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { String restFaultMessage = e.getMessage() //execution.setVariable("CVFMODVOL2_RESTFault", restFaultMessage) //execution.setVariable("CVFMODVOL2_isDataOk", false) - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest") @@ -301,7 +302,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Encountered ", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) @@ -402,7 +403,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { logger.debug("Outgoing MsoCompletionRequest: \n" + payload) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing PostProcessResponse - " + "\n", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("CVFMI_ErrorResponse", "Error Occured during PostProcessResponse Method:\n" + e.getMessage()) @@ -479,7 +480,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Caught exception in " + method , "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message") @@ -528,7 +529,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { logger.debug("CreateVfModuleInfra Outgoing UpdateInfra Request: " + payload) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing prepareUpdateInfraRequest.", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareUpdateInfraRequest Method:\n" + e.getMessage()) @@ -584,7 +585,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Caught exception in " + method , "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy index 5ba90eb989..1fba23d3c8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; @@ -306,7 +307,7 @@ class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { String xmlHandlerRequest = utils.formatXml(falloutHandlerRequest) execution.setVariable(prefix+'FalloutHandlerRequest', xmlHandlerRequest) - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Overall Error Response " + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Overall Error Response " + "going to FalloutHandler", "BPMN", ErrorCode.UnknownError.getValue(), "\n" + xmlHandlerRequest); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy index e941d50155..3eb15558d2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVnfInfra.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory import org.onap.so.logger.ErrorCode @@ -168,7 +169,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) @@ -194,7 +195,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { logger.debug("Rethrowing MSOWorkflowException") throw b }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), " Error Occurred in " + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), " Error Occurred in " + "CreateVnfInfra PreProcessRequest method", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in CreateVnfInfra PreProcessRequest") @@ -220,7 +221,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { execution.setVariable("CREVI_sentSyncResponse", true) } catch (Exception ex) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), " Error Occurred in CreateVnfInfra SendSyncResponse Process", "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), " Error Occurred in CreateVnfInfra SendSyncResponse Process", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra SendSyncResponse Process") @@ -246,7 +247,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { logger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage()) } @@ -270,7 +271,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { logger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured " + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured " + "Processing preProcessSDNCActivateRequest", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) } @@ -461,7 +462,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { logger.debug("obtained VNF list: " + vnfs) if (vnfs == null) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "No matching " + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "No matching " + "VNFs in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid, "BPMN", ErrorCode.UnknownError.getValue(), ""); exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "No matching VNFs in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid) } @@ -470,7 +471,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { JSONObject vnf = vnfs.get(0) if (vnf == null) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "No matching VNF" + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "No matching VNF" + " in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid, "BPMN", ErrorCode.UnknownError.getValue(), ""); exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "No matching VNF in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid) } @@ -543,7 +544,7 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { aaiCR.createAAILineOfBusiness(lineOfBusiness, vnfId) }catch(Exception ex){ String msg = "Exception in LineOfBusiness. " + ex.getMessage(); - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + ex) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy index 4233147f83..3d62a6ca90 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy @@ -31,6 +31,7 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.domain.ModelInfo import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.slf4j.Logger @@ -80,45 +81,14 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor //the operationType from worflow(first node) is highest priority. operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType") } - - - // TODO: based on the resource type decide action and operation type - String sdnc_svcAction = "deactivate" - switch (resourceInputObj.getResourceModelInfo().getModelName()) { - case ~/[\w\s\W]*SOTNConnectivity[\w\s\W]*/ : - operationType = "SOTNConnectivity" - break - - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : - operationType = "SOTNAttachment" - break - - case ~/[\w\s\W]*SiteVF[\w\s\W]*/ : - operationType = "Site" - break - - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - operationType = "SDWANDevice" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*SDWANConnectivity[\w\s\W]*/ : - operationType = "SDWANConnectivity" - break - - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - operationType = "SDWANAttachment" - break - - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - operationType = "SDWANPort" - execution.setVariable("isActivateRequired", "true") - break - - default: - break + String operationTypeFromConfig = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() + ".operation-type") + if (StringUtils.isNotEmpty(operationTypeFromConfig)) { + // highest priority if operation type configured + operationType = operationTypeFromConfig } + // based on the resource type decide action and operation type + String sdnc_svcAction = "deactivate" String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance" execution.setVariable(Prefix + "svcAction", sdnc_svcAction) execution.setVariable(Prefix + "requestAction", sdnc_requestAction) @@ -161,13 +131,12 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor String modelName = resourceInputObj.getResourceModelInfo().getModelName() String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion() String resourceInstnaceId = resourceInputObj.getResourceInstancenUuid() + String modelType = resourceInputObj.getResourceModelInfo().getModelType() // 1. prepare assign topology via SDNC Adapter SUBFLOW call String sdncTopologyDeleteRequest = "" - switch (modelName) { - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteVF[\w\s\W]*/: + switch (modelType) { + case "VNF" : sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> @@ -224,8 +193,17 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor </aetgt:SDNCAdapterWorkflowRequest>""".trim() break - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : + case "GROUP" : + //When a new resource creation request reaches SO, the parent resources information needs to be provided + //while creating the child resource. + String vnfid = resourceInputObj.getVnfId() + ModelInfo vfModelInfo = resourceInputObj.getVfModelInfo() + String vnfmodelInvariantUuid = vfModelInfo.getModelInvariantUuid() + String vnfmodelCustomizationUuid = vfModelInfo.getModelCustomizationUuid() + String vnfmodelUuid = vfModelInfo.getModelUuid() + String vnfmodelVersion = vfModelInfo.getModelVersion() + String vnfmodelName = vfModelInfo.getModelName() + sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> @@ -233,7 +211,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>connection-attachment-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation> <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> </sdncadapter:RequestHeader> @@ -257,26 +235,40 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor </onap-model-information> <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> - <subscriber-name></subscriber-name> + <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> </service-information> - <allotted-resource-information> - <allotted-resource-id>$resourceInstnaceId</allotted-resource-id> - <allotted-resource-type></allotted-resource-type> - <parent-service-instance-id></parent-service-instance-id> - <onap-model-information> - <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> - <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> - <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> - <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> - <model-name>${msoUtils.xmlEscape(modelName)}</model-name> - </onap-model-information> - </allotted-resource-information> - <connection-attachment-request-input> - </connection-attachment-request-input> + <vnf-information> + <vnf-id>$vnfid</vnf-id> + <vnf-type></vnf-type> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(vnfmodelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(vnfmodelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(vnfmodelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(vnfmodelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(vnfmodelName)}</model-name> + </onap-model-information> + </vnf-information> + <vf-module-information> + <vf-module-id>$resourceInstnaceId</vf-module-id> + <vf-module-type></vf-module-type> + <from-preload>false</from-preload> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(modelName)}</model-name> + </onap-model-information> + </vf-module-information> + <vf-module-request-input> + <vf-module-input-parameters> + </vf-module-input-parameters> + </vf-module-request-input> </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() break + // for SDWANConnectivity and SOTNConnectivity: default: sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" @@ -325,6 +317,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor </network-request-input> </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() + } String sdncTopologyDeleteRequesAsString = utils.formatXml(sdncTopologyDeleteRequest) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy index 1e2f50148c..5c7127f36e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil @@ -354,7 +355,7 @@ public class DeleteNetworkInstance extends AbstractServiceTaskProcessor { logger.debug(falloutHandlerRequest) execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, "BPMN", ErrorCode.UnknownError.getValue()) @@ -377,7 +378,7 @@ public class DeleteNetworkInstance extends AbstractServiceTaskProcessor { </aetgt:WorkflowException> </aetgt:FalloutHandlerRequest>""" execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest,"BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + ex) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy index dd9991bbd4..49f0e14d17 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy @@ -31,6 +31,8 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ResourceType import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.slf4j.Logger @@ -52,7 +54,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - + MsoUtils msoUtils = new MsoUtils() public void preProcessRequest(DelegateExecution execution){ @@ -84,62 +86,18 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { //the operationType from worflow(first node) is highest priority. operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType") } + String operationTypeFromConfig = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() + ".operation-type") + if (StringUtils.isNotEmpty(operationTypeFromConfig)) { + // highest priority if operation type configured + operationType = operationTypeFromConfig + } //For sdnc, generate svc_action and request_action String sdnc_svcAction = "delete" - switch (resourceInputObj.getResourceModelInfo().getModelName()) { - - case ~/[\w\s\W]*overlay[\w\s\W]*/ : - ///This will be resolved in R3. - sdnc_svcAction ="deactivate" - operationType = "NCINetwork" - break - - case ~/[\w\s\W]*underlay[\w\s\W]*/ : - //This will be resolved in R3. - operationType ="Network" - break - - case ~/[\w\s\W]*SOTNConnectivity[\w\s\W]*/ : - operationType = "SOTNConnectivity" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : - operationType = "SOTNAttachment" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*SiteVF[\w\s\W]*/ : - operationType = "Site" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - operationType = "SDWANDevice" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*SDWANConnectivity[\w\s\W]*/ : - operationType = "SDWANConnectivity" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - operationType = "SDWANAttachment" - execution.setVariable("isActivateRequired", "true") - break - - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - operationType = "SDWANPort" - execution.setVariable("isActivateRequired", "true") - break - - default: - break - } - String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance" + String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType + "Instance" + String isActivateRequired = UrnPropertiesReader.getVariable("resource-config." + resourceInputObj.resourceModelInfo.getModelName() + ".activation-required") + execution.setVariable("isActivateRequired", isActivateRequired) execution.setVariable(Prefix + "svcAction", sdnc_svcAction) execution.setVariable(Prefix + "requestAction", sdnc_requestAction) execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId()) @@ -190,13 +148,13 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { String modelName = resourceInputObj.getResourceModelInfo().getModelName() String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion() String resourceInstnaceId = resourceInputObj.getResourceInstancenUuid() + String modelType = resourceInputObj.getResourceModelInfo().getModelType() + // 1. prepare assign topology via SDNC Adapter SUBFLOW call String sdncTopologyDeleteRequest = "" - switch (modelName) { - case ~/[\w\s\W]*deviceVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteWANVF[\w\s\W]*/ : - case ~/[\w\s\W]*SiteVF[\w\s\W]*/: + switch (modelType) { + case "VNF": sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> @@ -252,60 +210,82 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { </sdncadapterworkflow:SDNCRequestData> </aetgt:SDNCAdapterWorkflowRequest>""".trim() break - - case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : - case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : - sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" - xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" - xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> - <sdncadapter:RequestHeader> + case "GROUP" : + //When a new resource creation request reaches SO, the parent resources information needs to be provided + //while creating the child resource. + String vnfid = resourceInputObj.getVnfId() + ModelInfo vfModelInfo = resourceInputObj.getVfModelInfo() + String vnfmodelInvariantUuid = vfModelInfo.getModelInvariantUuid() + String vnfmodelCustomizationUuid = vfModelInfo.getModelCustomizationUuid() + String vnfmodelUuid = vfModelInfo.getModelUuid() + String vnfmodelVersion = vfModelInfo.getModelVersion() + String vnfmodelName = vfModelInfo.getModelName() + + sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" + xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" + xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"> + <sdncadapter:RequestHeader> <sdncadapter:RequestId>${msoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId> <sdncadapter:SvcInstanceId>${msoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId> <sdncadapter:SvcAction>${msoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>connection-attachment-topology-operation</sdncadapter:SvcOperation> + <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation> <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${msoUtils.xmlEscape(hdrRequestId)}</request-id> - <request-action>${msoUtils.xmlEscape(sdnc_requestAction)}</request-action> - <source>${msoUtils.xmlEscape(source)}</source> - <notification-url></notification-url> - <order-number></order-number> - <order-version></order-version> - </request-information> - <service-information> - <service-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-id> - <subscription-service-type>${msoUtils.xmlEscape(serviceType)}</subscription-service-type> - <onap-model-information> - <model-invariant-uuid>${msoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid> - <model-uuid>${msoUtils.xmlEscape(serviceModelUuid)}</model-uuid> - <model-version>${msoUtils.xmlEscape(serviceModelVersion)}</model-version> - <model-name>${msoUtils.xmlEscape(serviceModelName)}</model-name> - </onap-model-information> - <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> - <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> - <subscriber-name></subscriber-name> - </service-information> - <allotted-resource-information> - <allotted-resource-id>$resourceInstnaceId</allotted-resource-id> - <allotted-resource-type></allotted-resource-type> - <parent-service-instance-id></parent-service-instance-id> - <onap-model-information> - <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> - <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> - <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> - <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> - <model-name>${msoUtils.xmlEscape(modelName)}</model-name> - </onap-model-information> - </allotted-resource-information> - <connection-attachment-request-input> - </connection-attachment-request-input> - </sdncadapterworkflow:SDNCRequestData> - </aetgt:SDNCAdapterWorkflowRequest>""".trim() + </sdncadapter:RequestHeader> + <sdncadapterworkflow:SDNCRequestData> + <request-information> + <request-id>${msoUtils.xmlEscape(hdrRequestId)}</request-id> + <request-action>${msoUtils.xmlEscape(sdnc_requestAction)}</request-action> + <source>${msoUtils.xmlEscape(source)}</source> + <notification-url></notification-url> + <order-number></order-number> + <order-version></order-version> + </request-information> + <service-information> + <service-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-id> + <subscription-service-type>${msoUtils.xmlEscape(serviceType)}</subscription-service-type> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid> + <model-uuid>${msoUtils.xmlEscape(serviceModelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(serviceModelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(serviceModelName)}</model-name> + </onap-model-information> + <service-instance-id>${msoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> + <global-customer-id>${msoUtils.xmlEscape(globalCustomerId)}</global-customer-id> + <subscriber-name>${msoUtils.xmlEscape(globalCustomerId)}</subscriber-name> + </service-information> + <vnf-information> + <vnf-id>$vnfid</vnf-id> + <vnf-type></vnf-type> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(vnfmodelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(vnfmodelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(vnfmodelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(vnfmodelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(vnfmodelName)}</model-name> + </onap-model-information> + </vnf-information> + <vf-module-information> + <vf-module-id>$resourceInstnaceId</vf-module-id> + <vf-module-type></vf-module-type> + <from-preload>false</from-preload> + <onap-model-information> + <model-invariant-uuid>${msoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid> + <model-customization-uuid>${msoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid> + <model-uuid>${msoUtils.xmlEscape(modelUuid)}</model-uuid> + <model-version>${msoUtils.xmlEscape(modelVersion)}</model-version> + <model-name>${msoUtils.xmlEscape(modelName)}</model-name> + </onap-model-information> + </vf-module-information> + <vf-module-request-input> + <vf-module-input-parameters> + </vf-module-input-parameters> + </vf-module-request-input> + </sdncadapterworkflow:SDNCRequestData> + </aetgt:SDNCAdapterWorkflowRequest>""".trim() break + // for SDWANConnectivity and SOTNConnectivity: default: sdncTopologyDeleteRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1" @@ -376,7 +356,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void prepareUpdateBeforeDeleteSDNCResource(DelegateExecution execution) { - logger.debug( " *** prepareUpdateBeforeDeleteSDNCResource *** ") + logger.debug(" *** prepareUpdateBeforeDeleteSDNCResource *** ") String resourceInput = execution.getVariable(Prefix + "resourceInput"); ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) String operType = resourceInputObj.getOperationType() @@ -412,7 +392,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { } public void prepareUpdateAfterDeleteSDNCResource(DelegateExecution execution) { - logger.debug( " *** prepareUpdateAfterDeleteSDNCResource *** ") + logger.debug(" *** prepareUpdateAfterDeleteSDNCResource *** ") String resourceInput = execution.getVariable(Prefix + "resourceInput"); ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) String operType = resourceInputObj.getOperationType() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy index 3a1815cfe6..79aa745792 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor; @@ -126,7 +127,7 @@ public class DeleteVfModuleInfra extends AbstractServiceTaskProcessor { } catch(Exception e) { String restFaultMessage = e.getMessage() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Caught exception", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Caught exception", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request") @@ -159,7 +160,7 @@ public class DeleteVfModuleInfra extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Caught exception in " + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) @@ -202,7 +203,7 @@ public class DeleteVfModuleInfra extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Caught exception in " + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) @@ -229,7 +230,7 @@ public class DeleteVfModuleInfra extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoDeleteVfModule(): ' + e.getMessage()) } @@ -277,7 +278,7 @@ public class DeleteVfModuleInfra extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepInfraRequest(): ' + e.getMessage()) @@ -322,7 +323,7 @@ public class DeleteVfModuleInfra extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') @@ -375,7 +376,7 @@ public class DeleteVfModuleInfra extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy index cf53aff878..9fa488f8a7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.VolumeGroup @@ -463,7 +464,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { logger.debug(xmlHandlerRequest) execution.setVariable("DELVfModVol_FalloutHandlerRequest", xmlHandlerRequest) - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Overall Error Response going to FalloutHandler", "BPMN", ErrorCode.UnknownError.getValue(), "\n" + xmlHandlerRequest); } @@ -484,7 +485,7 @@ public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { def String errorMessage = 'TenantId ' + tenantId + ' in incoming request does not match Tenant Id ' + volumeGroupTenantId + ' retrieved from AAI for Volume Group Id ' + volumeGroupId - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Error in DeleteVfModuleVolume: " + "\n" + errorMessage, "BPMN", ErrorCode.UnknownError.getValue()); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy index 7ad929b1c2..9f378e567c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy @@ -184,7 +184,7 @@ public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProce rmodel.setResourceCustomizationUuid(resourceCustomizationUuid) addedResourceList.add(rmodel) - Map<String, Object> resourceParameters = ResourceRequestBuilder.buildResouceRequest(serviceModelUuid, resourceCustomizationUuid, null) + Map<String, Object> resourceParameters = ResourceRequestBuilder.buildResouceRequest(rc, null, null) requestInputs.addAll(resourceParameters.keySet()) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index 125c3e4504..a5a92b6b06 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -22,6 +22,7 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode; import static org.apache.commons.lang3.StringUtils.*; @@ -443,7 +444,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { logger.debug("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preInitResourcesOperStatus.", "BPMN", ErrorCode.UnknownError.getValue(), e); execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) 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 b49f00a247..587337b647 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 @@ -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. @@ -22,7 +22,15 @@ package org.onap.so.bpmn.infrastructure.scripts + +import com.google.common.reflect.TypeToken +import com.google.gson.Gson +import org.apache.http.util.EntityUtils +import org.onap.so.bpmn.common.resource.InstanceResourceList import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.core.domain.GroupResource +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ResourceType import org.onap.so.bpmn.infrastructure.properties.BPMNProperties import org.apache.commons.lang3.StringUtils import org.apache.http.HttpResponse @@ -44,11 +52,12 @@ import org.onap.so.bpmn.common.resource.ResourceRequestBuilder import org.slf4j.Logger import org.slf4j.LoggerFactory +import java.lang.reflect.Type /** * This groovy class supports the <class>DoCreateResources.bpmn</class> process. - * + * * Inputs: * @param - msoRequestId * @param - globalSubscriberId - O @@ -56,7 +65,7 @@ import org.slf4j.LoggerFactory * @param - serviceInstanceId * @param - serviceInstanceName - O * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) - * @param - sdncVersion + * @param - sdncVersion * * @param - addResourceList * @@ -87,9 +96,19 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ logger.trace("Exit preProcessRequest ") } + // this method will convert resource list to instance_resource_list + public void prepareInstanceResourceList(DelegateExecution execution) { + + String uuiRequest = execution.getVariable("uuiRequest") + List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") + List<Resource> instanceResourceList = InstanceResourceList.getInstanceResourceList(sequencedResourceList, uuiRequest) + + execution.setVariable("instanceResourceList", instanceResourceList) + } + public void sequenceResoure(DelegateExecution execution) { logger.trace("Start sequenceResoure Process ") - + String incomingRequest = execution.getVariable("uuiRequest") String serviceModelUuid = jsonUtil.getJsonValue(incomingRequest,"service.serviceUuid") @@ -102,10 +121,10 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ String serviceDecompose = execution.getVariable("serviceDecomposition") String serviceModelName = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelName") - // get Sequence from properties + // get Sequence from properties def resourceSequence = BPMNProperties.getResourceSequenceProp(serviceModelName) - // get Sequence from csar(model) + // get Sequence from csar(model) if(resourceSequence == null) { resourceSequence = ResourceRequestBuilder.getResourceSequence(serviceModelUuid) logger.info("Get Sequence from csar : " + resourceSequence) @@ -117,6 +136,22 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { sequencedResourceList.add(resource) + // if resource type is vnfResource then check for groups also + // Did not use continue because if same model type is used twice + // 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.getGroupOrder() != null && !StringUtils.isEmpty(resource.getGroupOrder())) { + String[] grpSequence = resource.getGroupOrder().split(",") + for (String grpType in grpSequence) { + for (GroupResource gResource in resource.getGroups()) { + if (StringUtils.containsIgnoreCase(gResource.getModelInfo().getModelName(), grpType)) { + sequencedResourceList.add(gResource) + } + } + } + } + } if (resource instanceof NetworkResource) { networkResourceList.add(resource) } @@ -126,7 +161,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ } else { //define sequenced resource list, we deploy vf first and then network and then ar - //this is defaule sequence + //this is default sequence List<VnfResource> vnfResourceList = new ArrayList<VnfResource>() List<AllottedResource> arResourceList = new ArrayList<AllottedResource>() @@ -181,11 +216,11 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ public void getCurrentResoure(DelegateExecution execution){ logger.trace("Start getCurrentResoure Process ") def currentIndex = execution.getVariable("currentResourceIndex") - List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") - Resource currentResource = sequencedResourceList.get(currentIndex) + List<Resource> instanceResourceList = execution.getVariable("instanceResourceList") + Resource currentResource = instanceResourceList.get(currentIndex) execution.setVariable("resourceType", currentResource.getModelInfo().getModelName()) - logger.info("Now we deal with resouce:" + currentResource.getModelInfo().getModelName()) - logger.trace("COMPLETED getCurrentResoure Process ") + logger.info("Now we deal with resource:" + currentResource.getModelInfo().getModelName()) + logger.trace("COMPLETED getCurrentResource Process ") } public void parseNextResource(DelegateExecution execution){ @@ -193,8 +228,8 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ def currentIndex = execution.getVariable("currentResourceIndex") def nextIndex = currentIndex + 1 execution.setVariable("currentResourceIndex", nextIndex) - List<String> sequencedResourceList = execution.getVariable("sequencedResourceList") - if(nextIndex >= sequencedResourceList.size()){ + List<Resource> instanceResourceList = execution.getVariable("instanceResourceList") + if(nextIndex >= instanceResourceList.size()){ execution.setVariable("allResourceFinished", "true") }else{ execution.setVariable("allResourceFinished", "false") @@ -221,22 +256,43 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ resourceInput.setOperationId(operationId) resourceInput.setOperationType(operationType); def currentIndex = execution.getVariable("currentResourceIndex") - List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") + 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(); + + if (currentResource.getResourceType() == ResourceType.VNF) { + execution.setVariable("vfModelInfo", currentResource.getModelInfo()) + } + + resourceInput.setVfModelInfo(execution.getVariable("vfModelInfo") as ModelInfo) + String vnfId = execution.getVariable("vnf-id") + if (vnfId != null) { + resourceInput.setVnfId(vnfId) + } + + + 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 resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters) + //set the requestInputs from template To Be Done + String uuiServiceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters") + + // current vfdata holds information for preparing input for resource + // e.g. it will hold + // { top_level_list_name, second_level_list_name, top_index, second_index, last processed node} + Map<String, Object> currentVFData = (Map) execution.getVariable("currentVFData") + + if (null == currentVFData) { + currentVFData = new HashMap<>() + } + String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, currentResource, uuiServiceParameters, currentVFData) resourceInput.setResourceParameters(resourceParameters) resourceInput.setRequestsInputs(incomingRequest) execution.setVariable("resourceInput", resourceInput.toString()) execution.setVariable("resourceModelUUID", resourceInput.getResourceModelInfo().getModelUuid()) + execution.setVariable("currentVFData",currentVFData) logger.trace("COMPLETED prepareResourceRecipeRequest Process ") } @@ -262,6 +318,22 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ BpmnRestClient bpmnRestClient = new BpmnRestClient() HttpResponse resp = bpmnRestClient.post(recipeURL, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput, recipeParamXsd) + + def currentIndex = execution.getVariable("currentResourceIndex") + List<Resource> instanceResourceList = execution.getVariable("instanceResourceList") as List<Resource> + Resource currentResource = instanceResourceList.get(currentIndex) + if(ResourceType.VNF == currentResource.getResourceType()) { + if (resp.getStatusLine().getStatusCode() > 199 && resp.getStatusLine().getStatusCode() < 300) { + String responseString = EntityUtils.toString(resp.getEntity(), "UTF-8") + if (responseString != null) { + Gson gson = new Gson() + Type type = new TypeToken<Map<String, String>>() {}.getType() + Map<String, Object> map = gson.fromJson(responseString, type) + Map<String, String> map1 = gson.fromJson(map.get("response"), type) + execution.setVariable("vnf-id",map1.get("vnf-id")) + } + } + } } else { String exceptionMessage = "Resource receipe is not found for resource modeluuid: " + resourceModelUUID logger.trace(exceptionMessage) @@ -286,4 +358,4 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ } execution.setVariable("serviceDecomposition", serviceDecomposition) } -} +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy index 468f603ef6..eab99df9b2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.entities.uri.AAIResourceUri @@ -234,7 +235,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces getAAIClient().connect(nsUri,relatedServiceUri) logger.info("NS relationship to Service added successfully") }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception occured while executing AAI Put Call", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); throw new BpmnError("MSOWorkflowException") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy index ea9987e2ec..731c5b8dc5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory import org.onap.so.client.HttpClientFactory import org.onap.so.logger.ErrorCode @@ -568,7 +569,7 @@ public class DoCreateVfModule extends VfModuleBase { String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), msg); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) @@ -620,7 +621,7 @@ public class DoCreateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); @@ -747,7 +748,7 @@ public class DoCreateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) @@ -827,7 +828,7 @@ public class DoCreateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.SIX, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e, e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage()) @@ -863,7 +864,7 @@ public class DoCreateVfModule extends VfModuleBase { logger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage()) @@ -957,7 +958,7 @@ public class DoCreateVfModule extends VfModuleBase { logger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCGetRequest", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) @@ -1165,7 +1166,7 @@ public class DoCreateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message") @@ -1556,7 +1557,7 @@ public class DoCreateVfModule extends VfModuleBase { logger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessUpdateAAIVfModuleRequestOrch", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestOrch Method:\n" + e.getMessage()) @@ -1586,7 +1587,7 @@ public class DoCreateVfModule extends VfModuleBase { logger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessUpdateAAIVfModuleStatus", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleStatus Method:\n" + e.getMessage()) @@ -1616,7 +1617,7 @@ public class DoCreateVfModule extends VfModuleBase { logger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessUpdateAAIVfModuleRequestGroup", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestGroup Method:\n" + e.getMessage()) @@ -1696,7 +1697,7 @@ public class DoCreateVfModule extends VfModuleBase { logger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessSDNCGetRequest", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) @@ -1818,14 +1819,14 @@ public class DoCreateVfModule extends VfModuleBase { logger.debug(" is Cloud Region Good: " + execution.getVariable("DCVFM_isCloudRegionGood")) } catch(BpmnError b){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Rethrowing MSOWorkflowException", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + b.getMessage()); throw b }catch (Exception ex) { // try error String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + ex.getMessage() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "AAI Query Cloud Region Failed " + errorMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + ex); exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during queryCloudRegion method") @@ -1888,7 +1889,7 @@ public class DoCreateVfModule extends VfModuleBase { logger.debug("Outgoing CreateAAIVfModuleVolumeGroupRequest is: \n" + createAAIVfModuleVolumeGroupRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Exception Occured Processing prepareCreateAAIVfModuleVolumeGroupRequest', "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareCreateAAIVfModuleVolumeGroupRequest Method:\n" + e.getMessage()) @@ -2021,7 +2022,7 @@ public class DoCreateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Encountered in " + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); @@ -2066,7 +2067,7 @@ public class DoCreateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in postProcessUpdateAAIGenericVnf(): ' + e.getMessage()) @@ -2119,7 +2120,7 @@ public class DoCreateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in queryCatalogDB', "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryCatalogDB(): ' + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy index 65f6f76a21..4bab2b390d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy @@ -21,6 +21,8 @@ */ package org.onap.so.bpmn.infrastructure.scripts + +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.NetworkPolicies @@ -263,7 +265,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ logger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessSDNCDeactivateRequest.", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) @@ -448,7 +450,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ // - public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "AAI error occurred deleting the Generic Vnf" + execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), "BPMN", ErrorCode.UnknownError.getValue()); String processKey = getProcessKey(execution); @@ -609,7 +611,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessUpdateAAIGenericVnf((): ' + e.getMessage()) @@ -627,7 +629,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ execution.setVariable("rollbackError", null) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing setSuccessfulRollbackStatus.", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage()) @@ -647,7 +649,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ execution.setVariable("rollbackData", null) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing setFailedRollbackStatus.", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy index fb5c0fa0aa..e9b748b14b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.db.catalog.beans.HomingInstance import org.onap.so.logger.ErrorCode @@ -215,7 +216,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -406,7 +407,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { logger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessSDNCAssignRequest", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage()) @@ -624,7 +625,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { logger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCGetRequest. ", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) @@ -663,7 +664,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Caught exception in " + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy index 725a139b59..180032c8f0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.json.JSONObject; import org.json.JSONArray; import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -308,7 +309,7 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessAddOnModule ", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) @@ -326,7 +327,7 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { execution.setVariable("addOnModulesDeployed", addOnModulesDeployed + 1) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing postProcessAddOnModule ", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during postProcessAddOnModule Method:\n" + e.getMessage()) @@ -356,7 +357,7 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { } }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing validateBaseModule ", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during validateBaseModule Method:\n" + e.getMessage()) @@ -387,7 +388,7 @@ class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "${numOfCreatedAddOnModules}") execution.setVariable("rollbackData", rollbackData) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessAddOnModule ", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy index 7ea32d2a60..a6cb5cf4cc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; @@ -163,7 +164,7 @@ class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor { execution.setVariable("DCVAMR_RollbackData", vfModuleRollbackData) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessCreateVfModuleRollback ", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessCreateVfModuleRollback Method:\n" + e.getMessage()) @@ -183,14 +184,14 @@ class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor { def numOfModulesToDelete = execution.getVariable("DCVAMR_numOfModulesToDelete") execution.setVariable("DCVAMR_numOfModulesToDelete", numOfModulesToDelete - 1) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing postProcessCreateVfModuleRollback ", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during postProcessCreateVfModuleRollback Method:\n" + e.getMessage()) } if (rolledBack == false) { logger.debug("Failure on DoCreateVfModuleRollback") - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Unsuccessful rollback of DoCreateVfModule ", "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during rollback of DoCreateVfModule") @@ -216,7 +217,7 @@ class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor { logger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessSDNCDeactivateRequest ", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) @@ -339,7 +340,7 @@ class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor { execution.setVariable("rollbackError", null) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured " + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured " + "Processing setSuccessfulRollbackStatus ", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage()) } @@ -361,7 +362,7 @@ class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor { execution.setVariable("rollbackData", null) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured " + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured " + "Processing setFailedRollbackStatus. ", "BPMN",ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage()) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy index f1b7328bcc..cf3a0ef56f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy @@ -22,6 +22,7 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode import static org.apache.commons.lang3.StringUtils.*; @@ -532,7 +533,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess logger.debug("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preInitResourcesOperStatus.", "BPMN", ErrorCode.UnknownError.getValue(), e); execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy index 1912d65ce3..48e4fdf2ff 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy @@ -22,6 +22,7 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.aai.domain.yang.AllottedResource import org.onap.so.logger.ErrorCode @@ -944,7 +945,7 @@ public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProce }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preUpdateServiceOperationStatus.", "BPMN", ErrorCode.UnknownError.getValue(), e); execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy index e5b8d52376..e24597aab3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy @@ -21,9 +21,11 @@ */ package org.onap.so.bpmn.infrastructure.scripts + import groovy.json.JsonOutput import groovy.json.JsonSlurper import org.apache.commons.lang3.StringUtils +import org.apache.commons.lang3.tuple.ImmutablePair import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONArray @@ -36,9 +38,12 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.WorkflowException +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.ServiceDecomposition +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 @@ -51,14 +56,10 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.utils.TargetEntity import org.springframework.web.util.UriUtils -import org.w3c.dom.Document -import org.w3c.dom.Node -import org.xml.sax.InputSource import javax.ws.rs.NotFoundException import javax.ws.rs.core.Response -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory + import static org.apache.commons.lang3.StringUtils.isBlank @@ -171,23 +172,16 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { String msg = "" try { - String serviceInstanceId = execution.getVariable('serviceInstanceId') String globalSubscriberId = execution.getVariable('globalSubscriberId') String serviceType = execution.getVariable('serviceType') - - AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId) - if (!resourceClient.exists(serviceInstanceUri)) { exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service Instance was not found in aai") } - AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) - Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) - // found in AAI if (si.isPresent() && StringUtils.isNotEmpty(si.get().getServiceInstanceName())) { logger.debug("Found Service-instance in AAI") @@ -196,12 +190,10 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { // Get Template uuid and version if ((null != si.get().getModelInvariantId()) && (null != si.get().getModelVersionId())) { logger.debug("SI Data model-invariant-id and model-version-id exist") - // Set Original Template info execution.setVariable("model-invariant-id-original", si.get().getModelInvariantId()) execution.setVariable("model-version-id-original", si.get().getModelVersionId()) } - if ((null != si.get().getRelationshipList()) && (null != si.get().getRelationshipList().getRelationship())) { logger.debug("SI Data relationship-list exists") List<Relationship> relationshipList = si.get().getRelationshipList().getRelationship() @@ -210,12 +202,9 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { def jObj = getRelationShipData(relationship) jArray.put(jObj) } - execution.setVariable("serviceRelationShip", jArray.toString()) } - } else { - msg = "Service-instance: " + serviceInstanceId + " NOT found in AAI." logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) @@ -235,18 +224,13 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { private JSONObject getRelationShipData(Relationship relationship) { JSONObject jObj = new JSONObject() - - def rt = relationship.getRelatedTo() - def rl = relationship.getRelatedLink() logger.debug("ServiceInstance Related NS/Configuration :" + rl) - List<RelationshipData> rl_datas = relationship.getRelationshipData() for (RelationshipData rl_data : rl_datas) { def eKey = rl_data.getRelationshipKey() def eValue = rl_data.getRelationshipValue() - if ((rt.equals("service-instance") && eKey.equals("service-instance.service-instance-id")) //for overlay/underlay || (rt.equals("configuration") && eKey.equals("configuration.configuration-id") @@ -259,10 +243,8 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { String resourceName = rt + eValue; jObj.put("resourceType", resourceName) } - jObj.put("resourceLinkUrl", rl) } - List<RelatedToProperty> rl_props = relationship.getRelatedToProperty() for (RelatedToProperty rl_prop : rl_props) { def eKey = rl_prop.getPropertyKey() @@ -273,11 +255,66 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { jObj.put("resourceType", eValue) } } - logger.debug("Relationship related to Resource:" + jObj.toString()) return jObj } + private Relationship getRelationShipFromNode(groovy.util.slurpersupport.Node relationshipNode) { + Relationship relationship = new Relationship() + def rtn = relationshipNode.childNodes() + List<RelationshipData> relationshipDatas = new ArrayList<>() + List<RelatedToProperty> relationshipProperties = new ArrayList<>() + while (rtn.hasNext()) { + groovy.util.slurpersupport.Node node = rtn.next() + def key = node.name() + + if(key.equals("related-to")){ + def rt = node.text() + relationship.setRelatedTo(rt) + } else if (key.equals("related-link")){ + def rl = node.text() + relationship.setRelatedLink(rl) + } else if (key.equals("relationship-label")){ + def label = node.text() + relationship.setRelationshipLabel(label) + } else if (key.equals("relationship-data")){ + def rData = node.childNodes() + RelationshipData relationshipData = new RelationshipData() + while(rData.hasNext()){ + groovy.util.slurpersupport.Node datanode = rData.next() + def dataKey = datanode.name() + if(dataKey.equals("relationship-key")) { + relationshipData.setRelationshipKey(datanode.text()) + } else if(dataKey.equals("relationship-value")) { + relationshipData.setRelationshipValue(datanode.text()) + } + } + relationshipDatas.add(relationshipData) + } else if (key.equals("related-to-property")){ + def rProperty = node.childNodes() + RelatedToProperty relationshipProperty = new RelatedToProperty() + while(rProperty.hasNext()){ + groovy.util.slurpersupport.Node propnode = rProperty.next() + + def dataKey = propnode.name() + if(dataKey.equals("property-key")) { + relationshipProperty.setPropertyKey(propnode.text()) + } else if(dataKey.equals("property-value")) { + relationshipProperty.setPropertyValue(propnode.text()) + } + + } + relationshipProperties.add(relationshipProperty) + } + + } + relationship.getRelationshipData().addAll(relationshipDatas) + relationship.getRelatedToProperty().addAll(relationshipProperties) + + logger.debug("Relationship related to Resource:" + relationship.toString()) + return relationship + } + public void getCurrentNS(DelegateExecution execution){ logger.info( "======== Start getCurrentNS Process ======== ") @@ -315,19 +352,31 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { } } - private void generateRelatedResourceInfo(String response, JSONObject jObj){ + private void generateRelatedResourceInfo(String response, JSONObject jObj, boolean processRelationship){ def xml = new XmlSlurper().parseText(response) def rtn = xml.childNodes() while (rtn.hasNext()) { groovy.util.slurpersupport.Node node = rtn.next() def key = node.name() - def value = node.text() - jObj.put(key, value) + if (key.equals("relationship-list") && processRelationship) { + def relns = node.childNodes() + JSONArray jArray = new JSONArray() + while (relns.hasNext()) { + groovy.util.slurpersupport.Node relNode = relns.next() + Relationship relationship = getRelationShipFromNode(relNode) + def relationObj = getRelationShipData(relationship) + jArray.put(relationObj) + } + jObj.put(key, jArray) + } else { + def value = node.text() + jObj.put(key, value) + } } } - private JSONObject getRelatedResourceInAAI (DelegateExecution execution, JSONObject jObj) + private JSONObject getRelatedResourceInAAI (DelegateExecution execution, JSONObject jObj, boolean processRelationship) { logger.debug(" ***** Started getRelatedResourceInAAI *****") @@ -355,7 +404,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "SuccessIndicator", true) execution.setVariable(Prefix + "FoundIndicator", true) - generateRelatedResourceInfo(aaiResponse, jObj) + generateRelatedResourceInfo(aaiResponse, jObj, processRelationship) //get model-invariant-uuid and model-uuid String modelInvariantId = "" @@ -399,7 +448,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { relationShipList = jsonSlurper.parseText(serviceRelationShip) } - List<Resource> deleteRealResourceList = new ArrayList<Resource>() + List<ImmutablePair<Resource, List<Resource>>> deleteRealResourceList = new ArrayList<ImmutablePair<Resource, List<Resource>>>() //Set the real resource instance id to the decomosed resource list //reset the resource instance id , because in the decompose flow ,its a random one. @@ -407,21 +456,27 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { if (relationShipList != null) { relationShipList.each { - JSONObject obj = getRelatedResourceInAAI(execution, (JSONObject)it) + JSONObject obj = getRelatedResourceInAAI(execution, (JSONObject)it, true) for (Resource resource : deleteResourceList) { - String modelName = resource.getModelInfo().getModelName() - - String modelCustomizationUuid = resource.getModelInfo().getModelCustomizationUuid() - if (StringUtils.containsIgnoreCase(obj.get("resourceType"), modelName)) { - resource.setResourceId(obj.get("resourceInstanceId")) - deleteRealResourceList.add(resource) - } - else if (modelCustomizationUuid.equals(obj.get("modelCustomizationId"))) { - resource.setResourceId(obj.get("resourceInstanceId")) - resource.setResourceInstanceName(obj.get("resourceType")) - deleteRealResourceList.add(resource) + boolean matches = processMatchingResource(resource, obj) + if((matches) && resource.getResourceType().equals(ResourceType.VNF)) { + List<Resource> delGroupList = new ArrayList<Resource>() + JSONArray vfRelationship = obj.getJSONArray("relationship-list") + for (int idx = 0; idx < vfRelationship.length(); idx++) { + JSONObject vfItem = vfRelationship.getJSONObject(idx) + JSONObject groupObject = getRelatedResourceInAAI(execution, vfItem, false) + List<GroupResource> groups = ((VnfResource)resource).getGroups() + for (GroupResource group : groups){ + if(processMatchingResource(group, groupObject)){ + delGroupList.add(group) + } + } + } + def delMap = new ImmutablePair(resource, delGroupList) + + deleteRealResourceList.add(delMap) } } } @@ -429,7 +484,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { // only delete real existing resources execution.setVariable("deleteResourceList", deleteRealResourceList) - + boolean isDeleteResourceListValid = false if(deleteRealResourceList.size() > 0) { isDeleteResourceListValid = true @@ -442,7 +497,25 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { logger.error(exceptionMessage) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } - logger.debug( " ***** exit postDecomposeService() of delete generic e2e service flow ***** ") + logger.debug(" ***** exit postDecomposeService() of delete generic e2e service flow ***** ") + } + + private boolean processMatchingResource(Resource resource, JSONObject obj) { + boolean matches = false + String modelName = resource.getModelInfo().getModelName() + + String modelCustomizationUuid = resource.getModelInfo().getModelCustomizationUuid() + if (StringUtils.containsIgnoreCase(obj.get("resourceType"), modelName)) { + resource.setResourceId(obj.get("resourceInstanceId")) + //deleteRealResourceList.add(resource) + matches = true; + } else if (modelCustomizationUuid.equals(obj.get("modelCustomizationId"))) { + resource.setResourceId(obj.get("resourceInstanceId")) + resource.setResourceInstanceName(obj.get("resourceType")) + //deleteRealResourceList.add(resource) + matches = true; + } + return matches } public void preInitResourcesOperStatus(DelegateExecution execution){ @@ -461,11 +534,12 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("serviceInstanceId", serviceId) execution.setVariable("operationId", operationId) execution.setVariable("operationType", operationType) - List<Resource> deleteResourceList = execution.getVariable("deleteResourceList") + List<ImmutablePair<Resource, List<Resource>>> deleteResourceList = execution.getVariable("deleteResourceList") String serviceRelationShip = execution.getVariable("serviceRelationShip") - for(Resource resource : deleteResourceList){ - resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":" + for (ImmutablePair rc : deleteResourceList) { + Resource resource = rc.getKey() + resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":" } def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution) @@ -496,7 +570,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { } logger.debug("======== COMPLETED preInitResourcesOperStatus Process ======== ") } - + public void prepareUpdateServiceOperationStatus(DelegateExecution execution){ logger.debug(" ======== STARTED prepareUpdateServiceOperationStatus Process ======== ") try{ @@ -507,7 +581,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { String progress = execution.getVariable("progress") String reason = "" String operationContent = execution.getVariable("operationContent") - + serviceId = UriUtils.encode(serviceId,"UTF-8") def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution) @@ -550,5 +624,4 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { //to do } - } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 2558f7eff5..21f9484cbc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.L3Network @@ -465,7 +466,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } catch (Exception ex) { // caught exception String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, sendRequestToVnfAdapter() - " + ex.getMessage() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + ex); logger.debug(exceptionMessage) @@ -517,7 +518,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } catch (Exception ex) { // caught exception String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + ex); logger.debug(exceptionMessage) @@ -558,7 +559,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } catch (Exception ex) { // caught exception String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + ex); logger.debug(exceptionMessage) @@ -998,7 +999,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { } catch (Exception ex) { // caught exception String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRollback() - " + ex.getMessage() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), exceptionMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + ex); logger.debug(exceptionMessage) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy index 0d096f3b16..2dcfcaa4f4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy @@ -22,7 +22,12 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import org.apache.commons.lang3.tuple.ImmutablePair +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory +import org.onap.so.bpmn.core.domain.GroupResource +import org.onap.so.bpmn.core.domain.ModelInfo +import org.onap.so.bpmn.core.domain.ResourceType import static org.apache.commons.lang3.StringUtils.isBlank @@ -151,17 +156,61 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor { List<Resource> wanResources = new ArrayList<Resource>() // get delete resource list and order list - List<Resource> delResourceList = execution.getVariable("deleteResourceList") + List<ImmutablePair<Resource, List<Resource>>> delResourceList = execution.getVariable("deleteResourceList") ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") String serviceModelName = serviceDecomposition.getModelInfo().getModelName(); - + String serviceModelUuid = serviceDecomposition.getModelInfo().getModelUuid(); + + Map<String, Map<String, Object>> parentVNF = new HashMap<>() + + // get Sequence from properties def resourceSequence = BPMNProperties.getResourceSequenceProp(serviceModelName) + // get Sequence from catalog db csar(model) + if(resourceSequence == null) { + resourceSequence = ResourceRequestBuilder.getResourceSequence(serviceModelUuid) + logger.info("Get Sequence from catalog db csar : " + resourceSequence) + } + if(resourceSequence != null) { for (resourceType in resourceSequence.reverse()) { - for (resource in delResourceList) { + + boolean vfFound = false + + for (ImmutablePair resourceTuple : delResourceList) { + Resource resource = resourceTuple.getKey() + List<Resource> groupResources = resourceTuple.getValue() + if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { + + + + // if resource type is vnfResource then check for groups also + // Did not use continue because if same model type is used twice + // then we would like to add it twice for processing + // e.g. S{ V1{G1, G2, G1}} --> S{ {G2, G1, G1}V1} + // we will add in reverse order for deletion + if (resource instanceof VnfResource) { + if (resource.getGroupOrder() != null && !StringUtils.isEmpty(resource.getGroupOrder())) { + String[] grpSequence = resource.getGroupOrder().split(",") + + Map<String, Object> parentVNFData = new HashMap<>() + parentVNFData.put("vfModelInfo", resource.getModelInfo()) + parentVNFData.put("vnf-id", resource.getResourceId()) + + for (String grpType in grpSequence.reverse()) { + for (GroupResource gResource in groupResources) { + if (StringUtils.containsIgnoreCase(gResource.getModelInfo().getModelName(), grpType)) { + sequencedResourceList.add(gResource) + // Store parent VNF info for the group resource id + parentVNF.put(gResource.getResourceId(), parentVNFData) + } + } + } + } + } + sequencedResourceList.add(resource) if (resource instanceof NetworkResource) { @@ -173,11 +222,32 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor { }else { //define sequenced resource list, we deploy vf first and then network and then ar //this is defaule sequence + // While deleting we will delete in resource order group resource, ar, network, then VF. List<VnfResource> vnfResourceList = new ArrayList<VnfResource>() List<AllottedResource> arResourceList = new ArrayList<AllottedResource>() - for (Resource rc : delResourceList) { + for (ImmutablePair resourceTuple : delResourceList) { + Resource rc = resourceTuple.getKey() + List<Resource> groupResources = resourceTuple.getValue() + if (rc instanceof VnfResource) { vnfResourceList.add(rc) + if (rc.getGroupOrder() != null && !StringUtils.isEmpty(rc.getGroupOrder())) { + String[] grpSequence = rc.getGroupOrder().split(",") + + Map<String, Object> parentVNFData = new HashMap<>() + parentVNFData.put("vfModelInfo", rc.getModelInfo()) + parentVNFData.put("vnf-id", rc.getResourceId()) + + for (String grpType in grpSequence.reverse()) { + for (GroupResource gResource in groupResources) { + if (StringUtils.containsIgnoreCase(gResource.getModelInfo().getModelName(), grpType)) { + sequencedResourceList.add(gResource) + // Store parent VNF info for the group resource id + parentVNF.put(gResource.getResourceId(), parentVNFData) + } + } + } + } } else if (rc instanceof NetworkResource) { wanResources.add(rc) } else if (rc instanceof AllottedResource) { @@ -199,6 +269,7 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor { execution.setVariable("isContainsWanResource", isContainsWanResource) execution.setVariable("currentResourceIndex", 0) execution.setVariable("sequencedResourceList", sequencedResourceList) + execution.setVariable("parentVNF", parentVNF) logger.debug("resourceSequence: " + resourceSequence) logger.debug(" ======== END sequenceResource Process ======== ") } @@ -235,46 +306,58 @@ public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor { */ public void executeResourceDelete(DelegateExecution execution) { logger.debug("======== Start executeResourceDelete Process ======== ") - try { - String requestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String serviceType = execution.getVariable("serviceType") - - String resourceInstanceId = execution.getVariable("resourceInstanceId") - - Resource currentResource = execution.getVariable("currentResource") - String action = "deleteInstance" - JSONObject resourceRecipe = catalogDbUtils.getResourceRecipe(execution, currentResource.getModelInfo().getModelUuid(), action) - String recipeUri = resourceRecipe.getString("orchestrationUri") - int recipeTimeout = resourceRecipe.getInt("recipeTimeout") - String recipeParamXsd = resourceRecipe.get("paramXSD") - - - ResourceInput resourceInput = new ResourceInput(); - resourceInput.setServiceInstanceId(serviceInstanceId) - resourceInput.setResourceInstanceName(currentResource.getResourceInstanceName()) - resourceInput.setResourceInstancenUuid(currentResource.getResourceId()) - resourceInput.setOperationId(execution.getVariable("operationId")) - resourceInput.setOperationType(execution.getVariable("operationType")) - String globalSubscriberId = execution.getVariable("globalSubscriberId") - resourceInput.setGlobalSubscriberId(globalSubscriberId) - resourceInput.setResourceModelInfo(currentResource.getModelInfo()); - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()); - resourceInput.setServiceType(serviceType) - - String recipeURL = BPMNProperties.getProperty("bpelURL", "http://so-bpmn-infra.onap:8081") + recipeUri + try { + String requestId = execution.getVariable("msoRequestId") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceType = execution.getVariable("serviceType") + + String resourceInstanceId = execution.getVariable("resourceInstanceId") + + Resource currentResource = execution.getVariable("currentResource") + String action = "deleteInstance" + JSONObject resourceRecipe = catalogDbUtils.getResourceRecipe(execution, currentResource.getModelInfo().getModelUuid(), action) + String recipeUri = resourceRecipe.getString("orchestrationUri") + int recipeTimeout = resourceRecipe.getInt("recipeTimeout") + String recipeParamXsd = resourceRecipe.get("paramXSD") + + + ResourceInput resourceInput = new ResourceInput(); + resourceInput.setServiceInstanceId(serviceInstanceId) + resourceInput.setResourceInstanceName(currentResource.getResourceInstanceName()) + resourceInput.setResourceInstancenUuid(currentResource.getResourceId()) + resourceInput.setOperationId(execution.getVariable("operationId")) + resourceInput.setOperationType(execution.getVariable("operationType")) + String globalSubscriberId = execution.getVariable("globalSubscriberId") + resourceInput.setGlobalSubscriberId(globalSubscriberId) + resourceInput.setResourceModelInfo(currentResource.getModelInfo()); + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()); + resourceInput.setServiceType(serviceType) + resourceInput.getResourceModelInfo().setModelType(currentResource.getResourceType().toString()) + if (currentResource.getResourceType() == ResourceType.GROUP) { + Map<String, Map<String, Object>> parentVNF = execution.getVariable("parentVNF") + if((null != parentVNF) && (null!=parentVNF.get(currentResource.getResourceId()))){ + Map<String, Object> parentVNFData = parentVNF.get(currentResource.getResourceId()) + ModelInfo parentVNFModel = parentVNFData.get("vfModelInfo") + String parentResourceId = parentVNFData.get("vnf-id") + resourceInput.setVfModelInfo(parentVNFModel) + resourceInput.setVnfId(parentResourceId) + } + } + + String recipeURL = BPMNProperties.getProperty("bpelURL", "http://so-bpmn-infra.onap:8081") + recipeUri BpmnRestClient bpmnRestClient = new BpmnRestClient() - HttpResponse resp = bpmnRestClient.post(recipeURL, requestId, recipeTimeout, action, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd) - logger.debug(" ======== END executeResourceDelete Process ======== ") - }catch(BpmnError b){ - logger.error("Rethrowing MSOWorkflowException") - throw b - }catch(Exception e){ - logger.error("Error occured within DoDeleteResourcesV1 executeResourceDelete method: " + e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured during DoDeleteResourcesV1 executeResourceDelete Catalog") - } + + HttpResponse resp = bpmnRestClient.post(recipeURL, requestId, recipeTimeout, action, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd) + logger.debug(" ======== END executeResourceDelete Process ======== ") + } catch (BpmnError b) { + logger.error("Rethrowing MSOWorkflowException") + throw b + } catch (Exception e) { + logger.error("Error occured within DoDeleteResourcesV1 executeResourceDelete method: " + e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured during DoDeleteResourcesV1 executeResourceDelete Catalog") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy index b21dcf3433..4c8247a309 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.aai.domain.yang.NetworkPolicies import org.onap.aai.domain.yang.NetworkPolicy import org.onap.so.logger.ErrorCode @@ -359,7 +360,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ // generates a WorkflowException if // - public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "AAI error occurred deleting the Generic Vnf: " + execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), "BPMN", ErrorCode.UnknownError.getValue(), "Exception"); String processKey = getProcessKey(execution); @@ -580,7 +581,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) @@ -628,7 +629,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy index e5306c40de..eba43632a7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.NetworkPolicies import org.onap.aai.domain.yang.NetworkPolicy @@ -114,7 +115,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), "Exception"); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -160,7 +161,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVfModule(): ' + e.getMessage()) @@ -213,7 +214,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in validateVfModule(): ' + e.getMessage()) @@ -239,7 +240,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) @@ -403,7 +404,7 @@ public class DoDeleteVfModuleFromVnf extends VfModuleBase { // generates a WorkflowException if // - public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "AAI error occurred deleting the Generic Vnf: " + execution.getVariable("DDVFMV_deleteGenericVnfResponse"), "BPMN", ErrorCode.UnknownError.getValue(), "Exception"); String processKey = getProcessKey(execution); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy index 9bd3388b79..20d250d89f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.VfModule import org.camunda.bpm.engine.delegate.BpmnError @@ -110,7 +111,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback", execution) if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), "Exception"); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -238,7 +239,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessAddOnModule." + e, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) @@ -338,7 +339,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) @@ -366,7 +367,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { execution.setVariable("DDVAM_vfModuleModelInfo", vfModuleModelInfo) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessAddOnModule." + e, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToDelete Method:\n" + e.getMessage()) @@ -392,7 +393,7 @@ class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { logger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessSDNCDeactivateRequest." + e, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy index ce3b243533..231fe6e252 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy @@ -21,6 +21,7 @@ */ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode import static org.apache.commons.lang3.StringUtils.*; @@ -138,7 +139,7 @@ public class DoScaleE2EServiceInstance extends AbstractServiceTaskProcessor { logger.debug("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preInitResourcesOperStatus.", "BPMN", ErrorCode.UnknownError.getValue(), e); execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy index 1b089d2a2b..2a8cc08cdf 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONArray import org.json.JSONObject; @@ -182,7 +183,7 @@ public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcess try { Thread.sleep(5000) } catch (InterruptedException e) { - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Time Delay exception" + e, "BPMN", ErrorCode.UnknownError.getValue()); } @@ -216,7 +217,7 @@ public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcess logger.info("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class)) logger.trace("Completed Execute VF-C adapter Post Process ") }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception occured " + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception occured " + "while executing VFC Post Call.", "BPMN", ErrorCode.UnknownError.getValue(), e); throw new BpmnError("MSOWorkflowException") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy index abbcf66323..f7852431e5 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.GenericVnf @@ -333,7 +334,7 @@ public class DoUpdateVfModule extends VfModuleBase { def sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution) if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing' - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -342,7 +343,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) @@ -383,7 +384,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage()) @@ -434,14 +435,14 @@ public class DoUpdateVfModule extends VfModuleBase { logger.debug(" is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood")) } catch(BpmnError b){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Rethrowing MSOWorkflowException", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + b); throw b }catch (Exception e) { // try error String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage()) @@ -548,7 +549,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage()) @@ -612,7 +613,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage()) @@ -716,7 +717,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage()) @@ -764,7 +765,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) @@ -838,7 +839,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage()) @@ -941,7 +942,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage()) @@ -962,7 +963,7 @@ public class DoUpdateVfModule extends VfModuleBase { try { def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException') - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), method + ' caught WorkflowException: ' + workflowException.getErrorMessage(), "BPMN", ErrorCode.UnknownError.getValue()); @@ -970,7 +971,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage()) @@ -1048,7 +1049,7 @@ public class DoUpdateVfModule extends VfModuleBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e, e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy index eb788a85b7..75ac6900fa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.client.HttpClientFactory import org.onap.so.logger.ErrorCode @@ -272,7 +273,7 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) @@ -328,7 +329,7 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor { } }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToUpdate Method:\n" + e.getMessage()) @@ -404,7 +405,7 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy index 4321dbadd5..e36f32578d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.appc.client.lcm.model.Action; @@ -233,7 +234,7 @@ public class ReplaceVnfInfra extends VnfCmBase { } catch(Exception e) { String restFaultMessage = e.getMessage() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Encountered - " + "\n" + restFaultMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) @@ -276,7 +277,7 @@ public class ReplaceVnfInfra extends VnfCmBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) @@ -327,7 +328,7 @@ public class ReplaceVnfInfra extends VnfCmBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getVnfResourceDecomposition(): ' + e.getMessage()) @@ -369,7 +370,7 @@ public class ReplaceVnfInfra extends VnfCmBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") @@ -413,7 +414,7 @@ public class ReplaceVnfInfra extends VnfCmBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") @@ -461,7 +462,7 @@ public class ReplaceVnfInfra extends VnfCmBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") @@ -531,19 +532,19 @@ public class ReplaceVnfInfra extends VnfCmBase { logger.trace('Exited ' + method) } catch (BpmnError e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") execution.setVariable("errorText", e.getMessage()) } catch (java.lang.NoSuchMethodError e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") execution.setVariable("errorText", e.getMessage()) } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy index ef4a78ffde..ed65616d89 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.camunda.bpm.engine.delegate.DelegateExecution @@ -87,7 +88,7 @@ public class RollbackVnf extends VnfCmBase { } catch(Exception e) { String restFaultMessage = e.getMessage() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Encountered - " + "\n" + restFaultMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("rollbackErrorCode", "1") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy index 0afa34bdec..b21efdd563 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode import static org.apache.commons.lang3.StringUtils.* @@ -294,7 +295,7 @@ public class ScaleCustomE2EServiceInstance extends AbstractServiceTaskProcessor logger.debug("Scale network service updateServiceOperStatusRequest Request: " + payload) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN", ErrorCode.UnknownError.getValue(), e); execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy index 9db5b7366a..6946eebc56 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModule.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -96,7 +97,7 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) @@ -151,7 +152,7 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendSynchResponse(): ' + e.getMessage()) @@ -181,7 +182,7 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoUpdateVfModule(): ' + e.getMessage()) @@ -237,7 +238,7 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateInfraRequest(): ' + e.getMessage()) @@ -278,7 +279,7 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') @@ -333,7 +334,7 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy index 0344206145..7f2bbebc8d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import groovy.json.JsonException import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError @@ -482,7 +483,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion ExceptionUtil exceptionUtil = new ExceptionUtil() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Error in ' + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Error in ' + 'UpdateVfModuleVol: ' + errorMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception") exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) } @@ -501,7 +502,7 @@ class UpdateVfModuleVolumeInfraV1 extends VfModuleBase { " retrieved from AAI for Volume Group Id " ExceptionUtil exceptionUtil = new ExceptionUtil() - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Error in ' + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Error in ' + 'UpdateVfModuleVol: ' + errorMessage, "BPMN", ErrorCode.UnknownError.getValue(), "Exception") exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy index 05aff713bc..3cb40115ba 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.so.logger.LoggingAnchor import groovy.json.JsonOutput import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError @@ -351,7 +352,7 @@ public class VnfInPlaceUpdate extends VnfCmBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + ' ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") execution.setVariable("errorText", e.getMessage()) @@ -396,7 +397,7 @@ public class VnfInPlaceUpdate extends VnfCmBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + ' ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") execution.setVariable("errorText", e.getMessage()) @@ -441,7 +442,7 @@ public class VnfInPlaceUpdate extends VnfCmBase { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + ' ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") execution.setVariable("errorText", e.getMessage()) @@ -520,17 +521,17 @@ public class VnfInPlaceUpdate extends VnfCmBase { logger.trace('Exited ' + method) } catch (BpmnError e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + ' ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") execution.setVariable("errorText", e.getMessage()) } catch (java.lang.NoSuchMethodError e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + ' ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") execution.setVariable("errorText", e.getMessage()) } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + ' ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable("errorCode", "1002") execution.setVariable("errorText", e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index 9829419128..d57011f61f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -21,6 +21,7 @@ */ package org.onap.so.bpmn.vcpe.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode; import static org.apache.commons.lang3.StringUtils.* @@ -420,7 +421,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } catch (BpmnError e) { throw e; } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) @@ -847,7 +848,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { // Adding this line temporarily until this flows error handling gets updated exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") } catch (BpmnError b) { - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Rethrowing MSOWorkflowException", "BPMN", ErrorCode.UnknownError.getValue()); throw b diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy index a1cdacaf08..553ec2397c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -21,6 +21,7 @@ */ package org.onap.so.bpmn.vcpe.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -419,7 +420,7 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { execution.setVariable(Prefix+"unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") }catch(BpmnError b){ - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Rethrowing MSOWorkflowException", "BPMN", ErrorCode.UnknownError.getValue()); throw b diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy index 2c5b6430e6..0681e54bba 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.vcpe.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.AllottedResource @@ -585,7 +586,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ execution.setVariable("sdncGetRequest", SDNCGetRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy index 58c0ef2dcf..f24bb46981 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.vcpe.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.AllottedResource @@ -205,7 +206,7 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc } catch (BpmnError e) { throw e; }catch(Exception ex){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + ex); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy index 61dd13b4e2..51d04dd092 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.vcpe.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.AllottedResource @@ -520,7 +521,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ execution.setVariable("sdncGetRequest", SDNCGetRequest) }catch(Exception e){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy index 44e27d99cf..1427730187 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.vcpe.scripts +import org.onap.so.logger.LoggingAnchor import org.onap.aai.domain.yang.AllottedResource; import org.onap.so.bpmn.common.scripts.*; import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -206,7 +207,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc } catch (BpmnError e) { throw e; }catch(Exception ex){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + ex); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy index 9dcee3dfb2..29ee1a648e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.vcpe.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AllottedResourceUtils @@ -351,7 +352,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ } catch (BpmnError e) { throw e; }catch(Exception ex){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCGetRequest." + ex, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:" + ex); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy index 43e095859e..404f19eca9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.vcpe.scripts +import org.onap.so.logger.LoggingAnchor import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AllottedResourceUtils @@ -355,7 +356,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ } catch (BpmnError e) { throw e; }catch(Exception ex){ - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + ex); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java index 94ceddae97..2ababac7e3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClient.java @@ -24,11 +24,17 @@ import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.camunda.bpm.engine.runtime.Execution; +import org.onap.aai.domain.yang.v13.Metadatum; +import org.onap.so.bpmn.common.recipe.ResourceInput; +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder; +import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.HashMap; +import java.util.Optional; @Component public class InformDmaapClient implements JavaDelegate { @@ -41,8 +47,25 @@ public class InformDmaapClient implements JavaDelegate { String pnfCorrelationId = (String) execution.getVariable(ExecutionVariableNames.PNF_CORRELATION_ID); RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); String processBusinessKey = execution.getProcessBusinessKey(); - dmaapClient.registerForUpdate(pnfCorrelationId, () -> runtimeService.createMessageCorrelation("WorkflowMessage") - .processInstanceBusinessKey(processBusinessKey).correlateWithResult()); + HashMap<String, String> updateInfo = createUpdateInfo(execution); + updateInfo.put("pnfCorrelationId", pnfCorrelationId); + dmaapClient + .registerForUpdate(pnfCorrelationId, + () -> runtimeService.createMessageCorrelation("WorkflowMessage") + .processInstanceBusinessKey(processBusinessKey).correlateWithResult(), + Optional.of(updateInfo)); + } + + private HashMap<String, String> createUpdateInfo(DelegateExecution execution) { + HashMap<String, String> map = new HashMap(); + + ResourceInput resourceInputObj = ResourceRequestBuilder + + .getJsonObject((String) execution.getVariable("resourceInput"), ResourceInput.class); + map.put("globalSubscriberID", resourceInputObj.getGlobalSubscriberId()); + map.put("serviceType", resourceInputObj.getServiceType()); + map.put("serviceInstanceId", resourceInputObj.getServiceInstanceId()); + return map; } @Autowired diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java index fbf86cc411..d513684659 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/DmaapClient.java @@ -20,9 +20,13 @@ package org.onap.so.bpmn.infrastructure.pnf.dmaap; +import java.util.HashMap; +import java.util.Optional; + public interface DmaapClient { - void registerForUpdate(String pnfCorrelationId, Runnable informConsumer); + void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, + Optional<HashMap<String, String>> updateInfo); Runnable unregister(String pnfCorrelationId); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java index 7cb78a10e5..8010ce62ab 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationId.java @@ -5,6 +5,7 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2018 Nokia. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,15 +36,18 @@ public final class JsonUtilForPnfCorrelationId { private static final String JSON_PNF_CORRELATION_ID_FIELD_NAME = "correlationId"; + private JsonUtilForPnfCorrelationId() { + throw new IllegalStateException("Utility class"); + } + static List<String> parseJsonToGelAllPnfCorrelationId(String json) { JsonElement je = new JsonParser().parse(json); JsonArray array = je.getAsJsonArray(); List<String> list = new ArrayList<>(); Spliterator<JsonElement> spliterator = array.spliterator(); - spliterator.forEachRemaining(jsonElement -> { - handleEscapedCharacters(jsonElement).ifPresent(jsonObject -> getPnfCorrelationId(jsonObject) - .ifPresent(pnfCorrelationId -> list.add(pnfCorrelationId))); - }); + spliterator.forEachRemaining(jsonElement -> handleEscapedCharacters(jsonElement) + .ifPresent(jsonObject -> getPnfCorrelationId(jsonObject) + .ifPresent(pnfCorrelationId -> list.add(pnfCorrelationId)))); return list; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java index 96562fe90f..357b571a5c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java @@ -23,9 +23,7 @@ package org.onap.so.bpmn.infrastructure.pnf.dmaap; import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -40,6 +38,10 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.AAIObjectType; @Component public class PnfEventReadyDmaapClient implements DmaapClient { @@ -53,6 +55,8 @@ public class PnfEventReadyDmaapClient implements DmaapClient { private volatile ScheduledThreadPoolExecutor executor; private volatile boolean dmaapThreadListenerIsRunning; + public volatile List<HashMap<String, String>> updateInfoMap; + @Autowired public PnfEventReadyDmaapClient(Environment env) { httpClient = HttpClientBuilder.create().build(); @@ -64,11 +68,19 @@ public class PnfEventReadyDmaapClient implements DmaapClient { .port(env.getProperty("pnf.dmaap.port", Integer.class)).path(env.getProperty("pnf.dmaap.topicName")) .path(env.getProperty("pnf.dmaap.consumerGroup")).path(env.getProperty("pnf.dmaap.consumerId")) .build()); + updateInfoMap = new ArrayList<>(); } @Override - public synchronized void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) { + public synchronized void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, + Optional<HashMap<String, String>> updateInfo) { logger.debug("registering for pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId); + HashMap<String, String> map = updateInfo.get(); + if (map != null && map.size() > 0) { + synchronized (updateInfoMap) { + updateInfoMap.add(map); + } + } pnfCorrelationIdToThreadMap.put(pnfCorrelationId, informConsumer); if (!dmaapThreadListenerIsRunning) { startDmaapThreadListener(); @@ -78,7 +90,17 @@ public class PnfEventReadyDmaapClient implements DmaapClient { @Override public synchronized Runnable unregister(String pnfCorrelationId) { logger.debug("unregistering from pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId); - Runnable runnable = pnfCorrelationIdToThreadMap.remove(pnfCorrelationId); + Runnable runnable = runnable = pnfCorrelationIdToThreadMap.remove(pnfCorrelationId); + synchronized (updateInfoMap) { + for (int i = updateInfoMap.size() - 1; i >= 0; i--) { + if (!updateInfoMap.get(i).containsKey("pnfCorrelationId")) + continue; + String id = updateInfoMap.get(i).get("pnfCorrelationId"); + if (id != pnfCorrelationId) + continue; + updateInfoMap.remove(i); + } + } if (pnfCorrelationIdToThreadMap.isEmpty()) { stopDmaapThreadListener(); } @@ -111,7 +133,17 @@ public class PnfEventReadyDmaapClient implements DmaapClient { try { logger.debug("dmaap listener starts listening pnf ready dmaap topic"); HttpResponse response = httpClient.execute(getRequest); - getPnfCorrelationIdListFromResponse(response).forEach(this::informAboutPnfReadyIfPnfCorrelationIdFound); + List<String> idList = getPnfCorrelationIdListFromResponse(response); + + // idList is never null + if (!idList.isEmpty()) { + // send only body of response + registerClientResponse(idList.get(0), EntityUtils.toString(response.getEntity(), "UTF-8")); + } + + if (idList != null) { + idList.forEach(this::informAboutPnfReadyIfPnfCorrelationIdFound); + } } catch (IOException e) { logger.error("Exception caught during sending rest request to dmaap for listening event topic", e); } finally { @@ -136,5 +168,36 @@ public class PnfEventReadyDmaapClient implements DmaapClient { runnable.run(); } } + + private void registerClientResponse(String pnfCorrelationId, String response) { + + String customerId = null; + String serviceType = null; + String serId = null; + synchronized (updateInfoMap) { + for (HashMap<String, String> map : updateInfoMap) { + if (!map.containsKey("pnfCorrelationId")) + continue; + if (pnfCorrelationId != map.get("pnfCorrelationId")) + continue; + if (!map.containsKey("globalSubscriberID")) + continue; + if (!map.containsKey("serviceType")) + continue; + if (!map.containsKey("serviceInstanceId")) + continue; + customerId = map.get("pnfCorrelationId"); + serviceType = map.get("serviceType"); + serId = map.get("serviceInstanceId"); + } + } + if (customerId == null || serviceType == null || serId == null) + return; + AAIResourcesClient client = new AAIResourcesClient(); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE_METADATA, customerId, + serviceType, serId); + client.update(uri, response); + } + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java index 5451f9ff57..f7708b69d3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java @@ -27,6 +27,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import org.onap.so.logger.LoggingAnchor; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; @@ -282,7 +283,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { } catch (Exception exception) { logger.info("exception: AbstractSdncOperationTask.updateProgress fail!"); logger.error("exception: AbstractSdncOperationTask.updateProgress fail:", exception); - logger.error("{} {} {} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.GENERAL_EXCEPTION.toString(), " updateProgress catch exception: ", this.getTaskName(), ErrorCode.UnknownError.getValue(), exception.getClass().toString()); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java index 4d58439fda..8775b39f97 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncNetworkTopologyOperationTask.java @@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask; import java.util.Map; +import org.onap.so.logger.LoggingAnchor; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -78,7 +79,7 @@ public class SdncNetworkTopologyOperationTask extends AbstractSdncOperationTask httpPost.addHeader("Authorization", defaulAuth); httpPost.addHeader("Content-type", "application/json"); String postBody = getPostbody(inputEntity); - logger.info("{} {} {}", MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC"); + logger.info(LoggingAnchor.THREE, MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC"); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); logger.info("SdncNetworkTopologyOperationTask.send2SdncDirectly end!"); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java index 4fb6817a39..ab0bb718ab 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java @@ -24,6 +24,7 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask; import java.util.Map; +import org.onap.so.logger.LoggingAnchor; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -77,7 +78,7 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask httpPost.addHeader("Authorization", defaulAuth); httpPost.addHeader("Content-type", "application/json"); String postBody = getPostbody(inputEntity); - logger.info("{} {} {}", MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC"); + logger.info(LoggingAnchor.THREE, MessageEnum.RA_SEND_REQUEST_SDNC, postBody, "SDNC"); httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); httpPost(url, httpPost); logger.info("SdncServiceTopologyOperationTask.send2SdncDirectly end!"); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java index 21b14c35f9..2418479da6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilder.java @@ -38,31 +38,23 @@ public abstract class AbstractBuilder<I, O> { public static final String RESOURCE_TYPE = "resourceType"; public enum RequestAction { - CREATE_NETWORK_INSTANCE(0, "CreateNetworkInstance"), ACTIVATE_NETWORK_INSTANCE(1, - "ActivateNetworkInstance"), CREATE_SERVICE_INSTANCE(2, - "CreateServiceInstance"), DELETE_SERVICE_INSTANCE(3, - "DeleteServiceInstance"), DELETE_NETWORK_INSTANCE(4, - "DeleteNetworkInstance"), CREATE_VNF_INSTANCE(5, - "CreateVnfInstance"), ACTIVATE_VNF_INSTANCE(6, - "ActivateVnfInstance"), DELETE_VNF_INSTANCE(7, - "DeleteVnfInstance"), CREATE_VF_MODULE_INSTANCE(8, - "CreateVfModuleInstance"), ACTIVATE_VF_MODULE_INSTANCE( - 9, - "ActivateVfModuleInstance"), DELETE_VF_MODULE_INSTANCE( - 10, - "DeleteVfModuleInstance"), CREATE_CONTRAIL_ROUTE_INSTANCE( - 11, - "CreateContrailRouteInstance"), DELETE_CONTRAIL_ROUTE_INSTANCE( - 12, - "DeleteContrailRouteInstance"), CREATE_SECURITY_ZONE_INSTANCE( - 13, - "CreateSecurityZoneInstance"), DELETE_SECURITY_ZONE_INSTANCE( - 14, - "DeleteSecurityZoneInstance"), ACTIVATE_DCI_NETWORK_INSTANCE( - 15, - "ActivateDCINetworkInstance"), DEACTIVATE_DCI_NETWORK_INSTANCE( - 16, - "DeActivateDCINetworkInstance"); + CREATE_NETWORK_INSTANCE(0, "CreateNetworkInstance"), + ACTIVATE_NETWORK_INSTANCE(1, "ActivateNetworkInstance"), + CREATE_SERVICE_INSTANCE(2, "CreateServiceInstance"), + DELETE_SERVICE_INSTANCE(3, "DeleteServiceInstance"), + DELETE_NETWORK_INSTANCE(4, "DeleteNetworkInstance"), + CREATE_VNF_INSTANCE(5, "CreateVnfInstance"), + ACTIVATE_VNF_INSTANCE(6, "ActivateVnfInstance"), + DELETE_VNF_INSTANCE(7, "DeleteVnfInstance"), + CREATE_VF_MODULE_INSTANCE(8, "CreateVfModuleInstance"), + ACTIVATE_VF_MODULE_INSTANCE(9, "ActivateVfModuleInstance"), + DELETE_VF_MODULE_INSTANCE(10, "DeleteVfModuleInstance"), + CREATE_CONTRAIL_ROUTE_INSTANCE(11, "CreateContrailRouteInstance"), + DELETE_CONTRAIL_ROUTE_INSTANCE(12, "DeleteContrailRouteInstance"), + CREATE_SECURITY_ZONE_INSTANCE(13, "CreateSecurityZoneInstance"), + DELETE_SECURITY_ZONE_INSTANCE(14, "DeleteSecurityZoneInstance"), + ACTIVATE_DCI_NETWORK_INSTANCE(15, "ActivateDCINetworkInstance"), + DEACTIVATE_DCI_NETWORK_INSTANCE(16, "DeActivateDCINetworkInstance"); String name; int value; @@ -82,9 +74,16 @@ public abstract class AbstractBuilder<I, O> { } public enum SvcAction { - RESERVE(0, "reserve"), ASSIGN(1, "assign"), ACTIVATE(2, "activate"), DELETE(3, "delete"), CHANGEASSIGN(4, - "changeassign"), CHANGEDELETE(5, "changedelete"), ROLLBACK(6, - "rollback"), DEACTIVATE(7, "deactivate"), UNASSIGN(8, "unassign"), CREATE(9, "create"); + RESERVE(0, "reserve"), + ASSIGN(1, "assign"), + ACTIVATE(2, "activate"), + DELETE(3, "delete"), + CHANGEASSIGN(4, "changeassign"), + CHANGEDELETE(5, "changedelete"), + ROLLBACK(6, "rollback"), + DEACTIVATE(7, "deactivate"), + UNASSIGN(8, "unassign"), + CREATE(9, "create"); String name; int value; diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy index 8dde45be81..e547981b2d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResourceTest.groovy @@ -27,6 +27,7 @@ import org.junit.Test import org.mockito.MockitoAnnotations import org.onap.so.bpmn.common.recipe.ResourceInput import org.onap.so.bpmn.common.resource.ResourceRequestBuilder +import org.onap.so.bpmn.core.json.JsonUtils import static org.mockito.Mockito.* /** @@ -106,6 +107,46 @@ class CreateSDNCNetworkResourceTest extends GroovyTestCase { return resourceInputObj } + private ResourceInput getUpdateResInputObj(String modelName) { + + String resourceInput = "{\n" + + "\t\"resourceInstanceName\": \"SotnFc-wan-connection_wanconnection-37\",\n" + + "\t\"resourceInstanceDes\": null,\n" + + "\t\"globalSubscriberId\": \"sdwandemo\",\n" + + "\t\"serviceType\": \"CCVPN\",\n" + + "\t\"operationId\": \"df3387b5-4fbf-41bd-82a0-13a955ac178a\",\n" + + "\t\"serviceModelInfo\": {\n" + + "\t\t\"modelName\": \"WanConnectionSvc03\",\n" + + "\t\t\"modelUuid\": \"198b066c-0771-4157-9594-1824adfdda7e\",\n" + + "\t\t\"modelInvariantUuid\": \"43fb5165-7d03-4009-8951-a8f45d3f0148\",\n" + + "\t\t\"modelVersion\": \"1.0\",\n" + + "\t\t\"modelCustomizationUuid\": \"\",\n" + + "\t\t\"modelCustomizationName\": \"\",\n" + + "\t\t\"modelInstanceName\": \"\",\n" + + "\t\t\"modelType\": \"\"\n" + + "\t},\n" + + "\t\"resourceModelInfo\": {\n" + + "\t\t\"modelName\": \"" + + modelName + + "\",\n" + + "\t\t\"modelUuid\": \"6a0bf88b-343c-415b-88c1-6f73702452c4\",\n" + + "\t\t\"modelInvariantUuid\": \"50bc3415-2e01-4e50-a9e1-ec9584599bb3\",\n" + + "\t\t\"modelCustomizationUuid\": \"b205d620-84bd-4058-afa0-e3aeee8bb712\",\n" + + "\t\t\"modelCustomizationName\": \"\",\n" + + "\t\t\"modelInstanceName\": \"SotnFc-wan-connection 0\",\n" + + "\t\t\"modelType\": \"\"\n" + + "\t},\n" + + "\t\"resourceInstancenUuid\": null,\n" + + "\t\"resourceParameters\": \"{\\n\\\"locationConstraints\\\":[],\\n\\\"requestInputs\\\":{\\\"sotnfcspecwanconnection0_route-objective-function\\\":null,\\\"sotnfcspecwanconnection0_colorAware\\\":null,\\\"3rdctlspecwanconnection0_thirdPartyAdaptorRpc\\\":null,\\\"sotnfcspecwanconnection0_couplingFlag\\\":null,\\\"sotnfcspecwanconnection0_pbs\\\":null,\\\"3rdctlspecwanconnection0_thirdPartySdncId\\\":null,\\\"sotnfcspecwanconnection0_cbs\\\":null,\\\"3rdctlspecwanconnection0_thirdpartySdncName\\\":null,\\\"sotnfcspecwanconnection0_total-size\\\":null,\\\"3rdctlspecwanconnection0_templateFileName\\\":\\\"sotn_create_zte_template.json\\\",\\\"fcwanconnection0_type\\\":null,\\\"sotnfcspecwanconnection0_cir\\\":null,\\\"fcwanconnection0_uuid\\\":null,\\\"sotnfcspecwanconnection0_diversity-policy\\\":null,\\\"nf_naming\\\":true,\\\"multi_stage_design\\\":false,\\\"availability_zone_max_count\\\":1,\\\"3rdctlspecwanconnection0_restapiUrl\\\":\\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\\"max_instances\\\":null,\\\"sotnfcspecwanconnection0_reroute\\\":null,\\\"fcwanconnection0_name\\\":null,\\\"sotnfcspecwanconnection0_dualLink\\\":null,\\\"min_instances\\\":null,\\\"sotnfcspecwanconnection0_pir\\\":null,\\\"sotnfcspecwanconnection0_service-type\\\":null}\\n}\",\n" + + "\t\"operationType\": \"createInstance\",\n" + + "\t\"serviceInstanceId\": \"ffa07ae4-f820-45af-9439-1416b3bc1d39\",\n" + + "\t\"requestsInputs\": \"{\\r\\n\\t\\\"service\\\": {\\r\\n\\t\\t\\\"name\\\": \\\"wanconnection-37\\\",\\r\\n\\t\\t\\\"description\\\": \\\"deafe\\\",\\r\\n\\t\\t\\\"serviceInvariantUuid\\\": \\\"43fb5165-7d03-4009-8951-a8f45d3f0148\\\",\\r\\n\\t\\t\\\"serviceUuid\\\": \\\"198b066c-0771-4157-9594-1824adfdda7e\\\",\\r\\n\\t\\t\\\"globalSubscriberId\\\": \\\"sdwandemo\\\",\\r\\n\\t\\t\\\"serviceType\\\": \\\"CCVPN\\\",\\r\\n\\t\\t\\\"parameters\\\": {\\r\\n\\t\\t\\t\\\"resources\\\": [\\r\\n\\t\\t\\t],\\r\\n\\t\\t\\t\\\"requestInputs\\\": {\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sotn_create_zte_template.json\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sdwan_create_zte_template.json\\\",\\\"ont_ont_manufacturer\\\":\\\"huawei\\\",\\\"ont_ont_serial_num\\\":\\\"123\\\"\\r\\n\\t\\t\\t}\\r\\n\\t\\t}\\r\\n\\t}\\r\\n}\"\n" + + "}" + + ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) + return resourceInputObj + } + @Test void testAfterCreateSDNCCall() { init() @@ -132,4 +173,30 @@ class CreateSDNCNetworkResourceTest extends GroovyTestCase { def instanceId = response."response-data"."RequestData"."output"."network-response-information"."instance-id" return instanceId } + + @Test + void testUpdateResourceInput() { + init() + + def execution = getExecutionDelegate("OLT") + CreateSDNCNetworkResource createSDNCNetworkResource = new CreateSDNCNetworkResource() + def inputObject = createSDNCNetworkResource.updateResourceInput(execution) + + println(inputObject.getResourceParameters()) + assert JsonUtils.jsonElementExist(inputObject.getResourceParameters(), "requestInputs.SVLAN") + assert JsonUtils.jsonElementExist(inputObject.getResourceParameters(), "requestInputs.CVLAN") + assert JsonUtils.jsonElementExist(inputObject.getResourceParameters(), "requestInputs.manufacturer") + assert JsonUtils.jsonElementExist(inputObject.getResourceParameters(), "requestInputs.ONTSN") + } + + private ExecutionEntity getExecutionDelegate(String modelName) { + def input = getUpdateResInputObj(modelName) + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + when(mockExecution.getVariable(Prefix + "sdncCreateReturnCode")).thenReturn("200") + when(mockExecution.getVariable(Prefix + "SuccessIndicator")).thenReturn("false") + when(mockExecution.getVariable("isActivateRequired")).thenReturn("true") + when(mockExecution.getVariable("CRENWKI_createSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) + when(mockExecution.getVariable(Prefix + "resourceInput")).thenReturn(input.toString()) + return mockExecution + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java index e755214362..bfaf9cfee0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java @@ -42,7 +42,7 @@ public class CancelDmaapSubscriptionTest { .thenReturn(TEST_PNF_CORRELATION_ID); when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey"); dmaapClientTest.registerForUpdate("testPnfCorrelationId", () -> { - }); + }, null); // when delegate.execute(delegateExecution); // then diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java index 19ba18f6de..2634f03d4b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java @@ -21,7 +21,9 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; +import java.util.HashMap; import java.util.Objects; +import java.util.Optional; public class DmaapClientTestImpl implements DmaapClient { @@ -29,7 +31,8 @@ public class DmaapClientTestImpl implements DmaapClient { private Runnable informConsumer; @Override - public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) { + public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer, + Optional<HashMap<String, String>> updateInfo) { this.pnfCorrelationId = pnfCorrelationId; this.informConsumer = informConsumer; } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java index df060ed014..93a71b31ec 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java @@ -34,10 +34,12 @@ import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder; import org.junit.Before; import org.junit.Test; import org.mockito.InOrder; +import org.onap.so.bpmn.common.recipe.ResourceInput; +import org.onap.so.bpmn.common.resource.ResourceRequestBuilder; public class InformDmaapClientTest { @Before - public void setUp() throws Exception { + public void setUp() { informDmaapClient = new InformDmaapClient(); dmaapClientTest = new DmaapClientTestImpl(); informDmaapClient.setDmaapClient(dmaapClientTest); @@ -53,7 +55,7 @@ public class InformDmaapClientTest { private MessageCorrelationBuilder messageCorrelationBuilder; @Test - public void shouldSendListenerToDmaapClient() throws Exception { + public void shouldSendListenerToDmaapClient() { // when informDmaapClient.execute(delegateExecution); // then @@ -63,7 +65,7 @@ public class InformDmaapClientTest { } @Test - public void shouldSendListenerToDmaapClientAndSendMessageToCamunda() throws Exception { + public void shouldSendListenerToDmaapClientAndSendMessageToCamunda() { // when informDmaapClient.execute(delegateExecution); dmaapClientTest.getInformConsumer().run(); @@ -74,11 +76,41 @@ public class InformDmaapClientTest { inOrder.verify(messageCorrelationBuilder).correlateWithResult(); } + private ResourceInput getUpdateResInputObj(String modelName) { + + String resourceInput = "{\n" + "\t\"resourceInstanceName\": \"SotnFc-wan-connection_wanconnection-37\",\n" + + "\t\"resourceInstanceDes\": null,\n" + "\t\"globalSubscriberId\": \"sdwandemo\",\n" + + "\t\"serviceType\": \"CCVPN\",\n" + "\t\"operationId\": \"df3387b5-4fbf-41bd-82a0-13a955ac178a\",\n" + + "\t\"serviceModelInfo\": {\n" + "\t\t\"modelName\": \"WanConnectionSvc03\",\n" + + "\t\t\"modelUuid\": \"198b066c-0771-4157-9594-1824adfdda7e\",\n" + + "\t\t\"modelInvariantUuid\": \"43fb5165-7d03-4009-8951-a8f45d3f0148\",\n" + + "\t\t\"modelVersion\": \"1.0\",\n" + "\t\t\"modelCustomizationUuid\": \"\",\n" + + "\t\t\"modelCustomizationName\": \"\",\n" + "\t\t\"modelInstanceName\": \"\",\n" + + "\t\t\"modelType\": \"\"\n" + "\t},\n" + "\t\"resourceModelInfo\": {\n" + "\t\t\"modelName\": \"" + + modelName + "\",\n" + "\t\t\"modelUuid\": \"6a0bf88b-343c-415b-88c1-6f73702452c4\",\n" + + "\t\t\"modelInvariantUuid\": \"50bc3415-2e01-4e50-a9e1-ec9584599bb3\",\n" + + "\t\t\"modelCustomizationUuid\": \"b205d620-84bd-4058-afa0-e3aeee8bb712\",\n" + + "\t\t\"modelCustomizationName\": \"\",\n" + + "\t\t\"modelInstanceName\": \"SotnFc-wan-connection 0\",\n" + "\t\t\"modelType\": \"\"\n" + "\t},\n" + + "\t\"resourceInstancenUuid\": null,\n" + + "\t\"resourceParameters\": \"{\\n\\\"locationConstraints\\\":[],\\n\\\"requestInputs\\\":{\\\"sotnfcspecwanconnection0_route-objective-function\\\":null,\\\"sotnfcspecwanconnection0_colorAware\\\":null,\\\"3rdctlspecwanconnection0_thirdPartyAdaptorRpc\\\":null,\\\"sotnfcspecwanconnection0_couplingFlag\\\":null,\\\"sotnfcspecwanconnection0_pbs\\\":null,\\\"3rdctlspecwanconnection0_thirdPartySdncId\\\":null,\\\"sotnfcspecwanconnection0_cbs\\\":null,\\\"3rdctlspecwanconnection0_thirdpartySdncName\\\":null,\\\"sotnfcspecwanconnection0_total-size\\\":null,\\\"3rdctlspecwanconnection0_templateFileName\\\":\\\"sotn_create_zte_template.json\\\",\\\"fcwanconnection0_type\\\":null,\\\"sotnfcspecwanconnection0_cir\\\":null,\\\"fcwanconnection0_uuid\\\":null,\\\"sotnfcspecwanconnection0_diversity-policy\\\":null,\\\"nf_naming\\\":true,\\\"multi_stage_design\\\":false,\\\"availability_zone_max_count\\\":1,\\\"3rdctlspecwanconnection0_restapiUrl\\\":\\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\\"max_instances\\\":null,\\\"sotnfcspecwanconnection0_reroute\\\":null,\\\"fcwanconnection0_name\\\":null,\\\"sotnfcspecwanconnection0_dualLink\\\":null,\\\"min_instances\\\":null,\\\"sotnfcspecwanconnection0_pir\\\":null,\\\"sotnfcspecwanconnection0_service-type\\\":null}\\n}\",\n" + + "\t\"operationType\": \"createInstance\",\n" + + "\t\"serviceInstanceId\": \"ffa07ae4-f820-45af-9439-1416b3bc1d39\",\n" + + "\t\"requestsInputs\": \"{\\r\\n\\t\\\"service\\\": {\\r\\n\\t\\t\\\"name\\\": \\\"wanconnection-37\\\",\\r\\n\\t\\t\\\"description\\\": \\\"deafe\\\",\\r\\n\\t\\t\\\"serviceInvariantUuid\\\": \\\"43fb5165-7d03-4009-8951-a8f45d3f0148\\\",\\r\\n\\t\\t\\\"serviceUuid\\\": \\\"198b066c-0771-4157-9594-1824adfdda7e\\\",\\r\\n\\t\\t\\\"globalSubscriberId\\\": \\\"sdwandemo\\\",\\r\\n\\t\\t\\\"serviceType\\\": \\\"CCVPN\\\",\\r\\n\\t\\t\\\"parameters\\\": {\\r\\n\\t\\t\\t\\\"resources\\\": [\\r\\n\\t\\t\\t],\\r\\n\\t\\t\\t\\\"requestInputs\\\": {\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sotnfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sotn_create_zte_template.json\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_restapiUrl\\\": \\\"http://10.80.80.21:8443/restconf/operations/ZTE-API-ConnectivityService:create-connectivity-service\\\",\\r\\n\\t\\t\\t\\t\\\"sdwanfcwanconnection0_3rdctlspecwanconnection0_templateFileName\\\": \\\"sdwan_create_zte_template.json\\\",\\\"ont_ont_manufacturer\\\":\\\"huawei\\\",\\\"ont_ont_serial_num\\\":\\\"123\\\"\\r\\n\\t\\t\\t}\\r\\n\\t\\t}\\r\\n\\t}\\r\\n}\"\n" + + "}"; + + ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class); + return resourceInputObj; + } + private DelegateExecution mockDelegateExecution() { + ResourceInput input = getUpdateResInputObj("OLT"); DelegateExecution delegateExecution = mock(DelegateExecution.class); + when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID))) .thenReturn("testPnfCorrelationId"); when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey"); + when(delegateExecution.getVariable("resourceInput")).thenReturn(input.toString()); ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class); when(delegateExecution.getProcessEngineServices()).thenReturn(processEngineServices); RuntimeService runtimeService = mock(RuntimeService.class); @@ -86,6 +118,7 @@ public class InformDmaapClientTest { messageCorrelationBuilder = mock(MessageCorrelationBuilder.class); when(runtimeService.createMessageCorrelation(any())).thenReturn(messageCorrelationBuilder); when(messageCorrelationBuilder.processInstanceBusinessKey(any())).thenReturn(messageCorrelationBuilder); + return delegateExecution; } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/Macro/CreateNetworkCollection.json b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/Macro/CreateNetworkCollection.json index 7b369ab97e..ce0e5aa643 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/Macro/CreateNetworkCollection.json +++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/Macro/CreateNetworkCollection.json @@ -4,7 +4,7 @@ "modelType": "service", "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersion": "10" }, "cloudConfiguration": { @@ -34,7 +34,7 @@ { "service": { "modelInfo": { - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceParams": [], diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/Macro/ServiceMacroAssign.json b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/Macro/ServiceMacroAssign.json index 51caddd48a..b86a2a28f6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/Macro/ServiceMacroAssign.json +++ b/bpmn/so-bpmn-infrastructure-common/src/test/resources/__files/Macro/ServiceMacroAssign.json @@ -4,7 +4,7 @@ "modelType": "service", "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersion": "10.0" }, "owningEntity": { @@ -31,7 +31,7 @@ "service": { "modelInfo": { "modelType": "service", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceParams": [], diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn index 8cde4f6c56..e5b361643f 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/ActivateSDNCNetworkResource.bpmn @@ -1,13 +1,13 @@ <?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="2.0.0"> +<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="2.2.3"> <bpmn:process id="ActivateSDNCNetworkResource" name="ActivateSDNCNetworkResource" isExecutable="true"> <bpmn:startEvent id="createNS_StartEvent_activate" name="createNS_StartEvent"> <bpmn:outgoing>SequenceFlow_1c92ks3_activate</bpmn:outgoing> </bpmn:startEvent> <bpmn:endEvent id="EndEvent_1x6k78c_activate" name="create SDNC call end"> - <bpmn:incoming>SequenceFlow_17md60u_activate</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0ow44q0_activate</bpmn:incoming> </bpmn:endEvent> - <bpmn:sequenceFlow id="SequenceFlow_0ow44q0_activate" sourceRef="Task_023hred_activate" targetRef="ScriptTask_1g5zyi6_activate" /> + <bpmn:sequenceFlow id="SequenceFlow_0ow44q0_activate" sourceRef="Task_023hred_activate" targetRef="EndEvent_1x6k78c_activate" /> <bpmn:scriptTask id="Task_023hred_activate" name="post SDNC activate call"> <bpmn:incoming>SequenceFlow_1vnx1pp_activate</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ow44q0_activate</bpmn:outgoing> @@ -54,14 +54,6 @@ dcsi.prepareUpdateAfterActivateSDNCResource(execution)</bpmn:script> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_1jr6zi0_activate" sourceRef="Task_0uwlr22_activate" targetRef="ServiceTask_1cm8iwr_activate" /> <bpmn:sequenceFlow id="SequenceFlow_1vnx1pp_activate" sourceRef="ServiceTask_1cm8iwr_activate" targetRef="Task_023hred_activate" /> - <bpmn:scriptTask id="ScriptTask_1g5zyi6_activate" name="Send Sync Ack Response" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0ow44q0_activate</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_17md60u_activate</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def csi = new ActivateSDNCNetworkResource() -csi.sendSyncResponse(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_17md60u_activate" sourceRef="ScriptTask_1g5zyi6_activate" targetRef="EndEvent_1x6k78c_activate" /> <bpmn:sequenceFlow id="SequenceFlow_1c92ks3_activate" sourceRef="createNS_StartEvent_activate" targetRef="Task_13sx2bp_activate" /> <bpmn:scriptTask id="ScriptTask_1gih50a_activate" name="Prepare SDNC Actiate request" scriptFormat="groovy"> <bpmn:incoming>SequenceFlow_18l3crb_activate</bpmn:incoming> @@ -96,14 +88,14 @@ dcsi.prepareSDNCRequest(execution)</bpmn:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c_activate"> - <dc:Bounds x="930" y="306" width="36" height="36" /> + <dc:Bounds x="776" y="306" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="893" y="348" width="85" height="27" /> + <dc:Bounds x="740" y="348" width="84" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0ow44q0_di" bpmnElement="SequenceFlow_0ow44q0_activate"> <di:waypoint x="694" y="324" /> - <di:waypoint x="765" y="324" /> + <di:waypoint x="776" y="324" /> <bpmndi:BPMNLabel> <dc:Bounds x="780.5" y="314" width="90" height="12" /> </bpmndi:BPMNLabel> @@ -141,16 +133,6 @@ dcsi.prepareSDNCRequest(execution)</bpmn:script> <dc:Bounds x="641" y="314" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_1g5zyi6_di" bpmnElement="ScriptTask_1g5zyi6_activate"> - <dc:Bounds x="765" y="284" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_17md60u_di" bpmnElement="SequenceFlow_17md60u_activate"> - <di:waypoint x="865" y="324" /> - <di:waypoint x="930" y="324" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="998" y="313" width="0" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1c92ks3_di" bpmnElement="SequenceFlow_1c92ks3_activate"> <di:waypoint x="-239" y="324" /> <di:waypoint x="-205" y="324" /> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn index 0bdc6dc0bd..5a4b3ac348 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSDNCNetworkResource.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="2.0.0"> +<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.16.2"> <bpmn:process id="CreateSDNCNetworkResource" name="CreateSDNCNetworkResource" isExecutable="true"> <bpmn:startEvent id="createNS_StartEvent" name="createNS_StartEvent"> <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> @@ -137,8 +137,7 @@ dcsi.prepareUpdateAfterCreateSDNCResource(execution)</bpmn:script> <camunda:in source="requestAction" target="requestAction" /> <camunda:in source="URN_mso_workflow_sdncadapter_callback" target="URN_mso_workflow_sdncadapter_callback" /> <camunda:in source="networkRequest" target="networkRequest" /> - <camunda:in source="networkInstanceId" target="networkInstanceId" /> - <camunda:in source="parentServiceInstanceId" target="parentServiceInstanceId" /> + <camunda:in source="resourceInstanceId" target="resourceInstanceId" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_1dww8ye</bpmn:incoming> <bpmn:outgoing>SequenceFlow_05niqbf</bpmn:outgoing> @@ -309,4 +308,4 @@ dcsi.afterCreateSDNCCall(execution)</bpmn:script> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions>
\ No newline at end of file +</bpmn:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateResources.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateResources.bpmn index dc2cf9b676..75767929aa 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateResources.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateResources.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.16.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="DoCreateResourcesV3" name="DoCreateResourcesV3" isExecutable="true"> <bpmn2:startEvent id="createSI_startEvent" name="Start Flow"> <bpmn2:outgoing>SequenceFlow_1qiiycn</bpmn2:outgoing> @@ -7,17 +7,17 @@ <bpmn2:scriptTask id="preProcessRequest_ScriptTask" name="PreProcess Incoming Request" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_1qiiycn</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0w9t6tc</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* + <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.* def dcsi = new DoCreateResources() dcsi.preProcessRequest(execution) -]]></bpmn2:script> +</bpmn2:script> </bpmn2:scriptTask> <bpmn2:scriptTask id="ScriptTask_1xdjlzm" name="Post Config Service Instance Creation" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_16nxl6h</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0epxs3b</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* + <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.* def csi = new DoCreateResources() -csi.postConfigRequest(execution)]]></bpmn2:script> +csi.postConfigRequest(execution)</bpmn2:script> </bpmn2:scriptTask> <bpmn2:serviceTask id="Task_0io5qby" name="Call Sync SDNC service Create " camunda:class="org.onap.so.bpmn.infrastructure.workflow.serviceTask.SdncServiceTopologyOperationTask"> <bpmn2:incoming>SequenceFlow_0k0f7lm</bpmn2:incoming> @@ -27,9 +27,9 @@ csi.postConfigRequest(execution)]]></bpmn2:script> <bpmn2:scriptTask id="ScriptTask_1y0los4" name="Sequence Resource" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_1hbesp9</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_13d9g1n</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* + <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateResources() -ddsi.sequenceResoure(execution)]]></bpmn2:script> +ddsi.sequenceResoure(execution)</bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_13d9g1n" sourceRef="ScriptTask_1y0los4" targetRef="ExclusiveGateway_07rr3wp" /> <bpmn2:exclusiveGateway id="ExclusiveGateway_0n9y4du" name="All ResourceFinished?" default="SequenceFlow_0q6uy30"> @@ -41,18 +41,18 @@ ddsi.sequenceResoure(execution)]]></bpmn2:script> <bpmn2:scriptTask id="ScriptTask_0y4u2ty" name="Parse Next Resource" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_13c7bhn</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_1jenxlp</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* + <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateResources() -ddsi.parseNextResource(execution)]]></bpmn2:script> +ddsi.parseNextResource(execution)</bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_1jenxlp" sourceRef="ScriptTask_0y4u2ty" targetRef="ExclusiveGateway_0n9y4du" /> <bpmn2:scriptTask id="ScriptTask_0l4nkqr" name="Get Current Resource" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_0q6uy30</bpmn2:incoming> - <bpmn2:incoming>SequenceFlow_1qozd66</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_1obf0cq</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0uiygod</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* + <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateResources() -ddsi.getCurrentResoure(execution)]]></bpmn2:script> +ddsi.getCurrentResoure(execution)</bpmn2:script> </bpmn2:scriptTask> <bpmn2:exclusiveGateway id="ExclusiveGateway_07rr3wp" name="Is SDN-C Service Needed" default="SequenceFlow_18wj44x"> <bpmn2:incoming>SequenceFlow_13d9g1n</bpmn2:incoming> @@ -63,16 +63,16 @@ ddsi.getCurrentResoure(execution)]]></bpmn2:script> <bpmn2:scriptTask id="Task_0qlkmvt" name="Prepare resource recipe Request" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_0uiygod</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_1u9k0dm</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* + <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateResources() -ddsi.prepareResourceRecipeRequest(execution)]]></bpmn2:script> +ddsi.prepareResourceRecipeRequest(execution)</bpmn2:script> </bpmn2:scriptTask> <bpmn2:scriptTask id="Task_12ghoph" name="Execute Resource Recipe" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_1u9k0dm</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_13c7bhn</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* + <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateResources() -ddsi.executeResourceRecipe(execution)]]></bpmn2:script> +ddsi.executeResourceRecipe(execution)</bpmn2:script> </bpmn2:scriptTask> <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_0bq4fxs" name="Go to StratPrepareService"> <bpmn2:incoming>SequenceFlow_0w9t6tc</bpmn2:incoming> @@ -86,7 +86,7 @@ ddsi.executeResourceRecipe(execution)]]></bpmn2:script> <bpmn2:linkEventDefinition name="ResourceLoop" /> </bpmn2:intermediateThrowEvent> <bpmn2:sequenceFlow id="SequenceFlow_1vprtt9" name="yes" sourceRef="ExclusiveGateway_07rr3wp" targetRef="Task_1blaq0f"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("isContainsWanResource" ) == "true" )}]]></bpmn2:conditionExpression> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{(execution.getVariable("isContainsWanResource" ) == "true" )}</bpmn2:conditionExpression> </bpmn2:sequenceFlow> <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_05dus9b" name="StartPrepareResource"> <bpmn2:outgoing>SequenceFlow_1hbesp9</bpmn2:outgoing> @@ -98,12 +98,12 @@ ddsi.executeResourceRecipe(execution)]]></bpmn2:script> <bpmn2:linkEventDefinition name="ResourceLoop" /> </bpmn2:intermediateCatchEvent> <bpmn2:sequenceFlow id="SequenceFlow_16nxl6h" name="yes" sourceRef="ExclusiveGateway_0n9y4du" targetRef="ScriptTask_1xdjlzm"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{(execution.getVariable("allResourceFinished" ) == "true" )}]]></bpmn2:conditionExpression> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{(execution.getVariable("allResourceFinished" ) == "true" )}</bpmn2:conditionExpression> </bpmn2:sequenceFlow> <bpmn2:sequenceFlow id="SequenceFlow_0uiygod" sourceRef="ScriptTask_0l4nkqr" targetRef="Task_0qlkmvt" /> <bpmn2:sequenceFlow id="SequenceFlow_1u9k0dm" sourceRef="Task_0qlkmvt" targetRef="Task_12ghoph" /> <bpmn2:sequenceFlow id="SequenceFlow_13c7bhn" sourceRef="Task_12ghoph" targetRef="ScriptTask_0y4u2ty" /> - <bpmn2:sequenceFlow id="SequenceFlow_1qozd66" sourceRef="IntermediateCatchEvent_02bah5m" targetRef="ScriptTask_0l4nkqr" /> + <bpmn2:sequenceFlow id="SequenceFlow_1qozd66" sourceRef="IntermediateCatchEvent_02bah5m" targetRef="Task_0g7zo7b" /> <bpmn2:endEvent id="EndEvent_1ddg1di"> <bpmn2:incoming>SequenceFlow_0epxs3b</bpmn2:incoming> </bpmn2:endEvent> @@ -119,9 +119,9 @@ ddsi.executeResourceRecipe(execution)]]></bpmn2:script> <bpmn2:scriptTask id="ScriptTask_1648adp" name="Log / Print Unexpected Error" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_0gr9xqj</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0a6l29p</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* + <bpmn2:script>import org.onap.so.bpmn.common.scripts.* ExceptionUtil ex = new ExceptionUtil() -ex.processJavaException(execution)]]></bpmn2:script> +ex.processJavaException(execution)</bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_0gr9xqj" name="" sourceRef="StartEvent_0x7o2ug" targetRef="ScriptTask_1648adp" /> <bpmn2:sequenceFlow id="SequenceFlow_0a6l29p" name="" sourceRef="ScriptTask_1648adp" targetRef="EndEvent_0lgdyyb" /> @@ -129,11 +129,19 @@ ex.processJavaException(execution)]]></bpmn2:script> <bpmn2:scriptTask id="Task_1blaq0f" name="Prepare SDNC service Create" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_1vprtt9</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0k0f7lm</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.infrastructure.scripts.* + <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.* def ddsi = new DoCreateResources() -ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> +ddsi.prepareServiceTopologyRequest(execution)</bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_0k0f7lm" sourceRef="Task_1blaq0f" targetRef="Task_0io5qby" /> + <bpmn2:sequenceFlow id="SequenceFlow_1obf0cq" sourceRef="Task_0g7zo7b" targetRef="ScriptTask_0l4nkqr" /> + <bpmn2:scriptTask id="Task_0g7zo7b" name="Prepare Instnace ResourceList" scriptFormat="groovy"> + <bpmn2:incoming>SequenceFlow_1qozd66</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1obf0cq</bpmn2:outgoing> + <bpmn2:script>import org.onap.so.bpmn.infrastructure.scripts.* +def ddsi = new DoCreateResources() +ddsi.prepareInstanceResourceList(execution)</bpmn2:script> + </bpmn2:scriptTask> </bpmn2:process> <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" /> @@ -155,10 +163,10 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> <dc:Bounds x="1047" y="353" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_11f2zuu_di" bpmnElement="SequenceFlow_11f2zuu"> - <di:waypoint xsi:type="dc:Point" x="1147" y="393" /> - <di:waypoint xsi:type="dc:Point" x="1219" y="393" /> - <di:waypoint xsi:type="dc:Point" x="1219" y="300" /> - <di:waypoint xsi:type="dc:Point" x="1315" y="300" /> + <di:waypoint x="1147" y="393" /> + <di:waypoint x="1219" y="393" /> + <di:waypoint x="1219" y="300" /> + <di:waypoint x="1315" y="300" /> <bpmndi:BPMNLabel> <dc:Bounds x="1189" y="340.5" width="90" height="12" /> </bpmndi:BPMNLabel> @@ -167,8 +175,8 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> <dc:Bounds x="444" y="260" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_13d9g1n_di" bpmnElement="SequenceFlow_13d9g1n"> - <di:waypoint xsi:type="dc:Point" x="544" y="300" /> - <di:waypoint xsi:type="dc:Point" x="753" y="300" /> + <di:waypoint x="544" y="300" /> + <di:waypoint x="753" y="300" /> <bpmndi:BPMNLabel> <dc:Bounds x="603.5" y="279" width="90" height="12" /> </bpmndi:BPMNLabel> @@ -180,10 +188,10 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0q6uy30_di" bpmnElement="SequenceFlow_0q6uy30"> - <di:waypoint xsi:type="dc:Point" x="954" y="550" /> - <di:waypoint xsi:type="dc:Point" x="954" y="691" /> - <di:waypoint xsi:type="dc:Point" x="246" y="691" /> - <di:waypoint xsi:type="dc:Point" x="246" y="565" /> + <di:waypoint x="954" y="550" /> + <di:waypoint x="954" y="691" /> + <di:waypoint x="246" y="691" /> + <di:waypoint x="246" y="565" /> <bpmndi:BPMNLabel> <dc:Bounds x="593" y="670" width="15" height="12" /> </bpmndi:BPMNLabel> @@ -192,8 +200,8 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> <dc:Bounds x="728" y="485" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1jenxlp_di" bpmnElement="SequenceFlow_1jenxlp"> - <di:waypoint xsi:type="dc:Point" x="828" y="525" /> - <di:waypoint xsi:type="dc:Point" x="929" y="525" /> + <di:waypoint x="828" y="525" /> + <di:waypoint x="929" y="525" /> <bpmndi:BPMNLabel> <dc:Bounds x="833.5" y="504" width="90" height="12" /> </bpmndi:BPMNLabel> @@ -208,8 +216,8 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_18wj44x_di" bpmnElement="SequenceFlow_18wj44x"> - <di:waypoint xsi:type="dc:Point" x="803" y="300" /> - <di:waypoint xsi:type="dc:Point" x="1315" y="300" /> + <di:waypoint x="803" y="300" /> + <di:waypoint x="1315" y="300" /> <bpmndi:BPMNLabel> <dc:Bounds x="831" y="294" width="15" height="12" /> </bpmndi:BPMNLabel> @@ -227,17 +235,17 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1qiiycn_di" bpmnElement="SequenceFlow_1qiiycn"> - <di:waypoint xsi:type="dc:Point" x="54" y="-189" /> - <di:waypoint xsi:type="dc:Point" x="126" y="-189" /> + <di:waypoint x="54" y="-189" /> + <di:waypoint x="126" y="-189" /> <bpmndi:BPMNLabel> <dc:Bounds x="90" y="-210" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0w9t6tc_di" bpmnElement="SequenceFlow_0w9t6tc"> - <di:waypoint xsi:type="dc:Point" x="226" y="-189" /> - <di:waypoint xsi:type="dc:Point" x="771" y="-189" /> - <di:waypoint xsi:type="dc:Point" x="771" y="-189" /> - <di:waypoint xsi:type="dc:Point" x="1315" y="-189" /> + <di:waypoint x="226" y="-189" /> + <di:waypoint x="771" y="-189" /> + <di:waypoint x="771" y="-189" /> + <di:waypoint x="1315" y="-189" /> <bpmndi:BPMNLabel> <dc:Bounds x="786" y="-195" width="0" height="12" /> </bpmndi:BPMNLabel> @@ -249,9 +257,9 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1vprtt9_di" bpmnElement="SequenceFlow_1vprtt9"> - <di:waypoint xsi:type="dc:Point" x="778" y="325" /> - <di:waypoint xsi:type="dc:Point" x="778" y="393" /> - <di:waypoint xsi:type="dc:Point" x="861" y="394" /> + <di:waypoint x="778" y="325" /> + <di:waypoint x="778" y="393" /> + <di:waypoint x="861" y="394" /> <bpmndi:BPMNLabel> <dc:Bounds x="784" y="353" width="20" height="12" /> </bpmndi:BPMNLabel> @@ -263,49 +271,49 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1hbesp9_di" bpmnElement="SequenceFlow_1hbesp9"> - <di:waypoint xsi:type="dc:Point" x="54" y="300" /> - <di:waypoint xsi:type="dc:Point" x="444" y="300" /> + <di:waypoint x="54" y="300" /> + <di:waypoint x="444" y="300" /> <bpmndi:BPMNLabel> <dc:Bounds x="204" y="279" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="IntermediateCatchEvent_02bah5m_di" bpmnElement="IntermediateCatchEvent_02bah5m"> - <dc:Bounds x="18" y="507" width="36" height="36" /> + <dc:Bounds x="-26" y="507" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="2" y="543" width="73" height="12" /> + <dc:Bounds x="-41" y="543" width="72" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_16nxl6h_di" bpmnElement="SequenceFlow_16nxl6h"> - <di:waypoint xsi:type="dc:Point" x="979" y="525" /> - <di:waypoint xsi:type="dc:Point" x="1119" y="525" /> + <di:waypoint x="979" y="525" /> + <di:waypoint x="1119" y="525" /> <bpmndi:BPMNLabel> <dc:Bounds x="1040" y="504" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0uiygod_di" bpmnElement="SequenceFlow_0uiygod"> - <di:waypoint xsi:type="dc:Point" x="296" y="525" /> - <di:waypoint xsi:type="dc:Point" x="357" y="525" /> + <di:waypoint x="296" y="525" /> + <di:waypoint x="357" y="525" /> <bpmndi:BPMNLabel> <dc:Bounds x="326.5" y="504" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1u9k0dm_di" bpmnElement="SequenceFlow_1u9k0dm"> - <di:waypoint xsi:type="dc:Point" x="457" y="525" /> - <di:waypoint xsi:type="dc:Point" x="551" y="525" /> + <di:waypoint x="457" y="525" /> + <di:waypoint x="551" y="525" /> <bpmndi:BPMNLabel> <dc:Bounds x="504" y="504" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_13c7bhn_di" bpmnElement="SequenceFlow_13c7bhn"> - <di:waypoint xsi:type="dc:Point" x="651" y="525" /> - <di:waypoint xsi:type="dc:Point" x="728" y="525" /> + <di:waypoint x="651" y="525" /> + <di:waypoint x="728" y="525" /> <bpmndi:BPMNLabel> <dc:Bounds x="689.5" y="504" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1qozd66_di" bpmnElement="SequenceFlow_1qozd66"> - <di:waypoint xsi:type="dc:Point" x="54" y="525" /> - <di:waypoint xsi:type="dc:Point" x="196" y="525" /> + <di:waypoint x="10" y="525" /> + <di:waypoint x="52" y="525" /> <bpmndi:BPMNLabel> <dc:Bounds x="125" y="504" width="0" height="12" /> </bpmndi:BPMNLabel> @@ -317,8 +325,8 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0epxs3b_di" bpmnElement="SequenceFlow_0epxs3b"> - <di:waypoint xsi:type="dc:Point" x="1219" y="525" /> - <di:waypoint xsi:type="dc:Point" x="1315" y="525" /> + <di:waypoint x="1219" y="525" /> + <di:waypoint x="1315" y="525" /> <bpmndi:BPMNLabel> <dc:Bounds x="1267" y="504" width="0" height="12" /> </bpmndi:BPMNLabel> @@ -342,15 +350,15 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> <dc:Bounds x="511" y="863" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0gr9xqj_di" bpmnElement="SequenceFlow_0gr9xqj"> - <di:waypoint xsi:type="dc:Point" x="443" y="903" /> - <di:waypoint xsi:type="dc:Point" x="511" y="903" /> + <di:waypoint x="443" y="903" /> + <di:waypoint x="511" y="903" /> <bpmndi:BPMNLabel> <dc:Bounds x="387" y="888" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0a6l29p_di" bpmnElement="SequenceFlow_0a6l29p"> - <di:waypoint xsi:type="dc:Point" x="611" y="903" /> - <di:waypoint xsi:type="dc:Point" x="700" y="903" /> + <di:waypoint x="611" y="903" /> + <di:waypoint x="700" y="903" /> <bpmndi:BPMNLabel> <dc:Bounds x="567.5" y="888" width="0" height="12" /> </bpmndi:BPMNLabel> @@ -359,12 +367,19 @@ ddsi.prepareServiceTopologyRequest(execution)]]></bpmn2:script> <dc:Bounds x="861" y="354" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0k0f7lm_di" bpmnElement="SequenceFlow_0k0f7lm"> - <di:waypoint xsi:type="dc:Point" x="961" y="394" /> - <di:waypoint xsi:type="dc:Point" x="1047" y="393" /> + <di:waypoint x="961" y="394" /> + <di:waypoint x="1047" y="393" /> <bpmndi:BPMNLabel> <dc:Bounds x="1004" y="372.5" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1obf0cq_di" bpmnElement="SequenceFlow_1obf0cq"> + <di:waypoint x="152" y="525" /> + <di:waypoint x="196" y="525" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_0iag9tv_di" bpmnElement="Task_0g7zo7b"> + <dc:Bounds x="52" y="485" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java index 35f8f45999..5b095a9983 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -27,14 +27,15 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.put; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching; +import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; -import com.google.protobuf.Struct; import java.io.IOException; import java.util.List; import java.util.UUID; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; @@ -45,6 +46,7 @@ import org.onap.so.bpmn.mock.FileUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import com.google.protobuf.Struct; /** @@ -102,6 +104,7 @@ public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { } + @Ignore @Test public void workflow_validInput_expectedOuput() throws InterruptedException { diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/CreateNetworkCollection.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/CreateNetworkCollection.json index 7b369ab97e..ce0e5aa643 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/CreateNetworkCollection.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/CreateNetworkCollection.json @@ -4,7 +4,7 @@ "modelType": "service", "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersion": "10" }, "cloudConfiguration": { @@ -34,7 +34,7 @@ { "service": { "modelInfo": { - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceParams": [], diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/ServiceMacroAssign.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/ServiceMacroAssign.json index 51caddd48a..b86a2a28f6 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/ServiceMacroAssign.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/Macro/ServiceMacroAssign.json @@ -4,7 +4,7 @@ "modelType": "service", "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersion": "10.0" }, "owningEntity": { @@ -31,7 +31,7 @@ "service": { "modelInfo": { "modelType": "service", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceParams": [], diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java index 513ff74180..4e74e5d414 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java @@ -55,7 +55,7 @@ public class HomingV2 { private boolean isOof(BuildingBlockExecution execution) { for (Map<String, Object> params : execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters() .getUserParams()) { - if (params.containsKey(HOMINGSOLUTION) && params.get(HOMINGSOLUTION).equals("oof")) { + if (params.containsKey(HOMINGSOLUTION) && ("oof").equals(params.get(HOMINGSOLUTION))) { return true; } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java index 2696313daf..d5a085aba7 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java @@ -81,6 +81,7 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; @Component("OofHoming") public class OofHomingV2 { + public static final String ERROR_WHILE_PREPARING_OOF_REQUEST = " Error - while preparing oof request: "; private static final Logger logger = LoggerFactory.getLogger(OofHomingV2.class); private JsonUtils jsonUtils = new JsonUtils(); @Autowired @@ -91,13 +92,9 @@ public class OofHomingV2 { private OofValidator oofValidator; @Autowired private ExceptionBuilder exceptionUtil; - private static final String MODEL_NAME = "modelName"; private static final String MODEL_INVARIANT_ID = "modelInvariantId"; private static final String MODEL_VERSION_ID = "modelVersionId"; - private static final String MODEL_VERSION = "modelVersion"; private static final String SERVICE_RESOURCE_ID = "serviceResourceId"; - private static final String RESOURCE_MODULE_NAME = "resourceModuleName"; - private static final String RESOURCE_MODEL_INFO = "resourceModelInfo"; private static final String IDENTIFIER_TYPE = "identifierType"; private static final String SOLUTIONS = "solutions"; private static final String RESOURCE_MISSING_DATA = "Resource does not contain: "; @@ -128,7 +125,7 @@ public class OofHomingV2 { OofRequest oofRequest = new OofRequest(); - RequestInfo requestInfo = (RequestInfo) buildRequestInfo(requestId, timeout); + RequestInfo requestInfo = buildRequestInfo(requestId, timeout); oofRequest.setRequestInformation(requestInfo); ServiceInfo serviceInfo = buildServiceInfo(serviceInstance); @@ -157,13 +154,13 @@ public class OofHomingV2 { logger.trace("Completed Oof Homing Call Oof"); } catch (BpmnError e) { - logger.debug(" Error - while preparing oof request: " + e.getStackTrace()); + logger.debug(ERROR_WHILE_PREPARING_OOF_REQUEST + e.getStackTrace()); exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage()); } catch (BadResponseException e) { - logger.debug(" Error - while preparing oof request: " + e.getStackTrace()); + logger.debug(ERROR_WHILE_PREPARING_OOF_REQUEST + e.getStackTrace()); exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage()); } catch (Exception e) { - logger.debug(" Error - while preparing oof request: " + e.getStackTrace()); + logger.debug(ERROR_WHILE_PREPARING_OOF_REQUEST + e.getStackTrace()); exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while " + "preparing oof request: " + e + " Stack:" + ExceptionUtils.getFullStackTrace(e)); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java index 2f898b6697..e5df3d3f35 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java @@ -90,19 +90,17 @@ public class SniroHomingV2 { private SniroClient client; @Autowired private ExceptionBuilder exceptionUtil; - private static final String MODEL_NAME = "modelName"; private static final String MODEL_INVARIANT_ID = "modelInvariantId"; private static final String MODEL_VERSION_ID = "modelVersionId"; - private static final String MODEL_VERSION = "modelVersion"; private static final String SERVICE_RESOURCE_ID = "serviceResourceId"; - private static final String RESOURCE_MODULE_NAME = "resourceModuleName"; - private static final String RESOURCE_MODEL_INFO = "resourceModelInfo"; private static final String IDENTIFIER_TYPE = "identifierType"; private static final String SOLUTIONS = "solutions"; private static final String RESOURCE_MISSING_DATA = "Resource does not contain: "; private static final String SERVICE_MISSING_DATA = "Service Instance does not contain: "; private static final String UNPROCESSABLE = "422"; private static final int INTERNAL = 500; + private static final String EXCEPTION_OCCURRED = "Exception occurred"; + private static final String VNF_HOST_NAME = "vnfHostName"; /** * Generates the request payload then sends to sniro manager to perform homing and licensing for the provided @@ -147,7 +145,7 @@ public class SniroHomingV2 { licenseInfo.setDemands(licenseDemands); request.setLicenseInformation(licenseInfo); - if (placementDemands.size() > 0 || licenseDemands.size() > 0) { + if (!placementDemands.isEmpty() || !licenseDemands.isEmpty()) { client.postDemands(request); } else { logger.debug(SERVICE_MISSING_DATA + "resources eligible for homing or licensing"); @@ -161,13 +159,13 @@ public class SniroHomingV2 { logger.trace("Completed Sniro Homing Call Sniro"); } catch (BpmnError e) { - logger.error("Exception occurred", e); + logger.error(EXCEPTION_OCCURRED, e); exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage()); } catch (BadResponseException e) { - logger.error("Exception occurred", e); + logger.error(EXCEPTION_OCCURRED, e); exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage()); } catch (Exception e) { - logger.error("Exception occurred", e); + logger.error(EXCEPTION_OCCURRED, e); exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while preparing sniro request: " + e.getMessage()); } @@ -183,7 +181,6 @@ public class SniroHomingV2 { logger.trace("Started Sniro Homing Process Solution"); try { // TODO improve handling multiple solutions but is dependent on sniro enhancing api + work with sniro - // conductor to improve "inventoryType" representation validateSolution(asyncResponse); ServiceInstance serviceInstance = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription() .getServiceInstances().get(0); @@ -213,13 +210,13 @@ public class SniroHomingV2 { logger.trace("Completed Sniro Homing Process Solution"); } catch (BpmnError e) { - logger.error("Exception occurred", e); + logger.error(EXCEPTION_OCCURRED, e); exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage()); } catch (BadResponseException e) { - logger.error("Exception occurred", e); + logger.error(EXCEPTION_OCCURRED, e); exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage()); } catch (Exception e) { - logger.error("Exception occurred", e); + logger.error(EXCEPTION_OCCURRED, e); exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while processing sniro asynchronous response: " + e.getMessage()); } @@ -230,7 +227,7 @@ public class SniroHomingV2 { * * @throws Exception */ - private RequestInfo buildRequestInfo(String requestId, String timeout) throws Exception { + private RequestInfo buildRequestInfo(String requestId, String timeout) { logger.trace("Building request information"); RequestInfo requestInfo = new RequestInfo(); if (requestId != null) { @@ -305,7 +302,7 @@ public class SniroHomingV2 { */ private List<Demand> buildPlacementDemands(ServiceInstance serviceInstance) { logger.trace("Building placement information demands"); - List<Demand> placementDemands = new ArrayList<Demand>(); + List<Demand> placementDemands = new ArrayList<>(); List<AllottedResource> allottedResourceList = serviceInstance.getAllottedResources(); if (!allottedResourceList.isEmpty()) { @@ -334,6 +331,18 @@ public class SniroHomingV2 { } } } + List<ServiceProxy> serviceProxies = serviceInstance.getServiceProxies(); + if (!serviceProxies.isEmpty()) { + logger.debug("Adding service proxies to placement demands list"); + for (ServiceProxy sp : serviceProxies) { + if (isBlank(sp.getId())) { + sp.setId(UUID.randomUUID().toString()); + } + Demand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy()); + addCandidates(sp, demand); + placementDemands.add(demand); + } + } return placementDemands; } @@ -343,7 +352,7 @@ public class SniroHomingV2 { */ private List<Demand> buildLicenseDemands(ServiceInstance serviceInstance) { logger.trace("Building license information"); - List<Demand> licenseDemands = new ArrayList<Demand>(); + List<Demand> licenseDemands = new ArrayList<>(); List<GenericVnf> vnfList = serviceInstance.getVnfs(); if (!vnfList.isEmpty()) { logger.debug("Adding vnfs to license demands list"); @@ -394,37 +403,46 @@ public class SniroHomingV2 { } /** - * Adds required, excluded, and existing candidates to a demand + * Adds required, excluded, and existing candidates as well as filtering attributes to a demand * */ private void addCandidates(SolutionCandidates candidates, Demand demand) { List<Candidate> required = candidates.getRequiredCandidates(); List<Candidate> excluded = candidates.getExcludedCandidates(); - if (!required.isEmpty()) { - List<org.onap.so.client.sniro.beans.Candidate> cans = - new ArrayList<org.onap.so.client.sniro.beans.Candidate>(); - for (Candidate c : required) { - org.onap.so.client.sniro.beans.Candidate can = new org.onap.so.client.sniro.beans.Candidate(); - can.setIdentifierType(c.getIdentifierType()); - can.setIdentifiers(c.getIdentifiers()); - can.setCloudOwner(c.getCloudOwner()); - cans.add(can); - } - demand.setRequiredCandidates(cans); + List<Candidate> existing = candidates.getExistingCandidates(); + List<Candidate> filtering = candidates.getFilteringAttributes(); + + List<org.onap.so.client.sniro.beans.Candidate> candidateList = getCandidates(required); + if (!candidateList.isEmpty()) { + demand.setRequiredCandidates(candidateList); } - if (!excluded.isEmpty()) { - List<org.onap.so.client.sniro.beans.Candidate> cans = - new ArrayList<org.onap.so.client.sniro.beans.Candidate>(); - for (Candidate c : excluded) { + candidateList = getCandidates(excluded); + if (!candidateList.isEmpty()) { + demand.setExcludedCandidates(candidateList); + } + candidateList = getCandidates(existing); + if (!candidateList.isEmpty()) { + demand.setExistingCandidates(candidateList); + } + + candidateList = getCandidates(filtering); + if (!candidateList.isEmpty()) { + demand.setFilteringAttributes(candidateList); + } + } + + private List<org.onap.so.client.sniro.beans.Candidate> getCandidates(List<Candidate> candidates) { + List<org.onap.so.client.sniro.beans.Candidate> candidateList = new ArrayList<>(); + if (!candidates.isEmpty()) { + for (Candidate c : candidates) { org.onap.so.client.sniro.beans.Candidate can = new org.onap.so.client.sniro.beans.Candidate(); can.setIdentifierType(c.getIdentifierType()); can.setIdentifiers(c.getIdentifiers()); can.setCloudOwner(c.getCloudOwner()); - cans.add(can); + candidateList.add(can); } - demand.setExcludedCandidates(cans); } - // TODO support existing candidates + return candidateList; } /** @@ -462,6 +480,7 @@ public class SniroHomingV2 { List<VpnBondingLink> links = serviceInstance.getVpnBondingLinks(); List<AllottedResource> allottes = serviceInstance.getAllottedResources(); List<GenericVnf> vnfs = serviceInstance.getVnfs(); + List<ServiceProxy> serviceProxies = serviceInstance.getServiceProxies(); logger.debug("Processing placement solution " + i + 1); for (int p = 0; p < placements.length(); p++) { @@ -502,6 +521,12 @@ public class SniroHomingV2 { break search; } } + for (ServiceProxy proxy : serviceProxies) { + if (placement.getString(SERVICE_RESOURCE_ID).equals(proxy.getId())) { + proxy.setServiceInstance(setSolution(solutionInfo, placement)); + break search; + } + } } } } @@ -531,7 +556,7 @@ public class SniroHomingV2 { si.setServiceInstanceId(identifierValue); si.setOrchestrationStatus(OrchestrationStatus.CREATED); cloud.setLcpCloudRegionId(assignmentsMap.get("cloudRegionId")); - if (assignmentsMap.containsKey("vnfHostName") && !assignmentsMap.get("vnfHostName").isEmpty()) { + if (assignmentsMap.containsKey(VNF_HOST_NAME) && !assignmentsMap.get(VNF_HOST_NAME).isEmpty()) { logger.debug("Resources has been homed to a vnf"); GenericVnf vnf = setVnf(assignmentsMap); vnf.setCloudRegion(cloud); @@ -581,7 +606,7 @@ public class SniroHomingV2 { private GenericVnf setVnf(Map<String, String> assignmentsMap) { GenericVnf vnf = new GenericVnf(); vnf.setOrchestrationStatus(OrchestrationStatus.CREATED); - vnf.setVnfName(assignmentsMap.get("vnfHostName")); + vnf.setVnfName(assignmentsMap.get(VNF_HOST_NAME)); vnf.setVnfId(assignmentsMap.get("vnfId")); return vnf; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index d23f9c52ea..e3540ecc58 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -29,6 +29,7 @@ import java.util.TreeSet; import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -49,6 +50,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; @@ -75,6 +77,7 @@ public class AAICreateTasks { private static final Logger logger = LoggerFactory.getLogger(AAICreateTasks.class); private static final String networkTypeProvider = "PROVIDER"; + private static final String A_LA_CARTE = "aLaCarte"; private static String NETWORK_COLLECTION_NAME = "networkCollectionName"; private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList"; private static String HEAT_STACK_ID = "heatStackId"; @@ -104,8 +107,12 @@ public class AAICreateTasks { public void createServiceInstance(BuildingBlockExecution execution) { try { + Boolean alaCarte = execution.getVariable(A_LA_CARTE); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + if (Boolean.TRUE.equals(alaCarte) && aaiSIResources.checkInstanceServiceNameInUse(serviceInstance)) { + throw new DuplicateNameException("service-instance", serviceInstance.getServiceInstanceName()); + } Customer customer = execution.getGeneralBuildingBlock().getCustomer(); aaiSIResources.createServiceInstance(serviceInstance, customer); } catch (Exception ex) { @@ -122,8 +129,8 @@ public class AAICreateTasks { String errorMessage = "Exception in creating ServiceSubscription. Customer not present for ServiceInstanceID: " + serviceInstance.getServiceInstanceId(); - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), errorMessage, "BPMN", - ErrorCode.UnknownError.getValue(), errorMessage); + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), errorMessage, + "BPMN", ErrorCode.UnknownError.getValue(), errorMessage); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, errorMessage); } aaiSIResources.createServiceSubscription(customer); @@ -169,14 +176,14 @@ public class AAICreateTasks { if (owningEntityName == null || "".equals(owningEntityName)) { String msg = "Exception in AAICreateOwningEntity. Can't create an owningEntity with no owningEntityName."; - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), msg); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } else { if (aaiSIResources.existsOwningEntityName(owningEntityName)) { String msg = "Exception in AAICreateOwningEntity. Can't create OwningEntity as name already exists in AAI associated with a different owning-entity-id (name must be unique)"; - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), msg); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } else { @@ -192,7 +199,11 @@ public class AAICreateTasks { public void createVnf(BuildingBlockExecution execution) { try { + Boolean alaCarte = execution.getVariable(A_LA_CARTE); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + if (Boolean.TRUE.equals(alaCarte) && aaiVnfResources.checkNameInUse(vnf.getVnfName())) { + throw new DuplicateNameException("generic-vnf", vnf.getVnfName()); + } ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); execution.setVariable("homing", Boolean.TRUE.equals(vnf.isCallHoming())); @@ -251,6 +262,10 @@ public class AAICreateTasks { GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID); CloudRegion cloudRegion = gBBInput.getCloudRegion(); + Boolean alaCarte = execution.getVariable(A_LA_CARTE); + if (Boolean.TRUE.equals(alaCarte) && aaiVolumeGroupResources.checkNameInUse(volumeGroup)) { + throw new DuplicateNameException("volume-group", volumeGroup.getVolumeGroupName()); + } aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion); aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion); aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion); @@ -263,6 +278,10 @@ public class AAICreateTasks { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + Boolean alaCarte = execution.getVariable(A_LA_CARTE); + if (Boolean.TRUE.equals(alaCarte) && aaiVfModuleResources.checkNameInUse(vfModule)) { + throw new DuplicateNameException("vf-module", vfModule.getVfModuleName()); + } int moduleIndex = 0; if (vfModule.getModelInfoVfModule() != null && !Boolean.TRUE.equals(vfModule.getModelInfoVfModule().getIsBaseBoolean())) { @@ -308,9 +327,14 @@ public class AAICreateTasks { */ public void createNetwork(BuildingBlockExecution execution) { try { + Boolean alaCarte = execution.getVariable(A_LA_CARTE); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); + if (Boolean.TRUE.equals(alaCarte) + && aaiNetworkResources.checkNetworkNameInUse(l3network.getNetworkName())) { + throw new DuplicateNameException("l3Network", l3network.getNetworkName()); + } // set default to false. ToBe updated by SDNC l3network.setIsBoundToVpn(false); // define is bound to vpn flag as true if NEUTRON_NETWORK_TYPE is PROVIDER @@ -361,11 +385,16 @@ public class AAICreateTasks { */ public void createNetworkCollectionInstanceGroup(BuildingBlockExecution execution) { try { + Boolean alaCarte = execution.getVariable(A_LA_CARTE); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); InstanceGroup instanceGroup = serviceInstance.getCollection().getInstanceGroup(); // set name generated for NetworkCollection/NetworkCollectionInstanceGroup in previous step of the BB flow instanceGroup.setInstanceGroupName(execution.getVariable(NETWORK_COLLECTION_NAME)); + if (Boolean.TRUE.equals(alaCarte) + && aaiInstanceGroupResources.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName())) { + throw new DuplicateNameException("instance-group", instanceGroup.getInstanceGroupName()); + } // put shell in AAI aaiNetworkResources.createNetworkInstanceGroup(instanceGroup); } catch (Exception ex) { @@ -482,7 +511,12 @@ public class AAICreateTasks { public void createConfiguration(BuildingBlockExecution execution) { try { + Boolean alaCarte = execution.getVariable(A_LA_CARTE); Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID); + if (Boolean.TRUE.equals(alaCarte) + && aaiConfigurationResources.checkConfigurationNameInUse(configuration.getConfigurationName())) { + throw new DuplicateNameException("configuration", configuration.getConfigurationName()); + } aaiConfigurationResources.createConfiguration(configuration); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); @@ -491,9 +525,14 @@ public class AAICreateTasks { public void createInstanceGroupVnf(BuildingBlockExecution execution) { try { + Boolean alaCarte = execution.getVariable(A_LA_CARTE); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); + if (Boolean.TRUE.equals(alaCarte) + && aaiInstanceGroupResources.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName())) { + throw new DuplicateNameException("instance-group", instanceGroup.getInstanceGroupName()); + } aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java index 28186528e4..18ba91263b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIDeleteTasks.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. @@ -58,8 +58,8 @@ import org.springframework.stereotype.Component; public class AAIDeleteTasks { private static final Logger logger = LoggerFactory.getLogger(AAIDeleteTasks.class); - private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList"; - private static String NETWORK_POLICY_FQDN_PARAM = "network-policy-fqdn"; + private static String contrailNetworkPolicyFqdnList = "contrailNetworkPolicyFqdnList"; + private static String networkPolicyFqdnParam = "network-policy-fqdn"; @Autowired private ExceptionBuilder exceptionUtil; @@ -176,15 +176,15 @@ public class AAIDeleteTasks { public void deleteNetworkPolicies(BuildingBlockExecution execution) { try { - String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST); + String fqdns = execution.getVariable(contrailNetworkPolicyFqdnList); if (fqdns != null && !fqdns.isEmpty()) { - String fqdnList[] = fqdns.split(","); + String[] fqdnList = fqdns.split(","); int fqdnCount = fqdnList.length; if (fqdnCount > 0) { for (int i = 0; i < fqdnCount; i++) { String fqdn = fqdnList[i]; AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_POLICY); - uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn); + uri.queryParam(networkPolicyFqdnParam, fqdn); Optional<NetworkPolicies> oNetPolicies = aaiNetworkResources.getNetworkPolicies(uri); if (oNetPolicies.isPresent()) { NetworkPolicies networkPolicies = oNetPolicies.get(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index 426ef931b6..775e3213d4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -25,6 +25,7 @@ package org.onap.so.bpmn.infrastructure.activity; import java.util.HashMap; import java.util.Map; import java.util.UUID; +import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; @@ -94,7 +95,7 @@ public class ExecuteActivity implements JavaDelegate { Map<String, Object> variables = new HashMap<>(); variables.put("buildingBlock", executeBuildingBlock); - variables.put("mso-request-id", requestId); + variables.put(G_REQUEST_ID, requestId); variables.put("retryCount", 1); variables.put("aLaCarte", true); @@ -144,7 +145,7 @@ public class ExecuteActivity implements JavaDelegate { } protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), msg, ex); execution.setVariable("ExecuteActivityErrorMessage", msg); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java index 77898dd5cc..428f5e703d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterUpdateTasks.java @@ -32,7 +32,6 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.client.orchestration.NetworkAdapterResources; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +39,6 @@ import org.springframework.stereotype.Component; @Component public class NetworkAdapterUpdateTasks { - private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterUpdateTasks.class); @Autowired private ExtractPojosForBB extractPojosForBB; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java index 849465e787..b257e91165 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterCreateTasks.java @@ -47,7 +47,7 @@ import static org.apache.commons.lang3.StringUtils.*; @Component public class VnfAdapterCreateTasks { - private static final Logger logger = LoggerFactory.getLogger(VnfAdapterCreateTasks.class); + public static final String SDNCQUERY_RESPONSE = "SDNCQueryResponse_"; private static final String VNFREST_REQUEST = "VNFREST_Request"; @Autowired @@ -73,7 +73,7 @@ public class VnfAdapterCreateTasks { try { vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); if (vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) { - sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()); + sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId()); } else { throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value"); @@ -109,8 +109,8 @@ public class VnfAdapterCreateTasks { CloudRegion cloudRegion = gBBInput.getCloudRegion(); RequestContext requestContext = gBBInput.getRequestContext(); OrchestrationContext orchestrationContext = gBBInput.getOrchContext(); - String sdncVfModuleQueryResponse = execution.getVariable("SDNCQueryResponse_" + vfModule.getVfModuleId()); - String sdncVnfQueryResponse = execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId()); + String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId()); + String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId()); CreateVfModuleRequest createVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest( requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java index 116dc30d63..5fe80b79f9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterDeleteTasks.java @@ -42,7 +42,7 @@ import org.springframework.stereotype.Component; @Component public class VnfAdapterDeleteTasks { - private static final Logger logger = LoggerFactory.getLogger(VnfAdapterDeleteTasks.class); + private static final String VNFREST_REQUEST = "VNFREST_Request"; @Autowired diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java index bfa76c5053..e5f28aa4c3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.adapter.vnf.tasks; +import org.onap.so.logger.LoggingAnchor; import org.apache.commons.lang3.StringUtils; import org.onap.so.adapters.vnfrest.CreateVfModuleResponse; import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; @@ -63,6 +64,7 @@ public class VnfAdapterImpl { private static final String OAM_MANAGEMENT_V4_ADDRESS = "oamManagementV4Address"; private static final String OAM_MANAGEMENT_V6_ADDRESS = "oamManagementV6Address"; private static final String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList"; + public static final String HEAT_STACK_ID = "heatStackId"; @Autowired private ExtractPojosForBB extractPojosForBB; @@ -77,7 +79,7 @@ public class VnfAdapterImpl { extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId()); execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId()); - execution.setVariable("heatStackId", null); + execution.setVariable(HEAT_STACK_ID, null); execution.setVariable(CONTRAIL_SERVICE_INSTANCE_FQDN, null); execution.setVariable(OAM_MANAGEMENT_V4_ADDRESS, null); execution.setVariable(OAM_MANAGEMENT_V6_ADDRESS, null); @@ -97,7 +99,7 @@ public class VnfAdapterImpl { String heatStackId = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleStackId(); if (!StringUtils.isEmpty(heatStackId)) { vfModule.setHeatStackId(heatStackId); - execution.setVariable("heatStackId", heatStackId); + execution.setVariable(HEAT_STACK_ID, heatStackId); } Map<String, String> vfModuleOutputs = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleOutputs(); @@ -110,7 +112,7 @@ public class VnfAdapterImpl { Boolean vfModuleDelete = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleDeleted(); if (null != vfModuleDelete && vfModuleDelete) { vfModule.setHeatStackId(null); - execution.setVariable("heatStackId", null); + execution.setVariable(HEAT_STACK_ID, null); Map<String, String> vfModuleOutputs = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleOutputs(); if (vfModuleOutputs != null) { @@ -134,7 +136,7 @@ public class VnfAdapterImpl { String heatStackId = ((CreateVolumeGroupResponse) vnfRestResponse).getVolumeGroupStackId(); if (!StringUtils.isEmpty(heatStackId)) { volumeGroup.setHeatStackId(heatStackId); - execution.setVariable("heatStackId", heatStackId); + execution.setVariable(HEAT_STACK_ID, heatStackId); } else { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "HeatStackId is missing from create VolumeGroup Vnf Adapter response."); @@ -144,7 +146,7 @@ public class VnfAdapterImpl { Boolean volumeGroupDelete = ((DeleteVolumeGroupResponse) vnfRestResponse).getVolumeGroupDeleted(); if (null != volumeGroupDelete && volumeGroupDelete) { volumeGroup.setHeatStackId(null); - execution.setVariable("heatStackId", null); + execution.setVariable(HEAT_STACK_ID, null); } } } @@ -170,8 +172,8 @@ public class VnfAdapterImpl { SAXSource source = new SAXSource(xmlReader, inputSource); return jaxbUnmarshaller.unmarshal(source); } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(), ErrorCode.SchemaError.getValue(), - e.getMessage(), e); + logger.error(LoggingAnchor.THREE, MessageEnum.GENERAL_EXCEPTION.toString(), + ErrorCode.SchemaError.getValue(), e.getMessage(), e); throw new MarshallerException("Error parsing VNF Adapter response. " + e.getMessage(), ErrorCode.SchemaError.getValue(), e); } @@ -184,7 +186,7 @@ public class VnfAdapterImpl { try { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - List<String> contrailNetworkPolicyFqdnList = new ArrayList<String>(); + List<String> contrailNetworkPolicyFqdnList = new ArrayList<>(); Iterator<String> keys = vfModuleOutputs.keySet().iterator(); while (keys.hasNext()) { String key = keys.next(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java index 01519fab6e..4cf5131747 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/Constants.java @@ -2,6 +2,8 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -20,8 +22,7 @@ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; -import static com.google.common.collect.Sets.newHashSet; -import java.util.Set; +import com.google.common.collect.ImmutableSet; import org.onap.vnfmadapter.v1.model.OperationStateEnum; import org.onap.vnfmadapter.v1.model.OperationStatusRetrievalStatusEnum; @@ -51,11 +52,11 @@ public class Constants { public static final String PRELOAD_VNFS_URL = "/restconf/config/VNF-API:preload-vnfs/vnf-preload-list/"; - public static final Set<OperationStateEnum> OPERATION_FINISHED_STATES = - newHashSet(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK); + public static final ImmutableSet<OperationStateEnum> OPERATION_FINISHED_STATES = + ImmutableSet.of(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK); - public static final Set<OperationStatusRetrievalStatusEnum> OPERATION_RETRIEVAL_STATES = newHashSet( - OperationStatusRetrievalStatusEnum.STATUS_FOUND, OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS); + public static final ImmutableSet<OperationStatusRetrievalStatusEnum> OPERATION_RETRIEVAL_STATES = ImmutableSet + .of(OperationStatusRetrievalStatusEnum.STATUS_FOUND, OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS); public static final String OPERATION_STATUS_PARAM_NAME = "operationStatus"; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java index 4c84bcaa1f..30f0d38754 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Ericsson. All rights reserved. + * Copyright (C) 2019 Ericsson. All rights reserved. * ================================================================================ - * Modifications Copyright (c) 2019 Samsung + * Copyright (C) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,6 @@ * 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. - * - * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java index 34e3efa8f5..8fecb81d75 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Ericsson. All rights reserved. + * Copyright (C) 2019 Ericsson. All rights reserved. * ================================================================================ - * Modifications Copyright (c) 2019 Samsung + * Copyright (C) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,6 @@ * 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. - * - * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java index 4a51891184..32516c1dcb 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java @@ -42,6 +42,7 @@ import com.google.common.base.Optional; public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvider { private static final Logger LOGGER = LoggerFactory.getLogger(VnfmAdapterServiceProviderImpl.class); + public static final String RECEIVED_RESPONSE_WITHOUT_BODY = "Received response without body: {}"; private final VnfmAdapterUrlProvider urlProvider; private final HttpRestServiceProvider httpServiceProvider; @@ -69,7 +70,7 @@ public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvide } if (!response.hasBody()) { - LOGGER.error("Received response without body: {}", response); + LOGGER.error(RECEIVED_RESPONSE_WITHOUT_BODY, response); return Optional.absent(); } @@ -107,7 +108,7 @@ public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvide } if (!response.hasBody()) { - LOGGER.error("Received response without body: {}", response); + LOGGER.error(RECEIVED_RESPONSE_WITHOUT_BODY, response); return Optional.absent(); } final DeleteVnfResponse deleteVnfResponse = response.getBody(); @@ -139,7 +140,7 @@ public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvide } if (!response.hasBody()) { - LOGGER.error("Received response without body: {}", response); + LOGGER.error(RECEIVED_RESPONSE_WITHOUT_BODY, response); return Optional.absent(); } return Optional.of(response.getBody()); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index ef882b4694..eddcc94e71 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -24,6 +24,7 @@ package org.onap.so.bpmn.infrastructure.appc.tasks; import java.util.HashMap; import java.util.Optional; +import org.onap.so.logger.LoggingAnchor; import org.onap.appc.client.lcm.model.Action; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -47,6 +48,9 @@ import org.springframework.stereotype.Component; @Component public class AppcRunTasks { private static final Logger logger = LoggerFactory.getLogger(AppcRunTasks.class); + public static final String ROLLBACK_VNF_STOP = "rollbackVnfStop"; + public static final String ROLLBACK_VNF_LOCK = "rollbackVnfLock"; + public static final String ROLLBACK_QUIESCE_TRAFFIC = "rollbackQuiesceTraffic"; @Autowired private ExceptionBuilder exceptionUtil; @Autowired @@ -71,9 +75,9 @@ public class AppcRunTasks { execution.setVariable("actionHealthCheck", Action.HealthCheck); execution.setVariable("actionDistributeTraffic", Action.DistributeTraffic); execution.setVariable("actionDistributeTrafficCheck", Action.DistributeTrafficCheck); - execution.setVariable("rollbackVnfStop", false); - execution.setVariable("rollbackVnfLock", false); - execution.setVariable("rollbackQuiesceTraffic", false); + execution.setVariable(ROLLBACK_VNF_STOP, false); + execution.setVariable(ROLLBACK_VNF_LOCK, false); + execution.setVariable(ROLLBACK_QUIESCE_TRAFFIC, false); } public void runAppcCommand(BuildingBlockExecution execution, Action action) { @@ -137,7 +141,7 @@ public class AppcRunTasks { appcMessage = appCClient.getErrorMessage(); mapRollbackVariables(execution, action, appcCode); } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "Caught exception in runAppcCommand", "BPMN", ErrorCode.UnknownError.getValue(), "APPC Error", e); appcMessage = e.getMessage(); } @@ -153,17 +157,17 @@ public class AppcRunTasks { protected void mapRollbackVariables(BuildingBlockExecution execution, Action action, String appcCode) { if (appcCode.equals("0") && action != null) { if (action.equals(Action.Lock)) { - execution.setVariable("rollbackVnfLock", true); + execution.setVariable(ROLLBACK_VNF_LOCK, true); } else if (action.equals(Action.Unlock)) { - execution.setVariable("rollbackVnfLock", false); + execution.setVariable(ROLLBACK_VNF_LOCK, false); } else if (action.equals(Action.Start)) { - execution.setVariable("rollbackVnfStop", false); + execution.setVariable(ROLLBACK_VNF_STOP, false); } else if (action.equals(Action.Stop)) { - execution.setVariable("rollbackVnfStop", true); + execution.setVariable(ROLLBACK_VNF_STOP, true); } else if (action.equals(Action.QuiesceTraffic)) { - execution.setVariable("rollbackQuiesceTraffic", true); + execution.setVariable(ROLLBACK_QUIESCE_TRAFFIC, true); } else if (action.equals(Action.ResumeTraffic)) { - execution.setVariable("rollbackQuiesceTraffic", false); + execution.setVariable(ROLLBACK_QUIESCE_TRAFFIC, false); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java index a223259d4d..62878fd4f7 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/audit/AuditTasks.java @@ -60,6 +60,16 @@ public class AuditTasks { } } + public void isDeleteAuditNeeded(BuildingBlockExecution execution) { + try { + logger.debug("deleteAuditInventoryNeeded Value: {}", env.getProperty("mso.infra.deleteAuditInventory")); + execution.setVariable("auditInventoryNeeded", + Boolean.parseBoolean(env.getProperty("mso.infra.deleteAuditInventory"))); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + public void setupAuditVariable(BuildingBlockExecution execution) { try { execution.setVariable("auditInventory", createAuditInventory(execution)); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java index ab8818f682..4b88f741de 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java @@ -54,9 +54,9 @@ public class AssignNetworkBBUtils { * @return */ public boolean networkFoundByName(BuildingBlockExecution execution) throws Exception { - boolean found = false; + // TODO - populate logic after iTrack MSO-2143 implemented - return found; + return false; } /** @@ -71,7 +71,7 @@ public class AssignNetworkBBUtils { CloudRegion cloudRegion = gBBInput.getCloudRegion(); String cloudRegionSdnc; String cloudRegionPo = cloudRegion.getLcpCloudRegionId(); - if (cloudRegion.getCloudRegionVersion().equalsIgnoreCase("2.5")) { + if ("2.5".equalsIgnoreCase(cloudRegion.getCloudRegionVersion())) { cloudRegionSdnc = "AAIAIC25"; } else { cloudRegionSdnc = cloudRegionPo; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java index 6e7ca5f4e5..cdbe0db57c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java @@ -1,15 +1,20 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright 2019 TechMahindra - * ================================================================================= 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_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 TechMahindra + * ================================================================================ + * 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========================================================= */ @@ -40,9 +45,9 @@ import org.springframework.stereotype.Component; @Component public class ConfigDeployVnf { private static final Logger logger = LoggerFactory.getLogger(ConfigDeployVnf.class); - private final static String ORIGINATOR_ID = "SO"; - private final static String ACTION_NAME = "config-deploy"; - private final static String MODE = "async"; + private static final String ORIGINATOR_ID = "SO"; + private static final String ACTION_NAME = "config-deploy"; + private static final String MODE = "async"; @Autowired private ExceptionBuilder exceptionUtil; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java index 1925d8b69f..ff9d7376de 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import org.onap.so.logger.LoggingAnchor; import org.onap.appc.client.lcm.model.Action; import org.onap.so.bpmn.appc.payload.beans.ConfigScaleOutPayload; import org.onap.so.bpmn.appc.payload.beans.RequestParametersConfigScaleOut; @@ -152,7 +153,7 @@ public class ConfigurationScaleOut { appcMessage = appCClient.getErrorMessage(); } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "Caught exception in runAppcCommand in ConfigurationScaleOut", "BPMN", ErrorCode.UnknownError.getValue(), "APPC Error", e); appcMessage = e.getMessage(); @@ -160,7 +161,7 @@ public class ConfigurationScaleOut { logger.error("Error Message: " + appcMessage); logger.error("ERROR CODE: " + appcCode); logger.trace("End of runAppCommand "); - if (appcCode != null && !appcCode.equals("0")) { + if (appcCode != null && !("0").equals(appcCode)) { exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java index c2d9c6e7bb..b7ddc11f35 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java @@ -39,7 +39,7 @@ import org.springframework.stereotype.Component; @Component public class CreateNetwork { - private static final Logger logger = LoggerFactory.getLogger(CreateNetwork.class); + @Autowired private ExceptionBuilder exceptionUtil; @Autowired diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java index 4eaec381e9..36eab8f981 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java @@ -36,7 +36,7 @@ import org.springframework.stereotype.Component; @Component public class CreateNetworkCollection { - private static final Logger logger = LoggerFactory.getLogger(CreateNetworkCollection.class); + @Autowired private ExceptionBuilder exceptionUtil; @Autowired diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java index 98b602eca1..1a7d22c0dd 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java @@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; import java.util.HashMap; import java.util.Optional; +import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.appc.client.lcm.model.Action; import org.onap.so.bpmn.common.BuildingBlockExecution; @@ -45,6 +46,9 @@ import org.springframework.stereotype.Component; public class GenericVnfHealthCheck { private static final Logger logger = LoggerFactory.getLogger(GenericVnfHealthCheck.class); + public static final String VNF_NAME = "vnfName"; + public static final String OAM_IP_ADDRESS = "oamIpAddress"; + public static final String VNF_HOST_IP_ADDRESS = "vnfHostIpAddress"; @Autowired private ExceptionBuilder exceptionUtil; @Autowired @@ -71,9 +75,9 @@ public class GenericVnfHealthCheck { String controllerName = controllerSelectionReference.getControllerName(); execution.setVariable("vnfId", vnfId); - execution.setVariable("vnfName", vnfName); - execution.setVariable("oamIpAddress", oamIpAddress); - execution.setVariable("vnfHostIpAddress", oamIpAddress); + execution.setVariable(VNF_NAME, vnfName); + execution.setVariable(OAM_IP_ADDRESS, oamIpAddress); + execution.setVariable(VNF_HOST_IP_ADDRESS, oamIpAddress); execution.setVariable("msoRequestId", gBBInput.getRequestContext().getMsoRequestId()); execution.setVariable("action", actionCategory); execution.setVariable("controllerType", controllerName); @@ -98,11 +102,11 @@ public class GenericVnfHealthCheck { payload = Optional.of(pay); } String controllerType = execution.getVariable("controllerType"); - HashMap<String, String> payloadInfo = new HashMap<String, String>(); - payloadInfo.put("vnfName", execution.getVariable("vnfName")); + HashMap<String, String> payloadInfo = new HashMap<>(); + payloadInfo.put(VNF_NAME, execution.getVariable(VNF_NAME)); payloadInfo.put("vfModuleId", execution.getVariable("vfModuleId")); - payloadInfo.put("oamIpAddress", execution.getVariable("oamIpAddress")); - payloadInfo.put("vnfHostIpAddress", execution.getVariable("vnfHostIpAddress")); + payloadInfo.put(OAM_IP_ADDRESS, execution.getVariable(OAM_IP_ADDRESS)); + payloadInfo.put(VNF_HOST_IP_ADDRESS, execution.getVariable(VNF_HOST_IP_ADDRESS)); logger.debug("Running APP-C action: {}", action.toString()); logger.debug("VNFID: {}", vnfId); @@ -111,19 +115,19 @@ public class GenericVnfHealthCheck { appcCode = appCClient.getErrorCode(); appcMessage = appCClient.getErrorMessage(); } catch (BpmnError ex) { - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Caught exception in GenericVnfHealthCheck", "BPMN", ErrorCode.UnknownError.getValue(), ex); appcMessage = ex.getMessage(); exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } catch (Exception e) { if (e instanceof java.util.concurrent.TimeoutException) { appcMessage = "Request to APPC timed out. "; - logger.error("{} {} {} {} {}", MessageEnum.RA_CONNECTION_EXCEPTION.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONNECTION_EXCEPTION.toString(), "Caught timedOut exception in runAppcCommand in GenericVnfHealthCheck", "BPMN", ErrorCode.UnknownError.getValue(), "APPC Error", e); throw e; } else { - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "Caught exception in runAppcCommand in GenericVnfHealthCheck", "BPMN", ErrorCode.UnknownError.getValue(), "APPC Error", e); appcMessage = e.getMessage(); @@ -133,7 +137,7 @@ public class GenericVnfHealthCheck { logger.error("Error Message: " + appcMessage); logger.error("ERROR CODE: " + appcCode); logger.trace("End of runAppCommand "); - if (appcCode != null && !appcCode.equals("0")) { + if (appcCode != null && !("0").equals(appcCode)) { exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java index 27415190cc..7466df53b2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java @@ -38,11 +38,10 @@ import org.springframework.stereotype.Component; @Component public class UnassignNetworkBB { - private static final Logger logger = LoggerFactory.getLogger(UnassignNetworkBB.class); - private static String MESSAGE_CANNOT_PERFORM_UNASSIGN = + private static String messageCannotPerformUnassign = "Cannot perform Unassign Network. Network is still related to "; - private static String MESSAGE_ERROR_ROLLBACK = " Rollback is not possible. Please restore data manually."; + private static String messageErrorRollback = " Rollback is not possible. Please restore data manually."; @Autowired private ExceptionBuilder exceptionUtil; @@ -72,7 +71,7 @@ public class UnassignNetworkBB { Optional<org.onap.aai.domain.yang.L3Network> network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class); if (networkBBUtils.isRelationshipRelatedToExists(network, relatedToValue)) { - String msg = MESSAGE_CANNOT_PERFORM_UNASSIGN + relatedToValue; + String msg = messageCannotPerformUnassign + relatedToValue; execution.setVariable("ErrorUnassignNetworkBB", msg); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } @@ -109,7 +108,7 @@ public class UnassignNetworkBB { boolean isRollbackNeeded = execution.getVariable("isRollbackNeeded") != null ? execution.getVariable("isRollbackNeeded") : false; if (isRollbackNeeded == true) { - msg = execution.getVariable("ErrorUnassignNetworkBB") + MESSAGE_ERROR_ROLLBACK; + msg = execution.getVariable("ErrorUnassignNetworkBB") + messageErrorRollback; } else { msg = execution.getVariable("ErrorUnassignNetworkBB"); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java index b906b8a662..17089be571 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java @@ -1,7 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.manualhandling.tasks; import java.util.Map; import java.util.HashMap; +import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateTask; @@ -23,6 +44,14 @@ public class ManualHandlingTasks { private static final String TASK_TYPE_PAUSE = "pause"; private static final String TASK_TYPE_FALLOUT = "fallout"; + public static final String VNF_TYPE = "vnfType"; + public static final String SERVICE_TYPE = "serviceType"; + public static final String MSO_REQUEST_ID = "msoRequestId"; + public static final String REQUESTOR_ID = "requestorId"; + public static final String ERROR_CODE = "errorCode"; + public static final String VALID_RESPONSES = "validResponses"; + public static final String DESCRIPTION = "description"; + public static final String BPMN_EXCEPTION = "BPMN exception: "; @Autowired private ExceptionBuilder exceptionUtil; @@ -37,39 +66,39 @@ public class ManualHandlingTasks { String taskId = task.getId(); logger.debug("taskId is: " + taskId); String type = TASK_TYPE_FALLOUT; - String nfRole = (String) execution.getVariable("vnfType"); - String subscriptionServiceType = (String) execution.getVariable("serviceType"); - String originalRequestId = (String) execution.getVariable("msoRequestId"); - String originalRequestorId = (String) execution.getVariable("requestorId"); + String nfRole = (String) execution.getVariable(VNF_TYPE); + String subscriptionServiceType = (String) execution.getVariable(SERVICE_TYPE); + String originalRequestId = (String) execution.getVariable(MSO_REQUEST_ID); + String originalRequestorId = (String) execution.getVariable(REQUESTOR_ID); String description = ""; String timeout = ""; String errorSource = (String) execution.getVariable("failedActivity"); - String errorCode = (String) execution.getVariable("errorCode"); + String errorCode = (String) execution.getVariable(ERROR_CODE); String errorMessage = (String) execution.getVariable("errorText"); String buildingBlockName = (String) execution.getVariable("currentActivity"); String buildingBlockStep = (String) execution.getVariable("workStep"); - String validResponses = (String) execution.getVariable("validResponses"); + String validResponses = (String) execution.getVariable(VALID_RESPONSES); - Map<String, String> taskVariables = new HashMap<String, String>(); + Map<String, String> taskVariables = new HashMap<>(); taskVariables.put("type", type); taskVariables.put("nfRole", nfRole); taskVariables.put("subscriptionServiceType", subscriptionServiceType); taskVariables.put("originalRequestId", originalRequestId); taskVariables.put("originalRequestorId", originalRequestorId); taskVariables.put("errorSource", errorSource); - taskVariables.put("errorCode", errorCode); + taskVariables.put(ERROR_CODE, errorCode); taskVariables.put("errorMessage", errorMessage); taskVariables.put("buildingBlockName", buildingBlockName); taskVariables.put("buildingBlockStep", buildingBlockStep); - taskVariables.put("validResponses", validResponses); + taskVariables.put(VALID_RESPONSES, validResponses); taskVariables.put("tmeout", timeout); - taskVariables.put("description", description); + taskVariables.put(DESCRIPTION, description); TaskService taskService = execution.getProcessEngineServices().getTaskService(); taskService.setVariables(taskId, taskVariables); logger.debug("successfully created fallout task: " + taskId); } catch (BpmnError e) { - logger.debug("BPMN exception: " + e.getMessage()); + logger.debug(BPMN_EXCEPTION + e.getMessage()); throw e; } catch (Exception ex) { String msg = "Exception in setFalloutTaskVariables " + ex.getMessage(); @@ -86,39 +115,39 @@ public class ManualHandlingTasks { String taskId = task.getId(); logger.debug("taskId is: " + taskId); String type = TASK_TYPE_PAUSE; - String nfRole = (String) execution.getVariable("vnfType"); - String subscriptionServiceType = (String) execution.getVariable("serviceType"); - String originalRequestId = (String) execution.getVariable("msoRequestId"); - String originalRequestorId = (String) execution.getVariable("requestorId"); - String description = (String) execution.getVariable("description"); + String nfRole = (String) execution.getVariable(VNF_TYPE); + String subscriptionServiceType = (String) execution.getVariable(SERVICE_TYPE); + String originalRequestId = (String) execution.getVariable(MSO_REQUEST_ID); + String originalRequestorId = (String) execution.getVariable(REQUESTOR_ID); + String description = (String) execution.getVariable(DESCRIPTION); String timeout = (String) execution.getVariable("taskTimeout"); String errorSource = ""; String errorCode = ""; String errorMessage = ""; String buildingBlockName = ""; String buildingBlockStep = ""; - String validResponses = (String) execution.getVariable("validResponses"); + String validResponses = (String) execution.getVariable(VALID_RESPONSES); - Map<String, String> taskVariables = new HashMap<String, String>(); + Map<String, String> taskVariables = new HashMap<>(); taskVariables.put("type", type); taskVariables.put("nfRole", nfRole); - taskVariables.put("description", description); + taskVariables.put(DESCRIPTION, description); taskVariables.put("timeout", timeout); taskVariables.put("subscriptionServiceType", subscriptionServiceType); taskVariables.put("originalRequestId", originalRequestId); taskVariables.put("originalRequestorId", originalRequestorId); taskVariables.put("errorSource", errorSource); - taskVariables.put("errorCode", errorCode); + taskVariables.put(ERROR_CODE, errorCode); taskVariables.put("errorMessage", errorMessage); taskVariables.put("buildingBlockName", buildingBlockName); taskVariables.put("buildingBlockStep", buildingBlockStep); - taskVariables.put("validResponses", validResponses); + taskVariables.put(VALID_RESPONSES, validResponses); TaskService taskService = execution.getProcessEngineServices().getTaskService(); taskService.setVariables(taskId, taskVariables); logger.debug("successfully created pause task: " + taskId); } catch (BpmnError e) { - logger.debug("BPMN exception: " + e.getMessage()); + logger.debug(BPMN_EXCEPTION + e.getMessage()); throw e; } catch (Exception ex) { String msg = "Exception in setPauseTaskVariables " + ex.getMessage(); @@ -149,7 +178,7 @@ public class ManualHandlingTasks { execution.setVariable("responseValueTask", responseValueUppercaseStart); } catch (BpmnError e) { - logger.debug("BPMN exception: " + e.getMessage()); + logger.debug(BPMN_EXCEPTION + e.getMessage()); throw e; } catch (Exception ex) { String msg = "Exception in completeManualTask " + ex.getMessage(); @@ -164,26 +193,26 @@ public class ManualHandlingTasks { try { ExternalTicket ticket = new ExternalTicket(); - ticket.setRequestId((String) execution.getVariable("msoRequestId")); + ticket.setRequestId((String) execution.getVariable(MSO_REQUEST_ID)); ticket.setCurrentActivity((String) execution.getVariable("currentActivity")); - ticket.setNfRole((String) execution.getVariable("vnfType")); - ticket.setDescription((String) execution.getVariable("description")); - ticket.setSubscriptionServiceType((String) execution.getVariable("serviceType")); - ticket.setRequestorId((String) execution.getVariable("requestorId")); + ticket.setNfRole((String) execution.getVariable(VNF_TYPE)); + ticket.setDescription((String) execution.getVariable(DESCRIPTION)); + ticket.setSubscriptionServiceType((String) execution.getVariable(SERVICE_TYPE)); + ticket.setRequestorId((String) execution.getVariable(REQUESTOR_ID)); ticket.setTimeout((String) execution.getVariable("taskTimeout")); ticket.setErrorSource((String) execution.getVariable("failedActivity")); - ticket.setErrorCode((String) execution.getVariable("errorCode")); + ticket.setErrorCode((String) execution.getVariable(ERROR_CODE)); ticket.setErrorMessage((String) execution.getVariable("errorText")); ticket.setWorkStep((String) execution.getVariable("workStep")); ticket.createTicket(); } catch (BpmnError e) { String msg = "BPMN error in createAOTSTicket " + e.getMessage(); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", ErrorCode.UnknownError.getValue()); } catch (Exception ex) { String msg = "Exception in createExternalTicket " + ex.getMessage(); - logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", ErrorCode.UnknownError.getValue()); } @@ -191,7 +220,7 @@ public class ManualHandlingTasks { public void updateRequestDbStatus(DelegateExecution execution, String status) { try { - String requestId = (String) execution.getVariable("msoRequestId"); + String requestId = (String) execution.getVariable(MSO_REQUEST_ID); InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); request.setRequestStatus(status); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java index d248ad5443..155455e654 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java @@ -20,12 +20,28 @@ package org.onap.so.bpmn.infrastructure.namingservice.tasks; - +import java.util.List; +import java.util.Optional; +import org.onap.aai.domain.yang.Zone; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.Relationships; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.namingservice.NamingRequestObject; +import org.onap.so.client.namingservice.NamingServiceConstants; import org.onap.so.client.orchestration.NamingServiceResources; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -40,6 +56,14 @@ public class NamingServiceCreateTasks { @Autowired private NamingServiceResources namingServiceResources; + @Autowired + protected InjectionHelper injectionHelper; + @Autowired + protected BBInputSetupUtils bbInputSetupUtils; + + public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) { + this.bbInputSetupUtils = bbInputSetupUtils; + } public void createInstanceGroupName(BuildingBlockExecution execution) throws Exception { InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); @@ -54,4 +78,46 @@ public class NamingServiceCreateTasks { } instanceGroup.setInstanceGroupName(generatedInstanceGroupName); } + + public void createWanTransportServiceName(BuildingBlockExecution execution) throws Exception { + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + NamingRequestObject namingRequestObject = new NamingRequestObject(); + namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId()); + namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE); + namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME); + namingRequestObject.setPolicyInstanceNameValue(serviceInstance.getModelInfoServiceInstance().getNamingPolicy()); + namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName()); + namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion()); + + String generatedWanTransportServiceName = ""; + try { + generatedWanTransportServiceName = namingServiceResources.generateServiceInstanceName(namingRequestObject); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + serviceInstance.setServiceInstanceName(generatedWanTransportServiceName); + } + + public void createVpnBondingServiceName(BuildingBlockExecution execution) throws Exception { + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); + VpnBinding vpnBinding = extractPojosForBB.extractByKey(execution, ResourceKey.VPN_ID); + NamingRequestObject namingRequestObject = new NamingRequestObject(); + namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId()); + namingRequestObject.setPolicyInstanceNameValue(serviceInstance.getModelInfoServiceInstance().getNamingPolicy()); + namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE); + namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName()); + namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion()); + namingRequestObject.setNetworkNameValue(execution.getVariable(network.getNetworkName())); + namingRequestObject.setVpnNameValue(vpnBinding.getVpnName()); + namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME); + + String generatedVpnBondingServiceName = ""; + try { + generatedVpnBondingServiceName = namingServiceResources.generateServiceInstanceName(namingRequestObject); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + serviceInstance.setServiceInstanceName(generatedVpnBondingServiceName); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java index 9a8c9df8b5..507e14e42a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java @@ -23,9 +23,11 @@ package org.onap.so.bpmn.infrastructure.namingservice.tasks; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.namingservice.NamingRequestObject; import org.onap.so.client.orchestration.NamingServiceResources; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -50,4 +52,16 @@ public class NamingServiceDeleteTasks { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + + public void deleteServiceInstanceName(BuildingBlockExecution execution) throws Exception { + ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + NamingRequestObject namingRequestObject = new NamingRequestObject(); + namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId()); + try { + namingServiceResources.deleteServiceInstanceName(namingRequestObject); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java index d76d860b3b..b8f025aaa6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.sdnc.exceptions; public class SDNCErrorResponseException extends Exception { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java index 7a0008d5a2..e4dd35503e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java @@ -22,6 +22,8 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import java.net.URI; +import javax.ws.rs.core.UriBuilder; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; @@ -46,11 +48,13 @@ import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component public class SDNCActivateTasks { - private static final Logger logger = LoggerFactory.getLogger(SDNCActivateTasks.class); + + public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired private SDNCVnfResources sdncVnfResources; @Autowired @@ -61,7 +65,8 @@ public class SDNCActivateTasks { private SDNCNetworkResources sdncNetworkResources; @Autowired private SDNCVfModuleResources sdncVfModuleResources; - + @Autowired + private Environment env; public void activateVnf(BuildingBlockExecution execution) { try { @@ -77,7 +82,7 @@ public class SDNCActivateTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VNF); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -103,7 +108,7 @@ public class SDNCActivateTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.NETWORK); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -121,12 +126,15 @@ public class SDNCActivateTasks { vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.activateVfModule(vfModule, vnf, - serviceInstance, customer, cloudRegion, requestContext); SDNCRequest sdncRequest = new SDNCRequest(); + UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) + .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); + URI uri = builder.build(); + GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.activateVfModule(vfModule, vnf, + serviceInstance, customer, cloudRegion, requestContext, uri); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VFMODULE); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java index d3878f06b7..c100cd6cee 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java @@ -22,6 +22,8 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import java.net.URI; +import javax.ws.rs.core.UriBuilder; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; @@ -49,11 +51,13 @@ import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component public class SDNCAssignTasks { private static final Logger logger = LoggerFactory.getLogger(SDNCAssignTasks.class); + public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired private SDNCServiceInstanceResources sdncSIResources; @Autowired @@ -66,6 +70,8 @@ public class SDNCAssignTasks { private ExtractPojosForBB extractPojosForBB; @Autowired private SDNCNetworkResources sdncNetworkResources; + @Autowired + private Environment env; public void assignServiceInstance(BuildingBlockExecution execution) { try { @@ -79,7 +85,7 @@ public class SDNCAssignTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.SERVICE); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -99,7 +105,7 @@ public class SDNCAssignTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VNF); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -121,12 +127,15 @@ public class SDNCAssignTasks { } Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.assignVfModule(vfModule, - volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext); SDNCRequest sdncRequest = new SDNCRequest(); + UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) + .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); + URI uri = builder.build(); + GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.assignVfModule(vfModule, + volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, uri); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VFMODULE); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -152,7 +161,7 @@ public class SDNCAssignTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.NETWORK); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java index 50cf0fb074..acf48acdda 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import java.net.URI; +import javax.ws.rs.core.UriBuilder; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; @@ -43,10 +45,12 @@ import org.onap.so.client.orchestration.SDNCVnfResources; import org.onap.so.client.sdnc.beans.SDNCRequest; import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component public class SDNCChangeAssignTasks { + public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired private SDNCNetworkResources sdncNetworkResources; @Autowired @@ -59,6 +63,8 @@ public class SDNCChangeAssignTasks { private ExceptionBuilder exceptionUtil; @Autowired private SDNCVfModuleResources sdncVfModuleResources; + @Autowired + private Environment env; public void changeModelServiceInstance(BuildingBlockExecution execution) { try { @@ -70,7 +76,7 @@ public class SDNCChangeAssignTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.SERVICE); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -87,7 +93,7 @@ public class SDNCChangeAssignTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VNF); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -104,7 +110,7 @@ public class SDNCChangeAssignTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.NETWORK); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -120,12 +126,15 @@ public class SDNCChangeAssignTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); Customer customer = gBBInput.getCustomer(); - GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.changeAssignVfModule(vfModule, - vnf, serviceInstance, customer, cloudRegion, requestContext); SDNCRequest sdncRequest = new SDNCRequest(); + UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) + .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); + URI uri = builder.build(); + GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.changeAssignVfModule(vfModule, + vnf, serviceInstance, customer, cloudRegion, requestContext, uri); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VFMODULE); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java index 3a1528946d..3fc25196e1 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java @@ -22,6 +22,8 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import java.net.URI; +import javax.ws.rs.core.UriBuilder; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; @@ -47,11 +49,13 @@ import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component public class SDNCDeactivateTasks { - private static final Logger logger = LoggerFactory.getLogger(SDNCDeactivateTasks.class); + + public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired private SDNCNetworkResources sdncNetworkResources; @Autowired @@ -64,6 +68,8 @@ public class SDNCDeactivateTasks { private ExceptionBuilder exceptionUtil; @Autowired private ExtractPojosForBB extractPojosForBB; + @Autowired + private Environment env; public void deactivateVfModule(BuildingBlockExecution execution) { try { @@ -75,12 +81,15 @@ public class SDNCDeactivateTasks { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.deactivateVfModule(vfModule, vnf, - serviceInstance, customer, cloudRegion, requestContext); SDNCRequest sdncRequest = new SDNCRequest(); + UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) + .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); + URI uri = builder.build(); + GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.deactivateVfModule(vfModule, vnf, + serviceInstance, customer, cloudRegion, requestContext, uri); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VFMODULE); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -107,7 +116,7 @@ public class SDNCDeactivateTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VNF); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -132,7 +141,7 @@ public class SDNCDeactivateTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.SERVICE); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -157,7 +166,7 @@ public class SDNCDeactivateTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.NETWORK); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java index 7ae6117c61..fcc67d0ef7 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java @@ -39,7 +39,8 @@ import org.springframework.stereotype.Component; @Component public class SDNCQueryTasks { - private static final Logger logger = LoggerFactory.getLogger(SDNCQueryTasks.class); + + public static final String SDNCQUERY_RESPONSE = "SDNCQueryResponse_"; @Autowired private SDNCVnfResources sdncVnfResources; @Autowired @@ -61,7 +62,7 @@ public class SDNCQueryTasks { genericVnf.setSelflink(selfLink); } String response = sdncVnfResources.queryVnf(genericVnf); - execution.setVariable("SDNCQueryResponse_" + genericVnf.getVnfId(), response); + execution.setVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId(), response); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -82,7 +83,7 @@ public class SDNCQueryTasks { } if (vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) { String response = sdncVfModuleResources.queryVfModule(vfModule); - execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), response); + execution.setVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId(), response); } else { throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value"); @@ -97,7 +98,7 @@ public class SDNCQueryTasks { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); if (vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) { String response = sdncVfModuleResources.queryVfModule(vfModule); - execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), response); + execution.setVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId(), response); } else { throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java index f32ffd72c3..cb761f4110 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java @@ -21,8 +21,13 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import java.io.StringReader; +import java.io.StringWriter; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathFactory; import org.camunda.bpm.engine.delegate.DelegateExecution; @@ -98,12 +103,18 @@ public class SDNCRequestTasks { Document doc = db.parse(new InputSource(new StringReader(asyncRequest))); String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator"); + boolean isCallbackCompleted = convertIndicatorToBoolean(finalMessageIndicator); execution.setVariable(IS_CALLBACK_COMPLETED, isCallbackCompleted); if (isCallbackCompleted) { String responseCode = getXmlElement(doc, "/input/response-code"); - String responseMessage = getXmlElement(doc, "/input/response-message"); if (!SDNC_SUCCESS.equalsIgnoreCase(responseCode)) { + String responseMessage; + try { + responseMessage = getXmlElement(doc, "/input/response-message"); + } catch (Exception e) { + responseMessage = "Unknown Error in SDNC"; + } throw new SDNCErrorResponseException(responseMessage); } } @@ -126,8 +137,17 @@ public class SDNCRequestTasks { } protected String getXmlElement(Document doc, String exp) throws Exception { + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + StringWriter writer = new StringWriter(); + transformer.transform(new DOMSource(doc), new StreamResult(writer)); + logger.debug(writer.getBuffer().toString()); XPath xPath = XPathFactory.newInstance().newXPath(); - return xPath.evaluate(exp, doc); + String result = xPath.evaluate(exp, doc); + if (result == null || result.isEmpty()) { + throw new Exception("XPath Failed to find element expression: " + exp); + } + return result; } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java index e9848d1646..7d5591af0f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java @@ -22,6 +22,8 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; +import java.net.URI; +import javax.ws.rs.core.UriBuilder; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; @@ -47,11 +49,13 @@ import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component public class SDNCUnassignTasks { - private static final Logger logger = LoggerFactory.getLogger(SDNCUnassignTasks.class); + + public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired private SDNCServiceInstanceResources sdncSIResources; @Autowired @@ -64,6 +68,8 @@ public class SDNCUnassignTasks { private ExtractPojosForBB extractPojosForBB; @Autowired private SDNCNetworkResources sdncNetworkResources; + @Autowired + private Environment env; public void unassignServiceInstance(BuildingBlockExecution execution) { try { @@ -77,7 +83,7 @@ public class SDNCUnassignTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.SERVICE); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -89,12 +95,15 @@ public class SDNCUnassignTasks { extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); - GenericResourceApiVfModuleOperationInformation req = - sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance); SDNCRequest sdncRequest = new SDNCRequest(); + UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) + .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); + URI uri = builder.build(); + GenericResourceApiVfModuleOperationInformation req = + sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance, uri); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VFMODULE); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -114,7 +123,7 @@ public class SDNCUnassignTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VNF); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -136,7 +145,7 @@ public class SDNCUnassignTasks { SDNCRequest sdncRequest = new SDNCRequest(); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.NETWORK); - execution.setVariable("SDNCRequest", sdncRequest); + execution.setVariable(SDNC_REQUEST, sdncRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java index 47855eaa6e..fc3f2aec7a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/validations/CloudRegionOrchestrationValidator.java @@ -23,8 +23,8 @@ package org.onap.so.bpmn.infrastructure.validations; import java.util.Optional; import java.util.regex.Pattern; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.validation.PreBuildingBlockValidator; -import org.onap.so.bpmn.common.validation.Skip; +import org.onap.so.bpmn.common.listener.Skip; +import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.client.exception.ExceptionBuilder; import org.slf4j.Logger; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java new file mode 100644 index 0000000000..1852485083 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java @@ -0,0 +1,155 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Samsung Electronics Co., Ltd. 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +import java.util.List; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; +import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; + +public class ConfigBuildingBlocksDataObject { + + private ServiceInstancesRequest sIRequest; + private List<OrchestrationFlow> orchFlows; + private String requestId; + private Resource resourceKey; + private String apiVersion; + private String resourceId; + private String requestAction; + private boolean aLaCarte; + private String vnfType; + private WorkflowResourceIds workflowResourceIds; + private RequestDetails requestDetails; + private DelegateExecution execution; + + public ServiceInstancesRequest getsIRequest() { + return sIRequest; + } + + public ConfigBuildingBlocksDataObject setsIRequest(ServiceInstancesRequest sIRequest) { + this.sIRequest = sIRequest; + return this; + } + + public List<OrchestrationFlow> getOrchFlows() { + return orchFlows; + } + + public ConfigBuildingBlocksDataObject setOrchFlows(List<OrchestrationFlow> orchFlows) { + this.orchFlows = orchFlows; + return this; + } + + public String getRequestId() { + return requestId; + } + + public ConfigBuildingBlocksDataObject setRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public Resource getResourceKey() { + return resourceKey; + } + + public ConfigBuildingBlocksDataObject setResourceKey(Resource resourceKey) { + this.resourceKey = resourceKey; + return this; + } + + public String getApiVersion() { + return apiVersion; + } + + public ConfigBuildingBlocksDataObject setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + return this; + } + + public String getResourceId() { + return resourceId; + } + + public ConfigBuildingBlocksDataObject setResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + public String getRequestAction() { + return requestAction; + } + + public ConfigBuildingBlocksDataObject setRequestAction(String requestAction) { + this.requestAction = requestAction; + return this; + } + + public boolean isaLaCarte() { + return aLaCarte; + } + + public ConfigBuildingBlocksDataObject setaLaCarte(boolean aLaCarte) { + this.aLaCarte = aLaCarte; + return this; + } + + public String getVnfType() { + return vnfType; + } + + public ConfigBuildingBlocksDataObject setVnfType(String vnfType) { + this.vnfType = vnfType; + return this; + } + + public WorkflowResourceIds getWorkflowResourceIds() { + return workflowResourceIds; + } + + public ConfigBuildingBlocksDataObject setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) { + this.workflowResourceIds = workflowResourceIds; + return this; + } + + public RequestDetails getRequestDetails() { + return requestDetails; + } + + public ConfigBuildingBlocksDataObject setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + return this; + } + + public DelegateExecution getExecution() { + return execution; + } + + public ConfigBuildingBlocksDataObject setExecution(DelegateExecution execution) { + this.execution = execution; + return this; + } + + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfBondingServiceException.java index 6d81cba41d..0584472e14 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfBondingServiceException.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 - 2019 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. @@ -18,11 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.infrastructure.sdnc.tasks; +package org.onap.so.bpmn.infrastructure.workflow.tasks; -import org.springframework.stereotype.Component; - -@Component -public class SDNCDeleteTasks { +public class VrfBondingServiceException extends Exception { + /** + * + */ + private static final long serialVersionUID = -4277883464681291740L; + public VrfBondingServiceException(String errorMessage) { + super(errorMessage); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java new file mode 100644 index 0000000000..1e0208b6ec --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java @@ -0,0 +1,163 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +import java.util.List; +import java.util.Optional; +import org.onap.aai.domain.yang.L3Network; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class VrfValidation { + + @Autowired + protected BBInputSetupUtils bbInputSetupUtils; + + public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) { + this.bbInputSetupUtils = bbInputSetupUtils; + } + + protected void vrfServiceValidation(org.onap.so.db.catalog.beans.Service service) + throws VrfBondingServiceException { + if (!"BONDING".equalsIgnoreCase(service.getServiceType()) + || !"INFRASTRUCTURE-VPN".equalsIgnoreCase(service.getServiceRole())) { + throw new VrfBondingServiceException("Service: " + service.getModelName() + + " does not have service type of BONDING and does not have service role of INFRASTRUCTURE-VPN"); + } + } + + protected void vrfCatalogDbChecks(org.onap.so.db.catalog.beans.Service service) throws VrfBondingServiceException { + ConfigurationResourceCustomization configuration = getVrfConfiguration(service); + if (configuration == null || configuration.getServiceProxyResourceCustomization() == null + || configuration.getServiceProxyResourceCustomization().getSourceService() == null + || !configuration.getServiceProxyResourceCustomization().getSourceService().getServiceType() + .equalsIgnoreCase("TRANSPORT")) { + throw new VrfBondingServiceException("Service: " + service.getModelName() + + " does not have a configuration of type VRF-ENTRY and role INFRASTRUCTURE-CLOUD-VPN" + + ", and serviceProxy that does not have source service that has a serviceType of TRANSPORT)"); + } + } + + protected ConfigurationResourceCustomization getVrfConfiguration(org.onap.so.db.catalog.beans.Service service) { + for (ConfigurationResourceCustomization configuration : service.getConfigurationCustomizations()) { + if (configuration.getType() != null && configuration.getType().equalsIgnoreCase("VRF-ENTRY") + && configuration.getRole() != null + && configuration.getRole().equalsIgnoreCase("INFRASTRUCTURE-CLOUD-VPN")) { + return configuration; + } + } + return null; + } + + protected void aaiVpnBindingValidation(String relatedVpnId, org.onap.aai.domain.yang.VpnBinding aaiVpnBinding) + throws VrfBondingServiceException { + if (aaiVpnBinding == null) { + throw new VrfBondingServiceException("The infrastructure vpn " + relatedVpnId + " does not exist in A&AI."); + } else if (aaiVpnBinding.getVpnType() != null + && !aaiVpnBinding.getVpnType().equalsIgnoreCase("SERVICE-INFRASTRUCTURE")) { + throw new VrfBondingServiceException( + "VpnBinding: " + relatedVpnId + " does not have a vpn type of SERVICE-INFRASTRUCTURE."); + } + } + + protected void aaiAggregateRouteValidation(org.onap.aai.domain.yang.L3Network aaiLocalNetwork) + throws VrfBondingServiceException { + if (aaiLocalNetwork.getAggregateRoutes() == null + || aaiLocalNetwork.getAggregateRoutes().getAggregateRoute() == null) { + return; + } + if (aaiLocalNetwork.getAggregateRoutes().getAggregateRoute().size() == 1 && !aaiLocalNetwork + .getAggregateRoutes().getAggregateRoute().get(0).getIpVersion().equalsIgnoreCase("4")) { + throw new VrfBondingServiceException("LocalNetwork: " + aaiLocalNetwork.getNetworkId() + + " has 1 aggregate route but the Ip version of aggregate route is : " + + aaiLocalNetwork.getAggregateRoutes().getAggregateRoute().get(0).getIpVersion() + " and is not 4"); + } else if (aaiLocalNetwork.getAggregateRoutes().getAggregateRoute().size() == 2 + && !ipVersionValidation(aaiLocalNetwork.getAggregateRoutes().getAggregateRoute().get(0).getIpVersion(), + aaiLocalNetwork.getAggregateRoutes().getAggregateRoute().get(1).getIpVersion())) { + throw new VrfBondingServiceException("LocalNetwork: " + aaiLocalNetwork.getNetworkId() + + " has 2 aggregate routes but the combination of the Ip versions for the aggregate routes did not match the ip version of one of them to be 4 and one to be 6"); + } else if (aaiLocalNetwork.getAggregateRoutes().getAggregateRoute().size() > 2) { + throw new VrfBondingServiceException( + "LocalNetwork: " + aaiLocalNetwork.getNetworkId() + " either has more than 2 aggregate routes"); + } + } + + protected void aaiNetworkValidation(String relatedNetworkid, org.onap.aai.domain.yang.L3Network aaiLocalNetwork) + throws VrfBondingServiceException { + if (aaiLocalNetwork == null) { + throw new VrfBondingServiceException("The local network " + relatedNetworkid + " does not exist in A&AI."); + } + } + + protected void aaiSubnetValidation(org.onap.aai.domain.yang.L3Network aaiLocalNetwork) + throws VrfBondingServiceException { + if (aaiLocalNetwork.getSubnets() == null || aaiLocalNetwork.getSubnets().getSubnet() == null) { + throw new VrfBondingServiceException("LocalNetwork: " + aaiLocalNetwork.getNetworkId() + " has no subnets"); + } else if (aaiLocalNetwork.getSubnets().getSubnet().size() == 1 + && !aaiLocalNetwork.getSubnets().getSubnet().get(0).getIpVersion().equalsIgnoreCase("4")) { + throw new VrfBondingServiceException("LocalNetwork: " + aaiLocalNetwork.getNetworkId() + + " has 1 subnet but the Ip version of subnet is : " + + aaiLocalNetwork.getSubnets().getSubnet().get(0).getIpVersion() + " and is not 4"); + } else if (aaiLocalNetwork.getSubnets().getSubnet().size() == 2 + && !ipVersionValidation(aaiLocalNetwork.getSubnets().getSubnet().get(0).getIpVersion(), + aaiLocalNetwork.getSubnets().getSubnet().get(1).getIpVersion())) { + throw new VrfBondingServiceException("LocalNetwork: " + aaiLocalNetwork.getNetworkId() + + " has 2 subnets but the combination of the Ip versions for the subnets did not match the ip version of one of them to be 4 and one to be 6"); + } else if (aaiLocalNetwork.getSubnets().getSubnet().isEmpty() + || aaiLocalNetwork.getSubnets().getSubnet().size() > 2) { + throw new VrfBondingServiceException("LocalNetwork: " + aaiLocalNetwork.getNetworkId() + + " either has no subnets or more than 2 subnets"); + } + } + + protected boolean ipVersionValidation(String ipVersion1, String ipVersion2) { + return (ipVersion1.equalsIgnoreCase("4") && ipVersion2.equalsIgnoreCase("6")) + || (ipVersion1.equalsIgnoreCase("6") && ipVersion2.equalsIgnoreCase("4")); + } + + protected void aaiRouteTargetValidation(L3Network aaiLocalNetwork) throws VrfBondingServiceException { + AAIResultWrapper networkWrapper = new AAIResultWrapper(aaiLocalNetwork); + if (networkWrapper.getRelationships().isPresent()) { + List<AAIResourceUri> vpnBindingUris = + networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING); + if (!vpnBindingUris.isEmpty()) { + Optional<org.onap.aai.domain.yang.VpnBinding> vpnBindingOp = + bbInputSetupUtils.getAAIResourceDepthOne(vpnBindingUris.get(0)) + .asBean(org.onap.aai.domain.yang.VpnBinding.class); + if (vpnBindingOp.isPresent()) { + org.onap.aai.domain.yang.VpnBinding vpnBinding = vpnBindingOp.get(); + if (vpnBinding.getRouteTargets() != null + && !vpnBinding.getRouteTargets().getRouteTarget().isEmpty()) { + return; + } + } + } + } + throw new VrfBondingServiceException("The Local Network: " + aaiLocalNetwork.getNetworkId() + + " does not have vpn binding and/or RT information"); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 94209908be..fffaee0f7c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -35,13 +35,14 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; -import org.slf4j.LoggerFactory; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.Vnfc; import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.aai.domain.yang.VpnBinding; +import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; @@ -61,9 +62,11 @@ import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; +import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; -import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -78,9 +81,11 @@ import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.VfModules; import org.onap.so.serviceinstancebeans.Vnfs; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @Component @@ -91,15 +96,6 @@ public class WorkflowAction { private static final String VF_MODULES = "vfModules"; private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI = "WorkflowAction was unable to verify if the instance name already exist in AAI."; - private static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow"; - private static final String G_ACTION = "requestAction"; - private static final String G_CURRENT_SEQUENCE = "gCurrentSequence"; - private static final String G_REQUEST_ID = "mso-request-id"; - private static final String G_BPMN_REQUEST = "bpmnRequest"; - private static final String G_ALACARTE = "aLaCarte"; - private static final String G_APIVERSION = "apiVersion"; - private static final String G_URI = "requestUri"; - private static final String G_ISTOPLEVELFLOW = "isTopLevelFlow"; private static final String VNF_TYPE = "vnfType"; private static final String SERVICE = "Service"; private static final String VNF = "Vnf"; @@ -115,8 +111,8 @@ public class WorkflowAction { "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances|instanceGroups"; private static final String HOMINGSOLUTION = "Homing_Solution"; private static final String FABRIC_CONFIGURATION = "FabricConfiguration"; - private static final String G_SERVICE_TYPE = "serviceType"; private static final String SERVICE_TYPE_TRANSPORT = "TRANSPORT"; + private static final String SERVICE_TYPE_BONDING = "BONDING"; private static final String CLOUD_OWNER = "DEFAULT"; private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @@ -132,6 +128,8 @@ public class WorkflowAction { private AAIConfigurationResources aaiConfigurationResources; @Autowired private WorkflowActionExtractResourcesAAI workflowActionUtils; + @Autowired + private VrfValidation vrfValidation; @Autowired private Environment environment; @@ -146,17 +144,19 @@ public class WorkflowAction { } public void selectExecutionList(DelegateExecution execution) throws Exception { - final String requestAction = (String) execution.getVariable(G_ACTION); - final String requestId = (String) execution.getVariable(G_REQUEST_ID); - final String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST); - final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); - final String apiVersion = (String) execution.getVariable(G_APIVERSION); - final String uri = (String) execution.getVariable(G_URI); + final String requestAction = (String) execution.getVariable(BBConstants.G_ACTION); + final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID); + final String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST); + final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE); + final String apiVersion = (String) execution.getVariable(BBConstants.G_APIVERSION); + final String uri = (String) execution.getVariable(BBConstants.G_URI); final String vnfType = (String) execution.getVariable(VNF_TYPE); String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); - final String serviceType = Optional.ofNullable((String) execution.getVariable(G_SERVICE_TYPE)).orElse(""); + final String serviceType = + Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse(""); - List<OrchestrationFlow> orchFlows = (List<OrchestrationFlow>) execution.getVariable(G_ORCHESTRATION_FLOW); + List<OrchestrationFlow> orchFlows = + (List<OrchestrationFlow>) execution.getVariable(BBConstants.G_ORCHESTRATION_FLOW); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution); List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); @@ -167,7 +167,7 @@ public class WorkflowAction { try { ObjectMapper mapper = new ObjectMapper(); - execution.setVariable(G_ISTOPLEVELFLOW, true); + execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, true); ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); RequestDetails requestDetails = sIRequest.getRequestDetails(); String cloudOwner = ""; @@ -217,9 +217,13 @@ public class WorkflowAction { boolean isConfiguration = isConfiguration(orchFlows); Resource resourceKey = new Resource(resourceType, key, aLaCarte); if (isConfiguration && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) { - List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks(sIRequest, orchFlows, - requestId, resourceKey, apiVersion, resourceId, requestAction, aLaCarte, vnfType, - workflowResourceIds, requestDetails, execution); + List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks( + new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) + .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte) + .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds) + .setRequestDetails(requestDetails).setExecution(execution)); + flowsToExecute.addAll(configBuildingBlocks); } orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)) @@ -271,7 +275,7 @@ public class WorkflowAction { foundRelated = traverseUserParamsService(execution, resourceCounter, sIRequest, requestAction); } if (!foundRelated) { - traverseCatalogDbService(execution, sIRequest, resourceCounter); + traverseCatalogDbService(execution, sIRequest, resourceCounter, aaiResourceIds); } } else if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase("activateInstance") || requestAction.equalsIgnoreCase("unassignInstance") @@ -328,7 +332,8 @@ public class WorkflowAction { } } - // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, + // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is + // specified, // enable it. if (sIRequest.getRequestDetails().getRequestParameters() != null && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { @@ -355,14 +360,14 @@ public class WorkflowAction { flowNames.add(ebb.getBuildingBlock().getBpmnFlowName()); } execution.setVariable("flowNames", flowNames); - execution.setVariable(G_CURRENT_SEQUENCE, 0); + execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, 0); execution.setVariable("retryCount", 0); execution.setVariable("isRollback", false); execution.setVariable("flowsToExecute", flowsToExecute); execution.setVariable("isRollbackComplete", false); } catch (Exception ex) { - buildAndThrowException(execution, "Exception in create execution list " + ex.getMessage(), ex); + buildAndThrowException(execution, "Exception in create execution list. " + ex.getMessage(), ex); } } @@ -423,17 +428,14 @@ public class WorkflowAction { return false; } - protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ServiceInstancesRequest sIRequest, - List<OrchestrationFlow> orchFlows, String requestId, Resource resourceKey, String apiVersion, - String resourceId, String requestAction, boolean aLaCarte, String vnfType, - WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, DelegateExecution execution) { + protected List<ExecuteBuildingBlock> getConfigBuildingBlocks(ConfigBuildingBlocksDataObject dataObj) { List<ExecuteBuildingBlock> flowsToExecuteConfigs = new ArrayList<>(); - List<OrchestrationFlow> result = new ArrayList<>(orchFlows); - result = orchFlows.stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)) + List<OrchestrationFlow> result = new ArrayList<>(dataObj.getOrchFlows()); + result = dataObj.getOrchFlows().stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)) .collect(Collectors.toList()); - String vnfId = workflowResourceIds.getVnfId(); - String vfModuleId = workflowResourceIds.getVfModuleId(); + String vnfId = dataObj.getWorkflowResourceIds().getVnfId(); + String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId(); String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(); String vfModuleCustomizationUUID = @@ -447,21 +449,22 @@ public class WorkflowAction { if (configurations.size() > 1) { String multipleRelationshipsError = "Multiple relationships exist from VNFC " + vnfc.getVnfcName() + " to Configurations"; - buildAndThrowException(execution, multipleRelationshipsError, + buildAndThrowException(dataObj.getExecution(), multipleRelationshipsError, new Exception(multipleRelationshipsError)); } for (org.onap.aai.domain.yang.Configuration configuration : configurations) { - workflowResourceIds.setConfigurationId(configuration.getConfigurationId()); + dataObj.getWorkflowResourceIds().setConfigurationId(configuration.getConfigurationId()); for (OrchestrationFlow orchFlow : result) { - resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID); - resourceKey.setCvnfModuleCustomizationId(vnfc.getModelCustomizationId()); - resourceKey.setVnfCustomizationId(vnfCustomizationUUID); - ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, - resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, - null, true); + dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID); + dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId()); + dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID); + ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), + dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), + dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), + dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, true); String vnfcName = getVnfcNameForConfiguration(configuration); if (vnfcName == null || vnfcName.isEmpty()) { - buildAndThrowException(execution, "Exception in create execution list " + buildAndThrowException(dataObj.getExecution(), "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match")); } @@ -617,97 +620,179 @@ public class WorkflowAction { } protected void traverseCatalogDbService(DelegateExecution execution, ServiceInstancesRequest sIRequest, - List<Resource> resourceCounter) { + List<Resource> resourceCounter, List<Pair<WorkflowType, String>> aaiResourceIds) + throws JsonProcessingException, VrfBondingServiceException { String modelUUID = sIRequest.getRequestDetails().getModelInfo().getModelVersionId(); org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(modelUUID); if (service == null) { buildAndThrowException(execution, "Could not find the service model in catalog db."); } else { resourceCounter.add(new Resource(WorkflowType.SERVICE, service.getModelUUID(), false)); - if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) { - List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); - if (customizations.isEmpty()) { - logger.debug("No Collections found. CollectionResourceCustomization list is empty."); - } else { - CollectionResourceCustomization collectionResourceCustomization = - findCatalogNetworkCollection(execution, service); - if (collectionResourceCustomization != null) { - resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION, - collectionResourceCustomization.getModelCustomizationUUID(), false)); - logger.debug("Found a network collection"); - if (collectionResourceCustomization.getCollectionResource() != null) { - if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null) { - String toscaNodeType = collectionResourceCustomization.getCollectionResource() - .getInstanceGroup().getToscaNodeType(); - if (toscaNodeType != null && toscaNodeType.contains("NetworkCollection")) { - int minNetworks = 0; - org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = - collectionResourceCustomization.getCollectionResource().getInstanceGroup(); - CollectionResourceInstanceGroupCustomization collectionInstCust = null; - if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) { - for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup - .getCollectionInstanceGroupCustomizations()) { - if (collectionInstanceGroupTemp.getModelCustomizationUUID() - .equalsIgnoreCase(collectionResourceCustomization - .getModelCustomizationUUID())) { - collectionInstCust = collectionInstanceGroupTemp; - break; - } - } - if (collectionInstCust != null - && collectionInstCust.getSubInterfaceNetworkQuantity() != null) { - minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); - } - } - logger.debug("minNetworks: {}", minNetworks); - CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; - for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup - .getCollectionNetworkResourceCustomizations()) { - if (collectionNetworkTemp.getNetworkResourceCustomization() - .getModelCustomizationUUID().equalsIgnoreCase( - collectionResourceCustomization.getModelCustomizationUUID())) { - collectionNetworkResourceCust = collectionNetworkTemp; + RelatedInstance relatedVpnBinding = + bbInputSetupUtils.getRelatedInstanceByType(sIRequest.getRequestDetails(), ModelType.vpnBinding); + RelatedInstance relatedLocalNetwork = + bbInputSetupUtils.getRelatedInstanceByType(sIRequest.getRequestDetails(), ModelType.network); + if (relatedVpnBinding != null && relatedLocalNetwork != null) { + traverseVrfConfiguration(execution, aaiResourceIds, resourceCounter, service, relatedVpnBinding, + relatedLocalNetwork); + } else { + traverseNetworkCollection(execution, resourceCounter, service); + } + } + } + + protected void traverseVrfConfiguration(DelegateExecution execution, + List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceCounter, + org.onap.so.db.catalog.beans.Service service, RelatedInstance relatedVpnBinding, + RelatedInstance relatedLocalNetwork) throws VrfBondingServiceException, JsonProcessingException { + org.onap.aai.domain.yang.L3Network aaiLocalNetwork = + bbInputSetupUtils.getAAIL3Network(relatedLocalNetwork.getInstanceId()); + vrfValidation.vrfServiceValidation(service); + vrfValidation.vrfCatalogDbChecks(service); + vrfValidation.aaiVpnBindingValidation(relatedVpnBinding.getInstanceId(), + bbInputSetupUtils.getAAIVpnBinding(relatedVpnBinding.getInstanceId())); + vrfValidation.aaiNetworkValidation(relatedLocalNetwork.getInstanceId(), aaiLocalNetwork); + vrfValidation.aaiSubnetValidation(aaiLocalNetwork); + vrfValidation.aaiAggregateRouteValidation(aaiLocalNetwork); + vrfValidation.aaiRouteTargetValidation(aaiLocalNetwork); + String existingAAIVrfConfiguration = getExistingAAIVrfConfiguration(relatedVpnBinding, aaiLocalNetwork); + if (existingAAIVrfConfiguration != null) { + aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration)); + } + resourceCounter.add(new Resource(WorkflowType.CONFIGURATION, + service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false)); + + } + + protected String getExistingAAIVrfConfiguration(RelatedInstance relatedVpnBinding, + org.onap.aai.domain.yang.L3Network aaiLocalNetwork) + throws JsonProcessingException, VrfBondingServiceException { + Optional<Relationships> relationshipsOp = new AAIResultWrapper( + new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiLocalNetwork)).getRelationships(); + if (relationshipsOp.isPresent()) { + List<AAIResultWrapper> configurationsRelatedToLocalNetwork = + relationshipsOp.get().getByType(AAIObjectType.CONFIGURATION); + if (configurationsRelatedToLocalNetwork.size() > 1) { + throw new VrfBondingServiceException( + "Network: " + aaiLocalNetwork.getNetworkId() + " has more than 1 configuration related to it"); + } + if (configurationsRelatedToLocalNetwork.size() == 1) { + AAIResultWrapper configWrapper = configurationsRelatedToLocalNetwork.get(0); + Optional<Configuration> relatedConfiguration = configWrapper.asBean(Configuration.class); + if (relatedConfiguration.isPresent() && vrfConfigurationAlreadyExists(relatedVpnBinding, + relatedConfiguration.get(), configWrapper)) { + return relatedConfiguration.get().getConfigurationId(); + } + } + } + return null; + } + + protected boolean vrfConfigurationAlreadyExists(RelatedInstance relatedVpnBinding, Configuration vrfConfiguration, + AAIResultWrapper configWrapper) throws VrfBondingServiceException { + if (vrfConfiguration.getConfigurationType().equalsIgnoreCase("VRF-ENTRY")) { + Optional<Relationships> relationshipsConfigOp = configWrapper.getRelationships(); + if (relationshipsConfigOp.isPresent()) { + Optional<VpnBinding> relatedInfraVpnBindingOp = + workflowActionUtils.extractRelationshipsVpnBinding(relationshipsConfigOp.get()); + if (relatedInfraVpnBindingOp.isPresent()) { + VpnBinding relatedInfraVpnBinding = relatedInfraVpnBindingOp.get(); + if (!relatedInfraVpnBinding.getVpnId().equalsIgnoreCase(relatedVpnBinding.getInstanceId())) { + throw new VrfBondingServiceException("Configuration: " + vrfConfiguration.getConfigurationId() + + " is not connected to the same vpn binding id provided in request: " + + relatedVpnBinding.getInstanceId()); + } else { + return true; + } + } + } + } + return false; + } + + protected void traverseNetworkCollection(DelegateExecution execution, List<Resource> resourceCounter, + org.onap.so.db.catalog.beans.Service service) { + if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) { + List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); + if (customizations.isEmpty()) { + logger.debug("No Collections found. CollectionResourceCustomization list is empty."); + } else { + CollectionResourceCustomization collectionResourceCustomization = + findCatalogNetworkCollection(execution, service); + if (collectionResourceCustomization != null) { + resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION, + collectionResourceCustomization.getModelCustomizationUUID(), false)); + logger.debug("Found a network collection"); + if (collectionResourceCustomization.getCollectionResource() != null) { + if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null) { + String toscaNodeType = collectionResourceCustomization.getCollectionResource() + .getInstanceGroup().getToscaNodeType(); + if (toscaNodeType != null && toscaNodeType.contains("NetworkCollection")) { + int minNetworks = 0; + org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = + collectionResourceCustomization.getCollectionResource().getInstanceGroup(); + CollectionResourceInstanceGroupCustomization collectionInstCust = null; + if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) { + for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup + .getCollectionInstanceGroupCustomizations()) { + if (collectionInstanceGroupTemp.getModelCustomizationUUID().equalsIgnoreCase( + collectionResourceCustomization.getModelCustomizationUUID())) { + collectionInstCust = collectionInstanceGroupTemp; break; } } - for (int i = 0; i < minNetworks; i++) { - if (collectionNetworkResourceCust != null && collectionInstCust != null) { - Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, - collectionNetworkResourceCust.getModelCustomizationUUID(), false); - resource.setVirtualLinkKey(Integer.toString(i)); - resourceCounter.add(resource); - } + if (collectionInstCust != null + && collectionInstCust.getSubInterfaceNetworkQuantity() != null) { + minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); + } + } + logger.debug("minNetworks: {}", minNetworks); + CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; + for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup + .getCollectionNetworkResourceCustomizations()) { + if (collectionNetworkTemp.getNetworkResourceCustomization() + .getModelCustomizationUUID().equalsIgnoreCase( + collectionResourceCustomization.getModelCustomizationUUID())) { + collectionNetworkResourceCust = collectionNetworkTemp; + break; + } + } + for (int i = 0; i < minNetworks; i++) { + if (collectionNetworkResourceCust != null && collectionInstCust != null) { + Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, + collectionNetworkResourceCust.getModelCustomizationUUID(), false); + resource.setVirtualLinkKey(Integer.toString(i)); + resourceCounter.add(resource); } - } else { - logger.debug( - "Instance Group tosca node type does not contain NetworkCollection: {}", - toscaNodeType); } } else { - logger.debug("No Instance Group found for network collection."); + logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}", + toscaNodeType); } } else { - logger.debug("No Network Collection found. collectionResource is null"); + logger.debug("No Instance Group found for network collection."); } } else { - logger.debug("No Network Collection Customization found"); + logger.debug("No Network Collection found. collectionResource is null"); } + } else { + logger.debug("No Network Collection Customization found"); } - if (resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) - .collect(Collectors.toList()).isEmpty()) { - if (service.getNetworkCustomizations() == null) { - logger.debug("No networks were found on this service model"); - } else { - for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { - resourceCounter.add(new Resource(WorkflowType.NETWORK, - service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false)); - } + } + if (resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) + .collect(Collectors.toList()).isEmpty()) { + if (service.getNetworkCustomizations() == null) { + logger.debug("No networks were found on this service model"); + } else { + for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { + resourceCounter.add(new Resource(WorkflowType.NETWORK, + service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false)); } } - } else { - buildAndThrowException(execution, - "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows"); } + } else { + buildAndThrowException(execution, + "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows"); } } @@ -760,7 +845,8 @@ public class WorkflowAction { aaiConfigurationResources.getConfiguration(config.getConfigurationId()); if (aaiConfig.isPresent() && aaiConfig.get().getRelationshipList() != null) { for (Relationship relationship : aaiConfig.get().getRelationshipList().getRelationship()) { - if (relationship.getRelatedTo().contains("vnfc")) { + if (relationship.getRelatedTo().contains("vnfc") + || relationship.getRelatedTo().contains("vpn-binding")) { aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, config.getConfigurationId())); resourceCounter.add( @@ -1316,7 +1402,8 @@ public class WorkflowAction { WorkflowType resourceName, boolean aLaCarte, String cloudOwner, String serviceType) { List<OrchestrationFlow> listToExecute = new ArrayList<>(); NorthBoundRequest northBoundRequest = null; - if (serviceType.equalsIgnoreCase(SERVICE_TYPE_TRANSPORT)) { + if (serviceType.equalsIgnoreCase(SERVICE_TYPE_TRANSPORT) + || serviceType.equalsIgnoreCase(SERVICE_TYPE_BONDING)) { northBoundRequest = catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType( requestAction, resourceName.toString(), aLaCarte, cloudOwner, serviceType); @@ -1338,7 +1425,7 @@ public class WorkflowAction { } } else { if (northBoundRequest.getIsToplevelflow() != null) { - execution.setVariable(G_ISTOPLEVELFLOW, northBoundRequest.getIsToplevelflow()); + execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, northBoundRequest.getIsToplevelflow()); } List<OrchestrationFlow> flows = northBoundRequest.getOrchestrationFlowList(); if (flows == null) 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..35ceef0473 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,9 @@ public class WorkflowActionBBFailure { errorMsg = "Failed to determine error message"; } request.setStatusMessage(errorMsg); + request.setProgress(Long.valueOf(100)); + request.setLastModifiedBy("CamundaBPMN"); + request.setEndTime(new Timestamp(System.currentTimeMillis())); requestDbclient.updateInfraActiveRequests(request); } catch (Exception e) { logger.error( @@ -113,6 +117,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 8ec283032f..44152fcaf4 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. @@ -27,6 +27,8 @@ import java.util.UUID; import javax.persistence.EntityNotFoundException; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.aai.domain.yang.Vnfc; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse; import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; @@ -77,41 +79,19 @@ public class WorkflowActionBBTasks { private BBInputSetupUtils bbInputSetupUtils; @Autowired private CatalogDbClient catalogDbClient; + @Autowired + private FlowManipulatorListenerRunner flowManipulatorListenerRunner; public void selectBB(DelegateExecution execution) { List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); execution.setVariable("MacroRollback", false); - int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); - ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence); - if (ebb.getBuildingBlock().getBpmnFlowName().equals("ConfigAssignVnfBB") - || ebb.getBuildingBlock().getBpmnFlowName().equals("ConfigDeployVnfBB")) { - String vnfCustomizationUUID = ebb.getBuildingBlock().getKey(); + flowManipulatorListenerRunner.modifyFlows(flowsToExecute, new DelegateExecutionImpl(execution)); + int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); - List<VnfResourceCustomization> vnfResourceCustomizations = catalogDbClient - .getVnfResourceCustomizationByModelUuid(ebb.getRequestDetails().getModelInfo().getModelUuid()); - if (vnfResourceCustomizations != null && vnfResourceCustomizations.size() >= 1) { - VnfResourceCustomization vrc = catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, - vnfResourceCustomizations); - boolean skipConfigVNF = vrc.isSkipPostInstConf(); - if (skipConfigVNF) { - currentSequence++; - ebb = flowsToExecute.get(currentSequence); - } - } - } + ExecuteBuildingBlock ebb = flowsToExecute.get(currentSequence); - boolean homing = (boolean) execution.getVariable("homing"); - boolean calledHoming = (boolean) execution.getVariable("calledHoming"); - if (homing && !calledHoming) { - if (ebb.getBuildingBlock().getBpmnFlowName().equals("AssignVnfBB")) { - ebb.setHoming(true); - execution.setVariable("calledHoming", true); - } - } else { - ebb.setHoming(false); - } execution.setVariable("buildingBlock", ebb); currentSequence++; if (currentSequence >= flowsToExecute.size()) { @@ -226,11 +206,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/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java index 99ae2e7495..f672aa4b59 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java @@ -22,18 +22,25 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import java.util.List; import java.util.Optional; +import org.onap.aai.domain.yang.VpnBinding; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.Relationships; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class WorkflowActionExtractResourcesAAI { private static final Logger logger = LoggerFactory.getLogger(WorkflowActionExtractResourcesAAI.class); + @Autowired + protected BBInputSetupUtils bbInputSetupUtils; + public Optional<Configuration> extractRelationshipsConfiguration(Relationships relationships) { List<AAIResultWrapper> configurations = relationships.getByType(AAIObjectType.CONFIGURATION); for (AAIResultWrapper configWrapper : configurations) { @@ -45,6 +52,18 @@ public class WorkflowActionExtractResourcesAAI { return Optional.empty(); } + public Optional<VpnBinding> extractRelationshipsVpnBinding(Relationships relationships) { + List<AAIResourceUri> configurations = relationships.getRelatedUris(AAIObjectType.VPN_BINDING); + for (AAIResourceUri vpnBindingUri : configurations) { + AAIResultWrapper vpnBindingWrapper = bbInputSetupUtils.getAAIResourceDepthOne(vpnBindingUri); + Optional<VpnBinding> vpnBinding = vpnBindingWrapper.asBean(VpnBinding.class); + if (vpnBinding.isPresent()) { + return vpnBinding; + } + } + return Optional.empty(); + } + public Optional<Relationships> extractRelationshipsVnfc(Relationships relationships) { List<AAIResultWrapper> vnfcs = relationships.getByType(AAIObjectType.VNFC); for (AAIResultWrapper vnfcWrapper : vnfcs) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java index af8f93b92b..05a51797dd 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowType.java @@ -22,9 +22,15 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; public enum WorkflowType { - SERVICE("Service"), VNF("Vnf"), VFMODULE("VfModule"), VOLUMEGROUP("VolumeGroup"), NETWORK("Network"), VIRTUAL_LINK( - "VirtualLink"), NETWORKCOLLECTION( - "NetworkCollection"), CONFIGURATION("Configuration"), INSTANCE_GROUP("InstanceGroup"); + SERVICE("Service"), + VNF("Vnf"), + VFMODULE("VfModule"), + VOLUMEGROUP("VolumeGroup"), + NETWORK("Network"), + VIRTUAL_LINK("VirtualLink"), + NETWORKCOLLECTION("NetworkCollection"), + CONFIGURATION("Configuration"), + INSTANCE_GROUP("InstanceGroup"); private final String type; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java new file mode 100644 index 0000000000..6254aae029 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/HomingListener.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; + +import java.util.List; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.springframework.stereotype.Component; + +@Component +public class HomingListener implements FlowManipulator { + + + @Override + public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { + return "AssignVnfBB".equals(currentBBName); + } + + @Override + public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, + BuildingBlockExecution execution) { + + boolean homing = (boolean) execution.getVariable("homing"); + boolean calledHoming = (boolean) execution.getVariable("calledHoming"); + if (homing && !calledHoming) { + currentBB.setHoming(true); + execution.setVariable("calledHoming", true); + } + } + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java new file mode 100644 index 0000000000..fd0de086ad --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; + +import java.util.Collections; +import java.util.List; +import org.onap.so.bpmn.common.BBConstants; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class MultiStageSkipListener implements FlowManipulator { + + @Autowired + protected BBInputSetupUtils bbInputSetupUtils; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Override + public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { + return ((boolean) execution.getVariable(BBConstants.G_ALACARTE)) && "AssignVfModuleBB".equals(currentBBName) + && isFirst; + } + + @Override + public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, + BuildingBlockExecution execution) { + String vfModuleId = currentBB.getResourceId(); + String vnfId = currentBB.getWorkflowResourceIds().getVnfId(); + org.onap.aai.domain.yang.VfModule vfModule = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId); + if (vfModule == null) { + org.onap.aai.domain.yang.GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); + if (vnf != null) { + VnfResourceCustomization vnfCust = catalogDbClient + .getVnfResourceCustomizationByModelCustomizationUUID(vnf.getModelCustomizationId()); + if (vnfCust != null && vnfCust.getMultiStageDesign() != null + && vnfCust.getMultiStageDesign().equalsIgnoreCase("true")) { + flowsToExecute.retainAll(Collections.singletonList(currentBB)); + } + } + } + + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java new file mode 100644 index 0000000000..772fca0841 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java @@ -0,0 +1,44 @@ +package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; + +import java.util.List; +import org.onap.so.bpmn.common.BBConstants; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SkipConfigVnfListener implements FlowManipulator { + + @Autowired + private CatalogDbClient catalogDbClient; + + @Override + public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { + return "ConfigAssignVnfBB".equals(currentBBName) || "ConfigDeployVnfBB".equals(currentBBName); + } + + @Override + public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, + BuildingBlockExecution execution) { + String vnfCustomizationUUID = currentBB.getBuildingBlock().getKey(); + + List<VnfResourceCustomization> vnfResourceCustomizations = catalogDbClient + .getVnfResourceCustomizationByModelUuid(currentBB.getRequestDetails().getModelInfo().getModelUuid()); + if (vnfResourceCustomizations != null && !vnfResourceCustomizations.isEmpty()) { + VnfResourceCustomization vrc = + catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vnfResourceCustomizations); + boolean skipConfigVNF = vrc.isSkipPostInstConf(); + if (skipConfigVNF) { + execution.setVariable(BBConstants.G_CURRENT_SEQUENCE, + ((int) execution.getVariable(BBConstants.G_CURRENT_SEQUENCE)) + 1); + } + } + } + + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index 4fee1f909b..173e776af9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -34,7 +34,6 @@ import org.onap.so.adapters.nwrest.ContrailNetwork; import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; -import org.onap.so.adapters.nwrest.NetworkTechnology; import org.onap.so.adapters.nwrest.ProviderVlanNetwork; import org.onap.so.adapters.nwrest.RollbackNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; @@ -261,7 +260,7 @@ public class NetworkAdapterObjectMapper { * @param L3Network * @return List<org.onap.so.openstack.beans.Subnet> */ - private List<Subnet> buildOpenstackSubnetList(L3Network l3Network) { + protected List<Subnet> buildOpenstackSubnetList(L3Network l3Network) { List<org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet> subnets = l3Network.getSubnets(); List<org.onap.so.openstack.beans.Subnet> subnetList = new ArrayList<org.onap.so.openstack.beans.Subnet>(); @@ -292,9 +291,10 @@ public class NetworkAdapterObjectMapper { .setCidr(subnet.getNetworkStartAddress().concat(FORWARD_SLASH).concat(subnet.getCidrMask())); List<org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute> hostRouteList = subnet.getHostRoutes(); List<org.onap.so.openstack.beans.HostRoute> openstackHostRouteList = new ArrayList<>(); - org.onap.so.openstack.beans.HostRoute openstackHostRoute = new org.onap.so.openstack.beans.HostRoute(); + org.onap.so.openstack.beans.HostRoute openstackHostRoute = null; // TODO only 2 fields available on openstack object. Confirm it is sufficient or add as needed for (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute hostRoute : hostRouteList) { + openstackHostRoute = new org.onap.so.openstack.beans.HostRoute(); openstackHostRoute.setNextHop(hostRoute.getNextHop()); openstackHostRoute.setPrefix(hostRoute.getRoutePrefix()); // add host route to the list diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index b0ba0595d5..f23e5cdb5a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -33,7 +35,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; import javax.annotation.PostConstruct; -import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang3.StringUtils; import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; @@ -77,6 +78,9 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.entity.MsoRequest; import org.onap.so.jsonpath.JsonPathUtil; import org.onap.so.openstack.utils.MsoMulticloudUtils; +import org.onap.so.client.adapter.vnf.mapper.exceptions.MissingValueTagException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonParseException; @@ -91,6 +95,7 @@ import com.google.common.base.Joiner; public class VnfAdapterVfModuleObjectMapper { @Autowired protected VnfAdapterObjectMapperUtils vnfAdapterObjectMapperUtils; + private static final Logger logger = LoggerFactory.getLogger(VnfAdapterVfModuleObjectMapper.class); private static List<String> sdncResponseParamsToSkip = asList("vnf_id", "vf_module_id", "vnf_name", "vf_module_name"); @@ -118,7 +123,7 @@ public class VnfAdapterVfModuleObjectMapper { public CreateVfModuleRequest createVfModuleRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) - throws JsonParseException, JsonMappingException, IOException { + throws IOException, MissingValueTagException { CreateVfModuleRequest createVfModuleRequest = new CreateVfModuleRequest(); createVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId()); @@ -167,7 +172,7 @@ public class VnfAdapterVfModuleObjectMapper { private Map<String, Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) - throws JsonParseException, JsonMappingException, IOException { + throws IOException, MissingValueTagException { GenericResourceApiVnfTopology vnfTop = @@ -202,11 +207,11 @@ public class VnfAdapterVfModuleObjectMapper { return paramsMap; } - private void buildDirectivesParamFromMap(Map<String, Object> paramsMap, String directive, - Map<String, Object> srcMap) { + protected void buildDirectivesParamFromMap(Map<String, Object> paramsMap, String directive, + Map<String, Object> srcMap) throws MissingValueTagException { StringBuilder directives = new StringBuilder(); int no_directives_size = 0; - if (directives.equals(MsoMulticloudUtils.USER_DIRECTIVES) + if (directive.equals(MsoMulticloudUtils.USER_DIRECTIVES) && srcMap.containsKey(MsoMulticloudUtils.OOF_DIRECTIVES)) { no_directives_size = 1; } @@ -214,8 +219,12 @@ public class VnfAdapterVfModuleObjectMapper { directives.append("{ \"attributes\": [ "); int i = 0; for (String attributeName : srcMap.keySet()) { - if (!(MsoMulticloudUtils.USER_DIRECTIVES.equals(directives) + if (!(MsoMulticloudUtils.USER_DIRECTIVES.equals(directive) && attributeName.equals(MsoMulticloudUtils.OOF_DIRECTIVES))) { + if (srcMap.get(attributeName) == null) { + logger.error("No value tag found for attribute: {}", attributeName); + throw new MissingValueTagException("No value tag found for " + attributeName); + } directives.append(new AttributeNameValue(attributeName, srcMap.get(attributeName).toString())); if (i < (srcMap.size() - 1 + no_directives_size)) directives.append(", "); @@ -247,7 +256,7 @@ public class VnfAdapterVfModuleObjectMapper { private void buildParamsMapFromVnfSdncResponse(Map<String, Object> paramsMap, GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String, String> networkRoleMap, - boolean skipVnfResourceAssignments) throws JsonParseException, JsonMappingException, IOException { + boolean skipVnfResourceAssignments) throws IOException { // Get VNF parameters from SDNC response GenericResourceApiParam vnfParametersData = vnfTopology.getVnfParametersData(); buildParamsMapFromSdncParams(paramsMap, vnfParametersData); @@ -324,7 +333,7 @@ public class VnfAdapterVfModuleObjectMapper { private void buildParamsMapFromVfModuleSdncResponse(Map<String, Object> paramsMap, GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments) - throws JsonParseException, JsonMappingException, IOException { + throws IOException { // Get VF Module parameters from SDNC response GenericResourceApiParam vfModuleParametersData = vfModuleTopology.getVfModuleParameters(); buildParamsMapFromSdncParams(paramsMap, vfModuleParametersData); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/exceptions/MissingValueTagException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/exceptions/MissingValueTagException.java new file mode 100644 index 0000000000..7271971e46 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/exceptions/MissingValueTagException.java @@ -0,0 +1,15 @@ +package org.onap.so.client.adapter.vnf.mapper.exceptions; + +public class MissingValueTagException extends Exception { + + private static final long serialVersionUID = -1598147488593823724L; + + public MissingValueTagException() { + super(); + } + + public MissingValueTagException(String message) { + super(message); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java index 717bb04099..088ce1ac38 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java @@ -24,6 +24,7 @@ package org.onap.so.client.namingservice; import java.io.IOException; import java.util.List; +import org.onap.so.logger.LoggingAnchor; import org.apache.http.HttpStatus; import org.onap.namingservice.model.NameGenDeleteResponse; import org.onap.namingservice.model.NameGenResponse; @@ -43,6 +44,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class NamingClientResponseValidator { private static final Logger logger = LoggerFactory.getLogger(NamingClientResponseValidator.class); private static final String INSTANCE_GROUP_NAME = "instance-group-name"; + private static final String SERVICE_INSTANCE_NAME = "Service-Instance-Name"; private static final String NO_RESPONSE_FROM_NAMING_SERVICE = "Error did not receive a response from Naming Service."; private static final String NULL_RESPONSE_FROM_NAMING_SERVICE = @@ -51,8 +53,9 @@ public class NamingClientResponseValidator { public String validateNameGenResponse(ResponseEntity<NameGenResponse> response) throws BadResponseException { if (response == null) { - logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NO_RESPONSE_FROM_NAMING_SERVICE, - "BPMN", ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_NAMING_SERVICE); + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), + NO_RESPONSE_FROM_NAMING_SERVICE, "BPMN", ErrorCode.UnknownError.getValue(), + NO_RESPONSE_FROM_NAMING_SERVICE); throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE); } @@ -60,7 +63,7 @@ public class NamingClientResponseValidator { String generatedName = ""; NameGenResponse responseBody = response.getBody(); if (responseBody == null) { - logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), NULL_RESPONSE_FROM_NAMING_SERVICE, "BPMN", ErrorCode.UnknownError.getValue(), NULL_RESPONSE_FROM_NAMING_SERVICE); throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE); @@ -78,6 +81,9 @@ public class NamingClientResponseValidator { if (INSTANCE_GROUP_NAME.equals(resourceName)) { generatedName = respElement.getResourceValue(); break; + } else if (SERVICE_INSTANCE_NAME.equals(resourceName)) { + generatedName = respElement.getResourceValue(); + break; } } } @@ -90,7 +96,7 @@ public class NamingClientResponseValidator { errorMessageString = error.getMessage(); } String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString); - logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN", ErrorCode.DataError.getValue(), errorMessage); throw new BadResponseException(errorMessage); } @@ -99,8 +105,9 @@ public class NamingClientResponseValidator { public String validateNameGenDeleteResponse(ResponseEntity<NameGenDeleteResponse> response) throws BadResponseException { if (response == null) { - logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NO_RESPONSE_FROM_NAMING_SERVICE, - "BPMN", ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_NAMING_SERVICE); + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), + NO_RESPONSE_FROM_NAMING_SERVICE, "BPMN", ErrorCode.UnknownError.getValue(), + NO_RESPONSE_FROM_NAMING_SERVICE); throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE); } @@ -108,7 +115,7 @@ public class NamingClientResponseValidator { String responseMessage = ""; NameGenDeleteResponse responseBody = response.getBody(); if (responseBody == null) { - logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), NULL_RESPONSE_FROM_NAMING_SERVICE, "BPMN", ErrorCode.UnknownError.getValue(), NULL_RESPONSE_FROM_NAMING_SERVICE); throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE); @@ -121,7 +128,7 @@ public class NamingClientResponseValidator { String errorMessageString = NAMING_SERVICE_ERROR; String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString); - logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN", ErrorCode.DataError.getValue(), errorMessage); throw new BadResponseException(errorMessage); } @@ -141,7 +148,7 @@ public class NamingClientResponseValidator { errorMessageString = error.getMessage(); } String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString); - logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN", ErrorCode.DataError.getValue(), errorMessage); return errorMessage; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java new file mode 100644 index 0000000000..3d3058da0b --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingRequestObject.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.namingservice; + +import java.util.HashMap; + +public class NamingRequestObject { + + private HashMap<String, String> namingRequestMap = new HashMap<String, String>(); + + public HashMap<String, String> getNamingRequestObjectMap() { + return this.namingRequestMap; + } + + public String getExternalKeyValue() { + return namingRequestMap.get(NamingServiceConstants.NS_EXTERNAL_KEY); + } + + public void setExternalKeyValue(String externalKey) { + this.namingRequestMap.put(NamingServiceConstants.NS_EXTERNAL_KEY, externalKey); + } + + public String getPolicyInstanceNameValue() { + return this.namingRequestMap.get(NamingServiceConstants.NS_POLICY_INSTANCE_NAME); + } + + public void setPolicyInstanceNameValue(String policyInstanceName) { + this.namingRequestMap.put(NamingServiceConstants.NS_POLICY_INSTANCE_NAME, policyInstanceName); + } + + public String getNamingTypeValue() { + return namingRequestMap.get(NamingServiceConstants.NS_NAMING_TYPE); + } + + public void setNamingTypeValue(String namingType) { + this.namingRequestMap.put(NamingServiceConstants.NS_NAMING_TYPE, namingType); + } + + public String getResourceNameValue() { + return this.namingRequestMap.get(NamingServiceConstants.NS_RESOURCE_NAME); + } + + public void setResourceNameValue(String resourceName) { + namingRequestMap.put(NamingServiceConstants.NS_RESOURCE_NAME, resourceName); + } + + public String getNfNamingCodeValue() { + return this.namingRequestMap.get(NamingServiceConstants.NS_NF_NAMING_CODE); + } + + public void setNfNamingCodeValue(String nfNamingCode) { + this.namingRequestMap.put(NamingServiceConstants.NS_NF_NAMING_CODE, nfNamingCode); + } + + public String getServiceModelNameValue() { + return this.namingRequestMap.get(NamingServiceConstants.NS_SERVICE_MODEL_NAME); + } + + public void setServiceModelNameValue(String serviceModelName) { + this.namingRequestMap.put(NamingServiceConstants.NS_SERVICE_MODEL_NAME, serviceModelName); + } + + public String getModelVersionValue() { + return this.namingRequestMap.get(NamingServiceConstants.NS_MODEL_VERSION); + } + + public void setModelVersionValue(String modelVersion) { + this.namingRequestMap.put(NamingServiceConstants.NS_MODEL_VERSION, modelVersion); + } + + public String getNetworkNameValue() { + return this.namingRequestMap.get(NamingServiceConstants.NS_NETWORK_NAME); + } + + public void setNetworkNameValue(String networkName) { + this.namingRequestMap.put(NamingServiceConstants.NS_NETWORK_NAME, networkName); + } + + public String getVpnNameValue() { + return this.namingRequestMap.get(NamingServiceConstants.NS_VPN_NAME); + } + + public void setVpnNameValue(String vpnName) { + this.namingRequestMap.put(NamingServiceConstants.NS_VPN_NAME, vpnName); + } + + public String getZoneIdValue() { + return this.namingRequestMap.get(NamingServiceConstants.NS_ZONE_ID); + } + + public void setZoneIdValue(String zoneId) { + this.namingRequestMap.put(NamingServiceConstants.NS_ZONE_ID, zoneId); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceConstants.java new file mode 100644 index 0000000000..5637410af0 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceConstants.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.namingservice; + +public class NamingServiceConstants { + public static final String NS_EXTERNAL_KEY = "external-key"; + public static final String NS_POLICY_INSTANCE_NAME = "policy-instance-name"; + public static final String NS_NAMING_TYPE = "naming-type"; + public static final String NS_RESOURCE_NAME = "resource-name"; + public static final String NS_NF_NAMING_CODE = "nf-naming-code"; + public static final String NS_SERVICE_MODEL_NAME = "service-model-name"; + public static final String NS_MODEL_VERSION = "model-version"; + public static final String NS_NETWORK_NAME = "network-name"; + public static final String NS_VPN_NAME = "vpn-name"; + public static final String NS_ZONE_ID = "zone-id"; + public static final String NS_RESOURCE_VALUE = "resource-value"; + + public static final String NAMING_TYPE_SERVICE = "SERVICE"; + public static final String RESOURCE_NAME_SERVICE_INSTANCE_NAME = "Service-Instance-Name"; + public static final String RESOURCE_NAME_SERVICEINSTANCE = "ServiceInstance"; + + private NamingServiceConstants() {} +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceUtils.java new file mode 100644 index 0000000000..16c8e5549c --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingServiceUtils.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.namingservice; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.ExceptionBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class NamingServiceUtils { + + private static String errorMessages = "Policy name is not present, or Onap name was not generated! "; + + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private ExtractPojosForBB extractPojosForBB; + + public void checkVpnBondingService(BuildingBlockExecution execution) { + execution.setVariable("isVpnBondingService", false); + boolean isNamingPolicyAndOnapGeneratedNaming = false; + checkBondingAndInfrastureVpn(execution); + boolean isBondingAndInsfrastructureVpn = execution.getVariable("isBondingAndInsfrastructureVpn"); + if (isBondingAndInsfrastructureVpn) { + checkNamingPolicyAndOnapGeneratedNaming(execution); + isNamingPolicyAndOnapGeneratedNaming = execution.getVariable("isNamingPolicyAndOnapGeneratedNaming"); + } + if (isBondingAndInsfrastructureVpn && isNamingPolicyAndOnapGeneratedNaming) { + execution.setVariable("isVpnBondingService", true); + } + } + + public void checkBondingAndInfrastureVpn(BuildingBlockExecution execution) { + execution.setVariable("isBondingAndInsfrastructureVpn", false); + try { + ServiceInstance serviceInstance = + extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + if ("bonding".equalsIgnoreCase(serviceInstance.getModelInfoServiceInstance().getServiceType()) + && "infrastructure-vpn" + .equalsIgnoreCase(serviceInstance.getModelInfoServiceInstance().getServiceRole())) { + execution.setVariable("isBondingAndInsfrastructureVpn", true); + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void checkNamingPolicyAndOnapGeneratedNaming(BuildingBlockExecution execution) { + execution.setVariable("isNamingPolicyAndOnapGeneratedNaming", false); + try { + ServiceInstance serviceInstance = + extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + if (serviceInstance.getModelInfoServiceInstance().getNamingPolicy() != null + && !serviceInstance.getModelInfoServiceInstance().getNamingPolicy().isEmpty() + && serviceInstance.getModelInfoServiceInstance().getOnapGeneratedNaming() != null + && serviceInstance.getModelInfoServiceInstance().getOnapGeneratedNaming() == true) { + execution.setVariable("isNamingPolicyAndOnapGeneratedNaming", true); + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, errorMessages); + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java index 1453e40653..867d80a4ea 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java @@ -24,6 +24,7 @@ import java.util.Optional; import javax.ws.rs.core.UriBuilder; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIResourceUri; @@ -79,7 +80,7 @@ public class AAIConfigurationResources { /** * A&AI call to disconnect configuration relation with service instance - * + * * @param configurationId * @param serviceInstanceId */ @@ -211,7 +212,7 @@ public class AAIConfigurationResources { /** * Get Configuration from AAI using related Link - * + * * @param relatedLink related link - URI * @return AAI Configuration object */ @@ -228,4 +229,20 @@ public class AAIConfigurationResources { org.onap.aai.domain.yang.Configuration aaiConfiguration = aaiObjectMapper.mapConfiguration(configuration); injectionHelper.getAaiClient().update(aaiResourceUri, aaiConfiguration); } + + public void updateConfigurationOrchestrationStatus(Configuration configuration, + OrchestrationStatus orchestrationStatus) { + AAIResourceUri aaiResourceUri = + AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configuration.getConfigurationId()); + org.onap.aai.domain.yang.Configuration aaiConfiguration = new org.onap.aai.domain.yang.Configuration(); + aaiConfiguration.setOrchestrationStatus(orchestrationStatus.name()); + injectionHelper.getAaiClient().update(aaiResourceUri, aaiConfiguration); + } + + public boolean checkConfigurationNameInUse(String configurationName) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION) + .queryParam("configuration-name", configurationName); + return injectionHelper.getAaiClient().exists(uri); + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java index c48593037a..296d052315 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIInstanceGroupResources.java @@ -25,6 +25,7 @@ import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.uri.AAIResourceUri; @@ -84,4 +85,11 @@ public class AAIInstanceGroupResources { injectionHelper.getAaiClient().createIfNotExists(instanceGroupUri, Optional.of(aaiInstanceGroup)) .connect(instanceGroupUri, serviceInstanceURI); } + + public boolean checkInstanceGroupNameInUse(String instanceGroupName) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.INSTANCE_GROUP) + .queryParam("instance-group-name", instanceGroupName); + return injectionHelper.getAaiClient().exists(uri); + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java index b936551549..bc702c9fb4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java @@ -32,6 +32,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -206,4 +207,11 @@ public class AAINetworkResources { AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, networkPolicyId); injectionHelper.getAaiClient().delete(networkPolicyURI); } + + public boolean checkNetworkNameInUse(String networkName) { + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); + return injectionHelper.getAaiClient().exists(uri); + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java index e391349d2c..c41f3fa56c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java @@ -61,9 +61,9 @@ public class AAIServiceInstanceResources { AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, customer.getGlobalCustomerId(), customer.getServiceSubscription().getServiceType(), serviceInstance.getServiceInstanceId()); serviceInstance.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); - org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance = + org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance); - injectionHelper.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(AAIServiceInstance)); + injectionHelper.getAaiClient().createIfNotExists(serviceInstanceURI, Optional.of(aaiServiceInstance)); } /** @@ -87,24 +87,24 @@ public class AAIServiceInstanceResources { public void createProject(Project project) { AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName()); - org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project); - injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(AAIProject)); + org.onap.aai.domain.yang.Project aaiProject = aaiObjectMapper.mapProject(project); + injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(aaiProject)); } public void createProjectandConnectServiceInstance(Project project, ServiceInstance serviceInstance) { AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, project.getProjectName()); AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); - org.onap.aai.domain.yang.Project AAIProject = aaiObjectMapper.mapProject(project); - injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(AAIProject)).connect(projectURI, + org.onap.aai.domain.yang.Project aaiProject = aaiObjectMapper.mapProject(project); + injectionHelper.getAaiClient().createIfNotExists(projectURI, Optional.of(aaiProject)).connect(projectURI, serviceInstanceURI); } public void createOwningEntity(OwningEntity owningEntity) { AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId()); - org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity); - injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(AAIOwningEntity)); + org.onap.aai.domain.yang.OwningEntity aaiOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity); + injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(aaiOwningEntity)); } public boolean existsOwningEntity(OwningEntity owningEntity) { @@ -134,8 +134,8 @@ public class AAIServiceInstanceResources { AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntity.getOwningEntityId()); AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); - org.onap.aai.domain.yang.OwningEntity AAIOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity); - injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(AAIOwningEntity)) + org.onap.aai.domain.yang.OwningEntity aaiOwningEntity = aaiObjectMapper.mapOwningEntity(owningEntity); + injectionHelper.getAaiClient().createIfNotExists(owningEntityURI, Optional.of(aaiOwningEntity)) .connect(owningEntityURI, serviceInstanceURI); } @@ -152,10 +152,15 @@ public class AAIServiceInstanceResources { public void updateServiceInstance(ServiceInstance serviceInstance) { AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstance.getServiceInstanceId()); - org.onap.aai.domain.yang.ServiceInstance AAIServiceInstance = + org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiObjectMapper.mapServiceInstance(serviceInstance); - injectionHelper.getAaiClient().update(serviceInstanceURI, AAIServiceInstance); + injectionHelper.getAaiClient().update(serviceInstanceURI, aaiServiceInstance); } + public boolean checkInstanceServiceNameInUse(ServiceInstance serviceInstance) { + AAIResourceUri uriSI = AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE) + .queryParam("service-instance-name", serviceInstance.getServiceInstanceName()); + return injectionHelper.getAaiClient().exists(uriSI); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java index 83fe31a116..4d1a6dce38 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVfModuleResources.java @@ -23,12 +23,15 @@ package org.onap.so.client.orchestration; import java.util.Optional; +import org.onap.aai.domain.yang.VfModules; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @@ -40,7 +43,6 @@ import org.springframework.stereotype.Component; @Component public class AAIVfModuleResources { - private static final Logger logger = LoggerFactory.getLogger(AAIVfModuleResources.class); @Autowired private InjectionHelper injectionHelper; @@ -97,8 +99,8 @@ public class AAIVfModuleResources { public void changeAssignVfModule(VfModule vfModule, GenericVnf vnf) { AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnf.getVnfId(), vfModule.getVfModuleId()); - org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule); - injectionHelper.getAaiClient().update(vfModuleURI, AAIVfModule); + org.onap.aai.domain.yang.VfModule aaiVfModule = aaiObjectMapper.mapVfModule(vfModule); + injectionHelper.getAaiClient().update(vfModuleURI, aaiVfModule); } public void connectVfModuleToVolumeGroup(GenericVnf vnf, VfModule vfModule, VolumeGroup volumeGroup, @@ -109,4 +111,19 @@ public class AAIVfModuleResources { cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); injectionHelper.getAaiClient().connect(vfModuleURI, volumeGroupURI); } + + public boolean checkNameInUse(VfModule vfModule) { + boolean nameInUse = false; + AAIResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE) + .queryParam("vf-module-name", vfModule.getVfModuleName()); + AAIResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id", + vfModule.getModelInfoVfModule().getModelCustomizationUUID()); + if (injectionHelper.getAaiClient().exists(vfModuleUriWithCustomization)) { + // assume it's a resume case and return false + nameInUse = false; + } else { + nameInUse = injectionHelper.getAaiClient().exists(vfModuleUri); + } + return nameInUse; + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java index fc61d862aa..a9635d1e34 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java @@ -30,8 +30,10 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIValidatorImpl; +import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @@ -43,7 +45,6 @@ import org.springframework.stereotype.Component; @Component public class AAIVnfResources { - private static final Logger logger = LoggerFactory.getLogger(AAIVnfResources.class); @Autowired private InjectionHelper injectionHelper; @@ -153,4 +154,10 @@ public class AAIVnfResources { return aaiValidatorImpl.isPhysicalServerLocked(vnf.getVnfId()); } + + public boolean checkNameInUse(String vnfName) { + AAIResourceUri vnfUri = + AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName); + return injectionHelper.getAaiClient().exists(vnfUri); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java index c24d1483e2..b9e4aeb888 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVolumeGroupResources.java @@ -26,6 +26,7 @@ import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; @@ -38,7 +39,6 @@ import org.springframework.stereotype.Component; @Component public class AAIVolumeGroupResources { - private static final Logger logger = LoggerFactory.getLogger(AAIVolumeGroupResources.class); @Autowired private InjectionHelper injectionHelper; @@ -94,4 +94,10 @@ public class AAIVolumeGroupResources { copiedVolumeGroup.setHeatStackId(volumeGroup.getHeatStackId()); injectionHelper.getAaiClient().update(uri, aaiObjectMapper.mapVolumeGroup(copiedVolumeGroup)); } + + public boolean checkNameInUse(VolumeGroup volumeGroup) { + AAIResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) + .queryParam("volume-group-name", volumeGroup.getVolumeGroupName()); + return injectionHelper.getAaiClient().exists(volumeGroupUri); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java index 3ac61dff60..168d370521 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVpnBindingResources.java @@ -21,7 +21,6 @@ package org.onap.so.client.orchestration; import java.util.Optional; -import javax.ws.rs.NotFoundException; import org.onap.aai.domain.yang.VpnBindings; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java index 06535bb765..5513122560 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NamingServiceResources.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ @@ -24,12 +24,14 @@ package org.onap.so.client.orchestration; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import org.onap.namingservice.model.Element; import org.onap.namingservice.model.Deleteelement; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.namingservice.NamingClient; +import org.onap.so.client.namingservice.NamingRequestObject; import org.onap.so.client.namingservice.NamingRequestObjectBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,4 +65,25 @@ public class NamingServiceResources { return (namingClient .deleteNameGenRequest(namingRequestObjectBuilder.nameGenDeleteRequestMapper(deleteElements))); } + + public String generateServiceInstanceName(NamingRequestObject namingRequestObject) + throws BadResponseException, IOException { + HashMap<String, String> nsRequestObject = namingRequestObject.getNamingRequestObjectMap(); + Element element = new Element(); + nsRequestObject.forEach((k, v) -> element.put(k, v)); + List<Element> elements = new ArrayList<Element>(); + elements.add(element); + return (namingClient.postNameGenRequest(namingRequestObjectBuilder.nameGenRequestMapper(elements))); + } + + public String deleteServiceInstanceName(NamingRequestObject namingRequestObject) + throws BadResponseException, IOException { + HashMap<String, String> nsRequestObject = namingRequestObject.getNamingRequestObjectMap(); + Deleteelement delElement = new Deleteelement(); + nsRequestObject.forEach((k, v) -> delElement.setExternalKey(v)); + List<Deleteelement> delElements = new ArrayList<Deleteelement>(); + delElements.add(delElement); + return (namingClient.deleteNameGenRequest(namingRequestObjectBuilder.nameGenDeleteRequestMapper(delElements))); + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java index ca32130c23..4aa6a1026a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCConfigurationResources.java @@ -28,9 +28,7 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; -import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCSvcAction; -import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java index 54a9cabb57..d4a4cfbd8a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCNetworkResources.java @@ -39,7 +39,6 @@ import org.springframework.stereotype.Component; @Component public class SDNCNetworkResources { - private static final Logger logger = LoggerFactory.getLogger(SDNCNetworkResources.class); @Autowired private NetworkTopologyOperationRequestMapper sdncRM; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java index 60cad78f5d..b83a4d5628 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVfModuleResources.java @@ -22,6 +22,7 @@ package org.onap.so.client.orchestration; +import java.net.URI; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; @@ -53,22 +54,22 @@ public class SDNCVfModuleResources { public GenericResourceApiVfModuleOperationInformation assignVfModule(VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, - RequestContext requestContext) throws MapperException { + RequestContext requestContext, URI callbackURI) throws MapperException { return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, - volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null); + volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null, callbackURI); } public GenericResourceApiVfModuleOperationInformation unassignVfModule(VfModule vfModule, GenericVnf vnf, - ServiceInstance serviceInstance) throws MapperException { + ServiceInstance serviceInstance, URI callbackURI) throws MapperException { return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, - vnf, serviceInstance, null, null, null, null); + vnf, serviceInstance, null, null, null, null, callbackURI); } public GenericResourceApiVfModuleOperationInformation deactivateVfModule(VfModule vfModule, GenericVnf vnf, - ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException { + ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, + URI callbackURI) throws MapperException { return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null, - vnf, serviceInstance, customer, cloudRegion, requestContext, null); + vnf, serviceInstance, customer, cloudRegion, requestContext, null, callbackURI); } public String queryVfModule(VfModule vfModule) throws MapperException, BadResponseException { @@ -77,16 +78,16 @@ public class SDNCVfModuleResources { } public GenericResourceApiVfModuleOperationInformation activateVfModule(VfModule vfModule, GenericVnf vnf, - ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException { + ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, + URI callbackURI) throws MapperException { return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null, - vnf, serviceInstance, customer, cloudRegion, requestContext, null); + vnf, serviceInstance, customer, cloudRegion, requestContext, null, callbackURI); } public GenericResourceApiVfModuleOperationInformation changeAssignVfModule(VfModule vfModule, GenericVnf vnf, - ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext) - throws MapperException { + ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, + URI callbackURI) throws MapperException { return sdncRM.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, - null, vnf, serviceInstance, customer, cloudRegion, requestContext, null); + null, vnf, serviceInstance, customer, cloudRegion, requestContext, null, callbackURI); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java index 954cbc1b1d..0e32955eed 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java @@ -42,7 +42,6 @@ import org.springframework.stereotype.Component; @Component public class SDNCVnfResources { - private static final Logger logger = LoggerFactory.getLogger(SDNCVnfResources.class); @Autowired private VnfTopologyOperationRequestMapper sdncRM; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java index 939f53727d..0a825b8424 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java @@ -33,6 +33,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.adapter.vnf.mapper.VnfAdapterVfModuleObjectMapper; +import org.onap.so.client.adapter.vnf.mapper.exceptions.MissingValueTagException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +41,6 @@ import org.springframework.stereotype.Component; @Component public class VnfAdapterVfModuleResources { - private static final Logger logger = LoggerFactory.getLogger(VnfAdapterVfModuleResources.class); @Autowired private VnfAdapterVfModuleObjectMapper vnfAdapterVfModuleObjectMapper; @@ -48,7 +48,7 @@ public class VnfAdapterVfModuleResources { public CreateVfModuleRequest createVfModuleRequest(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) - throws IOException { + throws IOException, MissingValueTagException { return vnfAdapterVfModuleObjectMapper.createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java index c97ca8e0ea..2ec63182a0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java @@ -39,7 +39,6 @@ import org.springframework.stereotype.Component; @Component public class VnfAdapterVolumeGroupResources { - private static final Logger logger = LoggerFactory.getLogger(VnfAdapterVolumeGroupResources.class); @Autowired private VnfAdapterObjectMapper vnfAdapterObjectMapper; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java index f02d5e48ee..2e7877fe3b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java @@ -39,8 +39,6 @@ import org.springframework.stereotype.Component; @Component public class SDNCClient { - private static final Logger logger = LoggerFactory.getLogger(SDNCClient.class); - @Autowired private SDNCProperties properties; @Autowired diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java index e21f64accd..1144648517 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java @@ -25,6 +25,7 @@ package org.onap.so.client.sdnc; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import org.onap.so.logger.LoggingAnchor; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; import org.onap.so.client.exception.BadResponseException; @@ -52,6 +53,7 @@ public class SdnCommonTasks { private static final String SDNC_CODE_NOT_0_OR_IN_200_299 = "Error from SDNC: %s"; private static final String COULD_NOT_CONVERT_SDNC_POJO_TO_JSON = "ERROR: Could not convert SDNC pojo to json string."; + private static final String BRACKETS = LoggingAnchor.FIVE; /*** * @@ -66,8 +68,8 @@ public class SdnCommonTasks { try { jsonRequest = objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(request); } catch (JsonProcessingException e) { - logger.error("{} {} {} {} {}", MessageEnum.JAXB_EXCEPTION.toString(), COULD_NOT_CONVERT_SDNC_POJO_TO_JSON, - "BPMN", ErrorCode.DataError.getValue(), e.getMessage()); + logger.error(BRACKETS, MessageEnum.JAXB_EXCEPTION.toString(), COULD_NOT_CONVERT_SDNC_POJO_TO_JSON, "BPMN", + ErrorCode.DataError.getValue(), e.getMessage()); throw new MapperException(COULD_NOT_CONVERT_SDNC_POJO_TO_JSON); } jsonRequest = "{\"input\":" + jsonRequest + "}"; @@ -84,7 +86,7 @@ public class SdnCommonTasks { HttpHeaders httpHeader = new HttpHeaders(); httpHeader.set("Authorization", auth); httpHeader.setContentType(MediaType.APPLICATION_JSON); - List<MediaType> acceptMediaTypes = new ArrayList<MediaType>(); + List<MediaType> acceptMediaTypes = new ArrayList<>(); acceptMediaTypes.add(MediaType.APPLICATION_JSON); httpHeader.setAccept(acceptMediaTypes); return httpHeader; @@ -98,7 +100,7 @@ public class SdnCommonTasks { */ public String validateSDNResponse(LinkedHashMap<String, Object> output) throws BadResponseException { if (CollectionUtils.isEmpty(output)) { - logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", + logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); throw new BadResponseException(NO_RESPONSE_FROM_SDNC); } @@ -125,7 +127,7 @@ public class SdnCommonTasks { return jsonResponse; } else { String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage); - logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), errorMessage, "BPMN", + logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), errorMessage, "BPMN", ErrorCode.DataError.getValue(), errorMessage); throw new BadResponseException(errorMessage); } @@ -139,7 +141,7 @@ public class SdnCommonTasks { */ public String validateSDNGetResponse(LinkedHashMap<String, Object> output) throws BadResponseException { if (CollectionUtils.isEmpty(output)) { - logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", + logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); throw new BadResponseException(NO_RESPONSE_FROM_SDNC); } @@ -149,7 +151,7 @@ public class SdnCommonTasks { try { stringOutput = objMapper.writeValueAsString(output); } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), BAD_RESPONSE_FROM_SDNC, "BPMN", + logger.error(BRACKETS, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), BAD_RESPONSE_FROM_SDNC, "BPMN", ErrorCode.UnknownError.getValue(), BAD_RESPONSE_FROM_SDNC); throw new BadResponseException(BAD_RESPONSE_FROM_SDNC); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java index 5910975051..12d1b0be95 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java @@ -21,7 +21,6 @@ package org.onap.so.client.sdnc.beans; import java.io.Serializable; -import java.time.Duration; import java.util.UUID; import org.onap.so.client.sdnc.endpoint.SDNCTopology; import org.apache.commons.lang3.builder.HashCodeBuilder; @@ -35,8 +34,8 @@ public class SDNCRequest implements Serializable { private static final long serialVersionUID = 4679678988657593282L; private String timeOut = "PT1H"; private SDNCTopology topology; - private String CorrelationValue = UUID.randomUUID().toString(); - private String CorrelationName = "SDNCCallback"; + private String correlationValue = UUID.randomUUID().toString(); + private String correlationName = "SDNCCallback"; private Object SDNCPayload; @@ -57,19 +56,19 @@ public class SDNCRequest implements Serializable { } public String getCorrelationValue() { - return CorrelationValue; + return correlationValue; } public void setCorrelationValue(String correlationValue) { - CorrelationValue = correlationValue; + this.correlationValue = correlationValue; } public String getCorrelationName() { - return CorrelationName; + return correlationName; } public void setCorrelationName(String correlationName) { - CorrelationName = correlationName; + this.correlationName = correlationName; } public Object getSDNCPayload() { @@ -86,13 +85,13 @@ public class SDNCRequest implements Serializable { return false; } SDNCRequest castOther = (SDNCRequest) other; - return new EqualsBuilder().append(CorrelationValue, castOther.CorrelationValue) - .append(CorrelationName, castOther.CorrelationName).isEquals(); + return new EqualsBuilder().append(correlationValue, castOther.correlationValue) + .append(correlationName, castOther.correlationName).isEquals(); } @Override public int hashCode() { - return new HashCodeBuilder().append(CorrelationValue).append(CorrelationName).toHashCode(); + return new HashCodeBuilder().append(correlationValue).append(correlationName).toHashCode(); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java index 1718de9fe0..d6216c509d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcAction.java @@ -23,22 +23,17 @@ package org.onap.so.client.sdnc.beans; import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; public enum SDNCSvcAction { - ACTIVATE("activate", GenericResourceApiSvcActionEnumeration.ACTIVATE), DELETE("delete", - GenericResourceApiSvcActionEnumeration.DELETE), ASSIGN("assign", - GenericResourceApiSvcActionEnumeration.ASSIGN), ROLLBACK("rollback", - GenericResourceApiSvcActionEnumeration.ROLLBACK), UNASSIGN("unassign", - GenericResourceApiSvcActionEnumeration.UNASSIGN), DEACTIVATE("deactivate", - GenericResourceApiSvcActionEnumeration.DEACTIVATE), CHANGE_DELETE( - "changedelete", - GenericResourceApiSvcActionEnumeration.CHANGEDELETE), CHANGE_ASSIGN( - "changeassign", - GenericResourceApiSvcActionEnumeration.CHANGEASSIGN), CREATE( - "create", - GenericResourceApiSvcActionEnumeration.CREATE), ENABLE( - "enable", - GenericResourceApiSvcActionEnumeration.ENABLE), DISABLE( - "disable", - GenericResourceApiSvcActionEnumeration.DISABLE); + ACTIVATE("activate", GenericResourceApiSvcActionEnumeration.ACTIVATE), + DELETE("delete", GenericResourceApiSvcActionEnumeration.DELETE), + ASSIGN("assign", GenericResourceApiSvcActionEnumeration.ASSIGN), + ROLLBACK("rollback", GenericResourceApiSvcActionEnumeration.ROLLBACK), + UNASSIGN("unassign", GenericResourceApiSvcActionEnumeration.UNASSIGN), + DEACTIVATE("deactivate", GenericResourceApiSvcActionEnumeration.DEACTIVATE), + CHANGE_DELETE("changedelete", GenericResourceApiSvcActionEnumeration.CHANGEDELETE), + CHANGE_ASSIGN("changeassign", GenericResourceApiSvcActionEnumeration.CHANGEASSIGN), + CREATE("create", GenericResourceApiSvcActionEnumeration.CREATE), + ENABLE("enable", GenericResourceApiSvcActionEnumeration.ENABLE), + DISABLE("disable", GenericResourceApiSvcActionEnumeration.DISABLE); private final String name; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java index b9b04bc7b7..4edbf37bad 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCSvcOperation.java @@ -22,14 +22,14 @@ package org.onap.so.client.sdnc.beans; public enum SDNCSvcOperation { - VF_MODULE_TOPOLOGY_OPERATION("vf-module-topology-operation"), NETWORK_TOPOLOGY_OPERATION( - "network-topology-operation"), VNF_TOPOLOGY_OPERATION( - "vnf-topology-operation"), CONTRAIL_ROUTE_TOPOLOGY_OPERATION( - "contrail-route-topology-operation"), SECURITY_ZONE_TOPOLOGY_OPERATION( - "security-zone-topology-operation"), PORT_MIRROR_TOPOLOGY_OPERATION( - "port-mirror-topology-operation"), SERVICE_TOPOLOGY_OPERATION( - "service-topology-operation"), GENERIC_CONFIGURATION_TOPOLOGY_OPERATION( - "generic-configuration-topology-operation"); + VF_MODULE_TOPOLOGY_OPERATION("vf-module-topology-operation"), + NETWORK_TOPOLOGY_OPERATION("network-topology-operation"), + VNF_TOPOLOGY_OPERATION("vnf-topology-operation"), + CONTRAIL_ROUTE_TOPOLOGY_OPERATION("contrail-route-topology-operation"), + SECURITY_ZONE_TOPOLOGY_OPERATION("security-zone-topology-operation"), + PORT_MIRROR_TOPOLOGY_OPERATION("port-mirror-topology-operation"), + SERVICE_TOPOLOGY_OPERATION("service-topology-operation"), + GENERIC_CONFIGURATION_TOPOLOGY_OPERATION("generic-configuration-topology-operation"); private final String name; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java index fb5f24694b..ae9fe6ad70 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/endpoint/SDNCTopology.java @@ -22,11 +22,14 @@ package org.onap.so.client.sdnc.endpoint; public enum SDNCTopology { - SERVICE("service-topology-operation"), VNF("vnf-topology-operation"), VFMODULE( - "vf-module-topology-operation"), CONTRAILROUTE("contrail-route-topology-operation"), PORTMIRROR( - "port-mirror-topology-operation"), NETWORK("network-topology-operation"), SECURITYZONE( - "security-zone-topology-operation"), CONFIGURATION( - "generic-configuration-topology-operation"); + SERVICE("service-topology-operation"), + VNF("vnf-topology-operation"), + VFMODULE("vf-module-topology-operation"), + CONTRAILROUTE("contrail-route-topology-operation"), + PORTMIRROR("port-mirror-topology-operation"), + NETWORK("network-topology-operation"), + SECURITYZONE("security-zone-topology-operation"), + CONFIGURATION("generic-configuration-topology-operation"); private final String topology; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index 6627625d62..6ddb292a6c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -22,8 +22,10 @@ package org.onap.so.client.sdnc.mapper; +import java.net.URI; import java.util.Map; import java.util.UUID; +import org.onap.so.logger.LoggingAnchor; import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; @@ -64,7 +66,7 @@ public class VfModuleTopologyOperationRequestMapper { public GenericResourceApiVfModuleOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, VfModule vfModule, VolumeGroup volumeGroup, GenericVnf vnf, ServiceInstance serviceInstance, Customer customer, CloudRegion cloudRegion, RequestContext requestContext, - String sdncAssignResponse) throws MapperException { + String sdncAssignResponse, URI callbackURL) throws MapperException { GenericResourceApiVfModuleOperationInformation req = new GenericResourceApiVfModuleOperationInformation(); boolean includeModelInformation = false; @@ -113,7 +115,7 @@ public class VfModuleTopologyOperationRequestMapper { GenericResourceApiVfmodulerequestinputVfModuleRequestInput vfModuleRequestInput = buildVfModuleRequestInput(vfModule, volumeGroup, cloudRegion, requestContext); GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - buildVfModuleSdncRequestHeader(sdncReqId, genericResourceApiSvcAction); + buildVfModuleSdncRequestHeader(sdncReqId, genericResourceApiSvcAction, callbackURL); req.setRequestInformation(requestInformation); req.setSdncRequestHeader(sdncRequestHeader); @@ -169,13 +171,12 @@ public class VfModuleTopologyOperationRequestMapper { } private GenericResourceApiSdncrequestheaderSdncRequestHeader buildVfModuleSdncRequestHeader(String sdncReqId, - GenericResourceApiSvcActionEnumeration svcAction) { + GenericResourceApiSvcActionEnumeration svcAction, URI callbackUrl) { GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = new GenericResourceApiSdncrequestheaderSdncRequestHeader(); - sdncRequestHeader.setSvcRequestId(sdncReqId); sdncRequestHeader.setSvcAction(svcAction); - + sdncRequestHeader.setSvcNotificationUrl(callbackUrl.toString()); return sdncRequestHeader; } @@ -188,7 +189,7 @@ public class VfModuleTopologyOperationRequestMapper { mapper.readValue(sdncAssignResponse, GenericResourceApiVfModuleResponseInformation.class); objectPath = assignResponseInfo.getVfModuleResponseInformation().getObjectPath(); } catch (Exception e) { - logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), e.getMessage(), "BPMN", + logger.error(LoggingAnchor.FIVE, MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), e.getMessage(), "BPMN", ErrorCode.UnknownError.getValue(), e.getMessage()); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java index f31bff988a..e39e202aa3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -126,7 +126,7 @@ public class VnfTopologyOperationRequestMapper { } List<InstanceGroup> instanceGroups = vnf.getInstanceGroups(); List<GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds> networkInstanceGroupIdList = - new ArrayList<GenericResourceApiVnfrequestinputVnfrequestinputVnfNetworkInstanceGroupIds>(); + new ArrayList<>(); for (InstanceGroup instanceGroup : instanceGroups) { if (ModelInfoInstanceGroup.TYPE_L3_NETWORK diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java index a448082cfe..eb73001f42 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroValidator.java @@ -49,7 +49,7 @@ public class SniroValidator { JSONObject jsonResponse = new JSONObject(response); if (jsonResponse.has("requestStatus")) { String status = jsonResponse.getString("requestStatus"); - if (status.equals("accepted")) { + if ("accepted".equals(status)) { logger.debug("Sniro Managers synchronous response indicates accepted"); } else { String message = jsonResponse.getString("statusMessage"); @@ -111,7 +111,7 @@ public class SniroValidator { if (!response.isEmpty()) { String status = (String) response.get("status"); if (isNotBlank(status)) { - if (status.equals("success")) { + if ("success".equals(status)) { logger.debug("Sniro Conductors synchronous response indicates success"); } else { String message = (String) response.get("message"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java index cded23aad2..3127275b24 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Candidate.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. @@ -36,6 +36,13 @@ public class Candidate implements Serializable { @JsonProperty("cloudOwner") private String cloudOwner; + public Candidate() {} + + public Candidate(CandidateType identifierType, List<String> identifiers, String cloudOwner) { + this.identifierType = identifierType; + this.identifiers = identifiers; + this.cloudOwner = cloudOwner; + } public CandidateType getIdentifierType() { return identifierType; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.java index 19378cdbfa..0cc993560d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/Demand.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. @@ -38,6 +38,10 @@ public class Demand implements Serializable { private List<Candidate> requiredCandidates; @JsonProperty("excludedCandidates") private List<Candidate> excludedCandidates; + @JsonProperty("existingCandidates") + private List<Candidate> existingCandidates; + @JsonProperty("filteringAttributes") + private List<Candidate> filteringAttributes; public List<Candidate> getRequiredCandidates() { @@ -80,4 +84,20 @@ public class Demand implements Serializable { this.modelInfo = modelInfo; } + public List<Candidate> getExistingCandidates() { + return existingCandidates; + } + + public void setExistingCandidates(List<Candidate> existingCandidates) { + this.existingCandidates = existingCandidates; + } + + public List<Candidate> getFilteringAttributes() { + return filteringAttributes; + } + + public void setFilteringAttributes(List<Candidate> filteringAttributes) { + this.filteringAttributes = filteringAttributes; + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java index d71b4ec5fc..9ab3ae673a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/LicenseInfo.java @@ -30,7 +30,7 @@ public class LicenseInfo implements Serializable { private static final long serialVersionUID = 6878164369491185856L; @JsonProperty("licenseDemands") - private List<Demand> demands = new ArrayList<Demand>(); + private List<Demand> demands = new ArrayList<>(); public List<Demand> getDemands() { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java index ae13903a22..bbbbf9cfd6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/PlacementInfo.java @@ -37,7 +37,7 @@ public class PlacementInfo implements Serializable { @JsonProperty("subscriberInfo") private SubscriberInfo subscriberInfo; @JsonProperty("placementDemands") - private List<Demand> demands = new ArrayList<Demand>(); + private List<Demand> demands = new ArrayList<>(); @JsonRawValue @JsonProperty("requestParameters") private String requestParameters; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java index f632424c26..b8896a2bab 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SniroConductorRequest.java @@ -40,7 +40,7 @@ public class SniroConductorRequest implements Serializable { private static final Logger logger = LoggerFactory.getLogger(SniroConductorRequest.class); @JsonProperty("release-locks") - private List<Resource> resources = new ArrayList<Resource>(); + private List<Resource> resources = new ArrayList<>(); public List<Resource> getResources() { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java index eaf8b6e379..35a4cac459 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/beans/SubscriberInfo.java @@ -22,7 +22,6 @@ package org.onap.so.client.sniro.beans; import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRawValue; import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("subscriberInfo") diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java index a78dffb4e0..12adec9e24 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/ticket/ExternalTicket.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.client.ticket; public class ExternalTicket { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java index b40e43b959..39efa6dc76 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java @@ -35,6 +35,7 @@ import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.namingservice.NamingRequestObject; import org.onap.so.client.orchestration.AAICollectionResources; import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAIInstanceGroupResources; @@ -150,4 +151,8 @@ public abstract class BaseTaskTest extends TestDataSetup { @Mock protected Environment env; + + @Mock + protected NamingRequestObject namingRequestObject; + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java index b054cc17bb..b889493d2e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java @@ -60,6 +60,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.client.aai.entities.uri.AAIResourceUri; @@ -122,12 +123,21 @@ public class AAICreateTasksTest extends BaseTaskTest { @Test public void createServiceInstanceTest() throws Exception { + doReturn(false).when(aaiServiceInstanceResources).checkInstanceServiceNameInUse(serviceInstance); doNothing().when(aaiServiceInstanceResources).createServiceInstance(serviceInstance, customer); aaiCreateTasks.createServiceInstance(execution); verify(aaiServiceInstanceResources, times(1)).createServiceInstance(serviceInstance, customer); } @Test + public void createServiceInstanceNameInUseExceptionTest() throws Exception { + expectedException.expect(BpmnError.class); + doReturn(true).when(aaiServiceInstanceResources).checkInstanceServiceNameInUse(serviceInstance); + execution.setVariable("aLaCarte", Boolean.TRUE); + aaiCreateTasks.createServiceInstance(execution); + } + + @Test public void createServiceInstanceExceptionTest() throws Exception { expectedException.expect(BpmnError.class); @@ -140,7 +150,7 @@ public class AAICreateTasksTest extends BaseTaskTest { @Test public void createVolumeGroupTest() throws Exception { volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED); - + execution.setVariable("aLaCarte", Boolean.FALSE); doNothing().when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion); doNothing().when(aaiVolumeGroupResources).connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion); @@ -152,6 +162,14 @@ public class AAICreateTasksTest extends BaseTaskTest { } @Test + public void createVolumeGroupDuplicateNameTest() throws Exception { + expectedException.expect(BpmnError.class); + execution.setVariable("aLaCarte", Boolean.TRUE); + doReturn(true).when(aaiVolumeGroupResources).checkNameInUse(volumeGroup); + aaiCreateTasks.createVolumeGroup(execution); + } + + @Test public void createVolumeGroupExceptionTest() throws Exception { expectedException.expect(BpmnError.class); @@ -325,11 +343,20 @@ public class AAICreateTasksTest extends BaseTaskTest { @Test public void createVnfTest() throws Exception { doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance); + execution.setVariable("aLaCarte", Boolean.FALSE); aaiCreateTasks.createVnf(execution); verify(aaiVnfResources, times(1)).createVnfandConnectServiceInstance(genericVnf, serviceInstance); } @Test + public void createVnfDuplicateNameTest() throws Exception { + expectedException.expect(BpmnError.class); + doReturn(true).when(aaiVnfResources).checkNameInUse(genericVnf.getVnfName()); + execution.setVariable("aLaCarte", Boolean.TRUE); + aaiCreateTasks.createVnf(execution); + } + + @Test public void createVnfExceptionTest() throws Exception { expectedException.expect(BpmnError.class); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "notfound"); @@ -352,12 +379,21 @@ public class AAICreateTasksTest extends BaseTaskTest { .thenReturn(newVfModule); assertEquals(null, newVfModule.getModuleIndex()); + execution.setVariable("aLaCarte", Boolean.FALSE); aaiCreateTasks.createVfModule(execution); assertEquals(1, newVfModule.getModuleIndex().intValue()); verify(aaiVfModuleResources, times(1)).createVfModule(newVfModule, genericVnf); } @Test + public void createVfModuleDuplicateNameTest() throws Exception { + expectedException.expect(BpmnError.class); + execution.setVariable("aLaCarte", Boolean.TRUE); + doReturn(true).when(aaiVfModuleResources).checkNameInUse(vfModule); + aaiCreateTasks.createVfModule(execution); + } + + @Test public void createServiceSubscriptionTest() { doNothing().when(aaiServiceInstanceResources).createServiceSubscription(customer); aaiCreateTasks.createServiceSubscription(execution); @@ -398,13 +434,21 @@ public class AAICreateTasksTest extends BaseTaskTest { @Test public void createNetworkTest() throws Exception { network.getModelInfoNetwork().setNeutronNetworkType("PROVIDER"); - + execution.setVariable("aLaCarte", Boolean.FALSE); doNothing().when(aaiNetworkResources).createNetworkConnectToServiceInstance(network, serviceInstance); aaiCreateTasks.createNetwork(execution); verify(aaiNetworkResources, times(1)).createNetworkConnectToServiceInstance(network, serviceInstance); } @Test + public void createNetworkNameInUseExceptionTest() throws Exception { + expectedException.expect(BpmnError.class); + execution.setVariable("aLaCarte", Boolean.TRUE); + doReturn(true).when(aaiNetworkResources).checkNetworkNameInUse(network.getNetworkName()); + aaiCreateTasks.createNetwork(execution); + } + + @Test public void createNetworkExceptionTest() throws Exception { expectedException.expect(BpmnError.class); @@ -444,6 +488,7 @@ public class AAICreateTasksTest extends BaseTaskTest { public void createNetworkCollectionInstanceGroupTest() throws Exception { doNothing().when(aaiNetworkResources) .createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup()); + execution.setVariable("aLaCarte", Boolean.FALSE); aaiCreateTasks.createNetworkCollectionInstanceGroup(execution); verify(aaiNetworkResources, times(1)) .createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup()); @@ -509,11 +554,21 @@ public class AAICreateTasksTest extends BaseTaskTest { public void createConfigurationTest() throws Exception { gBBInput = execution.getGeneralBuildingBlock(); doNothing().when(aaiConfigurationResources).createConfiguration(configuration); + execution.setVariable("aLaCarte", Boolean.FALSE); aaiCreateTasks.createConfiguration(execution); verify(aaiConfigurationResources, times(1)).createConfiguration(configuration); } @Test + public void createConfigurationNameInUseExceptionTest() throws Exception { + expectedException.expect(BpmnError.class); + doReturn(true).when(aaiConfigurationResources) + .checkConfigurationNameInUse(configuration.getConfigurationName()); + execution.setVariable("aLaCarte", Boolean.TRUE); + aaiCreateTasks.createConfiguration(execution); + } + + @Test public void connectVnfToCloudRegionTest() throws Exception { gBBInput = execution.getGeneralBuildingBlock(); doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion()); @@ -543,14 +598,26 @@ public class AAICreateTasksTest extends BaseTaskTest { @Test public void createInstanceGroupVnfTest() throws Exception { + doReturn(false).when(aaiInstanceGroupResources) + .checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName()); doNothing().when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance); + execution.setVariable("aLaCarte", Boolean.FALSE); aaiCreateTasks.createInstanceGroupVnf(execution); verify(aaiInstanceGroupResources, times(1)).createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance); } @Test + public void createInstanceGroupVnfNameInUseExceptionTest() throws Exception { + expectedException.expect(BpmnError.class); + doReturn(true).when(aaiInstanceGroupResources) + .checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName()); + execution.setVariable("aLaCarte", Boolean.TRUE); + aaiCreateTasks.createInstanceGroupVnf(execution); + } + + @Test public void createInstanceGroupVnfExceptionTest() throws Exception { expectedException.expect(BpmnError.class); doThrow(RuntimeException.class).when(aaiInstanceGroupResources) diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java index 5805ea5ec1..caae90bfff 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/InputParameterRetrieverTaskTest.java @@ -119,5 +119,10 @@ public class InputParameterRetrieverTaskTest extends BaseTaskTest { return null; } + @Override + public int getCurrentSequence() { + return 0; + } + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java index 84012e8b8d..a4d8aa85a2 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/StubbedBuildingBlockExecution.java @@ -79,6 +79,11 @@ public class StubbedBuildingBlockExecution implements BuildingBlockExecution { return null; } + @Override + public int getCurrentSequence() { + return 0; + } + public static String getTenantId() { return TENANT_ID; } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java index 6f76c83c6f..982b75ae8e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnfTest.java @@ -1,16 +1,20 @@ - -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright 2019 TechMahindra - * ================================================================================= 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_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 TechMahindra + * ================================================================================ + * 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========================================================= */ diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java index 8d51ceb65f..7b6ba6b8fd 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/SniroHomingV2IT.java @@ -23,7 +23,7 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.isA; @@ -53,6 +53,7 @@ import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.sniro.beans.SniroManagerRequest; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; public class SniroHomingV2IT extends BaseIntegrationTest { @@ -107,6 +108,18 @@ public class SniroHomingV2IT extends BaseIntegrationTest { serviceInstance.getAllottedResources().add(setAllottedResource("3")); } + public void beforeServiceProxy() { + ServiceProxy sp = setServiceProxy("1", "infrastructure"); + Candidate filteringAttributes = new Candidate(); + filteringAttributes.setIdentifierType(CandidateType.CLOUD_REGION_ID); + List<String> c = new ArrayList<String>(); + c.add("testCloudRegionId"); + filteringAttributes.setCloudOwner("att"); + filteringAttributes.setIdentifiers(c); + sp.getFilteringAttributes().add(filteringAttributes); + serviceInstance.getServiceProxies().add(sp); + } + public void beforeVnf() { setGenericVnf(); } @@ -191,6 +204,23 @@ public class SniroHomingV2IT extends BaseIntegrationTest { verify(sniroClient, times(1)).postDemands(isA(SniroManagerRequest.class)); } + @Test + public void testCallSniro_success_1ServiceProxy() throws JsonProcessingException, BadResponseException { + beforeServiceProxy(); + + wireMockServer.stubFor(post(urlEqualTo("/sniro/api/placement/v2")).willReturn( + aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(mockResponse))); + + sniroHoming.callSniro(execution); + + String request = readResourceFile(RESOURCE_PATH + "SniroManagerRequest1SP.json"); + request = request.replace("28080", wireMockPort); + + ArgumentCaptor<SniroManagerRequest> argument = ArgumentCaptor.forClass(SniroManagerRequest.class); + verify(sniroClient, times(1)).postDemands(argument.capture()); + assertEquals(request, argument.getValue().toJsonString()); + } + @Test(expected = Test.None.class) public void testProcessSolution_success_1VpnLink_1Solution() { beforeVpnBondingLink("1"); @@ -563,10 +593,57 @@ public class SniroHomingV2IT extends BaseIntegrationTest { assertEquals(2, vnf.getLicense().getLicenseKeyGroupUuids().size()); assertEquals("f1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getEntitlementPoolUuids().get(0)); assertEquals("s1d563e8-e714-4393-8f99-cc480144a05e", vnf.getLicense().getLicenseKeyGroupUuids().get(0)); + } + @Test + public void testProcessSolution_success_1ServiceProxy_1Solutions() { + beforeServiceProxy(); + + JSONObject asyncResponse = new JSONObject(); + asyncResponse.put("transactionId", "testRequestId").put("requestId", "testRequestId").put("requestState", + "completed"); + JSONArray solution1 = new JSONArray(); + solution1 + .put(new JSONObject() + .put("serviceResourceId", "testProxyId1").put( + "solution", + new JSONObject() + .put("identifierType", "serviceInstanceId") + .put("identifiers", new JSONArray().put("testServiceInstanceId1"))) + .put("assignmentInfo", + new JSONArray().put(new JSONObject().put("key", "isRehome").put("value", "False")) + .put(new JSONObject().put("key", "cloudOwner").put("value", "")) + .put(new JSONObject().put("key", "aicClli").put("value", "testAicClli1")) + .put(new JSONObject().put("key", "aicVersion").put("value", "3")) + .put(new JSONObject().put("key", "cloudRegionId").put("value", "")) + .put(new JSONObject().put("key", "primaryPnfName").put("value", + "testPrimaryPnfName")) + .put(new JSONObject().put("key", "secondaryPnfName").put("value", + "testSecondaryPnfName")))); + + asyncResponse.put("solutions", new JSONObject().put("placementSolutions", new JSONArray().put(solution1)) + .put("licenseSolutions", new JSONArray())); + sniroHoming.processSolution(execution, asyncResponse.toString()); + + ServiceInstance si = + execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0); + + ServiceProxy sp = si.getServiceProxies().get(0); + assertNotNull(sp); + assertNotNull(sp.getServiceInstance()); + + assertEquals("testServiceInstanceId1", sp.getServiceInstance().getServiceInstanceId()); + assertNotNull(sp.getServiceInstance().getSolutionInfo()); + + assertFalse(sp.getServiceInstance().getPnfs().isEmpty()); + assertEquals("testPrimaryPnfName", sp.getServiceInstance().getPnfs().get(0).getPnfName()); + assertEquals("primary", sp.getServiceInstance().getPnfs().get(0).getRole()); + assertEquals("testSecondaryPnfName", sp.getServiceInstance().getPnfs().get(1).getPnfName()); + assertEquals("secondary", sp.getServiceInstance().getPnfs().get(1).getRole()); } + @Test(expected = BpmnError.class) public void testCallSniro_error_0Resources() throws BadResponseException, JsonProcessingException { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java index f9ad473e5a..9677f8e8f3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + package org.onap.so.bpmn.infrastructure.manualhandling.tasks; import static org.junit.Assert.assertEquals; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java index f5785f94fd..44e5e0e707 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasksTest.java @@ -22,31 +22,50 @@ package org.onap.so.bpmn.infrastructure.namingservice.tasks; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.aai.domain.yang.Zone; import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.client.aai.AAICommonObjectMapperProvider; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.Relationships; import org.onap.so.client.exception.BBObjectNotFoundException; public class NamingServiceCreateTasksTest extends BaseTaskTest { @InjectMocks - private NamingServiceCreateTasks namingServiceCreateTasks = new NamingServiceCreateTasks(); + private NamingServiceCreateTasks namingServiceCreateTasks; + + @Mock + private BBInputSetupUtils MOCK_bbInputSetupUtils; private InstanceGroup instanceGroup; + private ServiceInstance serviceInstance; @Before public void before() throws BBObjectNotFoundException { instanceGroup = setInstanceGroup(); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID))) .thenReturn(instanceGroup); + serviceInstance = setServiceInstance(); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstance); } @Test @@ -80,7 +99,29 @@ public class NamingServiceCreateTasksTest extends BaseTaskTest { namingServiceCreateTasks.createInstanceGroupName(execution); verify(namingServiceResources, times(1)).generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode); + } + + @Test + public void createWanTransportServiceNameTest() throws Exception { + String generatedName = "generatedWanTransportServiceName"; + doReturn(generatedName).when(namingServiceResources).generateServiceInstanceName(any()); + NamingServiceCreateTasks spy = Mockito.spy(namingServiceCreateTasks); + spy.createWanTransportServiceName(execution); + verify(namingServiceResources, times(1)).generateServiceInstanceName(any()); + assertEquals(generatedName, serviceInstance.getServiceInstanceName()); } + @Test + public void createVpnBondingServiceNameTest() throws Exception { + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))) + .thenReturn(buildL3Network()); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VPN_ID))) + .thenReturn(buildVpnBinding()); + String generatedName = "generatedWanTransportServiceName"; + doReturn(generatedName).when(namingServiceResources).generateServiceInstanceName(any()); + namingServiceCreateTasks.createVpnBondingServiceName(execution); + verify(namingServiceResources, times(1)).generateServiceInstanceName(any()); + assertEquals(generatedName, serviceInstance.getServiceInstanceName()); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java index 758b8f4ffd..32550a5467 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasksTest.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.namingservice.tasks; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; @@ -32,14 +33,17 @@ import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.namingservice.NamingRequestObject; public class NamingServiceDeleteTasksTest extends BaseTaskTest { @InjectMocks private NamingServiceDeleteTasks namingServiceDeleteTasks = new NamingServiceDeleteTasks(); private InstanceGroup instanceGroup; + private ServiceInstance serviceInstance; @Before public void before() throws BBObjectNotFoundException { @@ -68,4 +72,15 @@ public class NamingServiceDeleteTasksTest extends BaseTaskTest { verify(namingServiceResources, times(1)).deleteInstanceGroupName(instanceGroup); } + @Test + public void deleteServiceInstanceNameTest() throws Exception { + serviceInstance = setServiceInstance(); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstance); + doNothing().when(namingRequestObject).setExternalKeyValue(serviceInstance.getServiceInstanceId()); + doReturn("").when(namingServiceResources).deleteServiceInstanceName(namingRequestObject); + namingServiceDeleteTasks.deleteServiceInstanceName(execution); + verify(namingServiceResources, times(1)).deleteServiceInstanceName(any(NamingRequestObject.class)); + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java index 4eb1432bbf..ffd4f74b63 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java @@ -29,6 +29,7 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.net.URI; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; @@ -85,7 +86,10 @@ public class SDNCActivateTaskTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) .thenReturn(serviceInstance); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstance); + when(env.getRequiredProperty("mso.workflow.message.endpoint")).thenReturn("http://localhost:9090"); } @Test @@ -129,11 +133,12 @@ public class SDNCActivateTaskTest extends BaseTaskTest { @Test public void activateVfModuleTest() throws Exception { - doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources) - .activateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); + doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).activateVfModule( + eq(vfModule), eq(genericVnf), eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), + any(URI.class)); sdncActivateTasks.activateVfModule(execution); - verify(sdncVfModuleResources, times(1)).activateVfModule(vfModule, genericVnf, serviceInstance, customer, - cloudRegion, requestContext); + verify(sdncVfModuleResources, times(1)).activateVfModule(eq(vfModule), eq(genericVnf), eq(serviceInstance), + eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology()); } @@ -141,8 +146,8 @@ public class SDNCActivateTaskTest extends BaseTaskTest { @Test public void activateVfModuleTestException() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVfModuleResources).activateVfModule(vfModule, genericVnf, - serviceInstance, customer, cloudRegion, requestContext); + doThrow(RuntimeException.class).when(sdncVfModuleResources).activateVfModule(eq(vfModule), eq(genericVnf), + eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncActivateTasks.activateVfModule(execution); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java index 7d8e94d1e9..982868dcbc 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java @@ -28,6 +28,7 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.net.URI; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; @@ -89,6 +90,7 @@ public class SDNCAssignTasksTest extends BaseTaskTest { .thenReturn(serviceInstance); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID))) .thenReturn(volumeGroup); + when(env.getRequiredProperty("mso.workflow.message.endpoint")).thenReturn("http://localhost:9090"); } @Test @@ -132,10 +134,11 @@ public class SDNCAssignTasksTest extends BaseTaskTest { @Test public void assignVfModuleTest() throws Exception { doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).assignVfModule( - vfModule, volumeGroup, genericVnf, serviceInstance, customer, cloudRegion, requestContext); + eq(vfModule), eq(volumeGroup), eq(genericVnf), eq(serviceInstance), eq(customer), eq(cloudRegion), + eq(requestContext), any(URI.class)); sdncAssignTasks.assignVfModule(execution); - verify(sdncVfModuleResources, times(1)).assignVfModule(vfModule, volumeGroup, genericVnf, serviceInstance, - customer, cloudRegion, requestContext); + verify(sdncVfModuleResources, times(1)).assignVfModule(eq(vfModule), eq(volumeGroup), eq(genericVnf), + eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology()); } @@ -143,8 +146,8 @@ public class SDNCAssignTasksTest extends BaseTaskTest { @Test public void assignVfModuleExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVfModuleResources).assignVfModule(vfModule, volumeGroup, genericVnf, - serviceInstance, customer, cloudRegion, requestContext); + doThrow(RuntimeException.class).when(sdncVfModuleResources).assignVfModule(eq(vfModule), eq(volumeGroup), + eq(genericVnf), eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncAssignTasks.assignVfModule(execution); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java index 1c1616a472..8c25bea801 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java @@ -27,6 +27,7 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.net.URI; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; @@ -74,6 +75,7 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) .thenReturn(serviceInstance); + when(env.getRequiredProperty("mso.workflow.message.endpoint")).thenReturn("http://localhost:9090"); } @Test @@ -97,11 +99,12 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest { @Test public void changeAssignModelVfModuleTest() throws Exception { - doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources) - .changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); + doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).changeAssignVfModule( + eq(vfModule), eq(genericVnf), eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), + any(URI.class)); sdncChangeAssignTasks.changeAssignModelVfModule(execution); - verify(sdncVfModuleResources, times(1)).changeAssignVfModule(vfModule, genericVnf, serviceInstance, customer, - cloudRegion, requestContext); + verify(sdncVfModuleResources, times(1)).changeAssignVfModule(eq(vfModule), eq(genericVnf), eq(serviceInstance), + eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology()); } @@ -109,8 +112,8 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest { @Test public void changeAssignModelVfModuleExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVfModuleResources).changeAssignVfModule(vfModule, genericVnf, - serviceInstance, customer, cloudRegion, requestContext); + doThrow(RuntimeException.class).when(sdncVfModuleResources).changeAssignVfModule(eq(vfModule), eq(genericVnf), + eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncChangeAssignTasks.changeAssignModelVfModule(execution); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java index 08d4d196da..d8a1b0182e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java @@ -28,6 +28,7 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.net.URI; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; @@ -81,16 +82,17 @@ public class SDNCDeactivateTaskTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) .thenReturn(serviceInstance); - + when(env.getRequiredProperty("mso.workflow.message.endpoint")).thenReturn("http://localhost:9090"); } @Test public void deactivateVfModuleTest() throws Exception { - doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources) - .deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, cloudRegion, requestContext); + doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources).deactivateVfModule( + eq(vfModule), eq(genericVnf), eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), + any(URI.class)); sdncDeactivateTasks.deactivateVfModule(execution); - verify(sdncVfModuleResources, times(1)).deactivateVfModule(vfModule, genericVnf, serviceInstance, customer, - cloudRegion, requestContext); + verify(sdncVfModuleResources, times(1)).deactivateVfModule(eq(vfModule), eq(genericVnf), eq(serviceInstance), + eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology()); } @@ -98,8 +100,8 @@ public class SDNCDeactivateTaskTest extends BaseTaskTest { @Test public void deactivateVfModuleExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVfModuleResources).deactivateVfModule(vfModule, genericVnf, - serviceInstance, customer, cloudRegion, requestContext); + doThrow(RuntimeException.class).when(sdncVfModuleResources).deactivateVfModule(eq(vfModule), eq(genericVnf), + eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncDeactivateTasks.deactivateVfModule(execution); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java index b5d34ea4c9..6a94b357e0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java @@ -23,8 +23,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; import java.io.IOException; import java.io.StringReader; import java.nio.file.Files; @@ -39,7 +37,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; @@ -69,6 +66,7 @@ public class SDNCRequestTasksTest extends SDNCRequestTasks { @Mock SDNCClient sdncClient; + @Spy private ExceptionBuilder exceptionBuilder; @@ -151,7 +149,7 @@ public class SDNCRequestTasksTest extends SDNCRequestTasks { db = dbf.newDocumentBuilder(); Document doc = db.parse(new InputSource(new StringReader(sdncResponse))); - String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator"); + String finalMessageIndicator = getXmlElement(doc, "//*:ack-final-indicator"); String responseCode = getXmlElement(doc, "/input/response-code"); String responseMessage = getXmlElement(doc, "/input/response-message"); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java index 968723c628..10c034dc36 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java @@ -29,6 +29,7 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.net.URI; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; @@ -81,6 +82,7 @@ public class SDNCUnassignTasksTest extends BaseTaskTest { when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) .thenReturn(serviceInstance); + when(env.getRequiredProperty("mso.workflow.message.endpoint")).thenReturn("http://localhost:9090"); } @Test @@ -105,9 +107,10 @@ public class SDNCUnassignTasksTest extends BaseTaskTest { @Test public void unassignVfModuleTest() throws Exception { doReturn(new GenericResourceApiVfModuleOperationInformation()).when(sdncVfModuleResources) - .unassignVfModule(vfModule, genericVnf, serviceInstance); + .unassignVfModule(eq(vfModule), eq(genericVnf), eq(serviceInstance), any(URI.class)); sdncUnassignTasks.unassignVfModule(execution); - verify(sdncVfModuleResources, times(1)).unassignVfModule(vfModule, genericVnf, serviceInstance); + verify(sdncVfModuleResources, times(1)).unassignVfModule(eq(vfModule), eq(genericVnf), eq(serviceInstance), + any(URI.class)); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VFMODULE, sdncRequest.getTopology()); } @@ -115,8 +118,8 @@ public class SDNCUnassignTasksTest extends BaseTaskTest { @Test public void unassignVfModuleExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVfModuleResources).unassignVfModule(vfModule, genericVnf, - serviceInstance); + doThrow(RuntimeException.class).when(sdncVfModuleResources).unassignVfModule(eq(vfModule), eq(genericVnf), + eq(serviceInstance), any(URI.class)); sdncUnassignTasks.unassignVfModule(execution); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java new file mode 100644 index 0000000000..c05fd879ac --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java @@ -0,0 +1,219 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.InjectMocks; +import org.mockito.Mockito; +import org.onap.aai.domain.yang.AggregateRoute; +import org.onap.aai.domain.yang.AggregateRoutes; +import org.onap.aai.domain.yang.L3Network; +import org.onap.aai.domain.yang.RouteTarget; +import org.onap.aai.domain.yang.RouteTargets; +import org.onap.aai.domain.yang.Subnet; +import org.onap.aai.domain.yang.Subnets; +import org.onap.aai.domain.yang.VpnBinding; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class VrfValidationTest extends BaseTaskTest { + + protected ObjectMapper mapper = new ObjectMapper(); + + @InjectMocks + protected VrfValidation vrfValidation; + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + @Before + public void before() throws Exception { + vrfValidation.setBbInputSetupUtils(bbSetupUtils); + } + + @Test + public void testVrfServiceValidation() throws VrfBondingServiceException { + Service service = new Service(); + service.setModelName("modelName"); + service.setServiceType("BONDING"); + service.setServiceRole("VPN"); + exceptionRule.expect(VrfBondingServiceException.class); + exceptionRule.expectMessage( + "Service: modelName does not have service type of BONDING and does not have service role of INFRASTRUCTURE-VPN"); + vrfValidation.vrfServiceValidation(service); + + service.setServiceType("BOND"); + service.setServiceRole("INFRASTRUCTURE-VPN"); + exceptionRule.expect(VrfBondingServiceException.class); + exceptionRule.expectMessage( + "Service: modelName does not have service type of BONDING and does not have service role of INFRASTRUCTURE-VPN"); + vrfValidation.vrfServiceValidation(service); + + service.setServiceType("BONDING"); + service.setServiceRole("INFRASTRUCTURE-VPN"); + ExpectedException.none(); + vrfValidation.vrfServiceValidation(service); + } + + @Test + public void testVrfCatalogDbChecks() throws VrfBondingServiceException { + Service service = new Service(); + service.setModelName("modelName"); + ConfigurationResourceCustomization configuration = new ConfigurationResourceCustomization(); + service.setConfigurationCustomizations(new ArrayList<>()); + service.getConfigurationCustomizations().add(configuration); + ServiceProxyResourceCustomization serviceProxy = new ServiceProxyResourceCustomization(); + configuration.setServiceProxyResourceCustomization(serviceProxy); + service.setServiceProxyCustomizations(new ArrayList<>()); + service.getServiceProxyCustomizations().add(serviceProxy); + Service sourceService = new Service(); + sourceService.setServiceType("TRANSPORT"); + serviceProxy.setSourceService(sourceService); + configuration.setType("VRF-ENTRY"); + configuration.setRole("INFRASTRUCTURE-CLOUD-VPN"); + ExpectedException.none(); + vrfValidation.vrfCatalogDbChecks(service); + } + + @Test + public void testAaiVpnBindingValidation() throws VrfBondingServiceException { + org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = new org.onap.aai.domain.yang.VpnBinding(); + aaiVpnBinding.setVpnType("SERVICE-INFRASTRUCTURE"); + ExpectedException.none(); + vrfValidation.aaiVpnBindingValidation("test-vpn", aaiVpnBinding); + } + + @Test + public void testAaiVpnBindingValidationVpnBindingIsNull() throws VrfBondingServiceException { + exceptionRule.expect(VrfBondingServiceException.class); + exceptionRule.expectMessage("The infrastructure vpn test-vpn does not exist in A&AI."); + vrfValidation.aaiVpnBindingValidation("test-vpn", null); + } + + @Test + public void testAaiNetworkValidation() throws VrfBondingServiceException { + org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network(); + aaiLocalNetwork.setNetworkId("test-network"); + ExpectedException.none(); + vrfValidation.aaiNetworkValidation("test-network", aaiLocalNetwork); + } + + @Test + public void testAaiNetworkValidationNetworkIsNull() throws VrfBondingServiceException { + exceptionRule.expect(VrfBondingServiceException.class); + exceptionRule.expectMessage("The local network test-network does not exist in A&AI."); + vrfValidation.aaiNetworkValidation("test-network", null); + } + + @Test + public void testAaiAggregateRouteValidation() throws VrfBondingServiceException { + org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network(); + aaiLocalNetwork.setAggregateRoutes(new AggregateRoutes()); + aaiLocalNetwork.getAggregateRoutes().getAggregateRoute().add(new AggregateRoute()); + aaiLocalNetwork.getAggregateRoutes().getAggregateRoute().get(0).setIpVersion("4"); + ExpectedException.none(); + vrfValidation.aaiAggregateRouteValidation(aaiLocalNetwork); + + aaiLocalNetwork.getAggregateRoutes().getAggregateRoute().add(new AggregateRoute()); + aaiLocalNetwork.getAggregateRoutes().getAggregateRoute().get(1).setIpVersion("6"); + ExpectedException.none(); + vrfValidation.aaiAggregateRouteValidation(aaiLocalNetwork); + + aaiLocalNetwork.setAggregateRoutes(null); + ExpectedException.none(); + vrfValidation.aaiAggregateRouteValidation(aaiLocalNetwork); + } + + @Test + public void testAaiSubnetValidation() throws VrfBondingServiceException { + org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network(); + aaiLocalNetwork.setNetworkId("myNetworkID"); + aaiLocalNetwork.setSubnets(new Subnets()); + aaiLocalNetwork.getSubnets().getSubnet().add(new Subnet()); + aaiLocalNetwork.getSubnets().getSubnet().get(0).setIpVersion("4"); + ExpectedException.none(); + vrfValidation.aaiSubnetValidation(aaiLocalNetwork); + + aaiLocalNetwork.getSubnets().getSubnet().add(new Subnet()); + aaiLocalNetwork.getSubnets().getSubnet().get(1).setIpVersion("6"); + ExpectedException.none(); + vrfValidation.aaiSubnetValidation(aaiLocalNetwork); + + aaiLocalNetwork.setSubnets(null); + exceptionRule.expect(VrfBondingServiceException.class); + exceptionRule.expectMessage("LocalNetwork: myNetworkID has no subnets"); + vrfValidation.aaiSubnetValidation(aaiLocalNetwork); + } + + @Test + public void testIpVersionValidation() { + String ipVersion1 = "4"; + String ipVersion2 = "6"; + boolean validation = vrfValidation.ipVersionValidation(ipVersion1, ipVersion2); + assertEquals("Validation is correct", true, validation); + + + validation = vrfValidation.ipVersionValidation(ipVersion2, ipVersion1); + assertEquals("Validation is correct", true, validation); + + ipVersion1 = "6"; + validation = vrfValidation.ipVersionValidation(ipVersion1, ipVersion2); + assertEquals("Validation is correct", false, validation); + } + + @Test + public void testAaiRouteTargetValidation() + throws VrfBondingServiceException, JsonParseException, JsonMappingException, IOException { + L3Network l3Network = mapper.readValue( + new File("src/test/resources/__files/BuildingBlocks/aaiNetworkWrapper.json"), L3Network.class); + AAIResultWrapper networkWrapper = new AAIResultWrapper(l3Network); + if (networkWrapper.getRelationships().isPresent()) { + List<AAIResourceUri> vpnBindingUris = + networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING); + VpnBinding vpnBinding = new VpnBinding(); + vpnBinding.setRouteTargets(new RouteTargets()); + vpnBinding.getRouteTargets().getRouteTarget().add(new RouteTarget()); + AAIResultWrapper wrapper = Mockito.mock(AAIResultWrapper.class); + doReturn(wrapper).when(bbSetupUtils).getAAIResourceDepthOne(vpnBindingUris.get(0)); + doReturn(Optional.of(vpnBinding)).when(wrapper).asBean(VpnBinding.class); + ExpectedException.none(); + vrfValidation.aaiRouteTargetValidation(l3Network); + } + } +} 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..c683303a41 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 @@ -21,11 +21,13 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.isA; 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.Before; @@ -84,6 +86,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 +145,19 @@ 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)).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/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 1013cc8330..aac09b4475 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -42,6 +42,7 @@ import org.mockito.Mockito; import org.mockito.Spy; import org.onap.aai.domain.yang.GenericVnf; import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; @@ -72,6 +73,9 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { @Mock protected Environment environment; + @Mock + private FlowManipulatorListenerRunner flowManipulatorListenerRunner; + @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index ad1238b86f..09ba55aac0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -22,12 +22,17 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; @@ -45,6 +50,7 @@ import java.util.UUID; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.javatuples.Pair; import org.junit.Before; import org.junit.Ignore; import org.junit.Rule; @@ -60,7 +66,6 @@ import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; -import org.onap.aai.domain.yang.Vnfc; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; @@ -78,6 +83,7 @@ import org.onap.so.db.catalog.beans.CollectionResource; import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.ConfigurationResource; +import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.HeatEnvironment; import org.onap.so.db.catalog.beans.HeatTemplate; @@ -86,7 +92,6 @@ import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; -import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.serviceinstancebeans.RequestDetails; @@ -1550,7 +1555,7 @@ public class WorkflowActionTest extends BaseTaskTest { @Ignore @Test - public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException { + public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException, VrfBondingServiceException { execution.setVariable("testProcessKey", "testProcessKeyValue"); Service service = new Service(); List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>(); @@ -1584,7 +1589,8 @@ public class WorkflowActionTest extends BaseTaskTest { ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); List<Resource> resourceCounter = new ArrayList<>(); thrown.expect(BpmnError.class); - workflowAction.traverseCatalogDbService(execution, sIRequest, resourceCounter); + List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); + workflowAction.traverseCatalogDbService(execution, sIRequest, resourceCounter, aaiResourceIds); } @Test @@ -1672,6 +1678,72 @@ public class WorkflowActionTest extends BaseTaskTest { assertNotNull(result); } + @Test + public void traverseAAIServiceTest() { + List<Resource> resourceCounter = new ArrayList<>(); + String resourceId = "si0"; + List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); + + ServiceInstance serviceInstanceAAI = new ServiceInstance(); + serviceInstanceAAI.setServiceInstanceId(resourceId); + + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = setServiceInstance(); + setGenericVnf(); + setVfModule(true); + setVolumeGroup(); + setL3Network(); + setCollection(); + setConfiguration(); + + Configuration config = new Configuration(); + config.setConfigurationId("testConfigurationId2"); + serviceInstance.getConfigurations().add(config); + + Relationship relationship1 = new Relationship(); + relationship1.setRelatedTo("vnfc"); + RelationshipList relationshipList1 = new RelationshipList(); + relationshipList1.getRelationship().add(relationship1); + + Relationship relationship2 = new Relationship(); + relationship2.setRelatedTo("vpn-binding"); + RelationshipList relationshipList2 = new RelationshipList(); + relationshipList2.getRelationship().add(relationship2); + + org.onap.aai.domain.yang.Configuration aaiConfiguration1 = new org.onap.aai.domain.yang.Configuration(); + aaiConfiguration1.setConfigurationId("testConfigurationId"); + aaiConfiguration1.setRelationshipList(relationshipList1); + + org.onap.aai.domain.yang.Configuration aaiConfiguration2 = new org.onap.aai.domain.yang.Configuration(); + aaiConfiguration2.setConfigurationId("testConfigurationId2"); + aaiConfiguration2.setRelationshipList(relationshipList1); + + try { + doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById(resourceId); + doReturn(serviceInstance).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + doReturn(Optional.of(aaiConfiguration1)).when(aaiConfigurationResources) + .getConfiguration("testConfigurationId"); + doReturn(Optional.of(aaiConfiguration2)).when(aaiConfigurationResources) + .getConfiguration("testConfigurationId2"); + workflowAction.traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds); + assertEquals(8, resourceCounter.size()); + assertThat(aaiResourceIds, sameBeanAs(getExpectedResourceIds())); + } catch (Exception e) { + fail("Unexpected exception was thrown."); + } + } + + private List<Pair<WorkflowType, String>> getExpectedResourceIds() { + List<Pair<WorkflowType, String>> resourceIds = new ArrayList<>(); + resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, "testVnfId1")); + resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VFMODULE, "testVfModuleId1")); + resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP, "testVolumeGroupId1")); + resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORK, "testNetworkId1")); + resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION, "testId")); + resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, "testConfigurationId")); + resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, "testConfigurationId2")); + return resourceIds; + } + private List<OrchestrationFlow> createFlowList(String... flowNames) { List<OrchestrationFlow> result = new ArrayList<>(); for (String flowName : flowNames) { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java new file mode 100644 index 0000000000..b6f8aafa55 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import java.util.ArrayList; +import java.util.List; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.common.BBConstants; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.infrastructure.workflow.tasks.listeners.MultiStageSkipListener; +import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; + +@RunWith(MockitoJUnitRunner.class) +public class MultiStageSkipTest { + + @Mock + private CatalogDbClient catalogDbClient; + + @Mock + private BBInputSetupUtils bbInputSetupUtils; + + @InjectMocks + private MultiStageSkipListener multiStageSkipListener; + + @Test + public void testTrigger() { + BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake()); + execution.setVariable(BBConstants.G_ALACARTE, true); + + assertTrue("should be triggered", multiStageSkipListener.shouldRunFor("AssignVfModuleBB", true, execution)); + + execution.setVariable(BBConstants.G_ALACARTE, false); + assertFalse("should not be triggered", + multiStageSkipListener.shouldRunFor("AssignVfModuleBB", true, execution)); + + execution.setVariable(BBConstants.G_ALACARTE, true); + assertFalse("should not be triggered", + multiStageSkipListener.shouldRunFor("AssignVfModuleBB2", true, execution)); + + + } + + @Test + public void testProcessMultiStageSkip() { + String vfModuleId = "vfModuleId"; + String vnfId = "vnfId"; + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId("serviceInstanceId"); + workflowResourceIds.setVnfId(vnfId); + flowsToExecute.add(new ExecuteBuildingBlock()); + flowsToExecute.add(new ExecuteBuildingBlock()); + flowsToExecute.add(new ExecuteBuildingBlock()); + flowsToExecute.get(0).setResourceId(vfModuleId); + flowsToExecute.get(0).setBuildingBlock(new BuildingBlock()); + flowsToExecute.get(0).getBuildingBlock().setBpmnFlowName("AssignVfModuleBB"); + flowsToExecute.get(0).setWorkflowResourceIds(workflowResourceIds); + BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake()); + + org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule(); + vfModule.setVfModuleId(vfModuleId); + org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf(); + vnf.setModelCustomizationId("modelCustomizationUUID"); + VnfResourceCustomization vnfCust = new VnfResourceCustomization(); + vnfCust.setModelCustomizationUUID("modelCustomizationUUID"); + vnfCust.setMultiStageDesign("true"); + when(catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(vnf.getModelCustomizationId())) + .thenReturn(vnfCust); + when(bbInputSetupUtils.getAAIVfModule(eq(vnfId), eq(vfModuleId))).thenReturn(null); + when(bbInputSetupUtils.getAAIGenericVnf(eq(vnfId))).thenReturn(vnf); + + multiStageSkipListener.run(flowsToExecute, flowsToExecute.get(0), execution); + assertEquals("Flows should only have Assign", flowsToExecute.size(), 1); + assertEquals("Flows should only have Assign", flowsToExecute.get(0).getBuildingBlock().getBpmnFlowName(), + "AssignVfModuleBB"); + + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java index ccd677c80e..d6485bd57f 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapperTest.java @@ -21,8 +21,7 @@ package org.onap.so.client.adapter.network.mapper; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.*; -import static org.mockito.ArgumentMatchers.isA; +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.doReturn; import java.io.UnsupportedEncodingException; import java.nio.file.Files; @@ -39,7 +38,6 @@ import org.onap.so.adapters.nwrest.ContrailNetwork; import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; -import org.onap.so.adapters.nwrest.NetworkTechnology; import org.onap.so.adapters.nwrest.ProviderVlanNetwork; import org.onap.so.adapters.nwrest.RollbackNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; @@ -385,4 +383,19 @@ public class NetworkAdapterObjectMapperTest extends TestDataSetup { assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("messageId") .ignoring("msoRequest.requestId").ignoring("networkParams")); } + + @Test + public void buildOpenstackSubnetListMultipleHostRoutesTest() throws Exception { + + ObjectMapper omapper = new ObjectMapper(); + String l3NetworkJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "l3-network-multiple-subnets.json"))); + L3Network l3Network = omapper.readValue(l3NetworkJson, L3Network.class); + + List<org.onap.so.openstack.beans.Subnet> subnets = + SPY_networkAdapterObjectMapper.buildOpenstackSubnetList(l3Network); + assertEquals("192.168.0.0/16", subnets.get(0).getHostRoutes().get(0).getPrefix()); + assertEquals("192.168.1.5/16", subnets.get(0).getHostRoutes().get(1).getPrefix()); + + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java index 5a8e57135a..44a08139d6 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java @@ -29,7 +29,9 @@ import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.onap.sdnc.northbound.client.model.GenericResourceApiVmNetworkData; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; @@ -43,6 +45,8 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; +import org.onap.so.openstack.utils.MsoMulticloudUtils; +import org.onap.so.client.adapter.vnf.mapper.exceptions.MissingValueTagException; import com.fasterxml.jackson.databind.ObjectMapper; public class VnfAdapterVfModuleObjectMapperPayloadTest { @@ -52,6 +56,9 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { private VnfAdapterVfModuleObjectMapper vfModuleObjectMapper = new VnfAdapterVfModuleObjectMapper(); private ObjectMapper omapper = new ObjectMapper(); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @Before public void setUp() { vfModuleObjectMapper.vnfAdapterObjectMapperUtils = new VnfAdapterObjectMapperUtils(); @@ -362,6 +369,34 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { } @Test + public void buildDirectivesParamFromMapNoValueTagTest() throws Exception { + + Map<String, Object> paramsMap = new HashMap<>(); + Map<String, Object> srcMap = new HashMap<>(); + srcMap.put("key1", "value1"); + srcMap.put("key2", "value2"); + srcMap.put("key3", null); + + expectedException.expect(MissingValueTagException.class); + vfModuleObjectMapper.buildDirectivesParamFromMap(paramsMap, MsoMulticloudUtils.SDNC_DIRECTIVES, srcMap); + } + + @Test + public void buildDirectivesParamFromMapSunnyDayTest() throws Exception { + + Map<String, Object> paramsMap = new HashMap<>(); + Map<String, Object> srcMap = new HashMap<>(); + srcMap.put("key1", "value1"); + srcMap.put("key2", "value2"); + String expectedResult = + "[{ \"attributes\": [ {\"attribute_name\": \"key1\", \"attribute_value\": \"value1\"}, {\"attribute_name\": \"key2\", \"attribute_value\": \"value2\"}] }]"; + + vfModuleObjectMapper.buildDirectivesParamFromMap(paramsMap, MsoMulticloudUtils.SDNC_DIRECTIVES, srcMap); + + assertEquals(expectedResult, paramsMap.values().toString()); + } + + @Test public void createVfModuleWithVolumeGroupRequestMapperTest() throws Exception { // prepare and set service instance diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java index f50916c0be..f7fd00a673 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingClientResponseValidatorTest.java @@ -36,6 +36,7 @@ public class NamingClientResponseValidatorTest extends TestDataSetup { private NamingClientResponseValidator responseValidator = new NamingClientResponseValidator(); private String instanceGroupName = "generatedInstanceGroupName"; + private String serviceInstanceName = "generatedServiceInstanceName"; @Test public void validateNameGenResponseSuccessTest() throws BadResponseException { @@ -54,6 +55,22 @@ public class NamingClientResponseValidatorTest extends TestDataSetup { } @Test + public void validateServiceInstanceNameGenResponseSuccessTest() throws BadResponseException { + NameGenResponse name = new NameGenResponse(); + Respelement respElement = new Respelement(); + respElement.setResourceName("Service-Instance-Name"); + respElement.setResourceValue(serviceInstanceName); + List<Respelement> respList = new ArrayList<Respelement>(); + respList.add(respElement); + name.setElements(respList); + ResponseEntity<NameGenResponse> resp = new ResponseEntity<>(name, null, HttpStatus.OK); + + String actual = responseValidator.validateNameGenResponse(resp); + + assertEquals(actual, "generatedServiceInstanceName"); + } + + @Test public void validateNameGenResponseNoNameGeneratedTest() throws BadResponseException { NameGenResponse name = new NameGenResponse(); Respelement respElement = new Respelement(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectTest.java new file mode 100644 index 0000000000..7c50b2031d --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestObjectTest.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.namingservice; + +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertThat; +import java.util.HashMap; +import org.junit.Test; +import org.onap.namingservice.model.Element; + +public class NamingRequestObjectTest { + + private String externalKey = "95cbbe59-1017-4c13-b4e8-d824e54def3e"; + private String policyInstanceName = "MSO_Policy.Config_MS_VNFInstanceGroup"; + private String namingType = "Service"; + private String nfNamingCode = "NamingCode"; + private String resourceName = "resourceName"; + private String serviceModelName = "serviceModelName"; + private String modelVersion = "modelVersion"; + + @Test + public void namingRequestObjectTest() { + + Element expected = new Element(); + expected.put(NamingServiceConstants.NS_EXTERNAL_KEY, externalKey); + expected.put(NamingServiceConstants.NS_POLICY_INSTANCE_NAME, policyInstanceName); + expected.put(NamingServiceConstants.NS_NAMING_TYPE, namingType); + expected.put(NamingServiceConstants.NS_RESOURCE_NAME, resourceName); + expected.put(NamingServiceConstants.NS_NF_NAMING_CODE, nfNamingCode); + + NamingRequestObject namingRequestObject = new NamingRequestObject(); + namingRequestObject.setExternalKeyValue(externalKey); + namingRequestObject.setPolicyInstanceNameValue(policyInstanceName); + namingRequestObject.setNamingTypeValue(namingType); + namingRequestObject.setNfNamingCodeValue(nfNamingCode); + namingRequestObject.setResourceNameValue(resourceName); + + HashMap<String, String> actual = namingRequestObject.getNamingRequestObjectMap(); + assertThat(actual, sameBeanAs(expected)); + } + + @Test + public void namingWanTransportRequestObjectTest() { + + Element expected = new Element(); + expected.put(NamingServiceConstants.NS_EXTERNAL_KEY, externalKey); + expected.put(NamingServiceConstants.NS_POLICY_INSTANCE_NAME, policyInstanceName); + expected.put(NamingServiceConstants.NS_NAMING_TYPE, namingType); + expected.put(NamingServiceConstants.NS_RESOURCE_NAME, resourceName); + expected.put(NamingServiceConstants.NS_SERVICE_MODEL_NAME, serviceModelName); + expected.put(NamingServiceConstants.NS_MODEL_VERSION, modelVersion); + + NamingRequestObject namingRequestObject = new NamingRequestObject(); + namingRequestObject.setExternalKeyValue(externalKey); + namingRequestObject.setPolicyInstanceNameValue(policyInstanceName); + namingRequestObject.setNamingTypeValue(namingType); + namingRequestObject.setResourceNameValue(resourceName); + namingRequestObject.setModelVersionValue(modelVersion); + namingRequestObject.setServiceModelNameValue(serviceModelName); + + HashMap<String, String> actual = namingRequestObject.getNamingRequestObjectMap(); + assertThat(actual, sameBeanAs(expected)); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestUtilsTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestUtilsTest.java new file mode 100644 index 0000000000..5fdb790405 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/namingservice/NamingRequestUtilsTest.java @@ -0,0 +1,136 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.namingservice; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.client.exception.BBObjectNotFoundException; + +public class NamingRequestUtilsTest extends BaseTaskTest { + + @Mock + private ServiceInstance serviceInstanceMock; + + @Mock + ModelInfoServiceInstance modelInfoServiceInstanceMock; + + @InjectMocks + private NamingServiceUtils namingServiceUtils = new NamingServiceUtils(); + + @Before + public void before() throws BBObjectNotFoundException { + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstanceMock); + doReturn(modelInfoServiceInstanceMock).when(serviceInstanceMock).getModelInfoServiceInstance(); + } + + @Test + public void checkVpnBondingServiceTest() { + doReturn("bonding").when(modelInfoServiceInstanceMock).getServiceType(); + doReturn("infrastructure-vpn").when(modelInfoServiceInstanceMock).getServiceRole(); + doReturn("testNaminPolicy").when(modelInfoServiceInstanceMock).getNamingPolicy(); + doReturn(true).when(modelInfoServiceInstanceMock).getOnapGeneratedNaming(); + namingServiceUtils.checkVpnBondingService(execution); + assertTrue(execution.getVariable("isVpnBondingService")); + + doReturn("bonding-false").when(modelInfoServiceInstanceMock).getServiceType(); + doReturn("infrastructure-vpn").when(modelInfoServiceInstanceMock).getServiceRole(); + namingServiceUtils.checkVpnBondingService(execution); + assertFalse(execution.getVariable("isVpnBondingService")); + } + + @Test + public void checkBondingAndInfrastureVpnTrueTest() { + doReturn("bonding").when(modelInfoServiceInstanceMock).getServiceType(); + doReturn("infrastructure-vpn").when(modelInfoServiceInstanceMock).getServiceRole(); + namingServiceUtils.checkBondingAndInfrastureVpn(execution); + assertTrue(execution.getVariable("isBondingAndInsfrastructureVpn")); + } + + @Test + public void checkBondingAndInfrastureVpnFalse1Test() { + doReturn("falseBonding").when(modelInfoServiceInstanceMock).getServiceType(); + doReturn("infrastructure-vpn").when(modelInfoServiceInstanceMock).getServiceRole(); + namingServiceUtils.checkBondingAndInfrastureVpn(execution); + assertFalse(execution.getVariable("isBondingAndInsfrastructureVpn")); + } + + @Test + public void checkBondingAndInfrastureVpnFalse2Test() { + doReturn("bonding").when(modelInfoServiceInstanceMock).getServiceType(); + doReturn("false-infrastructure-vpn").when(modelInfoServiceInstanceMock).getServiceRole(); + namingServiceUtils.checkBondingAndInfrastureVpn(execution); + assertFalse(execution.getVariable("isBondingAndInsfrastructureVpn")); + } + + @Test + public void checkNamingPolicyAndAndEcompGeneratedNaming_TrueTest() { + doReturn("testNaminPolicy").when(modelInfoServiceInstanceMock).getNamingPolicy(); + doReturn(true).when(modelInfoServiceInstanceMock).getOnapGeneratedNaming(); + namingServiceUtils.checkNamingPolicyAndOnapGeneratedNaming(execution); + assertTrue(execution.getVariable("isNamingPolicyAndOnapGeneratedNaming")); + } + + @Test + public void checkNamingPolicyAndAndEcompGeneratedNamingFalse1Test() throws BBObjectNotFoundException { + doReturn(null).when(modelInfoServiceInstanceMock).getNamingPolicy(); + doReturn(true).when(modelInfoServiceInstanceMock).getOnapGeneratedNaming(); + namingServiceUtils.checkNamingPolicyAndOnapGeneratedNaming(execution); + assertFalse(execution.getVariable("isNamingPolicyAndOnapGeneratedNaming")); + } + + @Test + public void checkNamingPolicyAndAndEcompGeneratedNamingFalse2Test() throws BBObjectNotFoundException { + doReturn("testNaminPolicy").when(modelInfoServiceInstanceMock).getNamingPolicy(); + doReturn(false).when(modelInfoServiceInstanceMock).getOnapGeneratedNaming(); + namingServiceUtils.checkNamingPolicyAndOnapGeneratedNaming(execution); + assertFalse(execution.getVariable("isNamingPolicyAndOnapGeneratedNaming")); + } + + @Test + public void checkNamingPolicyAndAndEcompGeneratedNamingFalse3Test() throws BBObjectNotFoundException { + doReturn("").when(modelInfoServiceInstanceMock).getNamingPolicy(); + doReturn(false).when(modelInfoServiceInstanceMock).getOnapGeneratedNaming(); + namingServiceUtils.checkNamingPolicyAndOnapGeneratedNaming(execution); + assertFalse(execution.getVariable("isNamingPolicyAndOnapGeneratedNaming")); + } + + @Test + public void checkNamingPolicyAndAndEcompGeneratedNamingFalse4Test() throws BBObjectNotFoundException { + doReturn("bonding").when(modelInfoServiceInstanceMock).getNamingPolicy(); + doReturn(null).when(modelInfoServiceInstanceMock).getOnapGeneratedNaming(); + namingServiceUtils.checkNamingPolicyAndOnapGeneratedNaming(execution); + assertFalse(execution.getVariable("isNamingPolicyAndOnapGeneratedNaming")); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java index be58ccb046..68f3d20c82 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIConfigurationResourcesTest.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. @@ -20,6 +20,8 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; @@ -44,6 +46,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.AAIEdgeLabel; @@ -231,4 +234,32 @@ public class AAIConfigurationResourcesTest extends TestDataSetup { verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), ArgumentMatchers.isNull()); assertEquals(OrchestrationStatus.ACTIVE, configuration.getOrchestrationStatus()); } + + @Test + public void updateConfigurationOrchestrationStatusTest() throws Exception { + doNothing().when(MOCK_aaiResourcesClient).update(isA(AAIResourceUri.class), + isA(org.onap.aai.domain.yang.Configuration.class)); + aaiConfigurationResources.updateConfigurationOrchestrationStatus(configuration, OrchestrationStatus.ACTIVE); + verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), + any(org.onap.aai.domain.yang.Configuration.class)); + } + + @Test + public void checkConfigurationNameInUseTrueTest() throws Exception { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION) + .queryParam("configuration-name", "configurationName"); + doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(uri)); + boolean nameInUse = aaiConfigurationResources.checkConfigurationNameInUse("configurationName"); + assertTrue(nameInUse); + } + + @Test + public void checkConfigurationNameInUseFalseTest() throws Exception { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION) + .queryParam("configuration-name", "configurationName"); + doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(uri)); + boolean nameInUse = aaiConfigurationResources.checkConfigurationNameInUse("configurationName"); + assertFalse(nameInUse); + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java index 8c0d27f799..cb5683d9d8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIInstanceGroupResourcesTest.java @@ -22,6 +22,8 @@ package org.onap.so.client.orchestration; import static org.mockito.ArgumentMatchers.eq; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; @@ -40,6 +42,7 @@ import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.AAIEdgeLabel; @@ -131,4 +134,22 @@ public class AAIInstanceGroupResourcesTest extends TestDataSetup { verify(MOCK_aaiResourcesClient, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class)); } + @Test + public void checkInstanceGroupNameInUseTrueTest() throws Exception { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.INSTANCE_GROUP) + .queryParam("instance-group-name", "instanceGroupName"); + doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(uri)); + boolean nameInUse = aaiInstanceGroupResources.checkInstanceGroupNameInUse("instanceGroupName"); + assertTrue(nameInUse); + } + + @Test + public void checkInstanceGroupNameInUseFalseTest() throws Exception { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.INSTANCE_GROUP) + .queryParam("instance-group-name", "instanceGroupName"); + doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(uri)); + boolean nameInUse = aaiInstanceGroupResources.checkInstanceGroupNameInUse("instanceGroupName"); + assertFalse(nameInUse); + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java index d41148d784..b6161d7669 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAINetworkResourcesTest.java @@ -23,6 +23,7 @@ package org.onap.so.client.orchestration; 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.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; @@ -425,4 +426,22 @@ public class AAINetworkResourcesTest extends TestDataSetup { verify(MOCK_aaiResourcesClient, times(1)).delete(any(AAIResourceUri.class)); } + @Test + public void checkInstanceGroupNameInUseTrueTest() throws Exception { + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", "networkName"); + doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(uri)); + boolean nameInUse = aaiNetworkResources.checkNetworkNameInUse("networkName"); + assertTrue(nameInUse); + } + + @Test + public void checkInstanceGroupNameInUseFalseTest() throws Exception { + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", "networkName"); + doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(uri)); + boolean nameInUse = aaiNetworkResources.checkNetworkNameInUse("networkName"); + assertFalse(nameInUse); + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java index 14df832754..ea98ee0169 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIServiceInstanceResourcesTest.java @@ -21,8 +21,11 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; @@ -43,8 +46,10 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -186,4 +191,23 @@ public class AAIServiceInstanceResourcesTest extends TestDataSetup { verify(MOCK_aaiResourcesClient, times(1)).update(any(AAIResourceUri.class), any(org.onap.aai.domain.yang.ServiceInstance.class)); } + + @Test + public void checkInstanceServiceNameInUseTrueTest() throws Exception { + AAIResourceUri uri = AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE) + .queryParam("service-instance-name", serviceInstance.getServiceInstanceName()); + doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(uri)); + boolean nameInUse = aaiServiceInstanceResources.checkInstanceServiceNameInUse(serviceInstance); + assertTrue(nameInUse); + } + + @Test + public void checkInstanceServiceNameInUseFalseTest() throws Exception { + AAIResourceUri uri = AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE) + .queryParam("service-instance-name", serviceInstance.getServiceInstanceName()); + doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(uri)); + boolean nameInUse = aaiServiceInstanceResources.checkInstanceServiceNameInUse(serviceInstance); + assertFalse(nameInUse); + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java index ae3ebeddbd..9e3bc4f552 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVfModuleResourcesTest.java @@ -21,7 +21,10 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -41,8 +44,10 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -154,4 +159,39 @@ public class AAIVfModuleResourcesTest extends TestDataSetup { assertEquals("testContrailServiceInstanceFqdn", vfModule.getContrailServiceInstanceFqdn()); } + + @Test + public void checkNameInUseTrueTest() throws Exception { + AAIResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE) + .queryParam("vf-module-name", vfModule.getVfModuleName()); + AAIResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id", + vfModule.getModelInfoVfModule().getModelCustomizationUUID()); + doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(vfModuleUriWithCustomization)); + doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(vfModuleUri)); + boolean nameInUse = aaiVfModuleResources.checkNameInUse(vfModule); + assertTrue(nameInUse); + } + + @Test + public void checkNameInUseFalseIsResumeTest() throws Exception { + AAIResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE) + .queryParam("vf-module-name", vfModule.getVfModuleName()); + AAIResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id", + vfModule.getModelInfoVfModule().getModelCustomizationUUID()); + doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(vfModuleUriWithCustomization)); + boolean nameInUse = aaiVfModuleResources.checkNameInUse(vfModule); + assertFalse(nameInUse); + } + + @Test + public void checkNameInUseFalseTest() throws Exception { + AAIResourceUri vfModuleUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE) + .queryParam("vf-module-name", vfModule.getVfModuleName()); + AAIResourceUri vfModuleUriWithCustomization = vfModuleUri.clone().queryParam("model-customization-id", + vfModule.getModelInfoVfModule().getModelCustomizationUUID()); + doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(vfModuleUriWithCustomization)); + doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(vfModuleUri)); + boolean nameInUse = aaiVfModuleResources.checkNameInUse(vfModule); + assertFalse(nameInUse); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java index cdc601c1e4..0d48a29ca9 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java @@ -21,6 +21,7 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -45,9 +46,11 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.AAIValidatorImpl; +import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @@ -227,4 +230,23 @@ public class AAIVnfResourcesTest extends TestDataSetup { verify(MOCK_aaiValidatorImpl, times(1)).isPhysicalServerLocked(isA(String.class)); assertTrue(isVnfPserversLockedFlag); } + + + @Test + public void checkNameInUseTrueTest() { + AAIResourceUri vnfUri = + AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", "vnfName"); + doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(vnfUri)); + boolean nameInUse = aaiVnfResources.checkNameInUse("vnfName"); + assertTrue(nameInUse); + } + + @Test + public void checkNameInUseFalseTest() { + AAIResourceUri vnfUri = + AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", "vnfName"); + doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(vnfUri)); + boolean nameInUse = aaiVnfResources.checkNameInUse("vnfName"); + assertFalse(nameInUse); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java index 2bdcf30a4c..5772cab995 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVolumeGroupResourcesTest.java @@ -21,7 +21,10 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -39,8 +42,11 @@ import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -146,4 +152,22 @@ public class AAIVolumeGroupResourcesTest extends TestDataSetup { assertEquals("testVolumeHeatStackId", volumeGroup.getHeatStackId()); } + + @Test + public void checkNameInUseTrueTest() { + AAIResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) + .queryParam("volume-group-name", "testVolumeGroupName1"); + doReturn(true).when(MOCK_aaiResourcesClient).exists(eq(volumeGroupUri)); + boolean nameInUse = aaiVolumeGroupResources.checkNameInUse(volumeGroup); + assertTrue(nameInUse); + } + + @Test + public void checkNameInUseFalseTest() { + AAIResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP) + .queryParam("volume-group-name", "testVolumeGroupName1"); + doReturn(false).when(MOCK_aaiResourcesClient).exists(eq(volumeGroupUri)); + boolean nameInUse = aaiVolumeGroupResources.checkNameInUse(volumeGroup); + assertFalse(nameInUse); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java index 195c89a651..c60e749a29 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/NamingServiceResourcesTest.java @@ -42,7 +42,9 @@ import org.onap.namingservice.model.NameGenRequest; import org.onap.namingservice.model.NameGenResponse; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.client.namingservice.NamingClient; +import org.onap.so.client.namingservice.NamingRequestObject; import org.onap.so.client.namingservice.NamingRequestObjectBuilder; +import org.onap.so.client.namingservice.NamingServiceConstants; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -100,5 +102,37 @@ public class NamingServiceResourcesTest extends TestDataSetup { } + @Test + public void generateServiceInstanceNameTest() throws Exception { + + NameGenRequest req = new NameGenRequest(); + doReturn("generatedServiceInstanceName").when(MOCK_namingClient).postNameGenRequest(isA(NameGenRequest.class)); + doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenRequestMapper(isA(List.class)); + NamingRequestObject nrObject = new NamingRequestObject(); + nrObject.setExternalKeyValue("testExternalKey"); + nrObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE); + nrObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME); + nrObject.setPolicyInstanceNameValue(execution.getVariable("policyInstanceName")); + nrObject.setServiceModelNameValue("testServiceInstanceModelName"); + nrObject.setModelVersionValue("testServiceInstanceModelVersion"); + nrObject.setZoneIdValue(execution.getVariable("zoneId")); + + String generatedName = namingServiceResources.generateServiceInstanceName(nrObject); + + verify(MOCK_namingClient, times(1)).postNameGenRequest(any(NameGenRequest.class)); + assertEquals("generatedServiceInstanceName", generatedName); + } + + @Test + public void deleteServiceInstanceNameTest() throws Exception { + NameGenDeleteRequest req = new NameGenDeleteRequest(); + doReturn(req).when(MOCK_namingRequestObjectBuilder).nameGenDeleteRequestMapper(isA(List.class)); + + NamingRequestObject nrObject = new NamingRequestObject(); + nrObject.setExternalKeyValue("testExternalKey"); + nrObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE); + namingServiceResources.deleteServiceInstanceName(nrObject); + verify(MOCK_namingClient, times(1)).deleteNameGenRequest(any(NameGenDeleteRequest.class)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java index 2b45a3302c..57d6496a4f 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVfModuleResourcesTest.java @@ -23,6 +23,8 @@ package org.onap.so.client.orchestration; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import java.net.URI; +import java.net.URISyntaxException; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -62,6 +64,8 @@ public class SDNCVfModuleResourcesTest extends TestDataSetup { private RequestContext requestContext; private GenericResourceApiVfModuleOperationInformation sdncReq; + private URI testURI; + @Before public void before() { vfModule = buildVfModule(); @@ -72,60 +76,67 @@ public class SDNCVfModuleResourcesTest extends TestDataSetup { cloudRegion = buildCloudRegion(); requestContext = buildRequestContext(); sdncReq = new GenericResourceApiVfModuleOperationInformation(); + try { + testURI = new URI("http://localhost:9800"); + } catch (URISyntaxException e) { + + } } @Test public void assignVfModuleTest() throws MapperException { doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, - requestContext, null); + requestContext, null, testURI); sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, - requestContext); + requestContext, testURI); verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, serviceInstance, customer, cloudRegion, - requestContext, null); + requestContext, null, testURI); } @Test public void unassignVfModuleTest() throws MapperException { doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, - SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null); - sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance); + SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null, testURI); + sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance, testURI); verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, - SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null); + SDNCSvcAction.UNASSIGN, vfModule, null, vnf, serviceInstance, null, null, null, null, testURI); } @Test public void activateVfModuleTest() throws MapperException { doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, - null); - sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext); + null, testURI); + sdncVfModuleResources.activateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext, + testURI); verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, - null); + null, testURI); } @Test public void deactivateVfModuleTest() throws MapperException { doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, - null); - sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext); + null, testURI); + sdncVfModuleResources.deactivateVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, requestContext, + testURI); verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, vfModule, null, vnf, serviceInstance, customer, cloudRegion, requestContext, - null); + null, testURI); } @Test public void changeAssignVfModuleTest() throws MapperException, BadResponseException { doReturn(sdncReq).when(vfModuleTopologyMapper).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion, - requestContext, null); + requestContext, null, testURI); sdncVfModuleResources.changeAssignVfModule(vfModule, vnf, serviceInstance, customer, cloudRegion, - requestContext); + requestContext, testURI); verify(vfModuleTopologyMapper, times(1)).reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, vfModule, null, vnf, serviceInstance, customer, cloudRegion, - requestContext, null); + requestContext, null, testURI); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java index 275e9f7dbb..b71ddba63b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapperTest.java @@ -25,6 +25,7 @@ import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import java.net.URI; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; @@ -38,6 +39,7 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -53,7 +55,6 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(MockitoJUnitRunner.class) @@ -134,9 +135,9 @@ public class VfModuleTopologyOperationRequestMapperTest { CloudRegion cloudRegion = new CloudRegion(); - GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = - mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, - volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, null); + GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( + SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, volumeGroup, vnf, + serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); String jsonToCompare = new String(Files.readAllBytes( Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationAssign.json"))); @@ -145,7 +146,7 @@ public class VfModuleTopologyOperationRequestMapperTest { GenericResourceApiVfModuleOperationInformation reqMapper1 = omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class); - assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId") + assertThat(vfModuleSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId") .ignoring("requestInformation.requestId")); assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId()); } @@ -174,7 +175,7 @@ public class VfModuleTopologyOperationRequestMapperTest { GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, - vnf, serviceInstance, null, null, requestContext, null); + vnf, serviceInstance, null, null, requestContext, null, new URI("http://localhost:8080")); String jsonToCompare = new String(Files.readAllBytes( Paths.get(JSON_FILE_LOCATION + "genericResourceApiVfModuleOperationInformationUnassign.json"))); @@ -183,7 +184,7 @@ public class VfModuleTopologyOperationRequestMapperTest { GenericResourceApiVfModuleOperationInformation reqMapper1 = omapper.readValue(jsonToCompare, GenericResourceApiVfModuleOperationInformation.class); - assertThat(reqMapper1, sameBeanAs(vfModuleSDNCrequest).ignoring("sdncRequestHeader.svcRequestId") + assertThat(vfModuleSDNCrequest, sameBeanAs(reqMapper1).ignoring("sdncRequestHeader.svcRequestId") .ignoring("requestInformation.requestId")); assertEquals("MsoRequestId", vfModuleSDNCrequest.getRequestInformation().getRequestId()); } @@ -211,7 +212,7 @@ public class VfModuleTopologyOperationRequestMapperTest { GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, vfModule, null, - vnf, serviceInstance, null, null, requestContext, null); + vnf, serviceInstance, null, null, requestContext, null, new URI("http://localhost:8080")); assertNotNull(vfModuleSDNCrequest.getRequestInformation().getRequestId()); } @@ -271,9 +272,9 @@ public class VfModuleTopologyOperationRequestMapperTest { CloudRegion cloudRegion = new CloudRegion(); - GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = - mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, - vnf, serviceInstance, customer, cloudRegion, requestContext, null); + GenericResourceApiVfModuleOperationInformation vfModuleSDNCrequest = mapper.reqMapper( + SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, + serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); assertNull(vfModuleSDNCrequest.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); assertEquals("vnfModelCustomizationUuid", @@ -330,7 +331,7 @@ public class VfModuleTopologyOperationRequestMapperTest { expectedException.expectMessage(ERRORMESSAGE); mapper.reqMapper(SDNCSvcOperation.VF_MODULE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, vfModule, null, vnf, - serviceInstance, customer, cloudRegion, requestContext, null); + serviceInstance, customer, cloudRegion, requestContext, null, new URI("http://localhost:8080")); } } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json new file mode 100644 index 0000000000..e9b25ff266 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/l3-network-multiple-subnets.json @@ -0,0 +1,53 @@ +{ + "network-id" : "aNetworkId", + "cascaded" : false, + "cloud-params" : { }, + "network-name" : "aNetworkName", + "neutron-network-id" : null, + "network-type" : "aNetworkType", + "network-technology" : "aNetworkTechnology", + "network-role" : "", + "is-bound-to-vpn" : false, + "service-id" : "aServiceId", + "network-role-instance" : 0, + "orchestration-status" : "ACTIVE", + "heat-stack-id" : null, + "contrail-network-fqdn" : null, + "network-policies" : [ ], + "contrail-network-route-table-references" : [ ], + "widget-model-id" : null, + "widget-model-version" : null, + "physical-network-name" : "pNetworkName", + "is-provider-network" : false, + "is-shared-network" : false, + "is-external-network" : false, + "self-link" : "/", + "operational-status" : null, + "subnets" : [ { + "subnet-id" : "subnetId1", + "subnet-name" : "aSubnetName1", + "neutron-subnet-id" : null, + "gateway-address" : "192.168.1.1", + "network-start-address" : "192.168.1.2", + "cidr-mask" : "10", + "ip-version" : "4", + "orchestration-status" : "ACTIVE", + "dhcp-enabled" : true, + "dhcp-start" : "192.168.1.2", + "dhcp-end" : "192.168.1.16", + "subnet-role" : "", + "ip-assignment-direction" : "true", + "subnet-sequence" : null, + "host-routes": [{ + "host-route-id": "hrId1", + "route-prefix": "192.168.0.0/16", + "next-hop": "192.168.1.1", + "next-hop-type": null + }, { + "host-route-id": "hrId2", + "route-prefix": "192.168.1.5/16", + "next-hop": "192.168.1.1", + "next-hop-type": null + }] + }] +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1SP.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1SP.json new file mode 100644 index 0000000000..31e6fd5f53 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1SP.json @@ -0,0 +1,46 @@ +{ + "requestInfo" : { + "transactionId" : "testRequestId", + "requestId" : "testRequestId", + "callbackUrl" : "http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId", + "sourceId" : "mso", + "requestType" : "create", + "timeout" : 1800 + }, + "serviceInfo" : { + "modelInfo" : { + "modelName" : "testModelName1", + "modelVersionId" : "testModelUUID1", + "modelVersion" : "testModelVersion1", + "modelInvariantId" : "testModelInvariantUUID1" + }, + "serviceRole" : "testServiceRole1", + "serviceInstanceId" : "testServiceInstanceId1", + "serviceName" : "testServiceType1" + }, + "placementInfo" : { + "subscriberInfo" : { + "globalSubscriberId" : "testCustomerId", + "subscriberName" : "testCustomerName" + }, + "placementDemands" : [ { + "serviceResourceId" : "testProxyId1", + "resourceModuleName" : "testProxyInstanceName1", + "resourceModelInfo" : { + "modelName" : "testProxyModelName1", + "modelVersionId" : "testProxyModelUuid1", + "modelVersion" : "testProxyModelVersion1", + "modelInvariantId" : "testProxyModelInvariantUuid1" + }, + "filteringAttributes" : [ { + "identifierType" : "cloudRegionId", + "identifiers" : [ "testCloudRegionId" ], + "cloudOwner" : "att" + } ] + } ], + "requestParameters" : {"subscriptionServiceType":"testSubscriptionServiceType","aLaCarte":false} + }, + "licenseInfo" : { + "licenseDemands" : [ ] + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiNetworkWrapper.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiNetworkWrapper.json new file mode 100644 index 0000000000..aaa2c4ba35 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiNetworkWrapper.json @@ -0,0 +1,42 @@ +{ + "networkId": "0384d743-f69b-4cc8-9aa8-c3ae66662c44", + "networkName": "Dev_Bindings_1802_020118", + "networkType": "CONTRAIL30_BASIC", + "networkRole": "GN_EVPN_direct", + "networkTechnology": "contrail", + "neutronNetworkId": "1112b912-0e00-4d6d-9392-014e106399ee", + "isBoundToVpn": true, + "serviceId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "networkRoleInstance": 0, + "resourceVersion": "1517496965485", + "orchestrationStatus": "Active", + "heatStackId": "Dev_Bindings_1802_020118/06c2445f-1ca1-4ad8-be08-454c4de443bb", + "contrailNetworkFqdn": "default-domain:ECOMP_MSO_DND:Dev_Bindings_1802_020118", + "physicalNetworkName": "tbd", + "isProviderNetwork": false, + "isSharedNetwork": true, + "isExternalNetwork": false, + "relationshipList": { + "relationship": [ + { + "relatedTo": "vpn-binding", + "relatedLink": "/aai/v11/network/vpn-bindings/vpn-binding/9a7b327d9-287aa00-82c4b0-100001", + "relationshipData": [ + { + "relationshipKey": "vpn-binding.vpn-id", + "relationshipValue": "9a7b327d9-287aa00-82c4b0-100001" + } + ], + "relatedToProperty": [ + { + "propertyKey": "vpn-binding.vpn-name", + "propertyValue": "MSO_VPN_TEST" + }, + { + "propertyKey": "vpn-binding.vpn-type" + } + ] + } + ] + } +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json index 777f3444d2..53c1997126 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationAssign.json @@ -43,7 +43,7 @@ }, "sdnc-request-header" : { "svc-request-id" : "svcRequestId", - "svc-notification-url" : null, + "svc-notification-url" : "http://localhost:8080", "svc-action" : "assign" }, "vf-module-information" : { diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json index c28b0fa689..9f93c0df1f 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/genericResourceApiVfModuleOperationInformationUnassign.json @@ -17,7 +17,7 @@ }, "sdnc-request-header" : { "svc-request-id" : "svcRequestId", - "svc-notification-url" : null, + "svc-notification-url" : "http://localhost:8080", "svc-action" : "unassign" }, "vf-module-information" : { diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/CreateNetworkCollection.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/CreateNetworkCollection.json index 579075f502..692ecfdf75 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/CreateNetworkCollection.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/CreateNetworkCollection.json @@ -4,7 +4,7 @@ "modelType": "service", "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersion": "10" }, "cloudConfiguration": { @@ -35,7 +35,7 @@ { "service": { "modelInfo": { - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceParams": [], diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json index 26838024da..5753f69d3f 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json @@ -4,7 +4,7 @@ "modelType": "service", "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersion": "10.0" }, "cloudConfiguration": { diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json index ddb118ea49..39e87f19f1 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json @@ -4,7 +4,7 @@ "modelType": "service", "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersion": "10.0" }, "cloudConfiguration": { @@ -34,7 +34,7 @@ "service": { "modelInfo": { "modelType": "service", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceParams": [], diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json index 51caddd48a..b86a2a28f6 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json @@ -4,7 +4,7 @@ "modelType": "service", "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersion": "10.0" }, "owningEntity": { @@ -31,7 +31,7 @@ "service": { "modelInfo": { "modelType": "service", - "modelName": "MOW AVPN vMX BV vPE 1 Service", + "modelName": "Sample Service Model", "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a" }, "instanceParams": [], |