From 3ce735a660cd4d387affe1e301471d3bd765e21c Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 7 Jan 2019 16:33:02 -0500 Subject: Add support for blueprintprocessor runtime DB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - created db-resources module to store controller blueprint related controller blueprint repository and entities. Also create an abstract BlueprintCatalogServiceImpl so it can be used both by controllerblueprint and blueprintprocessor - created blueprint-validation to store the implementation of the validation interface. - change controllerblueprint service to levrage db-resources - implement CatalogService for blueprintprocessor db-lib by using db-resources. Change-Id: I0539e414e4ff3b7a6edf0f6304d6cbc5e6eac404 Issue-ID: CCSDK-664 Signed-off-by: Alexis de Talhouët --- .../service/BlueprintModelService.java | 32 ++++--- .../service/common/ApplicationConstants.java | 34 ------- .../BlueprintModelContentRepository.java | 102 --------------------- .../repository/BlueprintModelRepository.java | 96 ------------------- .../repository/BlueprintModelSearchRepository.java | 69 -------------- .../ControllerBlueprintModelSearchRepository.java | 69 ++++++++++++++ 6 files changed, 86 insertions(+), 316 deletions(-) delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java create mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java (limited to 'ms/controllerblueprints/modules/service/src/main/java') diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java index ba27742a..ca0e2439 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java @@ -21,14 +21,14 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import org.jetbrains.annotations.NotNull; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration; import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService; import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils; import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel; import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch; -import org.onap.ccsdk.apps.controllerblueprints.service.load.BluePrintLoadConfiguration; -import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelContentRepository; -import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelRepository; -import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelSearchRepository; +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelContentRepository; +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelRepository; +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelSearchRepository; import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; @@ -65,17 +65,17 @@ public class BlueprintModelService { private BluePrintCatalogService bluePrintCatalogService; @Autowired - private BlueprintModelSearchRepository blueprintModelSearchRepository; + private ControllerBlueprintModelSearchRepository blueprintModelSearchRepository; @Autowired - private BlueprintModelRepository blueprintModelRepository; + private ControllerBlueprintModelRepository blueprintModelRepository; @Autowired - private BlueprintModelContentRepository blueprintModelContentRepository; + private ControllerBlueprintModelContentRepository blueprintModelContentRepository; private static final String BLUEPRINT_MODEL_ID_FAILURE_MSG = "failed to get blueprint model id(%d) from repo"; private static final String BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG = "failed to get blueprint model by name(%d)" + - " and version(%d) from repo"; + " and version(%d) from repo"; /** * This is a saveBlueprintModel method @@ -86,10 +86,12 @@ public class BlueprintModelService { */ public Mono saveBlueprintModel(FilePart filePart) throws BluePrintException { try { - Path cbaLocation = BluePrintFileUtils.Companion.getCbaStorageDirectory(bluePrintLoadConfiguration.blueprintArchivePath); + Path cbaLocation = BluePrintFileUtils.Companion + .getCbaStorageDirectory(bluePrintLoadConfiguration.blueprintArchivePath); return BluePrintEnhancerUtils.Companion.saveCBAFile(filePart, cbaLocation).map(fileName -> { - String blueprintId = bluePrintCatalogService.uploadToDataBase(cbaLocation.resolve(fileName).toString(), false); - return blueprintModelSearchRepository.findById(blueprintId).get(); + String blueprintId = bluePrintCatalogService + .uploadToDataBase(cbaLocation.resolve(fileName).toString(), false); + return blueprintModelSearchRepository.findById(blueprintId).get(); }); } catch (IOException | BluePrintException e) { @@ -122,14 +124,15 @@ public class BlueprintModelService { /** * This is a getBlueprintModelByNameAndVersion method * - * @param name name + * @param name name * @param version version * @return BlueprintModelSearch */ - public BlueprintModelSearch getBlueprintModelByNameAndVersion(@NotNull String name, @NotNull String version) throws BluePrintException { + public BlueprintModelSearch getBlueprintModelByNameAndVersion(@NotNull String name, @NotNull String version) + throws BluePrintException { BlueprintModelSearch blueprintModelSearch; Optional dbBlueprintModel = blueprintModelSearchRepository - .findByArtifactNameAndArtifactVersion(name, version); + .findByArtifactNameAndArtifactVersion(name, version); if (dbBlueprintModel.isPresent()) { blueprintModelSearch = dbBlueprintModel.get(); } else { @@ -142,7 +145,6 @@ public class BlueprintModelService { /** * This is a downloadBlueprintModelFile method to find the target file to download and return a file resource using MONO * - * @param (id) * @return ResponseEntity */ public ResponseEntity downloadBlueprintModelFile(@NotNull String id) throws BluePrintException { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java deleted file mode 100644 index d16f1b13..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.common; - -/** - * ApplicationConstants.java Purpose: Provide ControllerBluprintsApplication Constant Information - * - * @author Brinda Santh - * @version 1.0 - */ -public final class ApplicationConstants { - public static final String ACTIVE_Y = "Y"; - public static final String ACTIVE_N = "N"; - public static final String ASDC_ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL"; - - private ApplicationConstants() { - - } - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java deleted file mode 100644 index 7940c944..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 Bell Canada. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.repository; - -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import javax.validation.constraints.NotNull; -import java.util.List; -import java.util.Optional; - -/** - * BlueprintModelContentRepository.java Purpose: Provide BlueprintModelContentRepository of Repository - * - * @author Brinda Santh - * @version 1.0 - */ -@Repository -public interface BlueprintModelContentRepository extends JpaRepository { - - /** - * This is a findById method - * - * @param id id - * @return Optional - */ - @NotNull - Optional findById(@NotNull String id); - - /** - * This is a findTopByBlueprintModelAndContentType method - * - * @param blueprintModel blueprintModel - * @param contentType contentType - * @return Optional - */ - @SuppressWarnings("unused") - Optional findTopByBlueprintModelAndContentType(BlueprintModel blueprintModel, String contentType); - - /** - * This is a findByBlueprintModelAndContentType method - * - * @param blueprintModel blueprintModel - * @param contentType contentType - * @return Optional - */ - @SuppressWarnings("unused") - List findByBlueprintModelAndContentType(BlueprintModel blueprintModel, String contentType); - - /** - * This is a findByBlueprintModel method - * - * @param blueprintModel blueprintModel - * @return Optional - */ - @SuppressWarnings("unused") - List findByBlueprintModel(BlueprintModel blueprintModel); - - /** - * This is a findByBlueprintModelAndContentTypeAndName method - * - * @param blueprintModel blueprintModel - * @param contentType contentType - * @param name name - * @return Optional - */ - @SuppressWarnings("unused") - Optional findByBlueprintModelAndContentTypeAndName(BlueprintModel blueprintModel, - String contentType, String name); - - /** - * This is a deleteByMdeleteByBlueprintModelodelName method - * - * @param blueprintModel blueprintModel - */ - void deleteByBlueprintModel(BlueprintModel blueprintModel); - - /** - * This is a deleteById method - * - * @param id id - */ - void deleteById(@NotNull String id); - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java deleted file mode 100644 index 41316049..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 Bell Canada. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.repository; - -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import javax.validation.constraints.NotNull; -import java.util.List; -import java.util.Optional; - -/** - * AsdcArtifactsRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository - * - * @author Brinda Santh - * @version 1.0 - */ -@Repository -public interface BlueprintModelRepository extends JpaRepository { - /** - * This is a findById method - * - * @param id id - * @return Optional - */ - @NotNull - Optional findById(@NotNull String id); - - /** - * This is a findByArtifactNameAndArtifactVersion method - * - * @param artifactName artifactName - * @param artifactVersion artifactVersion - * @return Optional - */ - Optional findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion); - - /** - * This is a findTopByArtifactNameOrderByArtifactIdDesc method - * - * @param artifactName artifactName - * @return Optional - */ - Optional findTopByArtifactNameOrderByArtifactVersionDesc(String artifactName); - - /** - * This is a findTopByArtifactName method - * - * @param artifactName artifactName - * @return Optional - */ - @SuppressWarnings("unused") - List findTopByArtifactName(String artifactName); - - /** - * This is a findByTagsContainingIgnoreCase method - * - * @param tags tags - * @return Optional - */ - List findByTagsContainingIgnoreCase(String tags); - - /** - * This is a deleteByArtifactNameAndArtifactVersion method - * - * @param artifactName artifactName - * @param artifactVersion artifactVersion - */ - @SuppressWarnings("unused") - void deleteByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion); - - /** - * This is a deleteById method - * - * @param id id - */ - @SuppressWarnings("unused") - void deleteById(@NotNull String id); - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java deleted file mode 100644 index ed863563..00000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 Bell Canada. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.repository; - -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import javax.validation.constraints.NotNull; -import java.util.List; -import java.util.Optional; - -/** - * BlueprintModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository - * - * @author Brinda Santh - * @version 1.0 - */ -@Repository -public interface BlueprintModelSearchRepository extends JpaRepository { - - /** - * This is a findById method - * - * @param id id - * @return Optional - */ - @NotNull - Optional findById(@NotNull String id); - - /** - * This is a findAll method - * @return List - */ - @Override - List findAll(); - - /** - * This is a findByArtifactNameAndArtifactVersion method - * - * @param artifactName artifactName - * @param artifactVersion artifactVersion - * @return Optional - */ - Optional findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion); - - /** - * This is a findByTagsContainingIgnoreCase method - * - * @param tags - * @return Optional - */ - List findByTagsContainingIgnoreCase(String tags); -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java new file mode 100644 index 00000000..343f8c67 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java @@ -0,0 +1,69 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2019 Bell Canada. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.repository; + +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Optional; + +/** + * ControllerBlueprintModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository + * + * @author Brinda Santh + * @version 1.0 + */ +@Repository +public interface ControllerBlueprintModelSearchRepository extends JpaRepository { + + /** + * This is a findById method + * + * @param id id + * @return Optional + */ + @NotNull + Optional findById(@NotNull String id); + + /** + * This is a findAll method + * @return List + */ + @Override + List findAll(); + + /** + * This is a findByArtifactNameAndArtifactVersion method + * + * @param artifactName artifactName + * @param artifactVersion artifactVersion + * @return Optional + */ + Optional findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion); + + /** + * This is a findByTagsContainingIgnoreCase method + * + * @param tags + * @return Optional + */ + List findByTagsContainingIgnoreCase(String tags); +} -- cgit 1.2.3-korg