aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main
diff options
context:
space:
mode:
authordavsad <david.sadlier@est.tech>2021-02-05 13:12:57 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-02-20 07:12:05 +0000
commitb1660e1be36e1f6572253f871dd5defa4030c98a (patch)
treecc856617ca244e651b139b4d61b7e7057b52dcb8 /openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main
parent372c2470e613128f1e33cfc581ea2c5b1b732d2b (diff)
Add new SOL004 validator
New validator for onboarding SOL 004 version 3.3.1 Issue-ID: SDC-2611 Signed-off-by: davsad <david.sadlier@est.tech> Change-Id: I4f41d2fbd913011f42a8319a6594c973c735d2a0
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main')
-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.java22
1 files changed, 22 insertions, 0 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/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 1281d611cb..8ec76fe14b 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
@@ -24,21 +24,25 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.ARTIFACTS_FOLDER;
import static org.openecomp.sdc.tosca.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_MF_FILE_NAME;
import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.COMPATIBLE_SPECIFICATION_VERSIONS;
import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS;
import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CHANGE_LOG;
import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST;
import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.ETSI_VERSION_2_6_1;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
+
import org.apache.commons.collections.MapUtils;
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.onap.sdc.tosca.services.YamlUtil;
@@ -55,6 +59,8 @@ import org.openecomp.sdc.tosca.csar.SOL004ManifestOnboarding;
import org.openecomp.sdc.tosca.csar.ToscaMetadata;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import com.vdurmont.semver4j.Semver;
+
public class ETSIServiceImpl implements ETSIService {
private static final Logger LOGGER = LoggerFactory.getLogger(ETSIServiceImpl.class);
@@ -202,6 +208,22 @@ public class ETSIServiceImpl implements ETSIService {
&& metaDataEntries.containsKey(ETSI_ENTRY_CHANGE_LOG.getName());
}
+ @Override
+ public Semver getHighestCompatibleSpecificationVersion(final FileContentHandler handler) {
+ try {
+ Map<String, String> metadata = getManifest(handler).getMetadata();
+ if (metadata.containsKey(COMPATIBLE_SPECIFICATION_VERSIONS.getToken())) {
+ return Arrays.asList(metadata.get(COMPATIBLE_SPECIFICATION_VERSIONS.getToken()).split(","))
+ .stream().map(Semver::new).max((v1, v2) -> v1.compareTo(v2))
+ .orElse(new Semver(ETSI_VERSION_2_6_1));
+ }
+ } catch (Exception ex) {
+ LOGGER.error("An error occurred while getting highest compatible version from manifest file", ex);
+ }
+ return new Semver(ETSI_VERSION_2_6_1);
+
+ }
+
private boolean isMetaFilePresent(Map<String, byte[]> handler) {
return handler.containsKey(TOSCA_META_PATH_FILE_NAME) || handler.containsKey(TOSCA_META_ORIG_PATH_FILE_NAME);
}