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/spi/CpsDataPersistenceService.java12
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/exceptions/CpsPathException.java35
-rwxr-xr-xcps-service/src/test/groovy/org/onap/cps/spi/exceptions/CpsExceptionsSpec.groovy9
3 files changed, 56 insertions, 0 deletions
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 9a0c180a8f..d2b6d45d66 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
@@ -21,6 +21,7 @@
package org.onap.cps.spi;
+import java.util.Collection;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.onap.cps.spi.model.DataNode;
@@ -86,4 +87,15 @@ public interface CpsDataPersistenceService {
* @param dataNode data node
*/
void replaceDataNodeTree(@NonNull String dataspaceName, @NonNull String anchorName, @NonNull DataNode dataNode);
+
+ /**
+ * Get a datanode by cps path.
+ *
+ * @param dataspaceName dataspace name
+ * @param anchorName anchor name
+ * @param cpsPath cps path
+ * @return the data nodes found i.e. 0 or more data nodes
+ */
+ Collection<DataNode> queryDataNodes(@NonNull String dataspaceName, @NonNull String anchorName,
+ @NonNull String cpsPath);
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/exceptions/CpsPathException.java b/cps-service/src/main/java/org/onap/cps/spi/exceptions/CpsPathException.java
new file mode 100644
index 0000000000..fde5566b14
--- /dev/null
+++ b/cps-service/src/main/java/org/onap/cps/spi/exceptions/CpsPathException.java
@@ -0,0 +1,35 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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;
+
+public class CpsPathException extends CpsException {
+
+ private static final long serialVersionUID = 1006899957127327791L;
+
+ /**
+ * Constructor.
+ *
+ * @param message the error message
+ * @param details the error details
+ */
+ public CpsPathException(final String message, final String details) {
+ super(message, details);
+ }
+}
diff --git a/cps-service/src/test/groovy/org/onap/cps/spi/exceptions/CpsExceptionsSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/spi/exceptions/CpsExceptionsSpec.groovy
index 500b80152d..a4a13ff4c9 100755
--- a/cps-service/src/test/groovy/org/onap/cps/spi/exceptions/CpsExceptionsSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/spi/exceptions/CpsExceptionsSpec.groovy
@@ -133,4 +133,13 @@ class CpsExceptionsSpec extends Specification {
(new DataNodeNotFoundException(dataspaceName, anchorName, xpath)).details
== "DataNode with xpath ${xpath} was not found for anchor ${anchorName} and dataspace ${dataspaceName}."
}
+
+ def 'Creating a cps path exception.'() {
+ given: 'a cps path exception is created'
+ def exception = new CpsPathException(providedMessage, providedDetails)
+ expect: 'the exception has the provided message'
+ exception.message == providedMessage
+ and: 'the exception has the provided details'
+ exception.details == providedDetails
+ }
} \ No newline at end of file