diff options
author | 2019-10-08 18:27:36 +0100 | |
---|---|---|
committer | 2019-11-20 17:23:14 +0000 | |
commit | 13af621442b4c74d9e63ede8e42dbae48aaa64c9 (patch) | |
tree | 93b192acc70f6b9eed7fba41402bf33bf9970442 /openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org | |
parent | 86655742cf36bdc056837f5b74bc32c58201a600 (diff) |
Onboard PNF software version
Change-Id: Id9e32e01f6c2f4c39c8ff10816d982cbb3063bf7
Issue-ID: SDC-2589
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org')
3 files changed, 18 insertions, 79 deletions
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; -} |