diff options
author | emaclee <lee.anjella.macabuhay@est.tech> | 2022-06-17 17:42:56 +0100 |
---|---|---|
committer | emaclee <lee.anjella.macabuhay@est.tech> | 2022-06-30 12:08:14 +0100 |
commit | e1f73e264e2dca1f10c273620653f541c2f25d69 (patch) | |
tree | f9adc065420549de0368842ae1f4e7df30c4effe /cps-service/src/main/java/org | |
parent | f7c7848d4cd7654ab94d9c31b62a71ed2bc4b9e8 (diff) |
Add method to get YANG module sources for CM handle
- part of this commit includes renaming the enum SyncState to
DataStoreSyncState
Issue-ID: CPS-1064
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
Change-Id: I6bf419141a1b33f09871946445cdfff422c8c354
Diffstat (limited to 'cps-service/src/main/java/org')
4 files changed, 66 insertions, 1 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 79d6e03d4a..5e8eb9f6cf 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 @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.Map; import org.onap.cps.spi.CascadeDeleteAllowed; import org.onap.cps.spi.exceptions.DataInUseException; +import org.onap.cps.spi.model.ModuleDefinition; import org.onap.cps.spi.model.ModuleReference; import org.onap.cps.spi.model.SchemaSet; @@ -94,6 +95,15 @@ public interface CpsModuleService { Collection<ModuleReference> getYangResourcesModuleReferences(String dataspaceName, String anchorName); /** + * Retrieve module definitions for the given dataspace name and anchor name. + * + * @param dataspaceName dataspace name + * @param anchorName anchor name + * @return a collection of module definitions (moduleName, revision, yang resource content) + */ + Collection<ModuleDefinition> getModuleDefinitionsByAnchorName(String dataspaceName, String anchorName); + + /** * Identify previously unknown Yang Resource module references. * The system will ignore the namespace of all module references. * 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 db8a81f276..ff725a617f 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 @@ -31,6 +31,7 @@ import org.onap.cps.spi.CascadeDeleteAllowed; import org.onap.cps.spi.CpsModulePersistenceService; import org.onap.cps.spi.exceptions.SchemaSetInUseException; import org.onap.cps.spi.model.Anchor; +import org.onap.cps.spi.model.ModuleDefinition; import org.onap.cps.spi.model.ModuleReference; import org.onap.cps.spi.model.SchemaSet; import org.onap.cps.utils.CpsValidator; @@ -106,6 +107,13 @@ public class CpsModuleServiceImpl implements CpsModuleService { } @Override + public Collection<ModuleDefinition> getModuleDefinitionsByAnchorName(final String dataspaceName, + final String anchorName) { + CpsValidator.validateNameCharacters(dataspaceName, anchorName); + return cpsModulePersistenceService.getYangResourceDefinitions(dataspaceName, anchorName); + } + + @Override public Collection<ModuleReference> identifyNewModuleReferences( final Collection<ModuleReference> moduleReferencesToCheck) { return cpsModulePersistenceService.identifyNewModuleReferences(moduleReferencesToCheck); 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 0e90e84f1e..db2cb60f34 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 @@ -23,6 +23,7 @@ package org.onap.cps.spi; import java.util.Collection; import java.util.Map; +import org.onap.cps.spi.model.ModuleDefinition; import org.onap.cps.spi.model.ModuleReference; /** @@ -89,11 +90,20 @@ public interface CpsModulePersistenceService { * * @param dataspaceName dataspace name * @param anchorName anchor name - * @return a collection of module names and revisions + * @return a collection of module reference (moduleName and revision) */ Collection<ModuleReference> getYangResourceModuleReferences(String dataspaceName, String anchorName); /** + * Get YANG resource definitions for the given anchor name and dataspace name. + * + * @param dataspaceName dataspace name + * @param anchorName anchor name + * @return a collection of module definitions (moduleName, revision and yang resource content) + */ + Collection<ModuleDefinition> getYangResourceDefinitions(String dataspaceName, String anchorName); + + /** * Remove unused Yang Resource Modules. */ void deleteUnusedYangResourceModules(); diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/ModuleDefinition.java b/cps-service/src/main/java/org/onap/cps/spi/model/ModuleDefinition.java new file mode 100644 index 0000000000..d7a5b38dcc --- /dev/null +++ b/cps-service/src/main/java/org/onap/cps/spi/model/ModuleDefinition.java @@ -0,0 +1,37 @@ +/* + * ============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.model; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ModuleDefinition extends ModuleReference { + + private static final long serialVersionUID = -6591435720836327732L; + private final String content; + + public ModuleDefinition(final String moduleName, final String revision, final String content) { + super(moduleName, revision); + this.content = content; + } +}
\ No newline at end of file |