aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/utils
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2022-09-05 06:51:13 +0100
committerMichael Morris <michael.morris@est.tech>2022-09-15 08:56:26 +0000
commitab1295e98af672548c10411c245e7da465d9f239 (patch)
treec2ed6c870dcdd05dc2a5db971983f7f55956e89d /catalog-ui/src/app/utils
parent4e9f61a3dce16a2d38e1db1437227377ae490a47 (diff)
Handle CSAR reading errors in Service Import
Issue-ID: SDC-4162 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Change-Id: I13c2d053991f4a2b12e4c845dcd0da6e1c00adae
Diffstat (limited to 'catalog-ui/src/app/utils')
-rw-r--r--catalog-ui/src/app/utils/service-csar-reader.ts22
1 files changed, 13 insertions, 9 deletions
diff --git a/catalog-ui/src/app/utils/service-csar-reader.ts b/catalog-ui/src/app/utils/service-csar-reader.ts
index 73b77559e2..90de53b8c9 100644
--- a/catalog-ui/src/app/utils/service-csar-reader.ts
+++ b/catalog-ui/src/app/utils/service-csar-reader.ts
@@ -26,17 +26,21 @@ export class ServiceCsarReader {
private serviceCsar = new ServiceCsar();
- public read(serviceCsarBlob:Blob): Promise<ServiceCsar> {
+ public read(serviceCsarBlob: Blob): Promise<ServiceCsar> {
const jsZip = require("jszip");
- return new Promise<ServiceCsar>((resolve) => {
+ return new Promise<ServiceCsar>((resolve, reject) => {
jsZip.loadAsync(serviceCsarBlob).then(async zip => {
- const toscaMetaFileContent = await zip.file("TOSCA-Metadata/TOSCA.meta").async("string");
- this.readToscaMeta(toscaMetaFileContent);
- const entryDefinitionFileContent = await zip.file(this.serviceCsar.entryDefinitionFileName).async("string");
- this.readServiceMetadata(entryDefinitionFileContent);
- const interfaceDefinitionFileContent = await zip.file(this.serviceCsar.interfaceDefinitionFileName).async("string");
- this.readServiceSubstitutionNode(interfaceDefinitionFileContent);
- resolve(this.serviceCsar);
+ try {
+ const toscaMetaFileContent = await zip.file("TOSCA-Metadata/TOSCA.meta").async("string");
+ this.readToscaMeta(toscaMetaFileContent);
+ const entryDefinitionFileContent = await zip.file(this.serviceCsar.entryDefinitionFileName).async("string");
+ this.readServiceMetadata(entryDefinitionFileContent);
+ const interfaceDefinitionFileContent = await zip.file(this.serviceCsar.interfaceDefinitionFileName).async("string");
+ this.readServiceSubstitutionNode(interfaceDefinitionFileContent);
+ resolve(this.serviceCsar);
+ } catch (error) {
+ reject(error);
+ }
});
});
}