summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/view-models
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/view-models
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/view-models')
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts45
1 files changed, 30 insertions, 15 deletions
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
index 9d67b8eb69..77c93301b2 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
@@ -41,6 +41,7 @@ import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view
import {CATEGORY_SERVICE_METADATA_KEYS, PREVIOUS_CSAR_COMPONENT, DEFAULT_MODEL_NAME} from "../../../../utils/constants";
import {Observable} from "rxjs";
import {Model} from "../../../../models/model";
+import {SdcUiServices} from "onap-ui-angular/dist";
export class Validation {
componentNameValidationPattern:RegExp;
@@ -127,6 +128,7 @@ export class GeneralViewModel {
'sdcConfig',
'$state',
'ModalsHandler',
+ 'ModalServiceSdcUI',
'EventListenerService',
'Notification',
'Sdc.Services.ProgressService',
@@ -155,6 +157,7 @@ export class GeneralViewModel {
private sdcConfig:IAppConfigurtaion,
private $state:ng.ui.IStateService,
private ModalsHandler:ModalsHandler,
+ private modalServiceSdcUI: SdcUiServices.ModalService,
private EventListenerService:EventListenerService,
private Notification:any,
private progressService:ProgressService,
@@ -277,28 +280,40 @@ export class GeneralViewModel {
if (resource.resourceType === ResourceType.VF && !resource.csarUUID) {
this.$scope.isShowFileBrowse = true;
}
- } else if(this.$scope.component.isService()){
+ } else if (this.$scope.component.isService()) {
let service: Service = <Service>this.$scope.component;
console.log(service.name + ": " + service.csarUUID);
if (service.importedFile) {
this.$scope.isShowFileBrowse = true;
(<Service>this.$scope.component).ecompGeneratedNaming = true;
let blob = this.FileUtils.base64toBlob(service.importedFile.base64, "zip");
- new ServiceCsarReader().read(blob).then((serviceCsar) => {
- serviceCsar.serviceMetadata.contactId = this.cacheService.get("user").userId;
- (<Service>this.$scope.component).setComponentMetadata(serviceCsar.serviceMetadata);
- (<Service>this.$scope.component).model = serviceCsar.serviceMetadata.model;
- this.$scope.onModelChange();
- this.$scope.componentCategories.selectedCategory = serviceCsar.serviceMetadata.selectedCategory;
- this.$scope.onCategoryChange();
- serviceCsar.extraServiceMetadata.forEach((value: string, key: string) => {
- if(this.getMetadataKey(key)) {
- (<Service>this.$scope.component).categorySpecificMetadata[key] = value;
- }
+ new ServiceCsarReader().read(blob).then(
+ (serviceCsar) => {
+ serviceCsar.serviceMetadata.contactId = this.cacheService.get("user").userId;
+ (<Service>this.$scope.component).setComponentMetadata(serviceCsar.serviceMetadata);
+ (<Service>this.$scope.component).model = serviceCsar.serviceMetadata.model;
+ this.$scope.onModelChange();
+ this.$scope.componentCategories.selectedCategory = serviceCsar.serviceMetadata.selectedCategory;
+ this.$scope.onCategoryChange();
+ serviceCsar.extraServiceMetadata.forEach((value: string, key: string) => {
+ if (this.getMetadataKey(key)) {
+ (<Service>this.$scope.component).categorySpecificMetadata[key] = value;
+ }
+ });
+ (<Service>this.$scope.component).derivedFromGenericType = serviceCsar.substitutionNodeType;
+ this.$scope.onBaseTypeChange();
+ },
+ (error) => {
+ const errorMsg = this.$filter('translate')('IMPORT_FAILURE_MESSAGE_TEXT');
+ console.error(errorMsg, error);
+ const errorDetails = {
+ 'Error': error.reason,
+ 'Details': error.message
+ };
+ this.modalServiceSdcUI.openErrorDetailModal('Error', this.$filter('translate')('IMPORT_FAILURE_MESSAGE_TEXT'),
+ 'error-modal', errorDetails);
+ this.$state.go('dashboard');
});
- (<Service>this.$scope.component).derivedFromGenericType = serviceCsar.substitutionNodeType;
- this.$scope.onBaseTypeChange();
- });
}
if (this.$scope.isEditMode() && service.serviceType == 'Service' && !service.csarUUID) {
this.$scope.isShowFileBrowse = true;