Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
bf14771
[DURACOM-413] port custom url functionality
FrancescoMolinaro Nov 12, 2025
66bd310
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-413
FrancescoMolinaro Nov 13, 2025
b42bf55
[DURACOM-413] additional tests
FrancescoMolinaro Nov 13, 2025
e88a40d
[DURACOM-413] update labels, fix sync script, adapt section handling
FrancescoMolinaro Nov 18, 2025
c93cb50
[DURACOM-413] update error handling/validation + resync translations
FrancescoMolinaro Nov 19, 2025
75937c4
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-413
FrancescoMolinaro Dec 5, 2025
d1c1ecf
[DURACOM-413] fix lint
FrancescoMolinaro Dec 5, 2025
8bdfd01
[DURACOM-426] init integration of authority framework
FrancescoMolinaro Dec 10, 2025
a9dc8ec
Merge branch 'task/main/DURACOM-413' into task/main/DURACOM-426
FrancescoMolinaro Dec 12, 2025
8c073ff
[DURACOM-426] port metadata link components for authorithy
FrancescoMolinaro Dec 15, 2025
d262480
[DURACOM-426] fix some tests
FrancescoMolinaro Dec 15, 2025
9c5e6bb
[DURACOM-426] fix some unit tests
FrancescoMolinaro Dec 16, 2025
a514b6e
[DURACOM-426] fix tests and lint
FrancescoMolinaro Dec 16, 2025
a9ee4e5
[DURACOM-426] add authority link for md representation
FrancescoMolinaro Dec 16, 2025
306029c
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-426
FrancescoMolinaro Dec 18, 2025
36c77fe
[DURACOM-426] clean up, add example, minor restyle, fix templates
FrancescoMolinaro Dec 18, 2025
e9f3df5
[DURACOM-426] improve tests
FrancescoMolinaro Dec 18, 2025
5b6fa80
[DURACOM-426] refactor
FrancescoMolinaro Dec 19, 2025
b29dc1e
[DURACOM-426] improve title configurability in popover, add link view…
FrancescoMolinaro Jan 15, 2026
3f35069
[DURACOM-426] add labels, fix facets labels,fix onebox other info tem…
FrancescoMolinaro Jan 16, 2026
1258bc2
[DURACOM-426] filter data labels
FrancescoMolinaro Jan 19, 2026
36e34a2
[DURACOM-426] revert changes to lables, except for english
FrancescoMolinaro Jan 19, 2026
d2c0749
[DURACOM-426] add config example, remove unnecessary config
FrancescoMolinaro Jan 19, 2026
1aef155
[DURACOM-426] clean config, add labels
FrancescoMolinaro Jan 19, 2026
995ff87
[DURACOM-426] add authority enrichment
FrancescoMolinaro Jan 21, 2026
efc488a
[DURACOM-426] fix tests
FrancescoMolinaro Jan 21, 2026
252c249
[DURACOM-426] fix test and model update
FrancescoMolinaro Jan 22, 2026
e316b11
[DURACOM-426] add vocabulary template in item field, adapt tests
FrancescoMolinaro Jan 22, 2026
317c1ee
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-426
FrancescoMolinaro Jan 23, 2026
be381eb
[DURACOM-426] fix lint
FrancescoMolinaro Jan 23, 2026
a19ef43
[DURACOM-426] refactor
FrancescoMolinaro Jan 29, 2026
837b47e
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-426
FrancescoMolinaro Feb 6, 2026
ca4edf7
Merge remote-tracking branch 'gitHub/main' into task/main/DURACOM-426
FrancescoMolinaro Feb 12, 2026
a15ad30
[DURACOM-426] remove unused method and duplicated config example
FrancescoMolinaro Feb 12, 2026
5160bf9
[DURACOM-426] revert changes to sync script
FrancescoMolinaro Feb 12, 2026
5bd912c
[DURACOM-455] add bitstream download redirect guard
FrancescoMolinaro Feb 17, 2026
64e866e
[DURACOM-455] add download button
FrancescoMolinaro Feb 18, 2026
4f72074
[DURACOM-455] add advanced attachment
FrancescoMolinaro Feb 20, 2026
6878cd6
[DURACOM-455] add config example
FrancescoMolinaro Feb 20, 2026
d361cc3
[DURACOM-455] fix tests
FrancescoMolinaro Feb 20, 2026
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
109 changes: 109 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ submission:
style: text-muted
icon: fa-circle-xmark

