diff options
Diffstat (limited to 'openecomp-be')
9 files changed, 30 insertions, 155 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/NonManoArtifactType.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/NonManoArtifactType.java deleted file mode 100644 index bcf697cdbe..0000000000 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/NonManoArtifactType.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 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.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation; - -/** - * Stores non mano artifact types. - */ -public enum NonManoArtifactType { - ONAP_VES_EVENTS("onap_ves_events"), - ONAP_PM_DICTIONARY("onap_pm_dictionary"), - ONAP_YANG_MODULES("onap_yang_modules"), - ONAP_ANSIBLE_PLAYBOOKS("onap_ansible_playbooks"), - ONAP_SCRIPTS("onap_scripts"), - ONAP_OTHERS("onap_others"), - ONAP_SW_INFORMATION("onap_pnf_sw_information"); - - private final String type; - - NonManoArtifactType(final String type) { - this.type = type; - } - - public String getType() { - return type; - } -} diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java index 9481a021e2..b0b8971e71 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidator.java @@ -21,6 +21,8 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation; +import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_PM_DICTIONARY; +import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_VES_EVENTS; import static org.openecomp.sdc.tosca.csar.CSARConstants.CSAR_VERSION_1_0; import static org.openecomp.sdc.tosca.csar.CSARConstants.CSAR_VERSION_1_1; import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_METADATA_LIMIT; @@ -37,8 +39,6 @@ import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSION; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSION_ENTRY; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.NonManoArtifactType.ONAP_PM_DICTIONARY; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.NonManoArtifactType.ONAP_VES_EVENTS; import java.io.IOException; import java.io.InputStream; diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilderTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilderTest.java index 5079ecc0ac..b91a1156ce 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilderTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/ManifestBuilderTest.java @@ -20,16 +20,16 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.emptyString; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.isEmptyString; +import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_PM_DICTIONARY; +import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_VES_EVENTS; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.PNFD_ARCHIVE_VERSION; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.PNFD_NAME; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.PNFD_PROVIDER; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.PNFD_RELEASE_DATE_TIME; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.NonManoArtifactType.ONAP_PM_DICTIONARY; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.NonManoArtifactType.ONAP_VES_EVENTS; import java.io.ByteArrayInputStream; import java.util.Arrays; @@ -53,7 +53,7 @@ public class ManifestBuilderTest { @Test public void givenNoManifestInformation_whenBuildingManifest_thenEmptyStringShouldBeReturned() { final String manifest = manifestBuilder.build(); - assertThat("Manifest should be empty", manifest, isEmptyString()); + assertThat("Manifest should be empty", manifest, is(emptyString())); } @Test diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java index 7ff800d07b..fc05b5ba7b 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/validation/SOL004MetaDirectoryValidatorTest.java @@ -28,6 +28,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_PM_DICTIONARY; +import static org.openecomp.sdc.be.config.NonManoArtifactType.ONAP_VES_EVENTS; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ATTRIBUTE_VALUE_SEPARATOR; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.PNFD_ARCHIVE_VERSION; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.PNFD_NAME; @@ -36,7 +38,6 @@ import static org.openecomp.sdc.tosca.csar.ManifestTokenType.VNF_PACKAGE_VERSION import static org.openecomp.sdc.tosca.csar.ManifestTokenType.VNF_PRODUCT_NAME; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.VNF_PROVIDER_ID; import static org.openecomp.sdc.tosca.csar.ManifestTokenType.VNF_RELEASE_DATE_TIME; -import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CREATED_BY_ENTRY; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.CSAR_VERSION_ENTRY; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS; @@ -46,8 +47,7 @@ import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_LICENSES; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_TESTS; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_FILE_VERSION_ENTRY; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.NonManoArtifactType.ONAP_PM_DICTIONARY; -import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.NonManoArtifactType.ONAP_VES_EVENTS; +import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_NAME; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.EMPTY_YAML_FILE_PATH; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.INVALID_YAML_FILE_PATH; import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.validation.TestConstants.SAMPLE_DEFINITION_FILE_PATH; diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/Configuration.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/Configuration.java deleted file mode 100644 index 77507b58b2..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/Configuration.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi; - -import java.util.Map; - -import lombok.Data; - -@Data -public class Configuration { - private Map<String, NonManoType> nonManoKeyFolderMapping; -} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java index d6b1194b81..671c3be0a8 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java @@ -31,7 +31,6 @@ import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.TOSCA_META_PATH_FILE_N import java.io.IOException; import java.io.InputStream; -import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; @@ -41,11 +40,12 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; import org.apache.commons.collections.MapUtils; -import org.apache.commons.io.IOUtils; import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; -import org.onap.sdc.tosca.parser.utils.YamlToObjectConverter; import org.onap.sdc.tosca.services.YamlUtil; import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.be.config.NonManoConfiguration; +import org.openecomp.sdc.be.config.NonManoConfigurationManager; +import org.openecomp.sdc.be.config.NonManoFolderType; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; @@ -59,20 +59,14 @@ public class ETSIServiceImpl implements ETSIService { private static final Logger LOGGER = LoggerFactory.getLogger(ETSIServiceImpl.class); - private Configuration configuration; + private final NonManoConfiguration nonManoConfiguration; - public ETSIServiceImpl() throws IOException { - final InputStream io = getClass().getClassLoader().getResourceAsStream("nonManoConfig.yaml"); - if (io == null) { - throw new IOException("Non Mano configuration not found"); - } - final String data = IOUtils.toString(io, StandardCharsets.UTF_8); - final YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter(); - configuration = yamlToObjectConverter.convertFromString(data, Configuration.class); + public ETSIServiceImpl() { + nonManoConfiguration = NonManoConfigurationManager.getInstance().getNonManoConfiguration(); } - public ETSIServiceImpl(Configuration configuration) { - this.configuration = configuration; + public ETSIServiceImpl(final NonManoConfiguration nonManoConfiguration) { + this.nonManoConfiguration = nonManoConfiguration; } @Override @@ -102,16 +96,16 @@ public class ETSIServiceImpl implements ETSIService { throw ex; } final Map<String, Path> fromToPathMap = new HashMap<>(); - final Map<String, NonManoType> nonManoKeyFolderMapping = configuration.getNonManoKeyFolderMapping(); + final Map<String, NonManoFolderType> nonManoKeyFolderMapping = nonManoConfiguration.getNonManoKeyFolderMapping(); manifest.getNonManoSources().entrySet().stream() .filter(manifestNonManoSourceEntry -> nonManoKeyFolderMapping.containsKey(manifestNonManoSourceEntry.getKey())) .forEach(manifestNonManoSourceEntry -> { - final NonManoType nonManoType = nonManoKeyFolderMapping.get(manifestNonManoSourceEntry.getKey()); + final NonManoFolderType nonManoFolderType = nonManoKeyFolderMapping.get(manifestNonManoSourceEntry.getKey()); final List<String> nonManoFileList = manifestNonManoSourceEntry.getValue(); final Map<String, Path> actualFromToPathMap = nonManoFileList.stream() .map(nonManoFilePath -> { final Path normalizedFilePath = resolveNonManoFilePath(originalManifestPath, nonManoFilePath); - final Optional<Path> changedPath = updateNonManoPathInHandler(handler, nonManoType, normalizedFilePath); + final Optional<Path> changedPath = updateNonManoPathInHandler(handler, nonManoFolderType, normalizedFilePath); if (changedPath.isPresent()) { final Map<String, Path> fromAndToPathMap = new HashMap<>(); fromAndToPathMap.put(nonManoFilePath, Paths.get(ARTIFACTS_FOLDER).resolve(changedPath.get())); @@ -145,15 +139,15 @@ public class ETSIServiceImpl implements ETSIService { * Updates the non mano file path in the package file handler based on the non mano type. * * @param handler The package file handler - * @param nonManoType The Non Mano type of the file to update + * @param nonManoFolderType The Non Mano type of the file to update * @param nonManoOriginalFilePath The Non Mano file original path * @return The new file path if it was updated in the package file handler, otherwise empty. */ - private Optional<Path> updateNonManoPathInHandler(final FileContentHandler handler, final NonManoType nonManoType, + private Optional<Path> updateNonManoPathInHandler(final FileContentHandler handler, final NonManoFolderType nonManoFolderType, final Path nonManoOriginalFilePath) { final Path fixedSourcePath = fixNonManoPath(nonManoOriginalFilePath); if (handler.containsFile(fixedSourcePath.toString())) { - final Path newNonManoPath = Paths.get(nonManoType.getType(), nonManoType.getLocation() + final Path newNonManoPath = Paths.get(nonManoFolderType.getType(), nonManoFolderType.getLocation() , fixedSourcePath.getFileName().toString()); if (!handler.containsFile(newNonManoPath.toString())) { handler.addFile(newNonManoPath.toString(), handler.remove(fixedSourcePath.toString())); @@ -285,4 +279,8 @@ public class ETSIServiceImpl implements ETSIService { } return io; } + + public NonManoConfiguration getConfiguration() { + return nonManoConfiguration; + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/NonManoType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/NonManoType.java deleted file mode 100644 index e10c102593..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/NonManoType.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019, Nordix Foundation. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi; - - -import lombok.Data; - -@Data -public class NonManoType { - private String location; - private String type; -} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/nonManoConfig.yaml b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/nonManoConfig.yaml deleted file mode 100644 index 4ace330392..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/nonManoConfig.yaml +++ /dev/null @@ -1,22 +0,0 @@ -nonManoKeyFolderMapping: - onap_ves_events: - location: VES_EVENTS - type: Deployment - onap_pm_dictionary: - location: PM_DICTIONARY - type: Deployment - onap_yang_modules: - location: YANG_MODULE - type: Deployment - onap_ansible_playbooks: - location: ANSIBLE_PLAYBOOK - type: Deployment - onap_scripts: - location: SCRIPTS - type: Deployment - onap_others: - location: OTHER - type: Informational - onap_pnf_sw_information: - location: PNF_SW_INFORMATION - type: Informational
\ No newline at end of file diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java index 3d70948b2f..f03d561375 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImplTest.java @@ -49,6 +49,7 @@ import org.junit.Test; import org.mockito.Mockito; import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; import org.onap.sdc.tosca.parser.utils.YamlToObjectConverter; +import org.openecomp.sdc.be.config.NonManoConfiguration; import org.onap.sdc.tosca.services.YamlUtil; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.sdc.tosca.csar.Manifest; @@ -73,8 +74,8 @@ public class ETSIServiceImplTest { @Before public void setUp() throws IOException { YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter(); - Configuration configuration = yamlToObjectConverter.convert("src/test/resources", - Configuration.class, "nonManoConfig.yaml"); + NonManoConfiguration configuration = yamlToObjectConverter.convert("src/test/resources", + NonManoConfiguration.class, "nonManoConfig.yaml"); etsiService = Mockito.spy(new ETSIServiceImpl(configuration)); } |