diff options
author | Toine Siebelink <toine.siebelink@est.tech> | 2022-06-09 13:05:54 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-06-09 13:05:54 +0000 |
commit | 96f59e3fd14cdd81e58537b647aa3dd001e3c4cc (patch) | |
tree | 15c59cc65c2298aae40a892ff8f29771f7a82ce6 | |
parent | 3d579b83363af5de0745aed9bcda9611305dffb5 (diff) | |
parent | 421f824800e51ddd4f70758f5be386e50bf8ea1e (diff) |
Merge "Fix sonar code smells"
-rw-r--r-- | cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutor.java | 6 | ||||
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java | 9 |
2 files changed, 6 insertions, 9 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutor.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutor.java index 93aa2858ca..5adbb252a0 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutor.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutor.java @@ -40,11 +40,7 @@ public class CpsNcmpTaskExecutor { public void executeTask(final Supplier<Object> taskSupplier, final int timeOutInMillis) { CompletableFuture.supplyAsync(taskSupplier::get) .orTimeout(timeOutInMillis, MILLISECONDS) - .whenCompleteAsync( - (responseAsJson, throwable) -> { - handleTaskCompletion(throwable); - } - ); + .whenCompleteAsync((responseAsJson, throwable) -> handleTaskCompletion(throwable)); } private void handleTaskCompletion(final Throwable throwable) { diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java index 9f021e818b..2fc2dc5c1a 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/InventoryPersistence.java @@ -41,6 +41,8 @@ public class InventoryPersistence { private static final String NCMP_DMI_REGISTRY_ANCHOR = "ncmp-dmi-registry"; + private static final String XPATH_TO_CM_HANDLE = "/dmi-registry/cm-handles[@id='" + "%s" + "']"; + private final JsonObjectMapper jsonObjectMapper; private final CpsDataService cpsDataService; @@ -57,7 +59,7 @@ public class InventoryPersistence { */ public CompositeState getCmHandleState(final String cmHandleId) { final DataNode stateAsDataNode = cpsDataService.getDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, - "/dmi-registry/cm-handles[@id='" + cmHandleId + "']/state", + String.format(XPATH_TO_CM_HANDLE, cmHandleId) + "/state", FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS); return compositeStateBuilder.fromDataNode(stateAsDataNode).build(); } @@ -72,7 +74,7 @@ public class InventoryPersistence { final String cmHandleJsonData = String.format("{\"state\":%s}", jsonObjectMapper.asJsonString(compositeState)); cpsDataService.replaceNodeTree(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, - "/dmi-registry/cm-handles[@id='" + cmHandleId + "']", + String.format(XPATH_TO_CM_HANDLE, cmHandleId), cmHandleJsonData, OffsetDateTime.now()); } @@ -100,10 +102,9 @@ public class InventoryPersistence { } private DataNode getCmHandleDataNode(final String cmHandle) { - final String xpathForDmiRegistryToFetchCmHandle = "/dmi-registry/cm-handles[@id='" + cmHandle + "']"; return cpsDataService.getDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, - xpathForDmiRegistryToFetchCmHandle, + String.format(XPATH_TO_CM_HANDLE, cmHandle), FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS); } |