summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/services
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-06-29 19:30:00 +0300
committerMichael Lando <ml636r@att.com>2017-06-29 21:32:19 +0300
commited7e1c3dfe332abc67ed943717db2ee94406f95e (patch)
treee0f2f39596656456272900f59aadc3dff6c6e828 /catalog-ui/src/app/ng2/services
parent68ccc45de18f41cddb79de33a245bceb3b063ffb (diff)
[SDC] rebase code
Change-Id: I456ec65a233d277e6bae35e140f2e3da5765bae6 Signed-off-by: Tal Gitelman <tg851x@intl.att.com> Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/src/app/ng2/services')
-rw-r--r--catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts4
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/component.service.ts6
-rw-r--r--catalog-ui/src/app/ng2/services/component-services/service.service.ts4
-rw-r--r--catalog-ui/src/app/ng2/services/http.interceptor.service.ts57
-rw-r--r--catalog-ui/src/app/ng2/services/posts.service.ts54
-rw-r--r--catalog-ui/src/app/ng2/services/responses/component-generic-response.ts4
6 files changed, 66 insertions, 63 deletions
diff --git a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
index 85709894ff..fd7e7b62ce 100644
--- a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts
@@ -1,18 +1,18 @@
import {Injectable} from '@angular/core';
import {Response, RequestOptions, Headers} from '@angular/http';
import { Observable } from 'rxjs/Observable';
-import {HttpService} from "../http.service";
import {sdc2Config} from "../../../../main";
import {PropertyBEModel} from "app/models";
import {CommonUtils} from "app/utils";
import {Component, ComponentInstance, InputModel} from "app/models";
+import {InterceptorService} from "ng2-interceptors/index";
@Injectable()
export class ComponentInstanceServiceNg2 {
protected baseUrl;
- constructor(private http: HttpService) {
+ constructor(private http: InterceptorService) {
this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root;
}
diff --git a/catalog-ui/src/app/ng2/services/component-services/component.service.ts b/catalog-ui/src/app/ng2/services/component-services/component.service.ts
index 3fa9fde40c..976d18eac3 100644
--- a/catalog-ui/src/app/ng2/services/component-services/component.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/component.service.ts
@@ -1,17 +1,17 @@
-import {Injectable, Query} from '@angular/core';
+import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import {Response, URLSearchParams} from '@angular/http';
import { Component, PropertyBEModel, InstancePropertiesAPIMap, FilterPropertiesAssignmentData} from "app/models";
import {downgradeInjectable} from '@angular/upgrade/static';
-import {HttpService} from "../http.service";
import {COMPONENT_FIELDS} from "app/utils";
import {ComponentGenericResponse} from "../responses/component-generic-response";
import {sdc2Config} from "../../../../main";
import {InstanceBePropertiesMap} from "../../../models/properties-inputs/property-fe-map";
import {API_QUERY_PARAMS} from "app/utils";
import {ComponentType, ServerTypeUrl} from "../../../utils/constants";
+import {InterceptorService} from "ng2-interceptors/index";
declare var angular:angular.IAngularStatic;
@@ -20,7 +20,7 @@ export class ComponentServiceNg2 {
protected baseUrl;
- constructor(private http:HttpService) {
+ constructor(private http:InterceptorService) {
this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root;
}
diff --git a/catalog-ui/src/app/ng2/services/component-services/service.service.ts b/catalog-ui/src/app/ng2/services/component-services/service.service.ts
index d2f7078599..147fe9385c 100644
--- a/catalog-ui/src/app/ng2/services/component-services/service.service.ts
+++ b/catalog-ui/src/app/ng2/services/component-services/service.service.ts
@@ -6,7 +6,7 @@ import { Response } from '@angular/http';
import {Service} from "app/models";
import { downgradeInjectable } from '@angular/upgrade/static';
import {sdc2Config} from "../../../../main";
-import {HttpService} from "../http.service";
+import {InterceptorService} from "ng2-interceptors/index";
@Injectable()
@@ -14,7 +14,7 @@ export class ServiceServiceNg2 {
protected baseUrl = "";
- constructor(private http: HttpService) {
+ constructor(private http: InterceptorService) {
this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root;
}
diff --git a/catalog-ui/src/app/ng2/services/http.interceptor.service.ts b/catalog-ui/src/app/ng2/services/http.interceptor.service.ts
new file mode 100644
index 0000000000..aebbdbf7af
--- /dev/null
+++ b/catalog-ui/src/app/ng2/services/http.interceptor.service.ts
@@ -0,0 +1,57 @@
+import 'rxjs/add/operator/map';
+import 'rxjs/add/operator/toPromise';
+import 'rxjs/Rx';
+import { sdc2Config } from './../../../main';
+import { Interceptor, InterceptedRequest, InterceptedResponse } from 'ng2-interceptors';
+import {SharingService} from "../../services/sharing-service";
+import {ReflectiveInjector} from '@angular/core';
+import {Cookie2Service} from "./cookie.service";
+import {UUID} from "angular2-uuid";
+import {Dictionary} from "../../utils/dictionary/dictionary";
+
+export class HttpInterceptor implements Interceptor {
+
+ private cookieService: Cookie2Service;
+ private sharingService:SharingService;
+ constructor() {
+ let injector = ReflectiveInjector.resolveAndCreate([Cookie2Service,SharingService]);
+ this.cookieService = injector.get(Cookie2Service);
+ this.sharingService = injector.get(SharingService);
+ }
+
+ public interceptBefore(request: InterceptedRequest): InterceptedRequest {
+
+ /**
+ * For every request to the server, that the service id, or resource id is sent in the URL, need to pass UUID in the header.
+ * Check if the unique id exists in uuidMap, and if so get the UUID and add it to the header.
+ */
+
+ request.options.headers.append(this.cookieService.getUserIdSuffix(), this.cookieService.getUserId());
+ var uuidValue = this.getUuidValue(request.url);
+ if(uuidValue!= ''){
+ request.options.headers.set('X-ECOMP-ServiceID',uuidValue);
+ }
+ request.options.headers.set('X-ECOMP-RequestID', UUID.UUID());
+ return request;
+
+ }
+
+ public interceptAfter(response: InterceptedResponse): InterceptedResponse {
+
+ return response;
+
+ }
+
+ private getUuidValue = (url: string) :string => {
+ let map:Dictionary<string, string> = this.sharingService.getUuidMap();
+ if (map && url.indexOf(sdc2Config.api.root) > 0) {
+ map.forEach((key:string) => {
+ if (url.indexOf(key) !== -1) {
+ return this.sharingService.getUuidValue(key);
+ }
+ });
+ }
+ return '';
+ }
+
+}
diff --git a/catalog-ui/src/app/ng2/services/posts.service.ts b/catalog-ui/src/app/ng2/services/posts.service.ts
deleted file mode 100644
index dbfd44f219..0000000000
--- a/catalog-ui/src/app/ng2/services/posts.service.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { Injectable } from '@angular/core';
-import { Observable } from 'rxjs/Observable';
-import 'rxjs/add/operator/map';
-import 'rxjs/add/operator/toPromise';
-import 'rxjs/Rx';
-import {Response, Headers, RequestOptions, Http} from '@angular/http';
-import { COMPONENT_INSTANCE_RESPONSE,COMPONENT_INPUT_RESPONSE,COMPONENT_PROPERTIES_RESPONSE } from './mocks/properties.mock';
-import { HttpService } from './http.service';
-import { sdc2Config } from './../../../main';
-import {IAppConfigurtaion} from "../../models/app-config";
-
-@Injectable()
-export class PostsService {
-
- private base;
-
- constructor(private http: HttpService) {
- this.base = sdc2Config.api.root;
- }
-
- getAppVersion(): Observable<JSON> {
- return this.http
- .get(this.base + sdc2Config.api.GET_SDC_Version)
- .map((res: Response) => res.json());
- }
-
- // getProperties(id:string): Observable<any> {
- // return this.http
- // .get(this.base + sdc2Config.api.GET_SDC_Version)
- // .map((res: Response) => res.json());
- // }
-
- getProperties(): Observable<any> {
- return Observable.create(observer => {
- observer.next(COMPONENT_PROPERTIES_RESPONSE);
- observer.complete();
- });
- }
-
- getInstance(): Observable<any> {
- return Observable.create(observer => {
- observer.next(COMPONENT_INSTANCE_RESPONSE);
- observer.complete();
- });
- }
-
- getInputs(): Observable<any> {
- return Observable.create(observer => {
- observer.next(COMPONENT_INPUT_RESPONSE);
- observer.complete();
- });
- }
-
-}
diff --git a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts
index 7dcd95d712..38e23a58f3 100644
--- a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts
+++ b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts
@@ -3,7 +3,7 @@
*/
import { ArtifactGroupModel, PropertyModel, PropertiesGroup, AttributeModel, AttributesGroup, ComponentInstance,
- InputModel, Module, ComponentMetadata, RelationshipModel, RequirementsGroup, CapabilitiesGroup,InputFEModel} from "app/models";
+ InputBEModel, Module, ComponentMetadata, RelationshipModel, RequirementsGroup, CapabilitiesGroup,InputFEModel} from "app/models";
import {CommonUtils} from "app/utils";
import {Serializable} from "../utils/serializable";
import {PropertyBEModel} from "../../../models/properties-inputs/property-be-model";
@@ -18,7 +18,7 @@ export class ComponentGenericResponse implements Serializable<ComponentGenericR
public componentInstancesAttributes:AttributesGroup;
public componentInstancesRelations:Array<RelationshipModel>;
public componentInstances:Array<ComponentInstance>;
- public inputs:Array<PropertyBEModel>;
+ public inputs:Array<InputBEModel>;
public capabilities:CapabilitiesGroup;
public requirements:RequirementsGroup;
public properties:Array<PropertyModel>;