mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
Merge branch 'response-cache-refactoring' into w2p-54472_Create-community-and-collection-pages
Conflicts: src/app/core/auth/auth-response-parsing.service.ts src/app/core/auth/auth.service.ts src/app/core/auth/models/auth-status.model.ts src/app/core/auth/models/normalized-auth-status.model.ts src/app/core/auth/server-auth.service.ts src/app/core/cache/builders/remote-data-build.service.ts src/app/core/data/collection-data.service.ts src/app/core/data/comcol-data.service.spec.ts src/app/core/data/comcol-data.service.ts src/app/core/data/community-data.service.ts src/app/core/data/data.service.spec.ts src/app/core/data/data.service.ts src/app/core/data/dspace-object-data.service.ts src/app/core/data/item-data.service.ts src/app/core/data/request.models.ts src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts src/app/core/shared/hal-endpoint.service.ts src/app/core/shared/operators.ts src/app/shared/testing/auth-request-service-stub.ts src/app/shared/testing/auth-service-stub.ts
This commit is contained in:
@@ -9,51 +9,41 @@ import { ConfigResponseParsingService } from './config-response-parsing.service'
|
||||
import { AuthResponseParsingService } from '../auth/auth-response-parsing.service';
|
||||
import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service';
|
||||
import { IntegrationResponseParsingService } from '../integration/integration-response-parsing.service';
|
||||
import { RestRequestMethod } from './rest-request-method';
|
||||
import { BrowseItemsResponseParsingService } from './browse-items-response-parsing-service';
|
||||
|
||||
/* tslint:disable:max-classes-per-file */
|
||||
|
||||
/**
|
||||
* Represents a Request Method.
|
||||
*
|
||||
* I didn't reuse the RequestMethod enum in @angular/http because
|
||||
* it uses numbers. The string values here are more clear when
|
||||
* debugging.
|
||||
*
|
||||
* The ones commented out are still unsupported in the rest of the codebase
|
||||
*/
|
||||
export enum RestRequestMethod {
|
||||
Get = 'GET',
|
||||
Post = 'POST',
|
||||
Put = 'PUT',
|
||||
Delete = 'DELETE',
|
||||
Options = 'OPTIONS',
|
||||
Head = 'HEAD',
|
||||
Patch = 'PATCH'
|
||||
}
|
||||
|
||||
export abstract class RestRequest {
|
||||
public responseMsToLive = 0;
|
||||
constructor(
|
||||
public uuid: string,
|
||||
public href: string,
|
||||
public method: RestRequestMethod = RestRequestMethod.Get,
|
||||
public method: RestRequestMethod = RestRequestMethod.GET,
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
public options?: HttpOptions,
|
||||
) {
|
||||
}
|
||||
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return DSOResponseParsingService;
|
||||
}
|
||||
|
||||
get toCache(): boolean {
|
||||
return this.responseMsToLive > 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class GetRequest extends RestRequest {
|
||||
public responseMsToLive = 60 * 15 * 1000;
|
||||
|
||||
constructor(
|
||||
public uuid: string,
|
||||
public href: string,
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
public options?: HttpOptions,
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Get, body)
|
||||
super(uuid, href, RestRequestMethod.GET, body, options)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +54,7 @@ export class PostRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Post, body)
|
||||
super(uuid, href, RestRequestMethod.POST, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +65,7 @@ export class PutRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Put, body)
|
||||
super(uuid, href, RestRequestMethod.PUT, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +76,7 @@ export class DeleteRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Delete, body)
|
||||
super(uuid, href, RestRequestMethod.DELETE, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +87,7 @@ export class OptionsRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Options, body)
|
||||
super(uuid, href, RestRequestMethod.OPTIONS, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +98,7 @@ export class HeadRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Head, body)
|
||||
super(uuid, href, RestRequestMethod.HEAD, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +109,7 @@ export class PatchRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Patch, body)
|
||||
super(uuid, href, RestRequestMethod.PATCH, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,6 +171,12 @@ export class BrowseEntriesRequest extends GetRequest {
|
||||
}
|
||||
}
|
||||
|
||||
export class BrowseItemsRequest extends GetRequest {
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return BrowseItemsResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class ConfigRequest extends GetRequest {
|
||||
constructor(uuid: string, href: string) {
|
||||
super(uuid, href);
|
||||
|
Reference in New Issue
Block a user