diff options
author | niamhcore <niamh.core@est.tech> | 2020-09-23 11:36:33 +0100 |
---|---|---|
committer | niamhcore <niamh.core@est.tech> | 2020-09-24 17:21:36 +0100 |
commit | 6820538d8f5f999f1fa7bc64ad40e2a2cee7c85b (patch) | |
tree | c0f80f7606d60ad8740bac7037a1f75aa866c184 | |
parent | b08767ed33915b9199f07cc9bca94b346e752196 (diff) |
Adding upload and validation of yang model
Issue-ID: CCSDK-2718
https: //jira.onap.org/browse/CCSDK-2718
Change-Id: I919525595e28d46f20c1adb560232c31025687e3
15 files changed, 590 insertions, 177 deletions
diff --git a/cps/cps-rest/pom.xml b/cps/cps-rest/pom.xml index 0e8317b622..bd9be8dfde 100644 --- a/cps/cps-rest/pom.xml +++ b/cps/cps-rest/pom.xml @@ -24,6 +24,11 @@ </dependency>
<dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-multipart</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
<exclusions>
@@ -39,6 +44,7 @@ <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
+
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
diff --git a/cps/cps-rest/src/main/java/org/onap/cps/rest/config/JerseyConfig.java b/cps/cps-rest/src/main/java/org/onap/cps/rest/config/JerseyConfig.java index a7c4307ab5..44487fe068 100644 --- a/cps/cps-rest/src/main/java/org/onap/cps/rest/config/JerseyConfig.java +++ b/cps/cps-rest/src/main/java/org/onap/cps/rest/config/JerseyConfig.java @@ -22,8 +22,9 @@ package org.onap.cps.rest.config; import javax.annotation.PostConstruct;
import javax.ws.rs.ApplicationPath;
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
-import org.onap.cps.rest.controller.ModelController;
+import org.onap.cps.rest.controller.RestController;
import org.springframework.context.annotation.Configuration;
@Configuration
@@ -32,6 +33,7 @@ public class JerseyConfig extends ResourceConfig { @PostConstruct
public void init() {
- register(ModelController.class);
+ register(RestController.class);
+ register(MultiPartFeature.class);
}
}
\ No newline at end of file diff --git a/cps/cps-rest/src/main/java/org/onap/cps/rest/controller/RestController.java b/cps/cps-rest/src/main/java/org/onap/cps/rest/controller/RestController.java new file mode 100644 index 0000000000..d2f1a3e037 --- /dev/null +++ b/cps/cps-rest/src/main/java/org/onap/cps/rest/controller/RestController.java @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.rest.controller; + +import java.io.File; +import java.io.IOException; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import org.glassfish.jersey.media.multipart.FormDataParam; +import org.onap.cps.api.CPService; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.parser.api.YangParserException; +import org.springframework.beans.factory.annotation.Autowired; + + +@Path("cps") +public class RestController { + + @Autowired + private CPService cpService; + + @POST + @Path("uploadYangFile") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.MULTIPART_FORM_DATA) + public Response uploadFile(@FormDataParam("file") File uploadedFile) throws IOException { + try { + File fileToParse = renameFileIfNeeded(uploadedFile); + SchemaContext schemaContext = cpService.parseAndValidateModel(fileToParse); + cpService.storeSchemaContext(schemaContext); + return Response.status(Status.OK).entity("Yang File Parsed").build(); + } catch (YangParserException e) { + return Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build(); + } + } + + private static File renameFileIfNeeded(File originalFile) { + if (originalFile.getName().endsWith(".yang")) { + return originalFile; + } + File renamedFile = new File(originalFile.getName() + ".yang"); + originalFile.renameTo(renamedFile); + return renamedFile; + } +} + + + + diff --git a/cps/cps-ri/pom.xml b/cps/cps-ri/pom.xml index 0d6dcace4a..781f8e8326 100644 --- a/cps/cps-ri/pom.xml +++ b/cps/cps-ri/pom.xml @@ -1,43 +1,48 @@ <project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.cps</groupId>
- <artifactId>cps</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>cps-ri</artifactId>
-
- <dependencies>
-
- <dependency>
- <groupId>org.onap.cps</groupId>
- <artifactId>cps-service</artifactId>
- <version>${project.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-validation</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.mariadb.jdbc</groupId>
- <artifactId>mariadb-java-client</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- </dependency>
-
- </dependencies>
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.cps</groupId>
+ <artifactId>cps</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>cps-ri</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.onap.cps</groupId>
+ <artifactId>cps-service</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-validation</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
+
+ <dependency>
+ <!-- Provides mariadb object mapping to an entity -->
+ <groupId>jakarta.persistence</groupId>
+ <artifactId>jakarta.persistence-api</artifactId>
+ </dependency>
+
+ </dependencies>
</project>
\ No newline at end of file diff --git a/cps/cps-ri/src/main/java/org/onap/cps/spi/dummy.txt b/cps/cps-ri/src/main/java/org/onap/cps/spi/dummy.txt deleted file mode 100644 index ff2b9f30c3..0000000000 --- a/cps/cps-ri/src/main/java/org/onap/cps/spi/dummy.txt +++ /dev/null @@ -1 +0,0 @@ -Have a good day !
\ No newline at end of file diff --git a/cps/cps-ri/src/main/java/org/onap/cps/spi/impl/ModelPersistencyServiceImpl.java b/cps/cps-ri/src/main/java/org/onap/cps/spi/impl/ModelPersistencyServiceImpl.java new file mode 100644 index 0000000000..6e718c8c6b --- /dev/null +++ b/cps/cps-ri/src/main/java/org/onap/cps/spi/impl/ModelPersistencyServiceImpl.java @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.impl; + + +import org.onap.cps.spi.impl.entities.ModuleEntity; +import org.onap.cps.spi.ModelPersistencyService; +import org.onap.cps.spi.repository.ModuleRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class ModelPersistencyServiceImpl implements ModelPersistencyService { + + + private final ModuleRepository moduleRepository; + + @Autowired + public ModelPersistencyServiceImpl(final ModuleRepository moduleRepository) { + this.moduleRepository = moduleRepository; + } + + @Override + public void storeModule(final String name, final String moduleContent, final String revision) { + final ModuleEntity moduleEntity = new ModuleEntity(name, moduleContent, revision); + moduleRepository.save(moduleEntity); + + } +} diff --git a/cps/cps-ri/src/main/java/org/onap/cps/spi/impl/entities/ModuleEntity.java b/cps/cps-ri/src/main/java/org/onap/cps/spi/impl/entities/ModuleEntity.java new file mode 100644 index 0000000000..be3dfefefc --- /dev/null +++ b/cps/cps-ri/src/main/java/org/onap/cps/spi/impl/entities/ModuleEntity.java @@ -0,0 +1,63 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.impl.entities; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + + +/** + * Entity to store a yang module. + */ +@Getter +@Setter +@Entity +@AllArgsConstructor +@NoArgsConstructor +@Table(name = "modules") +public class ModuleEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column + private String name; + + @Column + private String moduleContent; + + @Column + private String revision; + + public ModuleEntity(String name, String moduleContent, String revision) { + this.name = name; + this.moduleContent = moduleContent; + this.revision = revision; + } +}
\ No newline at end of file diff --git a/cps/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java b/cps/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java new file mode 100644 index 0000000000..84441cbf7e --- /dev/null +++ b/cps/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java @@ -0,0 +1,30 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.repository; + + +import org.onap.cps.spi.impl.entities.ModuleEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ModuleRepository extends JpaRepository<ModuleEntity, Integer> { + +}
\ No newline at end of file diff --git a/cps/cps-service/pom.xml b/cps/cps-service/pom.xml index a0bf49767c..844539410c 100644 --- a/cps/cps-service/pom.xml +++ b/cps/cps-service/pom.xml @@ -1,4 +1,6 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.cps</groupId>
@@ -7,36 +9,49 @@ </parent>
<artifactId>cps-service</artifactId>
- <properties>
- <org.opendaylight.yangtools.version>5.0.5</org.opendaylight.yangtools.version>
- </properties>
-
<dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-parser-api</artifactId>
- <version>${org.opendaylight.yangtools.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-parser-impl</artifactId>
- <version>${org.opendaylight.yangtools.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-util</artifactId>
- <version>${org.opendaylight.yangtools.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-codec-xml</artifactId>
- <version>${org.opendaylight.yangtools.version}</version>
- </dependency>
-
- </dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-parser-api</artifactId>
+ <version>${org.opendaylight.yangtools.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-parser-impl</artifactId>
+ <version>${org.opendaylight.yangtools.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-model-util</artifactId>
+ <version>${org.opendaylight.yangtools.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-codec-xml</artifactId>
+ <version>${org.opendaylight.yangtools.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
+
+ <dependency>
+ <!-- For logging -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <!-- For dependency injection -->
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+
+ </dependencies>
</project>
\ No newline at end of file diff --git a/cps/cps-service/src/main/java/org/onap/cps/api/CPService.java b/cps/cps-service/src/main/java/org/onap/cps/api/CPService.java new file mode 100644 index 0000000000..51622c3b0e --- /dev/null +++ b/cps/cps-service/src/main/java/org/onap/cps/api/CPService.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.api; + +import java.io.File; +import java.io.IOException; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.parser.api.YangParserException; + +/** + * Configuration and persistency service interface which holds methods for parsing and storing yang models and data. + */ +public interface CPService { + + /** + * Parse and validate a string representing a yang model to generate a schema context. + * + * @param yangModelContent the input stream + * @return the schema context + */ + SchemaContext parseAndValidateModel(final String yangModelContent) throws IOException, YangParserException; + + /** + * Parse and validate a file representing a yang model to generate a schema context. + * + * @param yangModelFile the yang file + * @return the schema context + */ + SchemaContext parseAndValidateModel(final File yangModelFile) throws IOException, YangParserException; + + /** + * Store schema context for a yang model. + * + * @param schemaContext the schema context + */ + void storeSchemaContext(final SchemaContext schemaContext); + +} diff --git a/cps/cps-service/src/main/java/org/onap/cps/api/dummy.txt b/cps/cps-service/src/main/java/org/onap/cps/api/dummy.txt deleted file mode 100644 index ff2b9f30c3..0000000000 --- a/cps/cps-service/src/main/java/org/onap/cps/api/dummy.txt +++ /dev/null @@ -1 +0,0 @@ -Have a good day !
\ No newline at end of file diff --git a/cps/cps-service/src/main/java/org/onap/cps/api/impl/CPServiceImpl.java b/cps/cps-service/src/main/java/org/onap/cps/api/impl/CPServiceImpl.java new file mode 100644 index 0000000000..5bd6e44906 --- /dev/null +++ b/cps/cps-service/src/main/java/org/onap/cps/api/impl/CPServiceImpl.java @@ -0,0 +1,89 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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.api.impl; + + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Iterator; +import java.util.ServiceLoader; +import org.onap.cps.api.CPService; +import org.onap.cps.spi.ModelPersistencyService; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.parser.api.YangParser; +import org.opendaylight.yangtools.yang.model.parser.api.YangParserException; +import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory; +import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode; +import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class CPServiceImpl implements CPService { + + private final static Logger LOGGER = LoggerFactory.getLogger(CPServiceImpl.class); + + private static final YangParserFactory PARSER_FACTORY; + + static { + final Iterator<YangParserFactory> it = + ServiceLoader.load(YangParserFactory.class).iterator(); + if (!it.hasNext()) { + throw new IllegalStateException("No YangParserFactory found"); + } + PARSER_FACTORY = it.next(); + } + + @Autowired + private ModelPersistencyService modelPersistencyService; + + @Override + public SchemaContext parseAndValidateModel(final String yangModelContent) + throws IOException, YangParserException { + final File tempFile = File.createTempFile("yang", ".yang"); + try (BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile))) { + writer.write(yangModelContent); + } catch (IOException e) { + LOGGER.error("Unable to write to temporary file {}", e.getMessage()); + } + return parseAndValidateModel(tempFile); + } + + @Override + public SchemaContext parseAndValidateModel(final File yangModelFile) throws IOException, YangParserException { + final YangTextSchemaSource yangTextSchemaSource = YangTextSchemaSource.forFile(yangModelFile); + final YangParser yangParser = PARSER_FACTORY.createParser(StatementParserMode.DEFAULT_MODE); + yangParser.addSource(yangTextSchemaSource); + return yangParser.buildEffectiveModel(); + } + + @Override + public void storeSchemaContext(final SchemaContext schemaContext) { + for (final Module module : schemaContext.getModules()) { + modelPersistencyService.storeModule(module.getName(), module.toString(), + module.getRevision().toString()); + } + } +} diff --git a/cps/cps-service/src/main/java/org/onap/cps/spi/ModelPersistencyService.java b/cps/cps-service/src/main/java/org/onap/cps/spi/ModelPersistencyService.java new file mode 100644 index 0000000000..e0286c1b2f --- /dev/null +++ b/cps/cps-service/src/main/java/org/onap/cps/spi/ModelPersistencyService.java @@ -0,0 +1,35 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 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; + +/** + * Defines methods to access and manipulate data using the chosen database solution. + */ +public interface ModelPersistencyService { + + /** + * Store the module from a yang model in the database. + * @param name + * @param moduleContent + * @param revision + */ + void storeModule(final String name, final String moduleContent, final String revision); + +} diff --git a/cps/cps-service/src/main/java/org/onap/cps/spi/dummy.txt b/cps/cps-service/src/main/java/org/onap/cps/spi/dummy.txt deleted file mode 100644 index ff2b9f30c3..0000000000 --- a/cps/cps-service/src/main/java/org/onap/cps/spi/dummy.txt +++ /dev/null @@ -1 +0,0 @@ -Have a good day !
\ No newline at end of file diff --git a/cps/pom.xml b/cps/pom.xml index 94ed29c077..1c1b2b1515 100644 --- a/cps/pom.xml +++ b/cps/pom.xml @@ -1,115 +1,114 @@ <project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.oparent</groupId>
- <artifactId>oparent</artifactId>
- <version>3.1.0</version>
- </parent>
- <groupId>org.onap.cps</groupId>
- <artifactId>cps</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>pom</packaging>
- <name>cps</name>
- <description>ONAP Configuration and Persistency Service</description>
- <organization>
- <name>ONAP - CPS</name>
- <url>http://www.onap.org/</url>
- </organization>
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>3.1.0</version>
+ </parent>
+ <groupId>org.onap.cps</groupId>
+ <artifactId>cps</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>cps</name>
+ <description>ONAP Configuration and Persistency Service</description>
+ <organization>
+ <name>ONAP - CPS</name>
+ <url>http://www.onap.org/</url>
+ </organization>
- <properties>
- <version.java.compiler>11</version.java.compiler>
- <springboot.version>2.3.3.RELEASE</springboot.version>
- <onap.logging.version>1.6.7</onap.logging.version>
- <oparent.version>3.1.0</oparent.version>
- </properties>
+ <properties>
+ <version.java.compiler>11</version.java.compiler>
+ <springboot.version>2.3.3.RELEASE</springboot.version>
+ <oparent.version>3.1.0</oparent.version>
+ <org.opendaylight.yangtools.version>5.0.5</org.opendaylight.yangtools.version>
+ </properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>${springboot.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${springboot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
- <build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
- <resource>
- <directory>target/generated-sources/license</directory>
- <includes>
- <include>third-party-licenses.txt</include>
- </includes>
- </resource>
+ <resource>
+ <directory>target/generated-sources/license</directory>
+ <includes>
+ <include>third-party-licenses.txt</include>
+ </includes>
+ </resource>
- <resource>
- <directory>target/generated-resources/licenses</directory>
- <includes>
- <include>*.*</include>
- </includes>
- <targetPath>third-party-licenses</targetPath>
- </resource>
- </resources>
+ <resource>
+ <directory>target/generated-resources/licenses</directory>
+ <includes>
+ <include>*.*</include>
+ </includes>
+ <targetPath>third-party-licenses</targetPath>
+ </resource>
+ </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>${version.java.compiler}</source>
- <target>${version.java.compiler}</target>
- </configuration>
- </plugin>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${version.java.compiler}</source>
+ <target>${version.java.compiler}</target>
+ </configuration>
+ </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <executions>
- <execution>
- <id>onap-java-style</id>
- <goals>
- <goal>check</goal>
- </goals>
- <phase>process-sources</phase>
- <configuration>
- <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
- <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
- <includeResources>true</includeResources>
- <includeTestSourceDirectory>true</includeTestSourceDirectory>
- <includeTestResources>true</includeTestResources>
- <consoleOutput>true</consoleOutput>
- <violationSeverity>warning</violationSeverity>
- <failsOnViolation>true</failsOnViolation>
- </configuration>
- </execution>
- </executions>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>onap-java-style</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <phase>process-sources</phase>
+ <configuration>
+ <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
+ <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
+ <includeResources>true</includeResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ <includeTestResources>true</includeTestResources>
+ <consoleOutput>true</consoleOutput>
+ <violationSeverity>warning</violationSeverity>
+ <failsOnViolation>true</failsOnViolation>
+ </configuration>
+ </execution>
+ </executions>
- <dependencies>
- <dependency>
- <groupId>org.onap.oparent</groupId>
- <artifactId>checkstyle</artifactId>
- <version>${oparent.version}</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>checkstyle</artifactId>
+ <version>${oparent.version}</version>
+ </dependency>
+ </dependencies>
- </plugin>
- </plugins>
- </build>
+ </plugin>
+ </plugins>
+ </build>
- <modules>
- <module>cps-service</module>
- <module>cps-rest</module>
- <module>cps-ri</module>
- </modules>
+ <modules>
+ <module>cps-service</module>
+ <module>cps-rest</module>
+ <module>cps-ri</module>
+ </modules>
</project>
\ No newline at end of file |