aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-lib
diff options
context:
space:
mode:
authorbilal.iqbal <bilal.iqbal@est.tech>2019-03-25 14:31:14 +0000
committerbilal.iqbal <bilal.iqbal@est.tech>2019-03-25 14:31:14 +0000
commit62f5ad6b806d0bda1bb918061a5aa4b5b4dbe8b8 (patch)
tree75d0c2d82c6be3b71d79b4174aca009681e9c0b1 /openecomp-be/lib/openecomp-tosca-lib
parent53903f1d96affe2c21e3ffbdd45aea8f7af0714d (diff)
Change SOL004 baseline from v2.5.1 to v2.6.1
Change-Id: Ic524e25a5f0a9952dd0a2c578034c60e51c7a290 Issue-ID: SDC-2190 Signed-off-by: bilal.iqbal <bilal.iqbal@est.tech>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib')
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/pom.xml6
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java18
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java9
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java8
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java2
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/ManifestParsingTest.java6
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java8
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta4
8 files changed, 50 insertions, 11 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/pom.xml b/openecomp-be/lib/openecomp-tosca-lib/pom.xml
index 834e8e36b2..6b7ca2fa17 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/pom.xml
+++ b/openecomp-be/lib/openecomp-tosca-lib/pom.xml
@@ -97,6 +97,12 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.be</groupId>
+ <artifactId>common-be</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<properties>
<useSystemClassLoader>false</useSystemClassLoader>
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java
index 50c2c106ff..00eb46183a 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/AbstractOnboardingManifest.java
@@ -19,6 +19,7 @@ package org.openecomp.sdc.tosca.csar;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -33,18 +34,22 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA;
import static org.openecomp.sdc.tosca.csar.CSARConstants.METADATA_MF_ATTRIBUTE;
import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
abstract class AbstractOnboardingManifest implements Manifest{
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractOnboardingManifest.class);
+ private static final int MAX_ALLOWED_MANIFEST_META_ENTRIES = 4;
protected Map<String, String> metadata;
protected List<String> sources;
protected List<String> errors;
protected Map<String, List<String>> nonManoSources;
+ protected ResourceTypeEnum type;
protected AbstractOnboardingManifest() {
errors = new ArrayList<>();
@@ -54,6 +59,19 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
}
@Override
+ public Optional<ResourceTypeEnum> getType(){
+ if(errors.isEmpty() && !metadata.isEmpty() && metadata.size() == MAX_ALLOWED_MANIFEST_META_ENTRIES) {
+ for (String key : metadata.keySet()) {
+ if (MANIFEST_PNF_METADATA.stream().anyMatch(key::equals)) {
+ return Optional.of(ResourceTypeEnum.PNF);
+ }
+ return Optional.of(ResourceTypeEnum.VF);
+ }
+ }
+ return Optional.empty();
+ }
+
+ @Override
public void parse(InputStream is) {
try {
ImmutableList<String> lines = readAllLines(is);
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java
index 826a72b6fd..d7dd3d450f 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/CSARConstants.java
@@ -32,10 +32,11 @@ public class CSARConstants {
public static final String TOSCA_META_CSAR_VERSION_ENTRY = "CSAR-Version";
public static final String TOSCA_META_CREATED_BY_ENTRY = "Created-by";
public static final String TOSCA_META_ENTRY_DEFINITIONS="Entry-Definitions";
- public static final String TOSCA_META_ENTRY_MANIFEST="Entry-Manifest";
- public static final String TOSCA_META_ENTRY_CHANGE_LOG="Entry-Change-Log";
- public static final String TOSCA_META_ENTRY_TESTS = "Entry-Tests";
- public static final String TOSCA_META_ENTRY_LICENSES= "Entry-Licenses";
+ public static final String TOSCA_META_ETSI_ENTRY_MANIFEST ="ETSI-Entry-Manifest";
+ public static final String TOSCA_META_ETSI_ENTRY_CHANGE_LOG ="ETSI-Entry-Change-Log";
+ public static final String TOSCA_META_ETSI_ENTRY_TESTS = "ETSI-Entry-Tests";
+ public static final String TOSCA_META_ETSI_ENTRY_LICENSES = "ETSI-Entry-Licenses";
+ public static final String TOSCA_META_ETSI_ENTRY_CERTIFICATE = "ETSI-Entry-Certificate";
public static final ImmutableSet<String> ELIGIBLE_FILES =
of(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME,MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME);
public static final ImmutableSet<String> MANIFEST_PNF_METADATA =
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java
index 1a11ecf6f6..c11f4a3ddc 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/Manifest.java
@@ -20,9 +20,11 @@
package org.openecomp.sdc.tosca.csar;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
public interface Manifest {
@@ -62,4 +64,10 @@ public interface Manifest {
* @return
*/
Map<String, List<String>> getNonManoSources();
+
+ /**
+ * Gets the type based on the metadata of manifest file (VF/PNF)
+ * @return enum for type values
+ */
+ Optional<ResourceTypeEnum> getType();
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java
index 267729596b..1ee1c1b1ae 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/csar/SOL004ManifestOnboarding.java
@@ -32,7 +32,7 @@ import static org.openecomp.sdc.tosca.csar.CSARConstants.NON_MANO_MF_ATTRIBUTE;
import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
import static org.openecomp.sdc.tosca.csar.CSARConstants.SOURCE_MF_ATTRIBUTE;
-public class SOL004ManifestOnboarding extends AbstractOnboardingManifest implements Manifest {
+public class SOL004ManifestOnboarding extends AbstractOnboardingManifest {
@Override
protected void processMetadata(Iterator<String> iterator) {
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/ManifestParsingTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/ManifestParsingTest.java
index 2e8a1ecbd0..b083cfad3a 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/ManifestParsingTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/ManifestParsingTest.java
@@ -18,9 +18,11 @@ package org.openecomp.sdc.tosca.csar;
import org.junit.Before;
import org.junit.Test;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.common.errors.Messages;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Optional;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
@@ -44,6 +46,10 @@ public class ManifestParsingTest {
assertTrue(manifest.isValid());
assertEquals(manifest.getMetadata().size(), 4);
assertEquals(manifest.getSources().size(), 5);
+ Optional<ResourceTypeEnum> resourceTypeEnum = manifest.getType();
+ if(resourceTypeEnum.isPresent()){
+ assertTrue(resourceTypeEnum.get() == ResourceTypeEnum.VF);
+ }
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java
index 5e32820bc3..4519ee7bd3 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/csar/MetadataParsingTest.java
@@ -4,9 +4,9 @@ package org.openecomp.sdc.tosca.csar;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_CHANGE_LOG;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_CHANGE_LOG;
import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS;
-import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ETSI_ENTRY_MANIFEST;
import java.io.IOException;
import java.io.InputStream;
@@ -61,8 +61,8 @@ public class MetadataParsingTest {
.getResourceAsStream("/vspmanager.csar/metadata/ValidETSItosca.meta")) {
ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
assertEquals(onboardingToscaMetadata.getMetaEntries().get(TOSCA_META_ENTRY_DEFINITIONS), "Definitions/MainServiceTemplate.yaml");
- assertEquals(onboardingToscaMetadata.getMetaEntries().get(TOSCA_META_ENTRY_MANIFEST), "MainServiceTemplate.mf");
- assertEquals(onboardingToscaMetadata.getMetaEntries().get(TOSCA_META_ENTRY_CHANGE_LOG), "change.log");
+ assertEquals(onboardingToscaMetadata.getMetaEntries().get(TOSCA_META_ETSI_ENTRY_MANIFEST), "MainServiceTemplate.mf");
+ assertEquals(onboardingToscaMetadata.getMetaEntries().get(TOSCA_META_ETSI_ENTRY_CHANGE_LOG), "change.log");
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta
index 0d74a150b1..8a51a625f2 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/resources/vspmanager.csar/metadata/ValidETSItosca.meta
@@ -2,5 +2,5 @@ TOSCA-Meta-File-Version: 1.0
CSAR-Version: 1.1
Created-By: Sergey Sachkov
Entry-Definitions: Definitions/MainServiceTemplate.yaml
-Entry-Manifest: MainServiceTemplate.mf
-Entry-Change-Log: change.log
+ETSI-Entry-Manifest: MainServiceTemplate.mf
+ETSI-Entry-Change-Log: change.log