Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use content route for downloading the bitstream #769

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/app/app-routing-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export function getBitstreamModuleRoute() {
export function getBitstreamDownloadRoute(bitstream): string {
return new URLCombiner(getBitstreamModuleRoute(), bitstream.uuid, 'download').toString();
}

export function getBitstreamContentRoute(bitstream): string {
return new URLCombiner(getBitstreamModuleRoute(), bitstream.uuid, 'content').toString();
}

export function getBitstreamRequestACopyRoute(item, bitstream): { routerLink: string, queryParams: any } {
const url = new URLCombiner(getItemModuleRoute(), item.uuid, 'request-a-copy').toString();
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Bitstream } from '../../core/shared/bitstream.model';
import { take } from 'rxjs/operators';
import { getBitstreamDownloadRoute } from '../../app-routing-paths';
import { HardRedirectService } from '../../core/services/hard-redirect.service';
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';

/**
* This component shows error that the download token is expired and redirect the user to the Item View page
Expand All @@ -22,14 +21,13 @@ export class ClarinBitstreamTokenExpiredComponent implements OnInit {

constructor(
private hardRedirectService: HardRedirectService,
private halService: HALEndpointService
) { }

ngOnInit(): void {
setTimeout(() => {
this.bitstream$.pipe(take(1))
.subscribe(bitstream => {
const bitstreamDownloadPath = this.halService.getRootHref() + getBitstreamDownloadRoute(bitstream);
const bitstreamDownloadPath = getBitstreamDownloadRoute(bitstream);
this.hardRedirectService.redirect(bitstreamDownloadPath);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { RemoteDataBuildService } from '../../core/cache/builders/remote-data-bu
import { HttpOptions } from '../../core/dspace-rest/dspace-rest.service';
import { Router } from '@angular/router';
import { getItemPageRoute } from '../../item-page/item-page-routing-paths';
import { getBitstreamDownloadRoute } from '../../app-routing-paths';
import { getBitstreamContentRoute } from '../../app-routing-paths';
import { hasFailed } from 'src/app/core/data/request-entry-state.model';
import { FindListOptions } from '../../core/data/find-list-options.model';
import isEqual from 'lodash/isEqual';
Expand Down Expand Up @@ -255,10 +255,12 @@ export class ClarinLicenseAgreementPageComponent implements OnInit {
.subscribe(bitstream$ => {
bitstream = bitstream$;
});
let bitstreamDownloadPath = getBitstreamDownloadRoute(bitstream);
let bitstreamDownloadPath = getBitstreamContentRoute(bitstream);
if (isNotEmpty(downloadToken)) {
bitstreamDownloadPath = this.halService.getRootHref() + bitstreamDownloadPath + '?dtoken=' + downloadToken;
bitstreamDownloadPath = this.halService.getRootHref() + '/core' + bitstreamDownloadPath +
'?dtoken=' + downloadToken;
}

this.hardRedirectService.redirect(bitstreamDownloadPath);
}

Expand Down
Loading