diff --git a/demo-shell-ng2/app/app.component.ts b/demo-shell-ng2/app/app.component.ts index c2f07c5b4e..7606b158e4 100644 --- a/demo-shell-ng2/app/app.component.ts +++ b/demo-shell-ng2/app/app.component.ts @@ -66,7 +66,8 @@ export class AppComponent { public router: Router, translate: AlfrescoTranslationService, alfrescoSettingsService: AlfrescoSettingsService) { - alfrescoSettingsService.host = 'http://localhost:8080'; + alfrescoSettingsService.ecmHost = 'http://localhost:8080'; + alfrescoSettingsService.bpmHost = 'http://localhost:9999'; this.translate = translate; this.translate.addTranslationFolder(); diff --git a/ng2-components/ng2-activiti-processlist/demo/src/main.ts b/ng2-components/ng2-activiti-processlist/demo/src/main.ts index bb7c305d6c..d3487dd38a 100644 --- a/ng2-components/ng2-activiti-processlist/demo/src/main.ts +++ b/ng2-components/ng2-activiti-processlist/demo/src/main.ts @@ -36,7 +36,7 @@ import { HTTP_PROVIDERS, BrowserXhr } from '@angular/http'; class MyDemoApp implements OnInit { authenticated: boolean; - host: string = 'http://127.0.0.1:9999'; + ecmHost: string = 'http://127.0.0.1:9999'; token: string; constructor( @@ -45,7 +45,7 @@ class MyDemoApp implements OnInit { ) { console.log('constructor'); - alfrescoSettingsService.host = this.host; + alfrescoSettingsService.ecmHost = this.ecmHost; if (this.authService.getTicket()) { this.token = this.authService.getTicket(); } @@ -60,7 +60,7 @@ class MyDemoApp implements OnInit { } public updateHost(): void { - this.alfrescoSettingsService.host = this.host; + this.alfrescoSettingsService.ecmHost = this.ecmHost; this.login(); } diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts index 366c4ef918..cada580c3d 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts @@ -30,6 +30,10 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem super(alfrescoSettingsService, http); } + getHost(): string { + return this.alfrescoSettingsService.bpmHost; + } + /** * Perform a login on behalf of the user and store the ticket returned * @@ -68,7 +72,7 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem } private apiActivitiLogin(username: string, password: string) { - let url = 'http://localhost:9999/activiti-app/app/authentication'; + let url = this.alfrescoSettingsService.getBPMApiBaseUrl + '/authentication'; let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' }); @@ -84,10 +88,14 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem } private apiActivitiLogout() { - let url = 'http://localhost:9999/activiti-app/app/logout'; + let url = this.alfrescoSettingsService.getBPMApiBaseUrl + '/logout'; return this.http.get(url).toPromise(); } + /** + * The method return the ticket stored in the localStorage + * @returns ticket + */ public getTicket(): string { return localStorage.getItem(`ticket-${this.TYPE}`); } diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBase.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBase.service.ts index 988cf46a6a..ddd4e3aaa2 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBase.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBase.service.ts @@ -25,8 +25,8 @@ export class AlfrescoAuthenticationBase { alfrescoApi: any; - private _authUrl: string = '/alfresco/api/-default-/public/authentication/versions/1'; private alfrescoSetting: AlfrescoSettingsService; + /** * Constructor * @param alfrescoSettingsService @@ -36,15 +36,11 @@ export class AlfrescoAuthenticationBase { this.alfrescoSetting = alfrescoSettingsService; } - getBaseUrl(): string { - return this.alfrescoSetting.host + this._authUrl; - } - /** * The method save the toke in the localStorage * @param ticket */ - public saveTicket(provider:string, ticket: string): void { + public saveTicket(provider: string, ticket: string): void { if (ticket) { localStorage.setItem(`ticket-${provider}`, ticket); } @@ -53,7 +49,7 @@ export class AlfrescoAuthenticationBase { /** * Remove the login ticket from localStorage */ - public removeTicket(provider:string): void { + public removeTicket(provider: string): void { localStorage.removeItem(`ticket-${provider}`); } diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationECM.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationECM.service.ts index 1a8266eee4..ab83f212af 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationECM.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationECM.service.ts @@ -40,18 +40,18 @@ export class AlfrescoAuthenticationECM extends AlfrescoAuthenticationBase implem if (!this.isLoggedIn) { this.alfrescoApi = new AlfrescoApi({ - host: this.getBaseUrl() + host: this.getHost() }); } else { this.alfrescoApi = new AlfrescoApi({ ticket: this.getTicket(), - host: this.getBaseUrl() + host: this.getHost() }); } } - getBaseUrl(): string { - return this.alfrescoSettingsService.host; + getHost(): string { + return this.alfrescoSettingsService.ecmHost; } /** @@ -87,7 +87,7 @@ export class AlfrescoAuthenticationECM extends AlfrescoAuthenticationBase implem this.alfrescoApi = new AlfrescoApi({ username: username, password: password, - host: this.getBaseUrl() + host: this.getHost() }); return this.alfrescoApi.login(); } @@ -111,7 +111,7 @@ export class AlfrescoAuthenticationECM extends AlfrescoAuthenticationBase implem * * @returns {*|Observable|Observable|Promise} */ - private callApiLogout():Promise { + private callApiLogout(): Promise { return this.alfrescoApi.logout(); } diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoContentService.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoContentService.spec.ts index 0537dc364c..ddb31efa85 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoContentService.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoContentService.spec.ts @@ -49,7 +49,7 @@ describe('AlfrescoContentService', () => { id: nodeId } })).toBe( - AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + DEFAULT_CONTEXT_PATH + + AlfrescoSettingsService.DEFAULT_ECM_ADDRESS + DEFAULT_CONTEXT_PATH + DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/content' + '?attachment=false&alf_ticket=' + authService.getTicket() ); @@ -61,7 +61,7 @@ describe('AlfrescoContentService', () => { id: nodeId } })).toBe( - AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + DEFAULT_CONTEXT_PATH + + AlfrescoSettingsService.DEFAULT_ECM_ADDRESS + DEFAULT_CONTEXT_PATH + DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/renditions/doclib/content' + '?attachment=false&alf_ticket=' + authService.getTicket() ); diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts index a970cb583b..ad674857e6 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.service.ts @@ -20,26 +20,48 @@ import { Injectable } from '@angular/core'; @Injectable() export class AlfrescoSettingsService { - static DEFAULT_HOST_ADDRESS: string = 'http://127.0.0.1:8080'; - static DEFAULT_CONTEXT_PATH: string = '/alfresco'; - static DEFAULT_BASE_API_PATH: string = '/api/-default-/public/alfresco/versions/1'; + static DEFAULT_ECM_ADDRESS: string = 'http://127.0.0.1:8080'; + static DEFAULT_BPM_ADDRESS: string = 'http://127.0.0.1:8080'; - private _host: string = AlfrescoSettingsService.DEFAULT_HOST_ADDRESS; - private _contextPath = AlfrescoSettingsService.DEFAULT_CONTEXT_PATH; - private _apiBasePath: string = AlfrescoSettingsService.DEFAULT_BASE_API_PATH; + static DEFAULT_ECM_CONTEXT_PATH: string = '/alfresco'; + static DEFAULT_BPM_CONTEXT_PATH: string = '/activiti-app'; + + static DEFAULT_ECM_BASE_API_PATH: string = '/api/-default-/public/alfresco/versions/1'; + static DEFAULT_BPM_BASE_API_PATH: string = '/app'; + + private _ecmHost: string = AlfrescoSettingsService.DEFAULT_ECM_ADDRESS; + private _bpmHost: string = AlfrescoSettingsService.DEFAULT_BPM_ADDRESS; + + private _ecmContextPath = AlfrescoSettingsService.DEFAULT_ECM_CONTEXT_PATH; + private _bpmContextPath = AlfrescoSettingsService.DEFAULT_BPM_CONTEXT_PATH; + + private _apiECMBasePath: string = AlfrescoSettingsService.DEFAULT_ECM_BASE_API_PATH; + private _apiBPMBasePath: string = AlfrescoSettingsService.DEFAULT_BPM_BASE_API_PATH; private providers: string[] = ['ECM', 'BPM']; - public get host(): string { - return this._host; + public get ecmHost(): string { + return this._ecmHost; } - public set host(value: string) { - this._host = value; + public set ecmHost(value: string) { + this._ecmHost = value; } - getApiBaseUrl(): string { - return this._host + this._contextPath + this._apiBasePath; + public get bpmHost(): string { + return this._bpmHost; + } + + public set bpmHost(value: string) { + this._bpmHost = value; + } + + getBPMApiBaseUrl(): string { + return this._bpmHost + this._bpmContextPath + this._apiBPMBasePath; + } + + getECMApiBaseUrl(): string { + return this._ecmHost + this._ecmContextPath + this._apiECMBasePath; } getProviders(): string [] { diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.spec.ts index b3f61dde03..b1eaa8daca 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoSettingsService.spec.ts @@ -26,15 +26,27 @@ describe('AlfrescoSettingsService', () => { service = new AlfrescoSettingsService(); }); - it('should have default host', () => { - expect(service.host).toBe(AlfrescoSettingsService.DEFAULT_HOST_ADDRESS); + it('should have default ECM host', () => { + expect(service.ecmHost).toBe(AlfrescoSettingsService.DEFAULT_ECM_ADDRESS); }); - it('should change host', () => { + it('should change host ECM', () => { // this test ensures 'host' getter/setter working properly let address = 'http://192.168.0.1'; - service.host = address; - expect(service.host).toBe(address); + service.ecmHost = address; + expect(service.ecmHost).toBe(address); }); + it('should have default BPM host', () => { + expect(service.ecmHost).toBe(AlfrescoSettingsService.DEFAULT_BPM_ADDRESS); + }); + + it('should change host BPM', () => { + // this test ensures 'host' getter/setter working properly + let address = 'http://192.168.0.1'; + service.bpmHost = address; + expect(service.bpmHost).toBe(address); + }); + + }); diff --git a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts index 1e19129db4..d3893bdaaf 100644 --- a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts @@ -143,8 +143,8 @@ class DocumentListDemo implements OnInit { currentPath: string = '/'; authenticated: boolean; - host: string = 'http://devproducts-platform.alfresco.me'; - // host: string = 'http://127.0.0.1:8080'; + ecmHost: string = 'http://devproducts-platform.alfresco.me'; + // ecmHost: string = 'http://127.0.0.1:8080'; token: string; @@ -154,7 +154,7 @@ class DocumentListDemo implements OnInit { translation: AlfrescoTranslationService, private documentActions: DocumentActionsService) { - alfrescoSettingsService.host = this.host; + alfrescoSettingsService.ecmHost = this.ecmHost; if (this.authService.getTicket()) { this.token = this.authService.getTicket(); } @@ -167,7 +167,7 @@ class DocumentListDemo implements OnInit { } public updateHost(): void { - this.alfrescoSettingsService.host = this.host; + this.alfrescoSettingsService.ecmHost = this.ecmHost; this.login(); } diff --git a/ng2-components/ng2-alfresco-login/demo/src/main.ts b/ng2-components/ng2-alfresco-login/demo/src/main.ts index 875220271a..83ec4d1ac6 100644 --- a/ng2-components/ng2-alfresco-login/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-login/demo/src/main.ts @@ -56,7 +56,7 @@ import { }) export class AppComponent { - public host: string = 'http://devproducts-platform.alfresco.me'; + public ecmHost: string = 'http://devproducts-platform.alfresco.me'; public token: string; @@ -66,11 +66,11 @@ export class AppComponent { constructor(public auth: AlfrescoAuthenticationService, private alfrescoSettingsService: AlfrescoSettingsService) { - alfrescoSettingsService.host = this.host; + alfrescoSettingsService.ecmHost = this.ecmHost; } public updateHost(): void { - this.alfrescoSettingsService.host = this.host; + this.alfrescoSettingsService.ecmHost = this.ecmHost; } mySuccessMethod($event) { diff --git a/ng2-components/ng2-alfresco-search/demo/src/main.ts b/ng2-components/ng2-alfresco-search/demo/src/main.ts index 719d61e450..506d26513b 100644 --- a/ng2-components/ng2-alfresco-search/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-search/demo/src/main.ts @@ -58,7 +58,7 @@ class SearchDemo implements OnInit { public searchTerm: string = 'test'; - public host: string = 'http://devproducts-platform.alfresco.me'; + public ecmHost: string = 'http://devproducts-platform.alfresco.me'; token: string; @@ -66,13 +66,13 @@ class SearchDemo implements OnInit { private alfrescoSettingsService: AlfrescoSettingsService, translation: AlfrescoTranslationService) { - alfrescoSettingsService.host = this.host; + alfrescoSettingsService.ecmHost = this.ecmHost; translation.addTranslationFolder(); } public updateHost(): void { - this.alfrescoSettingsService.host = this.host; + this.alfrescoSettingsService.ecmHost = this.ecmHost; this.login(); } diff --git a/ng2-components/ng2-alfresco-upload/demo/src/main.ts b/ng2-components/ng2-alfresco-upload/demo/src/main.ts index 369b908600..a9d7dc92cb 100644 --- a/ng2-components/ng2-alfresco-upload/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-upload/demo/src/main.ts @@ -76,12 +76,12 @@ export class MyDemoApp implements OnInit { authenticated: boolean; - public host: string = 'http://devproducts-platform.alfresco.me'; + public ecmHost: string = 'http://devproducts-platform.alfresco.me'; token: string; constructor(private authService: AlfrescoAuthenticationService, private alfrescoSettingsService: AlfrescoSettingsService) { - alfrescoSettingsService.host = this.host; + alfrescoSettingsService.ecmHost = this.ecmHost; if (this.authService.getTicket()) { this.token = this.authService.getTicket(); @@ -93,7 +93,7 @@ export class MyDemoApp implements OnInit { } public updateHost(): void { - this.alfrescoSettingsService.host = this.host; + this.alfrescoSettingsService.ecmHost = this.ecmHost; this.login(); } diff --git a/ng2-components/ng2-alfresco-webscript/demo/src/main.ts b/ng2-components/ng2-alfresco-webscript/demo/src/main.ts index 9a8fde946d..822fada650 100644 --- a/ng2-components/ng2-alfresco-webscript/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-webscript/demo/src/main.ts @@ -63,7 +63,7 @@ class WebscriptDemo implements OnInit { authenticated: boolean; - host: string = 'http://127.0.0.1:8080'; + ecmHost: string = 'http://127.0.0.1:8080'; scriptPath: string = 'sample/folder/Company%20Home'; @@ -78,7 +78,7 @@ class WebscriptDemo implements OnInit { constructor(private authService: AlfrescoAuthenticationService, private alfrescoSettingsService: AlfrescoSettingsService) { - alfrescoSettingsService.host = this.host; + alfrescoSettingsService.ecmHost = this.ecmHost; if (this.authService.getTicket()) { this.token = this.authService.getTicket(); } @@ -89,7 +89,7 @@ class WebscriptDemo implements OnInit { } public updateHost(): void { - this.alfrescoSettingsService.host = this.host; + this.alfrescoSettingsService.ecmHost = this.ecmHost; this.login(); }