summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2023-10-20 21:03:39 +0100
committerMichaelMorris <michael.morris@est.tech>2023-10-20 21:50:31 +0100
commit6b60a4739f1d64a5346017460f6e9022c6b93551 (patch)
treed8d34af02ffcc8b494ba0752b349d3543b96c117 /catalog-be/src
parent461f20fd6fb23c594361c734525cdd281b72c2e3 (diff)
Backout "Remove generation of csar.meta"
This commit reverts 8a9eed8e6e97068a47aa14016cc0601f89eb0939 Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4640 Change-Id: Ie50cecd009e9c74af1b55c7dcb899db6621279b3
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CommonCsarGenerator.java21
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java19
2 files changed, 21 insertions, 19 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 d80a91f0e4..7b55f32f71 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
@@ -130,8 +130,6 @@ 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();
@@ -201,16 +199,9 @@ 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, isSkipImports).getBytes();
+ final byte[] toscaBlock0Byte =
+ createToscaBlock0(TOSCA_META_VERSION, CSAR_VERSION, component.getCreatorFullName(), fileName, isAsdPackage, definitionsPath).getBytes();
zip.putNextEntry(new ZipEntry(TOSCA_META_PATH_FILE_NAME));
zip.write(toscaBlock0Byte);
zip.putNextEntry(new ZipEntry(definitionsPath + fileName));
@@ -262,10 +253,6 @@ 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();
@@ -1234,9 +1221,9 @@ public class CommonCsarGenerator {
}
private String createToscaBlock0(String metaFileVersion, String csarVersion, String createdBy, String entryDef, boolean isAsdPackage,
- String definitionsPath, boolean isSkipImports) {
+ String definitionsPath) {
final String block0template = "TOSCA-Meta-File-Version: %s\nCSAR-Version: %s\nCreated-By: %s\nEntry-Definitions: "
- + definitionsPath + "%s\n%s\n" + (!isSkipImports ? "Name: csar.meta\nContent-Type: text/plain\n" : "");
+ + definitionsPath + "%s\n%s\nName: 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 ee2cdc261f..35854d3570 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,6 +33,7 @@ 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;
@@ -44,6 +45,7 @@ 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;
@@ -74,6 +76,8 @@ 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]+)";
@@ -93,6 +97,7 @@ 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;
@@ -274,8 +279,11 @@ 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(isAsdPackage(component), component, getFromCS, isInCertificationRequest).left().map(responseFormat -> {
+ return generateCsarZip(csarBlock0Byte,
+ isAsdPackage(component), component, getFromCS, isInCertificationRequest).left().map(responseFormat -> {
loggerSupportability
.log(LoggerSupportabilityActions.GENERATE_CSAR, StatusCode.COMPLETE, "Ended create Csar for component {} ", component.getName());
return responseFormat;
@@ -302,11 +310,14 @@ public class CsarUtils {
return false;
}
- private Either<byte[], ResponseFormat> generateCsarZip(boolean isAsdPackage,
+ private Either<byte[], ResponseFormat> generateCsarZip(byte[] csarBlock0Byte,
+ 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()) {
@@ -322,6 +333,10 @@ 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) {