summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2019-10-08 18:27:36 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-11-20 17:23:14 +0000
commit13af621442b4c74d9e63ede8e42dbae48aaa64c9 (patch)
tree93b192acc70f6b9eed7fba41402bf33bf9970442 /openecomp-be/lib
parent86655742cf36bdc056837f5b74bc32c58201a600 (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')
-rw-r--r--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.java30
-rw-r--r--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.java38
-rw-r--r--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.java29
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/resources/nonManoConfig.yaml22
-rw-r--r--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.java5
5 files changed, 21 insertions, 103 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;
-}
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));
}