summaryrefslogtreecommitdiffstats
path: root/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-02-16 12:44:30 +0000
committerVasyl Razinkov <vasyl.razinkov@est.tech>2021-02-16 12:46:21 +0000
commit7f418398a37283d68c0fc934e0e4a91f529fe466 (patch)
treedd62ac8b7803f9640bfb4a3a17bd4568006d9930 /catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java
parent70533b5c8fff3e9eb9e3b7bc6dd439d53036915a (diff)
Reformat catalog-be-plugins
Change-Id: Ic81316ca7bc69ef5ff775b56cbff156be1f945e8 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449
Diffstat (limited to 'catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java')
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilder.java30
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdToscaMetadataBuilder.java8
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/NsdException.java2
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/VnfDescriptorException.java2
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/EtsiNfvNsdCsarGeneratorFactory.java5
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/NsDescriptorGeneratorFactory.java6
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsCsarEntryGenerator.java28
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGenerator.java3
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImpl.java67
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGenerator.java4
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java130
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGenerator.java8
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImpl.java52
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersion.java8
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorConfig.java2
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorVersionComparator.java5
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/Nsd.java3
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/VnfDescriptor.java3
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/NsdTemplateRepresenter.java29
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGenerator.java3
-rw-r--r--catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/UnsortedPropertyUtils.java8
21 files changed, 123 insertions, 283 deletions
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilder.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilder.java
index ed3a7fc4ee..38f03f12f5 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilder.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdCsarManifestBuilder.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.builder;
import java.time.ZonedDateTime;
@@ -30,19 +30,18 @@ import java.util.TreeSet;
* Builder for the manifest (.mf) file in a NSD CSAR
*/
public class NsdCsarManifestBuilder {
+
static final String METADATA = "metadata";
static final String SOURCE = "Source";
static final String COMPATIBLE_SPECIFICATION_VERSIONS = "compatible_specification_versions";
+ static final String NSD_RELEASE_DATE_TIME = "nsd_release_date_time";
+ static final String ATTRIBUTE_SEPARATOR = ": ";
private static final String NSD_DESIGNER = "nsd_designer";
private static final String NSD_FILE_STRUCTURE_VERSION = "nsd_file_structure_version";
- static final String NSD_RELEASE_DATE_TIME = "nsd_release_date_time";
private static final String NSD_NAME = "nsd_name";
private static final String NSD_INVARIANT_ID = "nsd_invariant_id";
- static final String ATTRIBUTE_SEPARATOR = ": ";
private static final String NEW_LINE = "\n";
- private static final DateTimeFormatter RFC_3339_DATE_TIME_FORMATTER =
- DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
-
+ private static final DateTimeFormatter RFC_3339_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ");
private final MetadataHeader metadataHeader;
private final Set<String> sources;
private final Set<String> compatibleSpecificationVersions;
@@ -137,21 +136,13 @@ public class NsdCsarManifestBuilder {
appendEntry(metadataBuilder, NSD_FILE_STRUCTURE_VERSION, metadataHeader.fileStructureVersion);
final StringBuilder sourceBuilder = new StringBuilder();
sources.forEach(source -> appendEntry(sourceBuilder, SOURCE, source));
-
final StringBuilder compatibleSpecificationVersionsBuilder = new StringBuilder();
if (!compatibleSpecificationVersions.isEmpty()) {
- compatibleSpecificationVersionsBuilder.append(COMPATIBLE_SPECIFICATION_VERSIONS)
- .append(ATTRIBUTE_SEPARATOR)
- .append(String.join(",", compatibleSpecificationVersions))
- .append(NEW_LINE);
+ compatibleSpecificationVersionsBuilder.append(COMPATIBLE_SPECIFICATION_VERSIONS).append(ATTRIBUTE_SEPARATOR)
+ .append(String.join(",", compatibleSpecificationVersions)).append(NEW_LINE);
}
-
final StringBuilder builder = new StringBuilder();
-
- builder.append(metadataBuilder)
- .append(compatibleSpecificationVersionsBuilder)
- .append(NEW_LINE)
- .append(sourceBuilder);
+ builder.append(metadataBuilder).append(compatibleSpecificationVersionsBuilder).append(NEW_LINE).append(sourceBuilder);
return builder.toString();
}
@@ -167,17 +158,16 @@ public class NsdCsarManifestBuilder {
private void appendEntry(final StringBuilder builder, final String entry, final String value) {
if (value != null) {
- builder.append(entry).append(ATTRIBUTE_SEPARATOR).append(value)
- .append(NEW_LINE);
+ builder.append(entry).append(ATTRIBUTE_SEPARATOR).append(value).append(NEW_LINE);
}
}
private class MetadataHeader {
+
private String fileStructureVersion;
private String nsdName;
private String nsdReleaseDateTime;
private String designer;
private String invariantId;
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdToscaMetadataBuilder.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdToscaMetadataBuilder.java
index e709993b45..64f0b9f1df 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdToscaMetadataBuilder.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/builder/NsdToscaMetadataBuilder.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.builder;
/**
@@ -30,10 +30,8 @@ public class NsdToscaMetadataBuilder {
public static final String ENTRY_DEFINITIONS = "Entry-Definitions";
public static final String ETSI_ENTRY_CHANGE_LOG = "ETSI-Entry-Change-Log";
public static final String ETSI_ENTRY_MANIFEST = "ETSI-Entry-Manifest";
-
private static final String ATTRIBUTE_SEPARATOR = ": ";
private static final String NEW_LINE = "\n";
-
private final StringBuilder builder = new StringBuilder();
private String csarVersion;
private String createdBy;
@@ -125,9 +123,7 @@ public class NsdToscaMetadataBuilder {
private void appendEntry(final String entry, final String value) {
if (value != null) {
- builder.append(entry).append(ATTRIBUTE_SEPARATOR).append(value)
- .append(NEW_LINE);
+ builder.append(entry).append(ATTRIBUTE_SEPARATOR).append(value).append(NEW_LINE);
}
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/NsdException.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/NsdException.java
index 2483b2ebe0..d7b70fe6dd 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/NsdException.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/NsdException.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.exception;
/**
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/VnfDescriptorException.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/VnfDescriptorException.java
index e4f966fea3..45038e3c33 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/VnfDescriptorException.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/exception/VnfDescriptorException.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.exception;
/**
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/EtsiNfvNsdCsarGeneratorFactory.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/EtsiNfvNsdCsarGeneratorFactory.java
index c1c792e443..fb08f56ac2 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/EtsiNfvNsdCsarGeneratorFactory.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/EtsiNfvNsdCsarGeneratorFactory.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
@@ -16,15 +17,14 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.factory;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.EtsiNfvNsdCsarGenerator;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.EtsiNfvNsdCsarGeneratorImpl;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.VnfDescriptorGenerator;
-import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.NsDescriptorConfig;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.EtsiVersion;
+import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config.NsDescriptorConfig;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.stereotype.Component;
@@ -51,5 +51,4 @@ public class EtsiNfvNsdCsarGeneratorFactory {
return etsiNfvNsdCsarGeneratorObjectProvider
.getObject(nsDescriptorConfig, vnfDescriptorGenerator, nsDescriptorGeneratorFactory, artifactCassandraDao);
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/NsDescriptorGeneratorFactory.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/NsDescriptorGeneratorFactory.java
index 5563078964..10dee994e7 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/NsDescriptorGeneratorFactory.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/factory/NsDescriptorGeneratorFactory.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.factory;
import org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.NsDescriptorGenerator;
@@ -42,8 +42,6 @@ public class NsDescriptorGeneratorFactory {
}
public NsDescriptorGenerator create() {
- return nsDescriptorGeneratorProvider
- .getObject(toscaExportHandler, toscaTemplateYamlGeneratorProvider);
+ return nsDescriptorGeneratorProvider.getObject(toscaExportHandler, toscaTemplateYamlGeneratorProvider);
}
-
}
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 ff20a3e70b..90359a550d 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
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import static org.openecomp.sdc.common.api.ArtifactTypeEnum.ETSI_PACKAGE;
@@ -39,11 +39,10 @@ import org.slf4j.LoggerFactory;
@org.springframework.stereotype.Component("etsiNfvNsCsarEntryGenerator")
public class EtsiNfvNsCsarEntryGenerator implements CsarEntryGenerator {
- private static final Logger LOGGER = LoggerFactory.getLogger(EtsiNfvNsCsarEntryGenerator.class);
static final String ETSI_NS_COMPONENT_CATEGORY = "ETSI NFV Network Service";
static final String NSD_FILE_PATH_FORMAT = "Artifacts/%s/%s.csar";
static final String ETSI_VERSION_METADATA = "ETSI Version";
-
+ private static final Logger LOGGER = LoggerFactory.getLogger(EtsiNfvNsCsarEntryGenerator.class);
private final EtsiNfvNsdCsarGeneratorFactory etsiNfvNsdCsarGeneratorFactory;
public EtsiNfvNsCsarEntryGenerator(final EtsiNfvNsdCsarGeneratorFactory etsiNfvNsdCsarGeneratorFactory) {
@@ -51,8 +50,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 of category {@link EtsiNfvNsCsarEntryGenerator#ETSI_NS_COMPONENT_CATEGORY} 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
@@ -64,31 +63,24 @@ 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 -> ETSI_NS_COMPONENT_CATEGORY.equals(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 the category '{}'", componentName,
+ ETSI_NS_COMPONENT_CATEGORY);
return Collections.emptyMap();
}
-
final byte[] nsdCsar;
try {
final EtsiVersion etsiVersion = getComponentEtsiVersion(component);
- final EtsiNfvNsdCsarGenerator etsiNfvNsdCsarGenerator =
- etsiNfvNsdCsarGeneratorFactory.create(etsiVersion);
+ final EtsiNfvNsdCsarGenerator etsiNfvNsdCsarGenerator = etsiNfvNsdCsarGeneratorFactory.create(etsiVersion);
nsdCsar = etsiNfvNsdCsarGenerator.generateNsdCsar(component);
} catch (final NsdException e) {
- LOGGER.error("Could not create NSD CSAR entry for component '{}'"
- , component.getName(), e);
+ LOGGER.error("Could not create NSD CSAR entry for component '{}'", component.getName(), e);
return Collections.emptyMap();
} catch (final Exception e) {
- LOGGER.error("Could not create NSD CSAR entry for component '{}'. An unexpected exception occurred"
- , component.getName(), e);
+ LOGGER.error("Could not create NSD CSAR entry for component '{}'. An unexpected exception occurred", component.getName(), e);
return Collections.emptyMap();
}
-
return createEntry(component.getNormalizedName(), nsdCsar);
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGenerator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGenerator.java
index f9ee55eecf..072c4c5a89 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGenerator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGenerator.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import org.openecomp.sdc.be.model.Component;
@@ -34,5 +34,4 @@ public interface EtsiNfvNsdCsarGenerator {
* @return the CSAR package content
*/
byte[] generateNsdCsar(Component component) throws NsdException;
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImpl.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImpl.java
index efc6ade92d..e7d30197d7 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImpl.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/EtsiNfvNsdCsarGeneratorImpl.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import static org.openecomp.sdc.common.api.ArtifactTypeEnum.ETSI_PACKAGE;
@@ -71,22 +71,18 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(EtsiNfvNsdCsarGeneratorImpl.class);
-
private static final String MANIFEST_EXT = "mf";
private static final String SLASH = "/";
private static final String DOT = ".";
private static final String DOT_YAML = DOT + "yaml";
-
private static final String DEFINITION = "Definitions";
private static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta";
-
private final VnfDescriptorGenerator vnfDescriptorGenerator;
private final NsDescriptorGeneratorFactory nsDescriptorGeneratorFactory;
private final ArtifactCassandraDao artifactCassandraDao;
private final NsDescriptorConfig nsDescriptorConfig;
- public EtsiNfvNsdCsarGeneratorImpl(final NsDescriptorConfig nsDescriptorConfig,
- final VnfDescriptorGenerator vnfDescriptorGenerator,
+ public EtsiNfvNsdCsarGeneratorImpl(final NsDescriptorConfig nsDescriptorConfig, final VnfDescriptorGenerator vnfDescriptorGenerator,
final NsDescriptorGeneratorFactory nsDescriptorGeneratorFactory,
final ArtifactCassandraDao artifactCassandraDao) {
this.nsDescriptorConfig = nsDescriptorConfig;
@@ -100,19 +96,14 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
if (component == null) {
throw new NsdException("Could not generate the NSD CSAR, invalid component argument");
}
-
loadComponentArtifacts(component);
loadComponentInstancesArtifacts(component);
-
final String componentName = component.getName();
-
try {
LOGGER.debug("Starting NSD CSAR generation for component '{}'", componentName);
final Map<String, byte[]> nsdCsarFiles = new HashMap<>();
-
final List<VnfDescriptor> vnfDescriptorList = generateVnfPackages(component);
vnfDescriptorList.forEach(vnfPackage -> nsdCsarFiles.putAll(vnfPackage.getDefinitionFiles()));
-
final String nsdFileName = getNsdFileName(component);
final EtsiVersion etsiVersion = nsDescriptorConfig.getNsVersion();
final Nsd nsd = generateNsd(component, vnfDescriptorList);
@@ -120,13 +111,10 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
nsdCsarFiles.put(TOSCA_META_PATH, buildToscaMetaContent(nsdFileName).getBytes());
addEtsiSolNsdTypes(etsiVersion, nsdCsarFiles);
for (final String referencedFile : nsd.getArtifactReferences()) {
- getReferencedArtifact(component, referencedFile).ifPresent(
- artifactDefinition -> nsdCsarFiles.put(referencedFile, artifactDefinition.getPayloadData())
- );
+ getReferencedArtifact(component, referencedFile)
+ .ifPresent(artifactDefinition -> nsdCsarFiles.put(referencedFile, artifactDefinition.getPayloadData()));
}
- nsdCsarFiles
- .put(getManifestPath(nsdFileName), getManifestFileContent(nsd, etsiVersion, nsdCsarFiles.keySet()).getBytes());
-
+ nsdCsarFiles.put(getManifestPath(nsdFileName), getManifestFileContent(nsd, etsiVersion, nsdCsarFiles.keySet()).getBytes());
final byte[] csar = buildCsarPackage(nsdCsarFiles);
LOGGER.debug("Successfully generated NSD CSAR package");
return csar;
@@ -147,8 +135,7 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
if (artifactPayload.isPresent()) {
artifactDefinition.setPayload(artifactPayload.get());
} else {
- LOGGER.warn("Could not load component '{}' artifact '{}'",
- component.getName(), artifactDefinition.getArtifactName());
+ LOGGER.warn("Could not load component '{}' artifact '{}'", component.getName(), artifactDefinition.getArtifactName());
}
}
});
@@ -164,15 +151,14 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
if (MapUtils.isEmpty(deploymentArtifacts)) {
continue;
}
- deploymentArtifacts.values().stream()
- .filter(artifactDefinition -> StringUtils.isNotEmpty(artifactDefinition.getEsId()))
+ deploymentArtifacts.values().stream().filter(artifactDefinition -> StringUtils.isNotEmpty(artifactDefinition.getEsId()))
.forEach(artifactDefinition -> {
final Optional<byte[]> artifactPayload = loadArtifactPayload(artifactDefinition.getEsId());
if (artifactPayload.isPresent()) {
artifactDefinition.setPayload(artifactPayload.get());
} else {
- LOGGER.warn("Could not load component '{}' instance '{}' artifact '{}'",
- component.getName(), componentInstance.getName(), artifactDefinition.getArtifactName());
+ LOGGER.warn("Could not load component '{}' instance '{}' artifact '{}'", component.getName(), componentInstance.getName(),
+ artifactDefinition.getArtifactName());
}
});
}
@@ -184,34 +170,27 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
LOGGER.warn("Could not find any instance in service '{}'", component.getName());
return Collections.emptyList();
}
-
final List<VnfDescriptor> vnfDescriptorList = new ArrayList<>();
for (final ComponentInstance componentInstance : componentInstanceList) {
final String componentInstanceName = componentInstance.getName();
final ArtifactDefinition onboardedCsarArtifact = findOnboardedCsar(componentInstance).orElse(null);
if (onboardedCsarArtifact == null) {
- LOGGER.warn(
- "Unable to generate VNF Package for component instance '{}', no onboarded package present",
- componentInstanceName);
+ LOGGER.warn("Unable to generate VNF Package for component instance '{}', no onboarded package present", componentInstanceName);
continue;
}
final Optional<VnfDescriptor> vnfPackage;
try {
vnfPackage = vnfDescriptorGenerator.generate(componentInstanceName, onboardedCsarArtifact);
} catch (final Exception e) {
- final String errorMsg =
- String.format("Could not generate VNF package for component instance %s", componentInstanceName);
+ final String errorMsg = String.format("Could not generate VNF package for component instance %s", componentInstanceName);
throw new NsdException(errorMsg, e);
}
if (vnfPackage.isPresent()) {
vnfDescriptorList.add(vnfPackage.get());
} else {
- LOGGER.warn(
- "Unable to generate VNF Package for component instance '{}', no onboarded package present",
- componentInstanceName);
+ LOGGER.warn("Unable to generate VNF Package for component instance '{}', no onboarded package present", componentInstanceName);
}
}
-
return vnfDescriptorList;
}
@@ -220,23 +199,15 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
if (artifactDefinitionMap == null || artifactDefinitionMap.isEmpty()) {
return Optional.empty();
}
- return artifactDefinitionMap.values()
- .stream()
- .filter(artifactDefinition -> {
- final String artifactType = (String) artifactDefinition
- .getToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE);
- return ONBOARDED_PACKAGE.getType().equals(artifactType) || ETSI_PACKAGE.getType().equals(artifactType);
- })
- .findFirst();
+ return artifactDefinitionMap.values().stream().filter(artifactDefinition -> {
+ final String artifactType = (String) artifactDefinition.getToscaPresentationValue(JsonPresentationFields.ARTIFACT_TYPE);
+ return ONBOARDED_PACKAGE.getType().equals(artifactType) || ETSI_PACKAGE.getType().equals(artifactType);
+ }).findFirst();
}
- private void addEtsiSolNsdTypes(final EtsiVersion etsiVersion,
- final Map<String, byte[]> nsdCsarFileMap) {
- final EtsiVersion currentVersion = etsiVersion == null ?
- EtsiVersion.getDefaultVersion() : etsiVersion;
-
+ private void addEtsiSolNsdTypes(final EtsiVersion etsiVersion, final Map<String, byte[]> nsdCsarFileMap) {
+ final EtsiVersion currentVersion = etsiVersion == null ? EtsiVersion.getDefaultVersion() : etsiVersion;
final PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
-
try {
final Resource[] resources =
resolver.getResources(String.format("classpath:etsi-nfv-types/%s/*.*", currentVersion.getVersion()));
@@ -388,3 +359,5 @@ public class EtsiNfvNsdCsarGeneratorImpl implements EtsiNfvNsdCsarGenerator {
}
}
+
+
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGenerator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGenerator.java
index d36757cf48..726a5e190c 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGenerator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGenerator.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import java.util.List;
@@ -31,7 +31,7 @@ public interface NsDescriptorGenerator {
/**
* Generates the TOSCA Network Service Descriptor (NSD) based on a SERVICE SDC component and its VNF instances.
*
- * @param component the SERVICE component
+ * @param component the SERVICE component
* @param vnfDescriptorList the VNF instances
* @return a NSD representation
*/
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java
index 2a2e2b008a..62f8e25590 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/NsDescriptorGeneratorImpl.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import com.google.common.collect.ImmutableMap;
@@ -63,15 +63,14 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(NsDescriptorGeneratorImpl.class);
private static final String TOSCA_VERSION = "tosca_simple_yaml_1_1";
private static final String NS_TOSCA_TYPE = "tosca.nodes.nfv.NS";
- private static final List<Map<String, Map<String, String>>> DEFAULT_IMPORTS = ConfigurationManager
- .getConfigurationManager().getConfiguration().getDefaultImports();
+ private static final List<Map<String, Map<String, String>>> DEFAULT_IMPORTS = ConfigurationManager.getConfigurationManager().getConfiguration()
+ .getDefaultImports();
private static final List<String> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE = Arrays
.asList("cds_model_name", "cds_model_version", "skip_post_instantiation_configuration", "controller_actor");
private static final List<String> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TEMPLATE = Arrays
- .asList("nf_function", "nf_role", "nf_naming_code", "nf_type", "nf_naming", "availability_zone_max_count",
- "min_instances", "max_instances", "multi_stage_design", "sdnc_model_name", "sdnc_model_version",
- "sdnc_artifact_name", "skip_post_instantiation_configuration", "controller_actor");
-
+ .asList("nf_function", "nf_role", "nf_naming_code", "nf_type", "nf_naming", "availability_zone_max_count", "min_instances", "max_instances",
+ "multi_stage_design", "sdnc_model_name", "sdnc_model_version", "sdnc_artifact_name", "skip_post_instantiation_configuration",
+ "controller_actor");
private final ToscaExportHandler toscaExportHandler;
private final ObjectProvider<ToscaTemplateYamlGenerator> toscaTemplateYamlGeneratorProvider;
@@ -81,19 +80,16 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
this.toscaTemplateYamlGeneratorProvider = toscaTemplateYamlGeneratorProvider;
}
- public Optional<Nsd> generate(final Component component,
- final List<VnfDescriptor> vnfDescriptorList) throws NsdException {
+ public Optional<Nsd> generate(final Component component, final List<VnfDescriptor> vnfDescriptorList) throws NsdException {
if (!ComponentTypeEnum.SERVICE.equals(component.getComponentType())) {
return Optional.empty();
}
-
final ToscaTemplate toscaTemplate = createNetworkServiceDescriptor(component, vnfDescriptorList);
final ToscaNodeType nsNodeType = toscaTemplate.getNode_types().values().stream()
.filter(toscaNodeType -> NS_TOSCA_TYPE.equals(toscaNodeType.getDerived_from())).findFirst().orElse(null);
if (nsNodeType == null) {
return Optional.empty();
}
-
return Optional.of(buildNsd(toscaTemplate, nsNodeType));
}
@@ -103,8 +99,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
nsd.setVersion(getProperty(nsNodeType, Nsd.VERSION_PROPERTY));
nsd.setName(getProperty(nsNodeType, Nsd.NAME_PROPERTY));
nsd.setInvariantId(getProperty(nsNodeType, Nsd.INVARIANT_ID_PROPERTY));
- final ToscaTemplateYamlGenerator yamlParserProvider =
- toscaTemplateYamlGeneratorProvider.getObject(toscaTemplate);
+ final ToscaTemplateYamlGenerator yamlParserProvider = toscaTemplateYamlGeneratorProvider.getObject(toscaTemplate);
final byte[] contents = yamlParserProvider.parseToYamlString().getBytes();
nsd.setContents(contents);
final List<String> interfaceImplementations = getInterfaceImplementations(toscaTemplate);
@@ -117,14 +112,10 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
return Collections.emptyList();
}
final List<String> interfaceImplementations = new ArrayList<>();
- final Collection<ToscaNodeTemplate> nodeTemplates =
- template.getTopology_template().getNode_templates().values();
- nodeTemplates.stream()
- .filter(toscaNodeTemplate -> toscaNodeTemplate.getInterfaces() != null)
- .forEach(toscaNodeTemplate ->
- toscaNodeTemplate.getInterfaces().values().forEach(interfaceInstance ->
- interfaceImplementations.addAll(getInterfaceImplementations(interfaceInstance))
- ));
+ final Collection<ToscaNodeTemplate> nodeTemplates = template.getTopology_template().getNode_templates().values();
+ nodeTemplates.stream().filter(toscaNodeTemplate -> toscaNodeTemplate.getInterfaces() != null).forEach(
+ toscaNodeTemplate -> toscaNodeTemplate.getInterfaces().values()
+ .forEach(interfaceInstance -> interfaceImplementations.addAll(getInterfaceImplementations(interfaceInstance))));
return interfaceImplementations;
}
@@ -142,78 +133,58 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
private String getProperty(final ToscaNodeType nodeType, final String propertyName) {
final ToscaProperty toscaProperty = nodeType.getProperties().get(propertyName);
-
- final String errorMsg =
- String.format("Property '%s' must be defined and must have a valid values constraint", propertyName);
+ final String errorMsg = String.format("Property '%s' must be defined and must have a valid values constraint", propertyName);
final String returnValueOnError = "unknown";
if (toscaProperty == null || CollectionUtils.isEmpty(toscaProperty.getConstraints())) {
LOGGER.error(errorMsg);
return returnValueOnError;
}
-
final ToscaPropertyConstraint toscaPropertyConstraint = toscaProperty.getConstraints().get(0);
if (ConstraintType.VALID_VALUES != toscaPropertyConstraint.getConstraintType()) {
LOGGER.error(errorMsg);
return returnValueOnError;
}
-
- final ToscaPropertyConstraintValidValues validValuesConstraint =
- (ToscaPropertyConstraintValidValues) toscaPropertyConstraint;
+ final ToscaPropertyConstraintValidValues validValuesConstraint = (ToscaPropertyConstraintValidValues) toscaPropertyConstraint;
final List<String> validValues = validValuesConstraint.getValidValues();
- if(CollectionUtils.isEmpty(validValues)) {
+ if (CollectionUtils.isEmpty(validValues)) {
LOGGER.error(errorMsg);
return returnValueOnError;
}
-
return validValues.get(0);
}
- private ToscaTemplate createNetworkServiceDescriptor(final Component component,
- final List<VnfDescriptor> vnfDescriptorList)
- throws NsdException {
-
+ private ToscaTemplate createNetworkServiceDescriptor(final Component component, final List<VnfDescriptor> vnfDescriptorList) throws NsdException {
final ToscaTemplate componentToscaTemplate = parseToToscaTemplate(component);
final ToscaTemplate componentToscaTemplateInterface = exportComponentInterfaceAsToscaTemplate(component);
-
- final Entry<String, ToscaNodeType> firstNodeTypeEntry =
- componentToscaTemplateInterface.getNode_types()
- .entrySet().stream().findFirst().orElse(null);
+ final Entry<String, ToscaNodeType> firstNodeTypeEntry = componentToscaTemplateInterface.getNode_types().entrySet().stream().findFirst()
+ .orElse(null);
if (firstNodeTypeEntry == null) {
throw new NsdException("Could not find abstract Service type");
}
-
final String nsNodeTypeName = firstNodeTypeEntry.getKey();
final ToscaNodeType nsNodeType = firstNodeTypeEntry.getValue();
-
final Map<String, ToscaNodeType> nodeTypeMap = new HashMap<>();
nodeTypeMap.put(nsNodeTypeName, createEtsiSolNsNodeType(nsNodeType));
-
if (componentToscaTemplate.getNode_types() == null) {
componentToscaTemplate.setNode_types(nodeTypeMap);
} else {
componentToscaTemplate.getNode_types().putAll(nodeTypeMap);
}
-
setPropertiesForNodeTemplates(componentToscaTemplate);
removeCapabilitiesFromNodeTemplates(componentToscaTemplate);
removeOnapPropertiesFromInputs(componentToscaTemplate);
handleSubstitutionMappings(componentToscaTemplate, nsNodeTypeName);
-
final Map<String, ToscaNodeTemplate> nodeTemplates = new HashMap<>();
- nodeTemplates.put(nsNodeTypeName, createNodeTemplateForNsNodeType(nsNodeTypeName,
- componentToscaTemplateInterface.getNode_types().get(nsNodeTypeName)));
-
+ nodeTemplates.put(nsNodeTypeName,
+ createNodeTemplateForNsNodeType(nsNodeTypeName, componentToscaTemplateInterface.getNode_types().get(nsNodeTypeName)));
if (componentToscaTemplate.getTopology_template().getNode_templates() == null) {
componentToscaTemplate.getTopology_template().setNode_templates(nodeTemplates);
} else {
setNodeTemplateTypesForVnfs(componentToscaTemplate, vnfDescriptorList);
componentToscaTemplate.getTopology_template().getNode_templates().putAll(nodeTemplates);
}
-
removeOnapMetaData(componentToscaTemplate);
-
setDefaultImportsForEtsiSolNsNsd(componentToscaTemplate, vnfDescriptorList);
-
return componentToscaTemplate;
}
@@ -228,8 +199,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
componentToscaTemplate.getTopology_template().setSubstitution_mappings(substitutionMapping);
}
- private void setNodeTemplateTypesForVnfs(final ToscaTemplate template,
- final List<VnfDescriptor> vnfDescriptorList) {
+ private void setNodeTemplateTypesForVnfs(final ToscaTemplate template, final List<VnfDescriptor> vnfDescriptorList) {
if (CollectionUtils.isEmpty(vnfDescriptorList)) {
return;
}
@@ -237,11 +207,9 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
if (MapUtils.isEmpty(nodeTemplateMap)) {
return;
}
- nodeTemplateMap.forEach((key, toscaNodeTemplate) ->
- vnfDescriptorList.stream()
- .filter(vnfDescriptor -> key.equals(vnfDescriptor.getName())).findFirst()
- .ifPresent(vnfDescriptor -> toscaNodeTemplate.setType(vnfDescriptor.getNodeType()))
- );
+ nodeTemplateMap.forEach(
+ (key, toscaNodeTemplate) -> vnfDescriptorList.stream().filter(vnfDescriptor -> key.equals(vnfDescriptor.getName())).findFirst()
+ .ifPresent(vnfDescriptor -> toscaNodeTemplate.setType(vnfDescriptor.getNodeType())));
}
private void setPropertiesForNodeTemplates(final ToscaTemplate template) {
@@ -257,10 +225,9 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
}
final Map<String, Object> editedPropertyMap = new HashMap<>();
for (final Entry<String, Object> property : propertyMap.entrySet()) {
- if (!PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TEMPLATE.contains(property.getKey())
- && propertyIsDefinedInNodeType(property.getKey())) {
- editedPropertyMap
- .put(property.getKey().substring(property.getKey().indexOf('_') + 1), property.getValue());
+ if (!PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TEMPLATE.contains(property.getKey()) && propertyIsDefinedInNodeType(
+ property.getKey())) {
+ editedPropertyMap.put(property.getKey().substring(property.getKey().indexOf('_') + 1), property.getValue());
}
}
if (editedPropertyMap.isEmpty()) {
@@ -270,14 +237,14 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
}
}
}
-
+
private void removeCapabilitiesFromNodeTemplates(final ToscaTemplate template) {
final Map<String, ToscaNodeTemplate> nodeTemplateMap = template.getTopology_template().getNode_templates();
if (MapUtils.isEmpty(nodeTemplateMap)) {
return;
}
for (final Entry<String, ToscaNodeTemplate> nodeTemplate : nodeTemplateMap.entrySet()) {
- nodeTemplate.getValue().setCapabilities(null);
+ nodeTemplate.getValue().setCapabilities(null);
}
}
@@ -285,8 +252,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
final ToscaTopolgyTemplate topologyTemplate = template.getTopology_template();
final Map<String, ToscaProperty> inputMap = topologyTemplate.getInputs();
if (MapUtils.isNotEmpty(inputMap)) {
- inputMap.entrySet()
- .removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey()));
+ inputMap.entrySet().removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey()));
}
if (MapUtils.isEmpty(inputMap)) {
topologyTemplate.setInputs(null);
@@ -302,8 +268,7 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
nodeTemplateMap.values().forEach(toscaNodeTemplate -> toscaNodeTemplate.setMetadata(null));
}
- private void setDefaultImportsForEtsiSolNsNsd(final ToscaTemplate template,
- final List<VnfDescriptor> vnfDescriptorList) {
+ private void setDefaultImportsForEtsiSolNsNsd(final ToscaTemplate template, final List<VnfDescriptor> vnfDescriptorList) {
final List<Map<String, Map<String, String>>> importEntryMap = new ArrayList<>();
final Map<String, Map<String, String>> defaultImportEntryMap = generateDefaultImportEntry();
if (MapUtils.isNotEmpty(defaultImportEntryMap)) {
@@ -318,22 +283,17 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
importEntryMap.add(vnfdImportVnfdEntry);
}
}
-
template.setImports(importEntryMap);
}
private Map<String, Map<String, String>> generateDefaultImportEntry() {
- return ImmutableMap.of("etsi_nfv_sol001_nsd_types",
- ImmutableMap.of("file", "etsi_nfv_sol001_nsd_types.yaml")
- );
+ return ImmutableMap.of("etsi_nfv_sol001_nsd_types", ImmutableMap.of("file", "etsi_nfv_sol001_nsd_types.yaml"));
}
private ToscaNodeType createEtsiSolNsNodeType(final ToscaNodeType nsNodeType) {
final ToscaNodeType toscaNodeType = new ToscaNodeType();
toscaNodeType.setDerived_from(NS_TOSCA_TYPE);
-
final Map<String, ToscaProperty> propertiesInNsNodeType = nsNodeType.getProperties();
-
for (final Entry<String, ToscaProperty> property : propertiesInNsNodeType.entrySet()) {
final ToscaProperty toscaProperty = property.getValue();
if (toscaProperty.getDefaultp() != null) {
@@ -342,36 +302,29 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
toscaProperty.setConstraints(Collections.singletonList(constraint));
}
}
-
- propertiesInNsNodeType.entrySet()
- .removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey()));
+ propertiesInNsNodeType.entrySet().removeIf(entry -> PROPERTIES_TO_EXCLUDE_FROM_ETSI_SOL_NSD_NS_NODE_TYPE.contains(entry.getKey()));
toscaNodeType.setProperties(propertiesInNsNodeType);
-
return toscaNodeType;
}
private boolean propertyIsDefinedInNodeType(final String propertyName) {
// This will achieve what we want for now, but will look into a more generic solution which would involve
+
// checking the node_type definition in the VNFD
return !propertyName.equals("additional_parameters");
}
-
- private ToscaNodeTemplate createNodeTemplateForNsNodeType(final String nodeType,
- final ToscaNodeType toscaNodeType) {
+ private ToscaNodeTemplate createNodeTemplateForNsNodeType(final String nodeType, final ToscaNodeType toscaNodeType) {
final ToscaNodeTemplate nodeTemplate = new ToscaNodeTemplate();
nodeTemplate.setType(nodeType);
-
final Map<String, ToscaProperty> properties = toscaNodeType.getProperties();
final Map<String, Object> nodeTemplateProperties = new HashMap<>();
for (final Entry<String, ToscaProperty> property : properties.entrySet()) {
nodeTemplateProperties.put(property.getKey(), property.getValue().getDefaultp());
}
-
if (!nodeTemplateProperties.isEmpty()) {
nodeTemplate.setProperties(nodeTemplateProperties);
}
-
final Map<String, Object> interfaces = toscaNodeType.getInterfaces();
if (interfaces != null) {
for (final Entry<String, Object> nodeInterface : interfaces.entrySet()) {
@@ -381,37 +334,30 @@ public class NsDescriptorGeneratorImpl implements NsDescriptorGenerator {
}
nodeTemplate.setInterfaces(interfaces);
}
-
return nodeTemplate;
}
private ToscaTemplate parseToToscaTemplate(final Component component) throws NsdException {
final Either<ToscaTemplate, ToscaError> toscaTemplateRes = toscaExportHandler.convertToToscaTemplate(component);
if (toscaTemplateRes.isRight()) {
- String errorMsg = String.format("Could not parse component '%s' to tosca template. Error '%s'",
- component.getName(), toscaTemplateRes.right().value().name());
+ String errorMsg = String
+ .format("Could not parse component '%s' to tosca template. Error '%s'", component.getName(), toscaTemplateRes.right().value().name());
throw new NsdException(errorMsg);
}
-
return toscaTemplateRes.left().value();
}
-
private ToscaTemplate exportComponentInterfaceAsToscaTemplate(final Component component) throws NsdException {
if (null == DEFAULT_IMPORTS) {
throw new NsdException("Could not load default CSAR imports from configuration");
}
-
final ToscaTemplate toscaTemplate = new ToscaTemplate(TOSCA_VERSION);
toscaTemplate.setImports(new ArrayList<>(DEFAULT_IMPORTS));
final Either<ToscaTemplate, ToscaError> toscaTemplateRes = toscaExportHandler
.convertInterfaceNodeType(new HashMap<>(), component, toscaTemplate, new HashMap<>(), false);
if (toscaTemplateRes.isRight()) {
- throw new NsdException(String.format("Could not create abstract service from component '%s'",
- component.getName()));
+ throw new NsdException(String.format("Could not create abstract service from component '%s'", component.getName()));
}
-
return toscaTemplateRes.left().value();
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGenerator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGenerator.java
index c4599d7cf4..e66adf3d06 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGenerator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGenerator.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import java.util.Optional;
@@ -32,12 +32,10 @@ public interface VnfDescriptorGenerator {
/**
* Generates the a VNF Descriptor based on the ONBOARDED_PACKAGE artifact.
*
- * @param name the name of the VNF package
+ * @param name the name of the VNF package
* @param onboardedPackageArtifact the onboarded package for the VNF
* @return a representation of the VNF package
* @throws VnfDescriptorException when a problem happens during the generation
*/
- Optional<VnfDescriptor> generate(final String name, final ArtifactDefinition onboardedPackageArtifact)
- throws VnfDescriptorException;
-
+ Optional<VnfDescriptor> generate(final String name, final ArtifactDefinition onboardedPackageArtifact) throws VnfDescriptorException;
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImpl.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImpl.java
index 8cf54d129a..902911b817 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImpl.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/VnfDescriptorGeneratorImpl.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator;
import java.io.FileNotFoundException;
@@ -60,22 +60,22 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
private static final String DEFINITIONS_DIRECTORY = "Definitions";
private static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta";
- public Optional<VnfDescriptor> generate(final String name,
- final ArtifactDefinition onboardedPackageArtifact)
- throws VnfDescriptorException {
+ private static boolean isACsarArtifact(final ArtifactDefinition definition) {
+ return definition.getPayloadData() != null && definition.getArtifactName() != null && CSAR
+ .equalsIgnoreCase(FilenameUtils.getExtension(definition.getArtifactName()));
+ }
+
+ public Optional<VnfDescriptor> generate(final String name, final ArtifactDefinition onboardedPackageArtifact) throws VnfDescriptorException {
if (!isACsarArtifact(onboardedPackageArtifact)) {
return Optional.empty();
}
-
final FileContentHandler fileContentHandler;
try {
fileContentHandler = FileUtils.getFileContentMapFromZip(onboardedPackageArtifact.getPayloadData());
} catch (final ZipException e) {
- final String errorMsg = String
- .format("Could not unzip artifact '%s' content", onboardedPackageArtifact.getArtifactName());
+ final String errorMsg = String.format("Could not unzip artifact '%s' content", onboardedPackageArtifact.getArtifactName());
throw new VnfDescriptorException(errorMsg, e);
}
-
if (MapUtils.isEmpty(fileContentHandler.getFiles())) {
return Optional.empty();
}
@@ -83,9 +83,7 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
try {
mainDefinitionFile = getMainFilePathFromMetaFile(fileContentHandler).orElse(null);
} catch (final IOException e) {
- final String errorMsg = String
- .format("Could not read main definition file of artifact '%s'",
- onboardedPackageArtifact.getArtifactName());
+ final String errorMsg = String.format("Could not read main definition file of artifact '%s'", onboardedPackageArtifact.getArtifactName());
throw new VnfDescriptorException(errorMsg, e);
}
LOGGER.debug("found main file: {}", mainDefinitionFile);
@@ -95,30 +93,19 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
final VnfDescriptor vnfDescriptor = new VnfDescriptor();
vnfDescriptor.setName(name);
final String vnfdFileName = FilenameUtils.getName(mainDefinitionFile);
-
vnfDescriptor.setVnfdFileName(vnfdFileName);
vnfDescriptor.setDefinitionFiles(getFiles(fileContentHandler, mainDefinitionFile));
vnfDescriptor.setNodeType(getNodeType(getFileContent(fileContentHandler, mainDefinitionFile)));
-
return Optional.of(vnfDescriptor);
}
- private static boolean isACsarArtifact(final ArtifactDefinition definition) {
- return definition.getPayloadData() != null && definition.getArtifactName() != null && CSAR
- .equalsIgnoreCase(FilenameUtils.getExtension(definition.getArtifactName()));
- }
-
private Map<String, byte[]> getFiles(final FileContentHandler fileContentHandler, final String filePath) {
final Map<String, byte[]> files = new HashMap<>();
-
final byte[] fileContent = fileContentHandler.getFileContent(filePath);
-
if (fileContent != null) {
final String mainYmlFile = new String(fileContent);
LOGGER.debug("file content: {}", mainYmlFile);
-
- files.put(appendDefinitionDirPath(filePath.substring(filePath.lastIndexOf(SLASH) + 1)),
- getVnfdWithoutTopologyTemplate(fileContent));
+ files.put(appendDefinitionDirPath(filePath.substring(filePath.lastIndexOf(SLASH) + 1)), getVnfdWithoutTopologyTemplate(fileContent));
final List<Object> imports = getImportFilesPath(mainYmlFile);
LOGGER.info("found imports {}", imports);
for (final Object importObject : imports) {
@@ -135,15 +122,13 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
private String getFileContent(final FileContentHandler fileContentHandler, final String filePath) {
final byte[] fileContent = fileContentHandler.getFileContent(filePath);
-
if (fileContent != null) {
return new String(fileContent);
}
return null;
}
- private Optional<String> getMainFilePathFromMetaFile(final FileContentHandler fileContentHandler)
- throws IOException {
+ private Optional<String> getMainFilePathFromMetaFile(final FileContentHandler fileContentHandler) throws IOException {
final Map<String, String> metaFileContent = getMetaFileContent(fileContentHandler);
final String mainFile = metaFileContent.get(NsdToscaMetadataBuilder.ENTRY_DEFINITIONS);
if (mainFile != null) {
@@ -153,16 +138,13 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
return Optional.empty();
}
- private Map<String, String> getMetaFileContent(final FileContentHandler fileContentHandler)
- throws IOException {
+ private Map<String, String> getMetaFileContent(final FileContentHandler fileContentHandler) throws IOException {
final InputStream inputStream = fileContentHandler.getFileContentAsStream(TOSCA_META_PATH);
if (inputStream == null) {
throw new FileNotFoundException("Unable find " + TOSCA_META_PATH + " file");
}
final List<String> lines = IOUtils.readLines(inputStream, StandardCharsets.UTF_8);
-
- return lines.stream().map(str -> str.split(COLON))
- .collect(Collectors.toMap(str -> str[0], str -> str.length > 1 ? str[1] : EMPTY_STRING));
+ return lines.stream().map(str -> str.split(COLON)).collect(Collectors.toMap(str -> str[0], str -> str.length > 1 ? str[1] : EMPTY_STRING));
}
private String appendDefinitionDirPath(final String filename) {
@@ -171,9 +153,7 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
private List<Object> getImportFilesPath(final String mainYmlFile) {
final Map<Object, Object> fileContentMap = new YamlUtil().yamlToObject(mainYmlFile, Map.class);
-
final Object importsObject = fileContentMap.get("imports");
-
if (importsObject instanceof List) {
return (List<Object>) importsObject;
}
@@ -184,19 +164,15 @@ public class VnfDescriptorGeneratorImpl implements VnfDescriptorGenerator {
final Yaml yaml = new Yaml();
final Map<String, Object> toscaFileContent = (Map<String, Object>) yaml.load(new String(vnfdFileContent));
toscaFileContent.remove("topology_template");
-
return yaml.dumpAsMap(toscaFileContent).getBytes();
}
private String getNodeType(final String mainYmlFile) {
final Map<Object, Object> fileContentMap = new YamlUtil().yamlToObject(mainYmlFile, Map.class);
-
final Object nodeTypesObject = fileContentMap.get("node_types");
- if (nodeTypesObject instanceof Map
- && ((Map<String, Object>) nodeTypesObject).size() == 1) {
+ if (nodeTypesObject instanceof Map && ((Map<String, Object>) nodeTypesObject).size() == 1) {
return ((Map<String, Object>) nodeTypesObject).keySet().iterator().next();
}
return null;
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersion.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersion.java
index d447dc428d..180337d1d5 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersion.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/EtsiVersion.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config;
import lombok.AllArgsConstructor;
@@ -29,10 +29,7 @@ import org.apache.commons.lang.StringUtils;
@Getter
@AllArgsConstructor
public enum EtsiVersion {
- VERSION_2_5_1("2.5.1"),
- VERSION_2_7_1("2.7.1"),
- VERSION_3_3_1("3.3.1");
-
+ VERSION_2_5_1("2.5.1"), VERSION_2_7_1("2.7.1"), VERSION_3_3_1("3.3.1");
private final String version;
public static EtsiVersion convertOrNull(final String etsiVersion) {
@@ -48,7 +45,6 @@ public enum EtsiVersion {
if (VERSION_3_3_1.getVersion().equals(etsiVersion)) {
return VERSION_3_3_1;
}
-
return null;
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorConfig.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorConfig.java
index d17b48d158..d17b03f7c4 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorConfig.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorConfig.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config;
import lombok.Getter;
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorVersionComparator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorVersionComparator.java
index 40e499c8c7..f24a0442ba 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorVersionComparator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/generator/config/NsDescriptorVersionComparator.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.generator.config;
import java.util.Comparator;
@@ -32,19 +32,16 @@ public class NsDescriptorVersionComparator implements Comparator<EtsiVersion> {
} else if (Integer.parseInt(v1[0]) < Integer.parseInt(v2[0])) {
return -1;
}
-
if (Integer.parseInt(v1[1]) > Integer.parseInt(v2[1])) {
return 1;
} else if (Integer.parseInt(v1[1]) < Integer.parseInt(v2[1])) {
return -1;
}
-
if (Integer.parseInt(v1[2]) > Integer.parseInt(v2[2])) {
return 1;
} else if (Integer.parseInt(v1[2]) < Integer.parseInt(v2[2])) {
return -1;
}
-
return 0;
}
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/Nsd.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/Nsd.java
index a8de728702..f1e0faa871 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/Nsd.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/Nsd.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.model;
import java.util.ArrayList;
@@ -31,7 +31,6 @@ public class Nsd {
public static final String VERSION_PROPERTY = "version";
public static final String NAME_PROPERTY = "name";
public static final String INVARIANT_ID_PROPERTY = "invariant_id";
-
private String designer;
private String version;
private String name;
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/VnfDescriptor.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/VnfDescriptor.java
index 53615effb6..88a2364386 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/VnfDescriptor.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/model/VnfDescriptor.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.model;
import java.util.HashMap;
@@ -63,5 +63,4 @@ public class VnfDescriptor {
public void setNodeType(String nodeType) {
this.nodeType = nodeType;
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/NsdTemplateRepresenter.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/NsdTemplateRepresenter.java
index 822d6dc82b..cb8928f372 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/NsdTemplateRepresenter.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/NsdTemplateRepresenter.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.tosca.yaml;
import java.util.ArrayList;
@@ -49,64 +49,50 @@ public class NsdTemplateRepresenter extends Representer {
}
@Override
- protected NodeTuple representJavaBeanProperty(final Object javaBean, final Property property,
- final Object propertyValue, final Tag customTag) {
+ protected NodeTuple representJavaBeanProperty(final Object javaBean, final Property property, final Object propertyValue, final Tag customTag) {
if (propertyValue == null) {
return null;
}
-
if (ignoredPropertySet.contains(property.getName())) {
return null;
}
-
if (javaBean instanceof ToscaTemplate) {
return handleToscaTemplate(javaBean, property, propertyValue, customTag);
}
-
if (javaBean instanceof ToscaPropertyConstraintValidValues) {
return handleToscaPropertyConstraintValidValues(javaBean, property, propertyValue, customTag);
}
-
if (javaBean instanceof ToscaProperty) {
return handleToscaProperty(javaBean, property, propertyValue, customTag);
}
-
return super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
}
- private NodeTuple handleToscaProperty(final Object javaBean, final Property property,
- final Object propertyValue, final Tag customTag) {
+ private NodeTuple handleToscaProperty(final Object javaBean, final Property property, final Object propertyValue, final Tag customTag) {
final NodeTuple nodeTuple = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
if ("_defaultp_".equals(property.getName())) {
return new NodeTuple(representData("default"), nodeTuple.getValueNode());
}
-
return nodeTuple;
}
- private NodeTuple handleToscaPropertyConstraintValidValues(final Object javaBean, final Property property,
- final Object propertyValue, final Tag customTag) {
+ private NodeTuple handleToscaPropertyConstraintValidValues(final Object javaBean, final Property property, final Object propertyValue,
+ final Tag customTag) {
final NodeTuple nodeTuple = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
if ("validValues".equals(property.getName())) {
final String validValuesEntryName = ToscaPropertyConstraintValidValues.getEntryToscaName("validValues");
return new NodeTuple(representData(validValuesEntryName), nodeTuple.getValueNode());
}
-
return nodeTuple;
}
- private NodeTuple handleToscaTemplate(final Object javaBean, final Property property,
- final Object propertyValueObj, final Tag customTag) {
+ private NodeTuple handleToscaTemplate(final Object javaBean, final Property property, final Object propertyValueObj, final Tag customTag) {
if ("imports".equals(property.getName())) {
- final List<Map<String, Map<String, String>>> importsList =
- (List<Map<String, Map<String, String>>>) propertyValueObj;
-
+ final List<Map<String, Map<String, String>>> importsList = (List<Map<String, Map<String, String>>>) propertyValueObj;
final List<Map<String, String>> newImportList = new ArrayList<>();
importsList.forEach(importMap -> importMap.forEach((key, value) -> newImportList.add(value)));
-
return super.representJavaBeanProperty(javaBean, property, newImportList, customTag);
}
-
return super.representJavaBeanProperty(javaBean, property, propertyValueObj, customTag);
}
@@ -115,7 +101,6 @@ public class NsdTemplateRepresenter extends Representer {
if (!classTags.containsKey(javaBean.getClass())) {
addClassTag(javaBean.getClass(), Tag.MAP);
}
-
return super.representJavaBean(properties, javaBean);
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGenerator.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGenerator.java
index 4c2cd87184..b73b52954b 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGenerator.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/ToscaTemplateYamlGenerator.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.tosca.yaml;
import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
@@ -69,5 +69,4 @@ public class ToscaTemplateYamlGenerator {
representer.addClassTag(toscaTemplate.getClass(), Tag.MAP);
representer.setPropertyUtils(new UnsortedPropertyUtils());
}
-
}
diff --git a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/UnsortedPropertyUtils.java b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/UnsortedPropertyUtils.java
index b93db62088..6c70e93f07 100644
--- a/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/UnsortedPropertyUtils.java
+++ b/catalog-be-plugins/etsi-nfv-nsd-csar-plugin/src/main/java/org/openecomp/sdc/be/plugins/etsi/nfv/nsd/tosca/yaml/UnsortedPropertyUtils.java
@@ -1,3 +1,4 @@
+
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation
@@ -16,7 +17,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.plugins.etsi.nfv.nsd.tosca.yaml;
import java.beans.IntrospectionException;
@@ -30,10 +30,8 @@ import org.yaml.snakeyaml.introspector.PropertyUtils;
public class UnsortedPropertyUtils extends PropertyUtils {
@Override
- protected Set<Property> createPropertySet(final Class clazz, final BeanAccess beanAccess)
- throws IntrospectionException {
-
+ protected Set<Property> createPropertySet(final Class clazz, final BeanAccess beanAccess) throws IntrospectionException {
final Collection<Property> fields = getPropertiesMap(clazz, BeanAccess.FIELD).values();
return new LinkedHashSet<>(fields);
}
-} \ No newline at end of file
+}