From 2c7f646b713ca570d4e25a0947eebf415a02b30b Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Thu, 8 Jun 2017 16:59:49 +0200 Subject: [PATCH] fixed relative/absolute paths --- src/app/core/data/collection-data.service.ts | 8 +++++--- src/app/core/data/community-data.service.ts | 8 +++++--- src/app/core/data/data.service.ts | 12 +++++++++--- src/app/core/data/item-data.service.ts | 8 +++++--- .../core/dspace-rest-v2/dspace-rest-v2.service.ts | 8 ++++---- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/app/core/data/collection-data.service.ts b/src/app/core/data/collection-data.service.ts index cf396ec118..8756d02837 100644 --- a/src/app/core/data/collection-data.service.ts +++ b/src/app/core/data/collection-data.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from "@angular/core"; +import { Inject, Injectable } from "@angular/core"; import { DataService } from "./data.service"; import { Collection } from "../shared/collection.model"; import { ObjectCacheService } from "../cache/object-cache.service"; @@ -8,6 +8,7 @@ import { NormalizedCollection } from "../cache/models/normalized-collection.mode import { CoreState } from "../core.reducers"; import { RequestService } from "./request.service"; import { RemoteDataBuildService } from "../cache/builders/remote-data-build.service"; +import { GLOBAL_CONFIG, GlobalConfig } from "../../../config"; @Injectable() export class CollectionDataService extends DataService { @@ -18,9 +19,10 @@ export class CollectionDataService extends DataService + protected store: Store, + @Inject(GLOBAL_CONFIG) EnvConfig: GlobalConfig ) { - super(NormalizedCollection); + super(NormalizedCollection, EnvConfig); } } diff --git a/src/app/core/data/community-data.service.ts b/src/app/core/data/community-data.service.ts index 3da43f09ea..07420ba58f 100644 --- a/src/app/core/data/community-data.service.ts +++ b/src/app/core/data/community-data.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from "@angular/core"; +import { Inject, Injectable } from "@angular/core"; import { DataService } from "./data.service"; import { Community } from "../shared/community.model"; import { ObjectCacheService } from "../cache/object-cache.service"; @@ -8,6 +8,7 @@ import { NormalizedCommunity } from "../cache/models/normalized-community.model" import { CoreState } from "../core.reducers"; import { RequestService } from "./request.service"; import { RemoteDataBuildService } from "../cache/builders/remote-data-build.service"; +import { GLOBAL_CONFIG, GlobalConfig } from "../../../config"; @Injectable() export class CommunityDataService extends DataService { @@ -18,9 +19,10 @@ export class CommunityDataService extends DataService + protected store: Store, + @Inject(GLOBAL_CONFIG) EnvConfig: GlobalConfig ) { - super(NormalizedCommunity); + super(NormalizedCommunity, EnvConfig); } } diff --git a/src/app/core/data/data.service.ts b/src/app/core/data/data.service.ts index 43db6cc4a2..2b665f487b 100644 --- a/src/app/core/data/data.service.ts +++ b/src/app/core/data/data.service.ts @@ -10,6 +10,9 @@ import { CoreState } from "../core.reducers"; import { RequestService } from "./request.service"; import { RemoteDataBuildService } from "../cache/builders/remote-data-build.service"; import { GenericConstructor } from "../shared/generic-constructor"; +import { Inject } from "@angular/core"; +import { GLOBAL_CONFIG, GlobalConfig } from "../../../config"; +import { RESTURLCombiner } from "../url-combiner/rest-url-combiner"; export abstract class DataService { protected abstract objectCache: ObjectCacheService; @@ -19,7 +22,10 @@ export abstract class DataService protected abstract store: Store; protected abstract endpoint: string; - constructor(private normalizedResourceType: GenericConstructor) { + constructor( + private normalizedResourceType: GenericConstructor, + protected EnvConfig: GlobalConfig + ) { } @@ -28,7 +34,7 @@ export abstract class DataService if (hasValue(scopeID)) { result += `?scope=${scopeID}` } - return result; + return new RESTURLCombiner(this.EnvConfig, result).toString(); } findAll(scopeID?: string): RemoteData> { @@ -40,7 +46,7 @@ export abstract class DataService } protected getFindByIDHref(resourceID): string { - return `${this.endpoint}/${resourceID}`; + return new RESTURLCombiner(this.EnvConfig, `${this.endpoint}/${resourceID}`).toString(); } findById(id: string): RemoteData { diff --git a/src/app/core/data/item-data.service.ts b/src/app/core/data/item-data.service.ts index a1a0109ed3..e7df1aea07 100644 --- a/src/app/core/data/item-data.service.ts +++ b/src/app/core/data/item-data.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from "@angular/core"; +import { Inject, Injectable } from "@angular/core"; import { DataService } from "./data.service"; import { Item } from "../shared/item.model"; import { ObjectCacheService } from "../cache/object-cache.service"; @@ -8,6 +8,7 @@ import { CoreState } from "../core.reducers"; import { NormalizedItem } from "../cache/models/normalized-item.model"; import { RequestService } from "./request.service"; import { RemoteDataBuildService } from "../cache/builders/remote-data-build.service"; +import { GLOBAL_CONFIG, GlobalConfig } from "../../../config"; @Injectable() export class ItemDataService extends DataService { @@ -18,8 +19,9 @@ export class ItemDataService extends DataService { protected responseCache: ResponseCacheService, protected requestService: RequestService, protected rdbService: RemoteDataBuildService, - protected store: Store + protected store: Store, + @Inject(GLOBAL_CONFIG) EnvConfig: GlobalConfig ) { - super(NormalizedItem); + super(NormalizedItem, EnvConfig); } } diff --git a/src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts b/src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts index 1920c0a994..9107d51bb7 100644 --- a/src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts +++ b/src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts @@ -18,15 +18,15 @@ export class DSpaceRESTv2Service { /** * Performs a request to the REST API with the `get` http method. * - * @param relativeURL - * A URL, relative to the basepath of the rest api + * @param absoluteURL + * A URL * @param options * A RequestOptionsArgs object, with options for the http call. * @return {Observable} * An Observablse containing the response from the server */ - get(relativeURL: string, options?: RequestOptionsArgs): Observable { - return this.http.get(new RESTURLCombiner(this.EnvConfig, relativeURL).toString(), options) + get(absoluteURL: string, options?: RequestOptionsArgs): Observable { + return this.http.get(absoluteURL, options) .map(res => ({ payload: res.json(), statusCode: res.statusText })) .catch(err => { console.log('Error: ', err);