mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
submit to this collection
This commit is contained in:
@@ -20,6 +20,7 @@ import { HALEndpointService } from '../shared/hal-endpoint.service';
|
||||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
|
||||
import { ErrorResponse, RestResponse, SubmissionSuccessResponse } from '../cache/response.models';
|
||||
import { getResponseFromEntry } from '../shared/operators';
|
||||
import {URLCombiner} from '../url-combiner/url-combiner';
|
||||
|
||||
/**
|
||||
* The service handling all submission REST requests
|
||||
@@ -65,9 +66,15 @@ export class SubmissionRestService {
|
||||
* The base endpoint for the type of object
|
||||
* @param resourceID
|
||||
* The identifier for the object
|
||||
* @param collectionId
|
||||
* The owning collection for the object
|
||||
*/
|
||||
protected getEndpointByIDHref(endpoint, resourceID): string {
|
||||
return isNotEmpty(resourceID) ? `${endpoint}/${resourceID}` : `${endpoint}`;
|
||||
protected getEndpointByIDHref(endpoint, resourceID, collectionId?: string): string {
|
||||
let url = isNotEmpty(resourceID) ? `${endpoint}/${resourceID}` : `${endpoint}`;
|
||||
if (collectionId) {
|
||||
url = new URLCombiner(url, '?owningCollection=' + collectionId).toString();
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,12 +137,14 @@ export class SubmissionRestService {
|
||||
* The [HttpOptions] object
|
||||
* @return Observable<SubmitDataResponseDefinitionObject>
|
||||
* server response
|
||||
* @param collectionId
|
||||
* The owning collection id
|
||||
*/
|
||||
public postToEndpoint(linkName: string, body: any, scopeId?: string, options?: HttpOptions): Observable<SubmitDataResponseDefinitionObject> {
|
||||
public postToEndpoint(linkName: string, body: any, scopeId?: string, options?: HttpOptions, collectionId?: string): Observable<SubmitDataResponseDefinitionObject> {
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
return this.halService.getEndpoint(linkName).pipe(
|
||||
filter((href: string) => isNotEmpty(href)),
|
||||
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, scopeId)),
|
||||
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, scopeId, collectionId)),
|
||||
distinctUntilChanged(),
|
||||
map((endpointURL: string) => new SubmissionPostRequest(requestId, endpointURL, body, options)),
|
||||
tap((request: PostRequest) => this.requestService.configure(request)),
|
||||
|
Reference in New Issue
Block a user