Merge "Updated prerequisites"
authorDan Timoney <dtimoney@att.com>
Sun, 31 Mar 2019 12:46:06 +0000 (12:46 +0000)
committerGerrit Code Review <gerrit@onap.org>
Sun, 31 Mar 2019 12:46:06 +0000 (12:46 +0000)
141 files changed:
cds-ui/client/src/app/common/core/store/models/propertyData.model.ts
cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html
cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.scss
cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/existing-model/existing-model.component.html
cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/existing-model/existing-model.component.ts
cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/existing-model/search-resource/search-resource.component.html
cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/existing-model/search-resource/search-resource.component.ts
cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.html
cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.scss
cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.ts
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.html
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.scss
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-edit.component.ts
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.html
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.scss
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/resource-metadata/resource-metadata.component.ts
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.html
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.scss
cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts
cds-ui/client/src/styles.scss
cds-ui/pom.xml
cds-ui/server/tsconfig.json
components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/node_types.json
components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json
components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/DefaultRestconf.cba.kts [new file with mode: 0644]
components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts
components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/python/RestconfConfigDeploy.py
components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/activation-blueprint.json [deleted file]
components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/data_types.json
components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/golden-blueprint.json [new file with mode: 0644]
components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/resources_definition_types.json
components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ConfigDeploy.xml [deleted file]
components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml [deleted file]
components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml [deleted file]
components/model-catalog/blueprint-model/test-blueprint/golden/README
components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/ConfigDeploy.py [moved from components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/NetconfRpcExample.py with 84% similarity]
components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/DescriptionExample.py
components/model-catalog/blueprint-model/test-blueprint/golden/Scripts/python/Rollback.py
components/model-catalog/blueprint-model/test-blueprint/golden/TOSCA-Metadata/TOSCA.meta
components/model-catalog/proto-definition/proto/BluePrintManagement.proto
components/parent/pom.xml
components/scripts/python/ccsdk_restconf/restconf_client.py
ms/blueprintsprocessor/application/src/main/resources/application-dev.properties
ms/blueprintsprocessor/application/src/main/resources/application.properties
ms/blueprintsprocessor/application/src/main/resources/logback.xml
ms/blueprintsprocessor/application/src/test/resources/application.properties
ms/blueprintsprocessor/distribution/src/main/docker/distribution.xml
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/mocks/NetconfDeviceSimulator.kt
ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/mocks/NetconfSubsystemFactory.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kts [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImplTest.kt
ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/application-test.properties
ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/factory/ComponentNodeFactory.kt
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/cds/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
ms/blueprintsprocessor/parent/pom.xml
ms/controllerblueprints/application/pom.xml
ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/ControllerBlueprintsApplication.java
ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java
ms/controllerblueprints/application/src/main/resources/application-dev.properties
ms/controllerblueprints/application/src/main/resources/application.properties
ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/config/BluePrintLoadConfiguration.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintCatalogService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContext.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintExpressionService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintValidatorService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/PropertyAssignmentService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintFileUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/ResourceResolverUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt [new file with mode: 0644]
ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintContextTest.kt
ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonReactorUtilsTest.kt
ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/JacksonUtilsTest.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt
ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/extension/ResourceDefinitionValidation.kt
ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt
ms/controllerblueprints/modules/pom.xml
ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt
ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java
ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt
ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/ApplicationRegistrationService.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/AutoResourceMappingService.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/SchemaGeneratorService.java
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelController.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintArtifactDefinitionEnhancerImpl.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintNodeTypeEnhancerImpl.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintServiceTemplateEnhancerImpl.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/BluePrintWorkflowEnhancerImpl.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/BluePrintModelHandler.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/handler/ModelTypeHandler.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintCatalogLoadService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ModelTypeLoadService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/load/ResourceDictionaryLoadService.kt
ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/utils/BluePrintEnhancerUtils.kt
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SchemaGeneratorServiceTest.java
ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/ModelTypeServiceTest.kt
ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/BlueprintModelControllerTest.kt
ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/service/controller/ModelTypeControllerTest.kt
ms/controllerblueprints/modules/service/src/test/resources/application.properties
ms/controllerblueprints/parent/pom.xml
pom.xml

index 94cff89..96e9fda 100644 (file)
@@ -20,8 +20,8 @@
 import {IEntrySchema} from './entrySchema.model';
 
 export interface IPropertyData{  
-    discription:string;
-    _type:string;
+    description:string;
+    type:string;
     required:boolean;
     entry_schema:IEntrySchema;
 }
\ No newline at end of file
index 1ce5bf5..6113e6d 100644 (file)
@@ -23,9 +23,9 @@ limitations under the License.
         <!-- <div style="width:inherit; height: inherit; position: fixed;z-index: 1; background-color: rgb(0,0,0);background-color: rgba(0,0,0,0.4);"></div> -->
         <div style="display: flex;">
             <div>
-                <i class="fa fa-folder" aria-hidden="true" style="color:#3f51b5; font-size: 20px;margin: 3px; cursor: pointer;" [ngClass] ="{'fa-disabled': selectedFileObj.type == 'file' || selectedFileObj.type == ''}" (click)="enableNameInputEl('createFolder')"></i>
-                <i class="fa fa-file" aria-hidden="true" style="color:#3f51b5; font-size: 18px; margin: 3px; cursor: pointer;" [ngClass] ="{'fa-disabled' : selectedFileObj.type == 'file' ||selectedFileObj.type == ''}" (click)="enableNameInputEl('createFile')"></i>
-                <i class="fa fa-trash" aria-hidden="true" style="color:#3f51b5; font-size: 20px; margin: 3px; cursor: pointer;" [ngClass] ="{'fa-disabled' : selectedFileObj.type == ''}"  (click)="deleteFolderOrFile('deleteFile')"></i>
+                <i class="fa fa-folder delete-add-file" aria-hidden="true" [ngClass] ="{'fa-disabled': selectedFileObj.type == 'file' || selectedFileObj.type == ''}" (click)="enableNameInputEl('createFolder')"></i>
+                <i class="fa fa-file add-file" aria-hidden="true" [ngClass] ="{'fa-disabled' : selectedFileObj.type == 'file' ||selectedFileObj.type == ''}" (click)="enableNameInputEl('createFile')"></i>
+                <i class="fa fa-trash delete-add-file" aria-hidden="true" [ngClass] ="{'fa-disabled' : selectedFileObj.type == ''}"  (click)="deleteFolderOrFile('deleteFile')"></i>
             </div>
             <div>
                 <input *ngIf="isNameTextboxEnablled" type="text" (focusout)="createFolderOrFile($event)"/>
index fac43eb..8375fff 100644 (file)
@@ -72,4 +72,18 @@ limitations under the License.
 
   .mat-tree-node {
     min-height: 40px !important;
+  }
+
+  .delete-add-file {
+    color:#3f51b5; 
+    font-size: 20px;
+    margin: 3px; 
+    cursor: pointer;
+  }
+
+  .add-file {
+    color:#3f51b5; 
+    font-size: 18px; 
+    margin: 3px; 
+    cursor: pointer;
   }
\ No newline at end of file
index f780ef8..9fdc388 100644 (file)
 */
 
 import { Component, OnInit } from '@angular/core';
+import { Store } from '@ngrx/store';
+import { IResources } from 'src/app/common/core/store/models/resources.model';
+import { IAppState } from 'src/app/common/core/store/state/app.state';
+import { LoadResourcesSuccess } from 'src/app/common/core/store/actions/resources.action';
 
 @Component({
   selector: 'app-existing-model',
@@ -27,9 +31,27 @@ import { Component, OnInit } from '@angular/core';
 })
 export class ExistingModelComponent implements OnInit {
 
-  constructor() { }
+  resourceName:string;
+  
+ constructor(private store: Store<IAppState>) { }
 
   ngOnInit() {
-  }
+ }
+ selectedResource(value){
+  console.log(value);
+  this.resourceName=value;
+ }
+
+ getDataUsingResouceName(){
+ }
+
+ updateResourcesState() {
+    var me = this; 
+    var data:IResources;
+    me.store.dispatch(new LoadResourcesSuccess(data));   
+ }
+
 
 }
index ab69628..236196b 100644 (file)
@@ -23,7 +23,7 @@
     <input type="text" [(ngModel)]="searchText" placeholder="Search Resources" matInput [matAutocomplete]="auto" formControlName="search_input">
     <button matSuffix mat-icon-button><mat-icon>search</mat-icon></button>
     <mat-autocomplete #auto="matAutocomplete">
-      <mat-option *ngFor="let option of options | search : searchText" [value]="option">
+      <mat-option (click)="selected(option)" *ngFor="let option of options | search : searchText" [value]="option">
         {{option}}
       </mat-option>
     </mat-autocomplete>
index 16129b7..7f2745e 100644 (file)
@@ -18,7 +18,7 @@
 * ============LICENSE_END=========================================================
 */
 
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, ViewChild, EventEmitter, Output  } from '@angular/core';
 import {FormBuilder, FormGroup, Validators} from '@angular/forms';
 @Component({
   selector: 'app-search-resource',
@@ -27,17 +27,18 @@ import {FormBuilder, FormGroup, Validators} from '@angular/forms';
 })
 export class SearchResourceComponent implements OnInit  {
 
-   myControl: FormGroup;
-
+  myControl: FormGroup;
+  @Output() resourcesData = new EventEmitter();  
+  options: string[] = ['One','One1', 'Two', 'Three'];
   constructor(private _formBuilder: FormBuilder)  { }
   
-  options: string[] = ['One','One1', 'Two', 'Three'];
-    
-    ngOnInit() {
+ ngOnInit() {
     this.myControl = this._formBuilder.group({
       search_input: ['', Validators.required]
     });
   }
-    
+ selected(value){
+   this.resourcesData.emit(value);
+   } 
 }
 
index 8ace910..c4fa67a 100644 (file)
     <ng-template matStepLabel>Browse or Search Resources</ng-template>
   <app-upload-resource (fileData)=upload($event)></app-upload-resource><br><br>
   <app-existing-model></app-existing-model>
-    <div>
-      <button mat-button matStepperNext (click)="updateResourcesState()" class="matStepNextBtn">Upload</button>
+   <div>      
+       <button mat-button matStepperNext (click)="updateResourcesState()" class="matStepNextBtn">Upload</button>
+   </div><br><br>
+   <div *ngIf="showMsg">
+    <p class="success"><strong>File Upload Success!</strong> Please click Proceed to continue!</p>
     </div>
-  </mat-step>
+   </mat-step>
  </mat-vertical-stepper>
  </mat-card-content>
 </mat-card>
\ No newline at end of file
index c751e0e..549fbb7 100644 (file)
@@ -34,6 +34,8 @@ export class ResourceCreationComponent implements OnInit {
 
   myFile: any;
   selectedValue: any;
+  showMsg:boolean=false;
+  
   constructor(private store: Store<IAppState>) {
   }
 
@@ -53,6 +55,7 @@ export class ResourceCreationComponent implements OnInit {
     me.store.dispatch(new LoadResourcesSuccess(data));
     console.log(data);
     }
+    this.showMsg= true;
  }
 
  selectedOption(value){
index 7df5092..de81e23 100644 (file)
 */-->
 
 
-<mat-card class="metadata-card">
+<button (click) ="changeView()" class="toggle-view-btn">{{viewText}}</button>
+<br><br>
+<div *ngIf="designerMode">
+   <mat-card class="metadata-card">
         <mat-card-header>
             <mat-card-title>Resource Metadata</mat-card-title>
         </mat-card-header>
         <mat-card-content>
-            <app-resource-metadata></app-resource-metadata>
+            <app-resource-metadata (resourcesData)="metaDataDetail($event)"></app-resource-metadata>
         </mat-card-content>
-</mat-card>
+    </mat-card>
 
-<mat-card class="sources-card">
-     <mat-card-header>
+       <mat-card class="sources-card">
+       <mat-card-header>
           <mat-card-title>
                 Sources
           </mat-card-title>
-    </mat-card-header>
-    <mat-card-content>
-          <app-sources-template></app-sources-template>
-    </mat-card-content>
-</mat-card>
+       </mat-card-header>
+       <mat-card-content>
+               <app-sources-template (resourcesData)="sourcesDetails($event)"></app-sources-template>
+       </mat-card-content>
+    </mat-card>
+</div>
 
-<mat-card class="submit">
-   <button mat-raised-button>Save</button>
-</mat-card>
-<!-- <router-outlet></router-outlet> -->
\ No newline at end of file
+<div *ngIf="editorMode">
+       <json-editor  class="jsoneditor" *ngIf="editorMode" [options]="options" [data]="resources" on-change="onChange($event)"></json-editor>
+</div>
+<div class="btn"> 
+       <button mat-button matStepperPrevious>Back</button></div>
+<div class="btn">
+       <button mat-button matStepperNext type="submit" (click)="updateResourcesState()">Upload</button>
+</div> 
index 7c60cf3..280645e 100644 (file)
@@ -25,6 +25,7 @@
   margin: 20px 0;
   box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12)!important;
   height: auto;
+  min-height:340px;
 }
 .sources-card {
   width: 100%;  
   margin: 20px 0;
   box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12)!important;
   height: auto;
+  min-height:300px;
 }
-.mat-raised-button{
-  border: 1px solid grey;
-  background-color: #3f51b5;
-  padding: 1px;
-  color: white;
-  border-radius: 1em;
+.mat-button{
+    color:white;
+    background:#3f51b5; 
+    margin-top: 10px; 
+    position: absolute;
+    border-radius: 1em;
 }
 .mat-card-title{
    padding-top: 7px;
    padding: 8px 8px;
    word-wrap: break-word;
 }
+.btn{
+  width: 50px;
+  max-width: 100%;
+  margin: 0 25px 25px 0;
+  display: inline-block;
+  vertical-align: top;
+}
+.toggle-view-btn{
+    color:white;
+    background:#3f51b5; 
+    border-radius: 1em;
+    margin-top: 10px;
+    padding:0.6em;
+    border: 1px solid #3f51b5;
+}
index 5b56703..55b8062 100644 (file)
 * ============LICENSE_END=========================================================
 */
 
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, ViewChild } from '@angular/core';
+import { IResources } from 'src/app/common/core/store/models/resources.model';
+import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model';
+import { LoadResourcesSuccess,UpdateResources,SetResourcesState } from 'src/app/common/core/store/actions/resources.action';
+import { Store } from '@ngrx/store';
+import { IAppState } from '../../../common/core/store/state/app.state';
+import { JsonEditorComponent, JsonEditorOptions } from 'ang-jsoneditor';
+import { Observable } from 'rxjs';
+import { A11yModule } from '@angular/cdk/a11y';
 
 @Component({
   selector: 'app-resource-edit',
@@ -27,9 +35,62 @@ import { Component, OnInit } from '@angular/core';
 })
 export class ResourceEditComponent implements OnInit {
 
-  constructor() { }
+    resources:IResources;
+    data:IResources;
+    rdState: Observable<IResourcesState>;
+    designerMode: boolean = true;
+    editorMode: boolean = false;
+    viewText: string = "Open in Editor Mode";
+    @ViewChild(JsonEditorComponent) editor: JsonEditorComponent;
+    options = new JsonEditorOptions();
+  
+  constructor(private store: Store<IAppState>) {
+       this.rdState = this.store.select('resources');
+    this.options.mode = 'text';
+    this.options.modes = [ 'text', 'tree', 'view'];
+    this.options.statusBar = false;    
+  }
 
   ngOnInit() {
+    this.rdState.subscribe(
+      resourcesdata => {
+        var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess };
+          this.resources=resourcesState.resources;
+    })     
   }
 
+ metaDataDetail(data: IResources) {
+    this.data=data;       
+  }
+    
+ sourcesDetails(data: IResources) {
+    this.data=data; 
+ }
+    
+ onChange($event) {
+      this.data=JSON.parse($event.srcElement.value);
+  };
+  
+ updateResourcesState(){
+      console.log(this.data);
+      let resourcesState = {
+      resources: this.data,
+      isLoadSuccess: true,
+      isUpdateSuccess:true,
+      isSaveSuccess:true
+    }  
+   this.store.dispatch(new SetResourcesState(resourcesState));   
+  }
+    
+ changeView() {
+    if(this.viewText == 'Open in Editor Mode') {
+      this.editorMode =  true;
+      this.designerMode = false;
+      this.viewText = 'Open in Form Mode'
+    } else {
+      this.editorMode =  false;
+      this.designerMode = true;
+      this.viewText = 'Open in Editor Mode'
+    }
+  }  
 }
index 0bbc0b7..3b35a99 100644 (file)
@@ -18,7 +18,7 @@
 * ============LICENSE_END=========================================================
 */-->
 
-<form [formGroup]="ResourceMetadata">
+<form [formGroup]="ResourceMetadata" (ngSubmit)="UploadMetadata()">
        <mat-form-field class="form-field">
       <input matInput placeholder="Name" formControlName="Resource_Name">
     </mat-form-field><mat-form-field class="form-field">
@@ -42,4 +42,8 @@
     <mat-form-field class="form-field" >
       <textarea matInput placeholder="Description" formControlName="_description"></textarea>
     </mat-form-field>
+    <br>
+    <div>
+       <button mat-button class="matStepNextBtn" type="submit">Save Metadata</button>
+    </div>  
 </form>
\ No newline at end of file
index 536be26..29244f0 100644 (file)
@@ -18,7 +18,7 @@
 * ============LICENSE_END=========================================================
 */
 
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, EventEmitter, Output  } from '@angular/core';
 import {FormBuilder, FormGroup, Validators} from '@angular/forms';
 import { IResources } from 'src/app/common/core/store/models/resources.model';
 import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model';
@@ -45,7 +45,8 @@ export class ResourceMetadataComponent implements OnInit {
     resources: IResources;
     propertyValues = [];
     property = [];   
-  
+    @Output() resourcesData = new EventEmitter();
+     
  constructor(private formBuilder: FormBuilder, private store: Store<IAppState>) { 
     this.rdState = this.store.select('resources');
     this.ResourceMetadata = this.formBuilder.group({
@@ -68,16 +69,27 @@ export class ResourceMetadataComponent implements OnInit {
         this.properties= resourcesState.resources.property;
         this.propertyValues=  this.checkNested(this.properties);
         this.ResourceMetadata = this.formBuilder.group({
-       Resource_Name: [this.resource_name, Validators.required],
-        _tags: [this.tags, Validators.required],
-        _description : [ this.propertyValues[0], Validators.required],
-        _type: [ this.propertyValues[1], Validators.required],
-        required: [ this.propertyValues[2], Validators.required],
-        entry_schema: [this.propertyValues[3]]
+        Resource_Name: [this.resource_name, Validators.required],
+         _tags: [this.tags, Validators.required],
+         _description : [ this.propertyValues[0], Validators.required],
+         _type: [ this.propertyValues[1], Validators.required],
+         required: [ JSON.stringify(this.propertyValues[2]), Validators.required],
+         entry_schema: [this.propertyValues[3]]
       });   
     })
  }
-    
+  
+ UploadMetadata() {
+  
+    this.resources.name = this.ResourceMetadata.value.Resource_Name;
+    this.resources.tags = this.ResourceMetadata.value._tags;
+    this.resources.property.description = this.ResourceMetadata.value._description;
+    this.resources.property.type = this.ResourceMetadata.value._type;
+       this.resources.property.required = this.ResourceMetadata.value.required;
+       this.resources.property.entry_schema = this.ResourceMetadata.value.entry_schema;
+       this.resourcesData.emit(this.resources); 
+ }
+   
  checkNested(obj) {
   for (let key in obj) {
     if (obj.hasOwnProperty(key)) {
index 903c6d3..91a22b8 100644 (file)
       [cdkDropListData]="sourcesOptions"
       class="sources-list"
       (cdkDropListDropped)="drop($event)">
-       <div class="sources-box" *ngFor="let item of sourcesOptions" cdkDrag>
+       <div class="sources-box" *ngFor="let item of sourcesOptions;let i = index" cdkDrag>
                <mat-expansion-panel class="expansion-panel">
                        <mat-expansion-panel-header>
                                <mat-panel-title>
                                        {{item}}
                                </mat-panel-title>
                        </mat-expansion-panel-header>
-                       <json-editor [options]="options" [data]="selected(item)" on-change="onChange()"></json-editor>
+                       <json-editor [options]="options" [data]="selected(item)" on-change="onChange(item,$event)"></json-editor>
                         </mat-expansion-panel>
+                        <button matSuffix mat-icon-button (click)="delete(item,i)"><mat-icon class="icon">delete</mat-icon></button>
        </div>
     </div>
   </div>
@@ -52,5 +53,8 @@
       (cdkDropListDropped)="drop($event)">
       <div class="options-box" *ngFor="let item of option | search :searchText" cdkDrag>{{item}}</div>
     </div>
-  </div>
+   </div>
+   <div> 
+       <button mat-button class="matStepNextBtn" (click)="UploadSourcesData()">Save Sources Data</button>
+   </div>
 </div>
\ No newline at end of file
index a76b60a..5bec796 100644 (file)
   overflow: hidden;\r
   display: block;\r
   width: 100%;\r
-  }
\ No newline at end of file
+ }\r
+ .matStepNextBtn{\r
+    color:white;\r
+    background:#3f51b5; \r
+    margin-top: 10px; \r
+    position: absolute;\r
+    border-radius: 1em;\r
+} \r
+.icon{\r
+color: red;\r
+}
\ No newline at end of file
index c43d1de..517add8 100644 (file)
@@ -18,7 +18,7 @@
 * ============LICENSE_END=========================================================
 */
 
-import { Component, OnInit, ViewChild } from '@angular/core';
+import { Component, OnInit, ViewChild, EventEmitter, Output } from '@angular/core';
 import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
 import { IResources } from 'src/app/common/core/store/models/resources.model';
 import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model';
@@ -36,52 +36,68 @@ import { JsonEditorComponent, JsonEditorOptions } from 'ang-jsoneditor';
   styleUrls: ['./sources-template.component.scss']
 })
 export class SourcesTemplateComponent implements OnInit {
-//    rdState: Observable<IResourcesState>;
-//    resources: IResources;
-//    todo = [];
-//    sources:ISourcesData; 
-//    sourcesOptions = [];
 
     @ViewChild(JsonEditorComponent) editor: JsonEditorComponent;
-    options = new JsonEditorOptions();
-    
+    options = new JsonEditorOptions(); 
     rdState: Observable<IResourcesState>;
     resources: IResources;
     option = ['mdsal','default'];
     sources:ISourcesData; 
     sourcesOptions = [];
     sourcesData = [];
-    
+    @Output() resourcesData = new EventEmitter();  
  constructor(private store: Store<IAppState>) {
-   this.rdState = this.store.select('resources');
-      this.options.mode = 'text';
+    this.rdState = this.store.select('resources');
+    this.options.mode = 'text';
     this.options.modes = [ 'text', 'tree', 'view'];
-    this.options.statusBar = false;
-    this.options.onChange = () => console.log(this.editor.get());
-     
+    this.options.statusBar = false;     
  }
 
  ngOnInit() {
     this.rdState.subscribe(
       resourcesdata => {
         var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess };
+        this.resources=resourcesState.resources;
         this.sources = resourcesState.resources.sources;
         for (let key in this.sources) {
             this.sourcesOptions.push(key);  
         }
-        //console.log(this.sourcesOptions);
     })
  }
 
- onChange() {
-     console.log(this.editor.get())
+ onChange(item,$event) {
+    var editedData =JSON.parse($event.srcElement.value);
+    var originalSources = this.resources.sources;
+     for (let key in originalSources){
+        if(key == item){
+            originalSources[key] = editedData;
+        }
+     }
+     this.resources.sources = Object.assign({},originalSources);
  };
     
  selected(value){
-    console.log(value);
-        this.sourcesData=this.sources[value];
-        return this.sourcesData;    
+       this.sourcesData=this.sources[value];
+    return this.sourcesData;    
  }    
+
+ delete(item,i){
+       if(confirm("Are sure you want to delete this source ?")) {
+       var originalSources = this.resources.sources;
+       for (let key in originalSources){
+               if(key == item){    
+                       delete originalSources[key];
+               }
+       }
+       this.resources.sources = Object.assign({},originalSources);
+               this.sourcesOptions.splice(i,1);
+       }     
+ } 
+  
+ UploadSourcesData() {
+       this.resourcesData.emit(this.resources);        
+  }
     
  drop(event: CdkDragDrop<string[]>) {
     if (event.previousContainer === event.container) {
index 54eb746..c75748a 100644 (file)
@@ -45,4 +45,28 @@ limitations under the License.
     min-width: 6em;
     border: none;
     cursor: initial;
-}
\ No newline at end of file
+}
+div.jsoneditor-outer {
+    position: static;
+    width: 100%;
+    height: 400px;
+    margin: 0;
+    padding: 0;
+    box-sizing: border-box;
+    color:white;
+}
+div.jsoneditor-outer.has-main-menu-bar{
+background-color:#3f51b5;
+
+}
+div.jsoneditor-tree div.jsoneditor-tree-inner{
+    padding-bottom: 300px;
+    background-color: white;     
+}
+div.jsoneditor-treepath {
+    padding: 0 5px;
+    overflow: hidden;
+    white-space: nowrap;
+    outline: 0;
+    color:white;
+   }
\ No newline at end of file
index ca3f8b9..a6cd085 100644 (file)
@@ -25,7 +25,7 @@ limitations under the License.
     <parent>
         <groupId>org.onap.ccsdk.parent</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>1.2.1-SNAPSHOT</version>
+        <version>1.2.2-SNAPSHOT</version>
         <relativePath/>
     </parent>
 
index eb96bb5..e042793 100644 (file)
@@ -10,5 +10,8 @@
     "node_modules/**",
     "packages/*/node_modules/**",
     "**/*.d.ts"
-  ]
+  ],
+  "compilerOptions": {
+    "experimentalDecorators": true
+  }
 }
