summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java2
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java2
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java5
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java3
-rwxr-xr-xcps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java2
-rw-r--r--cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java15
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java17
-rw-r--r--[-rwxr-xr-x]cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java34
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java18
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java12
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java13
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java5
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java6
-rw-r--r--cps-service/src/main/java/org/onap/cps/utils/YangUtils.java16
-rw-r--r--cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java7
15 files changed, 73 insertions, 84 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index 0c877f8ab7..83b47e8ce9 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -59,7 +59,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
@Valid final Boolean includeDescendants) {
final FetchDescendantsOption fetchDescendantsOption = Boolean.TRUE.equals(includeDescendants)
? FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS : FetchDescendantsOption.OMIT_DESCENDANTS;
- final DataNode dataNode = networkCmProxyDataService.getDataNode(cmHandle, xpath, fetchDescendantsOption);
+ final var dataNode = networkCmProxyDataService.getDataNode(cmHandle, xpath, fetchDescendantsOption);
return new ResponseEntity<>(DataMapUtils.toDataMap(dataNode), HttpStatus.OK);
}
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java
index bb922e781b..c91b821d66 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java
@@ -61,7 +61,7 @@ public class NetworkCmProxyRestExceptionHandler {
if (exception.getCause() != null || !(exception instanceof CpsException)) {
log.error("Exception occurred", exception);
}
- final ErrorMessage errorMessage = new ErrorMessage();
+ final var errorMessage = new ErrorMessage();
errorMessage.setStatus(status.toString());
errorMessage.setMessage(exception.getMessage());
errorMessage.setDetails(exception instanceof CpsException ? ((CpsException) exception).getDetails() :
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
index ead365af06..74b1a418d1 100755
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/AdminRestController.java
@@ -30,7 +30,6 @@ import org.onap.cps.api.CpsAdminService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.rest.api.CpsAdminApi;
import org.onap.cps.spi.model.Anchor;
-import org.onap.cps.spi.model.SchemaSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -71,7 +70,7 @@ public class AdminRestController implements CpsAdminApi {
@Override
public ResponseEntity<Object> getSchemaSet(final String dataspaceName, final String schemaSetName) {
- final SchemaSet schemaSet = cpsModuleService.getSchemaSet(dataspaceName, schemaSetName);
+ final var schemaSet = cpsModuleService.getSchemaSet(dataspaceName, schemaSetName);
return new ResponseEntity<>(schemaSet, HttpStatus.OK);
}
@@ -104,7 +103,7 @@ public class AdminRestController implements CpsAdminApi {
@Override
public ResponseEntity<Object> getAnchor(final String dataspaceName, final String anchorName) {
- final Anchor anchor = cpsAdminService.getAnchor(dataspaceName, anchorName);
+ final var anchor = cpsAdminService.getAnchor(dataspaceName, anchorName);
return new ResponseEntity<>(anchor, HttpStatus.OK);
}
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
index ddd3ac48ec..c8b7412593 100755
--- a/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/DataRestController.java
@@ -24,7 +24,6 @@ package org.onap.cps.rest.controller;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.rest.api.CpsDataApi;
import org.onap.cps.spi.FetchDescendantsOption;
-import org.onap.cps.spi.model.DataNode;
import org.onap.cps.utils.DataMapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -62,7 +61,7 @@ public class DataRestController implements CpsDataApi {
final String xpath, final Boolean includeDescendants) {
final FetchDescendantsOption fetchDescendantsOption = Boolean.TRUE.equals(includeDescendants)
? FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS : FetchDescendantsOption.OMIT_DESCENDANTS;
- final DataNode dataNode = cpsDataService.getDataNode(dataspaceName, anchorName, xpath,
+ final var dataNode = cpsDataService.getDataNode(dataspaceName, anchorName, xpath,
fetchDescendantsOption);
return new ResponseEntity<>(DataMapUtils.toDataMap(dataNode), HttpStatus.OK);
}
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java b/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java
index 0437e70fe5..2a89ef2230 100755
--- a/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java
@@ -83,7 +83,7 @@ public class CpsRestExceptionHandler {
if (exception.getCause() != null || !(exception instanceof CpsException)) {
log.error("Exception occurred", exception);
}
- final ErrorMessage errorMessage = new ErrorMessage();
+ final var errorMessage = new ErrorMessage();
errorMessage.setStatus(status.toString());
errorMessage.setMessage(exception.getMessage());
errorMessage.setDetails(exception instanceof CpsException ? ((CpsException) exception).getDetails() :
diff --git a/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java b/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java
index e3b0b2835c..d5c2b092b0 100644
--- a/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java
+++ b/cps-rest/src/main/java/org/onap/cps/rest/utils/MultipartFileUtil.java
@@ -25,7 +25,6 @@ import static org.opendaylight.yangtools.yang.common.YangConstants.RFC6020_YANG_
import com.google.common.collect.ImmutableMap;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Locale;
@@ -58,7 +57,7 @@ public class MultipartFileUtil {
public static Map<String, String> extractYangResourcesMap(final MultipartFile multipartFile) {
final String originalFileName = multipartFile.getOriginalFilename();
if (resourceNameEndsWithExtension(originalFileName, YANG_FILE_EXTENSION)) {
- return ImmutableMap.of(originalFileName, extractYangResourceContent(multipartFile));
+ return Map.of(originalFileName, extractYangResourceContent(multipartFile));
}
if (resourceNameEndsWithExtension(originalFileName, ZIP_FILE_EXTENSION)) {
return extractYangResourcesMapFromZipArchive(multipartFile);
@@ -70,10 +69,10 @@ public class MultipartFileUtil {
private static Map<String, String> extractYangResourcesMapFromZipArchive(final MultipartFile multipartFile) {
final ImmutableMap.Builder<String, String> yangResourceMapBuilder = ImmutableMap.builder();
- final ZipFileSizeValidator zipFileSizeValidator = new ZipFileSizeValidator();
+ final var zipFileSizeValidator = new ZipFileSizeValidator();
try (
- final InputStream inputStream = multipartFile.getInputStream();
- final ZipInputStream zipInputStream = new ZipInputStream(inputStream);
+ final var inputStream = multipartFile.getInputStream();
+ final var zipInputStream = new ZipInputStream(inputStream);
) {
ZipEntry zipEntry;
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
@@ -129,10 +128,10 @@ public class MultipartFileUtil {
private static String extractYangResourceContent(final ZipInputStream zipInputStream,
final ZipFileSizeValidator zipFileSizeValidator) throws IOException {
- try (final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
- int totalSizeEntry = 0;
+ try (final var byteArrayOutputStream = new ByteArrayOutputStream()) {
+ var totalSizeEntry = 0;
int numberOfBytesRead;
- final byte[] buffer = new byte[READ_BUFFER_SIZE];
+ final var buffer = new byte[READ_BUFFER_SIZE];
zipFileSizeValidator.incrementTotalEntryInArchive();
while ((numberOfBytesRead = zipInputStream.read(buffer, 0, READ_BUFFER_SIZE)) > 0) {
byteArrayOutputStream.write(buffer, 0, numberOfBytesRead);
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java
index edc56e4229..64c6ff507e 100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java
@@ -22,14 +22,13 @@
package org.onap.cps.spi.impl;
-import com.google.common.collect.ImmutableSet;
import java.util.Collection;
+import java.util.Set;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
import org.onap.cps.spi.CpsAdminPersistenceService;
import org.onap.cps.spi.entities.AnchorEntity;
import org.onap.cps.spi.entities.DataspaceEntity;
-import org.onap.cps.spi.entities.SchemaSetEntity;
import org.onap.cps.spi.exceptions.AlreadyDefinedException;
import org.onap.cps.spi.model.Anchor;
import org.onap.cps.spi.repository.AnchorRepository;
@@ -66,10 +65,10 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic
@Override
public void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) {
- final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
- final SchemaSetEntity schemaSetEntity =
+ final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final var schemaSetEntity =
schemaSetRepository.getByDataspaceAndName(dataspaceEntity, schemaSetName);
- final AnchorEntity anchorEntity = AnchorEntity.builder()
+ final var anchorEntity = AnchorEntity.builder()
.name(anchorName)
.dataspace(dataspaceEntity)
.schemaSet(schemaSetEntity)
@@ -83,7 +82,7 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic
@Override
public Collection<Anchor> getAnchors(final String dataspaceName) {
- final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
final Collection<AnchorEntity> anchorEntities = anchorRepository.findAllByDataspace(dataspaceEntity);
return anchorEntities.stream().map(CpsAdminPersistenceServiceImpl::toAnchor).collect(Collectors.toList());
}
@@ -96,13 +95,13 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic
@Transactional
@Override
public void deleteAnchor(final String dataspaceName, final String anchorName) {
- final AnchorEntity anchorEntity = getAnchorEntity(dataspaceName, anchorName);
- fragmentRepository.deleteByAnchorIn(ImmutableSet.of(anchorEntity));
+ final var anchorEntity = getAnchorEntity(dataspaceName, anchorName);
+ fragmentRepository.deleteByAnchorIn(Set.of(anchorEntity));
anchorRepository.delete(anchorEntity);
}
private AnchorEntity getAnchorEntity(final String dataspaceName, final String anchorName) {
- final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
return anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName);
}
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 a02b193d9e..48f1de710d 100755..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
@@ -67,7 +67,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
public void addChildDataNode(final String dataspaceName, final String anchorName, final String parentXpath,
final DataNode dataNode) {
final FragmentEntity parentFragment = getFragmentByXpath(dataspaceName, anchorName, parentXpath);
- final FragmentEntity fragmentEntity =
+ final var fragmentEntity =
toFragmentEntity(parentFragment.getDataspace(), parentFragment.getAnchor(), dataNode);
parentFragment.getChildFragments().add(fragmentEntity);
fragmentRepository.save(parentFragment);
@@ -75,9 +75,9 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
@Override
public void storeDataNode(final String dataspaceName, final String anchorName, final DataNode dataNode) {
- final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
- final AnchorEntity anchorEntity = anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName);
- final FragmentEntity fragmentEntity = convertToFragmentWithAllDescendants(dataspaceEntity, anchorEntity,
+ final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final var anchorEntity = anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName);
+ final var fragmentEntity = convertToFragmentWithAllDescendants(dataspaceEntity, anchorEntity,
dataNode);
try {
fragmentRepository.save(fragmentEntity);
@@ -97,7 +97,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
*/
private static FragmentEntity convertToFragmentWithAllDescendants(final DataspaceEntity dataspaceEntity,
final AnchorEntity anchorEntity, final DataNode dataNodeToBeConverted) {
- final FragmentEntity parentFragment = toFragmentEntity(dataspaceEntity, anchorEntity, dataNodeToBeConverted);
+ final var parentFragment = toFragmentEntity(dataspaceEntity, anchorEntity, dataNodeToBeConverted);
final Builder<FragmentEntity> childFragmentsImmutableSetBuilder = ImmutableSet.builder();
for (final DataNode childDataNode : dataNodeToBeConverted.getChildDataNodes()) {
final FragmentEntity childFragment =
@@ -122,14 +122,14 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
@Override
public DataNode getDataNode(final String dataspaceName, final String anchorName, final String xpath,
final FetchDescendantsOption fetchDescendantsOption) {
- final FragmentEntity fragmentEntity = getFragmentByXpath(dataspaceName, anchorName, xpath);
+ final var fragmentEntity = getFragmentByXpath(dataspaceName, anchorName, xpath);
return toDataNode(fragmentEntity, fetchDescendantsOption);
}
private FragmentEntity getFragmentByXpath(final String dataspaceName, final String anchorName,
final String xpath) {
- final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
- final AnchorEntity anchorEntity = anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName);
+ final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final var anchorEntity = anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName);
if (isRootXpath(xpath)) {
return fragmentRepository.getFirstByDataspaceAndAnchor(dataspaceEntity, anchorEntity);
} else {
@@ -141,19 +141,19 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
@Override
public List<DataNode> queryDataNodes(final String dataspaceName, final String anchorName, final String cpsPath,
final FetchDescendantsOption fetchDescendantsOption) {
- final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
- final AnchorEntity anchorEntity = anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName);
- final CpsPathQuery cpsPathQuery = CpsPathQuery.createFrom(cpsPath);
+ final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final var anchorEntity = anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName);
+ final var cpsPathQuery = CpsPathQuery.createFrom(cpsPath);
final List<FragmentEntity> fragmentEntities;
if (CpsPathQueryType.XPATH_LEAF_VALUE.equals(cpsPathQuery.getCpsPathQueryType())) {
fragmentEntities = fragmentRepository
- .getByAnchorAndXpathAndLeafAttributes(anchorEntity.getId(), cpsPathQuery.getXpathPrefix(), cpsPathQuery
- .getLeafName(), cpsPathQuery.getLeafValue());
+ .getByAnchorAndXpathAndLeafAttributes(anchorEntity.getId(), cpsPathQuery.getXpathPrefix(),
+ cpsPathQuery.getLeafName(), cpsPathQuery.getLeafValue());
} else if (CpsPathQueryType.XPATH_HAS_DESCENDANT_WITH_LEAF_VALUES.equals(cpsPathQuery.getCpsPathQueryType())) {
final String leafDataAsJson = GSON.toJson(cpsPathQuery.getLeavesData());
fragmentEntities = fragmentRepository
- .getByAnchorAndDescendentNameAndLeafValues(anchorEntity.getId(),
- cpsPathQuery.getDescendantName(), leafDataAsJson);
+ .getByAnchorAndDescendentNameAndLeafValues(anchorEntity.getId(), cpsPathQuery.getDescendantName(),
+ leafDataAsJson);
} else {
fragmentEntities = fragmentRepository
.getByAnchorAndXpathEndsInDescendantName(anchorEntity.getId(), cpsPathQuery.getDescendantName());
@@ -186,14 +186,14 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
@Override
public void updateDataLeaves(final String dataspaceName, final String anchorName, final String xpath,
final Map<String, Object> leaves) {
- final FragmentEntity fragmentEntity = getFragmentByXpath(dataspaceName, anchorName, xpath);
+ final var fragmentEntity = getFragmentByXpath(dataspaceName, anchorName, xpath);
fragmentEntity.setAttributes(GSON.toJson(leaves));
fragmentRepository.save(fragmentEntity);
}
@Override
public void replaceDataNodeTree(final String dataspaceName, final String anchorName, final DataNode dataNode) {
- final FragmentEntity fragmentEntity = getFragmentByXpath(dataspaceName, anchorName, dataNode.getXpath());
+ final var fragmentEntity = getFragmentByXpath(dataspaceName, anchorName, dataNode.getXpath());
removeExistingDescendants(fragmentEntity);
fragmentEntity.setAttributes(GSON.toJson(dataNode.getLeaves()));
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
index 9d3298e35e..ae6543dabe 100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
@@ -33,12 +33,10 @@ import org.onap.cps.spi.CascadeDeleteAllowed;
import org.onap.cps.spi.CpsAdminPersistenceService;
import org.onap.cps.spi.CpsModulePersistenceService;
import org.onap.cps.spi.entities.AnchorEntity;
-import org.onap.cps.spi.entities.DataspaceEntity;
import org.onap.cps.spi.entities.SchemaSetEntity;
import org.onap.cps.spi.entities.YangResourceEntity;
import org.onap.cps.spi.exceptions.AlreadyDefinedException;
import org.onap.cps.spi.exceptions.SchemaSetInUseException;
-import org.onap.cps.spi.model.Anchor;
import org.onap.cps.spi.repository.AnchorRepository;
import org.onap.cps.spi.repository.DataspaceRepository;
import org.onap.cps.spi.repository.FragmentRepository;
@@ -75,9 +73,9 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
public void storeSchemaSet(final String dataspaceName, final String schemaSetName,
final Map<String, String> yangResourcesNameToContentMap) {
- final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
final Set<YangResourceEntity> yangResourceEntities = synchronizeYangResources(yangResourcesNameToContentMap);
- final SchemaSetEntity schemaSetEntity = new SchemaSetEntity();
+ final var schemaSetEntity = new SchemaSetEntity();
schemaSetEntity.setName(schemaSetName);
schemaSetEntity.setDataspace(dataspaceEntity);
schemaSetEntity.setYangResources(yangResourceEntities);
@@ -92,7 +90,7 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
final Map<String, YangResourceEntity> checksumToEntityMap = yangResourcesNameToContentMap.entrySet().stream()
.map(entry -> {
final String checksum = DigestUtils.sha256Hex(entry.getValue().getBytes(StandardCharsets.UTF_8));
- final YangResourceEntity yangResourceEntity = new YangResourceEntity();
+ final var yangResourceEntity = new YangResourceEntity();
yangResourceEntity.setName(entry.getKey());
yangResourceEntity.setContent(entry.getValue());
yangResourceEntity.setChecksum(checksum);
@@ -120,8 +118,8 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
@Override
public Map<String, String> getYangSchemaResources(final String dataspaceName, final String schemaSetName) {
- final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
- final SchemaSetEntity schemaSetEntity =
+ final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final var schemaSetEntity =
schemaSetRepository.getByDataspaceAndName(dataspaceEntity, schemaSetName);
return schemaSetEntity.getYangResources().stream().collect(
Collectors.toMap(YangResourceEntity::getName, YangResourceEntity::getContent));
@@ -129,7 +127,7 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
@Override
public Map<String, String> getYangSchemaSetResources(final String dataspaceName, final String anchorName) {
- final Anchor anchor = cpsAdminPersistenceService.getAnchor(dataspaceName, anchorName);
+ final var anchor = cpsAdminPersistenceService.getAnchor(dataspaceName, anchorName);
return getYangSchemaResources(dataspaceName, anchor.getSchemaSetName());
}
@@ -137,8 +135,8 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
@Transactional
public void deleteSchemaSet(final String dataspaceName, final String schemaSetName,
final CascadeDeleteAllowed cascadeDeleteAllowed) {
- final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
- final SchemaSetEntity schemaSetEntity =
+ final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final var schemaSetEntity =
schemaSetRepository.getByDataspaceAndName(dataspaceEntity, schemaSetName);
final Collection<AnchorEntity> anchorEntities = anchorRepository.findAllBySchemaSet(schemaSetEntity);
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java b/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java
index ac7e7e0ac3..6f53e0013d 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/query/CpsPathQuery.java
@@ -71,8 +71,8 @@ public class CpsPathQuery {
* @return a CpsPath object.
*/
public static CpsPathQuery createFrom(final String cpsPath) {
- Matcher matcher = QUERY_CPS_PATH_WITH_SINGLE_LEAF_PATTERN.matcher(cpsPath);
- final CpsPathQuery cpsPathQuery = new CpsPathQuery();
+ var matcher = QUERY_CPS_PATH_WITH_SINGLE_LEAF_PATTERN.matcher(cpsPath);
+ final var cpsPathQuery = new CpsPathQuery();
if (matcher.matches()) {
return buildCpsPathQueryWithSingleLeafPattern(cpsPath, matcher, cpsPathQuery);
}
@@ -105,7 +105,7 @@ public class CpsPathQuery {
cpsPathQuery.setDescendantName(matcher.group(1));
final Map<String, Object> leafData = new HashMap<>();
for (final String leafValuePair : matcher.group(2).split(INDIVIDUAL_LEAF_DETAIL_PATTERN)) {
- final Matcher descendentMatcher = LEAF_VALUE_PATTERN.matcher(leafValuePair);
+ final var descendentMatcher = LEAF_VALUE_PATTERN.matcher(leafValuePair);
if (descendentMatcher.matches()) {
leafData.put(descendentMatcher.group(1),
convertLeafValueToCorrectType(descendentMatcher.group(2), cpsPath));
@@ -119,17 +119,17 @@ public class CpsPathQuery {
}
private static Object convertLeafValueToCorrectType(final String leafValueString, final String cpsPath) {
- final Matcher stringValueWithSingleQuotesMatcher =
+ final var stringValueWithSingleQuotesMatcher =
LEAF_STRING_VALUE_IN_SINGLE_QUOTES_PATTERN.matcher(leafValueString);
if (stringValueWithSingleQuotesMatcher.matches()) {
return stringValueWithSingleQuotesMatcher.group(1);
}
- final Matcher stringValueWithDoubleQuotesMatcher =
+ final var stringValueWithDoubleQuotesMatcher =
LEAF_STRING_VALUE_IN_DOUBLE_QUOTES_PATTERN.matcher(leafValueString);
if (stringValueWithDoubleQuotesMatcher.matches()) {
return stringValueWithDoubleQuotesMatcher.group(1);
}
- final Matcher integerValueMatcher = LEAF_INTEGER_VALUE_PATTERN.matcher(leafValueString);
+ final var integerValueMatcher = LEAF_INTEGER_VALUE_PATTERN.matcher(leafValueString);
if (integerValueMatcher.matches()) {
return Integer.valueOf(leafValueString);
}
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 cc290bf29d..fd0f76b536 100755
--- 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
@@ -26,7 +26,6 @@ import org.onap.cps.api.CpsDataService;
import org.onap.cps.api.CpsModuleService;
import org.onap.cps.spi.CpsDataPersistenceService;
import org.onap.cps.spi.FetchDescendantsOption;
-import org.onap.cps.spi.model.Anchor;
import org.onap.cps.spi.model.DataNode;
import org.onap.cps.spi.model.DataNodeBuilder;
import org.onap.cps.utils.YangUtils;
@@ -54,14 +53,14 @@ public class CpsDataServiceImpl implements CpsDataService {
@Override
public void saveData(final String dataspaceName, final String anchorName, final String jsonData) {
- final DataNode dataNode = buildDataNodeFromJson(dataspaceName, anchorName, ROOT_NODE_XPATH, jsonData);
+ final var dataNode = buildDataNodeFromJson(dataspaceName, anchorName, ROOT_NODE_XPATH, jsonData);
cpsDataPersistenceService.storeDataNode(dataspaceName, anchorName, dataNode);
}
@Override
public void saveData(final String dataspaceName, final String anchorName, final String parentNodeXpath,
final String jsonData) {
- final DataNode dataNode = buildDataNodeFromJson(dataspaceName, anchorName, parentNodeXpath, jsonData);
+ final var dataNode = buildDataNodeFromJson(dataspaceName, anchorName, parentNodeXpath, jsonData);
cpsDataPersistenceService.addChildDataNode(dataspaceName, anchorName, parentNodeXpath, dataNode);
}
@@ -74,7 +73,7 @@ public class CpsDataServiceImpl implements CpsDataService {
@Override
public void updateNodeLeaves(final String dataspaceName, final String anchorName, final String parentNodeXpath,
final String jsonData) {
- final DataNode dataNode = buildDataNodeFromJson(dataspaceName, anchorName, parentNodeXpath, jsonData);
+ final var dataNode = buildDataNodeFromJson(dataspaceName, anchorName, parentNodeXpath, jsonData);
cpsDataPersistenceService
.updateDataLeaves(dataspaceName, anchorName, dataNode.getXpath(), dataNode.getLeaves());
}
@@ -82,15 +81,15 @@ public class CpsDataServiceImpl implements CpsDataService {
@Override
public void replaceNodeTree(final String dataspaceName, final String anchorName, final String parentNodeXpath,
final String jsonData) {
- final DataNode dataNode = buildDataNodeFromJson(dataspaceName, anchorName, parentNodeXpath, jsonData);
+ final var dataNode = buildDataNodeFromJson(dataspaceName, anchorName, parentNodeXpath, jsonData);
cpsDataPersistenceService.replaceDataNodeTree(dataspaceName, anchorName, dataNode);
}
private DataNode buildDataNodeFromJson(final String dataspaceName, final String anchorName,
final String parentNodeXpath, final String jsonData) {
- final Anchor anchor = cpsAdminService.getAnchor(dataspaceName, anchorName);
- final SchemaContext schemaContext = getSchemaContext(dataspaceName, anchor.getSchemaSetName());
+ final var anchor = cpsAdminService.getAnchor(dataspaceName, anchorName);
+ final var schemaContext = getSchemaContext(dataspaceName, anchor.getSchemaSetName());
if (ROOT_NODE_XPATH.equals(parentNodeXpath)) {
final NormalizedNode<?, ?> normalizedNode = YangUtils.parseJsonData(jsonData, schemaContext);
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
index 990b7bb931..0b20c8a2bb 100644
--- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java
@@ -24,7 +24,6 @@ import org.onap.cps.api.CpsModuleService;
import org.onap.cps.spi.CascadeDeleteAllowed;
import org.onap.cps.spi.CpsModulePersistenceService;
import org.onap.cps.spi.model.SchemaSet;
-import org.onap.cps.yang.YangTextSchemaSourceSet;
import org.onap.cps.yang.YangTextSchemaSourceSetBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -41,7 +40,7 @@ public class CpsModuleServiceImpl implements CpsModuleService {
@Override
public void createSchemaSet(final String dataspaceName, final String schemaSetName,
final Map<String, String> yangResourcesNameToContentMap) {
- final YangTextSchemaSourceSet yangTextSchemaSourceSet
+ final var yangTextSchemaSourceSet
= YangTextSchemaSourceSetBuilder.of(yangResourcesNameToContentMap);
cpsModulePersistenceService.storeSchemaSet(dataspaceName, schemaSetName, yangResourcesNameToContentMap);
yangTextSchemaSourceSetCache.updateCache(dataspaceName, schemaSetName, yangTextSchemaSourceSet);
@@ -49,7 +48,7 @@ public class CpsModuleServiceImpl implements CpsModuleService {
@Override
public SchemaSet getSchemaSet(final String dataspaceName, final String schemaSetName) {
- final YangTextSchemaSourceSet yangTextSchemaSourceSet = yangTextSchemaSourceSetCache
+ final var yangTextSchemaSourceSet = yangTextSchemaSourceSetCache
.get(dataspaceName, schemaSetName);
return SchemaSet.builder().name(schemaSetName).dataspaceName(dataspaceName)
.moduleReferences(yangTextSchemaSourceSet.getModuleReferences()).build();
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java b/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java
index cf79ad7e0b..253d4c6242 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java
@@ -120,7 +120,7 @@ public class DataNodeBuilder {
}
private DataNode buildFromAttributes() {
- final DataNode dataNode = new DataNode();
+ final var dataNode = new DataNode();
dataNode.setXpath(xpath);
dataNode.setLeaves(leaves);
dataNode.setChildDataNodes(childDataNodes);
@@ -128,7 +128,7 @@ public class DataNodeBuilder {
}
private DataNode buildFromNormalizedNodeTree() {
- final DataNode parentDataNode = new DataNodeBuilder().withXpath(parentNodeXpath).build();
+ final var parentDataNode = new DataNodeBuilder().withXpath(parentNodeXpath).build();
addDataNodeFromNormalizedNode(parentDataNode, normalizedNodeTree);
return parentDataNode.getChildDataNodes().iterator().next();
}
@@ -187,7 +187,7 @@ public class DataNodeBuilder {
private static DataNode createAndAddChildDataNode(final DataNode parentDataNode, final String childXpath) {
- final DataNode newChildDataNode = new DataNodeBuilder()
+ final var newChildDataNode = new DataNodeBuilder()
.withXpath(parentDataNode.getXpath() + childXpath)
.build();
final Set<DataNode> allChildDataNodes = new ImmutableSet.Builder<DataNode>()
diff --git a/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java b/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java
index edef5cbca5..0b66d37fba 100644
--- a/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java
+++ b/cps-service/src/main/java/org/onap/cps/utils/YangUtils.java
@@ -37,8 +37,6 @@ import lombok.extern.slf4j.Slf4j;
import org.onap.cps.spi.exceptions.DataValidationException;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
import org.opendaylight.yangtools.yang.data.codec.gson.JsonParserStream;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
@@ -77,23 +75,23 @@ public class YangUtils {
@SuppressWarnings("squid:S1452") // Generic type <? ,?> is returned by external librray, opendaylight.yangtools
public static NormalizedNode<?, ?> parseJsonData(final String jsonData, final SchemaContext schemaContext,
final String parentNodeXpath) {
- final DataSchemaNode parentSchemaNode = getDataSchemaNodeByXpath(parentNodeXpath, schemaContext);
+ final var parentSchemaNode = getDataSchemaNodeByXpath(parentNodeXpath, schemaContext);
return parseJsonData(jsonData, schemaContext, Optional.of(parentSchemaNode));
}
private static NormalizedNode<?, ?> parseJsonData(final String jsonData, final SchemaContext schemaContext,
final Optional<DataSchemaNode> optionalParentSchemaNode) {
- final JSONCodecFactory jsonCodecFactory = JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02
+ final var jsonCodecFactory = JSONCodecFactorySupplier.DRAFT_LHOTKA_NETMOD_YANG_JSON_02
.getShared(schemaContext);
- final NormalizedNodeResult normalizedNodeResult = new NormalizedNodeResult();
- final NormalizedNodeStreamWriter normalizedNodeStreamWriter = ImmutableNormalizedNodeStreamWriter
+ final var normalizedNodeResult = new NormalizedNodeResult();
+ final var normalizedNodeStreamWriter = ImmutableNormalizedNodeStreamWriter
.from(normalizedNodeResult);
try (final JsonParserStream jsonParserStream = optionalParentSchemaNode.isPresent()
? JsonParserStream.create(normalizedNodeStreamWriter, jsonCodecFactory, optionalParentSchemaNode.get())
: JsonParserStream.create(normalizedNodeStreamWriter, jsonCodecFactory)
) {
- final JsonReader jsonReader = new JsonReader(new StringReader(jsonData));
+ final var jsonReader = new JsonReader(new StringReader(jsonData));
jsonParserStream.parse(jsonReader);
} catch (final IOException | IllegalStateException | JsonSyntaxException exception) {
@@ -110,7 +108,7 @@ public class YangUtils {
* @return an xpath
*/
public static String buildXpath(final YangInstanceIdentifier.PathArgument nodeIdentifier) {
- final StringBuilder xpathBuilder = new StringBuilder();
+ final var xpathBuilder = new StringBuilder();
xpathBuilder.append("/").append(nodeIdentifier.getNodeType().getLocalName());
if (nodeIdentifier instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) {
@@ -173,7 +171,7 @@ public class YangUtils {
}
private static String[] getNextLevelXpathNodeIdSequence(final String[] xpathNodeIdSequence) {
- final String[] nextXpathNodeIdSequence = new String[xpathNodeIdSequence.length - 1];
+ final var nextXpathNodeIdSequence = new String[xpathNodeIdSequence.length - 1];
System.arraycopy(xpathNodeIdSequence, 1, nextXpathNodeIdSequence, 0, nextXpathNodeIdSequence.length);
return nextXpathNodeIdSequence;
}
diff --git a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
index 712d9a0e27..0e8d939ee1 100644
--- a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
+++ b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java
@@ -30,7 +30,6 @@ import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import lombok.NoArgsConstructor;
@@ -62,7 +61,7 @@ public final class YangTextSchemaSourceSetBuilder {
}
public YangTextSchemaSourceSet build() {
- final SchemaContext schemaContext = generateSchemaContext(yangModelMap.build());
+ final var schemaContext = generateSchemaContext(yangModelMap.build());
return new YangTextSchemaSourceSetImpl(schemaContext);
}
@@ -148,7 +147,7 @@ public final class YangTextSchemaSourceSetBuilder {
}
private static YangTextSchemaSource toYangTextSchemaSource(final String sourceName, final String source) {
- final RevisionSourceIdentifier revisionSourceIdentifier =
+ final var revisionSourceIdentifier =
createIdentifierFromSourceName(checkNotNull(sourceName));
return new YangTextSchemaSource(revisionSourceIdentifier) {
@@ -166,7 +165,7 @@ public final class YangTextSchemaSourceSetBuilder {
}
private static RevisionSourceIdentifier createIdentifierFromSourceName(final String sourceName) {
- final Matcher matcher = RFC6020_RECOMMENDED_FILENAME_PATTERN.matcher(sourceName);
+ final var matcher = RFC6020_RECOMMENDED_FILENAME_PATTERN.matcher(sourceName);
if (matcher.matches()) {
return RevisionSourceIdentifier.create(matcher.group(1), Revision.of(matcher.group(2)));
}