diff options
17 files changed, 164 insertions, 61 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html index ebfad93c3..bf6bf1251 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.html @@ -22,8 +22,8 @@ <div class="container"> <div class="creat-action-container"> - <a class="action-button save" (click)="editBluePrint()"> - <i class="icon-save-sm" aria-hidden="true"></i> + <a class="action-button save" (click)="editBluePrint()" > + <i class="icon-save-sm" aria-hidden="true" ></i> <span>Save</span> </a> <a href="#" class="action-button" (click)="goBacktoDashboard()"> @@ -62,7 +62,7 @@ <div class="col-12 package-name deployed"> {{viewedPackage.artifactName}} <img src="/assets/img/icon-deploy-inactive.svg" class="deply-status-icon"> - <span class="package-version">v1.0.2</span> + <span class="package-version">v{{viewedPackage.artifactVersion}}</span> </div> <div class="col-12 package-description"> Last modified {{ viewedPackage.createdDate | date:'short' }} By diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts index 4a92943e3..e1e33a39a 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts @@ -14,6 +14,7 @@ import {PackageCreationBuilder} from '../package-creation/creationModes/PackageC import {saveAs} from 'file-saver'; import {DesignerStore} from '../designer/designer.store'; import {DesignerService} from '../designer/designer.service'; +import {ToastrService} from 'ngx-toastr'; @Component({ selector: 'app-configuration-dashboard', @@ -42,7 +43,9 @@ export class ConfigurationDashboardComponent implements OnInit { private packageCreationUtils: PackageCreationUtils, private router: Router, private designerStore: DesignerStore, - private designerService: DesignerService) { + private designerService: DesignerService, + private toastService: ToastrService + ) { } ngOnInit() { @@ -164,8 +167,17 @@ export class ConfigurationDashboardComponent implements OnInit { this.create(); this.zipFile.generateAsync({type: 'blob'}) .then(blob => { - this.packageCreationStore.saveBluePrint(blob); - this.router.navigate(['/packages']); + this.packageCreationStore.saveBluePrint(blob).subscribe( + bluePrintDetailModels => { + if (bluePrintDetailModels) { + const id = bluePrintDetailModels.toString().split('id')[1].split(':')[1].split('"')[1]; + this.toastService.info('package updated successfully '); + this.router.navigate(['/packages/package/' + id]); + } + }, error => { + this.toastService.error('error happened when editing ' + error.message); + console.log('Error -' + error.message); + }); }); } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/PackageCreationModes.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/PackageCreationModes.ts index 5b8db6b6d..6b80358fd 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/PackageCreationModes.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/creationModes/PackageCreationModes.ts @@ -20,9 +20,10 @@ export abstract class PackageCreationModes { } public static mapModeType(cbaPackage: CBAPackage) { - if (cbaPackage.metaData.mode.startsWith('Scripting')) { + console.log(cbaPackage.metaData.mode); + if (cbaPackage.metaData.mode.includes('Scripting')) { cbaPackage.metaData.mode = ModeType.Scripting; - } else if (cbaPackage.metaData.mode.startsWith('Designer')) { + } else if (cbaPackage.metaData.mode.includes('Designer') || cbaPackage.metaData.mode.includes('DEFAULT') ) { cbaPackage.metaData.mode = ModeType.Designer; } else { cbaPackage.metaData.mode = ModeType.Generic; diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/metadata/MetaDataTab.model.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/metadata/MetaDataTab.model.ts index 7200e1210..4d19cf61a 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/metadata/MetaDataTab.model.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/metadata/MetaDataTab.model.ts @@ -38,21 +38,6 @@ export class MetaDataTabModel { } -/*TOSCA-Meta-File-Version: 1.0.0 -CSAR-Version: 1.0 -Created-By: PLATANIA, MARCO <platania@research.att.com> -Entry-Definitions: Definitions/vLB_CDS.json -Template-Name: baseconfiguration -Template-Version: 1.0.0 -Template-Type: DEFAULT -Template-Tags: vDNS-CDS-test1 -Content-Type: application/vnd.oasis.bpmn*/ - -export class MetaDataFile { - - -} - export interface FolderNodes { name: string; diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.html index d73f7da76..28f8938a7 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.html @@ -80,7 +80,7 @@ <span>To add New Custom Key, fill the first key then <b>Press ENTER</b></span> </div> - <div *ngFor="let map of customKeysMap | keyvalue; let i=index" class="single-custom-key"> + <div *ngFor="let map of this.metaDataTab.mapOfCustomKey | keyvalue; let i=index" class="single-custom-key"> <div class="single-line-custom-key"> <label class="label-name"><span>{{i + 1}}.</span> Name</label> <div class="label-input"> diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts index 204d76fdb..dd9f45bf4 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.ts @@ -56,6 +56,7 @@ export class MetadataTabComponent implements OnInit { } this.customKeysMap = element.metaData.mapOfCustomKey; + this.metaDataTab.mapOfCustomKey = this.customKeysMap; // this.tags = element.metaData.templateTags; } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts index 42db2688e..57c849761 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts @@ -30,6 +30,7 @@ import {PackageCreationBuilder} from './creationModes/PackageCreationBuilder'; import {PackageCreationUtils} from './package-creation.utils'; import {MetadataTabComponent} from './metadata-tab/metadata-tab.component'; import {Router} from '@angular/router'; +import {ToastrService} from 'ngx-toastr'; @Component({ @@ -44,7 +45,8 @@ export class PackageCreationComponent implements OnInit { constructor(private packageCreationStore: PackageCreationStore, private packageCreationUtils: PackageCreationUtils, - private router: Router) { + private router: Router, + private toastService: ToastrService) { } counter = 0; @@ -89,8 +91,17 @@ export class PackageCreationComponent implements OnInit { this.create(); this.zipFile.generateAsync({type: 'blob'}) .then(blob => { - this.packageCreationStore.saveBluePrint(blob); - this.router.navigate(['/packages']); + this.packageCreationStore.saveBluePrint(blob).subscribe( + bluePrintDetailModels => { + if (bluePrintDetailModels) { + const id = bluePrintDetailModels.toString().split('id')[1].split(':')[1].split('"')[1]; + this.toastService.info('package updated successfully '); + this.router.navigate(['/packages/package/' + id]); + } + }, error => { + // this.toastService.error('error happened when editing ' + error.message); + console.log('Error -' + error.message); + }); }); } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts index 494c9e555..818577a59 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.service.ts @@ -26,7 +26,7 @@ import {ApiService} from '../../../../common/core/services/api.service'; import {BlueprintURLs, ResourceDictionaryURLs} from '../../../../common/constants/app-constants'; import {PackagesApiService} from '../packages-api.service'; import {PackagesStore} from '../packages.store'; -import { ResourceDictionary } from './mapping-models/ResourceDictionary.model'; +import {ResourceDictionary} from './mapping-models/ResourceDictionary.model'; @Injectable({ providedIn: 'root' @@ -54,13 +54,8 @@ export class PackageCreationService { const formData = new FormData(); formData.append('file', blob); - this.saveBlueprint(formData) - .subscribe( - data => { - console.log('Success:' + JSON.stringify(data)); - }, error => { - console.log('Error -' + error.message); - }); + return this.saveBlueprint(formData); + } getTemplateAndMapping(variables: string[]): Observable<ResourceDictionary[]> { diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts index 8302697fe..ce5dc4884 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts @@ -19,15 +19,16 @@ limitations under the License. ============LICENSE_END============================================ */ -import { Injectable } from '@angular/core'; +import {Injectable} from '@angular/core'; -import { Store } from '../../../../common/core/stores/Store'; +import {Store} from '../../../../common/core/stores/Store'; -import { CBAPackage, DslDefinition } from './mapping-models/CBAPacakge.model'; -import { PackageCreationService } from './package-creation.service'; -import { MetaDataTabModel } from './mapping-models/metadata/MetaDataTab.model'; -import { Observable } from 'rxjs'; -import { ResourceDictionary } from './mapping-models/ResourceDictionary.model'; +import {CBAPackage, DslDefinition} from './mapping-models/CBAPacakge.model'; +import {PackageCreationService} from './package-creation.service'; +import {MetaDataTabModel} from './mapping-models/metadata/MetaDataTab.model'; +import {Observable} from 'rxjs'; +import {ResourceDictionary} from './mapping-models/ResourceDictionary.model'; +import {BluePrintDetailModel} from '../model/BluePrint.detail.model'; @Injectable({ @@ -92,8 +93,8 @@ export class PackageCreationStore extends Store<CBAPackage> { this.state.definitions.imports.delete(filename); } - saveBluePrint(blob) { - this.packageCreationService.savePackage(blob); + saveBluePrint(blob): Observable<BluePrintDetailModel> { + return this.packageCreationService.savePackage(blob); } addTemplate(filePath: string, fileContent: string) { diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/shared-service.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/shared-service.ts index f2b73016c..57c2bcbfa 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/shared-service.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/shared-service.ts @@ -9,6 +9,7 @@ export class SharedService { // based on edit Mode, edit=false mode = new BehaviorSubject(false); + list = new BehaviorSubject(''); constructor() { } @@ -22,4 +23,12 @@ export class SharedService { this.mode.next(false); } + // from file from tempplate&mapping list + deleteFromList(filename) { + this.list.next(filename); + } + listAction(): Observable<string> { + return this.list.asObservable(); + } + } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html index 8acdd6546..cdc73f1b9 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html @@ -5,7 +5,13 @@ class="fa fa-chevron-left mr-2"></i>Template List</button> </div> <div class="col text-right"> - <button (click)="cancel()" [hidden]="fileName?.length <=0" class="btn btn-outline-secondary">Clear</button> + + <button data-toggle="modal" [hidden]="!edit" (click)="initDelete()" data-target="#templateDeletionModal2" + class="btn btn-outline-danger" title="Delete Template">Delete</button> + + + <button (click)="cancel()" [hidden]="fileName?.length <=0 || edit" + class="btn btn-outline-secondary">Clear</button> <button (click)="saveToStore()" [disabled]="fileName?.length <=0" class="btn btn-primary">Finish</button> </div> </div> @@ -272,3 +278,27 @@ </div> </div> </div> + +<!-- Delete Modal --> +<div class="modal fade" id="templateDeletionModal2" tabindex="-1" role="dialog" + aria-labelledby="templateDeletionModal2Label" aria-hidden="true"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title" id="templateDeletionModal2Label">Delete Script</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-body"> + <p>Are you sure you want to delete Template file + <span>{{fileToDelete}}</span>?</p> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> + <button type="button" (click)="confirmDelete()" data-dismiss="modal" + class="btn btn-primary">Delete</button> + </div> + </div> + </div> +</div> diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts index 334b3f484..f6bae0600 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts @@ -47,6 +47,7 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { currentTemplate: any; currentMapping: any; edit = false; + fileToDelete: any = {}; constructor( private packageCreationStore: PackageCreationStore, @@ -63,6 +64,7 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { console.log('Oninit'); console.log(templateInfo); this.templateInfo = templateInfo; + this.fileToDelete = templateInfo.fileName; this.fileName = templateInfo.fileName.split('/')[1]; if (this.fileName) { this.fileName = this.fileName.split('-')[0]; @@ -177,6 +179,22 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy { this.uploadedFiles.splice(index, 1); } + initDelete(file) { + } + confirmDelete() { + // Delete from templates + this.sharedService.deleteFromList(this.fileName); + this.packageCreationStore.state.templates.files.delete(this.fileToDelete); + // Delete from Mapping + this.packageCreationStore.state.mapping.files.delete(this.fileToDelete); + if ( + this.packageCreationStore.state.templates.files.size > 0 || + this.packageCreationStore.state.mapping.files.size > 0 + ) { + this.closeCreationForm(); + } + + } uploadFile() { this.dependancies.clear(); this.dependanciesSource.clear(); diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts index f25dcb1be..c790422c1 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts @@ -61,6 +61,7 @@ export class TemplMappListingComponent implements OnInit { console.log('hello there '); console.log(this.templateAndMappingMap); } + this.deleteFromList(); }); } @@ -77,6 +78,19 @@ export class TemplMappListingComponent implements OnInit { } + deleteFromList() { + this.sharedService.listAction().subscribe(res => { + console.log('response from actionList'); + console.log(res); + if (res) { + this.templateAndMappingMap.delete(res); + if (this.templateAndMappingMap.size <= 0) { + this.openCreationView(); + } + } + }); + } + openCreationView() { this.showCreationViewParentNotification.emit('tell parent to open create views'); console.log('disable edit mode'); diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.ts index 662d8d3f3..af6ced092 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/template-mapping.component.ts @@ -27,6 +27,9 @@ export class TemplateMappingComponent implements OnInit { this.listView = false; console.log('URL contains Id'); this.sharedService.enableEdit(); + if (this.pakcageStore.state.mapping.files.size > 0 || this.pakcageStore.state.templates.files.size > 0) { + this.openListView(); + } } else { console.log('Create mode'); this.pakcageStore.clear(); diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt index f846ab157..d10ec17b0 100755 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/service/BlueprintProcessorCatalogServiceImpl.kt @@ -150,7 +150,7 @@ class BlueprintProcessorCatalogServiceImpl( blueprintModel.updatedBy = metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]!! blueprintModel.tags = metadata[BluePrintConstants.METADATA_TEMPLATE_TAGS]!! val description = if (null != metadata[BluePrintConstants.METADATA_TEMPLATE_DESCRIPTION]) metadata[BluePrintConstants.METADATA_TEMPLATE_DESCRIPTION] else "" - blueprintModel.artifactDescription = "Controller Blueprint for $artifactName:$artifactVersion $description" + blueprintModel.artifactDescription = description val blueprintModelContent = BlueprintModelContent() blueprintModelContent.id = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt index 211bf76fb..4cd809778 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt @@ -105,7 +105,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic /** Resolve and validate lock properties */ implementation.lock?.apply { val resolvedValues = bluePrintRuntimeService.resolvePropertyAssignments( - nodeTemplateName, + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TEMPLATE, interfaceName, mutableMapOf("key" to this.key, "acquireTimeout" to this.acquireTimeout)) this.key = resolvedValues["key"] ?: "".asJsonType() @@ -153,21 +153,14 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic } override suspend fun applyNB(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput { - prepareRequestNB(executionServiceInput) - return implementation.lock?.let { - bluePrintClusterService.clusterLock("${it.key.textValue()}@$CDS_LOCK_GROUP") - .executeWithLock(it.acquireTimeout.intValue().times(1000).toLong()) { - applyNBWithTimeout(executionServiceInput) - } - } ?: applyNBWithTimeout(executionServiceInput) - } - - private suspend fun applyNBWithTimeout(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput { try { - withTimeout((implementation.timeout * 1000).toLong()) { - log.debug("DEBUG::: AbstractComponentFunction.withTimeout section ${implementation.timeout} seconds") - processNB(executionServiceInput) - } + prepareRequestNB(executionServiceInput) + implementation.lock?.let { + bluePrintClusterService.clusterLock("${it.key.textValue()}@$CDS_LOCK_GROUP") + .executeWithLock(it.acquireTimeout.intValue().times(1000).toLong()) { + applyNBWithTimeout(executionServiceInput) + } + } ?: applyNBWithTimeout(executionServiceInput) } catch (runtimeException: RuntimeException) { log.error("failed in ${getName()} : ${runtimeException.message}", runtimeException) recoverNB(runtimeException, executionServiceInput) @@ -175,6 +168,13 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic return prepareResponseNB() } + private suspend fun applyNBWithTimeout(executionServiceInput: ExecutionServiceInput) = + withTimeout((implementation.timeout * 1000).toLong()) { + log.debug("DEBUG::: AbstractComponentFunction.withTimeout " + + "section ${implementation.timeout} seconds") + processNB(executionServiceInput) + } + fun getOperationInput(key: String): JsonNode { return operationInputs[key] ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.") diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt index e0b690573..0f9dfd157 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt @@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.node.ObjectNode import io.mockk.every import io.mockk.mockk +import io.mockk.spyk import io.mockk.verify import kotlinx.coroutines.runBlocking import org.junit.Test @@ -53,6 +54,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.junit4.SpringRunner +import java.lang.RuntimeException import kotlin.test.BeforeTest import kotlin.test.assertEquals import kotlin.test.assertNotNull @@ -204,6 +206,27 @@ class AbstractComponentFunctionTest { } @Test + fun `applyNB should catch exceptions and call recoverNB`() { + val exception = RuntimeException("Intentional test exception") + every { + bluePrintRuntimeService.resolvePropertyAssignments(any(), any(), any()) + } throws exception + every { + blueprintContext.nodeTemplateOperationImplementation(any(), any(), any()) + } returns Implementation().apply { + this.lock = LockAssignment().apply { this.key = "testing-lock".asJsonType() } + } + + val component: AbstractComponentFunction = spyk(SampleComponent()) + component.bluePrintRuntimeService = bluePrintRuntimeService + component.bluePrintClusterService = blueprintClusterService + val input = getMockedInput(bluePrintRuntimeService) + + runBlocking { component.applyNB(input) } + verify { runBlocking { component.recoverNB(exception, input) } } + } + + @Test fun `applyNB - when lock is present use ClusterLock`() { val lockName = "testing-lock" |