index a8329b8..fdc18c5 100644 (file)
           }
         }
       },
+      "activate-restconf": {
+        "type": "component-restconf-executor",
+        "interfaces": {
+          "ComponentRestconfExecutor": {
+            "operations": {
+              "process": {
+                "implementation": {
+                  "primary": "component-script"
+                },
+                "inputs": {
+                  "script-type": "kotlin",
+                  "script-class-reference": "DefaultRestconf_cba$MountNEditConfigure",
+                  "instance-dependencies": []
+                },
+                "outputs": {
+                  "response-data": "",
+                  "status": "success"
+                }
+              }
+            }
+          }
+        }
+      },
       "sample-netconf-device": {
         "type": "vnf-netconf-device",
         "capabilities": {
           }
         }
       },
+      "activate-restconf": {
+        "steps": {
+          "activate-process": {
+            "description": "Activate Restconf flow",
+            "target": "activate-restconf",
+            "activities": [
+              {
+                "call_operation": "ComponentRestconfExecutor.process"
+              }
+            ]
+          }
+        }
+      },
       "assign-activate": {
         "inputs": {
           "assign-activate-properties": {
index 3658a26..07e4df1 100644 (file)
           "operations": {
             "process": {
               "inputs": {
+                "resolution-key": {
+                  "description": "Key for service instance related correlation.",
+                  "required": false,
+                  "type": "string"
+                },
+                "store-result": {
+                  "description": "Whether or not to store the output.",
+                  "required": false,
+                  "type": "boolean"
+                },
                 "resource-type": {
                   "description": "Request type.",
                   "required": false,
       },
       "derived_from": "tosca.nodes.Component"
     },
+    "component-restconf-executor": {
+      "description": "This is Restconf Transaction Configuration Component API",
+      "version": "1.0.0",
+      "capabilities": {
+        "component-node": {
+          "type": "tosca.capabilities.Node"
+        }
+      },
+      "interfaces": {
+        "ComponentRestconfExecutor": {
+          "operations": {
+            "process": {
+              "inputs": {
+                "script-type": {
+                  "description": "Script type, kotlin type is supported",
+                  "required": true,
+                  "type": "string",
+                  "constraints": [
+                    {
+                      "valid_values": [
+                        "kotlin",
+                        "jython",
+                        "internal"
+                      ]
+                    }
+                  ],
+                  "default": "internal"
+                },
+                "script-class-reference": {
+                  "description": "Kotlin Script class name or jython script name.",
+                  "required": true,
+                  "type": "string"
+                },
+                "instance-dependencies": {
+                  "description": "Instance names to inject to Jython or Kotlin Script.",
+                  "required": true,
+                  "type": "list",
+                  "entry_schema": {
+                    "type": "string"
+                  }
+                },
+                "dynamic-properties": {
+                  "description": "Dynamic Json Content or DSL Json reference.",
+                  "required": false,
+                  "type": "json"
+                }
+              },
+              "outputs": {
+                "response-data": {
+                  "description": "Execution Response Data in JSON format.",
+                  "required": false,
+                  "type": "string"
+                },
+                "status": {
+                  "description": "Status of the Component Execution ( success or failure )",
+                  "required": true,
+                  "type": "string"
+                }
+              }
+            }
+          }
+        }
+      },
+      "derived_from": "tosca.nodes.Component"
+    },
     "dg-generic": {
       "description": "This is Generic Directed Graph Type",
       "version": "1.0.0",
       },
       "derived_from": "tosca.nodes.Workflow"
     },
+    "source-capability": {
+      "description": "This is Component Resource Source Node Type",
+      "version": "1.0.0",
+      "properties": {
+        "script-type": {
+          "required": true,
+          "type": "string",
+          "constraints": [
+            {
+              "valid_values": [
+                "kotlin",
+                "internal",
+                "jython"
+              ]
+            }
+          ],
+          "default": "kotlin"
+        },
+        "script-class-reference": {
+          "description": "Capability reference name for internal and kotlin, for jython script file path",
+          "required": true,
+          "type": "string"
+        },
+        "instance-dependencies": {
+          "description": "Instance dependency Names to Inject to Kotlin / Jython Script.",
+          "required": false,
+          "type": "list",
+          "entry_schema": {
+            "type": "string"
+          }
+        },
+        "key-dependencies": {
+          "description": "Resource Resolution dependency dictionary names.",
+          "required": true,
+          "type": "list",
+          "entry_schema": {
+            "type": "string"
+          }
+        }
+      },
+      "derived_from": "tosca.nodes.ResourceSource"
+    },
     "source-input": {
       "description": "This is Input Resource Source Node Type",
       "version": "1.0.0",
       },
       "derived_from": "tosca.nodes.ResourceSource"
     },
-    "source-processor-db": {
+    "source-primary-db": {
       "description": "This is Database Resource Source Node Type",
       "version": "1.0.0",
       "properties": {
           ],
           "default": "JSON"
         },
+        "verb": {
+          "required": false,
+          "type": "string",
+          "constraints": [
+            {
+              "valid_values": [
+                "GET",
+                "POST",
+                "DELETE",
+                "PUT"
+              ]
+            }
+          ],
+          "default": "GET"
+        },
+        "payload": {
+          "required": false,
+          "type": "string",
+          "default": ""
+        },
         "endpoint-selector": {
           "required": false,
           "type": "string"
index 6e3d5e9..d926aa3 100644 (file)
@@ -27,7 +27,7 @@
         "properties": {}
       },
       "processor-db": {
-        "type": "source-processor-db",
+        "type": "source-primary-db",
         "properties": {
           "endpoint-selector": "dynamic-db-source",
           "query": "SELECT artifact_name FROM sdnctl.BLUEPRINT_RUNTIME where artifact_version=\"1.0.0\"",
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/DefaultRestconf.cba.kts b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/DefaultRestconf.cba.kts
new file mode 100644 (file)
index 0000000..770c363
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  Copyright Â© 2019 IBM.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.RestconfComponentFunction
+import org.slf4j.LoggerFactory
+
+open class MountNEditConfigure : RestconfComponentFunction() {
+
+    val log = LoggerFactory.getLogger(MountNEditConfigure::class.java)!!
+
+    override fun getName(): String {
+        return "MountNEditConfigure"
+    }
+
+    override fun process(executionRequest: ExecutionServiceInput) {
+        log.info("processing request..")
+
+    }
+
+    override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+        log.info("processing request..")
+    }
+}
\ No newline at end of file
index a471349..de2f15d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright Â© 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright Â© 2019 IBM.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.*
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintScriptsService
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.slf4j.LoggerFactory
 
 open class ScriptResourceAssignmentProcessor : ResourceAssignmentProcessor() {
 
-    lateinit var resourceAssignment: ResourceAssignment
+    private val log = LoggerFactory.getLogger(ScriptResourceAssignmentProcessor::class.java)!!
 
     override fun getName(): String {
-        return "resource-assignment-processor-custom-capability"
+        return "ScriptResourceAssignmentProcessor"
     }
 
-    override fun process(resourceAssignment: ResourceAssignment) {
-        this.resourceAssignment = resourceAssignment
+    override fun process(executionRequest: ResourceAssignment) {
+        log.info("Processing input")
     }
 
-    override fun prepareResponse(): ResourceAssignment {
-        return resourceAssignment
+    override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+        log.info("Recovering input")
     }
-
-    override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
-        TODO("To Implement")
-    }
-
 }
\ No newline at end of file
index 78a38a2..d65aefa 100644 (file)
@@ -37,11 +37,19 @@ class RestconfConfigDeploy(RestconfComponentFunction):
             web_client_service = self.restClientService(self.restconf_server_identifier)
 
             try:
+                # mount the device
                 mount_payload = self.resolveAndGenerateMessage("config-deploy-mapping", "config-deploy-template")
                 restconf_client.mount_device(web_client_service, pnf_id, mount_payload)
 
+                # log the current configuration subtree
+                current_configuration = restconf_client.retrieve_device_configuration_subtree(
+                    web_client_service, pnf_id, self.configlet_resource_path)
+                self.log.info("Current configuration subtree: {}", current_configuration)
+
+                # apply configuration
                 configlet = self.resolveFromDatabase(resolution_key, self.configlet_template_name)
-                restconf_client.configure_device(web_client_service, pnf_id, self.configlet_resource_path, configlet)
+                restconf_client.configure_device_json_patch(
+                    web_client_service, pnf_id, self.configlet_resource_path, configlet)
             except Exception, err:
                 self.log.error("an error occurred while configuring device {}", err)
                 raise err
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/activation-blueprint.json
deleted file mode 100644 (file)
index b6464f3..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-{
-  "tosca_definitions_version" : "controller_blueprint_1_0_0",
-  "metadata" : {
-    "template_author" : "Alexis de Talhouët",
-    "author-email" : "adetalhouet89@gmail.com",
-    "user-groups" : "ADMIN, OPERATION",
-    "template_name" : "test",
-    "template_version" : "1.0.0",
-    "template_tags" : "test"
-  },
-  "imports" : [ {
-    "file" : "Definitions/data_types.json"
-  }, {
-    "file" : "Definitions/relationship_types.json"
-  }, {
-    "file" : "Definitions/artifact_types.json"
-  }, {
-    "file" : "Definitions/node_types.json"
-  }, {
-    "file" : "Definitions/policy_types.json"
-  } ],
-  "dsl_definitions" : {
-    "ipam-1" : {
-      "type" : "token-auth",
-      "url" : "http://localhost:32778",
-      "token" : "Token 0123456789abcdef0123456789abcdef01234567"
-    },
-    "config-deploy-properties" : {
-      "resolution-key" : {
-        "get_input" : "resolution-key"
-      }
-    }
-  },
-  "topology_template" : {
-    "workflows" : {
-      "resource-assignment" : {
-        "steps" : {
-          "resource-assignment-process" : {
-            "description" : "Resource Assign Workflow",
-            "target" : "resource-assignment-process",
-            "activities" : [ {
-              "call_operation" : ""
-            } ]
-          }
-        },
-        "inputs" : {
-          "artifact-name" : {
-            "required" : true,
-            "type" : "list",
-            "entry_schema" : {
-              "type" : "string"
-            }
-          },
-          "store-result" : {
-            "required" : true,
-            "type" : "boolean"
-          },
-          "resolution-key" : {
-            "required" : true,
-            "type" : "string"
-          },
-          "resource-assignment-properties" : {
-            "description" : "Dynamic PropertyDefinition for workflow(resource-assignment).",
-            "required" : true,
-            "type" : "dt-resource-assignment-properties"
-          }
-        }
-      },
-      "config-deploy" : {
-        "steps" : {
-          "config-deploy" : {
-            "description" : "Resource Assign and Python Netconf Activation Workflow",
-            "target" : "config-deploy-process",
-            "activities" : [ {
-              "call_operation" : ""
-            } ]
-          }
-        },
-        "inputs" : {
-          "resolution-key" : {
-            "required" : false,
-            "type" : "string"
-          },
-          "password" : {
-            "required" : true,
-            "type" : "string"
-          },
-          "username" : {
-            "required" : true,
-            "type" : "string"
-          },
-          "ip" : {
-            "required" : true,
-            "type" : "string"
-          },
-          "config-deploy-properties" : {
-            "description" : "Dynamic PropertyDefinition for workflow(config-deploy).",
-            "required" : true,
-            "type" : "dt-config-deploy-properties"
-          }
-        }
-      },
-      "rollback" : {
-        "steps" : {
-          "rollback" : {
-            "description" : "Roolback Workflow",
-            "target" : "rollback-process",
-            "activities" : [ {
-              "call_operation" : ""
-            } ]
-          }
-        },
-        "inputs" : {
-          "resolution-key" : {
-            "required" : false,
-            "type" : "string"
-          },
-          "password" : {
-            "required" : true,
-            "type" : "string"
-          },
-          "username" : {
-            "required" : true,
-            "type" : "string"
-          },
-          "ip" : {
-            "required" : true,
-            "type" : "string"
-          },
-          "config-deploy-properties" : {
-            "description" : "Dynamic PropertyDefinition for workflow(config-deploy).",
-            "required" : true,
-            "type" : "dt-config-deploy-properties"
-          },
-          "rollback-properties" : {
-            "description" : "Dynamic PropertyDefinition for workflow(rollback).",
-            "required" : true,
-            "type" : "dt-rollback-properties"
-          }
-        }
-      }
-    },
-    "node_templates" : {
-      "resource-assignment-process" : {
-        "type" : "dg-generic",
-        "properties" : {
-          "content" : {
-            "get_artifact" : [ "SELF", "dg-resource-assignment-process" ]
-          },
-          "dependency-node-templates" : [ "resource-assignment" ]
-        },
-        "artifacts" : {
-          "dg-resource-assignment-process" : {
-            "type" : "artifact-directed-graph",
-            "file" : "Plans/ResourceAssignment.xml"
-          }
-        }
-      },
-      "resource-assignment" : {
-        "type" : "component-resource-resolution",
-        "interfaces" : {
-          "ResourceResolutionComponent" : {
-            "operations" : {
-              "process" : {
-                "inputs" : {
-                  "resolution-key" : {
-                    "get_input" : "resolution-key"
-                  },
-                  "store-result" : {
-                    "get_input" : "store-result"
-                  },
-                  "artifact-prefix-names" : {
-                    "get_input" : "artifact-name"
-                  }
-                },
-                "outputs" : {
-                  "resource-assignment-params" : {
-                    "get_attribute" : [ "SELF", "assignment-params" ]
-                  },
-                  "status" : "success"
-                }
-              }
-            }
-          }
-        },
-        "artifacts" : {
-          "hostname-template" : {
-            "type" : "artifact-template-velocity",
-            "file" : "Templates/hostname-template.vtl"
-          },
-          "hostname-mapping" : {
-            "type" : "artifact-mapping-resource",
-            "file" : "Templates/hostname-mapping.json"
-          },
-          "vf-module-1-template" : {
-            "type" : "artifact-template-velocity",
-            "file" : "Templates/vf-module-1-template.vtl"
-          },
-          "vf-module-1-mapping" : {
-            "type" : "artifact-mapping-resource",
-            "file" : "Templates/vf-module-1-mapping.json"
-          }
-        }
-      },
-      "config-deploy-process" : {
-        "type" : "dg-generic",
-        "properties" : {
-          "content" : {
-            "get_artifact" : [ "SELF", "dg-config-deploy-process" ]
-          },
-          "dependency-node-templates" : [ "config-deploy" ]
-        },
-        "artifacts" : {
-          "dg-config-deploy-process" : {
-            "type" : "artifact-directed-graph",
-            "file" : "Plans/ConfigDeploy.xml"
-          }
-        }
-      },
-      "config-deploy" : {
-        "type" : "component-netconf-executor",
-        "requirements" : {
-          "netconf-connection" : {
-            "capability" : "netconf",
-            "node" : "netconf-device",
-            "relationship" : "tosca.relationships.ConnectsTo"
-          }
-        },
-        "interfaces" : {
-          "ComponentNetconfExecutor" : {
-            "operations" : {
-              "process" : {
-                "inputs" : {
-                  "script-type" : "jython",
-                  "script-class-reference" : "Scripts/python/NetconfRpcExample.py",
-                  "instance-dependencies" : [ ],
-                  "dynamic-properties" : "*config-deploy-properties"
-                },
-                "outputs" : {
-                  "response-data" : "",
-                  "status" : "SUCCESS"
-                }
-              }
-            }
-          }
-        },
-        "artifacts" : {
-          "vfw-interface-template" : {
-            "type" : "artifact-template-velocity",
-            "file" : "Templates/vfw-interface-template.vtl"
-          },
-          "vfw-interface-mapping" : {
-            "type" : "artifact-mapping-resource",
-            "file" : "Templates/vfw-interface-mapping.json"
-          }
-        }
-      },
-      "rollback-process" : {
-        "type" : "dg-generic",
-        "properties" : {
-          "content" : {
-            "get_artifact" : [ "SELF", "dg-rollback-process" ]
-          },
-          "dependency-node-templates" : [ "config-deploy" ]
-        },
-        "artifacts" : {
-          "dg-rollback-process" : {
-            "type" : "artifact-directed-graph",
-            "file" : "Plans/Rollback.xml"
-          }
-        }
-      },
-      "rollback" : {
-        "type" : "component-netconf-executor",
-        "requirements" : {
-          "netconf-connection" : {
-            "capability" : "netconf",
-            "node" : "netconf-device",
-            "relationship" : "tosca.relationships.ConnectsTo"
-          }
-        },
-        "interfaces" : {
-          "ComponentNetconfExecutor" : {
-            "operations" : {
-              "process" : {
-                "inputs" : {
-                  "script-type" : "jython",
-                  "script-class-reference" : "Scripts/python/Rollback.py",
-                  "instance-dependencies" : [ ],
-                  "dynamic-properties" : "*config-deploy-properties"
-                },
-                "outputs" : {
-                  "response-data" : "",
-                  "status" : "SUCCESS"
-                }
-              }
-            }
-          }
-        },
-        "artifacts" : {
-          "junos-rollback-RPC-template" : {
-            "type" : "artifact-template-velocity",
-            "file" : "Templates/junos-rollback-RPC-template.vtl"
-          },
-          "junos-rollback-RPC-mapping" : {
-            "type" : "artifact-mapping-resource",
-            "file" : "Templates/junos-rollback-RPC-mapping.json"
-          }
-        }
-      },
-      "netconf-device" : {
-        "type" : "vnf-netconf-device",
-        "capabilities" : {
-          "netconf" : {
-            "properties" : {
-              "login-key" : {
-                "get_input" : "password"
-              },
-              "login-account" : {
-                "get_input" : "username"
-              },
-              "target-ip-address" : {
-                "get_input" : "ip"
-              },
-              "port-number" : 830,
-              "connection-time-out" : 5
-            }
-          }
-        }
-      }
-    }
-  }
-}
\ No newline at end of file
index d60e6f0..8f3b9b4 100644 (file)
 {
-  "data_types" : {
-    "dt-config-deploy-properties" : {
-      "description" : "Dynamic DataType definition for workflow(config-deploy).",
-      "version" : "1.0.0",
-      "properties" : {
-        "vfw_interface_ip" : {
-          "type" : "dt-netbox-ip"
-        },
-        "interface-name" : {
-          "type" : "string"
-        },
-        "interface-description" : {
-          "type" : "string"
-        },
-        "unit-number" : {
-          "type" : "string"
-        },
-        "prefix-id" : {
-          "type" : "string",
-          "default" : "11"
-        },
-        "vf-module-type" : {
-          "type" : "string"
-        },
-        "vf-module-number" : {
-          "type" : "string",
-          "default" : "3"
+  "data_types": {
+    "dt-resource-assignment-properties": {
+      "description": "Dynamic DataType definition for workflow(resource-assignment).",
+      "version": "1.0.0",
+      "properties": {
+        "vfw_interface_ip": {
+          "type": "dt-netbox-ip"
+        },
+        "interface-description": {
+          "type": "string"
+        },
+        "vf-module-type": {
+          "type": "string"
+        },
+        "vf-module-number": {
+          "type": "string",
+          "default": "3"
+        },
+        "prefix-id": {
+          "type": "integer",
+          "default": 11
         }
       },
-      "derived_from" : "tosca.datatypes.Dynamic"
+      "derived_from": "tosca.datatypes.Dynamic"
     },
-    "dt-netbox-ip" : {
-      "description" : "This is Netbox IP Data Type",
-      "version" : "1.0.0",
-      "properties" : {
-        "address" : {
-          "required" : true,
-          "type" : "string"
-        },
-        "id" : {
-          "required" : true,
-          "type" : "integer"
+    "dt-config-assign-properties": {
+      "description": "Dynamic DataType definition for workflow(config-assign).",
+      "version": "1.0.0",
+      "properties": {
+        "hostname": {
+          "type": "string"
         }
       },
-      "derived_from" : "tosca.datatypes.Root"
+      "derived_from": "tosca.datatypes.Dynamic"
     },
-    "dt-resource-assignment-properties" : {
-      "description" : "Dynamic DataType definition for workflow(resource-assignment).",
-      "version" : "1.0.0",
-      "properties" : {
-        "hostname" : {
-          "type" : "string"
+    "dt-config-deploy-properties": {
+      "description": "Dynamic DataType definition for workflow(config-deploy).",
+      "version": "1.0.0",
+      "properties": {
+        "vfw_interface_ip": {
+          "type": "dt-netbox-ip"
+        },
+        "interface-name": {
+          "type": "string"
         },
-        "vfw_interface_ip" : {
-          "type" : "dt-netbox-ip"
+        "interface-description": {
+          "type": "string"
         },
-        "interface-description" : {
-          "type" : "string"
+        "unit-number": {
+          "type": "string"
         },
-        "vf-module-type" : {
-          "type" : "string"
+        "prefix-id": {
+          "type": "string",
+          "default": "11"
         },
-        "vf-module-number" : {
-          "type" : "string",
-          "default" : "3"
+        "vf-module-type": {
+          "type": "string"
         },
-        "prefix-id" : {
-          "type" : "integer",
-          "default" : 11
+        "vf-module-number": {
+          "type": "string",
+          "default": "3"
         }
       },
-      "derived_from" : "tosca.datatypes.Dynamic"
+      "derived_from": "tosca.datatypes.Dynamic"
     },
-    "dt-rollback-properties" : {
-      "description" : "Dynamic DataType definition for workflow(rollback).",
-      "version" : "1.0.0",
-      "properties" : {
-        "vfw_interface_ip" : {
-          "type" : "dt-netbox-ip"
-        },
-        "interface-name" : {
-          "type" : "string"
-        },
-        "interface-description" : {
-          "type" : "string"
-        },
-        "unit-number" : {
-          "type" : "string"
-        },
-        "prefix-id" : {
-          "type" : "string",
-          "default" : "11"
-        },
-        "vf-module-type" : {
-          "type" : "string"
-        },
-        "vf-module-number" : {
-          "type" : "string",
-          "default" : "3"
+    "dt-rollback-properties": {
+      "description": "Dynamic DataType definition for workflow(rollback).",
+      "version": "1.0.0",
+      "properties": {
+      },
+      "derived_from": "tosca.datatypes.Dynamic"
+    },
+    "dt-netbox-ip": {
+      "description": "This is Netbox IP Data Type",
+      "version": "1.0.0",
+      "properties": {
+        "address": {
+          "required": true,
+          "type": "string"
+        },
+        "id": {
+          "required": true,
+          "type": "integer"
         }
       },
-      "derived_from" : "tosca.datatypes.Dynamic"
+      "derived_from": "tosca.datatypes.Root"
     }
   }
 }
\ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/golden-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/golden/Definitions/golden-blueprint.json
new file mode 100644 (file)
index 0000000..6a9df9b
--- /dev/null
@@ -0,0 +1,326 @@
+{
+  "metadata": {
+    "template_author": "Alexis de Talhouët",
+    "author-email": "adetalhouet89@gmail.com",
+    "user-groups": "ADMIN, OPERATION",
+    "template_name": "test",
+    "template_version": "1.0.0",
+    "template_tags": "test"
+  },
+  "imports": [
+    {
+      "file": "Definitions/data_types.json"
+    },
+    {
+      "file": "Definitions/relationship_types.json"
+    },
+    {
+      "file": "Definitions/artifact_types.json"
+    },
+    {
+      "file": "Definitions/node_types.json"
+    },
+    {
+      "file": "Definitions/policy_types.json"
+    }
+  ],
+  "dsl_definitions": {
+    "ipam-1": {
+      "type": "token-auth",
+      "url": "http://localhost:32768",
+      "token": "Token 0123456789abcdef0123456789abcdef01234567"
+    },
+    "config-deploy-properties": {
+      "resolution-key": {
+        "get_input": "resolution-key"
+      }
+    }
+  },
+  "topology_template": {
+    "workflows": {
+      "resource-assignment": {
+        "steps": {
+          "resource-assignment": {
+            "description": "Resource Assign Workflow",
+            "target": "resource-assignment",
+            "activities": [
+              {
+                "call_operation": ""
+              }
+            ]
+          }
+        },
+        "inputs": {
+          "resource-assignment-properties": {
+            "description": "Dynamic PropertyDefinition for workflow(resource-assignment).",
+            "required": true,
+            "type": "dt-resource-assignment-properties"
+          }
+        },
+        "outputs": {
+          "meshed-template": {
+            "type": "json",
+            "value": {
+              "get_attribute": [
+                "resource-assignment",
+                "assignment-params"
+              ]
+            }
+          }
+        }
+      },
+      "config-assign": {
+        "steps": {
+          "config-assign": {
+            "description": "Config Assign Workflow",
+            "target": "config-assign",
+            "activities": [
+              {
+                "call_operation": ""
+              }
+            ]
+          }
+        },
+        "inputs": {
+          "resolution-key": {
+            "required": true,
+            "type": "string"
+          },
+          "config-assign-properties": {
+            "description": "Dynamic PropertyDefinition for workflow(config-assign).",
+            "required": true,
+            "type": "dt-config-assign-properties"
+          }
+        },
+        "outputs": {
+          "dry-run": {
+            "type": "json",
+            "value": {
+              "get_attribute": [
+                "config-assign",
+                "assignment-params"
+              ]
+            }
+          }
+        }
+      },
+      "config-deploy": {
+        "steps": {
+          "config-deploy": {
+            "description": "Resource Assign and Python Netconf Activation Workflow",
+            "target": "config-deploy",
+            "activities": [
+              {
+                "call_operation": ""
+              }
+            ]
+          }
+        },
+        "inputs": {
+          "resolution-key": {
+            "required": false,
+            "type": "string"
+          },
+          "password": {
+            "required": true,
+            "type": "string"
+          },
+          "username": {
+            "required": true,
+            "type": "string"
+          },
+          "ip": {
+            "required": true,
+            "type": "string"
+          },
+          "config-deploy-properties": {
+            "description": "Dynamic PropertyDefinition for workflow(config-deploy).",
+            "required": true,
+            "type": "dt-config-deploy-properties"
+          }
+        }
+      },
+      "rollback": {
+        "steps": {
+          "rollback": {
+            "description": "Rollback Workflow",
+            "target": "rollback",
+            "activities": [
+              {
+                "call_operation": ""
+              }
+            ]
+          }
+        },
+        "inputs": {
+          "resolution-key": {
+            "required": false,
+            "type": "string"
+          },
+          "password": {
+            "required": true,
+            "type": "string"
+          },
+          "username": {
+            "required": true,
+            "type": "string"
+          },
+          "ip": {
+            "required": true,
+            "type": "string"
+          },
+          "rollback-properties": {
+            "description": "Dynamic PropertyDefinition for workflow(rollback).",
+            "required": true,
+            "type": "dt-rollback-properties"
+          }
+        }
+      }
+    },
+    "node_templates": {
+      "resource-assignment": {
+        "type": "component-resource-resolution",
+        "interfaces": {
+          "ResourceResolutionComponent": {
+            "operations": {
+              "process": {
+                "inputs": {
+                  "artifact-prefix-names": [
+                    "vf-module-1"
+                  ]
+                }
+              }
+            }
+          }
+        },
+        "artifacts": {
+          "vf-module-1-template": {
+            "type": "artifact-template-velocity",
+            "file": "Templates/vf-module-1-template.vtl"
+          },
+          "vf-module-1-mapping": {
+            "type": "artifact-mapping-resource",
+            "file": "Templates/vf-module-1-mapping.json"
+          }
+        }
+      },
+      "config-assign": {
+        "type": "component-resource-resolution",
+        "interfaces": {
+          "ResourceResolutionComponent": {
+            "operations": {
+              "process": {
+                "inputs": {
+                  "resolution-key": {
+                    "get_input": "resolution-key"
+                  },
+                  "store-result": true,
+                  "artifact-prefix-names": [
+                    "hostname"
+                  ]
+                }
+              }
+            }
+          }
+        },
+        "artifacts": {
+          "hostname-template": {
+            "type": "artifact-template-velocity",
+            "file": "Templates/hostname-template.vtl"
+          },
+          "hostname-mapping": {
+            "type": "artifact-mapping-resource",
+            "file": "Templates/hostname-mapping.json"
+          }
+        }
+      },
+      "config-deploy": {
+        "type": "component-netconf-executor",
+        "requirements": {
+          "netconf-connection": {
+            "capability": "netconf",
+            "node": "netconf-device",
+            "relationship": "tosca.relationships.ConnectsTo"
+          }
+        },
+        "interfaces": {
+          "ComponentNetconfExecutor": {
+            "operations": {
+              "process": {
+                "inputs": {
+                  "script-type": "jython",
+                  "script-class-reference": "Scripts/python/ConfigDeploy.py",
+                  "instance-dependencies": [],
+                  "dynamic-properties": "*config-deploy-properties"
+                }
+              }
+            }
+          }
+        },
+        "artifacts": {
+          "vfw-interface-template": {
+            "type": "artifact-template-velocity",
+            "file": "Templates/vfw-interface-template.vtl"
+          },
+          "vfw-interface-mapping": {
+            "type": "artifact-mapping-resource",
+            "file": "Templates/vfw-interface-mapping.json"
+          }
+        }
+      },
+      "rollback": {
+        "type": "component-netconf-executor",
+        "requirements": {
+          "netconf-connection": {
+            "capability": "netconf",
+            "node": "netconf-device",
+            "relationship": "tosca.relationships.ConnectsTo"
+          }
+        },
+        "interfaces": {
+          "ComponentNetconfExecutor": {
+            "operations": {
+              "process": {
+                "inputs": {
+                  "script-type": "jython",
+                  "script-class-reference": "Scripts/python/Rollback.py",
+                  "instance-dependencies": []
+                }
+              }
+            }
+          }
+        },
+        "artifacts": {
+          "junos-rollback-RPC-template": {
+            "type": "artifact-template-velocity",
+            "file": "Templates/junos-rollback-RPC-template.vtl"
+          },
+          "junos-rollback-RPC-mapping": {
+            "type": "artifact-mapping-resource",
+            "file": "Templates/junos-rollback-RPC-mapping.json"
+          }
+        }
+      },
+      "netconf-device": {
+        "type": "vnf-netconf-device",
+        "capabilities": {
+          "netconf": {
+            "properties": {
+              "login-key": {
+                "get_input": "password"
+              },
+              "login-account": {
+                "get_input": "username"
+              },
+              "target-ip-address": {
+                "get_input": "ip"
+              },
+              "port-number": 830,
+              "connection-time-out": 5
+            }
+          }
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
index 15f02a1..1169a8d 100644 (file)
@@ -55,7 +55,7 @@
         "type" : "source-capability",
         "properties" : {
           "script-type" : "jython",
-          "script-class-reference" : "DescriptionExample",
+          "script-class-reference" : "Scripts/python/DescriptionExample.py",
           "instance-dependencies" : [ ]
         }
       }
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ConfigDeploy.xml b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ConfigDeploy.xml
deleted file mode 100644 (file)
index ec154a1..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<service-logic xmlns="http://www.onap.org/sdnc/svclogic" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" module="CONFIG" version="1.0.0">
-   <method rpc="ConfigDeploy" mode="sync">
-      <block atomic="true">
-         <execute plugin="config-deploy" method="process">
-            <outcome value="failure">
-               <return status="failure" />
-            </outcome>
-            <outcome value="success">
-               <return status="success" />
-            </outcome>
-         </execute>
-      </block>
-   </method>
-</service-logic>
\ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/ResourceAssignment.xml
deleted file mode 100644 (file)
index 15872e5..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<service-logic
-        xmlns='http://www.onap.org/sdnc/svclogic'
-        xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
-        xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' 
-        module='CONFIG' 
-        version='1.0.0'>
-    <method rpc='ResourceAssignment' mode='sync'>
-        <block atomic="true">
-            <execute plugin="resource-assignment" method="process">
-                <outcome value='failure'>
-                    <return status="failure">
-                    </return>
-                </outcome>
-                <outcome value='success'>
-                    <return status="success">
-                    </return>
-                </outcome>
-            </execute>
-        </block>
-    </method>
-</service-logic>
\ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml b/components/model-catalog/blueprint-model/test-blueprint/golden/Plans/Rollback.xml
deleted file mode 100644 (file)
index c1231d7..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<service-logic xmlns="http://www.onap.org/sdnc/svclogic" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" module="CONFIG" version="1.0.0">
-   <method rpc="Rollback" mode="sync">
-      <block atomic="true">
-         <execute plugin="rollback" method="process">
-            <outcome value="failure">
-               <return status="failure" />
-            </outcome>
-            <outcome value="success">
-               <return status="success" />
-            </outcome>
-         </execute>
-      </block>
-   </method>
-</service-logic>
\ No newline at end of file
index 06f9112..3fba19c 100644 (file)
@@ -4,8 +4,19 @@ Example
     Pre-requisite
 
         Netbox running: https://github.com/netbox-community/netbox-docker
+
         NETCONF capable device (JUNOS use in this example, but templates could be changed for another OS)
-        Blueprint processor
+
+        Blueprint processor micro-service runnint
+
+        CDS SQL database, populated with reference data as bellow:
+
+          CREATE TABLE `demo` (
+            `id` text DEFAULT NULL,
+            `value` text DEFAULT NULL
+          )
+
+          INSERT INTO `demo` VALUES ('1','vsn'),('2','vpg'),('3','vfw');
 
     resources
 
@@ -25,61 +36,74 @@ Example
           interface-name         |   input
           interface-description  |   capability (python script)
 
-    3 workflow
+    4 workflows
+
+        resource-assignment
 
-        resource-assignment (dry-run)
+            Ability to resolve templates with their mappings and provide the result as output.
+            Example provide one templates: vf-module-1
 
-            Ability to resolve multiple templates and mappings at the same time,
-            based on the request 'artifact-name', and provide the result as output.
-            Example provide two templates: hostname and vf-module-1
+            Input:
 
-            In order to perform dry-run, we need to store the template and have
-            the ability to retrieve the stored result later point in time. For this
-            we have to specify that we want to store the result, and we need to provide
-            a resolution-key.
+              Nothing specific to pass as input to the request. The resolution will use SQL and script to
+              resolve all the parameters.
+
+            Output:
+
+              {
+                "resource-assignment-response": {
+                    "meshed-template": {
+                        "vf-module-1": "<interface>\n    <description>This is the Virtual Firewall entity</description>\n    <vfw>10.10.10.69/24</vfw>\n</interface>"
+                    }
+                }
+              }
 
-            Here is the request payload:
+        config-assign (dry-run)
+
+            Ability to resolve templates with their mappings and provide the result as output.
+            Example provide one templates: hostname
+
+            This action uses the same functionality as resource-assignment, and in addition,
+            store the resulting meshed-template to be used later.
+
+            Input
 
-                artifact name:    template(s) to resolve
-                store-result:     whether to save the generated configlet in DB
                 resolution-key:   To identify the configlet saved in the DB
                 hostname:         Value defined to be result trough input in the hostname mapping file
 
-                {
-                  "resource-assignment-request": {
-                    "artifact-name": [ "hostname", "vf-module-1" ],
-                    "resolution-key": "hostname-demo-123",
-                    "store-result": true,
-                    "resource-assignment-properties": {
-                      "hostname": "demo123"
+              {
+                  "config-assign-request": {
+                    "resolution-key": "config-assign-demo-123",
+                    "config-assign-properties": {
+                      "hostname": "demo-config-assign"
                     }
                   }
-                }
+              }
 
             Output:
 
-                {
-                  "resource-assignment-params": {
-                      "hostname": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration xmlns:junos=\"http://xml.juniper.net/junos/17.4R1/junos\">\n   <system xmlns=\"http://yang.juniper.net/junos-qfx/conf/system\">\n      <host-name operation=\"delete\" />\n      <host-name operation=\"create\">demo123</host-name>\n   </system>\n</configuration>\n",
-                      "vf-module-1": "<interface>\n    <description>This is the Virtual Firewall entity</description>\n    <vfw>10.10.10.39/24</vfw>\n</interface>"
-                  },
-                  "status": "success"
-                }
+              {
+                  "config-assign-response": {
+                      "dry-run": {
+                          "hostname": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration xmlns:junos=\"http://xml.juniper.net/junos/17.4R1/junos\">\n   <system xmlns=\"http://yang.juniper.net/junos-qfx/conf/system\">\n      <host-name operation=\"delete\" />\n      <host-name operation=\"create\">demo-config-assign</host-name>\n   </system>\n</configuration>\n"
+                      }
+                  }
+              }
 
         config-deploy
 
             This action will run a python script that will retrieved the resolved template
-            from previous step using the resolution-key and the artifact-name.
+            from previous step using the resolution-key.
             The script will also resolve another template during its execution: the Interface Template.
             Finally, this action will push these resolved templates into a device (JUNOS) using NETCONF.
             The python script will make use of utilities classes provided by the platform:
             resolution helper and netconf client.
 
             Information about the device is modelled as a requirement of this action, specifying that
-            username, password and ip of the device should be provided as input. Note: you could resolve
-            those information using the resource resolution framework, if need be.
+            username, password and ip of the device should be provided as input.
+            Note: you could resolve those information using the resource resolution framework, if need be.
 
-            Here is the request payload:
+            Input:
 
                 resolution-key:   To identify the configlet saved in the DB in previous step
                 username:         NETCONF device user
@@ -88,16 +112,18 @@ Example
                 interface-name:   Name of the interface to configure
                 unit-number:      Unit to configure for the interface
 
-                {
-                  "resolution-key": "hostname-demo-123",
-                  "username": "user",
-                  "password": "pass",
+              {
+                "config-deploy-request": {
+                  "resolution-key": "config-assign-demo-123",
+                  "username": "admin",
+                  "password": "passwd",
                   "ip": "10.198.1.35",
                   "config-deploy-properties": {
                     "interface-name": "ge-0/0/7",
-                    unit-number": "0"
+                    "unit-number": "0"
                   }
                 }
+              }
 
             Output:
 
@@ -109,26 +135,30 @@ Example
             specific RPC. To do so, a python script will be used, similar as in previous action, to dynamically
             resolve the rollback template payload, and send the RPC to the device.
 
-            Information about the NETCONF device is provided in a similar fashion as previous step. Actually, the
-            same model is used.
+            Information about the NETCONF device is provided in a similar fashion as previous step.
 
-            Here is the request payload:
+            Input:
 
                 username:         NETCONF device user
                 password:         NETCONF device password
                 ip:               NETCONF device ip
 
-                 {
-                    "username": "pass",
-                    "password": "user",
-                    "ip": "10.10.10.10"
-                 }
+              {
+                "rollback-request": {
+                  "username": "admin",
+                  "password": "passwd",
+                  "ip": "10.198.1.35",
+                  "rollback-properties": {
+
+                  }
+                }
+              }
 
             Output:
 
                 No specific output beside success or failure.
 
 
-Postman collection used for this example. 4 requests are provided one per workflow to execute, and 1 to load the CBA in the runtime environment.
+Postman collection used for this example. 5 requests are provided one per workflow to execute, and 1 to load the CBA in the runtime environment.
 
-    https://www.getpostman.com/collections/4d199ff02a735bd3e680
\ No newline at end of file
+    hhttps://www.getpostman.com/collections/4d199ff02a735bd3e680
\ No newline at end of file
 
 import netconf_constant
 from common import ResolutionHelper
-from java.lang import Exception as JavaException
 from netconfclient import NetconfClient
 from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import \
   NetconfComponentFunction
 
 
-class NetconfRpcExample(NetconfComponentFunction):
+class ConfigDeploy(NetconfComponentFunction):
 
   def process(self, execution_request):
-    try:
       log = globals()[netconf_constant.SERVICE_LOG]
       print(globals())
 
@@ -51,11 +49,7 @@ class NetconfRpcExample(NetconfComponentFunction):
       nc.unlock()
       nc.disconnect()
 
-    except JavaException, err:
-      log.error("Java Exception in the script {}", err)
-    except Exception, err:
-      log.error("Python Exception in the script {}", err)
-
   def recover(self, runtime_exception, execution_request):
-    print self.addError(runtime_exception.getMessage())
-    return None
+        log.error("Exception in the script {}", runtime_exception)
+        print self.addError(runtime_exception.cause.message)
+        return None
index 4cf635a..8482a89 100644 (file)
@@ -19,28 +19,24 @@ from java.lang import Exception as JavaException
 class DescriptionExample(AbstractRAProcessor):
 
     def process(self, resource_assignment):
-        try:
-            # get dependencies result
-            value = self.raRuntimeService.getStringFromResolutionStore("vf-module-type")
-            
-            # logic based on dependency outcome
-            result = ""
-            if value == "vfw":
-                result = "This is the Virtual Firewall entity"
-            elif value == "vsn":
-                result = "This is the Virtual Sink entity"
-            elif value == "vpg":
-                result = "This is the Virtual Packet Generator"
+        # get dependencies result
+        value = self.raRuntimeService.getStringFromResolutionStore("vf-module-type")
+        
+        # logic based on dependency outcome
+        result = ""
+        if value == "vfw":
+            result = "This is the Virtual Firewall entity"
+        elif value == "vsn":
+            result = "This is the Virtual Sink entity"
+        elif value == "vpg":
+            result = "This is the Virtual Packet Generator"
 
-            # set value for resource getting currently resolved
-            self.set_resource_data_value(resource_assignment, result)
+        # set value for resource getting currently resolved
+        self.set_resource_data_value(resource_assignment, result)
 
-        except JavaException, err:
-          log.error("Java Exception in the script {}", err)
-        except Exception, err:
-          log.error("Python Exception in the script {}", err)
         return None
 
     def recover(self, runtime_exception, resource_assignment):
-        print self.addError(runtime_exception.getMessage())
-        return None
No newline at end of file
+        log.error("Exception in the script {}", runtime_exception)
+        print self.addError(runtime_exception.cause.message)
       return None
index a2bef32..40b3c3d 100644 (file)
@@ -14,7 +14,6 @@
 
 import netconf_constant
 from common import ResolutionHelper
-from java.lang import Exception as JavaException
 from netconfclient import NetconfClient
 from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import \
   NetconfComponentFunction
@@ -23,25 +22,22 @@ from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import \
 class Rollback(NetconfComponentFunction):
 
   def process(self, execution_request):
-    try:
-      log = globals()[netconf_constant.SERVICE_LOG]
-      print(globals())
 
-      nc = NetconfClient(log, self, "netconf-connection")
-      rr = ResolutionHelper(self)
+        log = globals()[netconf_constant.SERVICE_LOG]
+        print(globals())
 
-      # rollback config on device
-      nc.connect()
-      payloadHostnameRollback = rr.resolve_and_generate_message_from_template_prefix("junos-rollback-RPC")
-      nc.invoke_rpc(payloadHostnameRollback)
-      nc.commit()
-      nc.disconnect()
+        nc = NetconfClient(log, self, "netconf-connection")
+        rr = ResolutionHelper(self)
 
-    except JavaException, err:
-      log.error("Java Exception in the script {}", err)
-    except Exception, err:
-      log.error("Python Exception in the script {}", err)
+        # rollback config on device
+        nc.connect()
+        payloadHostnameRollback = rr.resolve_and_generate_message_from_template_prefix("junos-rollback-RPC")
+        nc.invoke_rpc(payloadHostnameRollback)
+        nc.commit()
+        nc.disconnect()
+        return None
 
   def recover(self, runtime_exception, execution_request):
-    print self.addError(runtime_exception.getMessage())
-    return None
+        log.error("Exception in the script {}", runtime_exception)
+        print self.addError(runtime_exception.cause.message)
+        return None
index 065eda1..b8f3a20 100644 (file)
@@ -1,6 +1,6 @@
 TOSCA-Meta-File-Version: 1.0.0
 CSAR-Version: 1.0
 Created-By: Alexis de Talhouët
-Entry-Definitions: Definitions/activation-blueprint.json
+Entry-Definitions: Definitions/golden-blueprint.json
 Template-Tags: test
 Content-Type: application/vnd.oasis.bpmn
index 4062a8c..3349443 100644 (file)
@@ -3,11 +3,15 @@ import "BluePrintCommon.proto";
 option java_multiple_files = true;
 package org.onap.ccsdk.cds.controllerblueprints.management.api;
 
-message BluePrintManagementInput {
+message BluePrintUploadInput {
+  org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1;
+  FileChunk fileChunk = 2;
+}
+
+message BluePrintRemoveInput {
   org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1;
   string blueprintName = 2;
   string blueprintVersion = 3;
-  FileChunk fileChunk = 4;
 }
 
 message BluePrintManagementOutput {
@@ -20,6 +24,6 @@ message FileChunk {
 }
 
 service BluePrintManagementService {
-  rpc uploadBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput);
-  rpc removeBlueprint (BluePrintManagementInput) returns (BluePrintManagementOutput);
+  rpc uploadBlueprint (BluePrintUploadInput) returns (BluePrintManagementOutput);
+  rpc removeBlueprint (BluePrintRemoveInput) returns (BluePrintManagementOutput);
 }
index dc0795f..d6b40d7 100644 (file)
                 <scope>import</scope>
             </dependency>
 
-            <dependency>
-                <groupId>com.att.eelf</groupId>
-                <artifactId>eelf-core</artifactId>
-                <version>${eelf.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.onap.logging-analytics</groupId>
-                <artifactId>logging-slf4j</artifactId>
-                <version>${onap.logger.slf4j}</version>
-            </dependency>
-
             <!--Swagger Dependencies -->
             <dependency>
                 <groupId>io.springfox</groupId>
                 <artifactId>springfox-swagger2</artifactId>
                 <version>${springfox.swagger2.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-api</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>io.springfox</groupId>
     </dependencyManagement>
 
     <dependencies>
-        <dependency>
-            <groupId>com.att.eelf</groupId>
-            <artifactId>eelf-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.logging-analytics</groupId>
-            <artifactId>logging-slf4j</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         <dependency>
             <groupId>com.jayway.jsonpath</groupId>
             <artifactId>json-path</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
         <dependency>
             <groupId>io.springfox</groupId>
             <artifactId>springfox-swagger2</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>io.springfox</groupId>
index 43e885a..92069c5 100644 (file)
@@ -22,53 +22,61 @@ from time import sleep
 
 class RestconfClient:
 
+    __base_odl_url = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/"
     __odl_status_check_limit = 10
     __odl_status_check_pause = 1
+    # Once confirmed to be reliable, the check should change to use the connection-status API
     __odl_status_check_url = "restconf/operational/network-topology:network-topology/topology/topology-netconf/node/"
-    __base_odl_url = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/"
 
     def __init__(self, log, restconf_component_function):
         self.__log = log
         self.__component_function = restconf_component_function
 
-    def mount_device(self, web_client_service, pnf_id, mount_payload):
-        self.__log.debug("mounting device {}", pnf_id)
+    def mount_device(self, web_client_service, nf_id, mount_payload):
+        self.__log.debug("mounting device {}", nf_id)
         headers = {"Content-Type": "application/xml"}
-        url = self.__base_odl_url + pnf_id
+        url = self.__base_odl_url + nf_id
         self.__log.debug("sending mount request, url: {}", url)
         web_client_service.exchangeResource("PUT", url, mount_payload, headers)
-        self.__wait_for_odl_to_mount(web_client_service, pnf_id)
+        self.__wait_for_odl_to_mount(web_client_service, nf_id)
 
-    def __wait_for_odl_to_mount(self, web_client_service, pnf_id):
+    def __wait_for_odl_to_mount(self, web_client_service, nf_id):
         counter = 0
-        url = self.__odl_status_check_url + pnf_id
+        url = self.__odl_status_check_url + nf_id
         self.__log.info("url for ODL status check: {}", url)
         expected_result = '"netconf-node-topology:connection-status":"connected"'
         while counter < self.__odl_status_check_limit:
             result = web_client_service.exchangeResource("GET", url, "")
             if expected_result in result:
-                self.__log.info("PNF was mounted successfully on ODL")
+                self.__log.info("NF was mounted successfully on ODL")
                 return None
             sleep(self.__odl_status_check_pause)
             counter += 1
-        raise Exception("PNF was not mounted on ODL, aborting configuration procedure")
+        raise Exception("NF was not mounted on ODL, aborting configuration procedure")
 
-    def configure_device(self, web_client_service, pnf_id, configlet_resource_path, configlet_to_apply):
-        self.log_current_configlet(web_client_service, pnf_id, configlet_resource_path)
-        self.__log.info("configuring device: {}, Configlet: {}", pnf_id, configlet_to_apply)
+    def configure_device_json_patch(self, web_client_service, nf_id, configlet_resource_path, configlet_to_apply):
         headers = {"Content-Type": "application/yang.patch+json"}
-        url = self.__base_odl_url + pnf_id + configlet_resource_path
+        self.__configure_device(web_client_service, nf_id, configlet_resource_path, configlet_to_apply, headers)
+
+    def configure_device_xml_patch(self, web_client_service, nf_id, configlet_resource_path, configlet_to_apply):
+        headers = {"Content-Type": "application/yang.patch+xml"}
+        self.__configure_device(web_client_service, nf_id, configlet_resource_path, configlet_to_apply, headers)
+
+    def __configure_device(self, web_client_service, nf_id, configlet_resource_path, configlet_to_apply, headers):
+        self.__log.debug("headers: {}", headers)
+        self.__log.info("configuring device: {}, Configlet: {}", nf_id, configlet_to_apply)
+        url = self.__base_odl_url + nf_id + configlet_resource_path
         self.__log.debug("sending patch request,  url: {}", url)
         result = web_client_service.exchangeResource("PATCH", url, configlet_to_apply, headers)
         self.__log.info("Configuration application result: {}", result)
 
-    def log_current_configlet(self, web_client_service, pnf_id, configlet_resource_path):
-        url = self.__base_odl_url + pnf_id + configlet_resource_path
+    def retrieve_device_configuration_subtree(self, web_client_service, nf_id, configlet_resource_path):
+        url = self.__base_odl_url + nf_id + configlet_resource_path
         self.__log.debug("sending GET request,  url: {}", url)
         result = web_client_service.exchangeResource("GET", url, "")
-        self.__log.info("Current configuration: {}", result)
+        return result
 
-    def unmount_device(self, web_client_service, pnf_id):
-        url = self.__base_odl_url + str(pnf_id)
+    def unmount_device(self, web_client_service, nf_id):
+        url = self.__base_odl_url + nf_id
         self.__log.debug("sending unmount request, url: {}", url)
         web_client_service.exchangeResource("DELETE", url, "")
index e64dee2..7ed4cc9 100755 (executable)
 # Web server config\r
 server.port=8080\r
 \r
-blueprintsprocessor.grpcEnable=false\r
+blueprintsprocessor.grpcEnable=true\r
 blueprintsprocessor.httpPort=8080\r
 blueprintsprocessor.grpcPort=9111\r
+\r
 # Blueprint Processor File Execution and Handling Properties\r
-blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy\r
-blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive\r
+blueprintsprocessor.blueprintDeployPath=blueprints/deploy\r
+blueprintsprocessor.blueprintArchivePath=blueprints/archive\r
+blueprintsprocessor.blueprintWorkingPath=blueprints/work\r
 # Primary Database Configuration\r
 blueprintsprocessor.db.primary.url=jdbc:mysql://localhost:3306/sdnctl\r
 blueprintsprocessor.db.primary.username=sdnctl\r
index 66073a0..b34609c 100755 (executable)
@@ -25,7 +25,7 @@ blueprintsprocessor.grpcPort=9111
 # Blueprint Processor File Execution and Handling Properties
 blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy
 blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
-
+blueprintsprocessor.blueprintWorkingPath=/opt/app/onap/blueprints/work
 # Primary Database Configuration
 blueprintsprocessor.db.primary.url=jdbc:mysql://db:3306/sdnctl
 blueprintsprocessor.db.primary.username=sdnctl
index 48fc057..a6caf92 100644 (file)
@@ -19,7 +19,7 @@
         <!-- encoders are assigned the type\r
              ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
         <encoder>\r
-            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{50} - %msg%n</pattern>\r
         </encoder>\r
     </appender>\r
 \r
index fc6f729..3078505 100644 (file)
@@ -23,6 +23,7 @@ blueprintsprocessor.grpcPort=9111
 # Blueprint Processor File Execution and Handling Properties
 blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy
 blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
+blueprintsprocessor.blueprintWorkingPath=/opt/app/onap/blueprints/work
 # Primary Database Configuration
 blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
 blueprintsprocessor.db.primary.username=sa
index 3137eb4..6af268c 100755 (executable)
@@ -28,6 +28,7 @@
             <outputDirectory>/opt/app/onap/lib</outputDirectory>
             <outputFileNameMapping>${artifact.groupId}-${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
             <excludes>
+                <exclude>org.slf4j:slf4j-simple</exclude>
             </excludes>
         </dependencySet>
     </dependencySets>
index d1ecb4f..de4cda9 100644 (file)
@@ -19,10 +19,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core
 import com.google.common.collect.ImmutableList
 import com.google.common.collect.ImmutableSet
 import org.apache.sshd.client.SshClient
-import org.apache.sshd.client.channel.ChannelSubsystem
 import org.apache.sshd.client.channel.ClientChannel
 import org.apache.sshd.client.session.ClientSession
-import org.apache.sshd.client.session.ClientSessionImpl
 import org.apache.sshd.common.FactoryManager
 import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
@@ -195,9 +193,9 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
 
     private fun startClient() {
         client = SshClient.setUpDefaultClient()
+
         client.properties.putIfAbsent(FactoryManager.IDLE_TIMEOUT, TimeUnit.SECONDS.toMillis(idleTimeout.toLong()))
         client.properties.putIfAbsent(FactoryManager.NIO2_READ_TIMEOUT, TimeUnit.SECONDS.toMillis(idleTimeout + 15L))
-        client.keyPairProvider = SimpleGeneratorHostKeyProvider()
         client.start()
 
         startSession()
index c6d6308..2b7aa76 100644 (file)
@@ -17,12 +17,11 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.mocks
 
 
 import org.apache.sshd.common.NamedFactory
-import org.apache.sshd.server.Command
+import org.apache.sshd.server.command.Command
 import org.apache.sshd.server.SshServer
 import org.apache.sshd.server.auth.UserAuth
 import org.apache.sshd.server.auth.UserAuthNoneFactory
 import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.NetconfSubsystemFactory
 import java.util.*
 
 
index de0a5d0..f3e5d38 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.mocks
 
 
 import java.io.IOException
 import java.io.InputStream
 import java.io.OutputStream
 import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.server.Command;
+import org.apache.sshd.server.command.Command;
 import org.apache.sshd.server.Environment;
 import org.apache.sshd.server.ExitCallback;
 
index 7f4f452..4fc9336 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.ObjectMapper
 import com.fasterxml.jackson.databind.node.NullNode
@@ -39,7 +38,7 @@ import java.util.*
 class ResourceAssignmentUtils {
     companion object {
 
-        private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString())
+        private val logger= LoggerFactory.getLogger(ResourceAssignmentUtils::class.toString())
 
         // TODO("Modify Value type from Any to JsonNode")
         @Throws(BluePrintProcessorException::class)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kts b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/scripts/InternalRAProcessor.cba.kts
new file mode 100644 (file)
index 0000000..e6fc2ba
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  Copyright Â© 2019 IBM.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
+import org.slf4j.LoggerFactory
+
+open class SimpleRAProcessor : ResourceAssignmentProcessor() {
+
+    private val log = LoggerFactory.getLogger(SimpleRAProcessor::class.java)!!
+
+    override fun getName(): String {
+        return "ScriptResourceAssignmentProcessor"
+    }
+
+    override fun process(executionRequest: ResourceAssignment) {
+        log.info("Processing input")
+    }
+
+    override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
+        log.info("Recovering input")
+    }
+}
index 0a62500..3234c9a 100755 (executable)
 
 package org.onap.ccsdk.cds.blueprintsprocessor.db
 
-import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
 import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintProcessorModel
 import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintProcessorModelContent
 import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintProcessorModelRepository
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.*
 import org.onap.ccsdk.cds.controllerblueprints.core.common.ApplicationConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils
@@ -35,16 +34,16 @@ import org.springframework.stereotype.Service
 import java.io.File
 import java.nio.file.Files
 import java.nio.file.Path
-import java.nio.file.Paths
+import java.util.*
 
 /**
  * Similar/Duplicate implementation in [org.onap.ccsdk.cds.controllerblueprints.service.load.ControllerBlueprintCatalogServiceImpl]
  */
 @Service
 class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: BluePrintValidatorService,
-                                           private val blueprintConfig: BluePrintCoreConfiguration,
+                                           private val bluePrintPathConfiguration: BluePrintPathConfiguration,
                                            private val blueprintModelRepository: BlueprintProcessorModelRepository)
-    : BlueprintCatalogServiceImpl(bluePrintRuntimeValidatorService) {
+    : BlueprintCatalogServiceImpl(bluePrintPathConfiguration, bluePrintRuntimeValidatorService) {
 
     private val log = LoggerFactory.getLogger(BlueprintProcessorCatalogServiceImpl::class.toString())
 
@@ -53,33 +52,47 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu
         log.info("BlueprintProcessorCatalogServiceImpl initialized")
     }
 
-    override fun delete(name: String, version: String) = blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(name, version)
+    override suspend fun delete(name: String, version: String) {
+        // Cleaning Deployed Blueprint
+        deleteNBDir(bluePrintPathConfiguration.blueprintDeployPath, name, version)
+        // Cleaning Data Base
+        blueprintModelRepository
+                .deleteByArtifactNameAndArtifactVersion(name, version)
+    }
+
+
+    override suspend fun get(name: String, version: String, extract: Boolean): Path? {
 
+        val getId = UUID.randomUUID().toString()
+        var path = "${bluePrintPathConfiguration.blueprintArchivePath}/$getId/cba.zip"
 
-    override fun get(name: String, version: String, extract: Boolean): Path? {
-        var path = "${blueprintConfig.archivePath}/$name/$version.zip"
+        // TODO("Check first location for the file", If not get from database")
 
         blueprintModelRepository.findByArtifactNameAndArtifactVersion(name, version)?.also {
             it.blueprintModelContent.run {
-                val file = File(path)
-                file.parentFile.mkdirs()
-                file.createNewFile()
+                val file = normalizedFile(path)
+                file.parentFile.reCreateDirs()
+
                 file.writeBytes(this!!.content!!).let {
                     if (extract) {
-                        path = "${blueprintConfig.archivePath}/$name/$version"
+                        path = "${bluePrintPathConfiguration.blueprintDeployPath}/$name/$version"
                         BluePrintArchiveUtils.deCompress(file, path)
                     }
-                    return Paths.get(path)
+                    return normalizedPath(path)
                 }
             }
         }
         return null
     }
 
-    override fun save(metadata: MutableMap<String, String>, archiveFile: File) {
+    override suspend fun save(metadata: MutableMap<String, String>, archiveFile: File) {
         val artifactName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]
         val artifactVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]
 
+        check(archiveFile.isFile && !archiveFile.isDirectory) {
+            throw BluePrintException("Not a valid Archive file(${archiveFile.absolutePath})")
+        }
+
         blueprintModelRepository.findByArtifactNameAndArtifactVersion(artifactName!!, artifactVersion!!)?.let {
             log.info("Overwriting blueprint model :$artifactName::$artifactVersion")
             blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(artifactName, artifactVersion)
index a9a2ae7..2fda159 100644 (file)
  */
 package org.onap.ccsdk.cds.blueprintsprocessor.db
 
+import kotlinx.coroutines.runBlocking
 import org.junit.Test
 import org.junit.runner.RunWith
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
 import org.springframework.context.annotation.ComponentScan
 import org.springframework.test.context.TestPropertySource
 import org.springframework.test.context.junit4.SpringRunner
-import java.io.File
-import java.nio.file.Paths
+import kotlin.test.AfterTest
+import kotlin.test.BeforeTest
 import kotlin.test.assertTrue
 
 @RunWith(SpringRunner::class)
@@ -36,17 +39,30 @@ class BlueprintProcessorCatalogServiceImplTest {
     @Autowired
     lateinit var blueprintCatalog: BluePrintCatalogService
 
+    @BeforeTest
+    fun setup() {
+        deleteDir("target", "blueprints")
+    }
+
+    @AfterTest
+    fun cleanDir() {
+        deleteDir("target", "blueprints")
+    }
+
     @Test
     fun `test catalog service`() {
-        val file = Paths.get("./src/test/resources/test-cba.zip").toFile()
-        assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
+        runBlocking {
+            //FIXME("Create ZIP from test blueprints")
+
+            val file = normalizedFile("./src/test/resources/test-cba.zip")
+            assertTrue(file.exists(), "couldn't get file ${file.absolutePath}")
 
-        blueprintCatalog.saveToDatabase(file)
+            blueprintCatalog.saveToDatabase("1234", file)
 
-        blueprintCatalog.getFromDatabase("baseconfiguration", "1.0.0")
+            blueprintCatalog.getFromDatabase("baseconfiguration", "1.0.0")
 
-        blueprintCatalog.deleteFromDatabase("baseconfiguration", "1.0.0")
+            blueprintCatalog.deleteFromDatabase("baseconfiguration", "1.0.0")
 
-        File("./src/test/resources/baseconfiguration").deleteRecursively()
+        }
     }
 }
\ No newline at end of file
index 3ac7ec3..9dda71e 100644 (file)
@@ -25,3 +25,4 @@ blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
 # Controller Blueprints Core Configuration
 blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
 blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
+blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work
index 03b847e..5f1ae7d 100644 (file)
 
 package org.onap.ccsdk.cds.blueprintsprocessor.core
 
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration
 import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.beans.factory.annotation.Value
+import org.springframework.boot.context.properties.bind.Bindable
 import org.springframework.boot.context.properties.bind.Binder
 import org.springframework.boot.context.properties.source.ConfigurationPropertySources
 import org.springframework.context.annotation.Bean
 import org.springframework.context.annotation.Configuration
 import org.springframework.core.env.Environment
+import org.springframework.stereotype.Service
 
 
 @Configuration
-open class BluePrintCoreConfiguration {
+open class BluePrintCoreConfiguration(private val bluePrintProperties: BlueprintProcessorProperties) {
 
-    @Value("\${blueprintsprocessor.blueprintDeployPath}")
-    lateinit var deployPath: String
+    companion object {
+        const val PREFIX_BLUEPRINT_PROCESSOR = "blueprintsprocessor"
+    }
 
-    @Value("\${blueprintsprocessor.blueprintArchivePath}")
-    lateinit var archivePath: String
+    @Bean
+    open fun bluePrintPathConfiguration(): BluePrintPathConfiguration {
+        return bluePrintProperties
+                .propertyBeanType(PREFIX_BLUEPRINT_PROCESSOR, BluePrintPathConfiguration::class.java)
+    }
 
 }
 
@@ -46,4 +52,11 @@ open class BlueprintPropertyConfiguration {
         val configurationPropertySource = ConfigurationPropertySources.get(environment)
         return Binder(configurationPropertySource)
     }
+}
+
+@Service
+open class BlueprintProcessorProperties(private var bluePrintPropertyBinder: Binder) {
+    fun <T> propertyBeanType(prefix: String, type: Class<T>): T {
+        return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get()
+    }
 }
\ No newline at end of file
index a32d61e..bb2c040 100644 (file)
@@ -17,8 +17,8 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.core.factory
 
-import com.att.eelf.configuration.EELFManager
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.slf4j.LoggerFactory
 import org.springframework.context.ApplicationContext
 import org.springframework.context.ApplicationContextAware
 
@@ -48,7 +48,7 @@ interface ComponentNode {
  * @author Brinda Santh
  */
 open class ComponentNodeFactory : ApplicationContextAware {
-    private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java)
+    private val log = LoggerFactory.getLogger(ComponentNodeFactory::class.java)
 
     var componentNodes: MutableMap<String, ComponentNode> = hashMapOf()
 
index 94a5753..1c1d510 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright Â© 2017-2019 AT&T, Bell Canada, Nordix Foundation
+ * Modifications Copyright Â© 2018-2019 IBM.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +17,9 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.rest.service
 
+import com.fasterxml.jackson.databind.JsonNode
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
 import org.apache.commons.io.IOUtils
 import org.apache.http.client.methods.*
 import org.apache.http.entity.StringEntity
@@ -24,6 +28,7 @@ import org.apache.http.impl.client.HttpClients
 import org.apache.http.message.BasicHeader
 import org.onap.ccsdk.cds.blueprintsprocessor.rest.utils.WebClientUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.springframework.http.HttpMethod
 import java.nio.charset.Charset
 
@@ -35,9 +40,9 @@ interface BlueprintWebClientService {
 
     fun httpClient(): CloseableHttpClient {
         return HttpClients.custom()
-            .addInterceptorFirst(WebClientUtils.logRequest())
-            .addInterceptorLast(WebClientUtils.logResponse())
-            .build()
+                .addInterceptorFirst(WebClientUtils.logRequest())
+                .addInterceptorLast(WebClientUtils.logResponse())
+                .build()
     }
 
     fun exchangeResource(methodType: String, path: String, request: String): String {
@@ -105,4 +110,132 @@ interface BlueprintWebClientService {
             return IOUtils.toString(it, Charset.defaultCharset())
         }
     }
+
+    // Non Blocking Rest Implementation
+    suspend fun httpClientNB(): CloseableHttpClient {
+        return HttpClients.custom()
+                .addInterceptorFirst(WebClientUtils.logRequest())
+                .addInterceptorLast(WebClientUtils.logResponse())
+                .build()
+    }
+
+    suspend fun getNB(path: String): String {
+        return getNB(path, null, String::class.java)
+    }
+
+    suspend fun getNB(path: String, additionalHeaders: Map<String, String>?): String {
+        return getNB(path, additionalHeaders, String::class.java)
+    }
+
+    suspend fun <T> getNB(path: String, additionalHeaders: Map<String, String>?,
+                          responseType: Class<T>): T = withContext(Dispatchers.IO) {
+        val httpGet = HttpGet(host(path))
+        httpGet.setHeaders(basicHeaders(additionalHeaders))
+        httpClientNB().execute(httpGet).entity.content.use {
+            JacksonUtils.readValue(it, responseType)!!
+        }
+    }
+
+    suspend fun postNB(path: String, request: Any): String {
+        return postNB(path, request, null, String::class.java)
+    }
+
+    suspend fun postNB(path: String, request: Any, additionalHeaders: Map<String, String>?): String {
+        return postNB(path, request, additionalHeaders, String::class.java)
+    }
+
+    suspend fun <T> postNB(path: String, request: Any, additionalHeaders: Map<String, String>?,
+                           responseType: Class<T>): T =
+            withContext(Dispatchers.IO) {
+                val httpPost = HttpPost(host(path))
+                httpPost.entity = StringEntity(strRequest(request))
+                httpPost.setHeaders(basicHeaders(additionalHeaders))
+                httpClientNB().execute(httpPost).entity.content.use {
+                    JacksonUtils.readValue(it, responseType)!!
+                }
+            }
+
+    suspend fun putNB(path: String, request: Any): String {
+        return putNB(path, request, null, String::class.java)
+    }
+
+    suspend fun putNB(path: String, request: Any, additionalHeaders: Map<String, String>?): String {
+        return putNB(path, request, additionalHeaders, String::class.java)
+    }
+
+    suspend fun <T> putNB(path: String, request: Any, additionalHeaders: Map<String, String>?,
+                          responseType: Class<T>): T = withContext(Dispatchers.IO) {
+        val httpPut = HttpPut(host(path))
+        httpPut.entity = StringEntity(strRequest(request))
+        httpPut.setHeaders(basicHeaders(additionalHeaders))
+        httpClientNB().execute(httpPut).entity.content.use {
+            JacksonUtils.readValue(it, responseType)!!
+        }
+    }
+
+    suspend fun <T> deleteNB(path: String): String {
+        return deleteNB(path, null, String::class.java)
+    }
+
+    suspend fun <T> deleteNB(path: String, additionalHeaders: Map<String, String>?): String {
+        return deleteNB(path, additionalHeaders, String::class.java)
+    }
+
+    suspend fun <T> deleteNB(path: String, additionalHeaders: Map<String, String>?, responseType: Class<T>): T =
+            withContext(Dispatchers.IO) {
+                val httpDelete = HttpDelete(host(path))
+                httpDelete.setHeaders(basicHeaders(additionalHeaders))
+                httpClient().execute(httpDelete).entity.content.use {
+                    JacksonUtils.readValue(it, responseType)!!
+                }
+            }
+
+    suspend fun <T> patchNB(path: String, request: Any, additionalHeaders: Map<String, String>?,
+                            responseType: Class<T>): T = withContext(Dispatchers.IO) {
+        val httpPatch = HttpPatch(host(path))
+        httpPatch.entity = StringEntity(strRequest(request))
+        httpPatch.setHeaders(basicHeaders(additionalHeaders))
+        httpClient().execute(httpPatch).entity.content.use {
+            JacksonUtils.readValue(it, responseType)!!
+        }
+    }
+
+    suspend fun exchangeNB(methodType: String, path: String, request: Any): String {
+        return exchangeNB(methodType, path, request, hashMapOf(), String::class.java)
+    }
+
+    suspend fun exchangeNB(methodType: String, path: String, request: Any, additionalHeaders: Map<String, String>?): String {
+        return exchangeNB(methodType, path, request, additionalHeaders, String::class.java)
+    }
+
+    suspend fun <T> exchangeNB(methodType: String, path: String, request: Any, additionalHeaders: Map<String, String>?,
+                               responseType: Class<T>): T {
+        return when (HttpMethod.resolve(methodType)) {
+            HttpMethod.GET -> getNB(path, additionalHeaders, responseType)
+            HttpMethod.POST -> postNB(path, request, additionalHeaders, responseType)
+            HttpMethod.DELETE -> deleteNB(path, additionalHeaders, responseType)
+            HttpMethod.PUT -> putNB(path, request, additionalHeaders, responseType)
+            HttpMethod.PATCH -> patchNB(path, request, additionalHeaders, responseType)
+            else -> throw BluePrintProcessorException("Unsupported methodType($methodType)")
+        }
+    }
+
+    private fun strRequest(request: Any): String {
+        return when (request) {
+            is String -> request.toString()
+            is JsonNode -> request.toString()
+            else -> JacksonUtils.getJson(request)
+        }
+    }
+
+    private fun basicHeaders(headers: Map<String, String>?): Array<BasicHeader> {
+        val basicHeaders = mutableListOf<BasicHeader>()
+        defaultHeaders().forEach { name, value ->
+            basicHeaders.add(BasicHeader(name, value))
+        }
+        headers?.forEach { name, value ->
+            basicHeaders.add(BasicHeader(name, value))
+        }
+        return basicHeaders.toTypedArray()
+    }
 }
\ No newline at end of file
index 1fa1410..251ae2c 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright Â© 2017-2018 AT&T Intellectual Property.
  * Modifications Copyright Â© 2019 Bell Canada.
+ * Modifications Copyright Â© 2019 IBM.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,78 +20,87 @@ package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
 
 import io.grpc.StatusException
 import io.grpc.stub.StreamObserver
-import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
+import kotlinx.coroutines.runBlocking
 import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.currentTimestamp
 import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
 import org.onap.ccsdk.cds.controllerblueprints.common.api.Status
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
-import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementInput
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.onap.ccsdk.cds.controllerblueprints.core.reCreateDirs
 import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementOutput
 import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintRemoveInput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput
 import org.slf4j.LoggerFactory
 import org.springframework.security.access.prepost.PreAuthorize
 import org.springframework.stereotype.Service
 import java.io.File
+import java.util.*
 
 @Service
-open class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
-                                     private val bluePrintCatalogService: BluePrintCatalogService)
+open class BluePrintManagementGRPCHandler(private val bluePrintPathConfiguration: BluePrintPathConfiguration,
+                                          private val bluePrintCatalogService: BluePrintCatalogService)
     : BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() {
 
     private val log = LoggerFactory.getLogger(BluePrintManagementGRPCHandler::class.java)
 
     @PreAuthorize("hasRole('USER')")
-    override fun uploadBlueprint(request: BluePrintManagementInput, responseObserver: StreamObserver<BluePrintManagementOutput>) {
-        val blueprintName = request.blueprintName
-        val blueprintVersion = request.blueprintVersion
-        val blueprint = "blueprint $blueprintName:$blueprintVersion"
+    override fun uploadBlueprint(request: BluePrintUploadInput, responseObserver:
+    StreamObserver<BluePrintManagementOutput>) {
+        runBlocking {
+
+            log.info("request(${request.commonHeader.requestId})")
+            val uploadId = UUID.randomUUID().toString()
+            try {
+                val cbaFile = normalizedFile(bluePrintPathConfiguration.blueprintArchivePath, uploadId, "cba-zip")
+
+                saveToDisk(request, cbaFile)
+
+                val blueprintId = bluePrintCatalogService.saveToDatabase(uploadId, cbaFile)
+                responseObserver.onNext(successStatus("Successfully uploaded CBA($blueprintId)...", request.commonHeader))
+                responseObserver.onCompleted()
+            } catch (e: Exception) {
+                failStatus("request(${request.commonHeader.requestId}): Failed to upload CBA", e)
+            } finally {
+                deleteDir(bluePrintPathConfiguration.blueprintArchivePath, uploadId)
+                deleteDir(bluePrintPathConfiguration.blueprintWorkingPath, uploadId)
+            }
+        }
+    }
 
-        log.info("request(${request.commonHeader.requestId}): Received upload $blueprint")
+    @PreAuthorize("hasRole('USER')")
+    override fun removeBlueprint(request: BluePrintRemoveInput, responseObserver:
+    StreamObserver<BluePrintManagementOutput>) {
 
-        val blueprintArchivedFilePath = "${bluePrintCoreConfiguration.archivePath}/$blueprintName/$blueprintVersion/$blueprintName.zip"
-        try {
-            val blueprintArchivedFile = File(blueprintArchivedFilePath)
+        runBlocking {
+            val blueprintName = request.blueprintName
+            val blueprintVersion = request.blueprintVersion
+            val blueprint = "blueprint $blueprintName:$blueprintVersion"
 
-            saveToDisk(request, blueprintArchivedFile)
-            val blueprintId = bluePrintCatalogService.saveToDatabase(blueprintArchivedFile)
+            log.info("request(${request.commonHeader.requestId}): Received delete $blueprint")
 
-            File("${bluePrintCoreConfiguration.archivePath}/$blueprintName").deleteRecursively()
 
-            responseObserver.onNext(successStatus("Successfully uploaded $blueprint with id($blueprintId)", request.commonHeader))
-            responseObserver.onCompleted()
-        } catch (e: Exception) {
-            failStatus("request(${request.commonHeader.requestId}): Failed to upload $blueprint at path $blueprintArchivedFilePath", e)
+            try {
+                bluePrintCatalogService.deleteFromDatabase(blueprintName, blueprintVersion)
+                responseObserver.onNext(successStatus("Successfully deleted $blueprint", request.commonHeader))
+                responseObserver.onCompleted()
+            } catch (e: Exception) {
+                failStatus("request(${request.commonHeader.requestId}): Failed to delete $blueprint", e)
+            }
         }
     }
 
-    @PreAuthorize("hasRole('USER')")
-    override fun removeBlueprint(request: BluePrintManagementInput, responseObserver: StreamObserver<BluePrintManagementOutput>) {
-        val blueprintName = request.blueprintName
-        val blueprintVersion = request.blueprintVersion
-        val blueprint = "blueprint $blueprintName:$blueprintVersion"
-
-        log.info("request(${request.commonHeader.requestId}): Received delete $blueprint")
-
-        try {
-            bluePrintCatalogService.deleteFromDatabase(blueprintName, blueprintVersion)
-            responseObserver.onNext(successStatus("Successfully deleted $blueprint", request.commonHeader))
-            responseObserver.onCompleted()
-        } catch (e: Exception) {
-            failStatus("request(${request.commonHeader.requestId}): Failed to delete $blueprint", e)
-        }
-    }
+    private fun saveToDisk(request: BluePrintUploadInput, cbaFile: File) {
+        log.info("request(${request.commonHeader.requestId}): Writing CBA File under :${cbaFile.absolutePath}")
 
-    private fun saveToDisk(request: BluePrintManagementInput, blueprintDir: File) {
-        log.info("request(${request.commonHeader.requestId}): Writing CBA File under :${blueprintDir.absolutePath}")
-        if (blueprintDir.exists()) {
-            log.info("request(${request.commonHeader.requestId}): Re-creating blueprint directory(${blueprintDir.absolutePath})")
-            //FileUtils.deleteDirectory(blueprintDir.parentFile)
-            blueprintDir.parentFile.deleteRecursively()
-        }
-        blueprintDir.parentFile.mkdirs()
-        //FileUtils.forceMkdir(blueprintDir.parentFile)
-        blueprintDir.writeBytes(request.fileChunk.chunk.toByteArray()).apply {
-            log.info("request(${request.commonHeader.requestId}): CBA file(${blueprintDir.absolutePath} written successfully")
+        // Recreate Folder
+        cbaFile.parentFile.reCreateDirs()
+
+        // Write the File
+        cbaFile.writeBytes(request.fileChunk.chunk.toByteArray()).apply {
+            log.info("request(${request.commonHeader.requestId}): CBA file(${cbaFile.absolutePath} written successfully")
         }
 
     }
index 1039d5c..41e78e5 100644 (file)
@@ -27,7 +27,6 @@ import org.springframework.http.MediaType
 import org.springframework.http.codec.multipart.FilePart
 import org.springframework.security.access.prepost.PreAuthorize
 import org.springframework.web.bind.annotation.*
-import reactor.core.publisher.Mono
 
 @RestController
 @RequestMapping("/api/v1/execution-service")
@@ -46,11 +45,8 @@ open class ExecutionServiceController {
     @ApiOperation(value = "Upload CBA", notes = "Takes a File and load it in the runtime database")
     @ResponseBody
     @PreAuthorize("hasRole('USER')")
-    fun upload(@RequestPart("file") parts: Mono<FilePart>): Mono<String> {
-        return parts
-                .filter { it is FilePart }
-                .ofType(FilePart::class.java)
-                .flatMap(executionServiceHandler::upload)
+    fun upload(@RequestPart("file") filePart: FilePart): String = runBlocking {
+        executionServiceHandler.upload(filePart)
     }
 
     @RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE])
index f3af254..0120a8f 100644 (file)
@@ -22,44 +22,50 @@ import io.grpc.stub.StreamObserver
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.GlobalScope
 import kotlinx.coroutines.launch
-import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_SYNC
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status
-import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.saveCBAFile
+import kotlinx.coroutines.reactive.awaitSingle
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.*
 import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.toProto
 import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.slf4j.LoggerFactory
 import org.springframework.http.codec.multipart.FilePart
 import org.springframework.stereotype.Service
-import reactor.core.publisher.Mono
+import java.io.File
+import java.io.IOException
+import java.util.*
 import java.util.stream.Collectors
 
 @Service
-class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
+class ExecutionServiceHandler(private val bluePrintPathConfiguration: BluePrintPathConfiguration,
                               private val bluePrintCatalogService: BluePrintCatalogService,
                               private val bluePrintWorkflowExecutionService
                               : BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>) {
 
     private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString())
 
-    fun upload(filePart: FilePart): Mono<String> {
+    suspend fun upload(filePart: FilePart): String {
+        val saveId = UUID.randomUUID().toString()
+        val blueprintArchive = normalizedPathName(bluePrintPathConfiguration.blueprintArchivePath, saveId)
+        val blueprintWorking = normalizedPathName(bluePrintPathConfiguration.blueprintWorkingPath, saveId)
         try {
-            val archivedPath = BluePrintFileUtils.getCbaStorageDirectory(bluePrintCoreConfiguration.archivePath)
-            val cbaPath = saveCBAFile(filePart, archivedPath)
-            bluePrintCatalogService.saveToDatabase(cbaPath.toFile()).let {
-                return Mono.just("{\"status\": \"Successfully uploaded blueprint with id($it)\"}")
-            }
-        } catch (e: Exception) {
-            return Mono.error<String>(BluePrintException("Error uploading the CBA file.", e))
+
+            val compressedFile = normalizedFile(blueprintArchive, "cba.zip")
+            compressedFile.parentFile.reCreateNBDirs()
+            // Copy the File Part to Local File
+            copyFromFilePart(filePart, compressedFile)
+            // Save the Copied file to Database
+            return bluePrintCatalogService.saveToDatabase(saveId, compressedFile, true)
+        } catch (e: IOException) {
+            throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
+                    "Error in Upload CBA: ${e.message}", e)
+        } finally {
+            deleteNBDir(blueprintArchive)
+            deleteNBDir(blueprintWorking)
         }
     }
 
@@ -80,8 +86,8 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
                 responseObserver.onCompleted()
             }
             else -> responseObserver.onNext(response(executionServiceInput,
-                "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.",
-                true).toProto());
+                    "Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.",
+                    true).toProto());
         }
     }
 
@@ -100,7 +106,7 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
         val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath.toString())
 
         val output = bluePrintWorkflowExecutionService.executeBluePrintWorkflow(blueprintRuntimeService,
-            executionServiceInput, hashMapOf())
+                executionServiceInput, hashMapOf())
 
         val errors = blueprintRuntimeService.getBluePrintError().errors
         if (errors.isNotEmpty()) {
@@ -111,6 +117,12 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
         return output
     }
 
+    private suspend fun copyFromFilePart(filePart: FilePart, targetFile: File): File {
+        return filePart.transferTo(targetFile)
+                .thenReturn(targetFile)
+                .awaitSingle()
+    }
+
     private fun setErrorStatus(errorMessage: String, status: Status) {
         status.errorMessage = errorMessage
         status.eventType = EventType.EVENT_COMPONENT_FAILURE.name
index a03ad9e..fd764d7 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright Â© 2017-2018 AT&T Intellectual Property.
  * Modifications Copyright Â© 2019 Bell Canada.
+ * Modifications Copyright Â© 2019 IBM.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,8 +24,11 @@ import org.junit.Rule
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader
-import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementInput
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
 import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintRemoveInput
+import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput
 import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
@@ -32,7 +36,6 @@ import org.springframework.context.annotation.ComponentScan
 import org.springframework.test.annotation.DirtiesContext
 import org.springframework.test.context.TestPropertySource
 import org.springframework.test.context.junit4.SpringRunner
-import java.io.File
 import kotlin.test.AfterTest
 import kotlin.test.BeforeTest
 import kotlin.test.assertEquals
@@ -55,25 +58,23 @@ class BluePrintManagementGRPCHandlerTest {
     fun init() {
         // Create a server, add service, start, and register for automatic graceful shutdown.
         grpcServerRule.serviceRegistry.addService(bluePrintManagementGRPCHandler)
+        deleteDir("target", "blueprints")
     }
 
     @AfterTest
     fun cleanDir() {
-        //TODO It's giving fluctuating results, need to look for another way to cleanup
-        // works sometimes otherwise results IO Exception
-        // Most probably bufferReader stream is not getting closed when cleanDir is getting invoked
-        File("./target/blueprints").deleteRecursively()
+        deleteDir("target", "blueprints")
     }
 
     @Test
     fun `test upload blueprint`() {
         val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(grpcServerRule.channel)
         val id = "123_upload"
-        val req = createInputRequest(id)
+        val req = createUploadInputRequest(id)
         val output = blockingStub.uploadBlueprint(req)
 
         assertEquals(200, output.status.code)
-        assertTrue(output.status.message.contains("Successfully uploaded blueprint sample:1.0.0 with id("))
+        assertTrue(output.status.message.contains("Successfully uploaded CBA"))
         assertEquals(id, output.commonHeader.requestId)
     }
 
@@ -81,19 +82,20 @@ class BluePrintManagementGRPCHandlerTest {
     fun `test delete blueprint`() {
         val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(grpcServerRule.channel)
         val id = "123_delete"
-        val req = createInputRequest(id)
+        val req = createUploadInputRequest(id)
 
         var output = blockingStub.uploadBlueprint(req)
         assertEquals(200, output.status.code)
-        assertTrue(output.status.message.contains("Successfully uploaded blueprint sample:1.0.0 with id("))
+        assertTrue(output.status.message.contains("Successfully uploaded CBA"))
         assertEquals(id, output.commonHeader.requestId)
 
-        output = blockingStub.removeBlueprint(req)
+        val removeReq = createRemoveInputRequest(id)
+        output = blockingStub.removeBlueprint(removeReq)
         assertEquals(200, output.status.code)
     }
 
-    private fun createInputRequest(id: String): BluePrintManagementInput {
-        val file = File("./src/test/resources/test-cba.zip")
+    private fun createUploadInputRequest(id: String): BluePrintUploadInput {
+        val file = normalizedFile("./src/test/resources/test-cba.zip")
         assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
 
         val commonHeader = CommonHeader
@@ -106,11 +108,24 @@ class BluePrintManagementGRPCHandlerTest {
         val fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(file.inputStream().readBytes()))
                 .build()
 
-        return BluePrintManagementInput.newBuilder()
+        return BluePrintUploadInput.newBuilder()
+                .setCommonHeader(commonHeader)
+                .setFileChunk(fileChunk)
+                .build()
+    }
+
+    private fun createRemoveInputRequest(id: String): BluePrintRemoveInput {
+        val commonHeader = CommonHeader
+                .newBuilder()
+                .setTimestamp("2012-04-23T18:25:43.511Z")
+                .setOriginatorId("System")
+                .setRequestId(id)
+                .setSubRequestId("1234-56").build()
+
+        return BluePrintRemoveInput.newBuilder()
                 .setCommonHeader(commonHeader)
                 .setBlueprintName("sample")
                 .setBlueprintVersion("1.0.0")
-                .setFileChunk(fileChunk)
                 .build()
     }
 }
index b131fb7..d14761c 100644 (file)
 
 package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
 
+import kotlinx.coroutines.reactive.awaitSingle
+import kotlinx.coroutines.runBlocking
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.springframework.beans.factory.annotation.Autowired
@@ -33,9 +36,13 @@ import org.springframework.test.context.ContextConfiguration
 import org.springframework.test.context.TestPropertySource
 import org.springframework.test.context.junit4.SpringRunner
 import org.springframework.test.web.reactive.server.WebTestClient
+import org.springframework.test.web.reactive.server.returnResult
 import org.springframework.web.reactive.function.BodyInserters
 import java.nio.file.Files
 import java.nio.file.Paths
+import java.util.*
+import kotlin.test.AfterTest
+import kotlin.test.BeforeTest
 import kotlin.test.assertTrue
 
 @RunWith(SpringRunner::class)
@@ -50,40 +57,61 @@ class ExecutionServiceHandlerTest {
     @Autowired
     lateinit var webTestClient: WebTestClient
 
+    @BeforeTest
+    fun init() {
+        deleteDir("target", "blueprints")
+    }
+
+    @AfterTest
+    fun cleanDir() {
+        deleteDir("target", "blueprints")
+    }
+
 
     @Test
     fun `test rest upload blueprint`() {
-        val file = Paths.get("./src/test/resources/test-cba.zip").toFile()
-        assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
+        runBlocking {
+            val file = Paths.get("./src/test/resources/test-cba.zip").toFile()
+            assertTrue(file.exists(), "couldn't get file ${file.absolutePath}")
+
+            val body = MultipartBodyBuilder().apply {
+                part("file", object : ByteArrayResource(Files.readAllBytes(Paths.get("./src/test/resources/test-cba.zip"))) {
+                    override fun getFilename(): String {
+                        return "test-cba.zip"
+                    }
+                })
+            }.build()
 
-        val body = MultipartBodyBuilder().apply {
-            part("file", object : ByteArrayResource(Files.readAllBytes(Paths.get("./src/test/resources/test-cba.zip"))) {
-                override fun getFilename(): String {
-                    return "test-cba.zip"
-                }
-            })
-        }.build()
+            webTestClient
+                    .post()
+                    .uri("/api/v1/execution-service/upload")
+                    .body(BodyInserters.fromMultipartData(body))
+                    .exchange()
+                    .expectStatus().isOk
+                    .returnResult<String>()
+                    .responseBody
+                    .awaitSingle()
+        }
 
-        webTestClient
-                .post()
-                .uri("/api/v1/execution-service/upload")
-                .body(BodyInserters.fromMultipartData(body))
-                .exchange()
-                .expectStatus().isOk
     }
 
     @Test
     fun `test rest process`() {
-        val file = Paths.get("./src/test/resources/test-cba.zip").toFile()
-        assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
-        blueprintCatalog.saveToDatabase(file)
+        runBlocking {
+            val file = Paths.get("./src/test/resources/test-cba.zip").toFile()
+            assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
+            blueprintCatalog.saveToDatabase(UUID.randomUUID().toString(), file)
+
+            val executionServiceInput = JacksonUtils
+                    .readValueFromClassPathFile("execution-input/default-input.json",
+                            ExecutionServiceInput::class.java)!!
 
-        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
-        webTestClient
-                .post()
-                .uri("/api/v1/execution-service/process")
-                .body(BodyInserters.fromObject(executionServiceInput))
-                .exchange()
-                .expectStatus().isOk
+            webTestClient
+                    .post()
+                    .uri("/api/v1/execution-service/process")
+                    .body(BodyInserters.fromObject(executionServiceInput))
+                    .exchange()
+                    .expectStatus().isOk
+        }
     }
 }
\ No newline at end of file
index 6d8b62f..6705523 100644 (file)
@@ -25,6 +25,7 @@ blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.Improve
 blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
 # Controller Blueprints Core Configuration
 blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work
 blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
 
 # Python executor
index 35fef96..be4327b 100644 (file)
@@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.JsonNode
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status
-import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
 import org.onap.ccsdk.cds.controllerblueprints.core.asObjectNode
@@ -120,6 +119,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
             prepareRequest(executionServiceInput)
             process(executionServiceInput)
         } catch (runtimeException: RuntimeException) {
+            log.error("failed in ${getName()} : ${runtimeException.message}", runtimeException)
             recover(runtimeException, executionServiceInput)
         }
         return prepareResponse()
index 6712a7f..df250ae 100644 (file)
@@ -77,7 +77,7 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
     }
 
     override fun registerExecutors(name: String, svcLogicNodeExecutor: AbstractSvcLogicNodeExecutor) {
-        log.info("Registering executors($name) with type(${svcLogicNodeExecutor.javaClass}")
+        log.debug("Registering executors($name) with type(${svcLogicNodeExecutor.javaClass}")
         nodeExecutors[name] = svcLogicNodeExecutor
     }
 
index 0b2ac70..4343ff6 100755 (executable)
@@ -37,8 +37,7 @@
         <kotlin.maven.version>1.3.21</kotlin.maven.version>
         <kotlin.couroutines.version>1.1.1</kotlin.couroutines.version>
         <grpc.version>1.18.0</grpc.version>
-        <!-- TODO("Migrate SSHD to 2.x version") -->
-        <sshd.version>1.7.0</sshd.version>
+        <sshd.version>2.2.0</sshd.version>
         <jsch.version>0.1.55</jsch.version>
         <protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
         <eelf.version>1.0.0</eelf.version>
                 <scope>import</scope>
             </dependency>
 
-            <!-- Logging Dependencies -->
-            <dependency>
-                <groupId>com.att.eelf</groupId>
-                <artifactId>eelf-core</artifactId>
-                <version>${eelf.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.onap.logging-analytics</groupId>
-                <artifactId>logging-slf4j</artifactId>
-                <version>${onap.logger.slf4j}</version>
-            </dependency>
-
             <!--Swagger Dependencies -->
             <dependency>
                 <groupId>io.springfox</groupId>
                 <artifactId>springfox-swagger2</artifactId>
                 <version>${springfox.swagger2.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-api</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>io.springfox</groupId>
                 <groupId>org.apache.velocity</groupId>
                 <artifactId>velocity</artifactId>
                 <version>1.7</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-api</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>com.google.guava</groupId>
                 <groupId>org.apache.sshd</groupId>
                 <artifactId>sshd-core</artifactId>
                 <version>${sshd.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-api</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>com.jcraft</groupId>
     </dependencyManagement>
 
     <dependencies>
-        <dependency>
-            <groupId>com.att.eelf</groupId>
-            <artifactId>eelf-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.logging-analytics</groupId>
-            <artifactId>logging-slf4j</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         <dependency>
             <groupId>com.jayway.jsonpath</groupId>
             <artifactId>json-path</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
         <dependency>
             <groupId>io.springfox</groupId>
             <artifactId>springfox-swagger2</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>io.springfox</groupId>
index 3bb7fde..ddefb27 100644 (file)
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-security</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-logging</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
index 29d2eb7..df979c6 100644 (file)
@@ -16,8 +16,8 @@
 
 package org.onap.ccsdk.cds.controllerblueprints;
 
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -32,7 +32,7 @@ import org.springframework.web.reactive.config.EnableWebFlux;
 @ComponentScan(basePackages = {"org.onap.ccsdk.cds.controllerblueprints"})
 @EnableAutoConfiguration
 public class ControllerBlueprintsApplication {
-    private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBlueprintsApplication.class);
+    private static Logger log = LoggerFactory.getLogger(ControllerBlueprintsApplication.class);
 
     public static void main(String[] args) {
         log.info("****** Starting Controlled Blueprints Application ******");
index 131ff01..d992dd9 100644 (file)
@@ -16,8 +16,8 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.security;
 
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
@@ -37,7 +37,7 @@ public class ApplicationSecurityConfigurerAdapter {
     @Value("${basic-auth.hashed-pwd}")
     private String userHashedPassword;
 
-    private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationSecurityConfigurerAdapter.class);
+    private static Logger log = LoggerFactory.getLogger(ApplicationSecurityConfigurerAdapter.class);
 
     @Bean
     public SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception {
index 7282d75..46218d6 100755 (executable)
@@ -53,7 +53,7 @@ resourceSourceMappings=processor-db=source-processor-db,input=source-input,defau
 # Controller Blueprints Core Configuration
 controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy
 controllerblueprints.blueprintArchivePath=/etc/blueprints/archive
-controllerblueprints.blueprintEnrichmentPath=/etc/blueprints/enrichment
+controllerblueprints.blueprintWorkingPath=/etc/blueprints/work
 # Controller Blueprint Load Configurations
 controllerblueprints.loadInitialData=true
 controllerblueprints.loadBluePrint=false
index 5877ea5..b9c1d4f 100755 (executable)
@@ -57,7 +57,7 @@ resourceSourceMappings=processor-db=source-processor-db,input=source-input,defau
 # Controller Blueprints Core Configuration
 controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy
 controllerblueprints.blueprintArchivePath=/etc/blueprints/archive
-controllerblueprints.blueprintEnrichmentPath=/etc/blueprints/enrichment
+controllerblueprints.blueprintWorkingPath=/etc/blueprints/work
 # Controller Blueprint Load Configurations
 # blueprints.load.initial-data may be overridden by ENV variables
 controllerblueprints.loadInitialData=true
index 71597af..9688b26 100644 (file)
 \r
 package org.onap.ccsdk.cds.controllerblueprints;\r
 \r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
 import org.apache.commons.lang3.StringUtils;\r
 import org.junit.Assert;\r
 import org.junit.Test;\r
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;\r
 \r
 /**\r
@@ -29,7 +29,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  * @author Brinda Santh\r
  */\r
 public class VersionSplitTest {\r
-    private static EELFLogger log = EELFManager.getInstance().getLogger(VersionSplitTest.class);\r
+    private static Logger log = LoggerFactory.getLogger(VersionSplitTest.class);
 \r
     @Test\r
     public void testVersionSplit() {\r
index 6744b62..bda60ea 100644 (file)
@@ -84,6 +84,14 @@ fun normalizedPathName(path: String, vararg more: String?): String {
     return normalizedPath(path, *more).toString()
 }
 
+suspend fun File.reCreateNBDirs(): File = withContext(Dispatchers.IO) {
+    reCreateDirs()
+}
+
+suspend fun deleteNBDir(path: String, vararg more: String?) = withContext(Dispatchers.IO) {
+    normalizedFile(path, *more).deleteRecursively()
+}
+
 suspend fun File.readNBText(): String = withContext(Dispatchers.IO) {
     readText(Charset.defaultCharset())
 }
index 2815bad..8674c4d 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.core.config
 
-open class BluePrintLoadConfiguration {
 
+open class BluePrintPathConfiguration {
     lateinit var blueprintDeployPath: String
     lateinit var blueprintArchivePath: String
-    lateinit var blueprintEnrichmentPath: String
+    lateinit var blueprintWorkingPath: String
+}
 
+
+open class BluePrintLoadConfiguration : BluePrintPathConfiguration() {
     var loadInitialData: Boolean = false
     var loadBluePrint: Boolean = false
     var loadBluePrintPaths: String? = null
index d71569e..9b4f6b5 100755 (executable)
@@ -16,8 +16,6 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.interfaces
 
-import org.jetbrains.annotations.NotNull
-import org.jetbrains.annotations.Nullable
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import java.io.File
 import java.nio.file.Path
@@ -26,14 +24,14 @@ interface BluePrintCatalogService {
 
     /**
      * Save the CBA to database.
+     * @param processingId Processing Id
      * @param blueprintFile Either a directory, or an archive
      * @param validate whether to validate blueprint content. Default true.
      * @return The unique blueprint identifier
      * @throws BluePrintException if process failed
      */
-    @NotNull
     @Throws(BluePrintException::class)
-    fun saveToDatabase(@NotNull blueprintFile: File, @Nullable validate: Boolean = true): String
+    suspend fun saveToDatabase(processingId: String, blueprintFile: File, validate: Boolean = true): String
 
     /**
      * Retrieve the CBA from database either archived or extracted.
@@ -43,9 +41,9 @@ interface BluePrintCatalogService {
      * @return Path where CBA is located
      * @throws BluePrintException if process failed
      */
-    @NotNull
+
     @Throws(BluePrintException::class)
-    fun getFromDatabase(@NotNull name: String, @NotNull version: String, @Nullable extract: Boolean = true): Path
+    suspend fun getFromDatabase(name: String, version: String, extract: Boolean = true): Path
 
     /**
      * Delete the CBA from database.
@@ -53,7 +51,7 @@ interface BluePrintCatalogService {
      * @param version Version of the blueprint
      * @throws BluePrintException if process failed
      */
-    @NotNull
+
     @Throws(BluePrintException::class)
-    fun deleteFromDatabase(@NotNull name: String, @NotNull version: String)
+    suspend fun deleteFromDatabase(name: String, version: String)
 }
\ No newline at end of file
index f0a3bcc..26181bb 100644 (file)
@@ -18,8 +18,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
@@ -33,7 +32,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
  */
 class BluePrintContext(val serviceTemplate: ServiceTemplate) {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+    private val log= LoggerFactory.getLogger(this::class.toString())
 
     /**
      * Blueprint CBA extracted file location
index a126d64..32cb6ac 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.ArrayNode
 import com.fasterxml.jackson.databind.node.ObjectNode
@@ -34,7 +33,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.data.*
  * @author Brinda Santh
  */
 object BluePrintExpressionService {
-    val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+    val log= LoggerFactory.getLogger(this::class.toString())
 
     @JvmStatic
     fun checkContainsExpression(propertyAssignmentNode: JsonNode): Boolean {
index 8562287..4b02492 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.data.*
@@ -26,7 +25,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 
 open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintRepoFileService::class.toString())
 
     private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE)
     private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE)
index 37ab717..8f39a5a 100644 (file)
@@ -18,8 +18,7 @@
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.NullNode
 import com.fasterxml.jackson.databind.node.ObjectNode
@@ -134,7 +133,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
     : BluePrintRuntimeService<MutableMap<String, JsonNode>> {
 
     @Transient
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRuntimeService::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintRuntimeService::class.toString())
 
     private var store: MutableMap<String, JsonNode> = hashMapOf()
 
index 03fdc22..e74a8e9 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.google.common.base.Preconditions
 import org.apache.commons.lang3.StringUtils
@@ -44,7 +43,7 @@ interface BluePrintValidatorService : Serializable {
 @Deprecated("Decomposed implementation moved to blueprint-validation module")
 open class BluePrintValidatorDefaultService : BluePrintValidatorService {
 
-    val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorDefaultService::class.toString())
+    val log= LoggerFactory.getLogger(BluePrintValidatorDefaultService::class.toString())
 
     lateinit var bluePrintContext: BluePrintContext
     lateinit var serviceTemplate: ServiceTemplate
index 6080f52..931d31e 100644 (file)
@@ -18,8 +18,7 @@
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.NullNode
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
@@ -37,7 +36,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.ResourceResolverUtils
  * @author Brinda Santh
  */
 class PropertyAssignmentService(var bluePrintRuntimeService: BluePrintRuntimeService<MutableMap<String, JsonNode>>) {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+    private val log= LoggerFactory.getLogger(this::class.toString())
 
     private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext()
 
index 2586776..5f9725f 100755 (executable)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.utils
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import kotlinx.coroutines.runBlocking
 import org.apache.commons.io.FileUtils
 import org.apache.commons.lang3.StringUtils
@@ -39,7 +38,7 @@ import java.nio.file.StandardOpenOption
 class BluePrintFileUtils {
     companion object {
 
-        private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+        private val log= LoggerFactory.getLogger(this::class.toString())
 
         fun createEmptyBluePrint(basePath: String) {
 
index bc01039..c51f482 100644 (file)
@@ -18,8 +18,7 @@
 package org.onap.ccsdk.cds.controllerblueprints.core.utils
 
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import kotlinx.coroutines.runBlocking
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
@@ -36,7 +35,7 @@ import java.util.*
 
 class BluePrintMetadataUtils {
     companion object {
-        private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+        private val log= LoggerFactory.getLogger(this::class.toString())
 
 
         suspend fun toscaMetaData(basePath: String): ToscaMetaData {
index 2e3211e..3dd7567 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.utils
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.NullNode
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
@@ -29,7 +28,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
  * @author Brinda Santh
  */
 object BluePrintRuntimeUtils {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+    private val log= LoggerFactory.getLogger(this::class.toString())
 
     fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap<String, JsonNode>) {
         val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName)
index a7136a5..9fbc385 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.utils
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.withContext
@@ -30,7 +29,7 @@ import java.nio.charset.Charset
 class JacksonReactorUtils {
     companion object {
 
-        private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+        private val log= LoggerFactory.getLogger(this::class.toString())
 
         suspend fun getContent(fileName: String): String {
             //log.info("Reading File($fileName)")
index 7ac79e2..7b5f181 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright Â© 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright Â© 2018 IBM.
+ * Modifications Copyright Â© 2018-2019 IBM.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import kotlinx.coroutines.withContext
 import org.apache.commons.io.IOUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.*
 import java.io.File
+import java.io.InputStream
 import java.nio.charset.Charset
 
 /**
@@ -42,10 +43,17 @@ class JacksonUtils {
         inline fun <reified T : Any> readValue(content: String): T =
                 objectMapper.readValue(content, T::class.java)
 
+        inline fun <reified T : Any> readValue(stream: InputStream): T =
+                objectMapper.readValue(stream, T::class.java)
+
         fun <T> readValue(content: String, valueType: Class<T>): T? {
             return objectMapper.readValue(content, valueType)
         }
 
+        fun <T> readValue(stream: InputStream, valueType: Class<T>): T? {
+            return objectMapper.readValue(stream, valueType)
+        }
+
         fun <T> readValue(node: JsonNode, valueType: Class<T>): T? {
             return objectMapper.treeToValue(node, valueType)
         }
index 90e4ff8..f26e7ae 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.utils
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
 import java.io.File
@@ -30,7 +29,7 @@ import java.net.URL
  * @author Brinda Santh
  */
 object ResourceResolverUtils {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+    private val log= LoggerFactory.getLogger(this::class.toString())
 
     fun getFileContent(filename: String, basePath: String?): String {
         log.trace("file ({}), basePath ({}) ", filename, basePath)
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctionTest.kt
new file mode 100644 (file)
index 0000000..9a0da69
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  Copyright Â© 2019 IBM.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.controllerblueprints.core
+
+import org.junit.Test
+import kotlin.test.assertTrue
+
+class FileExtensionFunctionTest {
+    val blueprintBasePath = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+
+    @Test
+    fun testCompress() {
+        val blueprintFile = normalizedFile(blueprintBasePath)
+        val targetZip = normalizedFile("target", "compress.zip")
+        targetZip.deleteRecursively()
+        blueprintFile.compress(targetZip)
+        assertTrue(blueprintFile.exists(), "failed to create compressed file(${targetZip.absolutePath} ")
+    }
+
+}
\ No newline at end of file
index ac21f13..2c6561f 100644 (file)
@@ -18,8 +18,7 @@
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.junit.Test
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
@@ -32,7 +31,7 @@ import kotlin.test.assertNotNull
  */
 class BluePrintContextTest {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+    private val log= LoggerFactory.getLogger(this::class.toString())
 
     val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
 
index 3c573c4..4c207fb 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.service
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.NullNode
 import org.junit.Test
@@ -37,7 +36,7 @@ import kotlin.test.assertNotNull
  * @author Brinda Santh
  */
 class BluePrintRuntimeServiceTest {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+    private val log= LoggerFactory.getLogger(this::class.toString())
 
     @Test
     fun `test Resolve NodeTemplate Properties`() {
index 8812816..d0e971a 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.core.utils
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import kotlinx.coroutines.runBlocking
 import org.junit.Test
 
 class JacksonReactorUtilsTest {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+    private val log= LoggerFactory.getLogger(this::class.toString())
 
     @Test
     fun testJsonNodeFromClassPathFile() {
index 3d17213..faa198f 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.core.utils
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.junit.Test
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import kotlin.test.assertNotNull
@@ -31,7 +30,7 @@ import kotlin.test.assertTrue
  */
 class JacksonUtilsTest {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
+    private val log= LoggerFactory.getLogger(this::class.toString())
 
     @Test
     fun testJsonNodeFromClassPathFile() {
index 297bf43..182c22c 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
@@ -35,7 +34,7 @@ import java.io.File
 open class BluePrintArtifactDefinitionValidatorImpl(
         private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactDefinitionValidator {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintArtifactDefinitionValidatorImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintArtifactDefinitionValidatorImpl::class.toString())
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
     lateinit var bluePrintContext: BluePrintContext
index 0d16f9b..3cec5af 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
 import org.onap.ccsdk.cds.controllerblueprints.core.data.AttributeDefinition
@@ -35,7 +34,7 @@ import org.springframework.stereotype.Service
 open class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator {
 
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
 
index 72fb7ac..c67a9bc 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
@@ -39,7 +38,7 @@ open class BluePrintDesignTimeValidatorService(private val bluePrintTypeValidato
                                                private val resourceDefinitionValidator: ResourceDefinitionValidator)
     : BluePrintValidatorService {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDesignTimeValidatorService::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintDesignTimeValidatorService::class.toString())
 
     override fun validateBluePrints(basePath: String): Boolean {
 
index fb466f7..48f1b21 100644 (file)
@@ -17,9 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.cds.controllerblueprints.validation.utils.PropertyAssignmentValidationUtils
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
 import org.onap.ccsdk.cds.controllerblueprints.core.data.*
@@ -27,6 +25,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTemp
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.validation.utils.PropertyAssignmentValidationUtils
 import org.springframework.beans.factory.config.ConfigurableBeanFactory
 import org.springframework.context.annotation.Scope
 import org.springframework.stereotype.Service
@@ -36,7 +35,7 @@ import org.springframework.stereotype.Service
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTemplateValidator {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintNodeTemplateValidatorImpl::class.toString())
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
     lateinit var bluePrintContext: BluePrintContext
@@ -44,7 +43,7 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
     var paths: MutableList<String> = arrayListOf()
 
     override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
-        log.info("Validating NodeTemplate($name)")
+        log.debug("Validating NodeTemplate($name)")
 
         this.bluePrintRuntimeService = bluePrintRuntimeService
         this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
@@ -132,7 +131,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
     @Throws(BluePrintException::class)
     open fun validateRequirementAssignment(nodeTemplateName: String, requirementAssignmentName: String,
                                            requirementDefinition: RequirementDefinition, requirementAssignment: RequirementAssignment) {
-        log.info("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, requirementAssignmentName)
+        log.debug("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName,
+                requirementAssignmentName)
         val requirementNodeTemplateName = requirementAssignment.node!!
         val capabilityName = requirementAssignment.capability
         val relationship = requirementAssignment.relationship!!
@@ -197,7 +197,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
                 val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName)
                         ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName)")
 
-                log.info("Validation NodeTemplate($nodeTemplateName) Interface($interfaceAssignmentName) Operation ($operationAssignmentName)")
+                log.debug("Validation NodeTemplate($nodeTemplateName) Interface($interfaceAssignmentName) Operation " +
+                        "($operationAssignmentName)")
 
                 val inputs = operationAssignments.inputs
                 val outputs = operationAssignments.outputs
index 3085140..10804e4 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
 import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmptyOrThrow
@@ -36,7 +35,7 @@ import org.springframework.stereotype.Service
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
     lateinit var bluePrintContext: BluePrintContext
index 6808b8e..c2c80d7 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
 import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
@@ -34,7 +33,7 @@ import org.springframework.stereotype.Service
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
 
index cb9873c..0e76be4 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.google.common.base.Preconditions
 import org.apache.commons.lang3.StringUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
@@ -34,7 +33,7 @@ import org.springframework.stereotype.Service
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintServiceTemplateValidator {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
     lateinit var error: BluePrintError
index f881054..406f8de 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
 import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
@@ -35,7 +34,7 @@ import org.springframework.stereotype.Service
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
 
index 13307fd..e705808 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.validation.utils.PropertyAssignmentValidationUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.data.Workflow
@@ -33,7 +32,7 @@ import org.springframework.stereotype.Service
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
 
     var paths: MutableList<String> = arrayListOf()
index 0c3cef2..03183e6 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation.extension
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ArtifactDefinition
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionValidator
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
@@ -32,7 +31,7 @@ import java.io.File
 open class ArtifactMappingResourceValidator(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService)
     : BluePrintArtifactDefinitionValidator {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(ArtifactMappingResourceValidator::class.toString())
+    private val log= LoggerFactory.getLogger(ArtifactMappingResourceValidator::class.toString())
 
     override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
                           artifactDefinition: ArtifactDefinition) {
index 6439ee8..608de4f 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.validation.extension
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidator
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
@@ -32,7 +31,7 @@ interface ResourceDefinitionValidator : BluePrintValidator<ResourceDefinition>
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class ResourceDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : ResourceDefinitionValidator {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidatorImpl::class.java)
+    private val log= LoggerFactory.getLogger(ResourceDefinitionValidatorImpl::class.java)
 
     override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
                           resourceDefinition: ResourceDefinition) {
index 3be5648..9780bbd 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.db.resources
 
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.slf4j.LoggerFactory
 import java.io.File
 import java.nio.file.Path
-import java.util.*
 import javax.persistence.MappedSuperclass
 
 @MappedSuperclass
-abstract class BlueprintCatalogServiceImpl(private val blueprintValidator: BluePrintValidatorService)
-    : BluePrintCatalogService {
+abstract class BlueprintCatalogServiceImpl(
+        private val bluePrintPathConfiguration: BluePrintPathConfiguration,
+        private val blueprintValidator: BluePrintValidatorService) : BluePrintCatalogService {
 
-    override fun saveToDatabase(blueprintFile: File, validate: Boolean): String {
-        val extractedDirectory: File
-        val archivedDirectory: File
-        val toDeleteDirectory: File
-        val blueprintId = UUID.randomUUID().toString()
+    private val log = LoggerFactory.getLogger(BlueprintCatalogServiceImpl::class.java)!!
+
+    override suspend fun saveToDatabase(processingId: String, blueprintFile: File, validate: Boolean): String {
+
+        var archiveFile: File? = null
+        var workingDir: String? = null
 
         if (blueprintFile.isDirectory) {
-            extractedDirectory = blueprintFile
-            archivedDirectory = File("$blueprintFile.zip")
-            toDeleteDirectory = archivedDirectory
+            log.info("Save processing($processingId) Working Dir(${blueprintFile.absolutePath})")
+            workingDir = blueprintFile.absolutePath
+            archiveFile = normalizedFile(bluePrintPathConfiguration.blueprintArchivePath, processingId, "cba.zip")
 
-            if (!BluePrintArchiveUtils.compress(blueprintFile, archivedDirectory, true)) {
+            if (!BluePrintArchiveUtils.compress(blueprintFile, archiveFile, true)) {
                 throw BluePrintException("Fail to compress blueprint")
             }
         } else {
-            val targetDir = "${blueprintFile.parent}/${BluePrintFileUtils.stripFileExtension(blueprintFile.name)}"
-
-            extractedDirectory = BluePrintArchiveUtils.deCompress(blueprintFile, targetDir)
-            archivedDirectory = blueprintFile
-            toDeleteDirectory = extractedDirectory
+            // Compressed File
+            log.info("Save processing($processingId) CBA(${blueprintFile.absolutePath})")
+            workingDir = normalizedPathName(bluePrintPathConfiguration.blueprintWorkingPath, processingId)
+            archiveFile = blueprintFile
+            // Decompress the CBA file to working Directory
+            blueprintFile.deCompress(workingDir)
         }
 
         var valid = BluePrintConstants.FLAG_N
         if (validate) {
-            blueprintValidator.validateBluePrints(extractedDirectory.path)
+            blueprintValidator.validateBluePrints(workingDir!!)
             valid = BluePrintConstants.FLAG_Y
         }
 
-        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(blueprintId, extractedDirectory.path)
+        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(processingId, workingDir!!)
         val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
-        metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = blueprintId
+        metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = processingId
         metadata[BluePrintConstants.PROPERTY_BLUEPRINT_VALID] = valid
 
-        save(metadata, archivedDirectory)
-
-        toDeleteDirectory.deleteRecursively()
+        save(metadata, archiveFile)
 
-        return blueprintId
+        return processingId
     }
 
-    override fun getFromDatabase(name: String, version: String, extract: Boolean): Path = get(name, version, extract)
+    override suspend fun getFromDatabase(name: String, version: String, extract: Boolean): Path = get(name, version,
+            extract)
             ?: throw BluePrintException("Could not find blueprint $name:$version from database")
 
-    override fun deleteFromDatabase(name: String, version: String) = delete(name, version)
+    override suspend fun deleteFromDatabase(name: String, version: String) = delete(name, version)
 
-    abstract fun save(metadata: MutableMap<String, String>, archiveFile: File)
-    abstract fun get(name: String, version: String, extract: Boolean): Path?
-    abstract fun delete(name: String, version: String)
+    abstract suspend fun save(metadata: MutableMap<String, String>, archiveFile: File)
+    abstract suspend fun get(name: String, version: String, extract: Boolean): Path?
+    abstract suspend fun delete(name: String, version: String)
 
 }
\ No newline at end of file
index 9147862..c4d1b1d 100644 (file)
     </modules>
 
     <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-logging</artifactId>
+        </dependency>
         <!-- Test Dependencies -->
         <dependency>
             <groupId>io.mockk</groupId>
index a7e87b6..08b9d05 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.resource.dict.service
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.apache.commons.collections.CollectionUtils
 import org.apache.commons.lang3.StringUtils
 import org.apache.commons.lang3.text.StrBuilder
@@ -44,7 +43,7 @@ interface ResourceAssignmentValidationService : Serializable {
  * @author Brinda Santh
  */
 open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidationService {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceImpl::class.java)
+    private val log= LoggerFactory.getLogger(ResourceAssignmentValidationServiceImpl::class.java)
 
     open var resourceAssignmentMap: Map<String, ResourceAssignment> = hashMapOf()
     open val validationMessage = StrBuilder()
index 42bde85..dbd5b7d 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils
 
-import com.att.eelf.configuration.EELFLogger
 import org.apache.commons.collections.CollectionUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.TopologicalSortingUtils
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import java.util.ArrayList
 /**
  * BulkResourceSequencingUtils.
@@ -28,7 +27,7 @@ import java.util.ArrayList
  * @author Brinda Santh
  */
 object BulkResourceSequencingUtils {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BulkResourceSequencingUtils::class.java)
+    private val log= LoggerFactory.getLogger(BulkResourceSequencingUtils::class.java)
 
     @JvmStatic
     fun process(resourceAssignments: MutableList<ResourceAssignment>): List<List<ResourceAssignment>> {
index f615918..cd54709 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import com.fasterxml.jackson.databind.node.NullNode
 import org.apache.commons.collections.MapUtils
@@ -34,7 +33,7 @@ import java.io.File
 
 
 object ResourceDictionaryUtils {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils::class.java)
+    private val log= LoggerFactory.getLogger(ResourceDictionaryUtils::class.java)
 
     @JvmStatic
     fun populateSourceMapping(resourceAssignment: ResourceAssignment,
index db949d4..b8185c4 100644 (file)
@@ -20,11 +20,11 @@ package org.onap.ccsdk.cds.controllerblueprints.resource.dict;
 import org.junit.Assert;
 import org.junit.Test;
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ResourceDefinitionTest {
-    private EELFLogger log = EELFManager.getInstance().getLogger(ResourceDefinitionTest.class);
+    private Logger log = LoggerFactory.getLogger(ResourceDefinitionTest.class);
     private String basePath = "load/resource_dictionary";
 
     @Test
index f21ff40..b891f9e 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.resource.dict.service
 
-import com.att.eelf.configuration.EELFLogger
 import org.junit.Assert
 import org.junit.Test
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
-import com.att.eelf.configuration.EELFManager
 import org.junit.Before
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils
+import org.slf4j.LoggerFactory
 
 /**
  * ResourceAssignmentValidationServiceTest.
@@ -32,7 +31,7 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDicti
  * @author Brinda Santh
  */
 class ResourceAssignmentValidationServiceTest {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java)
+    private val log = LoggerFactory.getLogger(ResourceAssignmentValidationServiceTest::class.java)
     @Before
     fun setUp() {
         // Setup dummy Source Instance Mapping
index fccc4f5..93c4244 100644 (file)
@@ -27,18 +27,19 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils;
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment;
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition;
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDictionaryConstants;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
 
 import java.util.HashMap;
 import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * ResourceDictionaryUtilsTest.
  *
  * @author Brinda Santh
  */
 public class ResourceDictionaryUtilsTest {
-    private static final EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class);
+    private static final Logger log = LoggerFactory.getLogger(ResourceDictionaryUtilsTest.class);
 
     @Test
     public void testPopulateSourceMapping() {
index 1e71092..51484ff 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.service;
 
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
 import org.apache.commons.collections.CollectionUtils;
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
@@ -30,7 +30,7 @@ import java.util.List;
 @Component
 @SuppressWarnings("unused")
 public class ApplicationRegistrationService {
-    private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationRegistrationService.class);
+    private static Logger log = LoggerFactory.getLogger(ApplicationRegistrationService.class);
 
     @Value("#{'${resourceSourceMappings}'.split(',')}")
     private List<String> resourceSourceMappings;
index c04c0dc..b9eff76 100644 (file)
@@ -17,8 +17,6 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service;
 
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
 import com.google.common.base.Preconditions;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -30,6 +28,8 @@ import org.onap.ccsdk.cds.controllerblueprints.resource.dict.utils.ResourceDicti
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary;
 import org.onap.ccsdk.cds.controllerblueprints.service.model.AutoMapResponse;
 import org.onap.ccsdk.cds.controllerblueprints.service.repository.ResourceDictionaryRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -48,7 +48,7 @@ import java.util.Map;
 @SuppressWarnings("unused")
 public class AutoResourceMappingService {
 
-    private static EELFLogger log = EELFManager.getInstance().getLogger(AutoResourceMappingService.class);
+    private static Logger log = LoggerFactory.getLogger(AutoResourceMappingService.class);
 
     private ResourceDictionaryRepository dataDictionaryRepository;
 
index 6c09ef8..7d4d93b 100644 (file)
@@ -16,8 +16,6 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service;
 
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
 import com.google.common.base.Preconditions;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -29,6 +27,8 @@ import org.onap.ccsdk.cds.controllerblueprints.service.common.SwaggerGenerator;
 
 import java.util.HashMap;
 import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * SchemaGeneratorService.java Purpose: Provide Service to generate service template input schema definition and Sample
@@ -39,7 +39,7 @@ import java.util.Map;
  */
 @Deprecated
 public class SchemaGeneratorService {
-    private static EELFLogger log = EELFManager.getInstance().getLogger(SchemaGeneratorService.class);
+    private static Logger log = LoggerFactory.getLogger(SchemaGeneratorService.class);
 
     private Map<String, DataType> dataTypes;
 
index 8a7c018..790c61e 100644 (file)
@@ -34,7 +34,7 @@ open class ControllerBluePrintCoreConfiguration(private val bluePrintProperties:
     }
 
     @Bean
-    open fun controlelrBlueprintLoadConfiguration(): BluePrintLoadConfiguration {
+    open fun bluePrintLoadConfiguration(): BluePrintLoadConfiguration {
         return bluePrintProperties
                 .propertyBeanType(PREFIX_BLUEPRINT_LOAD_CONFIGURATION, BluePrintLoadConfiguration::class.java)
     }
@@ -53,7 +53,7 @@ open class ControllerBlueprintPropertyConfiguration {
 }
 
 @Service
-open class ControllerBlueprintProperties(var bluePrintPropertyBinder: Binder) {
+open class ControllerBlueprintProperties(private var bluePrintPropertyBinder: Binder) {
     fun <T> propertyBeanType(prefix: String, type: Class<T>): T {
         return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get()
     }
index 0ea753f..a214f96 100644 (file)
@@ -26,7 +26,6 @@ import org.springframework.http.MediaType
 import org.springframework.http.ResponseEntity
 import org.springframework.http.codec.multipart.FilePart
 import org.springframework.web.bind.annotation.*
-import reactor.core.publisher.Mono
 
 /**
  * BlueprintModelController Purpose: Handle controllerBlueprint API request
@@ -41,8 +40,8 @@ open class BlueprintModelController(private val bluePrintModelHandler: BluePrint
     @PostMapping("", produces = [MediaType.APPLICATION_JSON_VALUE], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
     @ResponseBody
     @Throws(BluePrintException::class)
-    fun saveBlueprint(@RequestPart("file") file: FilePart): Mono<BlueprintModelSearch> {
-        return bluePrintModelHandler.saveBlueprintModel(file)
+    fun saveBlueprint(@RequestPart("file") filePart: FilePart): BlueprintModelSearch = runBlocking {
+        bluePrintModelHandler.saveBlueprintModel(filePart)
     }
 
     @GetMapping("", produces = [MediaType.APPLICATION_JSON_VALUE])
index b49fc46..c6f821f 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.enhancer
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
@@ -43,7 +42,7 @@ open class BluePrintArtifactDefinitionEnhancerImpl(private val bluePrintRepoServ
     }
 
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintArtifactDefinitionEnhancerImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintArtifactDefinitionEnhancerImpl::class.toString())
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
     lateinit var bluePrintContext: BluePrintContext
index e4861e1..cad523e 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.enhancer
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
@@ -33,7 +32,7 @@ import java.util.*
 open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
                                         private val resourceDefinitionEnhancerService: ResourceDefinitionEnhancerService) : BluePrintEnhancerService {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerServiceImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintEnhancerServiceImpl::class.toString())
 
     override suspend fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext {
 
index 639b6ee..0e53c21 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.enhancer
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintNodeTemplateEnhancer
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintRepoService
@@ -36,7 +35,7 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B
                                              private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
     : BluePrintNodeTemplateEnhancer {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateEnhancerImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintNodeTemplateEnhancerImpl::class.toString())
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
     lateinit var bluePrintContext: BluePrintContext
index f248c31..2b5d007 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.enhancer
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
 import org.onap.ccsdk.cds.controllerblueprints.core.data.InterfaceDefinition
@@ -38,7 +37,7 @@ import org.springframework.stereotype.Service
 open class BluePrintNodeTypeEnhancerImpl(private val bluePrintRepoService: BluePrintRepoService,
                                          private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService) : BluePrintNodeTypeEnhancer {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTypeEnhancerImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintNodeTypeEnhancerImpl::class.toString())
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
     lateinit var bluePrintContext: BluePrintContext
index ef460ec..a6acf0b 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.enhancer
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintServiceTemplateEnhancer
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
@@ -31,7 +30,7 @@ import org.springframework.stereotype.Service
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class BluePrintServiceTemplateEnhancerImpl(private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService)
     : BluePrintServiceTemplateEnhancer {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateEnhancerImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintServiceTemplateEnhancerImpl::class.toString())
 
 
     lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
index 02e1052..8ea2313 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.enhancer
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
@@ -43,7 +42,7 @@ open class BluePrintWorkflowEnhancerImpl(private val bluePrintRepoService: BlueP
                                          private val bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
                                          private val resourceAssignmentEnhancerService: ResourceAssignmentEnhancerService)
     : BluePrintWorkflowEnhancer {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintWorkflowEnhancerImpl::class.toString())
+    private val log= LoggerFactory.getLogger(BluePrintWorkflowEnhancerImpl::class.toString())
 
     companion object {
         const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource"
index 7d4244c..b51d880 100644 (file)
@@ -16,8 +16,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.enhancer
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
@@ -53,7 +52,7 @@ interface ResourceAssignmentEnhancerService {
 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
 open class ResourceAssignmentEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService)
     : ResourceAssignmentEnhancerService {
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceImpl::class.java)
+    private val log= LoggerFactory.getLogger(ResourceAssignmentEnhancerServiceImpl::class.java)
 
     /**
      * Get the defined source instance from the ResourceAssignment,
index 6f4527a..df499b2 100644 (file)
@@ -17,8 +17,7 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.enhancer
 
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.slf4j.LoggerFactory
 import kotlinx.coroutines.Deferred
 import kotlinx.coroutines.async
 import kotlinx.coroutines.runBlocking
@@ -44,7 +43,7 @@ interface ResourceDefinitionEnhancerService {
 class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) :
         ResourceDefinitionEnhancerService {
 
-    private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionEnhancerService::class.toString())
+    private val log= LoggerFactory.getLogger(ResourceDefinitionEnhancerService::class.toString())
 
     companion object {
         const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource"
index 72c27ad..c54bf87 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.service.handler
 
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.cds.controllerblueprints.core.*
 import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintEnhancerService
-import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModel
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch
 import org.onap.ccsdk.cds.controllerblueprints.service.repository.ControllerBlueprintModelContentRepository
 import org.onap.ccsdk.cds.controllerblueprints.service.repository.ControllerBlueprintModelRepository
 import org.onap.ccsdk.cds.controllerblueprints.service.repository.ControllerBlueprintModelSearchRepository
 import org.onap.ccsdk.cds.controllerblueprints.service.utils.BluePrintEnhancerUtils
+import org.slf4j.LoggerFactory
 import org.springframework.core.io.ByteArrayResource
 import org.springframework.core.io.Resource
 import org.springframework.http.HttpHeaders
@@ -39,7 +38,6 @@ import org.springframework.http.ResponseEntity
 import org.springframework.http.codec.multipart.FilePart
 import org.springframework.stereotype.Service
 import org.springframework.transaction.annotation.Transactional
-import reactor.core.publisher.Mono
 import java.io.File
 import java.io.IOException
 import java.util.*
@@ -59,6 +57,8 @@ open class BluePrintModelHandler(private val bluePrintCatalogService: BluePrintC
                                  private val blueprintModelContentRepository: ControllerBlueprintModelContentRepository,
                                  private val bluePrintEnhancerService: BluePrintEnhancerService) {
 
+    private val log = LoggerFactory.getLogger(BluePrintModelHandler::class.java)!!
+
     /**
      * This is a getAllBlueprintModel method to retrieve all the BlueprintModel in Database
      *
@@ -76,23 +76,28 @@ open class BluePrintModelHandler(private val bluePrintCatalogService: BluePrintC
      * @throws BluePrintException BluePrintException
     </BlueprintModelSearch> */
     @Throws(BluePrintException::class)
-    open fun saveBlueprintModel(filePart: FilePart): Mono<BlueprintModelSearch> {
+    open suspend fun saveBlueprintModel(filePart: FilePart): BlueprintModelSearch {
+        val saveId = UUID.randomUUID().toString()
+        val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, saveId)
         try {
-            val cbaLocation = BluePrintFileUtils.getCbaStorageDirectory(bluePrintLoadConfiguration.blueprintArchivePath)
-            return BluePrintEnhancerUtils.saveCBAFile(filePart, cbaLocation).map { fileName ->
-                var blueprintId: String? = null
-                try {
-                    blueprintId = bluePrintCatalogService.saveToDatabase(cbaLocation.resolve(fileName).toFile(), false)
-                } catch (e: BluePrintException) {
-                    // FIXME handle expection
-                }
-                blueprintModelSearchRepository.findById(blueprintId!!).get()
-            }
+            //Recreate the Dir
+            normalizedFile(bluePrintLoadConfiguration.blueprintArchivePath, saveId).reCreateDirs()
+            val deCompressedFile = normalizedFile(blueprintArchive, "cba.zip")
+            // Copy the File Part to Local File
+            BluePrintEnhancerUtils.copyFromFilePart(filePart, deCompressedFile)
+            // Save the Copied file to Database
+            val blueprintId = bluePrintCatalogService.saveToDatabase(saveId, deCompressedFile, false)
+            // Check and Return the Saved File
+            val blueprintModelSearch = blueprintModelSearchRepository.findById(blueprintId).get()
+            log.info("Save($saveId) successful for blueprint(${blueprintModelSearch.artifactName}) " +
+                    "version(${blueprintModelSearch.artifactVersion})")
+            return blueprintModelSearch
         } catch (e: IOException) {
             throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
-                    String.format("I/O Error while uploading the CBA file: %s", e.message), e)
+                    "Error in Save CBA: ${e.message}", e)
+        } finally {
+            deleteDir(blueprintArchive)
         }
-
     }
 
 
@@ -277,20 +282,20 @@ open class BluePrintModelHandler(private val bluePrintCatalogService: BluePrintC
     open suspend fun enrichBlueprint(filePart: FilePart): ResponseEntity<Resource> {
         val enhanceId = UUID.randomUUID().toString()
         val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, enhanceId)
-        val blueprintEnrichmentDir = normalizedPathName(bluePrintLoadConfiguration.blueprintEnrichmentPath, enhanceId)
+        val blueprintWorkingDir = normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, enhanceId)
         try {
-            BluePrintEnhancerUtils.decompressFilePart(filePart, blueprintArchive, blueprintEnrichmentDir)
+            BluePrintEnhancerUtils.decompressFilePart(filePart, blueprintArchive, blueprintWorkingDir)
 
             // Enhance the Blue Prints
-            bluePrintEnhancerService.enhance(blueprintEnrichmentDir)
+            bluePrintEnhancerService.enhance(blueprintWorkingDir)
 
-            return BluePrintEnhancerUtils.compressToFilePart(blueprintEnrichmentDir, blueprintArchive)
+            return BluePrintEnhancerUtils.compressToFilePart(blueprintWorkingDir, blueprintArchive)
 
         } catch (e: IOException) {
             throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
                     "Error in Enriching CBA: ${e.message}", e)
         } finally {
-            BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintEnrichmentDir)
+            BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir)
         }
     }
 
@@ -305,12 +310,12 @@ open class BluePrintModelHandler(private val bluePrintCatalogService: BluePrintC
     open suspend fun publishBlueprint(filePart: FilePart): BlueprintModelSearch {
         val publishId = UUID.randomUUID().toString()
         val blueprintArchive = bluePrintLoadConfiguration.blueprintArchivePath.plus(File.separator).plus(publishId)
-        val blueprintEnrichmentDir = bluePrintLoadConfiguration.blueprintEnrichmentPath.plus(File.separator).plus(publishId)
+        val blueprintWorkingDir = bluePrintLoadConfiguration.blueprintWorkingPath.plus(File.separator).plus(publishId)
         try {
             val compressedFilePart = BluePrintEnhancerUtils
-                    .extractCompressFilePart(filePart, blueprintArchive, blueprintEnrichmentDir)
+                    .extractCompressFilePart(filePart, blueprintArchive, blueprintWorkingDir)
 
-            val blueprintId = bluePrintCatalogService.saveToDatabase(compressedFilePart, true)
+            val blueprintId = bluePrintCatalogService.saveToDatabase(publishId, compressedFilePart, true)
 
             return blueprintModelSearchRepository.findById(blueprintId).get()
 
@@ -318,7 +323,7 @@ open class BluePrintModelHandler(private val bluePrintCatalogService: BluePrintC
             throw BluePrintException(ErrorCode.IO_FILE_INTERRUPT.value,
                     "Error in Publishing CBA: ${e.message}", e)
         } finally {
-            BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintEnrichmentDir)
+            BluePrintEnhancerUtils.cleanEnhancer(blueprintArchive, blueprintWorkingDir)
         }
     }
 
index f602437..d68fdd0 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.service.handler
 
-import com.att.eelf.configuration.EELFManager
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType
 import org.onap.ccsdk.cds.controllerblueprints.service.repository.ModelTypeRepository
 import org.onap.ccsdk.cds.controllerblueprints.service.validator.ModelTypeValidator
+import org.slf4j.LoggerFactory
 import org.springframework.stereotype.Service
 
 @Service
 open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository) {
 
-    private val log = EELFManager.getInstance().getLogger(ModelTypeHandler::class.java)!!
+    private val log = LoggerFactory.getLogger(ModelTypeHandler::class.java)!!
 
     /**
      * This is a getModelTypeByName service
index eca7ce1..58e89d8 100644 (file)
 
 package org.onap.ccsdk.cds.controllerblueprints.service.load
 
-import com.att.eelf.configuration.EELFManager
+import kotlinx.coroutines.Deferred
+import kotlinx.coroutines.async
+import kotlinx.coroutines.runBlocking
+import org.apache.commons.lang.text.StrBuilder
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
 import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
+import org.slf4j.LoggerFactory
 import org.springframework.stereotype.Service
 import java.io.File
+import java.util.*
 
 @Service
 open class BluePrintCatalogLoadService(private val bluePrintCatalogService: BluePrintCatalogService) {
 
-    private val log = EELFManager.getInstance().getLogger(BluePrintCatalogLoadService::class.java)
+    private val log = LoggerFactory.getLogger(BluePrintCatalogLoadService::class.java)
 
-    open suspend fun loadPathsBluePrintModelCatalog(paths: List<String>) {
+    open fun loadPathsBluePrintModelCatalog(paths: List<String>) {
         paths.forEach { loadPathBluePrintModelCatalog(it) }
     }
 
-    open suspend fun loadPathBluePrintModelCatalog(path: String) {
+    open fun loadPathBluePrintModelCatalog(path: String) {
 
-        val files = normalizedFile(path).listFiles()
-        val errors = mutableListOf<String>()
-        files.forEach {
-            loadBluePrintModelCatalog(errors, it)
-        }
-        if (!errors.isEmpty()) {
-            log.error(errors.joinToString("\n"))
+        val files = File(path).listFiles()
+        runBlocking {
+            val errorBuilder = StrBuilder()
+            val deferredResults = mutableListOf<Deferred<Unit>>()
+
+            for (file in files) {
+                deferredResults += async {
+                    loadBluePrintModelCatalog(errorBuilder, file)
+                }
+            }
+
+            for (deferredResult in deferredResults) {
+                deferredResult.await()
+            }
+
+            if (!errorBuilder.isEmpty) {
+                log.error(errorBuilder.toString())
+            }
         }
     }
 
-    open suspend fun loadBluePrintModelCatalog(errorBuilder: MutableList<String>, file: File) {
+    open suspend fun loadBluePrintModelCatalog(errorBuilder: StrBuilder, file: File) {
         try {
-            log.info("loading blueprint cba(${file.absolutePath})")
-            bluePrintCatalogService.saveToDatabase(file)
+            bluePrintCatalogService.saveToDatabase(UUID.randomUUID().toString(), file)
         } catch (e: Exception) {
-            errorBuilder.add("Couldn't load BlueprintModel(${file.name}: ${e.message}")
+            errorBuilder.appendln("Couldn't load BlueprintModel(${file.name}: ${e.message}")
         }
     }
 
index 4a3168d..11c91ab 100644 (file)
@@ -17,9 +17,9 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.load
 
-import com.att.eelf.configuration.EELFManager
 import kotlinx.coroutines.runBlocking
 import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
+import org.slf4j.LoggerFactory
 import org.springframework.boot.context.event.ApplicationReadyEvent
 import org.springframework.context.event.EventListener
 import org.springframework.stereotype.Service
@@ -30,7 +30,7 @@ open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration:
                                         private val resourceDictionaryLoadService: ResourceDictionaryLoadService,
                                         private val bluePrintCatalogLoadService: BluePrintCatalogLoadService) {
 
-    private val log = EELFManager.getInstance().getLogger(BluePrintDatabaseLoadService::class.java)
+    private val log = LoggerFactory.getLogger(BluePrintDatabaseLoadService::class.java)
 
 
     @EventListener(ApplicationReadyEvent::class)
index 358a465..3d6e134 100755 (executable)
@@ -23,7 +23,9 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
 import org.onap.ccsdk.cds.controllerblueprints.core.common.ApplicationConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode
+import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService
+import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPath
 import org.onap.ccsdk.cds.controllerblueprints.db.resources.BlueprintCatalogServiceImpl
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModel
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelContent
@@ -34,7 +36,7 @@ import org.springframework.stereotype.Service
 import java.io.File
 import java.nio.file.Files
 import java.nio.file.Path
-import java.nio.file.Paths
+import java.util.*
 
 /**
  * Similar implementation in [org.onap.ccsdk.cds.blueprintsprocessor.db.BlueprintProcessorCatalogServiceImpl]
@@ -43,7 +45,7 @@ import java.nio.file.Paths
 class ControllerBlueprintCatalogServiceImpl(bluePrintValidatorService: BluePrintValidatorService,
                                             private val bluePrintLoadConfiguration: BluePrintLoadConfiguration,
                                             private val blueprintModelRepository: ControllerBlueprintModelRepository)
-    : BlueprintCatalogServiceImpl(bluePrintValidatorService) {
+    : BlueprintCatalogServiceImpl(bluePrintLoadConfiguration, bluePrintValidatorService) {
 
 
     private val log = LoggerFactory.getLogger(ControllerBlueprintCatalogServiceImpl::class.toString())
@@ -52,13 +54,18 @@ class ControllerBlueprintCatalogServiceImpl(bluePrintValidatorService: BluePrint
         log.info("BlueprintProcessorCatalogServiceImpl initialized")
     }
 
-    override fun delete(name: String, version: String) = blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(name, version)
+    override suspend fun delete(name: String, version: String) {
+        // Cleaning Deployed Blueprint
+        deleteDir(bluePrintLoadConfiguration.blueprintDeployPath, name, version)
+        // Cleaning Data Base
+        blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(name, version)
+    }
 
-    override fun get(name: String, version: String, extract: Boolean): Path? {
+    override suspend fun get(name: String, version: String, extract: Boolean): Path? {
         val path = if (extract) {
-            Paths.get("${bluePrintLoadConfiguration.blueprintDeployPath}/$name/$version")
+            normalizedPath(bluePrintLoadConfiguration.blueprintDeployPath, name, version)
         } else {
-            Paths.get("${bluePrintLoadConfiguration.blueprintArchivePath}/$name/$version.zip")
+            normalizedPath(bluePrintLoadConfiguration.blueprintArchivePath, UUID.randomUUID().toString(), "cba.zip")
         }
         blueprintModelRepository.findByArtifactNameAndArtifactVersion(name, version)?.also {
             it.blueprintModelContent.run {
@@ -70,11 +77,14 @@ class ControllerBlueprintCatalogServiceImpl(bluePrintValidatorService: BluePrint
         return null
     }
 
-    override fun save(metadata: MutableMap<String, String>, archiveFile: File) {
+    override suspend fun save(metadata: MutableMap<String, String>, archiveFile: File) {
 
         val artifactName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]
         val artifactVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]
 
+        check(archiveFile.isFile && !archiveFile.isDirectory) {
+            throw BluePrintException("Not a valid Archive file(${archiveFile.absolutePath})")
+        }
 
         blueprintModelRepository.findByArtifactNameAndArtifactVersion(artifactName!!, artifactVersion!!)?.let {
             log.info("Overwriting blueprint model :$artifactName::$artifactVersion")
index ff87ad4..f7875ef 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.load
 
-import com.att.eelf.configuration.EELFManager
 import kotlinx.coroutines.async
 import kotlinx.coroutines.awaitAll
 import kotlinx.coroutines.coroutineScope
@@ -31,13 +30,14 @@ import org.onap.ccsdk.cds.controllerblueprints.core.readNBText
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType
 import org.onap.ccsdk.cds.controllerblueprints.service.handler.ModelTypeHandler
+import org.slf4j.LoggerFactory
 import org.springframework.stereotype.Service
 import java.io.File
 
 @Service
 open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler) {
 
-    private val log = EELFManager.getInstance().getLogger(ModelTypeLoadService::class.java)
+    private val log = LoggerFactory.getLogger(ModelTypeLoadService::class.java)
     private val updateBySystem = "System"
 
     open suspend fun loadPathsModelType(modelTypePaths: List<String>) {
index 69b7c64..ce979f6 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.load
 
-import com.att.eelf.configuration.EELFManager
 import kotlinx.coroutines.async
 import kotlinx.coroutines.awaitAll
 import kotlinx.coroutines.coroutineScope
@@ -30,13 +29,14 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.ResourceDictionary
 import org.onap.ccsdk.cds.controllerblueprints.service.handler.ResourceDictionaryHandler
+import org.slf4j.LoggerFactory
 import org.springframework.stereotype.Service
 import java.io.File
 
 @Service
 open class ResourceDictionaryLoadService(private val resourceDictionaryHandler: ResourceDictionaryHandler) {
 
-    private val log = EELFManager.getInstance().getLogger(ResourceDictionaryLoadService::class.java)
+    private val log = LoggerFactory.getLogger(ResourceDictionaryLoadService::class.java)
 
     open suspend fun loadPathsResourceDictionary(paths: List<String>) {
         paths.forEach {
index 166a2b2..d4753e1 100644 (file)
@@ -84,7 +84,7 @@ class BluePrintEnhancerUtils {
             return artifactType
         }
 
-        private suspend fun copyFromFilePart(filePart: FilePart, targetFile: File): File {
+        suspend fun copyFromFilePart(filePart: FilePart, targetFile: File): File {
             // Delete the Directory
             targetFile.deleteRecursively()
             return filePart.transferTo(targetFile)
index 56a92fe..f17d637 100644 (file)
@@ -16,8 +16,6 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.common;
 
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
 import org.apache.commons.io.FileUtils;
 import org.junit.Assert;
 import org.junit.FixMethodOrder;
@@ -27,12 +25,14 @@ import org.onap.ccsdk.cds.controllerblueprints.service.SchemaGeneratorService;
 
 import java.io.File;
 import java.nio.charset.Charset;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class SchemaGeneratorServiceTest {
 
-    private static EELFLogger log = EELFManager.getInstance().getLogger(SchemaGeneratorServiceTest.class);
+    private static Logger log = LoggerFactory.getLogger(SchemaGeneratorServiceTest.class);
 
     @Test
     public void test01GenerateSwaggerData() throws Exception {
index 7414318..e55f2a5 100644 (file)
@@ -16,7 +16,6 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service
 
-import com.att.eelf.configuration.EELFManager
 import kotlinx.coroutines.runBlocking
 import org.junit.Assert
 import org.junit.FixMethodOrder
@@ -28,6 +27,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType
 import org.onap.ccsdk.cds.controllerblueprints.service.handler.ModelTypeHandler
+import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
 import org.springframework.test.annotation.Commit
@@ -48,7 +48,7 @@ class ModelTypeServiceTest {
 
     internal var modelName = "test-datatype"
 
-    private val log = EELFManager.getInstance().getLogger(ModelTypeServiceTest::class.java)
+    private val log = LoggerFactory.getLogger(ModelTypeServiceTest::class.java)
 
     @Test
     @Commit
index d61e642..64bd3ff 100644 (file)
@@ -17,9 +17,9 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.controller
 
-import com.google.gson.Gson
+import kotlinx.coroutines.reactive.awaitSingle
+import kotlinx.coroutines.runBlocking
 import org.json.JSONException
-import org.json.JSONObject
 import org.junit.After
 import org.junit.Before
 import org.junit.FixMethodOrder
@@ -27,26 +27,31 @@ import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.MethodSorters
 import org.onap.ccsdk.cds.controllerblueprints.TestApplication
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintArchiveUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.*
+import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintPathConfiguration
+import org.onap.ccsdk.cds.controllerblueprints.service.ControllerBluePrintCoreConfiguration
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.BlueprintModelSearch
+import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.beans.factory.annotation.Value
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration
 import org.springframework.boot.test.context.SpringBootTest
 import org.springframework.context.annotation.ComponentScan
 import org.springframework.core.io.ByteArrayResource
 import org.springframework.http.HttpMethod
 import org.springframework.http.HttpStatus
+import org.springframework.http.client.MultipartBodyBuilder
 import org.springframework.test.context.ContextConfiguration
 import org.springframework.test.context.junit4.SpringRunner
 import org.springframework.test.web.reactive.server.WebTestClient
+import org.springframework.test.web.reactive.server.returnResult
 import org.springframework.util.Base64Utils
 import org.springframework.web.reactive.function.BodyInserters
 import java.io.File
-import java.io.IOException
 import java.nio.charset.StandardCharsets.UTF_8
-import java.nio.file.Files
 import java.nio.file.Paths
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
 
 /**
  * BlueprintModelControllerTest Purpose: Integration test at API level
@@ -57,109 +62,142 @@ import java.nio.file.Paths
 
 @RunWith(SpringRunner::class)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
-@ContextConfiguration(classes = [TestApplication::class])
+@ContextConfiguration(classes = [TestApplication::class, ControllerBluePrintCoreConfiguration::class])
 @ComponentScan(basePackages = ["org.onap.ccsdk.cds.controllerblueprints"])
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 @EnableAutoConfiguration
 class BlueprintModelControllerTest {
 
-    companion object {
+    private val log = LoggerFactory.getLogger(BlueprintModelControllerTest::class.java)!!
 
-        private var id: String? = null
-        private var name: String? = null
-        private var version: String? = null
-        private var tag: String? = null
-        private var result: String? = null
+    companion object {
+        private var bp: BlueprintModelSearch? = null
     }
 
-    @Value("\${controllerblueprints.loadBluePrintPaths}")
-    private val loadBluePrintPaths: String? = null
-
     @Autowired
-    private val webTestClient: WebTestClient? = null
+    lateinit var webTestClient: WebTestClient
+
+    private var bluePrintLoadConfiguration: BluePrintPathConfiguration? = null
 
-    @Value("\${controllerblueprints.loadBlueprintsExamplesPath}")
-    private val blueprintArchivePath: String? = null
+    private val blueprintDir = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+    private var zipBlueprintFileName: String? = null
+
+    private var testZipFile: File? = null
 
-    private val filename = "test.zip"
-    private var blueprintFile: File? = null
-    private var zipBlueprintFile: File? = null
 
     @Before
-    @Throws(Exception::class)
     fun setUp() {
-        blueprintFile = File(loadBluePrintPaths+"/baseconfiguration")
-        if (blueprintFile!!.isDirectory) {
-            zipBlueprintFile = File(Paths.get(blueprintArchivePath).resolve(filename).toString())
-            BluePrintArchiveUtils.compress(blueprintFile!!, zipBlueprintFile!!, true)
+        assertNotNull(webTestClient, " Failed to create WebTestClient")
+
+        bluePrintLoadConfiguration = BluePrintPathConfiguration().apply {
+            blueprintArchivePath = "./target/blueprints/archive"
+            blueprintWorkingPath = "./target/blueprints/work"
+            blueprintDeployPath = "./target/blueprints/deploy"
         }
+        zipBlueprintFileName = normalizedPathName(bluePrintLoadConfiguration!!.blueprintArchivePath, "test.zip")
+
+        val archiveDir = normalizedFile(bluePrintLoadConfiguration!!.blueprintArchivePath).reCreateDirs()
+        assertTrue(archiveDir.exists(), "failed to create archiveDir(${archiveDir.absolutePath}")
+
+        val blueprintFile = Paths.get(blueprintDir).toFile().normalize()
+        testZipFile = blueprintFile.compress(zipBlueprintFileName!!)
+        assertNotNull(testZipFile, "test zip is null")
+        assertTrue(testZipFile!!.exists(), "Failed to create blueprint test zip(${testZipFile!!.absolutePath}")
     }
 
     @After
-    @Throws(Exception::class)
     fun tearDown() {
-        zipBlueprintFile!!.delete()
+        deleteDir(bluePrintLoadConfiguration!!.blueprintArchivePath)
+        deleteDir(bluePrintLoadConfiguration!!.blueprintWorkingPath)
     }
 
     @Test
-    @Throws(IOException::class, JSONException::class)
-    fun test1_saveBluePrint() {
-        webTestClient(HttpMethod.POST,
-                BodyInserters.fromMultipartData("file", object : ByteArrayResource(Files.readAllBytes(zipBlueprintFile!!.toPath())) {
-                    override fun getFilename(): String? {
+    fun test01_saveBluePrint() {
+        bp = runBlocking {
+            val body = MultipartBodyBuilder().apply {
+                part("file", object : ByteArrayResource(testZipFile!!.readBytes()) {
+                    override fun getFilename(): String {
                         return "test.zip"
                     }
-                }),
-                "/api/v1/blueprint-model",
-                HttpStatus.OK, true)
+                })
+            }.build()
+
+            val saveBP = webTestClient
+                    .post()
+                    .uri("/api/v1/blueprint-model")
+                    .body(BodyInserters.fromMultipartData(body))
+                    .exchange()
+                    .expectStatus().isOk
+                    .returnResult<BlueprintModelSearch>()
+                    .responseBody
+                    .awaitSingle()
+
+            assertNotNull(saveBP, "failed to get response")
+            assertEquals("baseconfiguration", saveBP.artifactName, "mismatch artifact name")
+            assertEquals("1.0.0", saveBP.artifactVersion, "mismatch artifact version")
+            assertEquals("N", saveBP.published, "mismatch publish")
+            saveBP
+        }
     }
 
     @Test
     @Throws(JSONException::class)
-    fun test2_getBluePrintByNameAndVersion() {
-        webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model/by-name/$name/version/$version", HttpStatus.OK, false)
+    fun test02_getBluePrintByNameAndVersion() {
+        webTestClient(HttpMethod.GET, null,
+                "/api/v1/blueprint-model/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}",
+                HttpStatus.OK, false)
     }
 
 
     @Test
     @Throws(JSONException::class)
-    fun test3_getBlueprintModel() {
-        webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model/$id", HttpStatus.OK, false)
+    fun test03_getBlueprintModel() {
+        webTestClient(HttpMethod.GET, null,
+                "/api/v1/blueprint-model/${bp!!.id}",
+                HttpStatus.OK, false)
     }
 
     @Test
     @Throws(JSONException::class)
-    fun test4_getAllBlueprintModel() {
+    fun test04_getAllBlueprintModel() {
         webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model", HttpStatus.OK, false)
     }
 
     @Test
     @Throws(JSONException::class)
-    fun test5_downloadBluePrint() {
-        webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model/download/$id", HttpStatus.OK, false)
+    fun test05_downloadBluePrint() {
+        webTestClient(HttpMethod.GET, null,
+                "/api/v1/blueprint-model/download/${bp!!.id}",
+                HttpStatus.OK, false)
+    }
+
+    @Test
+    fun test06_enrichBlueprintModel() {
     }
 
     @Test
-    fun test6_publishBlueprintModel() {
+    fun test07_publishBlueprintModel() {
     }
 
     @Test
     @Throws(JSONException::class)
-    fun test7_searchBlueprintModels() {
-        webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model/search/$name", HttpStatus.OK, false)
+    fun test08_searchBlueprintModels() {
+        webTestClient(HttpMethod.GET, null,
+                "/api/v1/blueprint-model/search/${bp!!.artifactName}",
+                HttpStatus.OK, false)
     }
 
     @Test
     @Throws(JSONException::class)
-    fun test8_downloadBlueprintByNameAndVersion() {
-        webTestClient(HttpMethod.GET, null, "/api/v1/blueprint-model/download/by-name/$name/version/$version", HttpStatus.OK, false)
+    fun test09_downloadBlueprintByNameAndVersion() {
+        webTestClient(HttpMethod.GET, null,
+                "/api/v1/blueprint-model/download/by-name/${bp!!.artifactName}/version/${bp!!.artifactVersion}",
+                HttpStatus.OK, false)
     }
 
     @Test
-    fun test9_deleteBluePrint() {
-        //TODO: Use webTestClient function
-        //webTestClient(HttpMethod.DELETE, null, "/api/v1/blueprint-model/" + id, HttpStatus.OK, false);
-        webTestClient!!.delete().uri("/api/v1/blueprint-model/$id")
+    fun test10_deleteBluePrint() {
+        webTestClient.delete().uri("/api/v1/blueprint-model/${bp!!.id}")
                 .header("Authorization", "Basic " + Base64Utils
                         .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)))
                 .exchange()
@@ -167,27 +205,20 @@ class BlueprintModelControllerTest {
     }
 
     @Throws(JSONException::class)
-    private fun webTestClient(requestMethod: HttpMethod, body: BodyInserters.MultipartInserter?, uri: String, expectedResponceStatus: HttpStatus, setParam: Boolean) {
+    private fun webTestClient(requestMethod: HttpMethod, body: BodyInserters.MultipartInserter?, uri: String,
+                              expectedResponceStatus: HttpStatus, setParam: Boolean) {
 
-        result = String(webTestClient!!.method(requestMethod).uri(uri)
+        log.info("Requesting($uri): Method(${requestMethod.name})")
+
+        webTestClient.method(requestMethod).uri(uri)
                 .header("Authorization", "Basic " + Base64Utils
                         .encodeToString(("ccsdkapps" + ":" + "ccsdkapps").toByteArray(UTF_8)))
                 .body(body)
                 .exchange()
                 .expectStatus().isEqualTo(expectedResponceStatus)
                 .expectBody()
-                .returnResult().responseBody!!)
-
-        if (setParam) {
-            val jsonResponse = JSONObject(result)
-            val blueprintModelSearchJSON = jsonResponse.getJSONObject("blueprintModel")
-            val gson = Gson()
-            val blueprintModelSearch = gson.fromJson(blueprintModelSearchJSON.toString(), BlueprintModelSearch::class.java)
-            id = blueprintModelSearch.id
-            name = blueprintModelSearch.artifactName
-            version = blueprintModelSearch.artifactVersion
-            tag = blueprintModelSearch.tags
-        }
+                .returnResult().responseBody!!
+
     }
 
 }
\ No newline at end of file
index 610c9d0..4af8851 100644 (file)
@@ -16,7 +16,6 @@
 
 package org.onap.ccsdk.cds.controllerblueprints.service.controller
 
-import com.att.eelf.configuration.EELFManager
 import org.junit.Assert
 import org.junit.FixMethodOrder
 import org.junit.Test
@@ -26,6 +25,7 @@ import org.onap.ccsdk.cds.controllerblueprints.TestApplication
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.cds.controllerblueprints.service.domain.ModelType
+import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
 import org.springframework.test.annotation.Commit
@@ -38,7 +38,7 @@ import org.springframework.test.context.junit4.SpringRunner
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 class ModelTypeControllerTest {
 
-    private val log = EELFManager.getInstance().getLogger(ModelTypeControllerTest::class.java)!!
+    private val log = LoggerFactory.getLogger(ModelTypeControllerTest::class.java)!!
 
     @Autowired
     internal var modelTypeController: ModelTypeController? = null
index 011bad3..19430ad 100755 (executable)
@@ -24,7 +24,7 @@ resourceSourceMappings=processor-db=source-processor-db,input=source-input,defau
 # Controller Blueprints Core Configuration
 controllerblueprints.blueprintDeployPath=./target/blueprints/deploy
 controllerblueprints.blueprintArchivePath=./target/blueprints/archive
-controllerblueprints.blueprintEnrichmentPath=./target/blueprints/enrichment
+controllerblueprints.blueprintWorkingPath=./target/blueprints/work
 # Controller Blueprint Load Configurations
 controllerblueprints.loadInitialData=false
 controllerblueprints.loadBluePrint=false
index 3fc5084..50cfae1 100644 (file)
             </dependency>
 
             <dependency>
-                <groupId>com.att.eelf</groupId>
-                <artifactId>eelf-core</artifactId>
-                <version>${eelf.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.onap.logging-analytics</groupId>
-                <artifactId>logging-slf4j</artifactId>
-                <version>${onap.logger.slf4j}</version>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-starter-logging</artifactId>
+                <version>${spring.boot.version}</version>
             </dependency>
 
             <!--Swagger Dependencies -->
                 <groupId>io.springfox</groupId>
                 <artifactId>springfox-swagger2</artifactId>
                 <version>${springfox.swagger2.version}</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-api</artifactId>
+                    </exclusion>
+                </exclusions>
             </dependency>
             <dependency>
                 <groupId>io.springfox</groupId>
     </dependencyManagement>
 
     <dependencies>
-        <dependency>
-            <groupId>com.att.eelf</groupId>
-            <artifactId>eelf-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.logging-analytics</groupId>
-            <artifactId>logging-slf4j</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         <dependency>
             <groupId>com.jayway.jsonpath</groupId>
             <artifactId>json-path</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
         <dependency>
             <groupId>io.springfox</groupId>
             <artifactId>springfox-swagger2</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-api</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>io.springfox</groupId>
diff --git a/pom.xml b/pom.xml
index 80359d1..cfc2e65 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
     <parent>
         <groupId>org.onap.ccsdk.parent</groupId>
         <artifactId>odlparent-lite</artifactId>
-        <version>1.2.1</version>
+        <version>1.2.2-SNAPSHOT</version>
         <relativePath/>
     </parent>