summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authorIdan Amit <ia096e@intl.att.com>2017-09-17 17:10:53 +0300
committerIdan Amit <ia096e@intl.att.com>2017-09-17 17:19:18 +0300
commitdfb6f09c9577a7cc16272ed37a780fd7ea2a3e74 (patch)
tree505072fb365cec8cdefc763782bab6f07e3919f5 /catalog-be/src/main
parent9c94d11d63d9016af74dcf3a2fd72d50955eace2 (diff)
Merged origin/release/1710 branch
Change-Id: If6900101b206d48112a6b2e25b33957b37083479 Issue-Id: SDC-329 Signed-off-by: Idan Amit <ia096e@intl.att.com>
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java53
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java17
-rw-r--r--catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml13
-rw-r--r--catalog-be/src/main/resources/import/tosca/categories/categoryTypes.zipbin1061 -> 1079 bytes
4 files changed, 67 insertions, 16 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
index 8198ef3d85..8b0c6fa8bf 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
@@ -20,11 +20,16 @@
package org.openecomp.sdc.be.components.impl;
+import static org.openecomp.sdc.be.tosca.CsarUtils.VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.StringReader;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -55,7 +60,13 @@ public class CsarValidationUtils {
private static final String NEW_LINE_DELM = "\n";
- public final static String TOSCA_METADATA_FILE = "TOSCA-Metadata/TOSCA.meta";
+ //public final static String TOSCA_METADATA_FILE = "TOSCA-Metadata/TOSCA.meta";
+ public final static String TOSCA_METADATA = "TOSCA-Metadata";
+ public final static String TOSCA_FILE = "TOSCA.meta";
+ public final static String DEL_PATTERN = "([/\\\\]+)";
+ public static final String TOSCA_METADATA_PATH_PATTERN = TOSCA_METADATA +
+ // Artifact Group (i.e Deployment/Informational)
+ DEL_PATTERN + TOSCA_FILE;
public static final String TOSCA_META_ENTRY_DEFINITIONS = "Entry-Definitions";
@@ -134,10 +145,19 @@ public class CsarValidationUtils {
if (validateStatus.isRight()) {
return Either.right(validateStatus.right().value());
}
- byte[] toscaMetaBytes = csar.get(TOSCA_METADATA_FILE);
+ Pattern pattern = Pattern.compile(TOSCA_METADATA_PATH_PATTERN);
+ Optional<String> keyOp = csar.keySet().stream().filter(k -> pattern.matcher(k).matches()).findAny();
+ if(!keyOp.isPresent()){
+ log.debug("TOSCA-Metadata/TOSCA.meta file is not in expected key-value form in csar, csar ID {}", csarUUID);
+ BeEcompErrorManager.getInstance().logInternalDataError("TOSCA-Metadata/TOSCA.meta file not in expected key-value form in CSAR with id " + csarUUID, "CSAR internals are invalid", ErrorSeverity.ERROR);
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID));
+ }
+ byte[] toscaMetaBytes = csar.get(keyOp.get());
Properties props = new Properties();
try {
- props.load(new ByteArrayInputStream(toscaMetaBytes));
+ //props.load(new ByteArrayInputStream(toscaMetaBytes));
+ String propStr = new String(toscaMetaBytes);
+ props.load(new StringReader(propStr.replace("\\","\\\\")));
} catch (IOException e) {
log.debug("TOSCA-Metadata/TOSCA.meta file is not in expected key-value form in csar, csar ID {}", csarUUID, e);
BeEcompErrorManager.getInstance().logInternalDataError("TOSCA-Metadata/TOSCA.meta file not in expected key-value form in CSAR with id " + csarUUID, "CSAR internals are invalid", ErrorSeverity.ERROR);
@@ -145,13 +165,16 @@ public class CsarValidationUtils {
}
String yamlFileName = props.getProperty(TOSCA_META_ENTRY_DEFINITIONS);
-
- if (!csar.containsKey(yamlFileName)) {
+ String[] ops = yamlFileName.split(DEL_PATTERN);
+ List<String> list = Arrays.asList(ops);
+ String result = list.stream().map(x -> x).collect(Collectors.joining(DEL_PATTERN));
+ keyOp = csar.keySet().stream().filter(k -> Pattern.compile(result).matcher(k).matches()).findAny();
+ if(!keyOp.isPresent()){
log.debug("Entry-Definitions entry not found in TOSCA-Metadata/TOSCA.meta file, csar ID {}", csarUUID);
BeEcompErrorManager.getInstance().logInternalDataError("Entry-Definitions entry not found in TOSCA-Metadata/TOSCA.meta file in CSAR with id " + csarUUID, "CSAR internals are invalid", ErrorSeverity.ERROR);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.YAML_NOT_FOUND_IN_CSAR, csarUUID, yamlFileName));
}
-
+
log.trace("Found Entry-Definitions property in TOSCA-Metadata/TOSCA.meta, Entry-Definitions: {}, CSAR id: {}", yamlFileName, csarUUID);
byte[] yamlFileBytes = csar.get(yamlFileName);
if (yamlFileBytes == null) {
@@ -205,8 +228,16 @@ public class CsarValidationUtils {
}
private static Either<Boolean, ResponseFormat> validateTOSCAMetadataFile(Map<String, byte[]> csar, String csarUUID, ComponentsUtils componentsUtils) {
+
+ Pattern pattern = Pattern.compile(TOSCA_METADATA_PATH_PATTERN);
+ Optional<String> keyOp = csar.keySet().stream().filter(k -> pattern.matcher(k).matches()).findAny();
+ if(!keyOp.isPresent()){
+ log.debug("TOSCA-Metadata/TOSCA.meta file is not in expected key-value form in csar, csar ID {}", csarUUID);
+ BeEcompErrorManager.getInstance().logInternalDataError("TOSCA-Metadata/TOSCA.meta file not in expected key-value form in CSAR with id " + csarUUID, "CSAR internals are invalid", ErrorSeverity.ERROR);
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID_FORMAT, csarUUID));
+ }
- byte[] toscaMetaBytes = csar.get(TOSCA_METADATA_FILE);
+ byte[] toscaMetaBytes = csar.get(keyOp.get());
String toscaMetadata = new String(toscaMetaBytes);
String[] splited = toscaMetadata.split(NEW_LINE_DELM);
if (splited == null || splited.length < TOSCA_METADATA_FIELDS.length) {
@@ -283,12 +314,16 @@ public class CsarValidationUtils {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID, csarUUID);
return Either.right(responseFormat);
}
- if (!csar.containsKey(TOSCA_METADATA_FILE)) {
+
+ Pattern pattern = Pattern.compile(TOSCA_METADATA_PATH_PATTERN);
+ Optional<String> keyOp = csar.keySet().stream().filter(k -> pattern.matcher(k).matches()).findAny();
+ if(!keyOp.isPresent()){
+
log.debug("TOSCA-Metadata/TOSCA.meta file not found in csar, csar ID {}", csarUUID);
BeEcompErrorManager.getInstance().logInternalDataError("TOSCA-Metadata/TOSCA.meta file not found in CSAR with id " + csarUUID, "CSAR structure is invalid", ErrorSeverity.ERROR);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID, csarUUID));
}
- byte[] toscaMetaBytes = csar.get(TOSCA_METADATA_FILE);
+ byte[] toscaMetaBytes = csar.get(keyOp.get());
// && exchanged for ||
if (toscaMetaBytes == null || toscaMetaBytes.length == 0) {
log.debug("TOSCA-Metadata/TOSCA.meta file not found in csar, csar ID {}", csarUUID);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
index 66627086f6..a0cc347e09 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
@@ -137,19 +137,26 @@ public class CsarUtils {
private static final String TOSCA_META_PATH_FILE_NAME = "TOSCA-Metadata/TOSCA.meta";
private static final String TOSCA_META_VERSION = "1.0";
private static final String CSAR_VERSION = "1.1";
+ public static final String ARTIFACTS = "Artifacts";
+ public static final String DEFINITION = "Definitions";
+ public static final String DEL_PATTERN = "([/\\\\]+)";
private static String versionFirstThreeOctates;
- public static final String VFC_NODE_TYPE_ARTIFACTS_PATH_PATTERN = ARTIFACTS_PATH + ImportUtils.Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "([\\d\\w\\_\\-\\.\\s]+)(/)([\\d\\w\\_\\-\\.\\s]+)(/)([\\d\\w\\_\\-\\.\\s\\/]+)";
+ public static final String VFC_NODE_TYPE_ARTIFACTS_PATH_PATTERN = ARTIFACTS + DEL_PATTERN +
+ ImportUtils.Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX +
+ "([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN +
+ "([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN +
+ "([\\d\\w\\_\\-\\.\\s]+)" + DEL_PATTERN;
- public static final String VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN = ARTIFACTS_PATH +
+ public static final String VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN = ARTIFACTS + DEL_PATTERN+
// Artifact Group (i.e Deployment/Informational)
- "([\\w\\_\\-\\.\\s]+)(/)" +
+ "([\\w\\_\\-\\.\\s]+)" + DEL_PATTERN +
// Artifact Type
- "([\\w\\_\\-\\.\\s]+)(/)" +
+ "([\\w\\_\\-\\.\\s]+)" + DEL_PATTERN +
// Artifact Any File Name
".+";
public static final String VALID_ENGLISH_ARTIFACT_NAME = "([\\w\\_\\-\\.\\s]+)";
- public static final String SERVICE_TEMPLATE_PATH_PATTERN = Constants.SERVICE_TEMPLATES_CONTAINING_FOLDER +
+ public static final String SERVICE_TEMPLATE_PATH_PATTERN = DEFINITION + DEL_PATTERN+
// Service Template File Name
"([\\w\\_\\-\\.\\s]+)";
diff --git a/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml b/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml
index 8914207b0f..4c7ca11f13 100644
--- a/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml
+++ b/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.yml
@@ -11,6 +11,12 @@ services:
VoIP_Call_Control:
name: "VoIP Call Control"
icons: ['call_controll']
+ E2E_Service:
+ name: "E2E Service"
+ icons: ['network_l_1-3']
+ Network_Service:
+ name: "Network Service"
+ icons: ['network_l_1-3']
resources:
NetworkLayer23:
name: "Network L2-3"
@@ -137,7 +143,10 @@ resources:
icons: ['service_admin']
ContrailRoute:
name: "Contrail Route"
- icons: ['contrail_route']
+ icons: ['contrail_route']
SecurityZone:
name: "Security Zone"
- icons: ['security_zone'] \ No newline at end of file
+ icons: ['security_zone']
+ NetworkService:
+ name: "Network Service"
+ icons: ['network'] \ No newline at end of file
diff --git a/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.zip b/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.zip
index 7a0e6bcad7..314a12ea55 100644
--- a/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.zip
+++ b/catalog-be/src/main/resources/import/tosca/categories/categoryTypes.zip
Binary files differ