Bug 1383 Error when consulting NS instance's topology

 * SOL006 Descriptor topology changes

Change-Id: I79afb00dfb54ce2c9dc02c0c4b7bbe435b07a915
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
diff --git a/src/app/utilities/clone-package/ClonePackageComponent.ts b/src/app/utilities/clone-package/ClonePackageComponent.ts
index 94e0920..125a726 100644
--- a/src/app/utilities/clone-package/ClonePackageComponent.ts
+++ b/src/app/utilities/clone-package/ClonePackageComponent.ts
@@ -26,9 +26,10 @@
 import { APIURLHEADER, ERRORDATA, GETAPIURLHEADER, MODALCLOSERESPONSEDATA, URLPARAMS } from 'CommonModel';
 import { environment } from 'environment';
 import * as jsyaml from 'js-yaml';
-import { NSDDetails } from 'NSDModel';
+import { NSDATACREATION, NSDDetails } from 'NSDModel';
 import { RestService } from 'RestService';
 import { SharedService } from 'SharedService';
+import { VNFDATA } from 'VNFDModel';
 
 /**
  * Creating component
@@ -99,9 +100,9 @@
       apiUrl = environment.VNFPACKAGES_URL + '/' + this.params.id + '/vnfd';
     this.isLoadingResults = true;
     this.restService.getResource(apiUrl, httpOptions)
-      .subscribe((nsData: NSDDetails[]) => {
+      .subscribe((nsData: NSDDetails[]): void => {
         this.modifyContent(nsData);
-      }, (error: ERRORDATA) => {
+      }, (error: ERRORDATA): void => {
         this.isLoadingResults = false;
         error.error = typeof error.error === 'string' ? jsyaml.load(error.error) : error.error;
         this.restService.handleError(error, 'get');
@@ -125,30 +126,28 @@
    * Get and modify package information based on type
    */
   private modifyContent(packageInfo: NSDDetails[]): void {
-    const packageContent: string = jsyaml.load(packageInfo.toString());
     if (this.params.page === 'nsd') {
-      this.packageName = 'clone_' + packageContent['nsd:nsd-catalog'].nsd[0].name;
+      const nsPackageContent: NSDATACREATION = jsyaml.load(packageInfo.toString());
+      this.packageName = 'clone_' + nsPackageContent.nsd.nsd[0].name;
       this.endPoint = environment.NSDESCRIPTORSCONTENT_URL;
-      packageContent['nsd:nsd-catalog'].nsd.forEach((nsd: NSDDetails) => {
+      nsPackageContent.nsd.nsd.forEach((nsd: NSDDetails): void => {
         nsd.id = 'clone_' + nsd.id;
         nsd.name = 'clone_' + nsd.name;
-        nsd['short-name'] = 'clone_' + nsd['short-name'];
       });
+      this.clonePackage(nsPackageContent);
     } else {
-      this.packageName = 'clone_' + packageContent['vnfd:vnfd-catalog'].vnfd[0].name;
+      const vnfPackageContent: VNFDATA = jsyaml.load(packageInfo.toString());
+      this.packageName = 'clone_' + vnfPackageContent.vnfd['product-name'];
       this.endPoint = environment.VNFPACKAGESCONTENT_URL;
-      packageContent['vnfd:vnfd-catalog'].vnfd.forEach((vnfd: NSDDetails) => {
-        vnfd.id = 'clone_' + vnfd.id;
-        vnfd.name = 'clone_' + vnfd.name;
-        vnfd['short-name'] = 'clone_' + vnfd['short-name'];
-      });
+      vnfPackageContent.vnfd.id = 'clone_' + vnfPackageContent.vnfd.id;
+      vnfPackageContent.vnfd['product-name'] = 'clone_' + vnfPackageContent.vnfd['product-name'];
+      this.clonePackage(vnfPackageContent);
     }
-    this.clonePackage(packageContent);
   }
   /**
    * Create clone package and upload as TAR.GZ file
    */
-  private clonePackage(packageContent: string): void {
+  private clonePackage(packageContent: NSDATACREATION | VNFDATA): void {
     const descriptorInfo: string = jsyaml.dump(packageContent);
     const apiHeader: HttpHeaders = new HttpHeaders({
       'Content-Type': 'application/gzip',
@@ -164,11 +163,12 @@
           url: this.endPoint,
           httpOptions: { headers: apiHeader }
         };
-        this.restService.postResource(apiURLHeader, content).subscribe((result: { id: string }) => {
+        // tslint:disable-next-line: completed-docs
+        this.restService.postResource(apiURLHeader, content).subscribe((result: { id: string }): void => {
           this.activeModal.close(modalData);
           this.isLoadingResults = false;
           this.notifierService.notify('success', this.translateService.instant('CLONESUCCESSFULLY'));
-        }, (error: ERRORDATA) => {
+        }, (error: ERRORDATA): void => {
           this.isLoadingResults = false;
           this.restService.handleError(error, 'post');
         });
diff --git a/src/app/utilities/compose-packages/ComposePackages.ts b/src/app/utilities/compose-packages/ComposePackages.ts
index 9567b43..be70655 100644
--- a/src/app/utilities/compose-packages/ComposePackages.ts
+++ b/src/app/utilities/compose-packages/ComposePackages.ts
@@ -113,6 +113,9 @@
     this.sharedService = this.injector.get(SharedService);
   }
 
+  /** convenience getter for easy access to form fields */
+  get f(): FormGroup['controls'] { return this.packagesForm.controls; }
+
   /**
    * Lifecyle Hooks the trigger before component is instantiate
    */
@@ -132,9 +135,6 @@
     });
   }
 
-  /** convenience getter for easy access to form fields */
-  get f(): FormGroup['controls'] { return this.packagesForm.controls; }
-
   /** Create packages @public */
   public createPackages(): void {
     this.submitted = true;
@@ -166,11 +166,12 @@
       url: this.endPoint,
       httpOptions: { headers: this.headers }
     };
-    this.restService.postResource(apiURLHeader, packageContent).subscribe((result: { id: string }) => {
+    // tslint:disable-next-line: completed-docs
+    this.restService.postResource(apiURLHeader, packageContent).subscribe((result: { id: string }): void => {
       this.isLoadingResults = false;
       this.activeModal.close();
       this.composeNSPackages(result.id);
-    }, (error: ERRORDATA) => {
+    }, (error: ERRORDATA): void => {
       this.isLoadingResults = false;
       this.restService.handleError(error, 'post');
     });
@@ -187,48 +188,54 @@
       this.notifierService.notify('success', this.packagesForm.value.name + ' ' +
         this.translateService.instant('PAGE.VNFPACKAGE.CREATEDSUCCESSFULLY'));
     }
-    this.router.navigate([packageUrl, id]).catch(() => {
+    this.router.navigate([packageUrl, id]).catch((): void => {
       // Catch Navigation Error
     });
   }
   /** Deafult template for NS and VNF Packages @private */
   private packageYaml(descriptorType: string): string {
     let packageYaml: {} = {};
+    const composerName: string = 'NGUI Composer';
+    const composerDefaultVersion: string = '1.0';
     if (descriptorType === 'ns-package') {
       packageYaml = {
-        'nsd:nsd-catalog': {
+        nsd: {
           nsd: [
             {
-              'short-name': this.packagesForm.value.name,
-              vendor: 'OSM Composer',
-              description: this.packagesForm.value.name + ' descriptor',
-              vld: [],
-              'constituent-vnfd': [],
-              version: '1.0',
               id: this.packagesForm.value.name,
-              name: this.packagesForm.value.name
+              name: this.packagesForm.value.name,
+              version: composerDefaultVersion,
+              description: this.packagesForm.value.name + ' descriptor',
+              designer: composerName,
+              df: [
+                {
+                  id: 'default-df',
+                  'vnf-profile': []
+                }
+              ]
             }
           ]
         }
       };
     } else {
       packageYaml = {
-        'vnfd:vnfd-catalog': {
-          vnfd: [
+        vnfd: {
+          id: this.packagesForm.value.name,
+          'product-name': this.packagesForm.value.name,
+          version: composerDefaultVersion,
+          description: this.packagesForm.value.name + ' descriptor',
+          provider: composerName,
+          df: [
             {
-              'short-name': this.packagesForm.value.name,
-              vdu: [],
-              description: '',
-              'mgmt-interface': {
-                cp: ''
-              },
-              id: this.packagesForm.value.name,
-              version: '1.0',
-              'internal-vld': [],
-              'connection-point': [],
-              name: this.packagesForm.value.name
+              id: 'default-df',
+              'instantiation-level': [],
+              'vdu-profile': []
             }
-          ]
+          ],
+          'ext-cpd': [],
+          vdu: [],
+          'sw-image-desc': [],
+          'virtual-storage-desc': []
         }
       };
     }
diff --git a/src/app/utilities/confirmation-topology/ConfirmationTopologyComponent.html b/src/app/utilities/confirmation-topology/ConfirmationTopologyComponent.html
index 03f5564..92a2726 100644
--- a/src/app/utilities/confirmation-topology/ConfirmationTopologyComponent.html
+++ b/src/app/utilities/confirmation-topology/ConfirmationTopologyComponent.html
@@ -29,8 +29,8 @@
     <div class="modal-body">
       <div *ngIf="topologyType === 'Add'">
         <p [innerHTML]="topologyname"></p>
-        <ng-select placeholder="{{'SELECT' | translate}}" formControlName="cpName" [items]="cpDetails" bindLabel="name"
-          bindValue="name" [(ngModel)]="connectionPointInput"
+        <ng-select placeholder="{{'SELECT' | translate}}" formControlName="cpName" [items]="cpDetails" bindLabel="id"
+          bindValue="id" [(ngModel)]="connectionPointInput"
           [ngClass]="{ 'is-invalid': submitted && f.cpName.errors }"></ng-select>
       </div>
     </div>
@@ -51,7 +51,7 @@
     </button>
   </div>
   <div class="modal-body">
-    <span *ngIf="topologyType === 'Delete'">{{'DELETECONFIRMPOPUPMESSAGE' | translate}} {{ topologyname }} ?</span>
+    <span *ngIf="topologyType === 'Delete'">{{'DELETECONFIRMPOPUPMESSAGE' | translate}} <b>{{ topologyname }}</b> ?</span>
     <ul *ngIf="topologyType === 'Info'">
       <li>
         <p><b>{{'PAGE.TOPOLOGY.HELPINFO.CREATEEDGE' | translate}}</b>:
diff --git a/src/app/utilities/delete/DeleteComponent.ts b/src/app/utilities/delete/DeleteComponent.ts
index 014b66a..b403e9b 100644
--- a/src/app/utilities/delete/DeleteComponent.ts
+++ b/src/app/utilities/delete/DeleteComponent.ts
@@ -115,8 +115,6 @@
     this.title = '';
     if (data.name !== undefined) {
       this.title = data.name;
-    } else if (data.shortName !== undefined) {
-      this.title = data.shortName;
     } else if (data.projectName !== undefined) {
       this.title = data.projectName;
       this.id = this.title;
@@ -124,6 +122,8 @@
       this.title = data.userName;
     } else if (data.username !== undefined) {
       this.title = data.username;
+    } else if (data.productName !== undefined) {
+      this.title = data.productName;
     }
   }
   /** Generate Delete url from data @public */
diff --git a/src/app/utilities/ns-packages-action/NsPackagesActionComponent.ts b/src/app/utilities/ns-packages-action/NsPackagesActionComponent.ts
index 6e7fbfb..18f3e5a 100644
--- a/src/app/utilities/ns-packages-action/NsPackagesActionComponent.ts
+++ b/src/app/utilities/ns-packages-action/NsPackagesActionComponent.ts
@@ -109,7 +109,7 @@
       'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0'
     });
     this.nsdID = this.value.identifier;
-    this.nsdName = this.value.shortName;
+    this.nsdName = this.value.name;
   }
 
   /** Instantiate NS using modalservice @public */
diff --git a/src/app/utilities/vnf-packages-action/VNFPackagesActionComponent.ts b/src/app/utilities/vnf-packages-action/VNFPackagesActionComponent.ts
index f9d1955..cd0d2dc 100644
--- a/src/app/utilities/vnf-packages-action/VNFPackagesActionComponent.ts
+++ b/src/app/utilities/vnf-packages-action/VNFPackagesActionComponent.ts
@@ -108,7 +108,7 @@
       'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0'
     });
     this.vnfID = this.value.identifier;
-    this.vnfName = this.value.shortName;
+    this.vnfName = this.value.productName;
   }
 
   /** Delete VNF packages @public */