diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN')
4 files changed, 77 insertions, 50 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java index 91cd2ad791..a727162415 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java @@ -31,10 +31,10 @@ public class Candidate implements Serializable { private static final long serialVersionUID = -3959572501582849328L; - @JsonProperty("candidateType") - private CandidateType candidateType; - @JsonProperty("candidates") - private List<String> candidates; + @JsonProperty("identifierType") + private CandidateType identifierType; + @JsonProperty("identifiers") + private List<String> identifiers; @JsonProperty("cloudOwner") private String cloudOwner; @@ -42,32 +42,32 @@ public class Candidate implements Serializable { * list of candidates * i.e. actual serviceInstanceId, actual vnfName, actual cloudRegionId, etc. */ - public List<String> getCandidates() { - return candidates; + public List<String> getIdentifiers() { + return identifiers; } /** * list of candidates * i.e. actual serviceInstanceId, actual vnfName, actual cloudRegionId, etc. */ - public void setCandidates(List<String> candidates) { - this.candidates = candidates; + public void setIdentifiers(List<String> identifiers) { + this.identifiers = identifiers; } /** * Way to identify the type of candidate * i.e. "serviceInstanceId", "vnfName", "cloudRegionId", etc. */ - public CandidateType getCandidateType(){ - return candidateType; + public CandidateType getIdentifierType(){ + return identifierType; } /** * Way to identify the type of candidate * i.e. "serviceInstanceId", "vnfName", "cloudRegionId", etc. */ - public void setCandidateType(CandidateType candidateType){ - this.candidateType = candidateType; + public void setIdentifierType(CandidateType identifierType){ + this.identifierType = identifierType; } /** 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 d2e0b07dd1..b210b5ed2f 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 @@ -40,18 +40,19 @@ import org.springframework.stereotype.Component; @Component public class ExecuteBuildingBlockRainyDay { - - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExecuteBuildingBlockRainyDay.class); + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, + ExecuteBuildingBlockRainyDay.class); public static final String HANDLING_CODE = "handlingCode"; - + @Autowired private CatalogDbClient catalogDbClient; @Autowired private RequestsDbClient requestDbclient; private static final String ASTERISK = "*"; - + @Autowired - private Environment environment; + private Environment environment; protected String retryDurationPath = "mso.rainyDay.retryDurationMultiplier"; protected String defaultCode = "mso.rainyDay.defaultCode"; @@ -67,7 +68,7 @@ public class ExecuteBuildingBlockRainyDay { throw new BpmnError("Unknown error incrementing retry counter"); } } - + public void queryRainyDayTable(DelegateExecution execution, boolean primaryPolicy) { try { ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock"); @@ -79,18 +80,20 @@ public class ExecuteBuildingBlockRainyDay { boolean aLaCarte = (boolean) execution.getVariable("aLaCarte"); boolean suppressRollback = (boolean) execution.getVariable("suppressRollback"); String handlingCode = ""; - if(suppressRollback){ + if (suppressRollback) { handlingCode = "Abort"; - }else{ + } else { try { - serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getModelInfoServiceInstance().getServiceType(); + serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) + .getModelInfoServiceInstance().getServiceType(); } catch (Exception ex) { // keep default serviceType value } String vnfType = ASTERISK; try { - for(GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs()) { - if(vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + for (GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) + .getVnfs()) { + if (vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { vnfType = vnf.getVnfType(); } } @@ -104,58 +107,78 @@ public class ExecuteBuildingBlockRainyDay { } catch (Exception ex) { // keep default errorCode value } + try { + errorCode = "" + (String) execution.getVariable("WorkflowExceptionCode"); + } catch (Exception ex) { + // keep default errorCode value + } + String workStep = ASTERISK; try { workStep = workflowException.getWorkStep(); } catch (Exception ex) { // keep default workStep value } - //Extract error data to be returned to WorkflowAction - execution.setVariable("WorkflowExceptionErrorMessage", workflowException.getErrorMessage()); + + try { + // Extract error data to be returned to WorkflowAction + execution.setVariable("WorkflowExceptionErrorMessage", workflowException.getErrorMessage()); + } catch (Exception e) { + msoLogger.error("No WorkflowException Found",e); + } RainyDayHandlerStatus rainyDayHandlerStatus; - rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,serviceType,vnfType,errorCode,workStep); - if(rainyDayHandlerStatus==null){ - rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,ASTERISK,ASTERISK,ASTERISK,ASTERISK); - if(rainyDayHandlerStatus==null){ + rainyDayHandlerStatus = catalogDbClient + .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName, + serviceType, vnfType, errorCode, workStep); + if (rainyDayHandlerStatus == null) { + rainyDayHandlerStatus = catalogDbClient + .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName, + ASTERISK, ASTERISK, errorCode, ASTERISK); + } + + if (rainyDayHandlerStatus == null) { + rainyDayHandlerStatus = catalogDbClient + .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName, + ASTERISK, ASTERISK, ASTERISK, ASTERISK); + if (rainyDayHandlerStatus == null) { handlingCode = "Abort"; - }else{ - if(primaryPolicy){ + } else { + if (primaryPolicy) { handlingCode = rainyDayHandlerStatus.getPolicy(); - }else{ + } else { handlingCode = rainyDayHandlerStatus.getSecondaryPolicy(); } } - }else{ - if(primaryPolicy){ + } else { + if (primaryPolicy) { handlingCode = rainyDayHandlerStatus.getPolicy(); - }else{ + } else { handlingCode = rainyDayHandlerStatus.getSecondaryPolicy(); } } - if(!primaryPolicy){ - try{ + if (!primaryPolicy) { + try { InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); request.setRetryStatusMessage("Retries have been exhausted."); requestDbclient.updateInfraActiveRequests(request); - } catch(Exception ex){ - msoLogger.debug(ex.toString()); - msoLogger.error("Failed to update Request Db Infra Active Requests with Retry Status"); + } catch (Exception ex) { + msoLogger.error("Failed to update Request Db Infra Active Requests with Retry Status",ex); } } - if(handlingCode.equals("RollbackToAssigned")&&!aLaCarte){ + if (handlingCode.equals("RollbackToAssigned") && !aLaCarte) { handlingCode = "Rollback"; } } msoLogger.debug("RainyDayHandler Status Code is: " + handlingCode); execution.setVariable(HANDLING_CODE, handlingCode); } catch (Exception e) { - msoLogger.error("Failed to determine RainyDayHandler Status. Seting handlingCode = Abort"); + msoLogger.error("Failed to determine RainyDayHandler Status. Seting handlingCode = Abort", e); String code = this.environment.getProperty(defaultCode); execution.setVariable(HANDLING_CODE, code); } } - - public void setHandlingStatusSuccess(DelegateExecution execution){ + + public void setHandlingStatusSuccess(DelegateExecution execution) { execution.setVariable(HANDLING_CODE, "Success"); } } 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 adffee6d42..459ef66e5b 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 @@ -78,7 +78,6 @@ public class ExceptionBuilder { break; } } - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, msg.toString()); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex){ @@ -108,6 +107,11 @@ public class ExceptionBuilder { msoLogger.info("Throwing MSOWorkflowException"); throw new BpmnError("MSOWorkflowException"); } + + public void buildAndThrowWorkflowException(DelegateExecution execution, String errorCode, String errorMessage) { + execution.setVariable("WorkflowExceptionErrorMessage", errorMessage); + throw new BpmnError(errorCode,errorMessage); + } public String getProcessKey(DelegateExecution execution) { String testKey = (String) execution.getVariable("testProcessKey"); 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 cb5683dcc8..868aabf6a9 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 @@ -93,7 +93,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); delegateExecution.setVariable("suppressRollback", false); - + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); @@ -116,7 +116,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); delegateExecution.setVariable("suppressRollback", false); - + delegateExecution.setVariable("WorkflowExceptionCode", ASTERISK); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode(ASTERISK); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); @@ -164,7 +164,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); delegateExecution.setVariable("suppressRollback", false); - + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); @@ -188,7 +188,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", false); delegateExecution.setVariable("suppressRollback", false); - + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); @@ -212,7 +212,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); delegateExecution.setVariable("suppressRollback", false); - + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); rainyDayHandlerStatus.setErrorCode("7000"); rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); |