aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service/src/main
diff options
context:
space:
mode:
authorToineSiebelink <toine.siebelink@est.tech>2025-02-11 18:44:48 +0000
committerToineSiebelink <toine.siebelink@est.tech>2025-02-12 15:50:35 +0000
commit61e1c70ebefc59356e8b6bf862ea2ba0b8e4efd9 (patch)
tree0e91ffce9d5c1fd80cfecda4e0d765936b46c46d /cps-service/src/main
parentee4e49556be15ef5f881403f1cd70fab8daa68f4 (diff)
Store yang resources with recommended RFC-6020 file-name
- Ignore input filename and create filename from module name and revision - added integration test to verify names and edge cases (before and after change) - Some code cleanup (vars etc) - Implemented NB comments from last merge(https://gerrit.onap.org/r/c/cps/+/140180) - fixed SQ warning Out of scope: - BLANK revision, test it but failed in ODL Yang Parser and many other places: not supported! Issue-ID: CPS-138 Change-Id: I6fe6d0f8f3683196b183c6e6582ad8eefdfbb7d7 Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
Diffstat (limited to 'cps-service/src/main')
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsQueryService.java4
-rw-r--r--cps-service/src/main/java/org/onap/cps/impl/CpsQueryServiceImpl.java6
-rw-r--r--cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java14
3 files changed, 11 insertions, 13 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsQueryService.java b/cps-service/src/main/java/org/onap/cps/api/CpsQueryService.java
index 3044fe0a90..30c8bbbdf3 100644
--- a/cps-service/src/main/java/org/onap/cps/api/CpsQueryService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsQueryService.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2024 Nordix Foundation
+ * Copyright (C) 2020-2025 Nordix Foundation
* Modifications Copyright (C) 2022-2023 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -32,7 +32,7 @@ import org.onap.cps.api.parameters.PaginationOption;
*/
public interface CpsQueryService {
- public static int NO_LIMIT = 0;
+ int NO_LIMIT = 0;
/**
* Get data nodes for the given dataspace and anchor by cps path.
diff --git a/cps-service/src/main/java/org/onap/cps/impl/CpsQueryServiceImpl.java b/cps-service/src/main/java/org/onap/cps/impl/CpsQueryServiceImpl.java
index f27445f7c9..a3884820c7 100644
--- a/cps-service/src/main/java/org/onap/cps/impl/CpsQueryServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/impl/CpsQueryServiceImpl.java
@@ -52,12 +52,12 @@ public class CpsQueryServiceImpl implements CpsQueryService {
@Override
@Timed(value = "cps.data.service.datanode.query",
description = "Time taken to query data nodes with a limit on results")
- public Collection<DataNode> queryDataNodes(final String dataSpaceName, final String anchorName,
+ public Collection<DataNode> queryDataNodes(final String dataspaceName, final String anchorName,
final String cpsPath,
final FetchDescendantsOption fetchDescendantsOption,
final int queryResultLimit) {
- cpsValidator.validateNameCharacters(dataSpaceName, anchorName);
- return cpsDataPersistenceService.queryDataNodes(dataSpaceName,
+ cpsValidator.validateNameCharacters(dataspaceName, anchorName);
+ return cpsDataPersistenceService.queryDataNodes(dataspaceName,
anchorName,
cpsPath,
fetchDescendantsOption,
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 ab7a095572..04b491692a 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
@@ -33,6 +33,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import lombok.NoArgsConstructor;
@@ -77,7 +78,7 @@ public final class YangTextSchemaSourceSetBuilder {
* @return the YangTextSchemaSourceSet
*/
public YangTextSchemaSourceSet build() {
- final var schemaContext = generateSchemaContext(yangModelMap.build());
+ final SchemaContext schemaContext = generateSchemaContext(yangModelMap.build());
return new YangTextSchemaSourceSetImpl(schemaContext);
}
@@ -113,9 +114,7 @@ public final class YangTextSchemaSourceSetBuilder {
@Override
public List<ModuleReference> getModuleReferences() {
- return schemaContext.getModules().stream()
- .map(YangTextSchemaSourceSetImpl::toModuleReference)
- .collect(Collectors.toList());
+ return schemaContext.getModules().stream().map(YangTextSchemaSourceSetImpl::toModuleReference).toList();
}
private static ModuleReference toModuleReference(final Module module) {
@@ -164,12 +163,11 @@ public final class YangTextSchemaSourceSetBuilder {
private static List<YangTextSchemaSource> forResources(final Map<String, String> yangResourceNameToContent) {
return yangResourceNameToContent.entrySet().stream()
- .map(entry -> toYangTextSchemaSource(entry.getKey(), entry.getValue()))
- .collect(Collectors.toList());
+ .map(entry -> toYangTextSchemaSource(entry.getKey(), entry.getValue())).toList();
}
private static YangTextSchemaSource toYangTextSchemaSource(final String sourceName, final String source) {
- final var revisionSourceIdentifier =
+ final RevisionSourceIdentifier revisionSourceIdentifier =
createIdentifierFromSourceName(checkNotNull(sourceName));
return new YangTextSchemaSource(revisionSourceIdentifier) {
@@ -192,7 +190,7 @@ public final class YangTextSchemaSourceSetBuilder {
}
private static RevisionSourceIdentifier createIdentifierFromSourceName(final String sourceName) {
- final var matcher = RFC6020_RECOMMENDED_FILENAME_PATTERN.matcher(sourceName);
+ final Matcher matcher = RFC6020_RECOMMENDED_FILENAME_PATTERN.matcher(sourceName);
if (matcher.matches()) {
return RevisionSourceIdentifier.create(matcher.group(1), Revision.of(matcher.group(2)));
}