From f4fe4ec7c29443d1b63e51ac101773844e146ac9 Mon Sep 17 00:00:00 2001 From: h00397475 Date: Tue, 23 Apr 2019 18:09:17 +0530 Subject: Define constant in place of literals Constants are declared and used in place of literals Issue-ID: SO-1490 Change-Id: I674b250fa3e141deea5c4b6c43d6fa94733f0b67 Signed-off-by: h00397475 --- .../flowspecific/tasks/AssignNetworkBBUtils.java | 6 +++--- .../flowspecific/tasks/ConfigDeployVnf.java | 6 +++--- .../flowspecific/tasks/ConfigurationScaleOut.java | 2 +- .../flowspecific/tasks/CreateNetwork.java | 2 +- .../flowspecific/tasks/CreateNetworkCollection.java | 2 +- .../flowspecific/tasks/GenericVnfHealthCheck.java | 19 +++++++++++-------- .../flowspecific/tasks/UnassignNetworkBB.java | 9 ++++----- 7 files changed, 24 insertions(+), 22 deletions(-) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java index ab8818f682..4b88f741de 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkBBUtils.java @@ -54,9 +54,9 @@ public class AssignNetworkBBUtils { * @return */ public boolean networkFoundByName(BuildingBlockExecution execution) throws Exception { - boolean found = false; + // TODO - populate logic after iTrack MSO-2143 implemented - return found; + return false; } /** @@ -71,7 +71,7 @@ public class AssignNetworkBBUtils { CloudRegion cloudRegion = gBBInput.getCloudRegion(); String cloudRegionSdnc; String cloudRegionPo = cloudRegion.getLcpCloudRegionId(); - if (cloudRegion.getCloudRegionVersion().equalsIgnoreCase("2.5")) { + if ("2.5".equalsIgnoreCase(cloudRegion.getCloudRegionVersion())) { cloudRegionSdnc = "AAIAIC25"; } else { cloudRegionSdnc = cloudRegionPo; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java index 359f19285f..4ec8b932c0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigDeployVnf.java @@ -40,9 +40,9 @@ import org.springframework.stereotype.Component; @Component public class ConfigDeployVnf { private static final Logger logger = LoggerFactory.getLogger(ConfigDeployVnf.class); - private final static String ORIGINATOR_ID = "SO"; - private final static String ACTION_NAME = "config-deploy"; - private final static String MODE = "async"; + private static final String ORIGINATOR_ID = "SO"; + private static final String ACTION_NAME = "config-deploy"; + private static final String MODE = "async"; @Autowired private ExceptionBuilder exceptionUtil; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java index 1925d8b69f..0ad88d0676 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java @@ -160,7 +160,7 @@ public class ConfigurationScaleOut { logger.error("Error Message: " + appcMessage); logger.error("ERROR CODE: " + appcCode); logger.trace("End of runAppCommand "); - if (appcCode != null && !appcCode.equals("0")) { + if (appcCode != null && !("0").equals(appcCode)) { exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java index c2d9c6e7bb..b7ddc11f35 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetwork.java @@ -39,7 +39,7 @@ import org.springframework.stereotype.Component; @Component public class CreateNetwork { - private static final Logger logger = LoggerFactory.getLogger(CreateNetwork.class); + @Autowired private ExceptionBuilder exceptionUtil; @Autowired diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java index 4eaec381e9..36eab8f981 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java @@ -36,7 +36,7 @@ import org.springframework.stereotype.Component; @Component public class CreateNetworkCollection { - private static final Logger logger = LoggerFactory.getLogger(CreateNetworkCollection.class); + @Autowired private ExceptionBuilder exceptionUtil; @Autowired diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java index 98b602eca1..8f0c809e1f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java @@ -45,6 +45,9 @@ import org.springframework.stereotype.Component; public class GenericVnfHealthCheck { private static final Logger logger = LoggerFactory.getLogger(GenericVnfHealthCheck.class); + public static final String VNF_NAME = "vnfName"; + public static final String OAM_IP_ADDRESS = "oamIpAddress"; + public static final String VNF_HOST_IP_ADDRESS = "vnfHostIpAddress"; @Autowired private ExceptionBuilder exceptionUtil; @Autowired @@ -71,9 +74,9 @@ public class GenericVnfHealthCheck { String controllerName = controllerSelectionReference.getControllerName(); execution.setVariable("vnfId", vnfId); - execution.setVariable("vnfName", vnfName); - execution.setVariable("oamIpAddress", oamIpAddress); - execution.setVariable("vnfHostIpAddress", oamIpAddress); + execution.setVariable(VNF_NAME, vnfName); + execution.setVariable(OAM_IP_ADDRESS, oamIpAddress); + execution.setVariable(VNF_HOST_IP_ADDRESS, oamIpAddress); execution.setVariable("msoRequestId", gBBInput.getRequestContext().getMsoRequestId()); execution.setVariable("action", actionCategory); execution.setVariable("controllerType", controllerName); @@ -98,11 +101,11 @@ public class GenericVnfHealthCheck { payload = Optional.of(pay); } String controllerType = execution.getVariable("controllerType"); - HashMap payloadInfo = new HashMap(); - payloadInfo.put("vnfName", execution.getVariable("vnfName")); + HashMap payloadInfo = new HashMap<>(); + payloadInfo.put(VNF_NAME, execution.getVariable(VNF_NAME)); payloadInfo.put("vfModuleId", execution.getVariable("vfModuleId")); - payloadInfo.put("oamIpAddress", execution.getVariable("oamIpAddress")); - payloadInfo.put("vnfHostIpAddress", execution.getVariable("vnfHostIpAddress")); + payloadInfo.put(OAM_IP_ADDRESS, execution.getVariable(OAM_IP_ADDRESS)); + payloadInfo.put(VNF_HOST_IP_ADDRESS, execution.getVariable(VNF_HOST_IP_ADDRESS)); logger.debug("Running APP-C action: {}", action.toString()); logger.debug("VNFID: {}", vnfId); @@ -133,7 +136,7 @@ public class GenericVnfHealthCheck { logger.error("Error Message: " + appcMessage); logger.error("ERROR CODE: " + appcCode); logger.trace("End of runAppCommand "); - if (appcCode != null && !appcCode.equals("0")) { + if (appcCode != null && !("0").equals(appcCode)) { exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } } 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 27415190cc..7466df53b2 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 @@ -38,11 +38,10 @@ import org.springframework.stereotype.Component; @Component public class UnassignNetworkBB { - private static final Logger logger = LoggerFactory.getLogger(UnassignNetworkBB.class); - private static String MESSAGE_CANNOT_PERFORM_UNASSIGN = + private static String messageCannotPerformUnassign = "Cannot perform Unassign Network. Network is still related to "; - private static String MESSAGE_ERROR_ROLLBACK = " Rollback is not possible. Please restore data manually."; + private static String messageErrorRollback = " Rollback is not possible. Please restore data manually."; @Autowired private ExceptionBuilder exceptionUtil; @@ -72,7 +71,7 @@ public class UnassignNetworkBB { Optional network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class); if (networkBBUtils.isRelationshipRelatedToExists(network, relatedToValue)) { - String msg = MESSAGE_CANNOT_PERFORM_UNASSIGN + relatedToValue; + String msg = messageCannotPerformUnassign + relatedToValue; execution.setVariable("ErrorUnassignNetworkBB", msg); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } @@ -109,7 +108,7 @@ public class UnassignNetworkBB { boolean isRollbackNeeded = execution.getVariable("isRollbackNeeded") != null ? execution.getVariable("isRollbackNeeded") : false; if (isRollbackNeeded == true) { - msg = execution.getVariable("ErrorUnassignNetworkBB") + MESSAGE_ERROR_ROLLBACK; + msg = execution.getVariable("ErrorUnassignNetworkBB") + messageErrorRollback; } else { msg = execution.getVariable("ErrorUnassignNetworkBB"); } -- cgit 1.2.3-korg