# Icons to be displayed next to an authority controlled value, to give indication of the source.
sourceIcons:
# Example of configuration for authority logo based on sources.
# The configured icon will be displayed next to the authority value in submission and on item page or search results.
- source: orcid
- path: assets/images/orcid.logo.icon.svg
# Fallback language in which the UI will be rendered if the user's browser language is not an active language
fallbackLanguage: en

Expand Down Expand Up @@ -641,3 +647,106 @@ geospatialMapViewer:
accessibility:
# The duration in days after which the accessibility settings cookie expires
cookieExpirationDuration: 7

# Configuration for custom layout
layout:
# Configuration of icons and styles to be used for each authority controlled link
authorityRef:
- entityType: DEFAULT
entityStyle:
default:
icon: fa fa-user
style: text-info
- entityType: PERSON
entityStyle:
person:
icon: fa fa-user
style: text-success
default:
icon: fa fa-user
style: text-info
- entityType: ORGUNIT
entityStyle:
default:
icon: fa fa-university
style: text-success
- entityType: PROJECT
entityStyle:
default:
icon: fas fa-project-diagram
style: text-success
# If true the dowmload link in item page will rerendered as an advanced attachment, the view can be then configured with the config advancedAttachmentRendering
showDownloadLinkAsAttachment: true
# When the search results are retrieved, for each item type the metadata with a valid authority value are inspected.
# Referenced items will be fetched with a find all by id strategy to avoid individual rest requests
# to efficiently display the search results.
followAuthorityMetadata:
- type: Publication
metadata: dc.contributor.author
- type: Product
metadata: dc.contributor.author

# The maximum number of item to process when following authority metadata values.
followAuthorityMaxItemLimit: 100

# The maximum number of metadata values to process for each metadata key
# when following authority metadata values.
followAuthorityMetadataValuesLimit: 5

# Configuration for customization of search results
searchResults:
# Metadata fields to be displayed in the search results under the standard ones
additionalMetadataFields:
- dc.contributor.author
- dc.date.issued
- dc.type
# Metadata fields to be displayed in the search results for the author section
authorMetadata:
- dc.contributor.author
- dc.creator
- dc.contributor.*

# Configuration of metadata to be displayed in the item metadata link view popover
metadataLinkViewPopoverData:
# Metdadata list to be displayed for entities without a specific configuration
fallbackMetdataList:
- dc.description.abstract
- dc.description.note
# Configuration for each entity type
entityDataConfig:
- entityType: Person
# Descriptive metadata (popover body)
metadataList:
- person.affiliation.name
- person.email
# Title metadata (popover header)
titleMetadataList:
- person.givenName
- person.familyName
# Configuration for identifier subtypes, based on metadata like dc.identifier.ror where ror is the subtype.
# This is used to map the layout of the identifier in the popover and the icon displayed next to the metadata value.
identifierSubtypes:
- name: ror
icon: assets/images/ror.logo.icon.svg
iconPosition: IdentifierSubtypesIconPositionEnum.LEFT
link: https://ror.org

# Configuration for advanced attachment rendering. Controls how bitstream attachments and their metadata are displayed.
advancedAttachmentRendering:
# Pagination settings for attachment lists
pagination:
enabled: true
elementsPerPage: 2
# Metadata and attributes to display for each attachment. Use 'metadata' type for DSpace metadata fields, 'attribute' for bitstream properties (size, format, checksum).
metadata:
- name: dc.title
type: metadata
truncatable: false
- name: dc.description
type: metadata
truncatable: true
- name: size
type: attribute
- name: format
type: attribute

