diff options
author | lukegleeson <luke.gleeson@est.tech> | 2021-09-02 15:11:34 +0100 |
---|---|---|
committer | lukegleeson <luke.gleeson@est.tech> | 2021-09-06 09:37:47 +0100 |
commit | c27465347d10b573e7a211c0b11b7c8a6fd792c0 (patch) | |
tree | 60bbb8a54fcc9cc256f43437ed283cdbecade364 | |
parent | 1ce718a31547f9345286154170f230b9e89e5ee3 (diff) |
Fix Sonar Qube Violations
Issue-ID: CPS-475
Signed-off-by: lukegleeson <luke.gleeson@est.tech>
Change-Id: Iffd7b24cf42db73a8b93c4d1f2860e41a82e565d
-rwxr-xr-x | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java | 7 | ||||
-rw-r--r-- | cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java | 6 |
2 files changed, 6 insertions, 7 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index dfe5603431..c840c0a7d4 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -225,11 +225,10 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private DataNode fetchDataNodeFromDmiRegistryForCmHandle(final String cmHandle) { final String xpathForDmiRegistryToFetchCmHandle = "/dmi-registry/cm-handles[@id='" + cmHandle + "']"; - final var dataNode = cpsDataService.getDataNode(NCMP_DATASPACE_NAME, + return cpsDataService.getDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, xpathForDmiRegistryToFetchCmHandle, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS); - return dataNode; } private String prepareOperationBody(final GenericRequestBody requestBodyObject) { @@ -243,7 +242,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService } private Map<String, String> getCmHandlePropertiesAsMap(final Collection<DataNode> cmHandlePropertiesList) { - if (cmHandlePropertiesList == null || cmHandlePropertiesList.size() == 0) { + if (cmHandlePropertiesList == null || cmHandlePropertiesList.isEmpty()) { return null; } final Map<String, String> cmHandlePropertiesMap = new LinkedHashMap<>(); @@ -329,7 +328,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService persistenceCmHandle.setDmiServiceName(dmiPluginService); persistenceCmHandle.setId(cmHandle.getCmHandleID()); if (cmHandle.getCmHandleProperties() == null) { - persistenceCmHandle.setAdditionalProperties(Collections.EMPTY_MAP); + persistenceCmHandle.setAdditionalProperties(Collections.emptyMap()); } else { persistenceCmHandle.setAdditionalProperties(cmHandle.getCmHandleProperties()); } diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java index 7b3b726284..c57723d322 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java @@ -91,7 +91,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService private static final Gson GSON = new GsonBuilder().create(); private static final String REG_EX_FOR_OPTIONAL_LIST_INDEX = "(\\[@[\\s\\S]+?]){0,1})"; - private static final String REG_EX_FOR_LIST_NODE_KEY = "\\[(\\@([^/]*?))+( and)*\\]$"; + private static final String REG_EX_FOR_LIST_NODE_KEY = "\\[(\\@([^/]*?)){0,99}( and)*\\]$"; @Override public void addChildDataNode(final String dataspaceName, final String anchorName, final String parentXpath, @@ -344,10 +344,10 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService final Matcher descendantNodeHasListNodeKey = Pattern.compile(REG_EX_FOR_LIST_NODE_KEY).matcher(descendantNode); final boolean xpathPointsToAValidChildNodeWithKey = parentEntity.getChildFragments().stream().anyMatch( - (fragment) -> fragment.getXpath().equals(listNodeXpath)); + fragment -> fragment.getXpath().equals(listNodeXpath)); final boolean xpathPointsToAValidChildNodeWithoutKey = parentEntity.getChildFragments().stream().anyMatch( - (fragment) -> fragment.getXpath().replaceAll(REG_EX_FOR_LIST_NODE_KEY, "").equals(listNodeXpath)); + fragment -> fragment.getXpath().replaceAll(REG_EX_FOR_LIST_NODE_KEY, "").equals(listNodeXpath)); if ((descendantNodeHasListNodeKey.find() && xpathPointsToAValidChildNodeWithKey) || |