summaryrefslogtreecommitdiffstats
path: root/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorstasys10 <stasys.jurgaitis@est.tech>2022-02-03 16:16:07 +0000
committerMichael Morris <michael.morris@est.tech>2022-02-09 17:37:38 +0000
commit8549cdded4f452a52aea32be1c97c820fa79b5af (patch)
treee790f44d574eacc69f28eaf57678390decf803ca /catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp
parent2dca3ece8e8438cb15bbaa962d3adc8d729ed785 (diff)
Add new category to NSD plugin
Issue-ID: SDC-3870 Signed-off-by: stasys10 <stasys.jurgaitis@est.tech> Change-Id: Ibb46b401f635192a680eb472eb8d7f3fb3380f57
Diffstat (limited to 'catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp')
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.java13
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/CategoriesToGenerateNsd.java45
2 files changed, 52 insertions, 6 deletions
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.java
index 9a7312b0fb..4640492441 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.java
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.CategoriesToGenerateNsd;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.plugins.CsarEntryGenerator;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.exception.NsdException;
@@ -39,7 +40,6 @@ import org.slf4j.LoggerFactory;
@org.springframework.stereotype.Component("etsiNfvNsCsarEntryGenerator")
public class EtsiNfvNsCsarEntryGenerator implements CsarEntryGenerator {
- static final String ETSI_NS_COMPONENT_CATEGORY = "ETSI NFV Network Service";
static final String NSD_FILE_PATH_FORMAT = "Artifacts/%s/%s.%s";
static final String SIGNED_CSAR_EXTENSION = "zip";
static final String UNSIGNED_CSAR_EXTENSION = "csar";
@@ -52,8 +52,8 @@ public class EtsiNfvNsCsarEntryGenerator implements CsarEntryGenerator {
}
/**
- * Generates a Network Service CSAR based on a SERVICE component of category {@link EtsiNfvNsCsarEntryGenerator#ETSI_NS_COMPONENT_CATEGORY} and
- * wraps it in a SDC CSAR entry.
+ * Generates a Network Service CSAR based on a SERVICE component that has category configured in
+ * {@link CategoriesToGenerateNsd } enum and wraps it in a SDC CSAR entry.
*
* @param component the component to create the NS CSAR from
* @return an entry to be added in the Component CSAR by SDC
@@ -65,10 +65,11 @@ public class EtsiNfvNsCsarEntryGenerator implements CsarEntryGenerator {
LOGGER.debug("Ignoring NSD CSAR generation for component '{}' as it is not a SERVICE", componentName);
return Collections.emptyMap();
}
- final boolean isEOTemplate = component.getCategories().stream().anyMatch(category -> ETSI_NS_COMPONENT_CATEGORY.equals(category.getName()));
+ final boolean isEOTemplate = component.getCategories().stream().anyMatch(category ->
+ CategoriesToGenerateNsd.hasCategoryName(category.getName()));
if (!isEOTemplate) {
- LOGGER.debug("Ignoring NSD CSAR generation for component '{}' as it does not belong to the category '{}'", componentName,
- ETSI_NS_COMPONENT_CATEGORY);
+ LOGGER.debug("Ignoring NSD CSAR generation for component '{}' as it does not belong to any of the categories '{}'",
+ componentName, CategoriesToGenerateNsd.getCategories());
return Collections.emptyMap();
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/CategoriesToGenerateNsd.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/CategoriesToGenerateNsd.java
new file mode 100644
index 0000000000..864d63d4bd
--- /dev/null
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/CategoriesToGenerateNsd.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Nordix
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.Arrays;
+import java.util.stream.Collectors;
+
+@Getter
+@AllArgsConstructor
+public enum CategoriesToGenerateNsd {
+ ETSI_NS_COMPONENT_CATEGORY ("ETSI NFV Network Service"),
+ ETSI_NS_COMPONENT_CATEGORY_FOR_ETSI_MODEL("ETSI NFV Network Service For ETSI Model");
+
+ private final String categoryName;
+
+ public static boolean hasCategoryName(String categoryNameToCheck) {
+ return Arrays.stream(CategoriesToGenerateNsd.values()).anyMatch(CategoriesToGenerateNsd ->
+ CategoriesToGenerateNsd.getCategoryName().equals(categoryNameToCheck));
+ }
+
+ public static String getCategories(){
+ return Arrays.stream(CategoriesToGenerateNsd.values()).map(CategoriesToGenerateNsd::getCategoryName)
+ .collect(Collectors.joining(", "));
+ }
+}