mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00

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
234 lines
5.9 KiB
TypeScript
234 lines
5.9 KiB
TypeScript
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-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 */
|
|
|
|
export abstract class RestRequest {
|
|
public responseMsToLive = 0;
|
|
constructor(
|
|
public uuid: string,
|
|
public href: string,
|
|
public method: RestRequestMethod = RestRequestMethod.GET,
|
|
public body?: any,
|
|
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,
|
|
) {
|
|
super(uuid, href, RestRequestMethod.GET, body, options)
|
|
}
|
|
}
|
|
|
|
export class PostRequest extends RestRequest {
|
|
constructor(
|
|
public uuid: string,
|
|
public href: string,
|
|
public body?: any,
|
|
public options?: HttpOptions
|
|
) {
|
|
super(uuid, href, RestRequestMethod.POST, body)
|
|
}
|
|
}
|
|
|
|
export class PutRequest extends RestRequest {
|
|
constructor(
|
|
public uuid: string,
|
|
public href: string,
|
|
public body?: any,
|
|
public options?: HttpOptions
|
|
) {
|
|
super(uuid, href, RestRequestMethod.PUT, body)
|
|
}
|
|
}
|
|
|
|
export class DeleteRequest extends RestRequest {
|
|
constructor(
|
|
public uuid: string,
|
|
public href: string,
|
|
public body?: any,
|
|
public options?: HttpOptions
|
|
) {
|
|
super(uuid, href, RestRequestMethod.DELETE, body)
|
|
}
|
|
}
|
|
|
|
export class OptionsRequest extends RestRequest {
|
|
constructor(
|
|
public uuid: string,
|
|
public href: string,
|
|
public body?: any,
|
|
public options?: HttpOptions
|
|
) {
|
|
super(uuid, href, RestRequestMethod.OPTIONS, body)
|
|
}
|
|
}
|
|
|
|
export class HeadRequest extends RestRequest {
|
|
constructor(
|
|
public uuid: string,
|
|
public href: string,
|
|
public body?: any,
|
|
public options?: HttpOptions
|
|
) {
|
|
super(uuid, href, RestRequestMethod.HEAD, body)
|
|
}
|
|
}
|
|
|
|
export class PatchRequest extends RestRequest {
|
|
constructor(
|
|
public uuid: string,
|
|
public href: string,
|
|
public body?: any,
|
|
public options?: HttpOptions
|
|
) {
|
|
super(uuid, href, RestRequestMethod.PATCH, body)
|
|
}
|
|
}
|
|
|
|
export class FindByIDRequest extends GetRequest {
|
|
constructor(
|
|
uuid: string,
|
|
href: string,
|
|
public resourceID: string
|
|
) {
|
|
super(uuid, href);
|
|
}
|
|
}
|
|
|
|
export class FindAllOptions {
|
|
scopeID?: string;
|
|
elementsPerPage?: number;
|
|
currentPage?: number;
|
|
sort?: SortOptions;
|
|
startsWith?: string;
|
|
}
|
|
|
|
export class FindAllRequest extends GetRequest {
|
|
constructor(
|
|
uuid: string,
|
|
href: string,
|
|
public body?: FindAllOptions,
|
|
) {
|
|
super(uuid, href);
|
|
}
|
|
}
|
|
|
|
export class EndpointMapRequest extends GetRequest {
|
|
constructor(
|
|
public uuid: string,
|
|
public href: string,
|
|
public body?: any
|
|
) {
|
|
super(uuid, href, 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;
|
|
}
|
|
}
|
|
|
|
export class ConfigRequest extends GetRequest {
|
|
constructor(uuid: string, href: string) {
|
|
super(uuid, href);
|
|
}
|
|
|
|
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 {
|
|
constructor(uuid: string, href: string, public options?: HttpOptions) {
|
|
super(uuid, href, null, options);
|
|
}
|
|
|
|
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
|
return AuthResponseParsingService;
|
|
}
|
|
}
|
|
|
|
export class IntegrationRequest extends GetRequest {
|
|
constructor(uuid: string, href: string) {
|
|
super(uuid, href);
|
|
}
|
|
|
|
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
|
return IntegrationResponseParsingService;
|
|
}
|
|
}
|
|
|
|
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 RequestError extends Error {
|
|
statusText: string;
|
|
}
|
|
/* tslint:enable:max-classes-per-file */
|