223 changes: 223 additions & 0 deletions src/app/bitstream-page/bitstream-download-redirect.guard.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
import { PLATFORM_ID } from '@angular/core';
import {
TestBed,
waitForAsync,
} from '@angular/core/testing';
import { Router } from '@angular/router';
import { NotificationsService } from '@dspace/core/notification-system/notifications.service';
import { getForbiddenRoute } from '@dspace/core/router/core-routing-paths';
import { createSuccessfulRemoteDataObject$ } from '@dspace/core/utilities/remote-data.utils';
import { Store } from '@ngrx/store';
import { of } from 'rxjs';

import { AuthService } from '../core/auth/auth.service';
import { RemoteDataBuildService } from '../core/cache/builders/remote-data-build.service';
import { ObjectCacheService } from '../core/cache/object-cache.service';
import { BitstreamDataService } from '../core/data/bitstream-data.service';
import { BitstreamFormatDataService } from '../core/data/bitstream-format-data.service';
import { DSOChangeAnalyzer } from '../core/data/dso-change-analyzer.service';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
import { SignpostingDataService } from '../core/data/signposting-data.service';
import { HardRedirectService } from '../core/services/hard-redirect.service';
import { ServerResponseService } from '../core/services/server-response.service';
import {
NativeWindowRef,
NativeWindowService,
} from '../core/services/window.service';
import { Bitstream } from '../core/shared/bitstream.model';
import { FileService } from '../core/shared/file.service';
import { HALEndpointService } from '../core/shared/hal-endpoint.service';
import { UUIDService } from '../core/shared/uuid.service';
import { bitstreamDownloadRedirectGuard } from './bitstream-download-redirect.guard';

