mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
Merge remote-tracking branch 'remotes/origin/master' into submission
# Conflicts: # package.json # src/app/+item-page/edit-item-page/item-delete/item-delete.component.spec.ts # src/app/+item-page/edit-item-page/item-private/item-private.component.spec.ts # src/app/+item-page/edit-item-page/item-public/item-public.component.spec.ts # src/app/+item-page/edit-item-page/item-reinstate/item-reinstate.component.spec.ts # src/app/+item-page/edit-item-page/item-withdraw/item-withdraw.component.spec.ts # src/app/+item-page/edit-item-page/simple-item-action/abstract-simple-item-action.component.spec.ts # src/app/+search-page/search-service/search.service.spec.ts # src/app/core/auth/auth-response-parsing.service.spec.ts # src/app/core/auth/auth-response-parsing.service.ts # src/app/core/cache/builders/remote-data-build.service.ts # src/app/core/cache/response-cache.reducer.spec.ts # src/app/core/cache/response-cache.service.spec.ts # src/app/core/cache/response.models.ts # src/app/core/config/config-response-parsing.service.ts # src/app/core/core.effects.ts # src/app/core/core.module.ts # src/app/core/core.reducers.ts # src/app/core/data/base-response-parsing.service.ts # src/app/core/data/data.service.ts # src/app/core/data/item-data.service.spec.ts # src/app/core/data/request.models.ts # src/app/core/data/request.service.spec.ts # src/app/core/data/request.service.ts # src/app/core/integration/integration-response-parsing.service.spec.ts # src/app/core/integration/integration-response-parsing.service.ts # src/app/core/integration/integration.service.ts # src/app/core/metadata/metadata.service.spec.ts # src/app/core/registry/registry.service.spec.ts # src/app/core/shared/hal-endpoint.service.ts # src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control.component.ts # src/app/shared/mocks/mock-response-cache.service.ts # src/app/shared/shared.module.ts
This commit is contained in:
@@ -10,54 +10,43 @@ import { AuthResponseParsingService } from '../auth/auth-response-parsing.servic
|
||||
import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service';
|
||||
import { SubmissionResponseParsingService } from '../submission/submission-response-parsing.service';
|
||||
import { IntegrationResponseParsingService } from '../integration/integration-response-parsing.service';
|
||||
import { RestRequestMethod } from './rest-request-method';
|
||||
import { SearchParam } from '../cache/models/search-param.model';
|
||||
import { EpersonResponseParsingService } from '../eperson/eperson-response-parsing.service';
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +57,7 @@ export class PostRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Post, body)
|
||||
super(uuid, href, RestRequestMethod.POST, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +68,7 @@ export class PutRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Put, body)
|
||||
super(uuid, href, RestRequestMethod.PUT, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +79,7 @@ export class DeleteRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Delete, body)
|
||||
super(uuid, href, RestRequestMethod.DELETE, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +90,7 @@ export class OptionsRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Options, body)
|
||||
super(uuid, href, RestRequestMethod.OPTIONS, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +101,7 @@ export class HeadRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Head, body)
|
||||
super(uuid, href, RestRequestMethod.HEAD, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +112,7 @@ export class PatchRequest extends RestRequest {
|
||||
public body?: any,
|
||||
public options?: HttpOptions
|
||||
) {
|
||||
super(uuid, href, RestRequestMethod.Patch, body)
|
||||
super(uuid, href, RestRequestMethod.PATCH, body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,6 +292,29 @@ export class EpersonRequest extends GetRequest {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to delete an object based on its identifier
|
||||
*/
|
||||
export class DeleteByIDRequest extends DeleteRequest {
|
||||
constructor(
|
||||
uuid: string,
|
||||
href: string,
|
||||
public resourceID: string
|
||||
) {
|
||||
super(uuid, href);
|
||||
}
|
||||
}
|
||||
|
||||
export class RequestError extends Error {
|
||||
statusCode: number;
|
||||
statusText: string;
|
||||
|
Reference in New Issue
Block a user