diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-02-01 18:13:35 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-02-01 18:48:10 -0500 |
commit | 4e63348e5b0c9b8df287ee6eba33b69ffd5f2516 (patch) | |
tree | a6d806d3185efc62ff8af71bb572c02550aea2a2 /bpmn/MSOCommonBPMN/src/main/java/org | |
parent | 62572d10fe5ea77726371c624b6bcbb33ff1707b (diff) |
compare resources from openstack to aai
Address Review comments on pull request
Update Unit test to have proper variable for testing
update logic inside bpmn to reflect proper variable
Update unit test to check property for audit
Add flag to turn on and off audit behavior
Add license headers, remove un-used files
Update Building Block Tests and Activity Names
Fix additional unit tests in so-bpmn-tasks layer
Fix broken Junit Test, and correct Bug in if statement
Add annotation to ignore class under test profile
Additional bug fixes and unit tests for classes
Add Additional JUNITS, add more sample data
Add Openstack Audit functionality to Adapter
Change-Id: I0492063271e991eefc608b56336a5cdf1d5a7778
Issue-ID: SO-1456
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java/org')
2 files changed, 60 insertions, 33 deletions
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"); |