From 5c14b4b3167e13579fa20bd6632c82d0dd7d0844 Mon Sep 17 00:00:00 2001 From: sourabh_sourabh Date: Wed, 19 Jun 2024 14:35:30 +0100 Subject: Addressed an adaptability issue - Defined a constant instead of duplicating literal "No data nodes 4 times. Issue-ID: CPS-478 Change-Id: I2b980a228217e85424342d4c2b9e97c5cfa618d1 Signed-off-by: sourabh_sourabh --- .../main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cps-service/src/main/java') diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java index 6386d38ff..5a4842877 100644 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java @@ -65,6 +65,7 @@ public class CpsDataServiceImpl implements CpsDataService { private static final String ROOT_NODE_XPATH = "/"; private static final long DEFAULT_LOCK_TIMEOUT_IN_MILLISECONDS = 300L; + private static final String NO_DATA_NODES = "No data nodes."; private final CpsDataPersistenceService cpsDataPersistenceService; private final CpsDataUpdateEventsService cpsDataUpdateEventsService; @@ -425,7 +426,7 @@ public class CpsDataServiceImpl implements CpsDataService { .withContainerNode(containerNode) .buildCollection(); if (dataNodes.isEmpty()) { - throw new DataValidationException("No data nodes.", "No data nodes provided"); + throw new DataValidationException(NO_DATA_NODES, "No data nodes provided"); } return dataNodes; } @@ -437,7 +438,7 @@ public class CpsDataServiceImpl implements CpsDataService { .withContainerNode(containerNode) .buildCollection(); if (dataNodes.isEmpty()) { - throw new DataValidationException("No data nodes.", "No data nodes provided"); + throw new DataValidationException(NO_DATA_NODES, "No data nodes provided"); } return dataNodes; } @@ -453,8 +454,7 @@ public class CpsDataServiceImpl implements CpsDataService { .withContainerNode(containerNode) .buildCollection(); if (dataNodes.isEmpty()) { - throw new DataValidationException("No data nodes.", - "Data nodes were not found under the xpath " + xpath); + throw new DataValidationException(NO_DATA_NODES, "Data nodes were not found under the xpath " + xpath); } return dataNodes; } @@ -466,7 +466,7 @@ public class CpsDataServiceImpl implements CpsDataService { .withContainerNode(containerNode) .buildCollection(); if (dataNodes.isEmpty()) { - throw new DataValidationException("No data nodes.", "Data nodes were not found under the xpath " + xpath); + throw new DataValidationException(NO_DATA_NODES, "Data nodes were not found under the xpath " + xpath); } return dataNodes; } -- cgit 1.2.3-korg