From 7f6c527bac8c0c60a2988e59ff7251178f904cdd 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 +++++++++++ .../service/BluePrintCoreConfiguration.kt | 60 --------- .../service/BluePrintRepoServiceImpl.kt | 11 ++ .../ControllerBluePrintCoreConfiguration.kt | 60 +++++++++ .../service/load/BluePrintCatalogServiceImpl.kt | 135 --------------------- .../service/load/BluePrintDatabaseLoadService.kt | 1 + .../service/load/BluePrintLoadConfiguration.kt | 34 ------ .../load/ControllerBlueprintCatalogServiceImpl.kt | 86 +++++++++++++ .../ControllerBlueprintModelContentRepository.kt | 22 ++++ .../ControllerBlueprintModelRepository.kt | 21 ++++ .../validator/BluePrintTypeValidatorServiceImpl.kt | 66 ---------- .../validator/BluePrintValidatorDefaultService.kt | 103 ---------------- 17 files changed, 287 insertions(+), 714 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 delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt delete mode 100755 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt create mode 100755 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt (limited to 'ms/controllerblueprints/modules/service/src/main') 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 ba27742af..ca0e24393 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 d16f1b135..000000000 --- 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 7940c9447..000000000 --- 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 413160498..000000000 --- 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 ed863563a..000000000 --- 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 000000000..343f8c67b --- /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); +} diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt deleted file mode 100644 index 2e5fc5ba3..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt +++ /dev/null @@ -1,60 +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 - -import org.onap.ccsdk.apps.controllerblueprints.service.load.BluePrintLoadConfiguration -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.context.properties.bind.Bindable -import org.springframework.boot.context.properties.bind.Binder -import org.springframework.boot.context.properties.source.ConfigurationPropertySources -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.core.env.Environment -import org.springframework.stereotype.Service - -@Configuration -open class BluePrintCoreConfiguration(private val bluePrintProperties: BluePrintProperties) { - - companion object { - const val PREFIX_BLUEPRINT_LOAD_CONFIGURATION = "controllerblueprints" - } - - @Bean - open fun bluePrintLoadConfiguration(): BluePrintLoadConfiguration { - return bluePrintProperties - .propertyBeanType(PREFIX_BLUEPRINT_LOAD_CONFIGURATION, BluePrintLoadConfiguration::class.java) - } -} - -@Configuration -open class BlueprintPropertyConfiguration { - @Autowired - lateinit var environment: Environment - - @Bean - open fun bluePrintPropertyBinder(): Binder { - val configurationPropertySource = ConfigurationPropertySources.get(environment) - return Binder(configurationPropertySource) - } -} - -@Service -open class BluePrintProperties(var bluePrintPropertyBinder: Binder) { - fun propertyBeanType(prefix: String, type: Class): T { - return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get() - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt index c818410f7..f856b9efe 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt @@ -24,10 +24,21 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository import org.springframework.stereotype.Service +// Resource Dictionary Validation Services + +@Service +class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl() + +@Service +class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService) + : ResourceDefinitionValidationServiceImpl(bluePrintRepoService) + interface ResourceDefinitionRepoService : BluePrintRepoService { @Throws(BluePrintException::class) diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt new file mode 100644 index 000000000..2c4ee746a --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt @@ -0,0 +1,60 @@ +/* + * 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 + +import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.context.properties.bind.Bindable +import org.springframework.boot.context.properties.bind.Binder +import org.springframework.boot.context.properties.source.ConfigurationPropertySources +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.core.env.Environment +import org.springframework.stereotype.Service + +@Configuration +open class ControllerBluePrintCoreConfiguration(private val bluePrintProperties: ControllerBlueprintProperties) { + + companion object { + const val PREFIX_BLUEPRINT_LOAD_CONFIGURATION = "controllerblueprints" + } + + @Bean + open fun controlelrBlueprintLoadConfiguration(): BluePrintLoadConfiguration { + return bluePrintProperties + .propertyBeanType(PREFIX_BLUEPRINT_LOAD_CONFIGURATION, BluePrintLoadConfiguration::class.java) + } +} + +@Configuration +open class ControllerBlueprintPropertyConfiguration { + @Autowired + lateinit var environment: Environment + + @Bean + open fun controllerBluePrintPropertyBinder(): Binder { + val configurationPropertySource = ConfigurationPropertySources.get(environment) + return Binder(configurationPropertySource) + } +} + +@Service +open class ControllerBlueprintProperties(var bluePrintPropertyBinder: Binder) { + fun propertyBeanType(prefix: String, type: Class): T { + return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get() + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt deleted file mode 100755 index 761dd25a3..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt +++ /dev/null @@ -1,135 +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.load - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -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 org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConstants -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent -import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelContentRepository -import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelRepository -import org.springframework.stereotype.Service -import java.io.File -import java.nio.file.Files - -@Service -class BluePrintCatalogServiceImpl(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, - private val bluePrintValidatorService: BluePrintValidatorService, - private val blueprintModelContentRepository: BlueprintModelContentRepository, - private val blueprintModelRepository: BlueprintModelRepository) : BluePrintCatalogService { - - override fun uploadToDataBase(file: String, validate: Boolean): String { - // The file name provided here is unique as we transform to UUID before storing - val blueprintFile = File(file) - val fileName = blueprintFile.name - val id = BluePrintFileUtils.stripFileExtension(fileName) - // If the file is directory - if (blueprintFile.isDirectory) { - - val zipFile = File("${bluePrintLoadConfiguration.blueprintArchivePath}/$fileName") - // zip the directory - BluePrintArchiveUtils.compress(blueprintFile, zipFile, true) - - // Upload to the Data Base - saveToDataBase(blueprintFile, id, zipFile) - - // After Upload to Database delete the zip file - zipFile.delete() - - } else { - // If the file is ZIP - // unzip the CBA file to validate before store in database - val targetDir = "${bluePrintLoadConfiguration.blueprintDeployPath}/$id/" - val extractedDirectory = BluePrintArchiveUtils.deCompress(blueprintFile, targetDir) - - // Upload to the Data Base - saveToDataBase(extractedDirectory, id, blueprintFile) - - // After Upload to Database delete the zip file - blueprintFile.delete() - extractedDirectory.delete() - } - - return id - } - - override fun downloadFromDataBase(name: String, version: String, path: String): String { - // If path ends with zip, then compress otherwise download as extracted folder - - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun downloadFromDataBase(uuid: String, path: String): String { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun prepareBluePrint(name: String, version: String): String { - val preparedPath = "${bluePrintLoadConfiguration.blueprintDeployPath}/$name/$version" - downloadFromDataBase(name, version, preparedPath) - return preparedPath - } - - private fun saveToDataBase(extractedDirectory: File, id: String, archiveFile: File, checkValidity: Boolean? = false) { - // Upload to the Data Base - //val id = "save-$uuid" - var valid = false - val firstItem = BluePrintArchiveUtils.getFirstItemInDirectory(extractedDirectory) - val blueprintBaseDirectory = extractedDirectory.absolutePath + "/" + firstItem - // Validate Blueprint - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(id, blueprintBaseDirectory) - - // Check Validity of blueprint - if (checkValidity!!) { - valid = bluePrintValidatorService.validateBluePrints(bluePrintRuntimeService) - } - - if ((valid && checkValidity!!) || (!valid && !checkValidity!!)) { - val metaData = bluePrintRuntimeService.bluePrintContext().metadata!! - // FIXME("Check Duplicate for Artifact Name and Artifact Version") - val blueprintModel = BlueprintModel() - blueprintModel.id = id - blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL - blueprintModel.published = ApplicationConstants.ACTIVE_N - blueprintModel.artifactName = metaData[BluePrintConstants.METADATA_TEMPLATE_NAME] - blueprintModel.artifactVersion = metaData[BluePrintConstants.METADATA_TEMPLATE_VERSION] - blueprintModel.updatedBy = metaData[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] - blueprintModel.tags = metaData[BluePrintConstants.METADATA_TEMPLATE_TAGS] - blueprintModel.artifactDescription = "Controller Blueprint for ${blueprintModel.artifactName}:${blueprintModel.artifactVersion}" - - val blueprintModelContent = BlueprintModelContent() - blueprintModelContent.id = id // For quick access both id's are same.always have one to one mapping. - blueprintModelContent.contentType = "CBA_ZIP" - blueprintModelContent.name = "${blueprintModel.artifactName}:${blueprintModel.artifactVersion}" - blueprintModelContent.description = "(${blueprintModel.artifactName}:${blueprintModel.artifactVersion} CBA Zip Content" - blueprintModelContent.content = Files.readAllBytes(archiveFile.toPath()) - - // Set the Blueprint Model into blueprintModelContent - blueprintModelContent.blueprintModel = blueprintModel - - // Set the Blueprint Model Content into blueprintModel - blueprintModel.blueprintModelContent = blueprintModelContent - - blueprintModelRepository.saveAndFlush(blueprintModel) - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt index eeea97c9b..8b6e54af9 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.load import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.context.event.EventListener import org.springframework.stereotype.Service diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt deleted file mode 100644 index cf36a3e5a..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt +++ /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.load - -open class BluePrintLoadConfiguration { - - lateinit var blueprintDeployPath: String - lateinit var blueprintArchivePath: String - lateinit var blueprintEnrichmentPath: String - - var loadInitialData: Boolean = false - var loadBluePrint: Boolean = false - var loadBluePrintPaths: String? = null - - var loadModelType: Boolean = false - var loadModeTypePaths: String? = null - - var loadResourceDictionary: Boolean = false - var loadResourceDictionaryPaths: String? = null -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt new file mode 100755 index 000000000..ac81f8fa6 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt @@ -0,0 +1,86 @@ +/* + * 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.load + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.common.ApplicationConstants +import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration +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.BluePrintMetadataUtils +import org.onap.ccsdk.apps.controllerblueprints.db.resources.BlueprintCatalogServiceImpl +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelContentRepository +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelRepository +import org.springframework.stereotype.Service +import java.io.File +import java.nio.file.Files + +/** +Similar implementation in [org.onap.ccsdk.apps.blueprintsprocessor.db.BlueprintProcessorCatalogServiceImpl] + */ +@Service +class ControllerBlueprintCatalogServiceImpl(bluePrintLoadConfiguration: BluePrintLoadConfiguration, + private val bluePrintValidatorService: BluePrintValidatorService, + private val blueprintModelContentRepository: ControllerBlueprintModelContentRepository, + private val blueprintModelRepository: ControllerBlueprintModelRepository) + : BlueprintCatalogServiceImpl(bluePrintLoadConfiguration) { + + override fun saveToDataBase(extractedDirectory: File, id: String, archiveFile: File, checkValidity: Boolean?) { + var valid = false + val firstItem = BluePrintArchiveUtils.getFirstItemInDirectory(extractedDirectory) + val blueprintBaseDirectory = extractedDirectory.absolutePath + "/" + firstItem + // Validate Blueprint + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(id, blueprintBaseDirectory) + + // Check Validity of blueprint + if (checkValidity!!) { + valid = bluePrintValidatorService.validateBluePrints(bluePrintRuntimeService) + } + + if ((valid && checkValidity!!) || (!valid && !checkValidity!!)) { + val metaData = bluePrintRuntimeService.bluePrintContext().metadata!! + // FIXME("Check Duplicate for Artifact Name and Artifact Version") + val blueprintModel = BlueprintModel() + blueprintModel.id = id + blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL + blueprintModel.published = ApplicationConstants.ACTIVE_N + blueprintModel.artifactName = metaData[BluePrintConstants.METADATA_TEMPLATE_NAME] + blueprintModel.artifactVersion = metaData[BluePrintConstants.METADATA_TEMPLATE_VERSION] + blueprintModel.updatedBy = metaData[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] + blueprintModel.tags = metaData[BluePrintConstants.METADATA_TEMPLATE_TAGS] + blueprintModel.artifactDescription = "Controller Blueprint for ${blueprintModel.artifactName}:${blueprintModel.artifactVersion}" + + val blueprintModelContent = BlueprintModelContent() + blueprintModelContent.id = id // For quick access both id's are same.always have one to one mapping. + blueprintModelContent.contentType = "CBA_ZIP" + blueprintModelContent.name = "${blueprintModel.artifactName}:${blueprintModel.artifactVersion}" + blueprintModelContent.description = "(${blueprintModel.artifactName}:${blueprintModel.artifactVersion} CBA Zip Content" + blueprintModelContent.content = Files.readAllBytes(archiveFile.toPath()) + + // Set the Blueprint Model into blueprintModelContent + blueprintModelContent.blueprintModel = blueprintModel + + // Set the Blueprint Model Content into blueprintModel + blueprintModel.blueprintModelContent = blueprintModelContent + + blueprintModelRepository.saveAndFlush(blueprintModel) + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt new file mode 100644 index 000000000..7cda72763 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt @@ -0,0 +1,22 @@ +/* + * Copyright (C) 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.db.resources.repository.ModelContentRepository +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent + +interface ControllerBlueprintModelContentRepository : ModelContentRepository diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt new file mode 100644 index 000000000..ec1175072 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 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.db.resources.repository.ModelRepository +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel + +interface ControllerBlueprintModelRepository : ModelRepository diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt deleted file mode 100644 index 9d4797ff9..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt +++ /dev/null @@ -1,66 +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.validator - -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.* -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.context.ApplicationContext -import org.springframework.stereotype.Service - -@Service -class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService { - - @Autowired - private lateinit var context: ApplicationContext - - override fun getServiceTemplateValidators(): List { - return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value } - } - - override fun getDataTypeValidators(): List { - return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value } - } - - override fun getArtifactTypeValidators(): List { - return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value } - } - - override fun getNodeTypeValidators(): List { - return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value } - } - - override fun getTopologyTemplateValidators(): List { - return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value } - } - - override fun getNodeTemplateValidators(): List { - return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value } - } - - override fun getWorkflowValidators(): List { - return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value } - } - - override fun getPropertyDefinitionValidators(): List { - return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value } - } - - override fun getAttributeDefinitionValidators(): List { - return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value } - } -} - diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt deleted file mode 100644 index 89f4d9e38..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt +++ /dev/null @@ -1,103 +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.validator - -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils -import org.onap.ccsdk.apps.controllerblueprints.core.validation.* -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl -import org.springframework.stereotype.Service -import java.util.* - -@Service -class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintValidatorService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) - - override fun validateBluePrints(basePath: String): Boolean { - - log.info("validating blueprint($basePath)") - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath) - return validateBluePrints(bluePrintRuntimeService) - } - - override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean { - - bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template", - bluePrintRuntimeService.bluePrintContext().serviceTemplate) - - if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) { - throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}") - } - return true - } -} - -// Core Validator Services - -@Service -class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaulBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService) - -// Resource Dictionary Validation Services - -@Service -class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl() - -@Service -class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService) - : ResourceDefinitionValidationServiceImpl(bluePrintRepoService) \ No newline at end of file -- cgit 1.2.3-korg