summaryrefslogtreecommitdiffstats
path: root/cps-ri
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2021-01-06 11:14:31 +0000
committerGerrit Code Review <gerrit@onap.org>2021-01-06 11:14:31 +0000
commit69fc5b35d884afaea6cd4d96734a4f7607723997 (patch)
tree89142e964ed1652d44537cb88e196bbfb39724ca /cps-ri
parentb41740d115b403e1790ec854c2aacf8b114ea6d0 (diff)
parentacfb2078d510f5cec7b6ce57c03ba42663b8f3ee (diff)
Merge "Create schema set REST API and service level"
Diffstat (limited to 'cps-ri')
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java20
1 files changed, 4 insertions, 16 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
index 8a14926255..ef327c2592 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
@@ -21,7 +21,6 @@
package org.onap.cps.spi.impl;
import com.google.common.collect.ImmutableSet;
-import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -32,17 +31,12 @@ import org.onap.cps.spi.CpsModulePersistenceService;
import org.onap.cps.spi.entities.Dataspace;
import org.onap.cps.spi.entities.SchemaSet;
import org.onap.cps.spi.entities.YangResource;
-import org.onap.cps.spi.exceptions.CpsException;
-import org.onap.cps.spi.exceptions.ModelValidationException;
import org.onap.cps.spi.exceptions.SchemaSetAlreadyDefinedException;
import org.onap.cps.spi.model.ModuleReference;
import org.onap.cps.spi.repository.DataspaceRepository;
import org.onap.cps.spi.repository.SchemaSetRepository;
import org.onap.cps.spi.repository.YangResourceRepository;
-import org.onap.cps.yang.YangTextSchemaSourceSet;
import org.onap.cps.yang.YangTextSchemaSourceSetBuilder;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Component;
@@ -62,7 +56,7 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
@Override
public void storeModule(final String namespace, final String moduleContent, final String revision,
- final String dataspaceName) {
+ final String dataspaceName) {
// TODO this method should be removed as obsolete.
// Modules to be processed within schema sets only.
}
@@ -70,7 +64,7 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
@Override
@Transactional
public void storeSchemaSet(final String dataspaceName, final String schemaSetName,
- final Map<String, String> yangResourcesNameToContentMap) {
+ final Map<String, String> yangResourcesNameToContentMap) {
final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName);
final Set<YangResource> yangResources = synchronizeYangResources(yangResourcesNameToContentMap);
@@ -119,13 +113,7 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName);
final SchemaSet schemaSet = schemaSetRepository.getByDataspaceAndName(dataspace, schemaSetName);
final Map<String, String> yangResourceNameToContent = schemaSet.getYangResources().stream().collect(
- Collectors.toMap(YangResource::getName, YangResource::getContent));
- try {
- final YangTextSchemaSourceSet schemaSourceSet = YangTextSchemaSourceSetBuilder
- .of(yangResourceNameToContent);
- return schemaSourceSet.getModuleReferences();
- } catch (final ReactorException | YangSyntaxErrorException e) {
- throw new ModelValidationException("Yang file validation failed", e.getMessage(), e);
- }
+ Collectors.toMap(YangResource::getName, YangResource::getContent));
+ return YangTextSchemaSourceSetBuilder.of(yangResourceNameToContent).getModuleReferences();
}
}