summaryrefslogtreecommitdiffstats
path: root/cps-service
diff options
context:
space:
mode:
Diffstat (limited to 'cps-service')
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java4
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java2
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java4
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java8
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java8
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/exceptions/AlreadyDefinedExceptionBatch.java34
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/exceptions/ConcurrencyException.java4
-rw-r--r--cps-service/src/main/java/org/onap/cps/utils/CpsValidator.java18
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy2
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/utils/CpsValidatorSpec.groovy14
10 files changed, 56 insertions, 42 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
index 5e8eb9f6cf..6b17e820c4 100644
--- a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java
@@ -50,11 +50,11 @@ public interface CpsModuleService {
* @param dataspaceName Dataspace name
* @param schemaSetName schema set name
* @param newModuleNameToContentMap YANG resources map where key is a module name and value is content
- * @param moduleReferences List of YANG resources module references of the modules
+ * @param allModuleReferences All YANG resource module references
*/
void createSchemaSetFromModules(String dataspaceName, String schemaSetName,
Map<String, String> newModuleNameToContentMap,
- Collection<ModuleReference> moduleReferences);
+ Collection<ModuleReference> allModuleReferences);
/**
* Read schema set in the given dataspace.
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 6bf493556e..b6aa04be76 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
@@ -97,7 +97,7 @@ public class CpsDataServiceImpl implements CpsDataService {
CpsValidator.validateNameCharacters(dataspaceName, anchorName);
final Collection<Collection<DataNode>> listElementDataNodeCollections =
buildDataNodes(dataspaceName, anchorName, parentNodeXpath, jsonDataList);
- cpsDataPersistenceService.addListElementsBatch(dataspaceName, anchorName, parentNodeXpath,
+ cpsDataPersistenceService.addMultipleLists(dataspaceName, anchorName, parentNodeXpath,
listElementDataNodeCollections);
processDataUpdatedEventAsync(dataspaceName, anchorName, parentNodeXpath, UPDATE, observedTimestamp);
}
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 ff725a617f..20b4a23a9b 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
@@ -60,10 +60,10 @@ public class CpsModuleServiceImpl implements CpsModuleService {
@Override
public void createSchemaSetFromModules(final String dataspaceName, final String schemaSetName,
final Map<String, String> newModuleNameToContentMap,
- final Collection<ModuleReference> moduleReferences) {
+ final Collection<ModuleReference> allModuleReferences) {
CpsValidator.validateNameCharacters(dataspaceName, schemaSetName);
cpsModulePersistenceService.storeSchemaSetFromModules(dataspaceName, schemaSetName,
- newModuleNameToContentMap, moduleReferences);
+ newModuleNameToContentMap, allModuleReferences);
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java
index 8b45ae78d9..cd0cefcbf3 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java
@@ -66,15 +66,15 @@ public interface CpsDataPersistenceService {
Collection<DataNode> listElementsCollection);
/**
- * Adds list child elements to a Fragment.
+ * Add multiple lists of data nodes to a parent node at the same time.
*
* @param dataspaceName dataspace name
* @param anchorName anchor name
* @param parentNodeXpath parent node xpath
- * @param listElementsCollections collections of data nodes representing list elements
+ * @param newLists collections of lists of data nodes representing list elements
*/
- void addListElementsBatch(String dataspaceName, String anchorName, String parentNodeXpath,
- Collection<Collection<DataNode>> listElementsCollections);
+ void addMultipleLists(String dataspaceName, String anchorName, String parentNodeXpath,
+ Collection<Collection<DataNode>> newLists);
/**
* Retrieves datanode by XPath for given dataspace and anchor.
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
index db2cb60f34..aaf6b38af4 100755
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java
@@ -43,13 +43,13 @@ public interface CpsModulePersistenceService {
/**
* Stores a schema set from new modules and existing modules.
*
- * @param dataspaceName Dataspace name
- * @param schemaSetName Schema set name
+ * @param dataspaceName Dataspace name
+ * @param schemaSetName Schema set name
* @param newModuleNameToContentMap YANG resources map where key is a module name and value is content
- * @param moduleReferences List of YANG resources module references
+ * @param allModuleReferences All YANG resources module references
*/
void storeSchemaSetFromModules(String dataspaceName, String schemaSetName,
- Map<String, String> newModuleNameToContentMap, Collection<ModuleReference> moduleReferences);
+ Map<String, String> newModuleNameToContentMap, Collection<ModuleReference> allModuleReferences);
/**
* Deletes Schema Set.
diff --git a/cps-service/src/main/java/org/onap/cps/spi/exceptions/AlreadyDefinedExceptionBatch.java b/cps-service/src/main/java/org/onap/cps/spi/exceptions/AlreadyDefinedExceptionBatch.java
new file mode 100644
index 0000000000..0ba656aa12
--- /dev/null
+++ b/cps-service/src/main/java/org/onap/cps/spi/exceptions/AlreadyDefinedExceptionBatch.java
@@ -0,0 +1,34 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.spi.exceptions;
+
+import java.util.Collection;
+import lombok.Getter;
+
+public class AlreadyDefinedExceptionBatch extends RuntimeException {
+
+ @Getter
+ private final Collection<String> alreadyDefinedXpaths;
+
+ public AlreadyDefinedExceptionBatch(final Collection<String> alreadyDefinedXPaths) {
+ this.alreadyDefinedXpaths = alreadyDefinedXPaths;
+ }
+}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/exceptions/ConcurrencyException.java b/cps-service/src/main/java/org/onap/cps/spi/exceptions/ConcurrencyException.java
index 3a8a94b979..b5eae93b32 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/exceptions/ConcurrencyException.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/exceptions/ConcurrencyException.java
@@ -20,8 +20,8 @@ package org.onap.cps.spi.exceptions;
public class ConcurrencyException extends CpsException {
- public ConcurrencyException(final String message, final String details, final Throwable cause) {
- super(message, details, cause);
+ public ConcurrencyException(final String message, final String details) {
+ super(message, details);
}
}
diff --git a/cps-service/src/main/java/org/onap/cps/utils/CpsValidator.java b/cps-service/src/main/java/org/onap/cps/utils/CpsValidator.java
index 28b49c9666..f3774d9529 100644
--- a/cps-service/src/main/java/org/onap/cps/utils/CpsValidator.java
+++ b/cps-service/src/main/java/org/onap/cps/utils/CpsValidator.java
@@ -22,7 +22,6 @@ package org.onap.cps.utils;
import com.google.common.collect.Lists;
import java.util.Collection;
-import java.util.regex.Pattern;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -33,30 +32,25 @@ import org.onap.cps.spi.exceptions.DataValidationException;
public final class CpsValidator {
private static final char[] UNSUPPORTED_NAME_CHARACTERS = "!\" #$%&'()*+,./\\:;<=>?@[]^`{|}~".toCharArray();
- private static final Pattern TOPIC_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9]([._-](?![._-])|"
- + "[a-zA-Z0-9]){0,120}[a-zA-Z0-9]$");
/**
* Validate characters in names within cps.
+ *
* @param names names of data to be validated
*/
public static void validateNameCharacters(final String... names) {
for (final String name : names) {
- final Collection<Character> charactersOfName = Lists.charactersOf(name);
+ final Collection<Character> charactersOfName = Lists.charactersOf(name);
for (final char unsupportedCharacter : UNSUPPORTED_NAME_CHARACTERS) {
if (charactersOfName.contains(unsupportedCharacter)) {
throw new DataValidationException("Name or ID Validation Error.",
- name + " invalid token encountered at position " + (name.indexOf(unsupportedCharacter) + 1));
+ name + " invalid token encountered at position "
+ + (name.indexOf(unsupportedCharacter) + 1));
}
}
}
}
- /**
- * Validate kafka topic name pattern.
- * @param topicName name of the topic to be validated
- */
- public static boolean validateTopicName(final String topicName) {
- return topicName != null && TOPIC_NAME_PATTERN.matcher(topicName).matches();
- }
+
+
}
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy
index ab960df6aa..3f28f0ac8d 100644
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy
@@ -143,7 +143,7 @@ class CpsDataServiceImplSpec extends Specification {
def jsonData = '{"branch": [{"name": "A"}, {"name": "B"}]}'
objectUnderTest.saveListElementsBatch(dataspaceName, anchorName, '/test-tree', [jsonData], observedTimestamp)
then: 'the persistence service method is invoked with correct parameters'
- 1 * mockCpsDataPersistenceService.addListElementsBatch(dataspaceName, anchorName, '/test-tree',_) >> {
+ 1 * mockCpsDataPersistenceService.addMultipleLists(dataspaceName, anchorName, '/test-tree',_) >> {
args -> {
def listElementsCollection = args[3] as Collection<Collection<DataNode>>
assert listElementsCollection.size() == 1
diff --git a/cps-service/src/test/groovy/org/onap/cps/utils/CpsValidatorSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/utils/CpsValidatorSpec.groovy
index ce728ef1c1..ea7a5d6d1d 100644
--- a/cps-service/src/test/groovy/org/onap/cps/utils/CpsValidatorSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/utils/CpsValidatorSpec.groovy
@@ -25,7 +25,6 @@ import spock.lang.Specification
class CpsValidatorSpec extends Specification {
-
def 'Validating a valid string.'() {
when: 'the string is validated using a valid name'
CpsValidator.validateNameCharacters('name-with-no-spaces')
@@ -46,17 +45,4 @@ class CpsValidatorSpec extends Specification {
'position 9' | 'nameWith Space' || 'nameWith Space invalid token encountered at position 9'
}
- def 'Validating topic names.'() {
- when: 'the topic name is validated'
- def isValidTopicName = CpsValidator.validateTopicName(topicName)
- then: 'boolean response will be returned for #scenario'
- assert isValidTopicName == booleanResponse
- where: 'the following names are used'
- scenario | topicName || booleanResponse
- 'valid topic' | 'my-topic-name' || true
- 'empty topic' | '' || false
- 'blank topic' | ' ' || false
- 'null topic' | null || false
- 'invalid non empty topic' | '1_5_*_#' || false
- }
}