aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2024-06-21 11:12:45 +0100
committerDaniel Hanrahan <daniel.hanrahan@est.tech>2024-06-25 12:38:47 +0000
commit7915e994ac4eb403461b3a93165a2e3c72871ab6 (patch)
tree789a2d6e89333327e7ae044073d917e7b5cf542f /cps-service/src/main/java
parent37d82d5d54ede4c05862fe648911c383d253cec3 (diff)
Fix incorrect use of getAnchors(dataspace, schemasets)
There is an issue in a method deleteDataNodes(dataspace, anchors) where it doesn't send data update events. This is because it fetches anchors using a method getAnchors(dataspace, schemaSetNames), when it needs to fetch anchors by name: getAnchors(dataspace, anchorNames) Changes: - Rename getAnchors method using schemasets to getAnchorsBySchemaSetNames - Add a method getAnchors(dataspace, anchorNames) - Update test of deleteDataNodes method using getAnchors so it checks that data update events are sent Issue-ID: CPS-2254 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: I55fe853f0a9278a66a5724bf4cf2723b0e2fbc8b
Diffstat (limited to 'cps-service/src/main/java')
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsAnchorService.java33
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsAnchorServiceImpl.java30
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java7
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java47
4 files changed, 72 insertions, 45 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsAnchorService.java b/cps-service/src/main/java/org/onap/cps/api/CpsAnchorService.java
index a247150c1..fcb969ba3 100644
--- a/cps-service/src/main/java/org/onap/cps/api/CpsAnchorService.java
+++ b/cps-service/src/main/java/org/onap/cps/api/CpsAnchorService.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation
+ * Copyright (C) 2023-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,6 +37,15 @@ public interface CpsAnchorService {
void createAnchor(String dataspaceName, String schemaSetName, String anchorName);
/**
+ * Get an anchor in the given dataspace using the anchor name.
+ *
+ * @param dataspaceName dataspace name
+ * @param anchorName anchor name
+ * @return an anchor
+ */
+ Anchor getAnchor(String dataspaceName, String anchorName);
+
+ /**
* Read all anchors in the given dataspace.
*
* @param dataspaceName dataspace name
@@ -45,13 +54,22 @@ public interface CpsAnchorService {
Collection<Anchor> getAnchors(String dataspaceName);
/**
+ * Read all anchors in the given dataspace with the anchor names.
+ *
+ * @param dataspaceName dataspace name
+ * @param anchorNames anchor names
+ * @return a collection of anchors
+ */
+ Collection<Anchor> getAnchors(String dataspaceName, Collection<String> anchorNames);
+
+ /**
* Read all anchors associated with the given schema-set in the given dataspace.
*
* @param dataspaceName dataspace name
* @param schemaSetName schema-set name
* @return a collection of anchors
*/
- Collection<Anchor> getAnchors(String dataspaceName, String schemaSetName);
+ Collection<Anchor> getAnchorsBySchemaSetName(String dataspaceName, String schemaSetName);
/**
* Read all anchors associated with the given schema-sets in the given dataspace.
@@ -60,16 +78,7 @@ public interface CpsAnchorService {
* @param schemaSetNames schema-set names
* @return a collection of anchors
*/
- Collection<Anchor> getAnchors(String dataspaceName, Collection<String> schemaSetNames);
-
- /**
- * Get an anchor in the given dataspace using the anchor name.
- *
- * @param dataspaceName dataspace name
- * @param anchorName anchor name
- * @return an anchor
- */
- Anchor getAnchor(String dataspaceName, String anchorName);
+ Collection<Anchor> getAnchorsBySchemaSetNames(String dataspaceName, Collection<String> schemaSetNames);
/**
* Delete anchor by name in given dataspace.
diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsAnchorServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsAnchorServiceImpl.java
index aa9c45d09..c31e51b17 100644
--- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsAnchorServiceImpl.java
+++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsAnchorServiceImpl.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation
+ * Copyright (C) 2023-2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,28 +44,36 @@ public class CpsAnchorServiceImpl implements CpsAnchorService {
}
@Override
+ public Anchor getAnchor(final String dataspaceName, final String anchorName) {
+ cpsValidator.validateNameCharacters(dataspaceName, anchorName);
+ return cpsAdminPersistenceService.getAnchor(dataspaceName, anchorName);
+ }
+
+ @Override
public Collection<Anchor> getAnchors(final String dataspaceName) {
cpsValidator.validateNameCharacters(dataspaceName);
return cpsAdminPersistenceService.getAnchors(dataspaceName);
}
@Override
- public Collection<Anchor> getAnchors(final String dataspaceName, final String schemaSetName) {
- cpsValidator.validateNameCharacters(dataspaceName, schemaSetName);
- return cpsAdminPersistenceService.getAnchors(dataspaceName, schemaSetName);
+ public Collection<Anchor> getAnchors(final String dataspaceName, final Collection<String> anchorNames) {
+ cpsValidator.validateNameCharacters(dataspaceName);
+ cpsValidator.validateNameCharacters(anchorNames);
+ return cpsAdminPersistenceService.getAnchors(dataspaceName, anchorNames);
}
@Override
- public Collection<Anchor> getAnchors(final String dataspaceName, final Collection<String> schemaSetNames) {
- cpsValidator.validateNameCharacters(dataspaceName);
- cpsValidator.validateNameCharacters(schemaSetNames);
- return cpsAdminPersistenceService.getAnchors(dataspaceName, schemaSetNames);
+ public Collection<Anchor> getAnchorsBySchemaSetName(final String dataspaceName, final String schemaSetName) {
+ cpsValidator.validateNameCharacters(dataspaceName, schemaSetName);
+ return cpsAdminPersistenceService.getAnchorsBySchemaSetName(dataspaceName, schemaSetName);
}
@Override
- public Anchor getAnchor(final String dataspaceName, final String anchorName) {
- cpsValidator.validateNameCharacters(dataspaceName, anchorName);
- return cpsAdminPersistenceService.getAnchor(dataspaceName, anchorName);
+ public Collection<Anchor> getAnchorsBySchemaSetNames(final String dataspaceName,
+ final Collection<String> schemaSetNames) {
+ cpsValidator.validateNameCharacters(dataspaceName);
+ cpsValidator.validateNameCharacters(schemaSetNames);
+ return cpsAdminPersistenceService.getAnchorsBySchemaSetNames(dataspaceName, schemaSetNames);
}
@Override
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 14b949e5a..e6ad9a8bb 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
@@ -97,7 +97,7 @@ public class CpsModuleServiceImpl implements CpsModuleService {
public void deleteSchemaSet(final String dataspaceName, final String schemaSetName,
final CascadeDeleteAllowed cascadeDeleteAllowed) {
cpsValidator.validateNameCharacters(dataspaceName, schemaSetName);
- final Collection<Anchor> anchors = cpsAnchorService.getAnchors(dataspaceName, schemaSetName);
+ final Collection<Anchor> anchors = cpsAnchorService.getAnchorsBySchemaSetName(dataspaceName, schemaSetName);
if (!anchors.isEmpty() && isCascadeDeleteProhibited(cascadeDeleteAllowed)) {
throw new SchemaSetInUseException(dataspaceName, schemaSetName);
}
@@ -114,8 +114,9 @@ public class CpsModuleServiceImpl implements CpsModuleService {
public void deleteSchemaSetsWithCascade(final String dataspaceName, final Collection<String> schemaSetNames) {
cpsValidator.validateNameCharacters(dataspaceName);
cpsValidator.validateNameCharacters(schemaSetNames);
- final Collection<String> anchorNames = cpsAnchorService.getAnchors(dataspaceName, schemaSetNames)
- .stream().map(Anchor::getName).collect(Collectors.toSet());
+ final Collection<String> anchorNames =
+ cpsAnchorService.getAnchorsBySchemaSetNames(dataspaceName, schemaSetNames)
+ .stream().map(Anchor::getName).collect(Collectors.toSet());
cpsAnchorService.deleteAnchors(dataspaceName, anchorNames);
cpsModulePersistenceService.deleteSchemaSets(dataspaceName, schemaSetNames);
cpsModulePersistenceService.deleteUnusedYangResourceModules();
diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
index 2b21619cb..25830a55d 100755
--- a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020-2022 Nordix Foundation.
+ * Copyright (C) 2020-2024 Nordix Foundation.
* Modifications Copyright (C) 2020-2022 Bell Canada.
* Modifications Copyright (C) 2021 Pantheon.tech
* Modifications Copyright (C) 2022 TechMahindra Ltd.
@@ -73,30 +73,48 @@ public interface CpsAdminPersistenceService {
void createAnchor(String dataspaceName, String schemaSetName, String anchorName);
/**
- * Read all anchors associated with the given schema-set in the given dataspace.
+ * Get an anchor in the given dataspace using the anchor name.
+ *
+ * @param dataspaceName dataspace name
+ * @param anchorName anchor name
+ * @return an anchor
+ */
+ Anchor getAnchor(String dataspaceName, String anchorName);
+
+ /**
+ * Read all anchors in the given a dataspace.
*
* @param dataspaceName dataspace name
- * @param schemaSetName schema-set name
* @return a collection of anchors
*/
- Collection<Anchor> getAnchors(String dataspaceName, String schemaSetName);
+ Collection<Anchor> getAnchors(String dataspaceName);
/**
- * Read all anchors associated with multiple schema-sets in the given dataspace.
+ * Read all anchors in the given dataspace with the anchor names.
*
- * @param dataspaceName dataspace name
- * @param schemaSetNames schema-set names
+ * @param dataspaceName dataspace name
+ * @param anchorNames anchor names
* @return a collection of anchors
*/
- Collection<Anchor> getAnchors(String dataspaceName, Collection<String> schemaSetNames);
+ Collection<Anchor> getAnchors(String dataspaceName, Collection<String> anchorNames);
/**
- * Read all anchors in the given a dataspace.
+ * Read all anchors associated with the given schema-set in the given dataspace.
*
* @param dataspaceName dataspace name
+ * @param schemaSetName schema-set name
* @return a collection of anchors
*/
- Collection<Anchor> getAnchors(String dataspaceName);
+ Collection<Anchor> getAnchorsBySchemaSetName(String dataspaceName, String schemaSetName);
+
+ /**
+ * Read all anchors associated with multiple schema-sets in the given dataspace.
+ *
+ * @param dataspaceName dataspace name
+ * @param schemaSetNames schema-set names
+ * @return a collection of anchors
+ */
+ Collection<Anchor> getAnchorsBySchemaSetNames(String dataspaceName, Collection<String> schemaSetNames);
/**
* Query anchor names for the given module names in the provided dataspace.
@@ -110,15 +128,6 @@ public interface CpsAdminPersistenceService {
Collection<String> queryAnchorNames(String dataspaceName, Collection<String> moduleNames);
/**
- * Get an anchor in the given dataspace using the anchor name.
- *
- * @param dataspaceName dataspace name
- * @param anchorName anchor name
- * @return an anchor
- */
- Anchor getAnchor(String dataspaceName, String anchorName);
-
- /**
* Delete anchor by name in given dataspace.
*
* @param dataspaceName dataspace name