Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ export class ClarinLicenseAgreementPageComponent implements OnInit {
});

// `/core/clarinusermetadatavalues/manage?bitstreamUUID=<BITSTREAM_UUID>`
const url = this.halService.getRootHref() + '/core/' + ClarinUserMetadata.type.value + '/' + CLARIN_USER_METADATA_MANAGE + '?bitstreamUUID=' + this.getBitstreamUUID();
// `/core/clarinusermetadatavalues/manage/zip?itemUUID=<ITEM_UUID>`
let url = this.halService.getRootHref() + '/core/' + ClarinUserMetadata.type.value + '/' +
CLARIN_USER_METADATA_MANAGE;
url += this.isDownloadingZIP() ? '/zip?itemUUID=' + this.item$.value.uuid : '?bitstreamUUID=' +
this.getBitstreamUUID();
const postRequest = new PostRequest(requestId, url, this.userMetadata$.value?.page, requestOptions);

// Add IP address into request. Every restricted download must have stored IP address in the `user_metadata` table.
Expand Down Expand Up @@ -204,6 +208,10 @@ export class ClarinLicenseAgreementPageComponent implements OnInit {
this.router.navigate([getItemPageRoute(this.item$?.value)]);
}

private isDownloadingZIP() {
return this.router.routerState.snapshot.url.endsWith('/zip');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really a good way to detect zip files? what if someone omits extension and file is e.g. txt file called howtounzip or something similar?

}

private redirectToDownload(downloadToken = null) {
// 1. Get bitstream
// 2. Get bitstream download link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { BehaviorSubject, Observable } from 'rxjs';
import { Bitstream } from '../../core/shared/bitstream.model';
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
import { PaginatedList } from '../../core/data/paginated-list.model';
import { hasValue } from '../../shared/empty.util';
import { hasValue, isUndefined } from '../../shared/empty.util';
import { BitstreamDataService } from '../../core/data/bitstream-data.service';
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
import { NotificationsService } from '../../shared/notifications/notifications.service';
Expand Down Expand Up @@ -70,8 +70,9 @@ export class ClarinZipDownloadPageComponent extends ClarinBitstreamDownloadPageC
const current: Bitstream[] = this.bitstreams$.getValue();
this.bitstreams$.next([...current, ...bitstreamsRD.payload.page]);
this.bitstreamRD$ = createSuccessfulRemoteDataObject$(this.bitstreams$.getValue()[0]);
this.dtoken = isUndefined(this.route.snapshot.queryParams.dtoken) ? null : this.route.snapshot.queryParams.dtoken;
this.zipDownloadLink.next(this.halService.getRootHref() +
`/core/items/${itemRD.payload.uuid}/allzip?handleId=${itemRD?.payload?.handle}`);
`/core/items/${itemRD.payload.uuid}/allzip?handleId=${itemRD?.payload?.handle}&dtoken=${this.dtoken}`);
super.ngOnInit();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class ClarinFilesSectionComponent implements OnInit {
}

downloadFiles() {
void this.router.navigate([getItemPageRoute(this.item), 'download']);
void this.router.navigate([getItemPageRoute(this.item), 'download', 'zip']);
}

generateCurlCommand() {
Expand Down
29 changes: 22 additions & 7 deletions src/app/item-page/item-page-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,28 @@ import {
},
{
path: 'download',
component: ClarinZipDownloadPageComponent,
resolve: {
dso: ItemPageResolver,
},
data: {
zipDownloadLink: 'This is download link'
}
children: [
{
path: '',
component: ClarinZipDownloadPageComponent,
resolve: {
dso: ItemPageResolver,
},
data: {
zipDownloadLink: 'This is download link'
}
},
{
path: 'zip',
component: ClarinZipDownloadPageComponent,
resolve: {
dso: ItemPageResolver,
},
data: {
zipDownloadLink: 'This is download link'
}
}
],
},
],
data: {
Expand Down