aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImpl.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceInstanceImpl.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImplTest.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java4
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaFileOutputService.java2
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java59
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java166
12 files changed, 207 insertions, 56 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index 1825dadf7f..bf173a28be 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -69,7 +69,9 @@ import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
import org.openecomp.sdc.tosca.csar.Manifest;
+import org.openecomp.sdc.tosca.csar.ManifestUtils;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
import org.openecomp.sdc.validation.util.ValidationManagerUtil;
@@ -545,7 +547,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
populateVersionsForVlm(vspDetails.getVendorId(), vlmVersion);
}
final PackageInfo packageInfo = createPackageInfo(vspDetails);
- final ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = new ToscaFileOutputServiceCsarImpl();
+ final ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils()));
final FileContentHandler licenseArtifacts = licenseArtifactsService
.createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion, vspDetails.getFeatureGroups());
final ETSIService etsiService = new ETSIServiceImpl();
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java
index e9d891dc94..c041778a0e 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-core/src/test/java/org/openecomp/sdc/enrichment/impl/EnrichmentManagerImplTest.java
@@ -38,6 +38,8 @@ import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory;
import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
+import org.openecomp.sdc.tosca.csar.ManifestUtils;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.services.ToscaFileOutputService;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
@@ -114,7 +116,7 @@ public class EnrichmentManagerImplTest {
try (FileOutputStream fos = new FileOutputStream(file))
{
- ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl();
+ ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils()));
fos.write(toscaFileOutputService.createOutputFile(toscaServiceModel, null));
}
diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java
index cf9ec3c49d..3350bb5f85 100644
--- a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java
+++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/test/java/org/openecomp/sdc/enrichment/impl/tosca/BaseToscaEnrichmentTest.java
@@ -19,6 +19,8 @@ package org.openecomp.sdc.enrichment.impl.tosca;
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
+import org.openecomp.sdc.tosca.csar.ManifestUtils;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.services.ToscaFileOutputService;
import org.openecomp.sdc.tosca.services.ToscaUtil;
@@ -146,7 +148,7 @@ public class BaseToscaEnrichmentTest {
void compareActualAndExpectedModel(ToscaServiceModel toscaServiceModel) throws IOException {
- ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl();
+ ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils()));
byte[] toscaActualFile = toscaFileOutputService.createOutputFile(toscaServiceModel, null);
URL url = BaseToscaEnrichmentTest.class.getResource(outputFilesPath);
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java
index 0547ec730b..97b572235c 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java
@@ -42,6 +42,8 @@ import org.openecomp.sdc.heat.datatypes.model.Output;
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
+import org.openecomp.sdc.tosca.csar.ManifestUtils;
import org.openecomp.sdc.tosca.datatypes.ToscaGroupType;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.services.DataModelUtil;
@@ -181,7 +183,7 @@ public class TranslationService {
private void createHeatStackGroup(ServiceTemplate serviceTemplate, FileData heatFileData, HeatOrchestrationTemplate heatOrchestrationTemplate,
TranslationContext context) {
- ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl();
+ ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils()));
final String fileName = heatFileData.getFile();
final String heatStackGroupId = FileUtils.getFileWithoutExtention(fileName) + "_group";
GroupDefinition groupDefinition = new GroupDefinition();
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImpl.java
index 253410e493..6606d0cf25 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImpl.java
@@ -21,6 +21,8 @@ import java.util.List;
import java.util.Map;
import org.onap.sdc.tosca.datatypes.model.ArtifactDefinition;
import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
+import org.openecomp.sdc.tosca.csar.ManifestUtils;
import org.openecomp.sdc.tosca.datatypes.ToscaArtifactType;
import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.tosca.services.ToscaConstants;
@@ -46,7 +48,7 @@ public class FunctionTranslationGetFileImpl implements FunctionTranslation {
artifactParameters.add(ToscaConstants.MODELABLE_ENTITY_NAME_SELF);
returnValue.put(ToscaFunctions.GET_ARTIFACT.getFunctionName(), artifactParameters);
artifactParameters.add(artifactId);
- ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl();
+ ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils()));
if (functionTranslator.getToscaTemplate() instanceof NodeTemplate) {
NodeTemplate nodeTemplate = (NodeTemplate) functionTranslator.getToscaTemplate();
ArtifactDefinition artifactDefinition = createArtifactDefinition(file, toscaFileOutputService);
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceInstanceImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceInstanceImpl.java
index d4ee120fb8..e3f28f6fdc 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceInstanceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceInstanceImpl.java
@@ -50,6 +50,8 @@ import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.heat.services.HeatConstants;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
+import org.openecomp.sdc.tosca.csar.ManifestUtils;
import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.openecomp.sdc.tosca.datatypes.ToscaGroupType;
@@ -418,7 +420,7 @@ public class ResourceTranslationContrailServiceInstanceImpl extends ResourceTran
serviceInstanceGroupDefinition.setType(ToscaGroupType.HEAT_STACK);
Map<String, Object> groupProperties = new HashMap<>();
groupProperties
- .put("heat_file", "../" + (new ToscaFileOutputServiceCsarImpl()).getArtifactsFolderName() + "/" + translateTo.getHeatFileName());
+ .put("heat_file", "../" + (new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils()))).getArtifactsFolderName() + "/" + translateTo.getHeatFileName());
serviceInstanceGroupDefinition.setProperties(groupProperties);
serviceInstanceGroupDefinition.setMembers(new ArrayList<>());
String heatStackGroupKey = translateTo.getTranslatedId() + "_group";
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImplTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImplTest.java
index 57115764aa..847a88cb08 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImplTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/functiontranslation/FunctionTranslationGetFileImplTest.java
@@ -21,6 +21,8 @@ import org.junit.Test;
import org.onap.sdc.tosca.datatypes.model.NodeTemplate;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
+import org.openecomp.sdc.tosca.csar.ManifestUtils;
import org.openecomp.sdc.tosca.services.ToscaConstants;
import org.openecomp.sdc.tosca.services.ToscaFileOutputService;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
@@ -81,7 +83,7 @@ public class FunctionTranslationGetFileImplTest {
Assert.assertNotNull(nodeTemplate.getArtifacts());
Assert.assertNotNull(
nodeTemplate.getArtifacts().get(FileUtils.getFileWithoutExtention((String) function)));
- ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl();
+ ToscaFileOutputService toscaFileOutputService = new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils()));
Assert.assertEquals(
nodeTemplate.getArtifacts().get(FileUtils.getFileWithoutExtention((String) function))
.getFile(), "../" + toscaFileOutputService.getArtifactsFolderName() + "/" + function);
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java
index 31dbb21a4c..fded190868 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseFullTranslationTest.java
@@ -43,6 +43,8 @@ import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
+import org.openecomp.sdc.tosca.csar.ManifestUtils;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
import org.openecomp.sdc.translator.TestUtils;
import org.togglz.testing.TestFeatureManager;
@@ -111,7 +113,7 @@ public class BaseFullTranslationTest {
.build());
}
- return new ToscaFileOutputServiceCsarImpl().createOutputFile(translatorOutput.getToscaServiceModel(), null);
+ return new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils())).createOutputFile(translatorOutput.getToscaServiceModel(), null);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java
index 42f4cfdfd5..60717bf0b9 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceTranslationTest.java
@@ -60,6 +60,8 @@ import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
+import org.openecomp.sdc.tosca.csar.ManifestUtils;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
import org.openecomp.sdc.translator.TestUtils;
import org.openecomp.sdc.translator.datatypes.heattotosca.TranslationContext;
@@ -144,7 +146,7 @@ public class BaseResourceTranslationTest {
.build());
}
- return new ToscaFileOutputServiceCsarImpl().createOutputFile(translatorOutput.getToscaServiceModel(), null);
+ return new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils())).createOutputFile(translatorOutput.getToscaServiceModel(), null);
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaFileOutputService.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaFileOutputService.java
index 334ff6f567..54f7890888 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaFileOutputService.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaFileOutputService.java
@@ -26,7 +26,7 @@ public interface ToscaFileOutputService {
byte[] createOutputFile(ToscaServiceModel toscaServiceModel, FileContentHandler externalArtifacts);
- String createMetaFile(String entryDefinitionsFileName);
+ String createMetaFile(String entryDefinitionsFileName, boolean isAsdPackage);
String getArtifactsFolderName();
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java
index d0df54b105..1fb3858717 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java
@@ -15,20 +15,6 @@
*/
package org.openecomp.sdc.tosca.services.impl;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.CREATED_BY_ENTRY;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.CSAR_VERSION_ENTRY;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ENTRY_DEFINITIONS;
-import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.TOSCA_META_FILE_VERSION_ENTRY;
-
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
import org.apache.commons.io.IOUtils;
import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.core.utilities.file.FileContentHandler;
@@ -36,11 +22,28 @@ import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.exceptions.CsarCreationErrorBuilder;
import org.openecomp.sdc.tosca.exceptions.CsarMissingEntryPointErrorBuilder;
import org.openecomp.sdc.tosca.services.ToscaFileOutputService;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ENTRY_DEFINITION_TYPE;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.CREATED_BY_ENTRY;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.CSAR_VERSION_ENTRY;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ENTRY_DEFINITIONS;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.TOSCA_META_FILE_VERSION_ENTRY;
+
public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService {
static final String EXTERNAL_ARTIFACTS_FOLDER_NAME = "Artifacts";
@@ -56,6 +59,11 @@ public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService {
private static final String SPACE = " ";
private static final String FILE_SEPARATOR = File.separator;
private static final Logger logger = LoggerFactory.getLogger(ToscaFileOutputServiceCsarImpl.class);
+ private final AsdPackageHelper asdPackageHelper;
+
+ public ToscaFileOutputServiceCsarImpl(AsdPackageHelper asdPackageHelper) {
+ this.asdPackageHelper = asdPackageHelper;
+ }
@Override
public byte[] createOutputFile(ToscaServiceModel toscaServiceModel, FileContentHandler externalArtifacts) {
@@ -63,13 +71,13 @@ public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService {
try (ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(baos))) {
packDefinitions(zos, toscaServiceModel.getServiceTemplates());
FileContentHandler artifactFiles = toscaServiceModel.getArtifactFiles();
- if (artifactFiles != null && !artifactFiles.isEmpty()) {
- packArtifacts(zos, artifactFiles);
- }
if (toscaServiceModel.getEntryDefinitionServiceTemplate() == null) {
throw new CoreException(new CsarMissingEntryPointErrorBuilder().build());
}
- createAndPackToscaMetaFile(zos, toscaServiceModel.getEntryDefinitionServiceTemplate());
+ if (artifactFiles != null) {
+ packArtifacts(zos, artifactFiles);
+ }
+ createAndPackToscaMetaFile(zos, toscaServiceModel.getEntryDefinitionServiceTemplate(), isAsdPackage(artifactFiles));
if (externalArtifacts != null) {
packExternalArtifacts(zos, externalArtifacts);
}
@@ -80,11 +88,12 @@ public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService {
}
@Override
- public String createMetaFile(String entryDefinitionsFileName) {
+ public String createMetaFile(String entryDefinitionsFileName, boolean isAsdPackage) {
return TOSCA_META_FILE_VERSION_ENTRY.getName() + META_FILE_DELIMITER + SPACE + TOSCA_META_FILE_VERSION_VALUE + System.lineSeparator()
+ CSAR_VERSION_ENTRY.getName() + META_FILE_DELIMITER + SPACE + CSAR_VERSION_VALUE + System.lineSeparator() + CREATED_BY_ENTRY.getName()
+ META_FILE_DELIMITER + SPACE + CREATED_BY_VALUE + System.lineSeparator() + ENTRY_DEFINITIONS.getName() + META_FILE_DELIMITER + SPACE
- + DEFINITIONS_FOLDER_NAME + FILE_SEPARATOR + entryDefinitionsFileName;
+ + DEFINITIONS_FOLDER_NAME + FILE_SEPARATOR + entryDefinitionsFileName
+ + (isAsdPackage ? System.lineSeparator() + ENTRY_DEFINITION_TYPE.getToken() + META_FILE_DELIMITER + SPACE + "asd" : "");
}
@Override
@@ -92,8 +101,14 @@ public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService {
return ARTIFACTS_FOLDER_NAME;
}
- private void createAndPackToscaMetaFile(ZipOutputStream zos, String entryDefinitionsFileName) throws IOException {
- String metaFile = createMetaFile(entryDefinitionsFileName);
+ private boolean isAsdPackage(FileContentHandler artifactFiles){
+
+ return artifactFiles != null && !artifactFiles.isEmpty() && asdPackageHelper.isAsdPackage(artifactFiles);
+
+ }
+
+ private void createAndPackToscaMetaFile(ZipOutputStream zos, String entryDefinitionsFileName, boolean isAsdPackage) throws IOException {
+ String metaFile = createMetaFile(entryDefinitionsFileName, isAsdPackage);
zos.putNextEntry(new ZipEntry(TOSCA_META_FOLDER_NAME + FILE_SEPARATOR + TOSCA_META_FILE_NAME));
writeBytesToZip(zos, new ByteArrayInputStream(metaFile.getBytes()));
}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java
index df7fa2af97..107d166823 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImplTest.java
@@ -20,9 +20,22 @@
package org.openecomp.sdc.tosca.services.impl;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.tosca.csar.AsdPackageHelper;
+import org.openecomp.sdc.tosca.csar.ManifestTokenType;
+import org.openecomp.sdc.tosca.csar.ManifestUtils;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.tosca.services.ToscaConstants;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Collections;
@@ -32,43 +45,43 @@ import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.MockitoAnnotations;
-import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.openecomp.core.utilities.file.FileContentHandler;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.sdc.tosca.services.ToscaUtil;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.APPLICATION_NAME;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.APPLICATION_PROVIDER;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ATTRIBUTE_VALUE_SEPARATOR;
+import static org.openecomp.sdc.tosca.csar.ManifestTokenType.ENTRY_DEFINITION_TYPE;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryAsd.CREATED_BY_ENTRY;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryAsd.CSAR_VERSION_ENTRY;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryAsd.ENTRY_DEFINITIONS;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryAsd.ETSI_ENTRY_MANIFEST;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryAsd.TOSCA_META_FILE_VERSION_ENTRY;
+import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
public class ToscaFileOutputServiceCsarImplTest {
- @InjectMocks
- private ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCsarImpl;
+ private static ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCsarImpl;
- @Before
- public void init() {
- MockitoAnnotations.openMocks(this);
+ @BeforeAll
+ public static void setupBeforeClass() {
+ toscaFileOutputServiceCsarImpl = new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils()));
}
@Test
public void testCreationMetaFile() {
- String createdMeta = toscaFileOutputServiceCsarImpl.createMetaFile("entryFile.yaml");
+ String createdMeta = toscaFileOutputServiceCsarImpl.createMetaFile("entryFile.yaml", false);
String expectedMeta =
"TOSCA-Meta-File-Version: 1.0\n" +
"CSAR-Version: 1.1\n" +
"Created-By: ASDC Onboarding portal\n" +
"Entry-Definitions: Definitions" + File.separator + "entryFile.yaml";
- Assert.assertEquals(createdMeta.replaceAll("\\s+", ""), expectedMeta.replaceAll("\\s+", ""));
+ assertEquals(createdMeta.replaceAll("\\s+", ""), expectedMeta.replaceAll("\\s+", ""));
}
@Test
public void testCSARFileCreationWithExternalArtifacts() throws IOException {
ToscaFileOutputServiceCsarImpl toscaFileOutputServiceCSARImpl =
- new ToscaFileOutputServiceCsarImpl();
+ new ToscaFileOutputServiceCsarImpl(new AsdPackageHelper(new ManifestUtils()));
ServiceTemplate mainServiceTemplate = new ServiceTemplate();
Map<String, String> metadata1 = new HashMap<>();
metadata1.put("Template_author", "OPENECOMP");
@@ -140,6 +153,112 @@ public class ToscaFileOutputServiceCsarImplTest {
}
@Test
+ public void testAsdCSARFileCreationWithExternalArtifacts() throws IOException {
+
+ ServiceTemplate mainServiceTemplate = new ServiceTemplate();
+ Map<String, String> metadata1 = new HashMap<>();
+ metadata1.put("Template_author", "OPENECOMP");
+ metadata1.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, "ST1");
+ metadata1.put("Template_version", "1.0.0");
+ metadata1.put("filename", "asd.yaml");
+ mainServiceTemplate.setMetadata(metadata1);
+ mainServiceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0");
+ mainServiceTemplate.setDescription("testing desc tosca service template");
+
+ ServiceTemplate additionalServiceTemplate = new ServiceTemplate();
+ Map<String, String> metadata2 = new HashMap<>();
+ metadata2.put("Template_author", "OPENECOMP");
+ metadata2.put(ToscaConstants.ST_METADATA_TEMPLATE_NAME, "ST2");
+ metadata2.put("Template_version", "1.0.0");
+ additionalServiceTemplate.setTosca_definitions_version("tosca_simple_yaml_1_0_0");
+ additionalServiceTemplate.setDescription("testing desc tosca service template");
+ additionalServiceTemplate.setMetadata(metadata2);
+
+ FileContentHandler handler = new FileContentHandler();
+ String metaFile = new StringBuilder()
+ .append(TOSCA_META_FILE_VERSION_ENTRY.getName())
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" 1.0").append("\n")
+ .append(CSAR_VERSION_ENTRY.getName())
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" 1.1").append("\n")
+ .append(CREATED_BY_ENTRY.getName())
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append(" Vendor").append("\n")
+ .append(ENTRY_DEFINITIONS.getName())
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append("Definitions/asd.yaml").append("\n")
+ .append(ETSI_ENTRY_MANIFEST.getName() + ATTRIBUTE_VALUE_SEPARATOR.getToken() + "asd.mf").append("\n").toString();
+ handler.addFile(TOSCA_META_PATH_FILE_NAME, metaFile.getBytes(StandardCharsets.UTF_8));
+
+ Map<String, byte[]> manifestMap = new HashMap<>();
+ String manifestContent = new StringBuilder().append("metadata")
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append("\n")
+ .append(ENTRY_DEFINITION_TYPE.getToken())
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append("asd").append("\n")
+ .append(ManifestTokenType.RELEASE_DATE_TIME.getToken())
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append("2021-10-21T11:30:00+05:00").append("\n")
+ .append(APPLICATION_NAME.getToken())
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append("SampleApp").append("\n")
+ .append(APPLICATION_PROVIDER.getToken())
+ .append(ATTRIBUTE_VALUE_SEPARATOR.getToken()).append("MyCompany")
+ .toString();
+ String manifestFile = "asd.mf";
+ manifestMap.put(manifestFile, manifestContent.getBytes());
+ handler.setFiles(manifestMap);
+
+ Map<String, ServiceTemplate> definitionsInput = new HashMap<>();
+ definitionsInput
+ .put(ToscaUtil.getServiceTemplateFileName(mainServiceTemplate), mainServiceTemplate);
+ definitionsInput.put(ToscaUtil.getServiceTemplateFileName(additionalServiceTemplate),
+ additionalServiceTemplate);
+
+ Map<String, byte[]> dummyHeatArtifacts = new HashMap<>();
+ String file1Content = "this is file number 1";
+ String file2Content = "this is file number 2";
+ String file1 = "file1.xml";
+ dummyHeatArtifacts.put(file1, file1Content.getBytes());
+ String file2 = "file2.yml";
+ dummyHeatArtifacts.put(file2, file2Content.getBytes());
+ handler.setFiles(dummyHeatArtifacts);
+
+
+ FileContentHandler heatFiles = new FileContentHandler();
+ heatFiles.setFiles(dummyHeatArtifacts);
+ heatFiles.addAll(handler);
+ Map<String, byte[]> licenseArtifacts = new HashMap<>();
+
+ FileContentHandler licenseArtifactsFiles = new FileContentHandler();
+
+ licenseArtifacts.put(
+ ToscaFileOutputServiceCsarImpl.EXTERNAL_ARTIFACTS_FOLDER_NAME + File.separator +
+ "license-file-1.xml", file1Content.getBytes());
+ licenseArtifacts.put(
+ ToscaFileOutputServiceCsarImpl.EXTERNAL_ARTIFACTS_FOLDER_NAME + File.separator +
+ "license-file-2.xml", file1Content.getBytes());
+
+ licenseArtifactsFiles.setFiles(licenseArtifacts);
+
+ byte[] csarFile = toscaFileOutputServiceCsarImpl.createOutputFile(
+ new ToscaServiceModel(heatFiles, definitionsInput,
+ ToscaUtil.getServiceTemplateFileName(mainServiceTemplate)), licenseArtifactsFiles);
+
+ File file = File.createTempFile("resultFile", "zip");
+ try (FileOutputStream fos = new FileOutputStream(file)) {
+ fos.write(csarFile);
+ }
+
+ try (ZipFile zipFile = new ZipFile(file)) {
+
+ Enumeration<? extends ZipEntry> entries = zipFile.entries();
+ int count = 0;
+ while (entries.hasMoreElements()) {
+ count++;
+ entries.nextElement();
+ }
+ assertEquals(9, count);
+ }
+
+ Files.delete(Paths.get(file.getAbsolutePath()));
+ }
+
+ @Test
public void testCSARFileCreation_noArtifacts() throws IOException {
ServiceTemplate serviceTemplate = new ServiceTemplate();
Map<String, String> metadata = new HashMap<>();
@@ -171,22 +290,21 @@ public class ToscaFileOutputServiceCsarImplTest {
count++;
entries.nextElement();
}
- Assert.assertEquals(2, count);
+ assertEquals(2, count);
}
Files.delete(Paths.get(file.getAbsolutePath()));
}
- @Test(expected = CoreException.class)
+ @Test
public void testCreateOutputFileEntryDefinitionServiceTemplateIsNull() {
ToscaServiceModel toscaServiceModel = new ToscaServiceModel();
toscaServiceModel.setServiceTemplates(Collections.emptyMap());
-
- toscaFileOutputServiceCsarImpl.createOutputFile(toscaServiceModel, null);
+ assertThrows(CoreException.class, () -> toscaFileOutputServiceCsarImpl.createOutputFile(toscaServiceModel, null));
}
@Test
public void testGetArtifactsFolderName() {
- Assert.assertEquals("Artifacts", toscaFileOutputServiceCsarImpl.getArtifactsFolderName());
+ assertEquals("Artifacts", toscaFileOutputServiceCsarImpl.getArtifactsFolderName());
}
}