describe('BitstreamDownloadRedirectGuard', () => {
let resolver: any;

let authService: AuthService;
let authorizationService: AuthorizationDataService;
let bitstreamDataService: BitstreamDataService;
let fileService: FileService;
let halEndpointService: HALEndpointService;
let hardRedirectService: HardRedirectService;
let remoteDataBuildService: RemoteDataBuildService;
let uuidService: UUIDService;
let objectCacheService: ObjectCacheService;
let router: Router;
let store: Store;
let bitstream: Bitstream;
let serverResponseService: jasmine.SpyObj<ServerResponseService>;
let signpostingDataService: jasmine.SpyObj<SignpostingDataService>;

let route = {
params: {},
queryParams: {},
};
let state = {};

const mocklink = {
href: 'http://test.org',
rel: 'test',
type: 'test',
};

const mocklink2 = {
href: 'http://test2.org',
rel: 'test',
type: 'test',
};

function init() {
authService = jasmine.createSpyObj('authService', {
isAuthenticated: of(true),
setRedirectUrl: {},
});
authorizationService = jasmine.createSpyObj('authorizationSerivice', {
isAuthorized: of(true),
});

fileService = jasmine.createSpyObj('fileService', {
retrieveFileDownloadLink: of('content-url-with-headers'),
});

hardRedirectService = jasmine.createSpyObj('fileService', {
redirect: {},
});

halEndpointService = jasmine.createSpyObj('halEndpointService', {
getEndpoint: of('https://rest.api/core'),
});

remoteDataBuildService = jasmine.createSpyObj('remoteDataBuildService', {
buildSingle: of(new Bitstream()),
});

uuidService = jasmine.createSpyObj('uuidService', {
generate: 'test-id',
});

bitstream = Object.assign(new Bitstream(), {
uuid: 'bitstreamUuid',
_links: {
content: { href: 'bitstream-content-link' },
self: { href: 'bitstream-self-link' },
},
});

router = jasmine.createSpyObj('router', ['navigateByUrl', 'createUrlTree']);

store = jasmine.createSpyObj('store', {
dispatch: {},
pipe: of(true),
});

serverResponseService = jasmine.createSpyObj('ServerResponseService', {
setHeader: jasmine.createSpy('setHeader'),
});

signpostingDataService = jasmine.createSpyObj('SignpostingDataService', {
getLinks: of([mocklink, mocklink2]),
});

objectCacheService = jasmine.createSpyObj('objectCacheService', {
getByHref: of(null),
});

bitstreamDataService = jasmine.createSpyObj('bitstreamDataService', {
findById: createSuccessfulRemoteDataObject$(Object.assign(new Bitstream(), {
_links: {
content: { href: 'bitstream-content-link' },
self: { href: 'bitstream-self-link' },
},
})),
});

resolver = bitstreamDownloadRedirectGuard;
}

function initTestbed() {
TestBed.configureTestingModule({
providers: [
{ provide: NativeWindowService, useValue: new NativeWindowRef() },
{ provide: Router, useValue: router },
{ provide: AuthorizationDataService, useValue: authorizationService },
{ provide: AuthService, useValue: authService },
{ provide: FileService, useValue: fileService },
{ provide: HardRedirectService, useValue: hardRedirectService },
{ provide: ServerResponseService, useValue: serverResponseService },
{ provide: SignpostingDataService, useValue: signpostingDataService },
{ provide: ObjectCacheService, useValue: objectCacheService },
{ provide: PLATFORM_ID, useValue: 'server' },
{ provide: UUIDService, useValue: uuidService },
{ provide: Store, useValue: store },
{ provide: RemoteDataBuildService, useValue: remoteDataBuildService },
{ provide: HALEndpointService, useValue: halEndpointService },
{ provide: DSOChangeAnalyzer, useValue: {} },
{ provide: BitstreamFormatDataService, useValue: {} },
{ provide: NotificationsService, useValue: {} },
{ provide: BitstreamDataService, useValue: bitstreamDataService },
],
});
}

describe('bitstream retrieval', () => {
describe('when the user is authorized and not logged in', () => {
beforeEach(() => {
init();
(authService.isAuthenticated as jasmine.Spy).and.returnValue(of(false));
initTestbed();
});
it('should redirect to the content link', waitForAsync(() => {
TestBed.runInInjectionContext(() => {
resolver(route, state).subscribe(() => {
expect(hardRedirectService.redirect).toHaveBeenCalledWith('bitstream-content-link', null, true);
},
);
});
}));
});
describe('when the user is authorized and logged in', () => {
beforeEach(() => {
init();
initTestbed();
});
it('should redirect to an updated content link', waitForAsync(() => {
TestBed.runInInjectionContext(() => {
resolver(route, state).subscribe(() => {
expect(hardRedirectService.redirect).toHaveBeenCalledWith('content-url-with-headers', null, true);
});
});
}));
});
describe('when the user is not authorized and logged in', () => {
beforeEach(() => {
init();
(authorizationService.isAuthorized as jasmine.Spy).and.returnValue(of(false));
initTestbed();
});
it('should navigate to the forbidden route', waitForAsync(() => {
TestBed.runInInjectionContext(() => {
resolver(route, state).subscribe(() => {
expect(router.createUrlTree).toHaveBeenCalledWith([getForbiddenRoute()]);
});
});
}));
});
describe('when the user is not authorized and not logged in', () => {
beforeEach(() => {
init();
(authService.isAuthenticated as jasmine.Spy).and.returnValue(of(false));
(authorizationService.isAuthorized as jasmine.Spy).and.returnValue(of(false));
initTestbed();
});
it('should navigate to the login page', waitForAsync(() => {

TestBed.runInInjectionContext(() => {
resolver(route, state).subscribe(() => {
expect(authService.setRedirectUrl).toHaveBeenCalled();
expect(router.createUrlTree).toHaveBeenCalledWith(['login']);
});
});
}));
});
});
});
Loading
Loading