aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service
diff options
context:
space:
mode:
Diffstat (limited to 'cps-service')
-rw-r--r--cps-service/pom.xml2
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsDataService.java15
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java3
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java11
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java2
-rw-r--r--cps-service/src/main/java/org/onap/cps/notification/NotificationService.java31
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java13
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java4
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java4
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java42
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java16
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java4
-rw-r--r--cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java9
-rw-r--r--cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSetBuilder.java12
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsDataServiceImplSpec.groovy16
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy7
16 files changed, 106 insertions, 85 deletions
diff --git a/cps-service/pom.xml b/cps-service/pom.xml
index 9c7031e2f8..aea122d176 100644
--- a/cps-service/pom.xml
+++ b/cps-service/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>3.1.0-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java b/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java
index cdd417bd8d..35caf95153 100644
--- a/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java
@@ -174,4 +174,19 @@ public interface CpsDataService {
*/
void updateNodeLeavesAndExistingDescendantLeaves(String dataspaceName, String anchorName, String parentNodeXpath,
String dataNodeUpdatesAsJson, OffsetDateTime observedTimestamp);
+
+ /**
+ * Starts a session which allows use of locks and batch interaction with the persistence service.
+ *
+ * @return Session ID string
+ */
+ String startSession();
+
+ /**
+ * Close session.
+ *
+ * @param sessionId session ID
+ *
+ */
+ void closeSession(String sessionId);
}
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 6ae28fe9c3..ecc9bf0986 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
@@ -96,9 +96,10 @@ public interface CpsModuleService {
/**
* Identify previously unknown Yang Resource module references.
+ * The system will ignore the namespace of all module references.
*
* @param moduleReferencesToCheck the moduleReferencesToCheck
- * @returns collection of module references
+ * @returns collection of module references (namespace will be always blank)
*/
Collection<ModuleReference> identifyNewModuleReferences(
Collection<ModuleReference> moduleReferencesToCheck);
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 aae355d507..643614f4fb 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
@@ -109,6 +109,17 @@ public class CpsDataServiceImpl implements CpsDataService {
}
@Override
+ public String startSession() {
+ final String sessionId = cpsDataPersistenceService.startSession();
+ return sessionId;
+ }
+
+ @Override
+ public void closeSession(final String sessionId) {
+ cpsDataPersistenceService.closeSession(sessionId);
+ }
+
+ @Override
public void replaceNodeTree(final String dataspaceName, final String anchorName, final String parentNodeXpath,
final String jsonData, final OffsetDateTime observedTimestamp) {
final var dataNode = buildDataNode(dataspaceName, anchorName, parentNodeXpath, jsonData);
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 7267f22b55..f0e79c60c7 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
@@ -68,7 +68,7 @@ public class CpsModuleServiceImpl implements CpsModuleService {
final var yangTextSchemaSourceSet = yangTextSchemaSourceSetCache
.get(dataspaceName, schemaSetName);
return SchemaSet.builder().name(schemaSetName).dataspaceName(dataspaceName)
- .extendedModuleReferences(yangTextSchemaSourceSet.getModuleReferences()).build();
+ .moduleReferences(yangTextSchemaSourceSet.getModuleReferences()).build();
}
@Override
diff --git a/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java b/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java
index 5e26a22045..30bb851426 100644
--- a/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java
+++ b/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (c) 2021-2022 Bell Canada.
+ * Modifications 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.
@@ -28,6 +29,8 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import javax.annotation.PostConstruct;
+import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.spi.model.Anchor;
import org.springframework.scheduling.annotation.Async;
@@ -35,32 +38,18 @@ import org.springframework.stereotype.Service;
@Service
@Slf4j
+@RequiredArgsConstructor
public class NotificationService {
- private NotificationProperties notificationProperties;
- private NotificationPublisher notificationPublisher;
- private CpsDataUpdatedEventFactory cpsDataUpdatedEventFactory;
- private NotificationErrorHandler notificationErrorHandler;
+ private final NotificationProperties notificationProperties;
+ private final NotificationPublisher notificationPublisher;
+ private final CpsDataUpdatedEventFactory cpsDataUpdatedEventFactory;
+ private final NotificationErrorHandler notificationErrorHandler;
private List<Pattern> dataspacePatterns;
- /**
- * Create an instance of Notification Subscriber.
- *
- * @param notificationProperties properties for notification
- * @param notificationPublisher notification Publisher
- * @param cpsDataUpdatedEventFactory to create CPSDataUpdatedEvent
- * @param notificationErrorHandler error handler
- */
- public NotificationService(
- final NotificationProperties notificationProperties,
- final NotificationPublisher notificationPublisher,
- final CpsDataUpdatedEventFactory cpsDataUpdatedEventFactory,
- final NotificationErrorHandler notificationErrorHandler) {
+ @PostConstruct
+ public void init() {
log.info("Notification Properties {}", notificationProperties);
- this.notificationProperties = notificationProperties;
- this.notificationPublisher = notificationPublisher;
- this.cpsDataUpdatedEventFactory = cpsDataUpdatedEventFactory;
- this.notificationErrorHandler = notificationErrorHandler;
this.dataspacePatterns = getDataspaceFilterPatterns(notificationProperties);
}
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 fd658861c2..fdcf15bee6 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
@@ -148,4 +148,17 @@ public interface CpsDataPersistenceService {
Collection<DataNode> queryDataNodes(String dataspaceName, String anchorName,
String cpsPath, FetchDescendantsOption fetchDescendantsOption);
+ /**
+ * Starts a session which allows use of locks and batch interaction with the persistence service.
+ *
+ * @return Session ID string
+ */
+ String startSession();
+
+ /**
+ * Close session.
+ *
+ * @param sessionId session ID
+ */
+ void closeSession(String sessionId);
}
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 4306df78da..0e90e84f1e 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
@@ -100,9 +100,11 @@ public interface CpsModulePersistenceService {
/**
* Identify new module references from those returned by a node compared to what is in CPS already.
+ * The system will ignore the namespace of all module references.
*
* @param moduleReferencesToCheck the module references ot check
- * @returns Collection of {@link ModuleReference} of previously unknown module references
+ * @returns Collection of {@link ModuleReference} (namespace will be always blank)
+ *
*/
Collection<ModuleReference> identifyNewModuleReferences(
Collection<ModuleReference> moduleReferencesToCheck);
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java b/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
index 8e9dff873a..55e7b9970b 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/DataNode.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2021 Nordix Foundation.
+ * Copyright (C) 2020-2022 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
* ================================================================================
@@ -38,7 +38,7 @@ public class DataNode {
private String dataspace;
private String schemaSetName;
private String anchorName;
- private ExtendedModuleReference extendedModuleReference;
+ private ModuleReference moduleReference;
private String xpath;
private Map<String, Object> leaves = Collections.emptyMap();
private Collection<String> xpathsChildren;
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java b/cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java
deleted file mode 100644
index 5e9c8d0cd7..0000000000
--- a/cps-service/src/main/java/org/onap/cps/spi/model/ExtendedModuleReference.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
- * Modifications Copyright 2020-2021 Pantheon.tech
- * ================================================================================
- * 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.model;
-
-import java.io.Serializable;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class ExtendedModuleReference implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private String name;
- private String namespace;
- private String revision;
-
-}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java b/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
index 9b73f8ff0f..569f0a06ed 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/ModuleReference.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021-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.
@@ -35,4 +35,18 @@ public class ModuleReference implements Serializable {
private static final long serialVersionUID = -1761408847591042599L;
private String moduleName;
private String revision;
+ @Builder.Default
+ private String namespace = "";
+
+ /**
+ * Constructor for module references without namespace (will remain blank).
+ *
+ * @param moduleName module names.
+ * @param revision revision of module.
+ */
+ public ModuleReference(final String moduleName, final String revision) {
+ this.moduleName = moduleName;
+ this.revision = revision;
+ this.namespace = "";
+ }
}
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java b/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
index 4df7893e2c..bb981482f4 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/model/SchemaSet.java
@@ -1,12 +1,14 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Pantheon.tech
+ * Modifications 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.
@@ -35,5 +37,5 @@ public class SchemaSet implements Serializable {
private static final long serialVersionUID = 1464791260718603291L;
private String name;
private String dataspaceName;
- private List<ExtendedModuleReference> extendedModuleReferences;
+ private List<ModuleReference> moduleReferences;
}
diff --git a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java
index 2c9d374b14..80f0224c69 100644
--- a/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java
+++ b/cps-service/src/main/java/org/onap/cps/yang/YangTextSchemaSourceSet.java
@@ -1,12 +1,14 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Pantheon.tech
+ * Modifications 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.
@@ -20,8 +22,7 @@
package org.onap.cps.yang;
import java.util.List;
-import org.checkerframework.checker.nullness.qual.NonNull;
-import org.onap.cps.spi.model.ExtendedModuleReference;
+import org.onap.cps.spi.model.ModuleReference;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
@@ -34,13 +35,11 @@ public interface YangTextSchemaSourceSet {
*
* @return list of ModuleRef
*/
- @NonNull
- List<ExtendedModuleReference> getModuleReferences();
+ List<ModuleReference> getModuleReferences();
/**
* Return SchemaContext for given YangSchema.
* @return SchemaContext
*/
- @NonNull
SchemaContext getSchemaContext();
}
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 5cbfd6222d..fd534971a1 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
@@ -1,12 +1,14 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Pantheon.tech
+ * Modifications 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.
@@ -35,7 +37,7 @@ import java.util.stream.Collectors;
import lombok.NoArgsConstructor;
import org.onap.cps.spi.exceptions.CpsException;
import org.onap.cps.spi.exceptions.ModelValidationException;
-import org.onap.cps.spi.model.ExtendedModuleReference;
+import org.onap.cps.spi.model.ModuleReference;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -88,15 +90,15 @@ public final class YangTextSchemaSourceSetBuilder {
}
@Override
- public List<ExtendedModuleReference> getModuleReferences() {
+ public List<ModuleReference> getModuleReferences() {
return schemaContext.getModules().stream()
.map(YangTextSchemaSourceSetImpl::toModuleReference)
.collect(Collectors.toList());
}
- private static ExtendedModuleReference toModuleReference(final Module module) {
- return ExtendedModuleReference.builder()
- .name(module.getName())
+ private static ModuleReference toModuleReference(final Module module) {
+ return ModuleReference.builder()
+ .moduleName(module.getName())
.namespace(module.getQNameModule().getNamespace().toString())
.revision(module.getRevision().map(Revision::toString).orElse(null))
.build();
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 785788be90..eb06199d1b 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
@@ -254,4 +254,20 @@ class CpsDataServiceImplSpec extends Specification {
def schemaContext = YangTextSchemaSourceSetBuilder.of(yangResourceNameToContent).getSchemaContext()
mockYangTextSchemaSourceSet.getSchemaContext() >> schemaContext
}
+
+ def 'start session'() {
+ when: 'start session method is called'
+ objectUnderTest.startSession()
+ then: 'the persistence service method to start session is invoked'
+ 1 * mockCpsDataPersistenceService.startSession()
+ }
+
+ def 'close session'(){
+ given: 'session Id from calling the start session method'
+ def sessionId = objectUnderTest.startSession()
+ when: 'close session method is called'
+ objectUnderTest.closeSession(sessionId)
+ then: 'the persistence service method to close session is invoked'
+ 1 * mockCpsDataPersistenceService.closeSession(sessionId)
+ }
}
diff --git a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
index afd8e8666f..bae06bb9ec 100644
--- a/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/api/impl/CpsModuleServiceImplSpec.groovy
@@ -28,7 +28,6 @@ import org.onap.cps.spi.CpsModulePersistenceService
import org.onap.cps.spi.exceptions.ModelValidationException
import org.onap.cps.spi.exceptions.SchemaSetInUseException
import org.onap.cps.spi.model.Anchor
-import org.onap.cps.spi.model.ExtendedModuleReference
import org.onap.cps.spi.model.ModuleReference
import org.onap.cps.yang.YangTextSchemaSourceSetBuilder
import spock.lang.Specification
@@ -54,7 +53,7 @@ class CpsModuleServiceImplSpec extends Specification {
def 'Create schema set from new modules and existing modules.'() {
given: 'a list of existing modules module reference'
- def moduleReferenceForExistingModule = new ExtendedModuleReference("test", "test.org", "2021-10-12")
+ def moduleReferenceForExistingModule = new ModuleReference("test", "2021-10-12","test.org")
def listOfExistingModulesModuleReference = [moduleReferenceForExistingModule]
when: 'create schema set from modules method is invoked'
objectUnderTest.createSchemaSetFromModules("someDataspaceName", "someSchemaSetName", [newModule: "newContent"], listOfExistingModulesModuleReference)
@@ -81,7 +80,7 @@ class CpsModuleServiceImplSpec extends Specification {
then: 'the correct schema set is returned'
result.getName().contains('someSchemaSet')
result.getDataspaceName().contains('someDataspace')
- result.getExtendedModuleReferences().contains(new ExtendedModuleReference('stores', 'org:onap:ccsdk:sample', '2020-09-15'))
+ result.getModuleReferences().contains(new ModuleReference('stores', '2020-09-15', 'org:onap:ccsdk:sample'))
}
def 'Delete schema-set when cascade is allowed.'() {
@@ -134,7 +133,7 @@ class CpsModuleServiceImplSpec extends Specification {
def 'Get all yang resources module references.'() {
given: 'an already present module reference'
- def moduleReferences = [new ExtendedModuleReference()]
+ def moduleReferences = [new ModuleReference('some module name','some revision name')]
mockCpsModulePersistenceService.getYangResourceModuleReferences('someDataspaceName') >> moduleReferences
expect: 'the list provided by persistence service is returned as result'
objectUnderTest.getYangResourceModuleReferences('someDataspaceName') == moduleReferences