From 72d22a4339db09824d46746dacbba1e141763dc0 Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Tue, 26 Mar 2019 09:49:13 -0400 Subject: Migrate ccdsk/apps to ccsdk/cds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I020a2ccec4e691717f888e8bd2afec91a7c4e987 Issue-ID: CCSDK-1178 Signed-off-by: Alexis de Talhouët --- .../modules/db-resources/pom.xml | 42 ---------- .../db/resources/BlueprintCatalogServiceImpl.kt | 86 -------------------- .../resources/repository/ModelContentRepository.kt | 91 ---------------------- .../db/resources/repository/ModelRepository.kt | 90 --------------------- .../resources/BlueprintCatalogServiceImplTest.kt | 21 ----- 5 files changed, 330 deletions(-) delete mode 100644 ms/controllerblueprints/modules/db-resources/pom.xml delete mode 100644 ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt delete mode 100644 ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt delete mode 100644 ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt delete mode 100644 ms/controllerblueprints/modules/db-resources/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImplTest.kt (limited to 'ms/controllerblueprints/modules/db-resources') diff --git a/ms/controllerblueprints/modules/db-resources/pom.xml b/ms/controllerblueprints/modules/db-resources/pom.xml deleted file mode 100644 index d1c3c44c..00000000 --- a/ms/controllerblueprints/modules/db-resources/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - 4.0.0 - - org.onap.ccsdk.apps.controllerblueprints - modules - 0.4.2-SNAPSHOT - - db-resources - Controller Blueprints DB Resources - - - - - - - org.onap.ccsdk.apps.controllerblueprints - blueprint-core - - - org.springframework.boot - spring-boot-starter-data-jpa - - - diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt deleted file mode 100644 index e4323152..00000000 --- a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 Bell Canada. - * Modifications Copyright © 2019 IBM. - * - * 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.db.resources - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils -import java.io.File -import java.nio.file.Path -import java.util.* -import javax.persistence.MappedSuperclass - -@MappedSuperclass -abstract class BlueprintCatalogServiceImpl(private val blueprintValidator: BluePrintValidatorService) - : BluePrintCatalogService { - - override fun saveToDatabase(blueprintFile: File, validate: Boolean): String { - val extractedDirectory: File - val archivedDirectory: File - val toDeleteDirectory: File - val blueprintId = UUID.randomUUID().toString() - - if (blueprintFile.isDirectory) { - extractedDirectory = blueprintFile - archivedDirectory = File("$blueprintFile.zip") - toDeleteDirectory = archivedDirectory - - if (!BluePrintArchiveUtils.compress(blueprintFile, archivedDirectory, true)) { - throw BluePrintException("Fail to compress blueprint") - } - } else { - val targetDir = "${blueprintFile.parent}/${BluePrintFileUtils.stripFileExtension(blueprintFile.name)}" - - extractedDirectory = BluePrintArchiveUtils.deCompress(blueprintFile, targetDir) - archivedDirectory = blueprintFile - toDeleteDirectory = extractedDirectory - } - - var valid = BluePrintConstants.FLAG_N - if (validate) { - blueprintValidator.validateBluePrints(extractedDirectory.path) - valid = BluePrintConstants.FLAG_Y - } - - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(blueprintId, extractedDirectory.path) - val metadata = bluePrintRuntimeService.bluePrintContext().metadata!! - metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId - metadata[BluePrintConstants.PROPERTY_BLUEPRINT_VALID] = valid - - save(metadata, archivedDirectory) - - toDeleteDirectory.deleteRecursively() - - return blueprintId - } - - override fun getFromDatabase(name: String, version: String, extract: Boolean): Path = get(name, version, extract) - ?: throw BluePrintException("Could not find blueprint $name:$version from database") - - override fun deleteFromDatabase(name: String, version: String) = delete(name, version) - - abstract fun save(metadata: MutableMap, archiveFile: File) - abstract fun get(name: String, version: String, extract: Boolean): Path? - abstract fun delete(name: String, version: String) - -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt deleted file mode 100644 index 680f1b2c..00000000 --- a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt +++ /dev/null @@ -1,91 +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.db.resources.repository - -import org.jetbrains.annotations.NotNull -import java.util.Optional -import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.data.repository.NoRepositoryBean - -/** - * @param Model - * @param ModelContent - */ -@NoRepositoryBean -interface ModelContentRepository : JpaRepository { - - /** - * This is a findById method - * - * @param id id - * @return Optional - */ - @NotNull - override fun findById(@NotNull id: String): Optional - - /** - * This is a findTopByBlueprintModelAndContentType method - * - * @param blueprintModel blueprintModel - * @param contentType contentType - * @return B? - */ - fun findTopByBlueprintModelAndContentType(blueprintModel: T, contentType: String): B? - - /** - * This is a findByBlueprintModelAndContentType method - * - * @param blueprintModel blueprintModel - * @param contentType contentType - * @return List - */ - fun findByBlueprintModelAndContentType(blueprintModel: T, contentType: String): List - - /** - * This is a findByBlueprintModel method - * - * @param blueprintModel T - * @return List - */ - fun findByBlueprintModel(blueprintModel: T): List - - /** - * This is a findByBlueprintModelAndContentTypeAndName method - * - * @param blueprintModel blueprintModel - * @param contentType contentType - * @param name name - * @return B? - */ - fun findByBlueprintModelAndContentTypeAndName(blueprintModel: T, contentType: String, name: String): B? - - /** - * This is a deleteByMdeleteByBlueprintModelodelName method - * - * @param blueprintModel T - */ - fun deleteByBlueprintModel(blueprintModel: T) - - /** - * This is a deleteById method - * - * @param id id - */ - override fun deleteById(@NotNull id: String) - -} diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt deleted file mode 100644 index e796c366..00000000 --- a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt +++ /dev/null @@ -1,90 +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.db.resources.repository - -import org.jetbrains.annotations.NotNull -import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.data.repository.NoRepositoryBean -import java.util.* -import javax.transaction.Transactional - -/** - * @param Model - */ -@NoRepositoryBean -interface ModelRepository : JpaRepository { - - /** - * This is a findById method - * - * @param id id - * @return Optional - */ - @NotNull - override fun findById(@NotNull id: String): Optional - - /** - * This is a findByArtifactNameAndArtifactVersion method - * - * @param artifactName artifactName - * @param artifactVersion artifactVersion - * @return T? - */ - fun findByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String): T? - - /** - * This is a findTopByArtifactNameOrderByArtifactIdDesc method - * - * @param artifactName artifactName - * @return T? - */ - fun findTopByArtifactNameOrderByArtifactVersionDesc(artifactName: String): T? - - /** - * This is a findTopByArtifactName method - * - * @param artifactName artifactName - * @return List - */ - fun findTopByArtifactName(artifactName: String): List - - /** - * This is a findByTagsContainingIgnoreCase method - * - * @param tags tags - * @return List - */ - fun findByTagsContainingIgnoreCase(tags: String): List - - /** - * This is a deleteByArtifactNameAndArtifactVersion method - * - * @param artifactName artifactName - * @param artifactVersion artifactVersion - */ - @Transactional - fun deleteByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String) - - /** - * This is a deleteById method - * - * @param id id - */ - override fun deleteById(@NotNull id: String) - -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/db-resources/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImplTest.kt b/ms/controllerblueprints/modules/db-resources/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImplTest.kt deleted file mode 100644 index 60541c3f..00000000 --- a/ms/controllerblueprints/modules/db-resources/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImplTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright © 2019 Bell Canada - * 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.db.resources - -// TODO -class BlueprintCatalogServiceImplTest \ No newline at end of file -- cgit 1.2.3-korg