Skip to content

Commit f5dc1c1

Browse files
committed
[DSC-1974] Use preventMetadataSecurity projection for browse pages
1 parent 66bc5ac commit f5dc1c1

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/app/core/browse/browse-entry-search-options.model.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export class BrowseEntrySearchOptions {
1616
public sort?: SortOptions,
1717
public startsWith?: string,
1818
public scope?: string,
19-
public fetchThumbnail?: boolean) {
19+
public fetchThumbnail?: boolean,
20+
public projection?: string,
21+
) {
2022
}
2123
}

src/app/core/browse/browse.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ export class BrowseService {
148148
if (isNotEmpty(filterAuthority)) {
149149
args.push(`filterAuthority=${encodeURIComponent(filterAuthority)}`);
150150
}
151+
if (isNotEmpty(options.projection)) {
152+
args.push(`projection=${options.projection}`);
153+
}
151154
if (isNotEmpty(args)) {
152155
href = new URLCombiner(href, `?${args.join('&')}`).toString();
153156
}

src/app/core/browse/search-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export class SearchManager {
4545
* @returns {Observable<RemoteData<PaginatedList<Item>>>}
4646
*/
4747
getBrowseItemsFor(filterValue: string, filterAuthority: string, options: BrowseEntrySearchOptions, ...linksToFollow: FollowLinkConfig<any>[]): Observable<RemoteData<PaginatedList<Item>>> {
48-
return this.browseService.getBrowseItemsFor(filterValue, filterAuthority, options, ...linksToFollow)
48+
const browseOptions = Object.assign({}, options, { projection: 'preventMetadataSecurity' });
49+
return this.browseService.getBrowseItemsFor(filterValue, filterAuthority, browseOptions, ...linksToFollow)
4950
.pipe(this.completeWithExtraData());
5051
}
5152

src/app/core/browse/search.manager.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ describe('SearchManager', () => {
130130

131131
const filterValue = 'filterValue';
132132
const filterAuthority = null;
133-
const options: BrowseEntrySearchOptions = { options: null} as any;
133+
const browseOptions: BrowseEntrySearchOptions = Object.assign({}, { projection: 'preventMetadataSecurity' }) as BrowseEntrySearchOptions;
134134
const followLink: FollowLinkConfig<any> = {} as any;
135135

136-
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, options, followLink).subscribe());
136+
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, browseOptions, followLink).subscribe());
137137
scheduler.flush();
138138

139-
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, null, options, followLink);
139+
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, null, browseOptions, followLink);
140140
expect(mockItemService.findAllById).toHaveBeenCalledWith([validAuthority, validAuthority2]);
141141

142142
});
@@ -145,13 +145,13 @@ describe('SearchManager', () => {
145145

146146
const filterValue = 'filterValue';
147147
const filterAuthority = 'filterAuthority';
148-
const options: BrowseEntrySearchOptions = { options: null} as any;
148+
const browseOptions: BrowseEntrySearchOptions = Object.assign({}, { projection: 'preventMetadataSecurity' }) as BrowseEntrySearchOptions;
149149
const followLink: FollowLinkConfig<any> = {} as any;
150150

151-
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, options, followLink).subscribe());
151+
scheduler.schedule(() => service.getBrowseItemsFor(filterValue, filterAuthority, browseOptions, followLink).subscribe());
152152
scheduler.flush();
153153

154-
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, filterAuthority, options, followLink);
154+
expect(mockBrowseService.getBrowseItemsFor).toHaveBeenCalledWith(filterValue, filterAuthority, browseOptions, followLink);
155155
expect(mockItemService.findAllById).toHaveBeenCalledWith([validAuthority, validAuthority2]);
156156

157157
});

0 commit comments

Comments
 (0)