mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
Cache redesign part 1, and add support for alternative links
This commit is contained in:
@@ -1,25 +1,15 @@
|
||||
import { SortOptions } from '../cache/models/sort-options.model';
|
||||
import { GenericConstructor } from '../shared/generic-constructor';
|
||||
import { BrowseEntriesResponseParsingService } from './browse-entries-response-parsing.service';
|
||||
import { DSOResponseParsingService } from './dso-response-parsing.service';
|
||||
import { ResponseParsingService } from './parsing.service';
|
||||
import { EndpointMapResponseParsingService } from './endpoint-map-response-parsing.service';
|
||||
import { BrowseResponseParsingService } from './browse-response-parsing.service';
|
||||
import { ConfigResponseParsingService } from '../config/config-response-parsing.service';
|
||||
import { AuthResponseParsingService } from '../auth/auth-response-parsing.service';
|
||||
import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service';
|
||||
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
|
||||
import { SubmissionResponseParsingService } from '../submission/submission-response-parsing.service';
|
||||
import { RestRequestMethod } from './rest-request-method';
|
||||
import { RequestParam } from '../cache/models/request-param.model';
|
||||
import { EpersonResponseParsingService } from '../eperson/eperson-response-parsing.service';
|
||||
import { BrowseItemsResponseParsingService } from './browse-items-response-parsing-service';
|
||||
import { URLCombiner } from '../url-combiner/url-combiner';
|
||||
import { TaskResponseParsingService } from '../tasks/task-response-parsing.service';
|
||||
import { ContentSourceResponseParsingService } from './content-source-response-parsing.service';
|
||||
import { MappedCollectionsReponseParsingService } from './mapped-collections-reponse-parsing.service';
|
||||
import { ProcessFilesResponseParsingService } from './process-files-response-parsing.service';
|
||||
import { TokenResponseParsingService } from '../auth/token-response-parsing.service';
|
||||
import { VocabularyEntriesResponseParsingService } from '../submission/vocabularies/vocabulary-entries-response-parsing.service';
|
||||
import { DspaceRestResponseParsingService } from './dspace-rest-response-parsing.service';
|
||||
import { environment } from '../../../environments/environment';
|
||||
|
||||
/* tslint:disable:max-classes-per-file */
|
||||
|
||||
@@ -30,7 +20,7 @@ export enum IdentifierType {
|
||||
}
|
||||
|
||||
export abstract class RestRequest {
|
||||
public responseMsToLive = 10 * 1000;
|
||||
public responseMsToLive = environment.cache.msToLive.default;
|
||||
public forceBypassCache = false;
|
||||
public isMultipart = false;
|
||||
|
||||
@@ -44,17 +34,11 @@ export abstract class RestRequest {
|
||||
}
|
||||
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return DSOResponseParsingService;
|
||||
}
|
||||
|
||||
get toCache(): boolean {
|
||||
return this.responseMsToLive > 0;
|
||||
return DspaceRestResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class GetRequest extends RestRequest {
|
||||
public responseMsToLive = 60 * 15 * 1000;
|
||||
|
||||
constructor(
|
||||
public uuid: string,
|
||||
public href: string,
|
||||
@@ -136,8 +120,6 @@ export class HeadRequest extends RestRequest {
|
||||
}
|
||||
|
||||
export class PatchRequest extends RestRequest {
|
||||
public responseMsToLive = 60 * 15 * 1000;
|
||||
|
||||
constructor(
|
||||
public uuid: string,
|
||||
public href: string,
|
||||
@@ -178,104 +160,11 @@ export class FindListRequest extends GetRequest {
|
||||
}
|
||||
|
||||
export class EndpointMapRequest extends GetRequest {
|
||||
public responseMsToLive = Number.MAX_SAFE_INTEGER;
|
||||
|
||||
constructor(
|
||||
uuid: string,
|
||||
href: string,
|
||||
body?: any
|
||||
) {
|
||||
super(uuid, new URLCombiner(href, '?endpointMap').toString(), body);
|
||||
}
|
||||
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return EndpointMapResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class BrowseEndpointRequest extends GetRequest {
|
||||
constructor(uuid: string, href: string) {
|
||||
super(uuid, href);
|
||||
}
|
||||
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return BrowseResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class BrowseEntriesRequest extends GetRequest {
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return BrowseEntriesResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class BrowseItemsRequest extends GetRequest {
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return BrowseItemsResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to fetch the mapped collections of an item
|
||||
*/
|
||||
export class MappedCollectionsRequest extends GetRequest {
|
||||
public responseMsToLive = 10000;
|
||||
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return MappedCollectionsReponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to fetch the files of a process
|
||||
*/
|
||||
export class ProcessFilesRequest extends GetRequest {
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return ProcessFilesResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class ConfigRequest extends GetRequest {
|
||||
constructor(uuid: string, href: string, public options?: HttpOptions) {
|
||||
super(uuid, href, null, options);
|
||||
}
|
||||
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return ConfigResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class AuthPostRequest extends PostRequest {
|
||||
constructor(uuid: string, href: string, public body?: any, public options?: HttpOptions) {
|
||||
super(uuid, href, body, options);
|
||||
}
|
||||
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return AuthResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class AuthGetRequest extends GetRequest {
|
||||
forceBypassCache = true;
|
||||
|
||||
constructor(uuid: string, href: string, public options?: HttpOptions) {
|
||||
super(uuid, href, null, options);
|
||||
}
|
||||
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return AuthResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A POST request for retrieving a token
|
||||
*/
|
||||
export class TokenPostRequest extends PostRequest {
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return TokenResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class representing a submission HTTP GET request object
|
||||
*/
|
||||
@@ -335,27 +224,10 @@ export class SubmissionPostRequest extends PostRequest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class representing an eperson HTTP GET request object
|
||||
*/
|
||||
export class EpersonRequest extends GetRequest {
|
||||
constructor(uuid: string, href: string) {
|
||||
super(uuid, href);
|
||||
}
|
||||
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return EpersonResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class CreateRequest extends PostRequest {
|
||||
constructor(uuid: string, href: string, public body?: any, public options?: HttpOptions) {
|
||||
super(uuid, href, body, options);
|
||||
}
|
||||
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return DSOResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class ContentSourceRequest extends GetRequest {
|
||||
@@ -415,15 +287,6 @@ export class MyDSpaceRequest extends GetRequest {
|
||||
public responseMsToLive = 10 * 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to get vocabulary entries
|
||||
*/
|
||||
export class VocabularyEntriesRequest extends FindListRequest {
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return VocabularyEntriesResponseParsingService;
|
||||
}
|
||||
}
|
||||
|
||||
export class RequestError extends Error {
|
||||
statusCode: number;
|
||||
statusText: string;
|
||||
|
Reference in New Issue
Block a user