diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main')
52 files changed, 1290 insertions, 515 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 4e7c549323..b98e395228 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 @@ -23,6 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.client.HttpClientFactory +import org.onap.so.logger.ErrorCode import java.util.regex.Matcher import java.util.regex.Pattern @@ -39,7 +40,6 @@ import org.onap.so.client.HttpClient import org.onap.so.client.aai.AAIVersion import org.onap.so.client.aai.entities.uri.AAIUri import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.openpojo.rules.HasToStringRule @@ -136,13 +136,13 @@ class AaiUtil { }else{ logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Call AAI Cloud Region is NOT Successful.", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); throw new BpmnError("MSOWorkflowException") } }catch(Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception occured while getting the Cloud Reqion.", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.getMessage()); + ErrorCode.UnknownError.getValue(), e.getMessage()); (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) } return regionId diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index c700fa70e1..1ceafb6684 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -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 @@ -32,111 +34,15 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.client.aai.AAIResourcesClient import org.springframework.web.util.UriUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory import groovy.json.JsonSlurper public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcessor { - public MsoUtils utils = new MsoUtils() - - - /** - * Logs a message at the ERROR level. - * @param message the message - */ - public void logError(String message) { - log('ERROR', message, null, "true") - } - - /** - * Logs a message at the ERROR level. - * @param message the message - * @param cause the cause (stracktrace will be included in the output) - */ - public void logError(String message, Throwable cause) { - log('ERROR', message, cause, "true") - } - - /** - * Logs a message at the WARN level. - * @param message the message - */ - public void logWarn(String message) { - log('WARN', message, null, "true") - } - - /** - * Logs a message at the WARN level. - * @param message the message - * @param cause the cause (stracktrace will be included in the output) - */ - public void logWarn(String message, Throwable cause) { - log('WARN', message, cause, "true") - } - - /** - * Logs a message at the DEBUG level. - * @param message the message - * @param isDebugLogEnabled a flag indicating if DEBUG level is enabled - */ - public void logDebug(String message, String isDebugLogEnabled) { - log('DEBUG', message, null, isDebugLogEnabled) - } - - /** - * Logs a message at the DEBUG level. - * @param message the message - * @param cause the cause (stracktrace will be included in the output) - * @param isDebugLogEnabled a flag indicating if DEBUG level is enabled - */ - public void logDebug(String message, Throwable cause, String isDebugLogEnabled) { - log('DEBUG', message, cause, isDebugLogEnabled) - } + private static final Logger logger = LoggerFactory.getLogger( MsoUtils.class); - /** - * Logs a message at the specified level. - * @param level the level (DEBUG, INFO, WARN, ERROR) - * @param message the message - * @param isLevelEnabled a flag indicating if the level is enabled - * (used only at the DEBUG level) - */ - public void log(String level, String message, String isLevelEnabled) { - log(level, message, null, isLevelEnabled) - } - - /** - * Logs a message at the specified level. - * @param level the level (DEBUG, INFO, WARN, ERROR) - * @param message the message - * @param cause the cause (stracktrace will be included in the output) - * @param isLevelEnabled a flag indicating if the level is enabled - * (used only at the DEBUG level) - */ - public void log(String level, String message, Throwable cause, String isLevelEnabled) { - if (cause == null) { - utils.log(level, message, isLevelEnabled); - } else { - StringWriter stringWriter = new StringWriter(); - PrintWriter printWriter = new PrintWriter(stringWriter); - printWriter.println(message); - cause.printStackTrace(printWriter); - utils.log(level, stringWriter.toString(), isLevelEnabled); - printWriter.close(); - } - } - - /** - * Logs a WorkflowException at the ERROR level with the specified message. - * @param execution the execution - */ - public void logWorkflowException(DelegateExecution execution, String message) { - def workflowException = execution.getVariable("WorkflowException") - - if (workflowException == null) { - logError(message); - } else { - logError(message + ": " + workflowException) - } - } + public MsoUtils utils = new MsoUtils() /** * Saves the WorkflowException in the execution to the specified variable, @@ -173,7 +79,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess ', requredVariables=' + requiredVariables + ')' def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) + logger.debug('Entered ' + method) String processKey = getProcessKey(execution) def prefix = execution.getVariable("prefix") @@ -236,14 +142,13 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess serviceInstanceId = (String) execution.getVariable("mso-service-instance-id") } - utils.logContext(requestId, serviceInstanceId) - logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled) - logDebug('Exited ' + method, isDebugLogEnabled) + logger.debug('Incoming message: ' + System.lineSeparator() + request) + logger.debug('Exited ' + method) return request } catch (BpmnError e) { throw e } catch (Exception e) { - logError('Caught exception in ' + method, e) + logger.error('Caught exception in {}: {}', method, e.getMessage(), e) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message") } } @@ -259,18 +164,11 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess 'execution=' + execution.getId() + ')' def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) + logger.debug('Entered ' + method) String processKey = getProcessKey(execution); def prefix = execution.getVariable("prefix") - def requestId =getVariable(execution, "mso-request-id") - def serviceInstanceId = getVariable(execution, "mso-service-instance-id") - if(requestId!=null && serviceInstanceId!=null){ - utils.logContext(requestId, serviceInstanceId) - } - - def request = getVariable(execution, prefix + 'Request') if (request == null) { @@ -286,8 +184,8 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess def parsed = jsonSlurper.parseText(request) - logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled) - logDebug('Exited ' + method, isDebugLogEnabled) + logger.debug('Incoming message: ' + System.lineSeparator() + request) + logger.debug('Exited ' + method) return parsed } @@ -317,10 +215,10 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess } if (String.valueOf(execution.getVariable(processKey + "WorkflowResponseSent")).equals("true")) { - logDebug("Sync response has already been sent for " + processKey, isDebugLogEnabled) + logger.debug("Sync response has already been sent for " + processKey) }else{ - logDebug("Building " + processKey + " response ", isDebugLogEnabled) + logger.debug("Building " + processKey + " response ") int intResponseCode; @@ -345,11 +243,10 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess execution.setVariable(processKey + "Status", status); execution.setVariable("WorkflowResponse", response) - logDebug("Sending response for " + processKey + logger.debug("Sending response for " + processKey + " ResponseCode=" + intResponseCode + " Status=" + status - + " Response=\n" + response, - isDebugLogEnabled) + + " Response=\n" + response) // TODO: ensure that this flow was invoked asynchronously? @@ -370,7 +267,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess } } catch (Exception ex) { - logError("Unable to send workflow response to client ....", ex) + logger.error("Unable to send workflow response to client ....", ex) } } @@ -440,7 +337,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess def element = utils.getNodeXml(xml, elementName, false) if (element.trim().isEmpty()) { def msg = 'Required element \'' + elementName + '\' is missing or empty' - logError(msg) + logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } else { return element @@ -462,7 +359,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess def elementText = utils.getNodeText(xml, elementName) if ((elementText == null) || (elementText.isEmpty())) { def msg = 'Required element \'' + elementName + '\' is missing or empty' - logError(msg) + logger.error(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } else { return elementText @@ -577,9 +474,9 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess String prefix = execution.getVariable('prefix') def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered SetSuccessIndicator Method', isDebugLogEnabled) + logger.debug('Entered SetSuccessIndicator Method') execution.setVariable(prefix+'SuccessIndicator', isSuccess) - logDebug('Outgoing SuccessIndicator is: ' + execution.getVariable(prefix+'SuccessIndicator') + '', isDebugLogEnabled) + logger.debug('Outgoing SuccessIndicator is: ' + execution.getVariable(prefix+'SuccessIndicator') + '') } /** @@ -587,14 +484,14 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * */ public void sendSyncError(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String requestId = execution.getVariable("mso-request-id") - logDebug('sendSyncError, requestId: ' + requestId, isDebugEnabled) + logger.debug('sendSyncError, requestId: ' + requestId) WorkflowException workflowExceptionObj = execution.getVariable("WorkflowException") if (workflowExceptionObj != null) { String errorMessage = workflowExceptionObj.getErrorMessage() def errorCode = workflowExceptionObj.getErrorCode() - logDebug('sendSyncError, requestId: ' + requestId + ' | errorMessage: ' + errorMessage + ' | errorCode: ' + errorCode, isDebugEnabled) + logger.debug('sendSyncError, requestId: ' + requestId + ' | errorMessage: ' + errorMessage + ' | errorCode: ' + errorCode) sendWorkflowResponse(execution, errorCode, errorMessage) } } @@ -610,27 +507,26 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess DelegateExecution execution = (DelegateExecution) args[0] def classAndMethod = getClass().getSimpleName() + '.' + methodName + '(execution=' + execution.getId() + ')' - def isDebugEnabled = execution.getVariable('isDebugLogEnabled') + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + classAndMethod, isDebugEnabled) - logDebug('Received parameters: ' + args, isDebugEnabled) + logger.debug('Entered ' + classAndMethod) + logger.debug('Received parameters: ' + args) try{ def methodToCall = this.metaClass.getMetaMethod(methodName, args) - logDebug('Method to call: ' + methodToCall, isDebugEnabled) + logger.debug('Method to call: ' + methodToCall) methodToCall?.invoke(this, args) } catch(BpmnError bpmnError) { - logDebug('Rethrowing BpmnError ' + bpmnError.getMessage(), isDebugEnabled) + logger.debug('Rethrowing BpmnError ' + bpmnError.getMessage()) throw bpmnError } catch(Exception e) { - e.printStackTrace() - logDebug('Unexpected error encountered - ' + e.getMessage(), isDebugEnabled) + logger.debug('Unexpected error encountered - {}', e.getMessage(), e) (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) } finally { - logDebug('Exited ' + classAndMethod, isDebugEnabled) + logger.debug('Exited ' + classAndMethod) } } } @@ -726,8 +622,8 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess def disableRollback = execution.getVariable("disableRollback") def defaultRollback = UrnPropertiesReader.getVariable("mso.rollback", execution).toBoolean() - logDebug('disableRollback: ' + disableRollback, isDebugLogEnabled) - logDebug('defaultRollback: ' + defaultRollback, isDebugLogEnabled) + logger.debug('disableRollback: ' + disableRollback) + logger.debug('defaultRollback: ' + defaultRollback) def rollbackEnabled @@ -735,7 +631,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess // get from default urn settings for mso_rollback disableRollback = !defaultRollback rollbackEnabled = defaultRollback - logDebug('disableRollback is null or empty!', isDebugLogEnabled) + logger.debug('disableRollback is null or empty!') } else { if(disableRollback == true) { @@ -748,9 +644,9 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess rollbackEnabled = defaultRollback } } - + execution.setVariable(prefix+"backoutOnFailure", rollbackEnabled) - logDebug('rollbackEnabled (aka backoutOnFailure): ' + rollbackEnabled, isDebugLogEnabled) + logger.debug('rollbackEnabled (aka backoutOnFailure): ' + rollbackEnabled) } public void setBasicDBAuthHeader(DelegateExecution execution, isDebugLogEnabled) { @@ -760,7 +656,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess execution.setVariable("BasicAuthHeaderValueDB",encodedString) } catch (IOException ex) { String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled) + logger.debug(dataErrorMessage) (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) } } 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 dec69dfb71..e0e85e9629 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 @@ -23,6 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.client.aai.entities.AAIResultWrapper +import org.onap.so.logger.ErrorCode import static org.apache.commons.lang3.StringUtils.isBlank; @@ -40,7 +41,6 @@ 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.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -196,7 +196,7 @@ class AllottedResourceUtils { getAAIClient().update(uri,allottedResource) }catch(Exception e){ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "Exception in updateAR.", "BPMN", MsoLogger.ErrorCode.UnknownError.getValue(), e.getMessage()); + "Exception in updateAR.", "BPMN", ErrorCode.UnknownError.getValue(), e.getMessage()); exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error in updateAROrchStatus.' + e.getMessage()) } logger.trace("Exit updateAROrchStatus ") 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 3545361811..4a59b9789a 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 @@ -26,9 +26,9 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.json.JsonUtils import org.onap.appc.client.lcm.model.Action -import org.onap.so.client.appc.ApplicationControllerAction; +import org.onap.so.client.appc.ApplicationControllerAction +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -122,7 +122,7 @@ public class AppCClient extends AbstractServiceTaskProcessor{ catch (BpmnError e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); appcMessage = e.getMessage() } execution.setVariable("errorCode", appcCode) 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 11c2bb265d..d5b0b31a39 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 @@ -31,8 +31,9 @@ import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.client.HttpClientFactory +import org.onap.so.logger.ErrorCode import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger + import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.utils.TargetEntity @@ -50,13 +51,13 @@ class CatalogDbUtils { private static final Logger logger = LoggerFactory.getLogger( CatalogDbUtils.class); private HttpClientFactory httpClientFactory - private MsoUtils msoUtils - private JsonUtils jsonUtils + private MsoUtils utils + private JsonUtils jsonUtils static private String defaultDbAdapterVersion = "v2" - CatalogDbUtils(HttpClientFactory httpClientFactory, MsoUtils msoUtils, JsonUtils jsonUtils) { + CatalogDbUtils(HttpClientFactory httpClientFactory, JsonUtils jsonUtils) { this.httpClientFactory = httpClientFactory - this.msoUtils = msoUtils + this.utils = new MsoUtils() this.jsonUtils = jsonUtils } @@ -81,7 +82,7 @@ class CatalogDbUtils { catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in Querying Catalog DB", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.message); + ErrorCode.UnknownError.getValue(), e.message); throw e } @@ -104,7 +105,7 @@ class CatalogDbUtils { } } catch (Exception e) { - msoUtils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + logger.error("Exception in Querying Catalog DB: " + e.message) throw e } @@ -119,7 +120,7 @@ class CatalogDbUtils { catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in Querying Catalog DB", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.message); + ErrorCode.UnknownError.getValue(), e.message); throw e } } @@ -143,7 +144,7 @@ class CatalogDbUtils { catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in Querying Catalog DB", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.message); + ErrorCode.UnknownError.getValue(), e.message); throw e } @@ -169,7 +170,7 @@ class CatalogDbUtils { catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in Querying Catalog DB", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.message); + ErrorCode.UnknownError.getValue(), e.message); throw e } @@ -219,7 +220,7 @@ class CatalogDbUtils { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in parsing Catalog DB Response", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.message); + ErrorCode.UnknownError.getValue(), e.message); } return modelInfos @@ -298,7 +299,7 @@ class CatalogDbUtils { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in parsing Catalog DB Response", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.message); + ErrorCode.UnknownError.getValue(), e.message); } return modelInfos @@ -352,7 +353,7 @@ class CatalogDbUtils { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in parsing Catalog DB Response", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.message); + ErrorCode.UnknownError.getValue(), e.message); } return modelInfos @@ -381,7 +382,7 @@ class CatalogDbUtils { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception in parsing Catalog DB Response", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.message); + ErrorCode.UnknownError.getValue(), e.message); } return serviceResourcesObject @@ -429,7 +430,7 @@ class CatalogDbUtils { catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception while parsing model information", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.message); + ErrorCode.UnknownError.getValue(), e.message); } return modelInfo } @@ -487,7 +488,7 @@ class CatalogDbUtils { } } catch (Exception e) { - msoUtils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + logger.error("Exception in Querying Catalog DB: " + e.message) throw e } @@ -499,13 +500,13 @@ class CatalogDbUtils { String encodedString = null try { String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution) - msoUtils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB) + logger.debug("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB) - encodedString = msoUtils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution)) + encodedString = utils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution)) execution.setVariable("BasicAuthHeaderValueDB",encodedString) } catch (IOException ex) { String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - msoUtils.log("ERROR", dataErrorMessage) + logger.error(dataErrorMessage) } return encodedString } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsFactory.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsFactory.groovy index faa0037169..bf7d07cbb3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsFactory.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsFactory.groovy @@ -4,6 +4,8 @@ * ================================================================================ * 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. * You may obtain a copy of the License at @@ -26,6 +28,6 @@ import org.onap.so.client.HttpClientFactory public class CatalogDbUtilsFactory { CatalogDbUtils create() { - return new CatalogDbUtils(new HttpClientFactory(), new MsoUtils(), new JsonUtils()) + return new CatalogDbUtils(new HttpClientFactory(), new JsonUtils()) } } 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 1c2862e00d..a9e01c7191 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 @@ -24,8 +24,8 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.logger.ErrorCode import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -75,7 +75,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { throw e; } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in' + - ' ' + method, "BPMN", MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ' ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) } @@ -238,7 +238,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) } logger.trace('Exited ' + method) @@ -271,7 +271,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) } @@ -309,7 +309,7 @@ public class CompleteMsoProcess extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + 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 dfe0772cab..6a82512d88 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 @@ -26,6 +26,7 @@ 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 @@ -37,7 +38,6 @@ 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.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -132,7 +132,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ 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", MsoLogger.ErrorCode.UnknownError.getValue(), + "BPMN", ErrorCode.UnknownError.getValue(), "ErrorResponse is:\n" + execution.getVariable("CVGN_queryVolumeGroupResponse")); } @@ -141,7 +141,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ 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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 1002, errorNotAssociated) } 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 f2d5a61542..7c1c0a0490 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 @@ -31,8 +31,8 @@ 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.constants.Defaults +import org.onap.so.logger.ErrorCode import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -107,7 +107,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ }catch(Exception e){ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing queryAAIForVolumeGroup.", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.getMessage()); + ErrorCode.UnknownError.getValue(), e.getMessage()); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in preProcessRequest.") } logger.trace("COMPLETED queryAAIForVolumeGroup Process ") @@ -129,7 +129,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ }catch(Exception e){ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing assignVolumeHeatId.", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e); + ErrorCode.UnknownError.getValue(), e); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in assignVolumeHeatId.") } logger.trace("COMPLETED assignVolumeHeatId Process ") @@ -149,7 +149,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ }catch(Exception e){ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing assignWorkflowException.", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e); + ErrorCode.UnknownError.getValue(), e); } logger.trace("COMPLETED Assign Workflow Exception =") } 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 8bc97f7f40..e9e7d1ed7c 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 @@ -32,8 +32,8 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.db.catalog.beans.OrchestrationStatus +import org.onap.so.logger.ErrorCode import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -63,8 +63,8 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_moduleExists",false) execution.setVariable("CAAIVfMod_baseModuleConflict", false) execution.setVariable("CAAIVfMod_vnfNameFromAAI", null) - - + + // CreateAAIVfModule workflow response variable placeholders execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode",null) execution.setVariable("CAAIVfMod_queryGenericVnfResponse","") @@ -80,14 +80,14 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CreateAAIVfModuleResponse","") execution.setVariable("RollbackData", null) - } - + } + // parse the incoming CREATE_VF_MODULE request and store the Generic VNF // and VF Module data in the flow DelegateExecution public void preProcessRequest(DelegateExecution execution) { initProcessVariables(execution) - def vnfId = execution.getVariable("vnfId") + def vnfId = execution.getVariable("vnfId") if (vnfId == null || vnfId.isEmpty()) { execution.setVariable("CAAIVfMod_newGenericVnf", true) execution.setVariable("CAAIVfMod_vnfId","") @@ -96,14 +96,14 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_vnfId",vnfId) } - def vnfName = execution.getVariable("vnfName") + def vnfName = execution.getVariable("vnfName") execution.setVariable("CAAIVfMod_vnfName", vnfName) String vnfType = execution.getVariable("vnfType") execution.setVariable("CAAIVfMod_vnfType", StringUtils.defaultString(vnfType)) execution.setVariable("CAAIVfMod_serviceId", execution.getVariable("serviceId")) - + String personaModelId = execution.getVariable("personaModelId") execution.setVariable("CAAIVfMod_personaId",StringUtils.defaultString(personaModelId)) @@ -219,8 +219,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("CAAIVfMod_createGenericVnfResponseCode", 201) execution.setVariable("CAAIVfMod_createGenericVnfResponse", "Vnf Created") } catch (Exception ex) { - ex.printStackTrace() - logger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage()) + logger.debug("Exception occurred while executing AAI PUT: {}", ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in createGenericVnf.") } } @@ -426,7 +425,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ public void handleAAIQueryFailure(DelegateExecution execution) { logger.error("{} {} {} {}", 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", MsoLogger.ErrorCode.UnknownError.getValue()); + "BPMN", ErrorCode.UnknownError.getValue()); int code = execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") exceptionUtil.buildAndThrowWorkflowException(execution, code, "Error occurred attempting to query AAI") @@ -478,7 +477,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Error occurred during CreateAAIVfModule flow", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), errorResponse); + ErrorCode.UnknownError.getValue(), errorResponse); exceptionUtil.buildAndThrowWorkflowException(execution, errorCode, errorResponse) logger.debug("Workflow exception occurred in CreateAAIVfModule: " + errorResponse) } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy index dc4871119e..7e46784af2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy @@ -121,8 +121,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { execution.setVariable('CAAIVfModVG_getVfModuleResponse', "VF-Module Not found!!") } }catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) execution.setVariable('CAAIVfModVG_getVfModuleResponseCode', 500) execution.setVariable('CAAIVfModVG_getVfModuleResponse', 'AAI GET Failed:' + ex.getMessage()) } @@ -174,8 +173,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { logger.debug("CreateAAIVfModule Response code: " + 200) logger.debug("CreateAAIVfModule Response: " + "Success") } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI PUT:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI PUT: {}', ex.getMessage(), ex) execution.setVariable('CAAIVfModVG_updateVfModuleResponseCode', 500) execution.setVariable('CAAIVfModVG_updateVfModuleResponse', 'AAI PUT Failed:' + ex.getMessage()) } 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 e6beac6742..4bce23eff7 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 @@ -27,8 +27,8 @@ 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.client.graphinventory.entities.uri.Depth +import org.onap.so.logger.ErrorCode import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -76,7 +76,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // send a GET request to AA&I to retrieve the Generic Vnf/Vf Module information based on a Vnf Id // expect a 200 response with the information in the response body or a 404 if the Generic Vnf does not exist public void queryAAIForGenericVnf(DelegateExecution execution) { - + def vnfId = execution.getVariable("DAAIVfMod_vnfId") try { @@ -112,8 +112,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("DAAIVfMod_deleteGenericVnfResponseCode", 200) execution.setVariable("DAAIVfMod_deleteGenericVnfResponse", "Vnf Deleted") } catch (Exception ex) { - ex.printStackTrace() - logger.debug("Exception occurred while executing AAI DELETE:" + ex.getMessage()) + logger.debug("Exception occurred while executing AAI DELETE: {}", ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured during deleteGenericVnf") } } @@ -131,8 +130,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ execution.setVariable("DAAIVfMod_deleteVfModuleResponseCode", 200) execution.setVariable("DAAIVfMod_deleteVfModuleResponse", "Vf Module Deleted") } catch (Exception ex) { - ex.printStackTrace() - logger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage()) + logger.debug("Exception occurred while executing AAI PUT: {}", ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured during deleteVfModule") } } @@ -208,7 +206,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ public void handleAAIQueryFailure(DelegateExecution execution) { logger.error("{} {} {} {}", 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", MsoLogger.ErrorCode.UnknownError.getValue()); + "BPMN", ErrorCode.UnknownError.getValue()); def errorCode = 5000 // set the errorCode to distinguish between a A&AI failure // and the Generic Vnf Id not found @@ -255,7 +253,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Error occurred during DeleteAAIVfModule flow", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), errorResponse); + ErrorCode.UnknownError.getValue(), errorResponse); exceptionUtil.buildAndThrowWorkflowException(execution, errorCode, errorResponse) } @@ -265,7 +263,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ public void handleDeleteGenericVnfFailure(DelegateExecution execution) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "AAI error occurred deleting the Generic Vnf", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), + ErrorCode.UnknownError.getValue(), execution.getVariable("DAAIVfMod_deleteGenericVnfResponse")); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, 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 b062974c98..30dbeb09d5 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,8 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.ErrorCode + import static org.apache.commons.lang3.StringUtils.* import com.google.common.xml.XmlEscapers @@ -31,7 +33,6 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.WorkflowException import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -91,7 +92,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { wfex = execution.getVariable("WorkflowException") logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), wfex.errorMessage); + ErrorCode.UnknownError.getValue(), wfex.errorMessage); return wfex } else { try { @@ -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", - MsoLogger.ErrorCode.UnknownError.getValue(), wfex.errorMessage); + ErrorCode.UnknownError.getValue(), wfex.errorMessage); return wfex } catch(Exception ex) { logger.debug("error mapping error, return null: " + 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 d4c5d2f7bb..2ceec3cb44 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 @@ -23,13 +23,13 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.logger.ErrorCode import java.text.SimpleDateFormat import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -99,7 +99,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) } } @@ -212,7 +212,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in" + method) } @@ -246,7 +246,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) } } @@ -277,7 +277,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) } } @@ -308,7 +308,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) } } @@ -337,7 +337,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) } } @@ -357,7 +357,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); // exceptionUtil.buildWorkflowException(execution, 2000, "Internal Error - Occured in " + method) } } @@ -392,7 +392,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { // Do NOT throw WorkflowException! logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + 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 0d39ea15f8..f008130c32 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 @@ -24,6 +24,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.client.HttpClientFactory +import org.onap.so.logger.ErrorCode import java.io.Serializable; @@ -42,7 +43,6 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth import org.onap.so.utils.TargetEntity import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -151,8 +151,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ } } } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex) exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) } logger.trace('Exited ' + method) @@ -161,7 +160,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + 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 cf7290a654..27fe33f5ea 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 @@ -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.ErrorCode; import static org.apache.commons.lang3.StringUtils.*; @@ -44,7 +46,6 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.ruby.* import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -290,7 +291,7 @@ public class ManualHandling extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + 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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); } catch (Exception ex){ msg = "Exception in createAOTSTicket " + ex.getMessage() logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + 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 10d02686cc..f371ccef4d 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,14 +22,14 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.ErrorCode + import java.text.SimpleDateFormat import org.apache.commons.codec.binary.Base64 import org.apache.commons.lang3.StringEscapeUtils -import org.onap.so.bpmn.core.BPMNLogger import org.onap.so.bpmn.core.xml.XmlTool import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.utils.CryptoUtils @@ -88,7 +88,7 @@ class MsoUtils { } return nodes } - + def getNodeXml(xmlInput,element){ return getNodeXml(xmlInput, element, true) } @@ -105,7 +105,7 @@ class MsoUtils { return unescapeNodeContents(nodeToSerialize, nodeAsText) } - + def unescapeNodeContents(NodeChild node, String text) { if (!node.childNodes().hasNext()) { return StringEscapeUtils.unescapeXml(text) @@ -124,9 +124,9 @@ class MsoUtils { } } - + /***** Utilities when using XmlParser *****/ - + /** * Convert a Node into a String by deserializing it and formatting it. * @@ -138,12 +138,12 @@ class MsoUtils { nodeAsString = removeXmlPreamble(nodeAsString) return formatXml(nodeAsString) } - + /** * Get the specified child Node of the specified parent. If there are * multiple children of the same name, only the first one is returned. * If there are no children with the specified name, 'null' is returned. - * + * * @param parent Parent Node in which to find a child. * @param childNodeName Name of the child Node to get. * @return the (first) child Node with the specified name or 'null' @@ -157,11 +157,11 @@ class MsoUtils { return nodeList.get(0) } } - + /** * Get the textual value of the specified child Node of the specified parent. * If there are no children with the specified name, 'null' is returned. - * + * * @param parent Parent Node in which to find a child. * @param childNodeName Name of the child Node whose value to get. * @return the textual value of child Node with the specified name or 'null' @@ -175,11 +175,11 @@ class MsoUtils { return childNode.text() } } - + /** * Get all of the child nodes from the specified parent that have the * specified name. The returned NodeList could be empty. - * + * * @param parent Parent Node in which to find children. * @param childNodeName Name of the children to get. * @return a NodeList of all the children from the parent with the specified @@ -191,14 +191,14 @@ class MsoUtils { /***** End of Utilities when using XmlParser *****/ - + /** these are covered under the common function above**/ def getSubscriberName(xmlInput,element){ def rtn=null if(xmlInput!=null){ def xml= new XmlSlurper().parseText(xmlInput) rtn= xml.'**'.find{node->node.name()==element}.text() - } + } return rtn } def getTenantInformation(xmlInput,element){ @@ -226,7 +226,7 @@ class MsoUtils { } return ret } - + def searchMetaDataNode(fxml, searchName, searchValue){ def ret = fxml.'**'.find {it.metaname.text() == searchName && it.metaval.text() == searchValue} if(ret != null){ @@ -234,7 +234,7 @@ class MsoUtils { } return ret } - + // for Trinity L3 add/delete bonding def getPBGFList(isDebugLogEnabled, xmlInput){ log("DEBUG", "getPBGFList: xmlInput " + xmlInput,isDebugLogEnabled) @@ -270,20 +270,18 @@ class MsoUtils { } myNodes.add(XmlUtil.serialize(nodeToAdd)) } - } } - return myNodes }else{ return null } } - + def getPBGFList(xmlInput){ getPBGFList("false", xmlInput) } - + def getMetaVal(node, name){ try{ return node.'**'.find {it.metaname.text() == name}.metaval.text() @@ -292,39 +290,20 @@ class MsoUtils { } } - def log(logmode,logtxt,isDebugLogEnabled="false"){ + def private log(logmode,logtxt,isDebugLogEnabled="false"){ if ("INFO"==logmode) { - logger.info(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, logtxt, "BPMN"); + logger.info(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), logtxt, "BPMN"); } else if ("WARN"==logmode) { - // to see the warning text displayed in the log entry, the text must also be passed as arg0 (2nd argument) to invoke the correct MsoLogger warn() method logger.warn ("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), logtxt, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), logtxt); + ErrorCode.UnknownError.getValue(), logtxt); } else if ("ERROR"==logmode) { - // to see the error text displayed in the log entry, the text must also be passed as arg0 (2nd argument) to invoke the correct MsoLogger error() method logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), logtxt, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), logtxt); - + ErrorCode.UnknownError.getValue(), logtxt); } else { - BPMNLogger.debug(isDebugLogEnabled, logtxt); + logger.debug(logtxt); } } - def logContext(requestId, serviceInstanceId){ -// msoLogger.setLogContext(requestId, serviceInstanceId); - } - - def logMetrics(elapsedTime, logtxt){ - -// msoLogger.recordMetricEvent (elapsedTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, -// logtxt, "BPMN", MsoLogger.getServiceName(), null); - } - - def logAudit(logtxt){ - long startTime = System.currentTimeMillis(); - -// msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logtxt); - } - // headers: header - name-value def getHeaderNameValue(xmlInput, nameAttribute){ def rtn=null @@ -334,7 +313,7 @@ class MsoUtils { } return rtn } - + /** * Gets the children of the specified element. */ @@ -353,10 +332,10 @@ class MsoUtils { } return out.toString(); } - + /** * Encodes a value so it can be used inside an XML text element. - * + * * <b>Will double encode</b> * @param s the string to encode * @return the encoded string @@ -364,7 +343,7 @@ class MsoUtils { public static String xmlEscape(Object value) { return XmlTool.encode(value) } - + /** * Removes the preamble, if present, from an XML document. * Also, for historical reasons, this also trims leading and trailing @@ -412,29 +391,29 @@ class MsoUtils { public String formatXml(def xml) { return XmlTool.normalize(xml); } - + // build single elements def buildElements(xmlInput, elementList, parentName) { String var = "" def xmlBuild = "" if (parentName != "") { xmlBuild += "<tns2:"+parentName+">" - } + } if (xmlInput != null) { for (element in elementList) { def xml= new XmlSlurper().parseText(xmlInput) var = xml.'**'.find {it.name() == element} if (var != null) { xmlBuild += "<tns2:"+element+">"+var.toString()+"</tns2:"+element+">" - } + } } } if (parentName != "") { xmlBuild += "</tns2:"+parentName+">" - } + } return xmlBuild } - + // build the Unbounded elements def buildElementsUnbounded(xmlInput, elementList, parentName) { def varParents = "" @@ -462,7 +441,7 @@ class MsoUtils { } return xmlBuildUnbounded } - + // Build l2-homing-information def buildL2HomingInformation(xmlInput) { def elementsL2HomingList = ["evc-name", "topology", "preferred-aic-clli","aic-version"] @@ -472,7 +451,7 @@ class MsoUtils { } return rebuildL2Home } - + // Build internet-evc-access-information def buildInternetEvcAccessInformation(xmlInput) { def elementsInternetEvcAccessInformationList = ["internet-evc-speed-value", "internet-evc-speed-units", "ip-version"] @@ -482,7 +461,7 @@ class MsoUtils { } return rebuildInternetEvcAccess } - + // Build ucpe-vms-service-information def buildUcpeVmsServiceInformation(xmlInput) { def rebuildUcpeVmsServiceInformation = '' @@ -514,7 +493,7 @@ class MsoUtils { log("DEBUG", " rebuildUcpeVmsServiceInformation - " + rebuildUcpeVmsServiceInformation) return rebuildUcpeVmsServiceInformation } - + // Build internet-service-change-details def buildInternetServiceChangeDetails(xmlInput) { def rebuildInternetServiceChangeDetails = "" @@ -544,33 +523,33 @@ class MsoUtils { } } return rebuildInternetServiceChangeDetails - } - - // Build vr-lan + } + + // Build vr-lan def buildVrLan(xmlInput) { - + def rebuildVrLan = '' if (xmlInput != null) { - + rebuildVrLan = "<tns2:vr-lan>" def vrLan = getNodeXml(xmlInput, "vr-lan").drop(38).trim() rebuildVrLan += buildElements(vrLan, ["routing-protocol"], "") - + // vr-lan-interface def rebuildVrLanInterface = "<tns2:vr-lan-interface>" def vrLanInterface = getNodeXml(vrLan, "vr-lan-interface").drop(38).trim() rebuildVrLanInterface += buildVrLanInterfacePartial(vrLanInterface) - + // dhcp def dhcp = getNodeXml(vrLan, "dhcp").drop(38).trim() def rebuildDhcp = buildDhcp(dhcp) rebuildVrLanInterface += rebuildDhcp - + // pat def pat = getNodeXml(vrLan, "pat").drop(38).trim() def rebuildPat = buildPat(pat) rebuildVrLanInterface += rebuildPat - + // nat def rebuildNat = "" try { // optional @@ -580,31 +559,31 @@ class MsoUtils { log("ERROR", " Optional - Exception 'nat' ") } rebuildVrLanInterface += rebuildNat - + // firewall-lite def firewallLite = getNodeXml(vrLan, "firewall-lite").drop(38).trim() def rebuildFirewallLite = buildFirewallLite(firewallLite) rebuildVrLanInterface += rebuildFirewallLite - + // static-routes def rebuildStaticRoutes = "" - try { // optional + try { // optional def staticRoutes = getNodeXml(vrLan, "static-routes").drop(38).trim() rebuildStaticRoutes = buildStaticRoutes(staticRoutes) } catch (Exception e) { log("ERROR", " Optional - Exception 'static-routes' ") } rebuildVrLanInterface += rebuildStaticRoutes - + rebuildVrLan += rebuildVrLanInterface rebuildVrLan += "</tns2:vr-lan-interface>" rebuildVrLan += "</tns2:vr-lan>" - + } log("DEBUG", " rebuildVrLan - " + rebuildVrLan) - return rebuildVrLan + return rebuildVrLan } - + // Build vr-lan-interface def buildVrLanInterfacePartial(xmlInput) { def rebuildingVrLanInterface = '' @@ -633,7 +612,7 @@ class MsoUtils { log("DEBUG", " rebuildingVrLanInterface - " + rebuildingVrLanInterface) return rebuildingVrLanInterface } - + // Build dhcp def buildDhcp(xmlInput) { def rebuildingDhcp = '' @@ -703,10 +682,10 @@ class MsoUtils { log("ERROR", " Optional - Exception DHCP 'v6-dhcp-pools' ") } rebuildingDhcp += "</tns2:dhcp>" - } + } log("DEBUG", " rebuildingDhcp - " + rebuildingDhcp) return rebuildingDhcp - } + } // Build pat def buildPat(xmlInput) { @@ -727,7 +706,7 @@ class MsoUtils { log("DEBUG", " rebuildingPat - " + rebuildingPat) return rebuildingPat } - + // Build nat def buildNat(xmlInput) { def rebuildingNat = '' @@ -745,19 +724,19 @@ class MsoUtils { } log("DEBUG", " rebuildingNat - " + rebuildingNat) return rebuildingNat - } - + } + // Build firewall-lite def buildFirewallLite(xmlInput) { def rebuildingFirewallLite = '' - + if (xmlInput != null) { - + def firewallLiteData = new XmlSlurper().parseText(xmlInput) rebuildingFirewallLite = "<tns2:firewall-lite>" def firewallLiteList = ["stateful-firewall-lite-v4-enabled", "stateful-firewall-lite-v6-enabled"] rebuildingFirewallLite += buildElements(xmlInput, firewallLiteList, "") - + try { // optional def v4FirewallPacketFilters = firewallLiteData.'**'.findAll {it.name() == "v4-firewall-packet-filters"} def v4FirewallPacketFiltersSize = v4FirewallPacketFilters.size() @@ -785,7 +764,7 @@ class MsoUtils { } catch (Exception e) { log("ERROR", " Optional - Exception FIREWALL-LITE 'v4-firewall-packet-filters' ") } - + try { // optional def v6FirewallPacketFilters = firewallLiteData.'**'.findAll {it.name() == "v6-firewall-packet-filters"} def v6FirewallPacketFiltersSize = v6FirewallPacketFilters.size() @@ -818,7 +797,7 @@ class MsoUtils { log("DEBUG", " rebuildingFirewallLite - " + rebuildingFirewallLite) return rebuildingFirewallLite } - + def buildStaticRoutes(xmlInput) { def rebuildingStaticRoutes = '' if (xmlInput != null) { @@ -832,21 +811,21 @@ class MsoUtils { log("DEBUG", " rebuildingStaticRoutes - " + rebuildingStaticRoutes) return rebuildingStaticRoutes } - + public String generateCurrentTimeInUtc(){ final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); final String utcTime = sdf.format(new Date()); return utcTime; } - + public String generateCurrentTimeInGMT(){ final SimpleDateFormat sdf = new SimpleDateFormat("E, d MMM yyyy h:m:s z"); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); final String utcTime = sdf.format(new Date()); return utcTime; } - + /** * @param encryptedAuth: encrypted credentials from urn properties @@ -867,7 +846,7 @@ class MsoUtils { throw ex } } - + def encrypt(toEncrypt, msokey){ try { String result = CryptoUtils.encrypt(toEncrypt, msokey); @@ -877,7 +856,7 @@ class MsoUtils { log("ERROR", "Failed to encrypt credentials") } } - + def decrypt(toDecrypt, msokey){ try { String result = CryptoUtils.decrypt(toDecrypt, msokey); @@ -888,7 +867,7 @@ class MsoUtils { throw e } } - + /** * Return URL with qualified host name (if any) or urn mapping * @param String url from urn mapping @@ -904,12 +883,12 @@ class MsoUtils { callbackUrlToUse = callbackUrlToUse.replaceAll("(http://)(.*)(:28080*)", {orig, first, torepl, last -> "${first}${qualifiedHostName}${last}"}) } }catch(Exception e){ - log("DEBUG", "unable to grab qualified host name, using what's in urn properties for callbackurl. Exception was: " + e.printStackTrace()) + logger.debug("Unable to grab qualified host name, using what's in urn properties for callbackurl. Exception was: {}", e.getMessage(), e) } return callbackUrlToUse - + } - + /** * Retrieves text context of the element if the element exists, returns empty string otherwise * @param com.sun.org.apache.xerces.internal.dom.DeferredElementNSImpl element to parse @@ -924,7 +903,7 @@ class MsoUtils { } return text } - + /** * * Find the lowest unused module-index value in a given xml @@ -932,14 +911,14 @@ class MsoUtils { public String getLowestUnusedIndex(String xml) { if (xml == null || xml.isEmpty()) { return "0" - } - def moduleIndexList = getMultNodes(xml, "module-index") - if (moduleIndexList == null || moduleIndexList.size() == 0) { + } + def moduleIndexList = getMultNodes(xml, "module-index") + if (moduleIndexList == null || moduleIndexList.size() == 0) { return "0" } - + def sortedModuleIndexList = moduleIndexList.sort{ a, b -> a as Integer <=> b as Integer} - + for (i in 0..sortedModuleIndexList.size()-1) { if (Integer.parseInt(sortedModuleIndexList[i]) != i) { return i.toString() diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy index cac7a35282..49acf37078 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy @@ -195,7 +195,6 @@ class OofHoming extends AbstractServiceTaskProcessor { try { String response = execution.getVariable("asyncCallbackResponse") logger.debug( "OOF Async Callback Response is: " + response) - utils.logAudit("OOF Async Callback Response is: " + response) oofUtils.validateCallbackResponse(execution, response) String placements = jsonUtil.getJsonValue(response, "solutions.placementSolutions") @@ -378,7 +377,6 @@ class OofHoming extends AbstractServiceTaskProcessor { } execution.setVariable("DHVCS_requestId", requestId) logger.debug( "***** STARTED Homing Subflow for request: " + requestId + " *****") - utils.logAudit("***** STARTED Homing Subflow for request: " + requestId + " *****") } /** diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy index 259808feb6..50c4e56547 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy @@ -38,7 +38,6 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.entities.uri.Depth import org.springframework.web.util.UriUtils import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory 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 3a93d48da3..a0da6870ae 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 @@ -29,8 +29,8 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.logger.ErrorCode import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -67,7 +67,7 @@ public void preProcessRequest (DelegateExecution execution) { String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_timeout\'' logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -78,7 +78,7 @@ public void preProcessRequest (DelegateExecution execution) { String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_messageType\'' logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -89,7 +89,7 @@ public void preProcessRequest (DelegateExecution execution) { String msg = getProcessKey(execution) + ': Missing or empty input variable \'RCVWFMSG_correlator\'' logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } execution.setVariable(messageType + '_CORRELATOR', correlator) @@ -101,7 +101,7 @@ public void preProcessRequest (DelegateExecution execution) { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + 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 cf0e35a59f..a7bb707dff 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 @@ -21,14 +21,14 @@ */ package org.onap.so.bpmn.common.scripts; -import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.logger.ErrorCode; import java.text.SimpleDateFormat import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.WorkflowException import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -75,7 +75,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { } catch (IOException ex) { logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Unable to encode username password string", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); } // TODO Use variables instead of passing xml request - Huh? @@ -166,7 +166,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { logger.debug(UrnPropertiesReader.getVariable("mso.adapters.sdnc.endpoint", execution)) }catch(Exception e){ - logger.debug('Internal Error occured during PreProcess Method: ', e) + logger.debug('Internal Error occured during PreProcess Method: {}', e.getMessage(), e) exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PreProcess Method') // TODO: what message and error code? } logger.trace("End pre Process SDNCRequestScript ") 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 fd5dbaea90..69d5f02df5 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 @@ -23,6 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.client.HttpClientFactory +import org.onap.so.logger.ErrorCode import java.text.SimpleDateFormat import javax.ws.rs.core.Response @@ -43,7 +44,6 @@ import org.onap.so.bpmn.core.domain.RollbackData import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.utils.TargetEntity @@ -87,7 +87,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { 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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -108,7 +108,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -123,7 +123,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -140,7 +140,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -156,7 +156,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined") logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); } else { try { def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution)) @@ -165,7 +165,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter") logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", - "BPMN", MsoLogger.ErrorCode.UnknownError.getValue()); + "BPMN", ErrorCode.UnknownError.getValue(), ex); } } @@ -196,7 +196,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } } @@ -244,7 +244,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Unsupported HTTP method "' + sdncAdapterMethod + '" in ' + method + ": " + e logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -258,7 +258,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg, e) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } } @@ -274,9 +274,6 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String prefix = execution.getVariable('prefix') String callback = execution.getVariable('SDNCAResponse_MESSAGE') - String requestId = execution.getVariable("mso-request-id"); - String serviceInstanceId = execution.getVariable("mso-service-instance-id") - utils.logContext(requestId, serviceInstanceId) logger.debug("Incoming SDNC Rest Callback is: " + callback) try { @@ -372,7 +369,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } } @@ -398,7 +395,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + 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 cd86120860..f91bf54edc 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,8 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.logger.ErrorCode + import java.text.SimpleDateFormat import java.net.URLEncoder @@ -38,7 +40,6 @@ import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -85,7 +86,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { 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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -106,7 +107,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -121,7 +122,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -132,7 +133,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -151,7 +152,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined") logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); } else { try { def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution)) @@ -160,7 +161,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter") logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", - "BPMN", MsoLogger.ErrorCode.UnknownError.getValue()); + "BPMN", ErrorCode.UnknownError.getValue(), ex); } } @@ -191,7 +192,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + 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 085e82ca24..e6d54b8681 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 @@ -26,11 +26,11 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.aai.domain.yang.L3Network import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.logger.ErrorCode; import org.springframework.web.util.UriUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -265,7 +265,7 @@ class SDNCAdapterUtils { if (callbackUrl == null || callbackUrl.trim() == "") { logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'mso:workflow:sdncadapter:callback URN is not set', "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code? } @@ -403,7 +403,7 @@ class SDNCAdapterUtils { if (callbackUrl == null || callbackUrl.trim() == "") { logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'mso:workflow:sdncadapter:callback URN is not set', "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request") } @@ -476,7 +476,7 @@ class SDNCAdapterUtils { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error") } } @@ -983,7 +983,7 @@ class SDNCAdapterUtils { }else { logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING, 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ', - "BPMN", MsoLogger.ErrorCode.UnknownError, + "BPMN", ErrorCode.UnknownError, 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ') execution.setVariable("L3HLAB_rollback", true) def msg = trinityExceptionUtil.intDataResponseCode(response, execution) @@ -993,7 +993,7 @@ class SDNCAdapterUtils { if (response == null || response.trim().equals("")) { logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING, 'sdncAdapter workflow response is empty', "BPMN", - MsoLogger.ErrorCode.UnknownError, 'sdncAdapter workflow response is empty') + ErrorCode.UnknownError, 'sdncAdapter workflow response is empty') execution.setVariable("L3HLAB_rollback", true) def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response " , execution) exceptionUtil.buildAndThrowWorkflowException(execution, intResponseCode, msg) @@ -1005,7 +1005,7 @@ class SDNCAdapterUtils { throw e; } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught ' + - 'exception in ' + method, "BPMN", MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + 'exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); execution.setVariable(prefix+"ResponseCode",400) execution.setVariable("L3HLAB_rollback", true) def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response: " + e.getMessage(), execution) 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 c489778d36..615c977a1e 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 @@ -24,8 +24,8 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.DelegateExecution import org.apache.commons.lang3.* +import org.onap.so.logger.ErrorCode import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -216,7 +216,7 @@ class TrinityExceptionUtil { if(message != null) { execution.setVariable(prefix+"ErrorResponse",message) logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), + ErrorCode.UnknownError.getValue(), execution.getVariable(prefix+"ErrorResponse")); return message } else { @@ -312,7 +312,7 @@ class TrinityExceptionUtil { execution.setVariable(prefix+"errTxt", messageTxt) execution.setVariable(prefix+"errVariables", msgVars) logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Fault", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), + ErrorCode.UnknownError.getValue(), execution.getVariable(prefix+"ErrorResponse")); return message }catch(Exception ex) { 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 fd45cb5a03..a40bf59097 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 @@ -30,8 +30,8 @@ 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.client.graphinventory.entities.uri.Depth +import org.onap.so.logger.ErrorCode import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -183,7 +183,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { 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", - MsoLogger.ErrorCode.UnknownError.getValue()) + ErrorCode.UnknownError.getValue()) throw new Exception(msg) } @@ -206,7 +206,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Construct payload managementV6AddressEntry = updateGenericVnfNode(origRequest, 'management-v6-address') } - + // Handle orchestration-status String orchestrationStatus = execution.getVariable('UAAIGenVnf_orchestrationStatus') String orchestrationStatusEntry = null @@ -214,7 +214,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { // Construct payload orchestrationStatusEntry = updateGenericVnfNode(origRequest, 'orchestration-status') } - + org.onap.aai.domain.yang.GenericVnf payload = new org.onap.aai.domain.yang.GenericVnf(); payload.setVnfId(vnfId) payload.setPersonaModelVersion(personaModelVersionEntry) @@ -227,8 +227,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { try { getAAIClient().update(uri,payload) } catch (Exception ex) { - ex.printStackTrace() - logger.debug('Exception occurred while executing AAI PATCH:' + ex.getMessage()) + logger.debug('Exception occurred while executing AAI PATCH: {}', ex.getMessage(), ex) execution.setVariable('UAAIGenVnf_updateGenericVnfResponseCode', 500) execution.setVariable('UAAIGenVnf_updateGenericVnfResponse', 'AAI PATCH Failed:' + ex.getMessage()) } @@ -258,9 +257,9 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { return "" } else { - return elementValue + return elementValue } - + } /** diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy index 92a043e65a..9b12413177 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy @@ -30,7 +30,6 @@ import org.onap.so.bpmn.core.WorkflowException 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.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory 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 536d9062c0..c4ef165f63 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 @@ -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.ErrorCode; import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory @@ -31,7 +33,6 @@ import org.w3c.dom.Node import org.w3c.dom.NodeList import org.xml.sax.InputSource import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -111,7 +112,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), 'Exception transforming network params to vnfNetworks', "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), 'Exception is: \n' + e); + ErrorCode.UnknownError.getValue(), 'Exception is: \n' + e); } return vnfNetworks } @@ -150,7 +151,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), 'Exception transforming params to entries', "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e); + ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e); } return entries } @@ -191,7 +192,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { } catch (Exception e) { logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING.toString(), 'Exception transforming params to entries', "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e); + ErrorCode.UnknownError.getValue(), 'Exception transforming params to entries' + e); } return entries } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy index 259a7872a3..1960cafb0f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy @@ -69,7 +69,7 @@ class VidUtils { public String createXmlVolumeRequest(Map requestMap, String action, String serviceInstanceId) { createXmlVolumeRequest(requestMap, action, serviceInstanceId, '') } - + /** * Create a volume-request XML using a map @@ -84,9 +84,9 @@ class VidUtils { def serviceName = '' def modelCustomizationName = '' def asdcServiceModelVersion = '' - + def suppressRollback = requestMap.requestDetails.requestInfo.suppressRollback - + def backoutOnFailure = "" if(suppressRollback != null){ if ( suppressRollback == true) { @@ -95,7 +95,7 @@ class VidUtils { backoutOnFailure = "true" } } - + def volGrpName = requestMap.requestDetails.requestInfo?.instanceName ?: '' def serviceId = requestMap.requestDetails.requestParameters?.serviceId ?: '' def relatedInstanceList = requestMap.requestDetails.relatedInstanceList @@ -108,16 +108,16 @@ class VidUtils { modelCustomizationName = it.relatedInstance.modelInfo?.modelInstanceName } } - + vnfType = serviceName + '/' + modelCustomizationName - + def userParams = requestMap.requestDetails?.requestParameters?.userParams def userParamsNode = '' if(userParams != null) { userParamsNode = buildUserParams(userParams) } def modelCustomizationId = requestMap.requestDetails?.modelInfo?.modelCustomizationUuid ?: '' - + String xmlReq = """ <volume-request xmlns="http://www.w3.org/2001/XMLSchema"> <request-info> @@ -145,9 +145,9 @@ class VidUtils { // return a pretty-print of the volume-request xml without the preamble return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") } - + /** - * A common method that can be used to build volume-params node from a map. + * A common method that can be used to build volume-params node from a map. * @param Map userParams * @return */ @@ -166,9 +166,9 @@ class VidUtils { } /** - * A common method that can be used to extract 'requestDetails' + * A common method that can be used to extract 'requestDetails' * @param String json - * @return String json requestDetails + * @return String json requestDetails */ @Deprecated public getJsonRequestDetails(String jsonInput) { @@ -183,10 +183,10 @@ class VidUtils { return rtn } else { return rtn - } + } } } - + /** * A common method that can be used to extract 'requestDetails' in Xml * @param String json @@ -203,17 +203,17 @@ class VidUtils { return XmlTool.normalize(XML.toString(jsonObj)) } } - + /** * Create a network-request XML using a map - * @param execution - * @param xmlRequestDetails - requestDetails in xml + * @param execution + * @param xmlRequestDetails - requestDetails in xml * @return * Note: See latest version: createXmlNetworkRequestInstance() */ public String createXmlNetworkRequestInfra(execution, def networkJsonIncoming) { - + def requestId = execution.getVariable("requestId") def serviceInstanceId = execution.getVariable("serviceInstanceId") def requestAction = execution.getVariable("requestAction") @@ -225,13 +225,13 @@ class VidUtils { def instanceName = reqMap.requestDetails.requestInfo.instanceName def modelCustomizationId = reqMap.requestDetails.modelInfo.modelCustomizationId if (modelCustomizationId == null) { - modelCustomizationId = reqMap.requestDetails.modelInfo.modelCustomizationUuid !=null ? + modelCustomizationId = reqMap.requestDetails.modelInfo.modelCustomizationUuid !=null ? reqMap.requestDetails.modelInfo.modelCustomizationUuid : "" } def modelName = reqMap.requestDetails.modelInfo.modelName def lcpCloudRegionId = reqMap.requestDetails.cloudConfiguration.lcpCloudRegionId def tenantId = reqMap.requestDetails.cloudConfiguration.tenantId - def serviceId = reqMap.requestDetails.requestInfo.productFamilyId + def serviceId = reqMap.requestDetails.requestInfo.productFamilyId def suppressRollback = reqMap.requestDetails.requestInfo.suppressRollback.toString() def backoutOnFailure = "true" if(suppressRollback != null){ @@ -241,7 +241,7 @@ class VidUtils { backoutOnFailure = "true" } } - + //def userParams = reqMap.requestDetails.requestParameters.userParams //def userParamsNode = buildUserParams(userParams) def userParams = reqMap.requestDetails?.requestParameters?.userParams @@ -249,26 +249,26 @@ class VidUtils { if(userParams != null) { userParamsNode = buildUserParams(userParams) } - + //'sdncVersion' = current, '1610' (non-RPC SDNC) or '1702' (RPC SDNC) def sdncVersion = execution.getVariable("sdncVersion") - + String xmlReq = """ - <network-request xmlns="http://www.w3.org/2001/XMLSchema"> - <request-info> + <network-request xmlns="http://www.w3.org/2001/XMLSchema"> + <request-info> <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> - <action>${MsoUtils.xmlEscape(requestAction)}</action> - <source>VID</source> + <action>${MsoUtils.xmlEscape(requestAction)}</action> + <source>VID</source> <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> - </request-info> + </request-info> <network-inputs> - <network-id>${MsoUtils.xmlEscape(networkId)}</network-id> - <network-name>${MsoUtils.xmlEscape(instanceName)}</network-name> + <network-id>${MsoUtils.xmlEscape(networkId)}</network-id> + <network-name>${MsoUtils.xmlEscape(instanceName)}</network-name> <network-type>${MsoUtils.xmlEscape(modelName)}</network-type> - <modelCustomizationId>${MsoUtils.xmlEscape(modelCustomizationId)}</modelCustomizationId> - <aic-cloud-region>${MsoUtils.xmlEscape(lcpCloudRegionId)}</aic-cloud-region> + <modelCustomizationId>${MsoUtils.xmlEscape(modelCustomizationId)}</modelCustomizationId> + <aic-cloud-region>${MsoUtils.xmlEscape(lcpCloudRegionId)}</aic-cloud-region> <tenant-id>${MsoUtils.xmlEscape(tenantId)}</tenant-id> - <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id> + <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id> <backout-on-failure>${MsoUtils.xmlEscape(backoutOnFailure)}</backout-on-failure> <sdncVersion>${MsoUtils.xmlEscape(sdncVersion)}</sdncVersion> </network-inputs> @@ -281,8 +281,7 @@ class VidUtils { return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") } catch(Exception e) { - logger.debug("{} {}", "Error in Vid Utils", e.getCause()) - e.printStackTrace(); + logger.debug("Error in Vid Utils: {}", e.getCause(), e) throw e } } @@ -299,7 +298,7 @@ class VidUtils { def networkModelVersion = "" def networkModelCustomizationUuid = "" def networkModelInvariantUuid = "" - + // verify the DB Catalog response JSON structure def networkModelInfo = execution.getVariable("networkModelInfo") def jsonSlurper = new JsonSlurper() @@ -326,14 +325,14 @@ class VidUtils { } catch (Exception ex) { throw ex } - } - + } + def serviceModelUuid = "" def serviceModelName = "" def serviceModelVersion = "" def serviceModelCustomizationUuid = "" def serviceModelInvariantUuid = "" - + // verify the DB Catalog response JSON structure def serviceModelInfo = execution.getVariable("serviceModelInfo") def jsonServiceSlurper = new JsonSlurper() @@ -361,8 +360,8 @@ class VidUtils { throw ex } } - - + + def subscriptionServiceType = execution.getVariable("subscriptionServiceType") != null ? execution.getVariable("subscriptionServiceType") : "" def globalSubscriberId = execution.getVariable("globalSubscriberId") != null ? execution.getVariable("globalSubscriberId") : "" def requestId = execution.getVariable("msoRequestId") @@ -382,88 +381,88 @@ class VidUtils { backoutOnFailure = "true" } } - + //'sdncVersion' = current, '1610' (non-RPC SDNC) or '1702' (RPC SDNC) def sdncVersion = execution.getVariable("sdncVersion") - + def source = "VID" def action = execution.getVariable("action") - + def userParamsNode = "" def userParams = execution.getVariable("networkInputParams") if(userParams != null) { userParamsNode = buildUserParams(userParams) } - + String xmlReq = """ - <network-request xmlns="http://www.w3.org/2001/XMLSchema"> - <request-info> + <network-request xmlns="http://www.w3.org/2001/XMLSchema"> + <request-info> <request-id>${MsoUtils.xmlEscape(requestId)}</request-id> - <action>${MsoUtils.xmlEscape(action)}</action> - <source>${MsoUtils.xmlEscape(source)}</source> + <action>${MsoUtils.xmlEscape(action)}</action> + <source>${MsoUtils.xmlEscape(source)}</source> <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id> - </request-info> - <network-inputs> - <network-id>${MsoUtils.xmlEscape(networkId)}</network-id> - <network-name>${MsoUtils.xmlEscape(networkName)}</network-name> + </request-info> + <network-inputs> + <network-id>${MsoUtils.xmlEscape(networkId)}</network-id> + <network-name>${MsoUtils.xmlEscape(networkName)}</network-name> <network-type>${MsoUtils.xmlEscape(networkModelName)}</network-type> <subscription-service-type>${MsoUtils.xmlEscape(subscriptionServiceType)}</subscription-service-type> <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id> - <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudReqion)}</aic-cloud-region> + <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudReqion)}</aic-cloud-region> <tenant-id>${MsoUtils.xmlEscape(tenantId)}</tenant-id> - <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id> + <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id> <backout-on-failure>${MsoUtils.xmlEscape(backoutOnFailure)}</backout-on-failure> <failIfExist>${MsoUtils.xmlEscape(failIfExist)}</failIfExist> <networkModelInfo> <modelName>${MsoUtils.xmlEscape(networkModelName)}</modelName> <modelUuid>${MsoUtils.xmlEscape(networkModelUuid)}</modelUuid> - <modelInvariantUuid>${MsoUtils.xmlEscape(networkModelInvariantUuid)}</modelInvariantUuid> + <modelInvariantUuid>${MsoUtils.xmlEscape(networkModelInvariantUuid)}</modelInvariantUuid> <modelVersion>${MsoUtils.xmlEscape(networkModelVersion)}</modelVersion> <modelCustomizationUuid>${MsoUtils.xmlEscape(networkModelCustomizationUuid)}</modelCustomizationUuid> </networkModelInfo> <serviceModelInfo> <modelName>${MsoUtils.xmlEscape(serviceModelName)}</modelName> <modelUuid>${MsoUtils.xmlEscape(serviceModelUuid)}</modelUuid> - <modelInvariantUuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</modelInvariantUuid> + <modelInvariantUuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</modelInvariantUuid> <modelVersion>${MsoUtils.xmlEscape(serviceModelVersion)}</modelVersion> <modelCustomizationUuid>${MsoUtils.xmlEscape(serviceModelCustomizationUuid)}</modelCustomizationUuid> - - </serviceModelInfo> - <sdncVersion>${MsoUtils.xmlEscape(sdncVersion)}</sdncVersion> + + </serviceModelInfo> + <sdncVersion>${MsoUtils.xmlEscape(sdncVersion)}</sdncVersion> </network-inputs> <network-params> ${userParamsNode} - </network-params> + </network-params> </network-request> """ // return a pretty-print of the volume-request xml without the preamble return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") - + } - + /** * Create a vnf-request XML using a map - * @param requestMap - map created from VID JSON + * @param requestMap - map created from VID JSON * @param action * @return */ public String createXmlVfModuleRequest(execution, Map requestMap, String action, String serviceInstanceId) { - + //def relatedInstanceList = requestMap.requestDetails.relatedInstanceList - + //relatedInstanceList.each { // if (it.relatedInstance.modelInfo.modelType == 'vnf') { // vnfType = it.relatedInstance.modelInfo.modelName // vnfId = it.relatedInstance.modelInfo.modelInvariantId // } //} - + def vnfName = '' def asdcServiceModelInfo = '' - + def relatedInstanceList = requestMap.requestDetails?.relatedInstanceList - - + + if (relatedInstanceList != null) { relatedInstanceList.each { if (it.relatedInstance.modelInfo?.modelType == 'service') { @@ -474,30 +473,30 @@ class VidUtils { } } } - + def vnfType = execution.getVariable('vnfType') def vnfId = execution.getVariable('vnfId') def vfModuleId = execution.getVariable('vfModuleId') def volumeGroupId = execution.getVariable('volumeGroupId') def userParams = requestMap.requestDetails?.requestParameters?.userParams - - + + def userParamsNode = '' if(userParams != null) { userParamsNode = buildUserParams(userParams) } - + def isBaseVfModule = "false" if (execution.getVariable('isBaseVfModule') == true) { isBaseVfModule = "true" } - + def requestId = execution.getVariable("mso-request-id") def vfModuleName = requestMap.requestDetails?.requestInfo?.instanceName ?: '' def vfModuleModelName = requestMap.requestDetails?.modelInfo?.modelName ?: '' def suppressRollback = requestMap.requestDetails?.requestInfo?.suppressRollback - + def backoutOnFailure = "" if(suppressRollback != null){ if ( suppressRollback == true) { @@ -506,14 +505,14 @@ class VidUtils { backoutOnFailure = "true" } } - + def serviceId = requestMap.requestDetails?.requestParameters?.serviceId ?: '' def aicCloudRegion = requestMap.requestDetails?.cloudConfiguration?.lcpCloudRegionId ?: '' def tenantId = requestMap.requestDetails?.cloudConfiguration?.tenantId ?: '' def personaModelId = requestMap.requestDetails?.modelInfo?.modelInvariantUuid ?: '' def personaModelVersion = requestMap.requestDetails?.modelInfo?.modelUuid ?: '' def modelCustomizationId = requestMap.requestDetails?.modelInfo?.modelCustomizationUuid ?: '' - + String xmlReq = """ <vnf-request> <request-info> @@ -524,17 +523,17 @@ class VidUtils { </request-info> <vnf-inputs> <!-- not in use in 1610 --> - <vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name> + <vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name> <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type> <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id> <volume-group-id>${MsoUtils.xmlEscape(volumeGroupId)}</volume-group-id> <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id> - <vf-module-name>${MsoUtils.xmlEscape(vfModuleName)}</vf-module-name> + <vf-module-name>${MsoUtils.xmlEscape(vfModuleName)}</vf-module-name> <vf-module-model-name>${MsoUtils.xmlEscape(vfModuleModelName)}</vf-module-model-name> <model-customization-id>${MsoUtils.xmlEscape(modelCustomizationId)}</model-customization-id> <is-base-vf-module>${MsoUtils.xmlEscape(isBaseVfModule)}</is-base-vf-module> <asdc-service-model-version>${MsoUtils.xmlEscape(asdcServiceModelInfo)}</asdc-service-model-version> - <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region> + <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region> <tenant-id>${MsoUtils.xmlEscape(tenantId)}</tenant-id> <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id> <backout-on-failure>${MsoUtils.xmlEscape(backoutOnFailure)}</backout-on-failure> @@ -546,10 +545,10 @@ class VidUtils { </vnf-params> </vnf-request> """ - + // return a pretty-print of the volume-request xml without the preamble return groovy.xml.XmlUtil.serialize(xmlReq.normalize().replaceAll("\t", "").replaceAll("\n", "")).replaceAll("(<\\?[^<]*\\?>\\s*[\\r\\n]*)?", "") } - + } 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 d8b2c4f5c0..aacd385a3b 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 @@ -23,6 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.client.HttpClientFactory +import org.onap.so.logger.ErrorCode import javax.ws.rs.core.Response import org.apache.commons.lang3.* @@ -31,7 +32,6 @@ import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.client.HttpClient import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory import org.onap.so.utils.TargetEntity @@ -79,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -93,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -107,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -125,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -138,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -147,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -161,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -170,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -184,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -193,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -202,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -223,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -239,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -255,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -268,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", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -286,7 +286,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { if (basicAuthValue == null || basicAuthValue.isEmpty()) { logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); } else { try { def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution)) @@ -294,7 +294,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { } catch (IOException ex) { logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": Unable to encode BasicAuth credentials for VnfAdapter", - "BPMN", MsoLogger.ErrorCode.UnknownError.getValue()); + "BPMN", ErrorCode.UnknownError.getValue(), ex); } } @@ -304,7 +304,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); logger.debug(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -356,7 +356,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { } else { String msg = 'Unsupported HTTP method "' + vnfAdapterMethod + '" in ' + method + ": " + e logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -369,7 +369,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { } catch (Exception e) { String msg = 'Caught exception in ' + method + ": " + e logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()); exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } } @@ -398,7 +398,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { vnfAdapterWorkflowException(execution, callback) } } catch (Exception e) { - logger.debug("Error encountered within VnfAdapterRest ProcessCallback method", e) + logger.debug("Error encountered within VnfAdapterRest ProcessCallback method: {}", e.getMessage(), e) exceptionUtil.buildAndThrowWorkflowException(execution, 7020, "Error encountered within VnfAdapterRest ProcessCallback method") } } 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 4d74ac374e..c947bf2e65 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 @@ -25,8 +25,8 @@ package org.onap.so.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.core.WorkflowException +import org.onap.so.logger.ErrorCode import org.onap.so.logger.MessageEnum -import org.onap.so.logger.MsoLogger import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -88,7 +88,7 @@ class VnfAdapterUtils { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught exception in ' + method, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + 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/recipe/BpmnRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java index 2dbf2feaf7..526f5d5288 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 @@ -35,13 +35,12 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; /** @@ -185,7 +184,7 @@ public class BpmnRestClient { logger.trace("request body is {}", jsonReq); } catch(Exception e) { logger.error("{} {} {} {} {}", MessageEnum.APIH_WARP_REQUEST.toString(), "Camunda", "wrapVIDRequest", - MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Error in APIH Warp request", e); + ErrorCode.BusinessProcesssError.getValue(), "Error in APIH Warp request", e); } return jsonReq; } 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/validation/FlowValidatorRunner.java index 5352fc2fe0..2cc6415a50 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/validation/FlowValidatorRunner.java @@ -146,7 +146,7 @@ public abstract class FlowValidatorRunner<S extends FlowValidator, E extends Flo result.add(klass.newInstance()); } } catch (InstantiationException | IllegalAccessException e) { - logger.error("failed to build validator list for " + clazz.getName(), e); + logger.error("failed to build validator list for {}", clazz.getName(), e); throw new RuntimeException(e); } 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 61f92313f7..0de3414381 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 @@ -26,8 +26,8 @@ package org.onap.so.bpmn.common.workflow.context; import java.util.concurrent.DelayQueue; import java.util.concurrent.TimeUnit; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -121,7 +121,6 @@ public class WorkflowContextHolder { while (!isInterrupted()) { try { WorkflowContext requestObject = responseQueue.take(); - MsoLogger.setLogContext(requestObject.getRequestId(), null); logger.debug("Time remaining for request id: {}:{}", requestObject.getRequestId(), requestObject .getDelay (TimeUnit.MILLISECONDS)); @@ -132,7 +131,7 @@ public class WorkflowContextHolder { } catch (Exception e) { logger.debug("WorkflowContextHolder timeout thread caught exception: ", e); logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "Error in WorkflowContextHolder timeout thread"); + ErrorCode.UnknownError.getValue(), "Error in WorkflowContextHolder timeout thread"); } } logger.debug("WorkflowContextHolder timeout thread interrupted, quitting"); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java index ba3ab7f315..c6e7668f22 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java @@ -143,8 +143,28 @@ public class GenericVnf implements Serializable, ShallowCopy<GenericVnf> { private String nfFunction; @JsonProperty("nf-role") private String nfRole; + @JsonProperty("CDS_BLUEPRINT_NAME") + private String blueprintName; + @JsonProperty("CDS_BLUEPRINT_VERSION") + private String blueprintVersion; + public String getBlueprintName() { + return blueprintName; + } + + public void setBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + } + + public String getBlueprintVersion() { + return blueprintVersion; + } + + public void setBlueprintVersion(String blueprintVersion) { + this.blueprintVersion = blueprintVersion; + } + public String getNfFunction() { return nfFunction; } 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 68caeb244f..b432fe10b7 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 @@ -13,11 +13,11 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("vnfc") public class Vnfc implements Serializable { - + /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -9170269565756850796L; @Id @JsonProperty("vnfc-name") private String vnfcName; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoConfiguration.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoConfiguration.java index 87168107e1..462664c612 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoConfiguration.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoConfiguration.java @@ -34,9 +34,25 @@ public class ModelInfoConfiguration implements Serializable{ private String modelVersionId; @JsonProperty("model-customization-id") private String modelCustomizationId; + @JsonProperty("configuration-type") + private String configurationType; + @JsonProperty("configuration-role") + private String configurationRole; @JsonProperty("policy-name") private String policyName; + public String getConfigurationRole() { + return configurationRole; + } + public void setConfigurationRole(String configurationRole) { + this.configurationRole = configurationRole; + } + public String getConfigurationType() { + return configurationType; + } + public void setConfigurationType(String configurationType) { + this.configurationType = configurationType; + } public String getModelInvariantId() { return modelInvariantId; } 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 0a334cde6f..50a9c4e8b1 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 @@ -505,6 +505,8 @@ public class BBInputSetupMapperLayer { modelInfoConfiguration.setModelCustomizationId(vnfVfmoduleCvnfcConfigurationCustomization.getModelCustomizationUUID()); modelInfoConfiguration.setModelInvariantId(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationResource().getModelInvariantUUID()); modelInfoConfiguration.setPolicyName(vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName()); + modelInfoConfiguration.setConfigurationType(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationType()); + modelInfoConfiguration.setConfigurationRole(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationRole()); return modelInfoConfiguration; } 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 36a6bf37d9..88ed5d37d9 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 @@ -146,7 +146,7 @@ public class BBInputSetupUtils { } public VnfVfmoduleCvnfcConfigurationCustomization getVnfVfmoduleCvnfcConfigurationCustomizationByActionAndIsALaCarteAndRequestScopeAndCloudOwner(String vnfCustomizationUuid, - String vfModuleCustomizationUuid, String cvnfcCustomizationUuid) { + String vfModuleCustomizationUuid, String cvnfcCustomizationUuid){ return catalogDbClient.getVnfVfmoduleCvnfcConfigurationCustomizationByVnfCustomizationUuidAndVfModuleCustomizationUuidAndCvnfcCustomizationUuid(vnfCustomizationUuid, vfModuleCustomizationUuid, cvnfcCustomizationUuid); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java index d2d321f8f4..8af6e809f4 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java @@ -46,6 +46,9 @@ public class ExtractPojosForBB { private static final Logger logger = LoggerFactory.getLogger(ExtractPojosForBB.class); + public <T> T extractByKey(BuildingBlockExecution execution, ResourceKey key) throws BBObjectNotFoundException { + return extractByKey(execution, key, execution.getLookupMap().get(key)); + } public <T> T extractByKey(BuildingBlockExecution execution, ResourceKey key, String value) throws BBObjectNotFoundException { @@ -59,39 +62,39 @@ public class ExtractPojosForBB { result = lookupObjectInList(gBBInput.getCustomer().getServiceSubscription().getServiceInstances(), value); break; case GENERIC_VNF_ID: - serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); result = lookupObjectInList(serviceInstance.getVnfs(), value); break; case NETWORK_ID: - serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); result = lookupObjectInList(serviceInstance.getNetworks(), value); break; case VOLUME_GROUP_ID: - vnf = extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + vnf = extractByKey(execution, ResourceKey.GENERIC_VNF_ID); result = lookupObjectInList(vnf.getVolumeGroups(), value); break; case VF_MODULE_ID: - vnf = extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + vnf = extractByKey(execution, ResourceKey.GENERIC_VNF_ID); result = lookupObjectInList(vnf.getVfModules(), value); break; case ALLOTTED_RESOURCE_ID: - serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); result = lookupObjectInList(serviceInstance.getAllottedResources(), value); break; case CONFIGURATION_ID: - serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); result = lookupObjectInList(serviceInstance.getConfigurations(), value); break; case VPN_ID: - serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); result = lookupObjectInList(gBBInput.getCustomer().getVpnBindings(), value); break; case VPN_BONDING_LINK_ID: - serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); result = lookupObjectInList(serviceInstance.getVpnBondingLinks(),value); break; case INSTANCE_GROUP_ID: - serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); result = lookupObjectInList(serviceInstance.getInstanceGroups(), value); break; default: diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java new file mode 100644 index 0000000000..0b2ef928ad --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -0,0 +1,192 @@ +/*- + * ============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========================================================= + */ + +package org.onap.so.client.cds; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; +import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; +import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; +import org.onap.so.client.PreconditionFailedException; +import org.onap.so.client.RestPropertiesLoader; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.Struct; +import com.google.protobuf.Struct.Builder; +import com.google.protobuf.util.JsonFormat; + +import io.grpc.Status; + +/** + * Util class to support Call to CDS client + * + */ +@Component +public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { + + private static final Logger logger = LoggerFactory.getLogger(AbstractCDSProcessingBBUtils.class); + + private static final String SUCCESS = "Success"; + private static final String FAILED = "Failed"; + private static final String PROCESSING = "Processing"; + + private final AtomicReference<String> cdsResponse = new AtomicReference<>(); + + @Autowired + private ExceptionBuilder exceptionUtil; + + /** + * Extracting data from execution object and building the ExecutionServiceInput + * Object + * + * @param execution + * DelegateExecution object + */ + public void constructExecutionServiceInputObject(DelegateExecution execution) { + logger.trace("Start AbstractCDSProcessingBBUtils.preProcessRequest "); + + try { + AbstractCDSPropertiesBean executionObject = (AbstractCDSPropertiesBean) execution + .getVariable("executionObject"); + + String payload = executionObject.getRequestObject(); + + CommonHeader commonHeader = CommonHeader.newBuilder().setOriginatorId(executionObject.getOriginatorId()) + .setRequestId(executionObject.getRequestId()).setSubRequestId(executionObject.getSubRequestId()) + .build(); + ActionIdentifiers actionIdentifiers = ActionIdentifiers.newBuilder() + .setBlueprintName(executionObject.getBlueprintName()) + .setBlueprintVersion(executionObject.getBlueprintVersion()) + .setActionName(executionObject.getActionName()).setMode(executionObject.getMode()).build(); + + Builder struct = Struct.newBuilder(); + try { + JsonFormat.parser().merge(payload, struct); + } catch (InvalidProtocolBufferException e) { + logger.error("Failed to parse received message. blueprint({}:{}) for action({}). {}", + executionObject.getBlueprintVersion(), executionObject.getBlueprintName(), + executionObject.getActionName(), e); + } + + ExecutionServiceInput executionServiceInput = ExecutionServiceInput.newBuilder() + .setCommonHeader(commonHeader).setActionIdentifiers(actionIdentifiers).setPayload(struct.build()) + .build(); + + execution.setVariable("executionServiceInput", executionServiceInput); + + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * get the executionServiceInput object from execution and send a request to CDS + * Client and wait for TIMEOUT period + * + * @param execution + * DelegateExecution object + */ + public void sendRequestToCDSClient(DelegateExecution execution) { + + logger.trace("Start AbstractCDSProcessingBBUtils.sendRequestToCDSClient "); + try { + CDSProperties props = RestPropertiesLoader.getInstance().getNewImpl(CDSProperties.class); + if (props == null) { + throw new PreconditionFailedException( + "No RestProperty.CDSProperties implementation found on classpath, can't create client."); + } + + ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution + .getVariable("executionServiceInput"); + + CDSProcessingListener cdsProcessingListener = new AbstractCDSProcessingBBUtils(); + + CDSProcessingClient cdsClient = new CDSProcessingClient(cdsProcessingListener); + CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput); + + try { + countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS); + } catch (InterruptedException ex) { + logger.error("Caught exception in sendRequestToCDSClient in AbstractCDSProcessingBBUtils : ", ex); + } finally { + cdsClient.close(); + } + + if (cdsResponse != null) { + execution.setVariable("CDSStatus", cdsResponse.get()); + } + + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * Get Response from CDS Client + * + */ + @Override + public void onMessage(ExecutionServiceOutput message) { + logger.info("Received notification from CDS: {}", message); + EventType eventType = message.getStatus().getEventType(); + + switch (eventType) { + + case EVENT_COMPONENT_FAILURE: + // failed processing with failure + cdsResponse.set(FAILED); + break; + case EVENT_COMPONENT_PROCESSING: + // still processing + cdsResponse.set(PROCESSING); + break; + case EVENT_COMPONENT_EXECUTED: + // done with async processing + cdsResponse.set(SUCCESS); + break; + default: + cdsResponse.set(FAILED); + break; + } + + } + + /** + * On error at CDS, log the error + */ + @Override + public void onError(Throwable t) { + Status status = Status.fromThrowable(t); + logger.error("Failed processing blueprint {}", status, t); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/AbstractCDSPropertiesBean.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/AbstractCDSPropertiesBean.java new file mode 100644 index 0000000000..4b645984cf --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/AbstractCDSPropertiesBean.java @@ -0,0 +1,89 @@ +package org.onap.so.client.cds.beans; + +import java.io.Serializable; + +public class AbstractCDSPropertiesBean implements Serializable { + + private static final long serialVersionUID = -4800522372460352963L; + + private String blueprintName; + + private String blueprintVersion; + + private String requestObject; + + private String originatorId; + + private String requestId; + + private String subRequestId; + + private String actionName; + + private String mode; + + public String getBlueprintName() { + return blueprintName; + } + + public void setBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + } + + public String getBlueprintVersion() { + return blueprintVersion; + } + + public void setBlueprintVersion(String blueprintVersion) { + this.blueprintVersion = blueprintVersion; + } + + public String getRequestObject() { + return requestObject; + } + + public void setRequestObject(String requestObject) { + this.requestObject = requestObject; + } + + public String getOriginatorId() { + return originatorId; + } + + public void setOriginatorId(String originatorId) { + this.originatorId = originatorId; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getSubRequestId() { + return subRequestId; + } + + public void setSubRequestId(String subRequestId) { + this.subRequestId = subRequestId; + } + + public String getActionName() { + return actionName; + } + + public void setActionName(String actionName) { + this.actionName = actionName; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnf.java new file mode 100644 index 0000000000..bdb9161735 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnf.java @@ -0,0 +1,112 @@ +package org.onap.so.client.cds.beans; + +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"service-instance-id", +"pnf-id", +"pnf-name", +"service-model-uuid", +"pnf-customization-uuid" +}) + +public class ConfigAssignPropertiesForPnf { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + + @JsonProperty("pnf-id") + private String pnfId; + + @JsonProperty("pnf-name") + private String pnfName; + + @JsonProperty("service-model-uuid") + private String serviceModelUuid; + + @JsonProperty("pnf-customization-uuid") + private String pnfCustomizationUuid; + + @JsonIgnore + private Map<String, Object> userParam = new HashMap<String, Object>(); + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getPnfId() { + return pnfId; + } + + public void setPnfId(String pnfId) { + this.pnfId = pnfId; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getServiceModelUuid() { + return serviceModelUuid; + } + + public void setServiceModelUuid(String serviceModelUuid) { + this.serviceModelUuid = serviceModelUuid; + } + + public String getPnfCustomizationUuid() { + return pnfCustomizationUuid; + } + + public void setPnfCustomizationUuid(String pnfCustomizationUuid) { + this.pnfCustomizationUuid = pnfCustomizationUuid; + } + + public Map<String, Object> getUserParam() { + return this.userParam; + } + + public void setUserParam(String name, Object value) { + this.userParam.put(name, value); + } + + @Override + public String toString() { + + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"pnf-id\":").append("\"").append(pnfId).append("\""); + sb.append(", \"pnf-name\":").append("\"").append(pnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"pnf-customization-uuid\":").append("\"").append(pnfCustomizationUuid).append("\""); + for (Map.Entry<String, Object> entry : userParam.entrySet()) { + sb.append(","); + sb.append("\""); + sb.append(entry.getKey()); + sb.append("\""); + sb.append(":"); + sb.append("\""); + sb.append(entry.getValue()); + sb.append("\""); + } + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnf.java new file mode 100644 index 0000000000..1ce26d8585 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnf.java @@ -0,0 +1,112 @@ +package org.onap.so.client.cds.beans; + +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"service-instance-id", +"vnf-id", +"vnf-name", +"service-model-uuid", +"vnf-customization-uuid" +}) + +public class ConfigAssignPropertiesForVnf { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + + @JsonProperty("vnf-id") + private String vnfId; + + @JsonProperty("vnf-name") + private String vnfName; + + @JsonProperty("service-model-uuid") + private String serviceModelUuid; + + @JsonProperty("vnf-customization-uuid") + private String vnfCustomizationUuid; + + @JsonIgnore + private Map<String, Object> userParam = new HashMap<String, Object>(); + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getServiceModelUuid() { + return serviceModelUuid; + } + + public void setServiceModelUuid(String serviceModelUuid) { + this.serviceModelUuid = serviceModelUuid; + } + + public String getVnfCustomizationUuid() { + return vnfCustomizationUuid; + } + + public void setVnfCustomizationUuid(String vnfCustomizationUuid) { + this.vnfCustomizationUuid = vnfCustomizationUuid; + } + + public Map<String, Object> getUserParam() { + return this.userParam; + } + + public void setUserParam(String name, Object value) { + this.userParam.put(name, value); + } + + @Override + public String toString() { + + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"vnf-id\":").append("\"").append(vnfId).append("\""); + sb.append(", \"vnf-name\":").append("\"").append(vnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"vnf-customization-uuid\":").append("\"").append(vnfCustomizationUuid).append("\""); + for (Map.Entry<String, Object> entry : userParam.entrySet()) { + sb.append(","); + sb.append("\""); + sb.append(entry.getKey()); + sb.append("\""); + sb.append(":"); + sb.append("\""); + sb.append(entry.getValue()); + sb.append("\""); + } + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnf.java new file mode 100644 index 0000000000..b96847f422 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnf.java @@ -0,0 +1,46 @@ +package org.onap.so.client.cds.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"config-assign-properties", +"resolution-key" +}) + +public class ConfigAssignRequestPnf { + @JsonProperty("resolution-key") + private String resolutionKey; + @JsonProperty("config-assign-properties") + private ConfigAssignPropertiesForPnf configAssignPropertiesForPnf; + + public String getResolutionKey() { + return resolutionKey; + } + + public void setResolutionKey(String resolutionKey) { + this.resolutionKey = resolutionKey; + } + + public ConfigAssignPropertiesForPnf getConfigAssignPropertiesForPnf() { + return configAssignPropertiesForPnf; + } + + public void setConfigAssignPropertiesForPnf(ConfigAssignPropertiesForPnf configAssignPropertiesForPnf) { + this.configAssignPropertiesForPnf = configAssignPropertiesForPnf; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{\"config-assign-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-assign-properties\":").append(configAssignPropertiesForPnf.toString()); + sb.append('}'); + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnf.java new file mode 100644 index 0000000000..b3a9601e2e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnf.java @@ -0,0 +1,45 @@ + +package org.onap.so.client.cds.beans; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"config-assign-properties", +"resolution-key" +}) +public class ConfigAssignRequestVnf { + @JsonProperty("resolution-key") + private String resolutionKey; + @JsonProperty("config-assign-properties") + private ConfigAssignPropertiesForVnf configAssignPropertiesForVnf; + + public String getResolutionKey() { + return resolutionKey; + } + + public void setResolutionKey(String resolutionKey) { + this.resolutionKey = resolutionKey; + } + + public ConfigAssignPropertiesForVnf getConfigAssignPropertiesForVnf() { + return configAssignPropertiesForVnf; + } + + public void setConfigAssignPropertiesForVnf(ConfigAssignPropertiesForVnf configAssignPropertiesForVnf) { + this.configAssignPropertiesForVnf = configAssignPropertiesForVnf; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{\"config-assign-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-assign-properties\":").append(configAssignPropertiesForVnf.toString()); + sb.append('}'); + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnf.java new file mode 100644 index 0000000000..b8fb5b96bd --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnf.java @@ -0,0 +1,88 @@ +package org.onap.so.client.cds.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"service-instance-id", +"pnf-id", +"pnf-name", +"service-model-uuid", +"pnf-customization-uuid" +}) + +public class ConfigDeployPropertiesForPnf { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + + @JsonProperty("pnf-id") + private String pnfId; + + @JsonProperty("pnf-name") + private String pnfName; + + @JsonProperty("service-model-uuid") + private String serviceModelUuid; + + @JsonProperty("pnf-customization-uuid") + private String pnfCustomizationUuid; + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getPnfId() { + return pnfId; + } + + public void setPnfId(String pnfId) { + this.pnfId = pnfId; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getServiceModelUuid() { + return serviceModelUuid; + } + + public void setServiceModelUuid(String serviceModelUuid) { + this.serviceModelUuid = serviceModelUuid; + } + + public String getPnfCustomizationUuid() { + return pnfCustomizationUuid; + } + + public void setPnfCustomizationUuid(String pnfCustomizationUuid) { + this.pnfCustomizationUuid = pnfCustomizationUuid; + } + + @Override + public String toString() { + + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"pnf-id\":").append("\"").append(pnfId).append("\""); + sb.append(", \"pnf-name\":").append("\"").append(pnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"pnf-customization-uuid\":").append("\"").append(pnfCustomizationUuid).append("\""); + + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnf.java new file mode 100644 index 0000000000..ca2530b541 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnf.java @@ -0,0 +1,87 @@ +package org.onap.so.client.cds.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"service-instance-id", +"vnf-id", +"vnf-name", +"service-model-uuid", +"vnf-customization-uuid" +}) +public class ConfigDeployPropertiesForVnf { + + @JsonProperty("service-instance-id") + private String serviceInstanceId; + + @JsonProperty("vnf-id") + private String vnfId; + + @JsonProperty("vnf-name") + private String vnfName; + + @JsonProperty("service-model-uuid") + private String serviceModelUuid; + + @JsonProperty("vnf-customization-uuid") + private String vnfCustomizationUuid; + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getServiceModelUuid() { + return serviceModelUuid; + } + + public void setServiceModelUuid(String serviceModelUuid) { + this.serviceModelUuid = serviceModelUuid; + } + + public String getVnfCustomizationUuid() { + return vnfCustomizationUuid; + } + + public void setVnfCustomizationUuid(String vnfCustomizationUuid) { + this.vnfCustomizationUuid = vnfCustomizationUuid; + } + + @Override + public String toString() { + + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"service-instance-id\":").append("\"").append(serviceInstanceId).append("\""); + sb.append(", \"vnf-id\":").append("\"").append(vnfId).append("\""); + sb.append(", \"vnf-name\":").append("\"").append(vnfName).append("\""); + sb.append(", \"service-model-uuid\":").append("\"").append(serviceModelUuid).append("\""); + sb.append(", \"vnf-customization-uuid\":").append("\"").append(vnfCustomizationUuid).append("\""); + + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnf.java new file mode 100644 index 0000000000..4635008d3f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnf.java @@ -0,0 +1,46 @@ +package org.onap.so.client.cds.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"config-deploy-properties", +"resolution-key" +}) +public class ConfigDeployRequestPnf { + @JsonProperty("resolution-key") + private String resolutionKey; + + @JsonProperty("config-deploy-properties") + private ConfigDeployPropertiesForPnf configDeployPropertiesForPnf; + + public String getResolutionKey() { + return resolutionKey; + } + + public void setResolutionKey(String resolutionKey) { + this.resolutionKey = resolutionKey; + } + + public ConfigDeployPropertiesForPnf getConfigDeployPropertiesForPnf() { + return configDeployPropertiesForPnf; + } + + public void setConfigDeployPropertiesForPnf(ConfigDeployPropertiesForPnf configDeployPropertiesForPnf) { + this.configDeployPropertiesForPnf = configDeployPropertiesForPnf; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{\"config-deploy-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-deploy-properties\":").append(configDeployPropertiesForPnf.toString()); + sb.append('}'); + sb.append('}'); + + return sb.toString(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnf.java new file mode 100644 index 0000000000..53b956d3c4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnf.java @@ -0,0 +1,46 @@ +package org.onap.so.client.cds.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"config-deploy-properties", +"resolution-key" +}) +public class ConfigDeployRequestVnf { + @JsonProperty("resolution-key") + private String resolutionKey; + + @JsonProperty("config-deploy-properties") + private ConfigDeployPropertiesForVnf configDeployPropertiesForVnf; + + public String getResolutionKey() { + return resolutionKey; + } + + public void setResolutionKey(String resolutionKey) { + this.resolutionKey = resolutionKey; + } + + public ConfigDeployPropertiesForVnf getConfigDeployPropertiesForVnf() { + return configDeployPropertiesForVnf; + } + + public void setConfigDeployPropertiesForVnf(ConfigDeployPropertiesForVnf configDeployPropertiesForVnf) { + this.configDeployPropertiesForVnf = configDeployPropertiesForVnf; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{\"config-deploy-request\":{"); + sb.append("\"resolution-key\":").append("\"").append(resolutionKey).append("\""); + sb.append(", \"config-deploy-properties\":").append(configDeployPropertiesForVnf.toString()); + sb.append('}'); + sb.append('}'); + + return sb.toString(); + } + +} 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 916d24e8dc..cb65f4d420 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 @@ -27,8 +27,8 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; 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.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -55,7 +55,7 @@ public class ExceptionBuilder { } logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), msg.toString()); + ErrorCode.UnknownError.getValue(), msg.toString()); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex){ //log trace, allow process to complete gracefully @@ -84,7 +84,7 @@ public class ExceptionBuilder { } } logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), msg.toString()); + ErrorCode.UnknownError.getValue(), msg.toString()); execution.setVariable(errorVariable, exception.getMessage()); } catch (Exception ex){ //log trace, allow process to complete gracefully diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java index 1967e5a1ce..d1888b17df 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/CDSPropertiesImpl.java @@ -30,6 +30,7 @@ public class CDSPropertiesImpl implements CDSProperties { private static final String ENDPOINT = "cds.endpoint"; private static final String PORT = "cds.port"; private static final String AUTH = "cds.auth"; + private static final String TIMEOUT = "cds.timeout"; public CDSPropertiesImpl() { // Needed for service loader @@ -74,4 +75,9 @@ public class CDSPropertiesImpl implements CDSProperties { public boolean mapNotFoundToEmpty() { return false; } + + @Override + public int getTimeout() { + return Integer.parseInt(Objects.requireNonNull(UrnPropertiesReader.getVariable(TIMEOUT))); + } } |