diff options
Diffstat (limited to 'bpmn')
36 files changed, 372 insertions, 946 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy index 64567a349e..5525c2642b 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -40,11 +40,11 @@ class ExternalAPIUtil { String Prefix="EXTAPI_" - private static final Logger logger = LoggerFactory.getLogger( ExternalAPIUtil.class); + private static final Logger logger = LoggerFactory.getLogger( ExternalAPIUtil.class) - private final HttpClientFactory httpClientFactory; - private final MsoUtils utils; - private final ExceptionUtil exceptionUtil; + private final HttpClientFactory httpClientFactory + private final MsoUtils utils + private final ExceptionUtil exceptionUtil public static final String PostServiceOrderRequestsTemplate = "{\n" + @@ -107,22 +107,22 @@ class ExternalAPIUtil { // } public String setTemplate(String template, Map<String, String> valueMap) { - logger.debug("ExternalAPIUtil setTemplate", true); - StringBuffer result = new StringBuffer(); + logger.debug("ExternalAPIUtil setTemplate", true) + StringBuffer result = new StringBuffer() - String pattern = "<.*>"; - Pattern r = Pattern.compile(pattern); - Matcher m = r.matcher(template); + String pattern = "<.*>" + Pattern r = Pattern.compile(pattern) + Matcher m = r.matcher(template) - logger.debug("ExternalAPIUtil template:" + template, true); + logger.debug("ExternalAPIUtil template:" + template, true) while (m.find()) { - String key = template.substring(m.start() + 1, m.end() - 1); - logger.debug("ExternalAPIUtil key:" + key + " contains key? " + valueMap.containsKey(key), true); - m.appendReplacement(result, valueMap.getOrDefault(key, "\"TBD\"")); + String key = template.substring(m.start() + 1, m.end() - 1) + logger.debug("ExternalAPIUtil key:" + key + " contains key? " + valueMap.containsKey(key), true) + m.appendReplacement(result, valueMap.getOrDefault(key, "\"TBD\"")) } - m.appendTail(result); - logger.debug("ExternalAPIUtil return:" + result.toString(), true); - return result.toString(); + m.appendTail(result) + logger.debug("ExternalAPIUtil return:" + result.toString(), true) + return result.toString() } /** diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilFactory.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilFactory.groovy index e7f46464ee..549267eec1 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilFactory.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtilFactory.groovy @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Nokia. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * 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 f013fa8698..db39358ccd 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 @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -22,9 +22,9 @@ package org.onap.so.bpmn.common.scripts -import org.onap.so.logger.LoggingAnchor; +import org.onap.so.logger.LoggingAnchor import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.ErrorCode import java.text.SimpleDateFormat @@ -39,7 +39,7 @@ import static org.apache.commons.lang3.StringUtils.* // SDNC Adapter Request/Response processing public class SDNCAdapter extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( SDNCAdapter.class); + private static final Logger logger = LoggerFactory.getLogger( SDNCAdapter.class) def Prefix="SDNCA_" @@ -77,7 +77,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { } catch (IOException ex) { logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Unable to encode username password string", "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) } // TODO Use variables instead of passing xml request - Huh? @@ -238,9 +238,9 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { def sdnccallbackreq=execution.getVariable("sdncAdapterCallbackRequest") logger.debug("sdncAdapterCallbackRequest :" + sdnccallbackreq) if (sdnccallbackreq==null){ - execution.setVariable("callbackResponseReceived",false); + execution.setVariable("callbackResponseReceived",false) }else{ - execution.setVariable("callbackResponseReceived",true); + execution.setVariable("callbackResponseReceived",true) } } @@ -303,10 +303,10 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { } 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; + 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 void toggleSuccessIndicator(DelegateExecution execution){ 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 449f4e3222..c30d807bf3 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 @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -53,7 +53,7 @@ import org.onap.so.utils.TargetEntity class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( SDNCAdapterRestV1.class); + private static final Logger logger = LoggerFactory.getLogger( SDNCAdapterRestV1.class) ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -88,7 +88,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined' logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -109,7 +109,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -124,7 +124,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -141,7 +141,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -157,7 +157,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined") logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) } else { try { def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution)) @@ -166,7 +166,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter") logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", - "BPMN", ErrorCode.UnknownError.getValue(), ex); + "BPMN", ErrorCode.UnknownError.getValue(), ex) } } @@ -176,7 +176,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String timeout = jsonUtil.getJsonValue(request, requestType + ".bpTimeout") // in addition to null/empty, also need to verify that the timer value is a valid duration "P[n]T[n]H|M|S" - String timerRegex = "PT[0-9]+[HMS]"; + String timerRegex = "PT[0-9]+[HMS]" if (timeout == null || timeout.isEmpty() || !timeout.matches(timerRegex)) { logger.debug(getProcessKey(execution) + ': preProcessRequest(): null/empty/invalid bpTimeout value. Using "mso.adapters.sdnc.timeout"') timeout = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution) @@ -197,7 +197,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } } @@ -221,7 +221,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String sdncAdapterRequest = execution.getVariable(prefix + 'sdncAdapterRequest') logger.debug("SDNC Rest Request is: " + sdncAdapterRequest) - URL url = new URL(sdncAdapterUrl); + URL url = new URL(sdncAdapterUrl) HttpClient httpClient = new HttpClientFactory().newJsonClient(url, TargetEntity.SDNC_ADAPTER) httpClient.addAdditionalHeader("X-ONAP-RequestID", execution.getVariable("mso-request-id")) @@ -245,7 +245,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Unsupported HTTP method "' + sdncAdapterMethod + '" in ' + method + ": " + e logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -259,7 +259,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg, e) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } } @@ -330,7 +330,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { } // Note: the mapping function handles a null or empty responseCode - int mappedResponseCode = Integer.parseInt(exceptionUtil.MapSDNCResponseCodeToErrorCode(responseCode)); + int mappedResponseCode = Integer.parseInt(exceptionUtil.MapSDNCResponseCodeToErrorCode(responseCode)) exceptionUtil.buildWorkflowException(execution, mappedResponseCode, "Received " + responseType + " from SDNCAdapter:" + info) } catch (Exception e) { @@ -370,7 +370,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } } @@ -396,12 +396,12 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } } public Logger getLogger() { - return logger; + return logger } } 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 62c7bb5adf..ba5145d19b 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 @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -51,7 +51,7 @@ import org.slf4j.LoggerFactory * any non-final response received from SDNC. */ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { - private static final Logger logger = LoggerFactory.getLogger( SDNCAdapterRestV2.class); + private static final Logger logger = LoggerFactory.getLogger( SDNCAdapterRestV2.class) ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -87,7 +87,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined' logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -108,7 +108,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -123,7 +123,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -134,7 +134,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } @@ -153,7 +153,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined") logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) } else { try { def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution)) @@ -162,7 +162,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter") logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", - "BPMN", ErrorCode.UnknownError.getValue(), ex); + "BPMN", ErrorCode.UnknownError.getValue(), ex) } } @@ -172,7 +172,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { String timeout = jsonUtil.getJsonValue(request, requestType + ".bpTimeout") // in addition to null/empty, also need to verify that the timer value is a valid duration "P[n]T[n]H|M|S" - String timerRegex = "PT[0-9]+[HMS]"; + String timerRegex = "PT[0-9]+[HMS]" if (timeout == null || timeout.isEmpty() || !timeout.matches(timerRegex)) { logger.debug(getProcessKey(execution) + ': preProcessRequest(): null/empty/invalid bpTimeout value. Using "mso.adapters.sdnc.timeout"') timeout = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution) @@ -193,7 +193,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { String msg = 'Caught exception in ' + method + ": " + e logger.debug(msg) logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); + ErrorCode.UnknownError.getValue()) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } } @@ -297,6 +297,6 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { } public Logger getLogger() { - return logger; + return logger } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java index b1173bbf95..cc3ec52c7a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java @@ -108,6 +108,11 @@ public class InstanceResourceList { sequencedResourceList.add(vnfResource); } + // check if the resource contains vf-module + if (vnfResource != null && vnfResource.getVfModules() != null) { + sequencedResourceList.addAll(vnfResource.getVfModules()); + } + return sequencedResourceList; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index fd2054c3d0..09a5424d47 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -144,9 +144,20 @@ public class ExecuteBuildingBlockRainyDay { // keep default workStep value } + String serviceRole = ASTERISK; + try { + serviceRole = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) + .getModelInfoServiceInstance().getServiceRole(); + if (serviceRole == null || serviceRole.isEmpty()) { + serviceRole = ASTERISK; + } + } catch (Exception ex) { + // keep default serviceRole value + } + RainyDayHandlerStatus rainyDayHandlerStatus; rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatus(bbName, serviceType, vnfType, - errorCode, workStep, errorMessage); + errorCode, workStep, errorMessage, serviceRole); if (rainyDayHandlerStatus == null) { handlingCode = "Abort"; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index 80373eb760..18e08917ed 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -105,7 +105,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setWorkStep(ASTERISK); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", "7000", "*", "errorMessage"); + "st1", "vnft1", "7000", "*", "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); @@ -128,7 +128,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setWorkStep(ASTERISK); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", ASTERISK, ASTERISK, "errorMessage"); + "st1", "vnft1", ASTERISK, ASTERISK, "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); assertEquals(5, delegateExecution.getVariable("maxRetries")); @@ -141,7 +141,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatus(isA(String.class), isA(String.class), - isA(String.class), isA(String.class), isA(String.class), isA(String.class)); + isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class)); delegateExecution.setVariable("suppressRollback", false); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -152,7 +152,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { @Test public void queryRainyDayTableExceptionTest() { doThrow(RuntimeException.class).when(MOCK_catalogDbClient).getRainyDayHandlerStatus(isA(String.class), - isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class)); + isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class), + isA(String.class)); delegateExecution.setVariable("aLaCarte", true); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); delegateExecution.setVariable("suppressRollback", false); @@ -178,7 +179,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setSecondaryPolicy("Abort"); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", "7000", "*", "errorMessage"); + "st1", "vnft1", "7000", "*", "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, false); @@ -203,7 +204,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setSecondaryPolicy("Abort"); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", "7000", "*", "errorMessage"); + "st1", "vnft1", "7000", "*", "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -229,7 +230,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setSecondaryPolicy("Abort"); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", "7000", "*", "errorMessage"); + "st1", "vnft1", "7000", "*", "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -255,7 +256,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setSecondaryPolicy("Abort"); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", "7000", "*", "errorMessage"); + "st1", "vnft1", "7000", "*", "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -272,4 +273,52 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { assertEquals("Abort", delegateExecution.getVariable("handlingCode")); } + @Test + public void queryRainyDayTableServiceRoleNotDefined() throws Exception { + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + serviceInstance.getModelInfoServiceInstance().setServiceRole("sr1"); + vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("Rollback"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage", "sr1"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); + assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); + } + + @Test + public void queryRainyDayTableServiceRoleNC() throws Exception { + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + serviceInstance.getModelInfoServiceInstance().setServiceRole("NETWORK-COLLECTION"); + vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("ActivateServiceInstanceBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("Abort"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage", "NETWORK-COLLECTION"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); + assertEquals("Abort", delegateExecution.getVariable("handlingCode")); + } + } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java deleted file mode 100644 index 1442099286..0000000000 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/BaseTask.java +++ /dev/null @@ -1,422 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.core; - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.Expression; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.so.bpmn.core.internal.VariableNameExtractor; - -/** - * Base class for service tasks. - */ -public class BaseTask implements JavaDelegate { - - /** - * Get the value of a required field. This method throws MissingInjectedFieldException if the expression is null, - * and BadInjectedFieldException if the expression evaluates to a null value. - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @return the field value - */ - protected Object getField(Expression expression, DelegateExecution execution, String fieldName) { - return getFieldImpl(expression, execution, fieldName, false); - } - - /** - * Gets the value of an optional field. There are three conditions in which this method returns null: - * <p> - * <ol> - * <li>The expression itself is null (i.e. the field is missing altogether.</li> - * <li>The expression evaluates to a null value.</li> - * <li>The expression references a single variable which has not been set.</li> - * </ol> - * <p> - * Examples:<br> - * Expression ${x} when x is null: return null<br> - * Expression ${x} when x is unset: return null<br> - * Expression ${x+y} when x and/or y are unset: exception<br> - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @return the field value, possibly null - */ - protected Object getOptionalField(Expression expression, DelegateExecution execution, String fieldName) { - return getFieldImpl(expression, execution, fieldName, true); - } - - /** - * Get the value of a required output variable field. This method throws MissingInjectedFieldException if the - * expression is null, and BadInjectedFieldException if the expression produces a null or illegal variable name. - * Legal variable names contain only letters, numbers, and the underscore character ('_'). - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @return the output variable name - */ - protected String getOutputField(Expression expression, DelegateExecution execution, String fieldName) { - Object o = getFieldImpl(expression, execution, fieldName, false); - if (o instanceof String) { - String variable = (String) o; - if (!isLegalVariable(variable)) { - throw new BadInjectedFieldException(fieldName, getTaskName(), - "'" + variable + "' is not a legal variable name"); - } - return variable; - } else { - if (o != null) { - throw new BadInjectedFieldException(fieldName, getTaskName(), - "expected a variable name string, got object of type " + o.getClass().getName()); - } else { - throw new BadInjectedFieldException(fieldName, getTaskName(), - "expected a variable name string, got null object"); - } - } - } - - /** - * Get the value of an optional output variable field. This method throws BadInjectedFieldException if the - * expression produces an illegal variable name. Legal variable names contain only letters, numbers, and the - * underscore character ('_'). - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @return the output variable name, possibly null - */ - protected String getOptionalOutputField(Expression expression, DelegateExecution execution, String fieldName) { - Object o = getFieldImpl(expression, execution, fieldName, true); - if (o instanceof String) { - String variable = (String) o; - if (!isLegalVariable(variable)) { - throw new BadInjectedFieldException(fieldName, getTaskName(), - "'" + variable + "' is not a legal variable name"); - } - return variable; - } else if (o == null) { - return null; - } else { - throw new BadInjectedFieldException(fieldName, getTaskName(), - "expected a variable name string, got object of type " + o.getClass().getName()); - } - } - - /** - * Get the value of a required string field. This method throws MissingInjectedFieldException if the expression is - * null, and BadInjectedFieldException if the expression evaluates to a null value. - * <p> - * Note: the result is coerced to a string value, if necessary. - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @return the field value - */ - protected String getStringField(Expression expression, DelegateExecution execution, String fieldName) { - Object o = getFieldImpl(expression, execution, fieldName, false); - if (o instanceof String) { - return (String) o; - } else if (o != null) { - throw new BadInjectedFieldException(fieldName, getTaskName(), - "cannot convert '" + o.toString() + "' to Integer"); - } else { - throw new MissingInjectedFieldException(fieldName, getTaskName()); - } - } - - /** - * Gets the value of an optional string field. There are three conditions in which this method returns null: - * <p> - * <ol> - * <li>The expression itself is null (i.e. the field is missing altogether.</li> - * <li>The expression evaluates to a null value.</li> - * <li>The expression references a single variable which has not been set.</li> - * </ol> - * <p> - * Examples:<br> - * Expression ${x} when x is null: return null<br> - * Expression ${x} when x is unset: return null<br> - * Expression ${x+y} when x and/or y are unset: exception<br> - * <p> - * Note: the result is coerced to a string value, if necessary. - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @return the field value, possibly null - */ - protected String getOptionalStringField(Expression expression, DelegateExecution execution, String fieldName) { - Object o = getFieldImpl(expression, execution, fieldName, true); - if (o instanceof String) { - return (String) o; - } else if (o == null) { - return null; - } else { - return o.toString(); - } - } - - /** - * Get the value of a required integer field. This method throws MissingInjectedFieldException if the expression is - * null, and BadInjectedFieldException if the expression evaluates to a null value or a value that cannot be coerced - * to an integer. - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @return the field value - */ - protected Integer getIntegerField(Expression expression, DelegateExecution execution, String fieldName) { - Object o = getFieldImpl(expression, execution, fieldName, false); - if (o instanceof Integer) { - return (Integer) o; - } else { - try { - return Integer.parseInt(o.toString()); - } catch (NumberFormatException e) { - if (o != null) { - throw new BadInjectedFieldException(fieldName, getTaskName(), - "cannot convert '" + o.toString() + "' to Integer"); - } else { - throw new MissingInjectedFieldException(fieldName, getTaskName()); - } - } - } - } - - /** - * Gets the value of an optional integer field. There are three conditions in which this method returns null: - * <p> - * <ol> - * <li>The expression itself is null (i.e. the field is missing altogether.</li> - * <li>The expression evaluates to a null value.</li> - * <li>The expression references a single variable which has not been set.</li> - * </ol> - * <p> - * Examples:<br> - * Expression ${x} when x is null: return null<br> - * Expression ${x} when x is unset: return null<br> - * Expression ${x+y} when x and/or y are unset: exception<br> - * <p> - * Note: the result is coerced to an integer value, if necessary. This method throws BadInjectedFieldException if - * the result cannot be coerced to an integer. - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @return the field value, possibly null - */ - protected Integer getOptionalIntegerField(Expression expression, DelegateExecution execution, String fieldName) { - Object o = getFieldImpl(expression, execution, fieldName, true); - if (o instanceof Integer) { - return (Integer) o; - } else if (o == null) { - return null; - } else { - try { - return Integer.parseInt(o.toString()); - } catch (NumberFormatException e) { - throw new BadInjectedFieldException(fieldName, getTaskName(), - "cannot convert '" + o.toString() + "' to Integer"); - } - } - } - - /** - * Gets the value of an optional long field. There are three conditions in which this method returns null: - * <p> - * <ol> - * <li>The expression itself is null (i.e. the field is missing altogether.</li> - * <li>The expression evaluates to a null value.</li> - * <li>The expression references a single variable which has not been set.</li> - * </ol> - * <p> - * Examples:<br> - * Expression ${x} when x is null: return null<br> - * Expression ${x} when x is unset: return null<br> - * Expression ${x+y} when x and/or y are unset: exception<br> - * <p> - * Note: the result is coerced to a long value, if necessary. This method throws BadInjectedFieldException if the - * result cannot be coerced to a long. - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @return the field value, possibly null - */ - protected Long getOptionalLongField(Expression expression, DelegateExecution execution, String fieldName) { - Object o = getFieldImpl(expression, execution, fieldName, true); - if (o instanceof Long) { - return (Long) o; - } else if (o == null) { - return null; - } else { - try { - return Long.parseLong(o.toString()); - } catch (NumberFormatException e) { - throw new BadInjectedFieldException(fieldName, getTaskName(), - "cannot convert '" + o.toString() + "' to Long"); - } - } - } - - /** - * Get the value of a required long field. This method throws MissingInjectedFieldException if the expression is - * null, and BadInjectedFieldException if the expression evaluates to a null value or a value that cannot be coerced - * to a long. - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @return the field value - */ - protected Long getLongField(Expression expression, DelegateExecution execution, String fieldName) { - Object o = getFieldImpl(expression, execution, fieldName, false); - if (o instanceof Long) { - return (Long) o; - } else { - try { - return Long.parseLong(o.toString()); - } catch (NumberFormatException e) { - if (o != null) { - throw new BadInjectedFieldException(fieldName, getTaskName(), - "cannot convert '" + o.toString() + "' to Long"); - } else { - throw new MissingInjectedFieldException(fieldName, getTaskName()); - } - } - } - } - - /** - * Common implementation for field "getter" methods. - * - * @param expression the expression - * @param execution the execution - * @param fieldName the field name (for logging and exceptions) - * @param optional true if the field is optional - * @return the field value, possibly null - */ - private Object getFieldImpl(Expression expression, DelegateExecution execution, String fieldName, - boolean optional) { - if (expression == null) { - if (!optional) { - throw new MissingInjectedFieldException(fieldName, getTaskName()); - } - return null; - } - - Object value = null; - - try { - value = expression.getValue(execution); - } catch (Exception e) { - if (!optional) { - throw new BadInjectedFieldException(fieldName, getTaskName(), e.getClass().getSimpleName(), e); - } - - // At this point, we have an exception that occurred while - // evaluating an expression for an optional field. A common - // problem is that the expression is a simple reference to a - // variable which has never been set, e.g. the expression is - // ${x}. The normal activiti behavior is to throw an exception, - // but we don't like that, so we have the following workaround, - // which parses the expression text to see if it is a "simple" - // variable reference, and if so, returns null. If the - // expression is anything other than a single variable - // reference, then an exception is thrown, as it would have - // been without this workaround. - - // Get the expression text so we can parse it - String s = expression.getExpressionText(); - new VariableNameExtractor(s).extract().ifPresent(name -> { - if (execution.hasVariable(name)) { - throw new BadInjectedFieldException(fieldName, getTaskName(), e.getClass().getSimpleName(), e); - } - }); - } - - if (value == null && !optional) { - throw new BadInjectedFieldException(fieldName, getTaskName(), "required field has null value"); - } - - return value; - } - - /** - * Tests if a character is a "word" character. - * - * @param c the character - * @return true if the character is a "word" character. - */ - private static boolean isWordCharacter(char c) { - return (Character.isLetterOrDigit(c) || c == '_'); - } - - /** - * Tests if the specified string is a legal flow variable name. - * - * @param name the string - * @return true if the string is a legal flow variable name - */ - private boolean isLegalVariable(String name) { - if (name == null) { - return false; - } - - int len = name.length(); - - if (len == 0) { - return false; - } - - char c = name.charAt(0); - - if (!Character.isLetter(c) && c != '_') { - return false; - } - - for (int i = 1; i < len; i++) { - c = name.charAt(i); - if (!Character.isLetterOrDigit(c) && c != '_') { - return false; - } - } - - return true; - } - - /** - * Returns the name of the task (normally the java class name). - * - * @return the name of the task - */ - public String getTaskName() { - return getClass().getSimpleName(); - } - - @Override - public void execute(DelegateExecution execution) throws Exception {} -} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java index 21847e1c4e..7d5bb0dcf1 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java @@ -33,7 +33,7 @@ public class WorkflowException implements Serializable { private final int errorCode; private final String errorMessage; private final String workStep; - private transient TargetEntities extSystemErrorSource; + private TargetEntities extSystemErrorSource; /** * Constructor diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java deleted file mode 100644 index a9f33f20c5..0000000000 --- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/BaseTaskTest.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * ============LICENSE_START======================================================= ONAP : SO - * ================================================================================ Copyright (C) 2018 AT&T Intellectual - * Property. All rights reserved. ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.core; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import org.camunda.bpm.engine.ProcessEngineServices; -import org.camunda.bpm.engine.RepositoryService; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.Expression; -import org.camunda.bpm.engine.repository.ProcessDefinition; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -public class BaseTaskTest { - - private String prefix = "PRE_"; - private String processKey = "AnyProcessKey"; - private String definitionId = "100"; - private String anyVariable = "anyVariable"; - private String anyValueString = "anyValue"; - private String badValueString = "123abc"; - private int anyValueInt = 123; - private Integer anyValueInteger = Integer.valueOf(anyValueInt); - private long anyValuelong = 123L; - private Long anyValueLong = Long.valueOf(anyValuelong); - - private DelegateExecution mockExecution; - private Expression mockExpression; - private BaseTask baseTask; - private Object obj1; - private Object obj2; - private Object objectString; - private Object objectInteger; - private Object objectLong; - private Object objectBoolean; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Before - public void before() throws Exception { - baseTask = new BaseTask(); - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class); - when(mockProcessDefinition.getKey()).thenReturn(processKey); - RepositoryService mockRepositoryService = mock(RepositoryService.class); - when(mockRepositoryService.getProcessDefinition(definitionId)).thenReturn(mockProcessDefinition); - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class); - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService); - mockExecution = mock(DelegateExecution.class); - when(mockExecution.getId()).thenReturn(definitionId); - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices); - when(mockExecution.getProcessEngineServices().getRepositoryService() - .getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition); - when(mockExecution.getVariable("prefix")).thenReturn(prefix); - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true"); - mockExpression = mock(Expression.class); - } - - @Test - public void testExecution() throws Exception { - baseTask.execute(mockExecution); - assertEquals("BaseTask", baseTask.getTaskName()); - } - - @Test - public void testGetFieldAndMissingInjectedException() throws Exception { - objectString = new String(anyValueString); - when(mockExpression.getValue(mockExecution)).thenReturn(objectString); - obj1 = baseTask.getField(mockExpression, mockExecution, anyVariable); - assertEquals(anyValueString, obj1.toString()); - - expectedException.expect(MissingInjectedFieldException.class); - obj2 = baseTask.getField(null, mockExecution, anyVariable); - } - - @Test - public void testGetFieldAndBadInjectedFieldException() throws Exception { - expectedException.expect(BadInjectedFieldException.class); - obj1 = baseTask.getField(mockExpression, mockExecution, null); - } - - @Test - public void testGetOptionalField() throws Exception { - objectString = new String(anyValueString); - when(mockExpression.getValue(mockExecution)).thenReturn(objectString); - obj1 = baseTask.getOptionalField(mockExpression, mockExecution, anyVariable); - assertEquals(anyValueString, obj1.toString()); - } - - @Test - public void testGetStringFieldAndMissingInjectedFieldException() throws Exception { - objectString = new String(anyValueString); - when(mockExpression.getValue(mockExecution)).thenReturn(objectString); - obj1 = baseTask.getStringField(mockExpression, mockExecution, anyVariable); - assertEquals(anyValueString, obj1.toString()); - - expectedException.expect(MissingInjectedFieldException.class); - Object objectBoolean = Boolean.valueOf(true); // bad data - when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean); - obj2 = baseTask.getStringField(null, mockExecution, anyVariable); - } - - @Test - public void testGetStringFieldAndBadInjectedFieldException() throws Exception { - expectedException.expect(BadInjectedFieldException.class); - obj1 = baseTask.getStringField(mockExpression, mockExecution, null); - } - - @Test - public void testGetOptionalStringField() throws Exception { - objectString = new String(anyValueString); - when(mockExpression.getValue(mockExecution)).thenReturn(objectString); - obj1 = baseTask.getOptionalStringField(mockExpression, mockExecution, anyVariable); - assertEquals(anyValueString, obj1.toString()); - } - - @Test - public void testGetIntegerFieldAndMissingInjectedFieldException() throws Exception { - objectInteger = Integer.valueOf(anyValueInt); - when(mockExpression.getValue(mockExecution)).thenReturn(objectInteger); - obj1 = baseTask.getIntegerField(mockExpression, mockExecution, anyVariable); - assertEquals(anyValueInteger, (Integer) obj1); - - expectedException.expect(MissingInjectedFieldException.class); - objectString = new String(badValueString); - when(mockExpression.getValue(mockExecution)).thenReturn(objectString); - obj2 = baseTask.getIntegerField(null, mockExecution, anyVariable); - } - - @Test - public void testGetIntegerFieldAndBadInjectedFieldException() throws Exception { - expectedException.expect(BadInjectedFieldException.class); - obj1 = baseTask.getIntegerField(mockExpression, mockExecution, null); - } - - - @Test - public void testGetOptionalIntegerField() throws Exception { - objectInteger = Integer.valueOf(anyValueInt); - when(mockExpression.getValue(mockExecution)).thenReturn(objectInteger); - obj1 = baseTask.getOptionalIntegerField(mockExpression, mockExecution, anyVariable); - assertEquals(anyValueInteger, (Integer) obj1); - } - - @Test - public void testGetOptionalIntegerFieldAndBadInjectedFieldException() throws Exception { - expectedException.expect(BadInjectedFieldException.class); - objectBoolean = Boolean.valueOf(true); - when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean); - obj1 = baseTask.getOptionalIntegerField(mockExpression, mockExecution, anyVariable); - } - - @Test - public void testGetLongFieldAndMissingInjectedFieldException() throws Exception { - objectLong = Long.valueOf(anyValuelong); - when(mockExpression.getValue(mockExecution)).thenReturn(objectLong); - obj1 = baseTask.getLongField(mockExpression, mockExecution, anyVariable); - assertEquals(anyValueLong, (Long) obj1); - - expectedException.expect(MissingInjectedFieldException.class); - objectString = new String(badValueString); - when(mockExpression.getValue(mockExecution)).thenReturn(objectString); - obj2 = baseTask.getLongField(null, mockExecution, anyVariable); - } - - @Test - public void testGetLongFieldAndBadInjectedFieldException() throws Exception { - expectedException.expect(BadInjectedFieldException.class); - obj2 = baseTask.getLongField(mockExpression, mockExecution, null); - } - - @Test - public void testGetOptionalLongField() throws Exception { - objectLong = Long.valueOf(anyValuelong); - when(mockExpression.getValue(mockExecution)).thenReturn(objectLong); - obj1 = baseTask.getOptionalLongField(mockExpression, mockExecution, anyVariable); - assertEquals(anyValueLong, (Long) obj1); - } - - @Test - public void testGetOptionalLongFieldAndBadInjectedFieldException() throws Exception { - expectedException.expect(BadInjectedFieldException.class); - objectBoolean = Boolean.valueOf(true); - when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean); - obj1 = baseTask.getOptionalLongField(mockExpression, mockExecution, anyVariable); - } - - @Test - public void testGetOutputAndMissingInjectedFieldException() throws Exception { - objectString = new String(anyValueString); - when(mockExpression.getValue(mockExecution)).thenReturn(objectString); - obj1 = baseTask.getOutputField(mockExpression, mockExecution, anyVariable); - assertEquals(anyValueString, obj1.toString()); - - expectedException.expect(MissingInjectedFieldException.class); - objectString = new String(anyValueString); - when(mockExpression.getValue(mockExecution)).thenReturn(objectString); - obj2 = baseTask.getOutputField(null, mockExecution, anyVariable); - } - - @Test - public void testGetOutputAndBadInjectedFieldException() throws Exception { - expectedException.expect(BadInjectedFieldException.class); - obj2 = baseTask.getOutputField(null, mockExecution, anyVariable); - } - - @Test - public void testGetOptionalOutputField() throws Exception { - objectString = new String(anyValueString); - when(mockExpression.getValue(mockExecution)).thenReturn(objectString); - obj1 = baseTask.getOptionalOutputField(mockExpression, mockExecution, anyVariable); - assertEquals(anyValueString, obj1.toString()); - } - - @Test - public void testGetOptionalOutputFieldAndBadInjectedFieldException() throws Exception { - expectedException.expect(BadInjectedFieldException.class); - objectBoolean = Boolean.valueOf(true); - when(mockExpression.getValue(mockExecution)).thenReturn(objectBoolean); - obj1 = baseTask.getOptionalOutputField(mockExpression, mockExecution, anyVariable); - } - -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy index 30b5cc8567..b855e936d0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory * flow for SDNC Network Resource Activate */ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( ActivateSDNCNetworkResource.class); + private static final Logger logger = LoggerFactory.getLogger( ActivateSDNCNetworkResource.class) String Prefix = "ACTSDNCRES_" @@ -57,7 +57,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { MsoUtils msoUtils = new MsoUtils() - public void preProcessRequest(DelegateExecution execution) { + void preProcessRequest(DelegateExecution execution) { logger.info(" ***** Started preProcessRequest *****") try { @@ -106,7 +106,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } } - public void prepareUpdateAfterActivateSDNCResource(DelegateExecution execution) { + void prepareUpdateAfterActivateSDNCResource(DelegateExecution execution) { logger.info("started prepareUpdateAfterActivateSDNCResource ") ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(execution.getVariable(Prefix + "resourceInput"), ResourceInput.class) @@ -135,7 +135,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { <statusDescription>${msoUtils.xmlEscape(statusDescription)}</statusDescription> </ns:updateResourceOperationStatus> </soapenv:Body> - </soapenv:Envelope>"""; + </soapenv:Envelope>""" setProgressUpdateVariables(execution, body) } @@ -148,12 +148,12 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { String customizeResourceParam(String networkInputParametersJson) { List<Map<String, Object>> paramList = new ArrayList() - JSONObject jsonObject = new JSONObject(networkInputParametersJson); + JSONObject jsonObject = new JSONObject(networkInputParametersJson) Iterator iterator = jsonObject.keys() while (iterator.hasNext()) { String key = iterator.next() HashMap<String, String> hashMap = new HashMap() - hashMap.put("name", key); + hashMap.put("name", key) hashMap.put("value", jsonObject.get(key)) paramList.add(hashMap) } @@ -163,7 +163,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { return new JSONObject(paramMap).toString() } - public void prepareSDNCRequest (DelegateExecution execution) { + void prepareSDNCRequest (DelegateExecution execution) { logger.info("Started prepareSDNCRequest ") try { @@ -186,7 +186,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { String serviceModelVersion = resourceInputObj.getServiceModelInfo().getModelVersion() String serviceModelName = resourceInputObj.getServiceModelInfo().getModelName() String globalCustomerId = resourceInputObj.getGlobalSubscriberId() - String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid(); + String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid() String modelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() String modelUuid = resourceInputObj.getResourceModelInfo().getModelUuid() String modelName = resourceInputObj.getResourceModelInfo().getModelName() @@ -451,7 +451,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { logger.info(" ***** Exit prepareSDNCRequest *****") } - public void postActivateSDNCCall(DelegateExecution execution) { + void postActivateSDNCCall(DelegateExecution execution) { logger.info("started postCreateSDNCCall ") String responseCode = execution.getVariable(Prefix + "sdncCreateReturnCode") @@ -460,7 +460,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { logger.info("response from sdnc, response code :" + responseCode + " response object :" + responseObj) } - public void sendSyncResponse(DelegateExecution execution) { + void sendSyncResponse(DelegateExecution execution) { logger.info("started sendsyncResp") try { @@ -478,4 +478,4 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { } logger.info("exited send sync Resp") } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy index 608bf66da9..df11549ff4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -19,9 +19,9 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.infrastructure.scripts; +package org.onap.so.bpmn.infrastructure.scripts -import static org.apache.commons.lang3.StringUtils.*; +import static org.apache.commons.lang3.StringUtils.* import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError @@ -55,7 +55,7 @@ import groovy.json.* * @param - WorkflowException */ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( CompareModelofE2EServiceInstance.class); + private static final Logger logger = LoggerFactory.getLogger( CompareModelofE2EServiceInstance.class) String Prefix="CMPMDSI_" private static final String DebugFlag = "isDebugEnabled" @@ -64,7 +64,7 @@ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcess JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils() - public void preProcessRequest (DelegateExecution execution) { + void preProcessRequest (DelegateExecution execution) { execution.setVariable("prefix",Prefix) String msg = "" @@ -128,7 +128,7 @@ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcess execution.setVariable("operationType", "CompareModel") } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex){ msg = "Exception in preProcessRequest " + ex.getMessage() logger.info(msg) @@ -137,7 +137,7 @@ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcess logger.trace("Exit preProcessRequest ") } - public void sendSyncResponse (DelegateExecution execution) { + void sendSyncResponse (DelegateExecution execution) { logger.trace("sendSyncResponse ") try { @@ -155,7 +155,7 @@ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcess logger.trace("Exit sendSyncResopnse ") } - public void sendSyncError (DelegateExecution execution) { + void sendSyncError (DelegateExecution execution) { logger.trace("sendSyncError ") try { @@ -182,7 +182,7 @@ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcess } - public void prepareCompletionRequest (DelegateExecution execution) { + void prepareCompletionRequest (DelegateExecution execution) { logger.trace("prepareCompletion ") try { @@ -214,7 +214,7 @@ public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcess logger.trace("Exit prepareCompletionRequest ") } - public void prepareFalloutRequest(DelegateExecution execution){ + void prepareFalloutRequest(DelegateExecution execution){ logger.trace("prepareFalloutRequest ") try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy index 8bb48a203b..ced1b928fc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -72,7 +72,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso JsonUtils jsonUtil = new JsonUtils() - private static final Logger logger = LoggerFactory.getLogger( Create3rdONAPE2EServiceInstance.class); + private static final Logger logger = LoggerFactory.getLogger( Create3rdONAPE2EServiceInstance.class) public void checkSPPartnerInfo (DelegateExecution execution) { logger.info(" ***** Started checkSPPartnerInfo *****") @@ -312,7 +312,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso // Put TP Link info into serviceParameters JSONObject inputParameters = new JSONObject(execution.getVariable(Prefix + "ServiceParameters")) if(inputParameters.has("remote-access-provider-id")) { - Map<String, Object> crossTPs = new HashMap<String, Object>(); + Map<String, Object> crossTPs = new HashMap<String, Object>() crossTPs.put("local-access-provider-id", inputParameters.get("remote-access-provider-id")) crossTPs.put("local-access-client-id", inputParameters.get("remote-access-client-id")) crossTPs.put("local-access-topology-id", inputParameters.get("remote-access-topology-id")) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy index 2abee7caaa..cae629fdf0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy @@ -7,7 +7,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -39,7 +39,7 @@ import org.onap.so.client.aai.AAIObjectType import org.onap.so.client.aai.AAIResourcesClient import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory -import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.ErrorCode import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.MessageEnum import org.slf4j.Logger @@ -56,7 +56,7 @@ public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor String Prefix="CRESI_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - private static final Logger logger = LoggerFactory.getLogger( CreateCustomE2EServiceInstance.class); + private static final Logger logger = LoggerFactory.getLogger( CreateCustomE2EServiceInstance.class) public void preProcessRequest (DelegateExecution execution) { @@ -154,7 +154,7 @@ public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams")) //execution.setVariable("failExists", true) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex){ msg = "Exception in preProcessRequest " + ex.getMessage() logger.debug(msg) @@ -332,7 +332,7 @@ public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor }catch(Exception e){ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); + ErrorCode.UnknownError.getValue(), "Exception is:\n" + e) execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) } logger.trace("finished prepareInitServiceOperationStatus") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index bcd33530b1..4b3c1aa7b4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -55,7 +55,7 @@ import org.slf4j.LoggerFactory */ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( CreateSDNCNetworkResource.class); + private static final Logger logger = LoggerFactory.getLogger( CreateSDNCNetworkResource.class) String Prefix="CRESDNCRES_" ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -120,20 +120,20 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { } String customizeResourceParam(String networkInputParametersJson) { - List<Map<String, Object>> paramList = new ArrayList(); - JSONObject jsonObject = new JSONObject(networkInputParametersJson); - Iterator iterator = jsonObject.keys(); + List<Map<String, Object>> paramList = new ArrayList() + JSONObject jsonObject = new JSONObject(networkInputParametersJson) + Iterator iterator = jsonObject.keys() while (iterator.hasNext()) { - String key = iterator.next(); - HashMap<String, String> hashMap = new HashMap(); - hashMap.put("name", key); + String key = iterator.next() + HashMap<String, String> hashMap = new HashMap() + hashMap.put("name", key) hashMap.put("value", jsonObject.get(key)) paramList.add(hashMap) } - Map<String, List<Map<String, Object>>> paramMap = new HashMap(); - paramMap.put("param", paramList); + Map<String, List<Map<String, Object>>> paramMap = new HashMap() + paramMap.put("param", paramList) - return new JSONObject(paramMap).toString(); + return new JSONObject(paramMap).toString() } private List<Metadatum> getMetaDatum(String customerId, @@ -347,7 +347,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { String serviceModelVersion = resourceInputObj.getServiceModelInfo().getModelVersion() String serviceModelName = resourceInputObj.getServiceModelInfo().getModelName() String globalCustomerId = resourceInputObj.getGlobalSubscriberId() - String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid(); + String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid() String modelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() String modelUuid = resourceInputObj.getResourceModelInfo().getModelUuid() String modelName = resourceInputObj.getResourceModelInfo().getModelName() @@ -357,7 +357,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { //here convert json string to xml string String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(networkInputParametersJson))) // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sdncTopologyCreateRequest = ""; + String sdncTopologyCreateRequest = "" String modelType = resourceInputObj.getResourceModelInfo().getModelType() @@ -641,7 +641,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { <statusDescription>${msoUtils.xmlEscape(statusDescription)}</statusDescription> </ns:updateResourceOperationStatus> </soapenv:Body> - </soapenv:Envelope>"""; + </soapenv:Envelope>""" setProgressUpdateVariables(execution, body) @@ -674,7 +674,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { <statusDescription>${msoUtils.xmlEscape(statusDescription)}</statusDescription> </ns:updateResourceOperationStatus> </soapenv:Body> - </soapenv:Envelope>"""; + </soapenv:Envelope>""" setProgressUpdateVariables(execution, body) } @@ -724,7 +724,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { try { String operationStatus = "finished" // RESTResponse for main flow - String vnfid=execution.getVariable("resourceInstanceId"); + String vnfid=execution.getVariable("resourceInstanceId") String resourceOperationResp = """{"operationStatus":"${operationStatus}","vnf-id":"${vnfid}"}""".trim() logger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp) sendWorkflowResponse(execution, 202, resourceOperationResp) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy index 433a8d0bb9..901964f465 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -25,7 +25,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.client.HttpClientFactory 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.aai.entities.uri.AAIUriFactory import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -44,7 +44,7 @@ import org.onap.so.utils.TargetEntity * flow for VFC Network Service Create */ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( CreateVFCNSResource.class); + private static final Logger logger = LoggerFactory.getLogger( CreateVFCNSResource.class) ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -77,7 +77,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { String globalSubscriberId = jsonUtil.getJsonValue(resourceInput, "globalSubscriberId") logger.info("globalSubscriberId:" + globalSubscriberId) //set local globalSubscriberId variable - execution.setVariable("globalSubscriberId", globalSubscriberId); + execution.setVariable("globalSubscriberId", globalSubscriberId) String serviceType = execution.getVariable("serviceType") logger.info("serviceType:" + serviceType) @@ -110,9 +110,9 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { "operationId":"${operationId}", "nodeTemplateUUID":"${nodeTemplateUUID}" }""" - execution.setVariable("nsOperationKey", nsOperationKey); + execution.setVariable("nsOperationKey", nsOperationKey) execution.setVariable("nsParameters", nsParameters) - execution.setVariable("nsServiceModelUUID", nsServiceModelUUID); + execution.setVariable("nsServiceModelUUID", nsServiceModelUUID) String vfcAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.vfc.rest.endpoint", execution) @@ -128,7 +128,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { execution.setVariable("vfcAdapterUrl", vfcAdapterUrl) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex){ msg = "Exception in preProcessRequest " + ex.getMessage() logger.info(msg) @@ -143,9 +143,9 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { public void createNetworkService(DelegateExecution execution) { logger.trace("createNetworkService ") String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl") - String nsOperationKey = execution.getVariable("nsOperationKey"); - String nsServiceModelUUID = execution.getVariable("nsServiceModelUUID"); - String nsParameters = execution.getVariable("nsParameters"); + String nsOperationKey = execution.getVariable("nsOperationKey") + String nsServiceModelUUID = execution.getVariable("nsServiceModelUUID") + String nsParameters = execution.getVariable("nsParameters") String nsServiceName = execution.getVariable("nsServiceName") String nsServiceDescription = execution.getVariable("nsServiceDescription") String locationConstraints = jsonUtil.getJsonValue(nsParameters, "locationConstraints") @@ -163,7 +163,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { Response apiResponse = postRequest(execution, vfcAdapterUrl + "/ns", reqBody) String returnCode = apiResponse.getStatus () String aaiResponseAsString = apiResponse.readEntity(String.class) - String nsInstanceId = ""; + String nsInstanceId = "" if(returnCode== "200" || returnCode == "201"){ nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId") } @@ -177,8 +177,8 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { public void instantiateNetworkService(DelegateExecution execution) { logger.trace("instantiateNetworkService ") String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl") - String nsOperationKey = execution.getVariable("nsOperationKey"); - String nsParameters = execution.getVariable("nsParameters"); + String nsOperationKey = execution.getVariable("nsOperationKey") + String nsParameters = execution.getVariable("nsParameters") String nsServiceName = execution.getVariable("nsServiceName") String nsServiceDescription = execution.getVariable("nsServiceDescription") String reqBody ="""{ @@ -192,7 +192,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { Response apiResponse = postRequest(execution, url, reqBody) String returnCode = apiResponse.getStatus() String aaiResponseAsString = apiResponse.readEntity(String.class) - String jobId = ""; + String jobId = "" if(returnCode== "200"|| returnCode == "201"){ jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId") } @@ -207,7 +207,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { logger.trace("queryNSProgress ") String vfcAdapterUrl = execution.getVariable("vfcAdapterUrl") String jobId = execution.getVariable("jobId") - String nsOperationKey = execution.getVariable("nsOperationKey"); + String nsOperationKey = execution.getVariable("nsOperationKey") String url = vfcAdapterUrl + "/jobs/" + jobId Response apiResponse = postRequest(execution, url, nsOperationKey) String returnCode = apiResponse.getStatus() @@ -225,9 +225,9 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { */ public void timeDelay(DelegateExecution execution) { try { - Thread.sleep(5000); + Thread.sleep(5000) } catch(InterruptedException e) { - logger.error("Time Delay exception" + e.getMessage()); + logger.error("Time Delay exception" + e.getMessage()) } } @@ -252,7 +252,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { getAAIClient().connect(nsUri,relatedServiceUri) logger.info("NS relationship to Service added successfully") }catch(Exception e){ - logger.error("Exception occured while Creating NS relationship."+ e.getMessage()); + logger.error("Exception occured while Creating NS relationship."+ e.getMessage()) throw new BpmnError("MSOWorkflowException") } } @@ -268,7 +268,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { Response apiResponse = null try{ - URL url = new URL(urlString); + URL url = new URL(urlString) // Get the Basic Auth credentials for the VFCAdapter, username is 'bpel', auth is '07a7159d3bf51a0e53be7a8f89699be7' // user 'bepl' authHeader is the same with mso.db.auth @@ -282,7 +282,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor { logger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class)) }catch(Exception e){ - logger.error("VFC Aatpter Post Call Exception:" + e.getMessage()); + logger.error("VFC Aatpter Post Call Exception:" + e.getMessage()) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VFC Aatpter Post Call Exception") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy index 097a1be291..1a689d426c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory * flow for SDNC Network Resource Activate */ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( DeActivateSDNCNetworkResource.class); + private static final Logger logger = LoggerFactory.getLogger( DeActivateSDNCNetworkResource.class) String Prefix = "DEACTSDNCRES_" ExceptionUtil exceptionUtil = new ExceptionUtil() @@ -53,7 +53,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor MsoUtils msoUtils = new MsoUtils() - public void preProcessRequest(DelegateExecution execution) { + void preProcessRequest(DelegateExecution execution) { logger.info(" ***** Started preProcessRequest *****") @@ -96,7 +96,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor execution.setVariable("mso-request-id", requestId) execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId()) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex){ msg = "Exception in preProcessRequest " + ex.getMessage() logger.debug(msg) @@ -104,7 +104,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor } } - public void prepareSDNCRequest(DelegateExecution execution) { + void prepareSDNCRequest(DelegateExecution execution) { logger.info(" ***** Started prepareSDNCRequest *****") try { @@ -127,7 +127,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor String serviceModelVersion = resourceInputObj.getServiceModelInfo().getModelVersion() String serviceModelName = resourceInputObj.getServiceModelInfo().getModelName() String globalCustomerId = resourceInputObj.getGlobalSubscriberId() - String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid(); + String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid() String modelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() String modelUuid = resourceInputObj.getResourceModelInfo().getModelUuid() String modelName = resourceInputObj.getResourceModelInfo().getModelName() @@ -390,7 +390,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor logger.info(" ***** Exit prepareSDNCRequest *****") } - public void prepareUpdateAfterDeActivateSDNCResource(DelegateExecution execution) { + void prepareUpdateAfterDeActivateSDNCResource(DelegateExecution execution) { String resourceInput = execution.getVariable("resourceInput") ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) String operType = resourceInputObj.getOperationType() @@ -418,7 +418,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor <statusDescription>${msoUtils.xmlEscape(statusDescription)}</statusDescription> </ns:updateResourceOperationStatus> </soapenv:Body> - </soapenv:Envelope>"""; + </soapenv:Envelope>""" setProgressUpdateVariables(execution, body) } @@ -429,7 +429,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor execution.setVariable("CVFMI_updateResOperStatusRequest", body) } - public void postDeactivateSDNCCall(DelegateExecution execution) { + void postDeactivateSDNCCall(DelegateExecution execution) { logger.info(" ***** Started prepareSDNCRequest *****") String responseCode = execution.getVariable(Prefix + "sdncDeleteReturnCode") String responseObj = execution.getVariable(Prefix + "SuccessIndicator") @@ -438,7 +438,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor logger.info(" ***** Exit prepareSDNCRequest *****") } - public void sendSyncResponse(DelegateExecution execution) { + void sendSyncResponse(DelegateExecution execution) { logger.debug(" *** sendSyncResponse *** ") try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy index 64ae3dfbef..da486bb1c3 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -60,7 +60,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso JsonUtils jsonUtil = new JsonUtils() - private static final Logger logger = LoggerFactory.getLogger( Delete3rdONAPE2EServiceInstance.class); + private static final Logger logger = LoggerFactory.getLogger( Delete3rdONAPE2EServiceInstance.class) public void checkSPPartnerInfoFromAAI (DelegateExecution execution) { logger.info(" ***** Started checkSPPartnerInfo *****") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy index a9b1fdaac3..2a65ae97a2 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy @@ -8,7 +8,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -22,9 +22,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.infrastructure.scripts; +package org.onap.so.bpmn.infrastructure.scripts -import static org.apache.commons.lang3.StringUtils.*; +import static org.apache.commons.lang3.StringUtils.* import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError @@ -38,7 +38,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.bpmn.core.UrnPropertiesReader import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.springframework.web.util.UriUtils; +import org.springframework.web.util.UriUtils import groovy.json.* @@ -52,7 +52,7 @@ public class DeleteCustomE2EServiceInstance extends AbstractServiceTaskProcessor ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils() - private static final Logger logger = LoggerFactory.getLogger( DeleteCustomE2EServiceInstance.class); + private static final Logger logger = LoggerFactory.getLogger( DeleteCustomE2EServiceInstance.class) public void preProcessRequest (DelegateExecution execution) { execution.setVariable("prefix",Prefix) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy index 7c8b7eb7cc..61b1250522 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy @@ -67,7 +67,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { MsoUtils msoUtils = new MsoUtils() - public void preProcessRequest(DelegateExecution execution){ + void preProcessRequest(DelegateExecution execution){ logger.info(" ***** Started preProcessRequest *****") try { @@ -184,7 +184,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { * generate the nsOperationKey * generate the nsParameters */ - public void prepareSDNCRequest (DelegateExecution execution) { + void prepareSDNCRequest (DelegateExecution execution) { logger.info(" ***** Started prepareSDNCRequest *****") try { @@ -475,7 +475,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { execution.setVariable("CVFMI_updateResOperStatusRequest", body) } - public void prepareUpdateBeforeDeleteSDNCResource(DelegateExecution execution) { + void prepareUpdateBeforeDeleteSDNCResource(DelegateExecution execution) { logger.debug(" *** prepareUpdateBeforeDeleteSDNCResource *** ") String resourceInput = execution.getVariable(Prefix + "resourceInput"); ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) @@ -511,7 +511,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { } - public void prepareUpdateAfterDeleteSDNCResource(DelegateExecution execution) { + void prepareUpdateAfterDeleteSDNCResource(DelegateExecution execution) { logger.debug(" *** prepareUpdateAfterDeleteSDNCResource *** ") String resourceInput = execution.getVariable(Prefix + "resourceInput"); ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) @@ -546,7 +546,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { logger.debug(" ***** Exit prepareUpdateAfterDeleteSDNCResource *****") } - public void postDeleteSDNCCall(DelegateExecution execution){ + void postDeleteSDNCCall(DelegateExecution execution){ logger.info(" ***** Started postDeleteSDNCCall *****") String responseCode = execution.getVariable(Prefix + "sdncDeleteReturnCode") String responseObj = execution.getVariable(Prefix + "SuccessIndicator") @@ -555,7 +555,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { logger.info(" ***** Exit postDeleteSDNCCall *****") } - public void sendSyncResponse (DelegateExecution execution) { + void sendSyncResponse (DelegateExecution execution) { logger.debug( " *** sendSyncResponse *** ") try { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy index 9b269c734f..642609a970 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy @@ -63,14 +63,14 @@ public class DeleteVFCNSResource extends AbstractServiceTaskProcessor { logger.info(" ***** end preProcessRequest *****") } - public void postProcessRequest (DelegateExecution execution) { + void postProcessRequest (DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") logger.info(" ***** start postProcessRequest *****") logger.info(" ***** end postProcessRequest *****") } - public void sendSyncResponse (DelegateExecution execution) { + void sendSyncResponse (DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") logger.debug( " *** sendSyncResponse *** ") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy index fff2503308..324e6b42ba 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -19,9 +19,9 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.so.bpmn.infrastructure.scripts; +package org.onap.so.bpmn.infrastructure.scripts -import static org.apache.commons.lang3.StringUtils.*; +import static org.apache.commons.lang3.StringUtils.* import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.domain.Resource @@ -52,7 +52,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor { String Prefix="DCMPMDV_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - private static final Logger logger = LoggerFactory.getLogger( DoCompareModelVersions.class); + private static final Logger logger = LoggerFactory.getLogger( DoCompareModelVersions.class) public void preProcessRequest (DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") @@ -196,8 +196,8 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor { ServiceDecomposition serviceDecomposition_Target = execution.getVariable("serviceDecomposition_Target") ServiceDecomposition serviceDecomposition_Original = execution.getVariable("serviceDecomposition_Original") - List<Resource> allSR_target = serviceDecomposition_Target.getServiceResources(); - List<Resource> allSR_original = serviceDecomposition_Original.getServiceResources(); + List<Resource> allSR_target = serviceDecomposition_Target.getServiceResources() + List<Resource> allSR_original = serviceDecomposition_Original.getServiceResources() List<Resource> addResourceList = new ArrayList<String>() List<Resource> delResourceList = new ArrayList<String>() @@ -214,8 +214,8 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor { if(rc_o.getModelInfo().getModelUuid() == muuid && rc_o.getModelInfo().getModelInvariantUuid() == mIuuid && rc_o.getModelInfo().getModelCustomizationUuid() == mCuuid) { - addResourceList.remove(rc_t); - delResourceList.remove(rc_o); + addResourceList.remove(rc_t) + delResourceList.remove(rc_o) } } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index 0191439dac..9d8b953f0e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -7,7 +7,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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,9 +26,9 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializationFeature import org.onap.so.logger.LoggingAnchor -import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.ErrorCode -import static org.apache.commons.lang3.StringUtils.*; +import static org.apache.commons.lang3.StringUtils.* import javax.ws.rs.NotFoundException @@ -83,7 +83,7 @@ import org.onap.so.bpmn.core.UrnPropertiesReader * */ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( DoCreateE2EServiceInstance.class); + private static final Logger logger = LoggerFactory.getLogger( DoCreateE2EServiceInstance.class) String Prefix="DCRESI_" @@ -165,7 +165,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("serviceInstanceData", si) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex){ msg = "Exception in preProcessRequest " + ex.getMessage() logger.info(msg) @@ -210,7 +210,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { //we need a service plugin platform here. ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") String uuiRequest = execution.getVariable("uuiRequest") - String newUuiRequest = ServicePluginFactory.getInstance().preProcessService(serviceDecomposition, uuiRequest); + String newUuiRequest = ServicePluginFactory.getInstance().preProcessService(serviceDecomposition, uuiRequest) execution.setVariable("uuiRequest", newUuiRequest) } @@ -218,7 +218,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { //we need a service plugin platform here. ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") String uuiRequest = execution.getVariable("uuiRequest") - String newUuiRequest = ServicePluginFactory.getInstance().doServiceHoming(serviceDecomposition, uuiRequest); + String newUuiRequest = ServicePluginFactory.getInstance().doServiceHoming(serviceDecomposition, uuiRequest) execution.setVariable("uuiRequest", newUuiRequest) } @@ -254,7 +254,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { } } } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex) { msg = "Exception in DoCreateServiceInstance.postProcessAAIGET. " + ex.getMessage() logger.info(msg) @@ -276,7 +276,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { client.create(uri, si) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex) { //start rollback set up RollbackData rollbackData = new RollbackData() @@ -310,11 +310,11 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { AAIResultWrapper aaiResult = client.get(uri,NotFoundException.class) Map<String, Object> result = aaiResult.asMap() List<Object> resources = - (List<Object>) result.getOrDefault("result-data", Collections.emptyList()); + (List<Object>) result.getOrDefault("result-data", Collections.emptyList()) if(resources.size()>0) { String relationshipUrl = ((Map<String, Object>) resources.get(0)).get("resource-link") - final Relationship body = new Relationship(); + final Relationship body = new Relationship() body.setRelatedLink(relationshipUrl) createRelationShipInAAI(execution, body) @@ -329,7 +329,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex) { msg = "Exception in DoCreateE2EServiceInstance.createCustomRelationship. " + ex.getMessage() @@ -349,7 +349,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { client.create(uri, relationship) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex) { msg = "Exception in DoCreateE2EServiceInstance.createRelationShipInAAI. " + ex.getMessage() @@ -362,9 +362,9 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { private String isNeedProcessCustomRelationship(String uuiRequest) { String requestInput = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs") - Map<String, String> requestInputObject = getJsonObject(requestInput, Map.class); + Map<String, String> requestInputObject = getJsonObject(requestInput, Map.class) if (requestInputObject == null) { - return null; + return null } Optional<Map.Entry> firstKey = @@ -380,15 +380,15 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { } private static <T> T getJsonObject(String jsonstr, Class<T> type) { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + ObjectMapper mapper = new ObjectMapper() + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true) try { - return mapper.readValue(jsonstr, type); + return mapper.readValue(jsonstr, type) } catch (IOException e) { logger.error("{} {} fail to unMarshal json", MessageEnum.RA_NS_EXC.toString(), - ErrorCode.BusinessProcesssError.getValue(), e); + ErrorCode.BusinessProcesssError.getValue(), e) } - return null; + return null } @@ -409,7 +409,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("serviceInstanceName", si.get().getServiceInstanceName()) }catch(BpmnError e) { - throw e; + throw e }catch(Exception ex) { String msg = "Internal Error in getServiceInstance: " + ex.getMessage() exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) @@ -449,7 +449,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { } } } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex) { msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage() logger.info(msg) @@ -462,12 +462,12 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { logger.trace("preProcessRollback ") try { - Object workflowException = execution.getVariable("WorkflowException"); + Object workflowException = execution.getVariable("WorkflowException") if (workflowException instanceof WorkflowException) { logger.info("Prev workflowException: " + workflowException.getErrorMessage()) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); + execution.setVariable("prevWorkflowException", workflowException) + //execution.setVariable("WorkflowException", null) } } catch (BpmnError e) { logger.info("BPMN Error during preProcessRollback") @@ -482,15 +482,15 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { logger.trace("postProcessRollback ") String msg = "" try { - Object workflowException = execution.getVariable("prevWorkflowException"); + Object workflowException = execution.getVariable("prevWorkflowException") if (workflowException instanceof WorkflowException) { logger.info("Setting prevException to WorkflowException: ") - execution.setVariable("WorkflowException", workflowException); + execution.setVariable("WorkflowException", workflowException) } execution.setVariable("rollbackData", null) } catch (BpmnError b) { logger.info("BPMN Error during postProcessRollback") - throw b; + throw b } catch(Exception ex) { msg = "Exception in postProcessRollback. " + ex.getMessage() logger.info(msg) @@ -547,19 +547,19 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { }catch(Exception e){ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preInitResourcesOperStatus.", "BPMN", - ErrorCode.UnknownError.getValue(), e); + ErrorCode.UnknownError.getValue(), e) execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) } logger.trace("COMPLETED preInitResourcesOperStatus Process ") } - // if site location is in local Operator, create all resources in local ONAP; + // if site location is in local Operator, create all resources in local ONAP // if site location is in 3rd Operator, only process sp-partner to create all resources in 3rd ONAP public void doProcessSiteLocation(DelegateExecution execution){ logger.trace("======== Start doProcessSiteLocation Process ======== ") ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") String uuiRequest = execution.getVariable("uuiRequest") - uuiRequest = ServicePluginFactory.getInstance().doProcessSiteLocation(serviceDecomposition, uuiRequest); + uuiRequest = ServicePluginFactory.getInstance().doProcessSiteLocation(serviceDecomposition, uuiRequest) execution.setVariable("uuiRequest", uuiRequest) execution.setVariable("serviceDecomposition", serviceDecomposition) @@ -571,7 +571,7 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { logger.trace("======== Start doTPResourcesAllocation Process ======== ") ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") String uuiRequest = execution.getVariable("uuiRequest") - uuiRequest = ServicePluginFactory.getInstance().doTPResourcesAllocation(execution, uuiRequest); + uuiRequest = ServicePluginFactory.getInstance().doTPResourcesAllocation(execution, uuiRequest) execution.setVariable("uuiRequest", uuiRequest) logger.trace("======== COMPLETED doTPResourcesAllocation Process ======== ") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy index b1356b9fb6..bc26aa10ec 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -72,13 +72,13 @@ import java.lang.reflect.Type * @param - WorkflowException */ public class DoCreateResources extends AbstractServiceTaskProcessor{ - private static final Logger logger = LoggerFactory.getLogger( DoCreateResources.class); + private static final Logger logger = LoggerFactory.getLogger( DoCreateResources.class) ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() - public void preProcessRequest(DelegateExecution execution) { + void preProcessRequest(DelegateExecution execution) { logger.trace("preProcessRequest ") String msg = "" @@ -95,7 +95,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ logger.trace("Exit preProcessRequest ") } - public void sequenceResoure(DelegateExecution execution) { + void sequenceResoure(DelegateExecution execution) { logger.trace("Start sequenceResoure Process ") String incomingRequest = execution.getVariable("uuiRequest") @@ -170,7 +170,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ String isContainsWanResource = networkResourceList.isEmpty() ? "false" : "true" //if no networkResource, get SDNC config from properties file if( "false".equals(isContainsWanResource)) { - String serviceNeedSDNC = "mso.workflow.custom." + serviceModelName + ".sdnc.need"; + String serviceNeedSDNC = "mso.workflow.custom." + serviceModelName + ".sdnc.need" isContainsWanResource = BPMNProperties.getProperty(serviceNeedSDNC, isContainsWanResource) } @@ -181,7 +181,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ logger.trace("COMPLETED sequenceResoure Process ") } - public prepareServiceTopologyRequest(DelegateExecution execution) { + void prepareServiceTopologyRequest(DelegateExecution execution) { logger.trace("======== Start prepareServiceTopologyRequest Process ======== ") @@ -201,7 +201,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ logger.trace("======== End prepareServiceTopologyRequest Process ======== ") } - public void getCurrentResoure(DelegateExecution execution){ + void getCurrentResoure(DelegateExecution execution){ logger.trace("Start getCurrentResoure Process ") def currentIndex = execution.getVariable("currentResourceIndex") List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") @@ -211,7 +211,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ logger.trace("COMPLETED getCurrentResource Process ") } - public void parseNextResource(DelegateExecution execution){ + void parseNextResource(DelegateExecution execution){ logger.trace("Start parseNextResource Process ") def currentIndex = execution.getVariable("currentResourceIndex") def nextIndex = currentIndex + 1 @@ -225,7 +225,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ logger.trace("COMPLETED parseNextResource Process ") } - public void prepareResourceRecipeRequest(DelegateExecution execution){ + void prepareResourceRecipeRequest(DelegateExecution execution){ logger.trace("Start prepareResourceRecipeRequest Process ") ResourceInput resourceInput = new ResourceInput() String serviceInstanceName = execution.getVariable("serviceInstanceName") @@ -242,7 +242,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ resourceInput.setServiceType(serviceType) resourceInput.setServiceInstanceId(serviceInstanceId) resourceInput.setOperationId(operationId) - resourceInput.setOperationType(operationType); + resourceInput.setOperationType(operationType) def currentIndex = execution.getVariable("currentResourceIndex") List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") Resource currentResource = sequencedResourceList.get(currentIndex) @@ -284,7 +284,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ logger.trace("COMPLETED prepareResourceRecipeRequest Process ") } - public void executeResourceRecipe(DelegateExecution execution){ + void executeResourceRecipe(DelegateExecution execution){ logger.trace("Start executeResourceRecipe Process ") try { @@ -338,7 +338,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ } } - public void postConfigRequest(DelegateExecution execution){ + void postConfigRequest(DelegateExecution execution){ //now do noting ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") for (VnfResource resource : serviceDecomposition.vnfResources) { @@ -346,4 +346,4 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{ } execution.setVariable("serviceDecomposition", serviceDecomposition) } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy index bf52b11de2..64d9827c7c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy @@ -83,7 +83,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { JsonUtils jsonUtil = new JsonUtils() CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create() - public void preProcessRequest (DelegateExecution execution) { + void preProcessRequest (DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") String msg = "" logger.trace("preProcessRequest") @@ -286,7 +286,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { logger.trace("Exit preProcessRequest") } - public void getAAICustomerById (DelegateExecution execution) { + void getAAICustomerById (DelegateExecution execution) { // https://{aaiEP}/aai/v8/business/customers/customer/{globalCustomerId} try { @@ -306,7 +306,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { } - public void putServiceInstance(DelegateExecution execution) { + void putServiceInstance(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") logger.trace("putServiceInstance") String msg = "" @@ -380,7 +380,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { logger.trace("Exit putServiceInstance") } - public void preProcessSDNCAssignRequest(DelegateExecution execution) { + void preProcessSDNCAssignRequest(DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") String msg = "" logger.trace("preProcessSDNCAssignRequest") @@ -479,7 +479,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { logger.trace("Exit preProcessSDNCAssignRequest") } - public void postProcessSDNCAssign (DelegateExecution execution) { + void postProcessSDNCAssign (DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") logger.trace("postProcessSDNCAssign") try { @@ -518,7 +518,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { logger.trace("Exit postProcessSDNCAssign") } - public void postProcessAAIGET2(DelegateExecution execution) { + void postProcessAAIGET2(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") logger.trace("postProcessAAIGET2") String msg = "" @@ -561,7 +561,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { logger.trace("Exit postProcessAAIGET2") } - public void preProcessRollback (DelegateExecution execution) { + void preProcessRollback (DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") logger.trace("preProcessRollback") try { @@ -582,7 +582,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { logger.trace("Exit preProcessRollback") } - public void postProcessRollback (DelegateExecution execution) { + void postProcessRollback (DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") logger.trace("postProcessRollback") String msg = "" @@ -603,7 +603,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { logger.trace("Exit postProcessRollback") } - public void createProject(DelegateExecution execution) { + void createProject(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") logger.trace("createProject") @@ -631,7 +631,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { logger.trace("Exit createProject") } - public void createOwningEntity(DelegateExecution execution) { + void createOwningEntity(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") logger.trace("createOwningEntity") String msg = ""; @@ -679,7 +679,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { // Build Error Section // ******************************* - public void processJavaException(DelegateExecution execution){ + void processJavaException(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") try{ diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy index cf3a0ef56f..a88becad1a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy @@ -7,7 +7,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -25,7 +25,7 @@ package org.onap.so.bpmn.infrastructure.scripts import org.onap.so.logger.LoggingAnchor import org.onap.so.logger.ErrorCode -import static org.apache.commons.lang3.StringUtils.*; +import static org.apache.commons.lang3.StringUtils.* import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory @@ -33,8 +33,8 @@ import javax.xml.parsers.DocumentBuilderFactory import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONArray; -import org.json.JSONObject; +import org.json.JSONArray +import org.json.JSONObject import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.MsoUtils @@ -44,7 +44,7 @@ import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory -import org.springframework.web.util.UriUtils; +import org.springframework.web.util.UriUtils import org.w3c.dom.Document import org.w3c.dom.Element import org.w3c.dom.Node @@ -79,7 +79,7 @@ import groovy.json.* * Rollback - Deferred */ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( DoCustomDeleteE2EServiceInstance.class); + private static final Logger logger = LoggerFactory.getLogger( DoCustomDeleteE2EServiceInstance.class) String Prefix="DDELSI_" @@ -151,7 +151,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess execution.setVariable("siParamsXml", siParamsXml) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex){ msg = "Exception in preProcessRequest " + ex.getMessage() logger.info(msg) @@ -271,7 +271,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess logger.info("sdncDelete:\n" + sdncDelete) } catch (BpmnError e) { - throw e; + throw e } catch(Exception ex) { msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() logger.info(msg) @@ -302,7 +302,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg) } } catch (BpmnError e) { - throw e; + throw e } catch(Exception ex) { msg = "Exception in postProcessSDNC " + method + " Exception:" + ex.getMessage() logger.info(msg) @@ -337,8 +337,8 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess //Confirm there are no related service instances (vnf/network or volume) if (utils.nodeExists(siData, "relationship-list")) { logger.info("SI Data relationship-list exists:") - InputSource source = new InputSource(new StringReader(siData)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + InputSource source = new InputSource(new StringReader(siData)) + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance() DocumentBuilder docBuilder = docFactory.newDocumentBuilder() Document serviceXml = docBuilder.parse(source) serviceXml.getDocumentElement().normalize() @@ -433,7 +433,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess logger.info("Service-instance NOT found in AAI. Silent Success") } }catch (BpmnError e) { - throw e; + throw e } catch (Exception ex) { msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage() logger.info(msg) @@ -452,7 +452,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess String serviceType = execution.getVariable("serviceType") String serviceInstanceId = execution.getVariable("serviceInstanceId") - AAIResourcesClient resourceClient = new AAIResourcesClient(); + AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) resourceClient.delete(serviceInstanceUri) @@ -535,7 +535,7 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess }catch(Exception e){ logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "Exception Occured Processing preInitResourcesOperStatus.", "BPMN", - ErrorCode.UnknownError.getValue(), e); + ErrorCode.UnknownError.getValue(), e) execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) } logger.trace("COMPLETED preInitResourcesOperStatus Process ") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy index 481a79a7ef..34ea20ba62 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy @@ -6,7 +6,7 @@ * ================================================================================ * Modifications Copyright (c) 2019 Samsung * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -90,7 +90,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { String Prefix="DDEESI_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() - private static final Logger logger = LoggerFactory.getLogger( DoDeleteE2EServiceInstance.class); + private static final Logger logger = LoggerFactory.getLogger( DoDeleteE2EServiceInstance.class) public void preProcessRequest (DelegateExecution execution) { @@ -158,7 +158,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("siParamsXml", siParamsXml) } catch (BpmnError e) { - throw e; + throw e } catch (Exception ex){ msg = "Exception in preProcessRequest " + ex.getMessage() logger.error(msg) @@ -243,7 +243,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { // for sp-partner and others else if (eKey.endsWith("-id")) { jObj.put("resourceInstanceId", eValue) - String resourceName = rt + eValue; + String resourceName = rt + eValue jObj.put("resourceType", resourceName) } jObj.put("resourceLinkUrl", rl) @@ -520,12 +520,12 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { if (StringUtils.containsIgnoreCase(obj.get("resourceType"), modelName)) { resource.setResourceId(obj.get("resourceInstanceId")) //deleteRealResourceList.add(resource) - matches = true; + matches = true } else if (modelCustomizationUuid.equals(obj.get("modelCustomizationId")) || modelUuid.equals(obj.get("model-version-id")) ) { resource.setResourceId(obj.get("resourceInstanceId")) resource.setResourceInstanceName(obj.get("resourceType")) //deleteRealResourceList.add(resource) - matches = true; + matches = true } return matches } @@ -646,7 +646,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { String serviceType = execution.getVariable("serviceType") String serviceInstanceId = execution.getVariable("serviceInstanceId") - AAIResourcesClient resourceClient = new AAIResourcesClient(); + AAIResourcesClient resourceClient = new AAIResourcesClient() AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustId, serviceType, serviceInstanceId) resourceClient.delete(serviceInstanceUri) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy index cbeb1d3d69..97eb3b3960 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2017 - 2019 Huawei Intellectual Property. All rights reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * @@ -34,7 +34,7 @@ import org.slf4j.Logger import org.slf4j.LoggerFactory public class HandlePNF extends AbstractServiceTaskProcessor{ - private static final Logger logger = LoggerFactory.getLogger( HandlePNF.class); + private static final Logger logger = LoggerFactory.getLogger( HandlePNF.class) ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() @@ -95,7 +95,7 @@ public class HandlePNF extends AbstractServiceTaskProcessor{ <statusDescription>${msoUtils.xmlEscape(statusDescription)}</statusDescription> </ns:updateResourceOperationStatus> </soapenv:Body> - </soapenv:Envelope>"""; + </soapenv:Envelope>""" logger.debug("body: "+body) setProgressUpdateVariables(execution, body) logger.debug("exit postProcess for HandlePNF") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java index 357b571a5c..48061db887 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java @@ -90,7 +90,7 @@ public class PnfEventReadyDmaapClient implements DmaapClient { @Override public synchronized Runnable unregister(String pnfCorrelationId) { logger.debug("unregistering from pnf ready dmaap event for pnf correlation id: {}", pnfCorrelationId); - Runnable runnable = runnable = pnfCorrelationIdToThreadMap.remove(pnfCorrelationId); + Runnable runnable = pnfCorrelationIdToThreadMap.remove(pnfCorrelationId); synchronized (updateInfoMap) { for (int i = updateInfoMap.size() - 1; i >= 0; i--) { if (!updateInfoMap.get(i).containsKey("pnfCorrelationId")) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java index f7708b69d3..f933277f3c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java @@ -27,6 +27,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.so.logger.LoggingAnchor; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.methods.CloseableHttpResponse; @@ -41,7 +42,6 @@ import org.json.JSONObject; import org.onap.msb.sdk.discovery.common.RouteException; import org.onap.msb.sdk.httpclient.RestServiceCreater; import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; -import org.onap.so.bpmn.core.BaseTask; import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi; import org.onap.so.db.request.beans.ResourceOperationStatus; @@ -56,7 +56,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -public abstract class AbstractSdncOperationTask extends BaseTask { +public abstract class AbstractSdncOperationTask implements JavaDelegate { private static final Logger logger = LoggerFactory.getLogger(AbstractSdncOperationTask.class); @@ -284,7 +284,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { logger.info("exception: AbstractSdncOperationTask.updateProgress fail!"); logger.error("exception: AbstractSdncOperationTask.updateProgress fail:", exception); logger.error(LoggingAnchor.FIVE, MessageEnum.GENERAL_EXCEPTION.toString(), - " updateProgress catch exception: ", this.getTaskName(), ErrorCode.UnknownError.getValue(), + " updateProgress catch exception: ", ErrorCode.UnknownError.getValue(), exception.getClass().toString()); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java index 5b7f3bb432..16bd194f99 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/SdncUnderlayVpnPreprocessTask.java @@ -22,12 +22,12 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask; import org.apache.commons.lang3.StringUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.so.bpmn.core.BaseTask; +import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.so.db.request.beans.ResourceOperationStatus; import org.springframework.stereotype.Component; @Component -public class SdncUnderlayVpnPreprocessTask extends BaseTask { +public class SdncUnderlayVpnPreprocessTask implements JavaDelegate { public static final String RESOURCE_OPER_TYPE = "resourceOperType"; @Override diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index a436f7b5c2..9340609ffc 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -59,9 +59,18 @@ public class ExecuteActivity implements JavaDelegate { private static final String VNF_ID = "vnfId"; private static final String SERVICE_INSTANCE_ID = "serviceInstanceId"; private static final String WORKFLOW_SYNC_ACK_SENT = "workflowSyncAckSent"; + private static final String BUILDING_BLOCK = "buildingBlock"; + private static final String EXECUTE_BUILDING_BLOCK = "ExecuteBuildingBlock"; + private static final String RETRY_COUNT = "retryCount"; + private static final String A_LA_CARTE = "aLaCarte"; + private static final String SUPPRESS_ROLLBACK = "suppressRollback"; + private static final String WORKFLOW_EXCEPTION = "WorkflowException"; + private static final String HANDLING_CODE = "handlingCode"; + private static final String ABORT_HANDLING_CODE = "Abort"; private static final String SERVICE_TASK_IMPLEMENTATION_ATTRIBUTE = "implementation"; private static final String ACTIVITY_PREFIX = "activity:"; + private static final String EXECUTE_ACTIVITY_ERROR_MESSAGE = "ExecuteActivityErrorMessage"; private ObjectMapper mapper = new ObjectMapper(); @@ -75,7 +84,8 @@ public class ExecuteActivity implements JavaDelegate { @Override public void execute(DelegateExecution execution) throws Exception { final String requestId = (String) execution.getVariable(G_REQUEST_ID); - + WorkflowException workflowException = null; + String handlingCode = null; try { Boolean workflowSyncAckSent = (Boolean) execution.getVariable(WORKFLOW_SYNC_ACK_SENT); if (workflowSyncAckSent == null || workflowSyncAckSent == false) { @@ -95,31 +105,44 @@ public class ExecuteActivity implements JavaDelegate { ExecuteBuildingBlock executeBuildingBlock = buildExecuteBuildingBlock(execution, requestId, buildingBlock); Map<String, Object> variables = new HashMap<>(); - variables.put("buildingBlock", executeBuildingBlock); - variables.put(G_REQUEST_ID, requestId); - variables.put("retryCount", 1); - variables.put("aLaCarte", true); - variables.put("suppressRollback", true); - execution.getVariables().forEach((key, value) -> { - if (value instanceof Serializable) { - variables.put(key, (Serializable) value); - } - }); + if (execution.getVariables() != null) { + execution.getVariables().forEach((key, value) -> { + if (value instanceof Serializable) { + variables.put(key, (Serializable) value); + } + }); + } + + variables.put(BUILDING_BLOCK, executeBuildingBlock); + variables.put(G_REQUEST_ID, requestId); + variables.put(RETRY_COUNT, 1); + variables.put(A_LA_CARTE, true); + variables.put(SUPPRESS_ROLLBACK, true); ProcessInstanceWithVariables buildingBlockResult = - runtimeService.createProcessInstanceByKey("ExecuteBuildingBlock").setVariables(variables) + runtimeService.createProcessInstanceByKey(EXECUTE_BUILDING_BLOCK).setVariables(variables) .executeWithVariablesInReturn(); VariableMap variableMap = buildingBlockResult.getVariables(); - WorkflowException workflowException = (WorkflowException) variableMap.get("WorklfowException"); + workflowException = (WorkflowException) variableMap.get(WORKFLOW_EXCEPTION); if (workflowException != null) { logger.error("Workflow exception is: {}", workflowException.getErrorMessage()); } - execution.setVariable("WorkflowException", workflowException); + + handlingCode = (String) variableMap.get(HANDLING_CODE); + logger.debug("Handling code: " + handlingCode); + + execution.setVariable(WORKFLOW_EXCEPTION, workflowException); } catch (Exception e) { buildAndThrowException(execution, e.getMessage()); } + + if (workflowException != null && handlingCode != null && handlingCode.equals(ABORT_HANDLING_CODE)) { + logger.debug("Aborting execution of the custom workflow"); + buildAndThrowException(execution, workflowException.getErrorMessage()); + } + } protected BuildingBlock buildBuildingBlock(String activityName) { @@ -161,7 +184,7 @@ public class ExecuteActivity implements JavaDelegate { protected void buildAndThrowException(DelegateExecution execution, String msg) { logger.error(msg); - execution.setVariable("ExecuteActuvityErrorMessage", msg); + execution.setVariable(EXECUTE_ACTIVITY_ERROR_MESSAGE, msg); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java index 7466df53b2..c9a937b824 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/UnassignNetworkBB.java @@ -30,8 +30,6 @@ import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAINetworkResources; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -61,10 +59,10 @@ public class UnassignNetworkBB { * @param execution - BuildingBlockExecution * @param relatedToValue - String, ex: vf-module * @return void - nothing - * @throws Exception + * */ - public void checkRelationshipRelatedTo(BuildingBlockExecution execution, String relatedToValue) throws Exception { + public void checkRelationshipRelatedTo(BuildingBlockExecution execution, String relatedToValue) { try { L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); @@ -85,10 +83,10 @@ public class UnassignNetworkBB { * * @param execution - BuildingBlockExecution * @return void - nothing - * @throws Exception + * */ - public void getCloudSdncRegion(BuildingBlockExecution execution) throws Exception { + public void getCloudSdncRegion(BuildingBlockExecution execution) { try { String cloudRegionSdnc = networkBBUtils.getCloudRegion(execution, SourceSystem.SDNC); execution.setVariable("cloudRegionSdnc", cloudRegionSdnc); @@ -107,7 +105,7 @@ public class UnassignNetworkBB { String msg; boolean isRollbackNeeded = execution.getVariable("isRollbackNeeded") != null ? execution.getVariable("isRollbackNeeded") : false; - if (isRollbackNeeded == true) { + if (isRollbackNeeded) { msg = execution.getVariable("ErrorUnassignNetworkBB") + messageErrorRollback; } else { msg = execution.getVariable("ErrorUnassignNetworkBB"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index f23e5cdb5a..5c69987a54 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -33,6 +33,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; import javax.annotation.PostConstruct; import org.apache.commons.lang3.StringUtils; @@ -210,23 +211,25 @@ public class VnfAdapterVfModuleObjectMapper { protected void buildDirectivesParamFromMap(Map<String, Object> paramsMap, String directive, Map<String, Object> srcMap) throws MissingValueTagException { StringBuilder directives = new StringBuilder(); - int no_directives_size = 0; + int noOfDirectivesSize = 0; if (directive.equals(MsoMulticloudUtils.USER_DIRECTIVES) && srcMap.containsKey(MsoMulticloudUtils.OOF_DIRECTIVES)) { - no_directives_size = 1; + noOfDirectivesSize = 1; } - if (srcMap.size() > no_directives_size) { + if (srcMap.size() > noOfDirectivesSize) { directives.append("{ \"attributes\": [ "); int i = 0; - for (String attributeName : srcMap.keySet()) { + for (Map.Entry<String, Object> attributeEntry : srcMap.entrySet()) { + String attributeName = attributeEntry.getKey(); + Object attributeValue = attributeEntry.getValue(); if (!(MsoMulticloudUtils.USER_DIRECTIVES.equals(directive) && attributeName.equals(MsoMulticloudUtils.OOF_DIRECTIVES))) { - if (srcMap.get(attributeName) == null) { + if (attributeValue == null) { logger.error("No value tag found for attribute: {}", attributeName); throw new MissingValueTagException("No value tag found for " + attributeName); } - directives.append(new AttributeNameValue(attributeName, srcMap.get(attributeName).toString())); - if (i < (srcMap.size() - 1 + no_directives_size)) + directives.append(new AttributeNameValue(attributeName, attributeValue.toString())); + if (i < (srcMap.size() - 1 + noOfDirectivesSize)) directives.append(", "); i++; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java index 21c0b971b8..d07574a1ad 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sniro/SniroClient.java @@ -57,10 +57,10 @@ public class SniroClient { * * @param homingRequest * @return - * @throws JsonProcessingException + * @throws BadResponseException * @throws BpmnError */ - public void postDemands(SniroManagerRequest homingRequest) throws BadResponseException, JsonProcessingException { + public void postDemands(SniroManagerRequest homingRequest) throws BadResponseException { logger.trace("Started Sniro Client Post Demands"); String url = managerProperties.getHost() + managerProperties.getUri().get("v2"); logger.debug("Post demands url: {}", url); |