aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-09-29 14:38:36 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-09-29 13:40:23 +0000
commit8a9eed8e6e97068a47aa14016cc0601f89eb0939 (patch)
tree04737bfa443bea9c12fca43016558a389d5b2db8 /catalog-be
parentb30ec85492a613fa9ebadab175d663bc2da44ffd (diff)
Remove generation of csar.meta
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I7788d76741b36e9269aad9e99308d8e8af2602d2 Issue-ID: SDC-4640
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java22
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java19
2 files changed, 19 insertions, 22 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java
index aee8b65ca3..16df325b24 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java
@@ -127,6 +127,8 @@ public class CommonCsarGenerator {
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";
+ private static final String BLOCK_0_TEMPLATE = "SDC-TOSCA-Meta-File-Version: %s\nSDC-TOSCA-Definitions-Version: %s\n";
+ private static final String CSAR_META_PATH_FILE_NAME = "csar.meta";
private static final String SDC_VERSION = ExternalConfiguration.getAppVersion();
public static final String NODES_YML = "nodes.yml";
private static final String CONFORMANCE_LEVEL = ConfigurationManager.getConfigurationManager().getConfiguration().getToscaConformanceLevel();
@@ -175,7 +177,6 @@ public class CommonCsarGenerator {
* @param component the component to create the NS CSAR from
* @return an entry to be added in the Component CSAR by SDC
*/
-
public Either<ZipOutputStream, ResponseFormat> generateCsarZip(Component component,
boolean getFromCS,
ZipOutputStream zip,
@@ -197,9 +198,16 @@ public class CommonCsarGenerator {
} else {
return Either.right(toscaRepresentation.right().value());
}
+
+ if (!isSkipImports) {
+ final String toscaConformanceLevel = ConfigurationManager.getConfigurationManager().getConfiguration().getToscaConformanceLevel();
+ zip.putNextEntry(new ZipEntry(CSAR_META_PATH_FILE_NAME));
+ zip.write(createCsarBlock0(TOSCA_META_VERSION, toscaConformanceLevel).getBytes());
+ }
+
final String fileName = artifactDef.getArtifactName();
- final byte[] toscaBlock0Byte =
- createToscaBlock0(TOSCA_META_VERSION, CSAR_VERSION, component.getCreatorFullName(), fileName, isAsdPackage, definitionsPath).getBytes();
+ final byte[] toscaBlock0Byte = createToscaBlock0(
+ TOSCA_META_VERSION, CSAR_VERSION, component.getCreatorFullName(), fileName, isAsdPackage, definitionsPath, isSkipImports).getBytes();
zip.putNextEntry(new ZipEntry(TOSCA_META_PATH_FILE_NAME));
zip.write(toscaBlock0Byte);
zip.putNextEntry(new ZipEntry(definitionsPath + fileName));
@@ -250,6 +258,10 @@ public class CommonCsarGenerator {
return writeAllFilesToCsar(component, collectedComponentCsarDefinition.left().value(), zip, isInCertificationRequest);
}
+ private String createCsarBlock0(String metaFileVersion, String toscaConformanceLevel) {
+ return String.format(BLOCK_0_TEMPLATE, metaFileVersion, toscaConformanceLevel);
+ }
+
private Either<ToscaRepresentation, ResponseFormat> fetchToscaRepresentation(Component component, boolean getFromCS,
ArtifactDefinition artifactDef, boolean isSkipImports) {
LifecycleStateEnum lifecycleState = component.getLifecycleState();
@@ -1140,9 +1152,9 @@ public class CommonCsarGenerator {
}
private String createToscaBlock0(String metaFileVersion, String csarVersion, String createdBy, String entryDef, boolean isAsdPackage,
- String definitionsPath) {
+ String definitionsPath, boolean isSkipImports) {
final String block0template = "TOSCA-Meta-File-Version: %s\nCSAR-Version: %s\nCreated-By: %s\nEntry-Definitions: "
- + definitionsPath + "%s\n%s\nName: csar.meta\nContent-Type: text/plain\n";
+ + definitionsPath + "%s\n%s\n" + (!isSkipImports ? "Name: csar.meta\nContent-Type: text/plain\n" : "");
return String.format(block0template, metaFileVersion, csarVersion, createdBy, entryDef, isAsdPackage ? "entry_definition_type: asd" : "");
}
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 35854d3570..ee2cdc261f 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
@@ -33,7 +33,6 @@ import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.regex.Pattern;
-import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import lombok.Getter;
import lombok.Setter;
@@ -45,7 +44,6 @@ import org.openecomp.sdc.be.components.impl.ImportUtils;
import org.openecomp.sdc.be.config.ArtifactConfigManager;
import org.openecomp.sdc.be.config.ArtifactConfiguration;
import org.openecomp.sdc.be.config.ComponentType;
-import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
@@ -76,8 +74,6 @@ public class CsarUtils {
private static final Logger log = Logger.getLogger(CsarUtils.class);
private static final LoggerSupportability loggerSupportability = LoggerSupportability.getLogger(CsarUtils.class.getName());
private static final String PATH_DELIMITER = "/";
- private static final String CSAR_META_VERSION = "1.0";
- private static final String CSAR_META_PATH_FILE_NAME = "csar.meta";
private static final String DEFINITION = "Definitions";
private static final String DEL_PATTERN = "([/\\\\]+)";
private static final String WORD_PATTERN = "\\w\\_\\@\\-\\.\\s]+)";
@@ -97,7 +93,6 @@ public class CsarUtils {
ARTIFACTS + DEL_PATTERN + ImportUtils.Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + VALID_ENGLISH_ARTIFACT_NAME_WITH_DIGITS + DEL_PATTERN
+ VALID_ENGLISH_ARTIFACT_NAME_WITH_DIGITS + DEL_PATTERN + VALID_ENGLISH_ARTIFACT_NAME_WITH_DIGITS + DEL_PATTERN
+ VALID_ENGLISH_ARTIFACT_NAME_WITH_DIGITS;
- private static final String BLOCK_0_TEMPLATE = "SDC-TOSCA-Meta-File-Version: %s\nSDC-TOSCA-Definitions-Version: %s\n";
private final ToscaOperationFacade toscaOperationFacade;
private final ComponentsUtils componentsUtils;
@@ -279,11 +274,8 @@ public class CsarUtils {
public Either<byte[], ResponseFormat> createCsar(final Component component, final boolean getFromCS, final boolean isInCertificationRequest) {
loggerSupportability
.log(LoggerSupportabilityActions.GENERATE_CSAR, StatusCode.STARTED, "Starting to create Csar for component {} ", component.getName());
- final String toscaConformanceLevel = ConfigurationManager.getConfigurationManager().getConfiguration().getToscaConformanceLevel();
- final byte[] csarBlock0Byte = createCsarBlock0(CSAR_META_VERSION, toscaConformanceLevel).getBytes();
- return generateCsarZip(csarBlock0Byte,
- isAsdPackage(component), component, getFromCS, isInCertificationRequest).left().map(responseFormat -> {
+ return generateCsarZip(isAsdPackage(component), component, getFromCS, isInCertificationRequest).left().map(responseFormat -> {
loggerSupportability
.log(LoggerSupportabilityActions.GENERATE_CSAR, StatusCode.COMPLETE, "Ended create Csar for component {} ", component.getName());
return responseFormat;
@@ -310,14 +302,11 @@ public class CsarUtils {
return false;
}
- private Either<byte[], ResponseFormat> generateCsarZip(byte[] csarBlock0Byte,
- boolean isAsdPackage,
+ private Either<byte[], ResponseFormat> generateCsarZip(boolean isAsdPackage,
Component component,
boolean getFromCS,
boolean isInCertificationRequest) {
try (final ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out)) {
- zip.putNextEntry(new ZipEntry(CSAR_META_PATH_FILE_NAME));
- zip.write(csarBlock0Byte);
Either<ZipOutputStream, ResponseFormat> populateZip = mapFromModelCsarGeneratorService.generateCsarZip(
component, getFromCS, zip, isInCertificationRequest, isAsdPackage);
if (populateZip.isRight()) {
@@ -333,10 +322,6 @@ public class CsarUtils {
}
}
- private String createCsarBlock0(String metaFileVersion, String toscaConformanceLevel) {
- return String.format(BLOCK_0_TEMPLATE, metaFileVersion, toscaConformanceLevel);
- }
-
/************************************ Artifacts Structure END******************************************************************/
private Either<CsarDefinition, ResponseFormat> collectComponentCsarDefinition(Component component) {