diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception')
5 files changed, 119 insertions, 117 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BBObjectNotFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BBObjectNotFoundException.java index 26c8d80075..8a1a110fac 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BBObjectNotFoundException.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BBObjectNotFoundException.java @@ -22,24 +22,23 @@ package org.onap.so.client.exception; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; -public class BBObjectNotFoundException extends Exception{ - private ResourceKey resourceKey; - private String resourceValue; - +public class BBObjectNotFoundException extends Exception { + private ResourceKey resourceKey; + private String resourceValue; + public BBObjectNotFoundException() {} - public BBObjectNotFoundException(ResourceKey resourceKey, String resourceValue) - { - super("BBObject" + resourceKey + " was not found in gBBInput using reference value: " + resourceValue); - this.resourceKey = resourceKey; - this.resourceValue = resourceValue; + public BBObjectNotFoundException(ResourceKey resourceKey, String resourceValue) { + super("BBObject" + resourceKey + " was not found in gBBInput using reference value: " + resourceValue); + this.resourceKey = resourceKey; + this.resourceValue = resourceValue; } public ResourceKey getResourceKey() { - return resourceKey; + return resourceKey; } - + public String getResourceValue() { - return resourceValue; + return resourceValue; } } 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 ac8ff9efe4..333d99ed2e 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 @@ -20,13 +20,12 @@ package org.onap.so.client.exception; -public class BadResponseException extends Exception{ +public class BadResponseException extends Exception { - public BadResponseException() {} + public BadResponseException() {} - public BadResponseException(String message) - { - super(message); + public BadResponseException(String message) { + super(message); } } 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 cb65f4d420..ae5e41f7ce 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 @@ -35,96 +35,101 @@ import org.springframework.stereotype.Component; @Component public class ExceptionBuilder { - private static final Logger logger = LoggerFactory.getLogger(ExceptionBuilder.class); - - public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, Exception exception) { - String msg = "Exception in %s.%s "; - try{ - logger.error("Exception occurred", exception); - - String errorVariable = "Error%s%s"; - - StackTraceElement[] trace = Thread.currentThread().getStackTrace(); - for (StackTraceElement traceElement : trace) { - if (!traceElement.getClassName().equals(this.getClass().getName()) && !traceElement.getClassName().equals(Thread.class.getName())) { - msg = String.format(msg, traceElement.getClassName(), traceElement.getMethodName()); - String shortClassName = traceElement.getClassName().substring(traceElement.getClassName().lastIndexOf(".") + 1); - errorVariable = String.format(errorVariable, shortClassName, traceElement.getMethodName()); - break; - } - } - - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), msg.toString()); - execution.setVariable(errorVariable, exception.getMessage()); - } catch (Exception ex){ - //log trace, allow process to complete gracefully - logger.error("Exception occurred", ex); - } - - if (exception.getMessage() != null) - msg = msg.concat(exception.getMessage()); - buildAndThrowWorkflowException(execution, errorCode, msg); - } - - public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, Exception exception) { - String msg = "Exception in %s.%s "; - try{ - logger.error("Exception occurred", exception); - - String errorVariable = "Error%s%s"; - - StackTraceElement[] trace = Thread.currentThread().getStackTrace(); - for (StackTraceElement traceElement : trace) { - if (!traceElement.getClassName().equals(this.getClass().getName()) && !traceElement.getClassName().equals(Thread.class.getName())) { - msg = String.format(msg, traceElement.getClassName(), traceElement.getMethodName()); - String shortClassName = traceElement.getClassName().substring(traceElement.getClassName().lastIndexOf(".") + 1); - errorVariable = String.format(errorVariable, shortClassName, traceElement.getMethodName()); - break; - } - } - logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue(), msg.toString()); - execution.setVariable(errorVariable, exception.getMessage()); - } catch (Exception ex){ - //log trace, allow process to complete gracefully - logger.error("Exception occurred", ex); - } - - if (exception.getMessage() != null) - msg = msg.concat(exception.getMessage()); - buildAndThrowWorkflowException(execution, errorCode, msg); - } - - public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, String errorMessage) { - if (execution instanceof DelegateExecutionImpl) { - buildAndThrowWorkflowException(((DelegateExecutionImpl) execution).getDelegateExecution(), errorCode, errorMessage); - } - } - - public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) { - String processKey = getProcessKey(execution); - logger.info("Building a WorkflowException for Subflow"); - - WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage); - execution.setVariable("WorkflowException", exception); - execution.setVariable("WorkflowExceptionErrorMessage", errorMessage); - logger.info("Outgoing WorkflowException is {}", exception); - logger.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"); - if (testKey != null) { - return testKey; - } - return execution.getProcessEngineServices().getRepositoryService() - .getProcessDefinition(execution.getProcessDefinitionId()).getKey(); - } + private static final Logger logger = LoggerFactory.getLogger(ExceptionBuilder.class); + + public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, Exception exception) { + String msg = "Exception in %s.%s "; + try { + logger.error("Exception occurred", exception); + + String errorVariable = "Error%s%s"; + + StackTraceElement[] trace = Thread.currentThread().getStackTrace(); + for (StackTraceElement traceElement : trace) { + if (!traceElement.getClassName().equals(this.getClass().getName()) + && !traceElement.getClassName().equals(Thread.class.getName())) { + msg = String.format(msg, traceElement.getClassName(), traceElement.getMethodName()); + String shortClassName = + traceElement.getClassName().substring(traceElement.getClassName().lastIndexOf(".") + 1); + errorVariable = String.format(errorVariable, shortClassName, traceElement.getMethodName()); + break; + } + } + + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue(), msg.toString()); + execution.setVariable(errorVariable, exception.getMessage()); + } catch (Exception ex) { + // log trace, allow process to complete gracefully + logger.error("Exception occurred", ex); + } + + if (exception.getMessage() != null) + msg = msg.concat(exception.getMessage()); + buildAndThrowWorkflowException(execution, errorCode, msg); + } + + public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, Exception exception) { + String msg = "Exception in %s.%s "; + try { + logger.error("Exception occurred", exception); + + String errorVariable = "Error%s%s"; + + StackTraceElement[] trace = Thread.currentThread().getStackTrace(); + for (StackTraceElement traceElement : trace) { + if (!traceElement.getClassName().equals(this.getClass().getName()) + && !traceElement.getClassName().equals(Thread.class.getName())) { + msg = String.format(msg, traceElement.getClassName(), traceElement.getMethodName()); + String shortClassName = + traceElement.getClassName().substring(traceElement.getClassName().lastIndexOf(".") + 1); + errorVariable = String.format(errorVariable, shortClassName, traceElement.getMethodName()); + break; + } + } + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue(), msg.toString()); + execution.setVariable(errorVariable, exception.getMessage()); + } catch (Exception ex) { + // log trace, allow process to complete gracefully + logger.error("Exception occurred", ex); + } + + if (exception.getMessage() != null) + msg = msg.concat(exception.getMessage()); + buildAndThrowWorkflowException(execution, errorCode, msg); + } + + public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, String errorMessage) { + if (execution instanceof DelegateExecutionImpl) { + buildAndThrowWorkflowException(((DelegateExecutionImpl) execution).getDelegateExecution(), errorCode, + errorMessage); + } + } + + public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) { + String processKey = getProcessKey(execution); + logger.info("Building a WorkflowException for Subflow"); + + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage); + execution.setVariable("WorkflowException", exception); + execution.setVariable("WorkflowExceptionErrorMessage", errorMessage); + logger.info("Outgoing WorkflowException is {}", exception); + logger.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"); + if (testKey != null) { + return testKey; + } + return execution.getProcessEngineServices().getRepositoryService() + .getProcessDefinition(execution.getProcessDefinitionId()).getKey(); + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java index 3f3beadb92..354c669d62 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java @@ -20,13 +20,12 @@ package org.onap.so.client.exception; -public class MapperException extends Exception{ - +public class MapperException extends Exception { + public MapperException() {} - public MapperException(String message) - { - super(message); + public MapperException(String message) { + super(message); } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/OrchestrationStatusValidationException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/OrchestrationStatusValidationException.java index fe7b079568..e9d1e1fba0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/OrchestrationStatusValidationException.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/OrchestrationStatusValidationException.java @@ -20,10 +20,10 @@ package org.onap.so.client.exception; -public class OrchestrationStatusValidationException extends Exception{ - public OrchestrationStatusValidationException() {} +public class OrchestrationStatusValidationException extends Exception { + public OrchestrationStatusValidationException() {} public OrchestrationStatusValidationException(String message) { - super(message); + super(message); } } |