Skip to content

Commit c1813b1

Browse files
authored
Merge pull request #5117 from toniprieto/find-authorized-endpoints-9x
[Port dspace-9_x] Update DSO creation and edition selectors in admin menu to use more specific authorization endpoints
2 parents 64f42c3 + 4c0f0c0 commit c1813b1

22 files changed

+483
-51
lines changed

src/app/core/data/collection-data.service.ts

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,47 @@ export class CollectionDataService extends ComColDataService<Collection> {
6666
}
6767

6868
/**
69-
* Get all collections the user is authorized to submit to
69+
* Get all collections the user is admin of
70+
*
71+
* @param query limit the returned collection to those with metadata values
72+
* matching the query terms.
73+
* @param options The [[FindListOptions]] object
74+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
75+
* no valid cached version. Defaults to true
76+
* @param reRequestOnStale Whether or not the request should automatically be re-
77+
* requested after the response becomes stale
78+
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
79+
* {@link HALLink}s should be automatically resolved
80+
* @return Observable<RemoteData<PaginatedList<Collection>>>
81+
* collection list
82+
*/
83+
getAdminAuthorizedCollection(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<PaginatedList<Collection>>> {
84+
const searchHref = 'findAdminAuthorized';
85+
return this.getAuthorizedCollection(query, options, useCachedVersionIfAvailable, reRequestOnStale, searchHref, ...linksToFollow);
86+
}
87+
88+
/**
89+
* Get all collections the user is authorized to edit
90+
*
91+
* @param query limit the returned collection to those with metadata values
92+
* matching the query terms.
93+
* @param options The [[FindListOptions]] object
94+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
95+
* no valid cached version. Defaults to true
96+
* @param reRequestOnStale Whether or not the request should automatically be re-
97+
* requested after the response becomes stale
98+
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
99+
* {@link HALLink}s should be automatically resolved
100+
* @return Observable<RemoteData<PaginatedList<Collection>>>
101+
* collection list
102+
*/
103+
getEditAuthorizedCollection(query: string,options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<PaginatedList<Collection>>> {
104+
const searchHref = 'findEditAuthorized';
105+
return this.getAuthorizedCollection(query, options, useCachedVersionIfAvailable, reRequestOnStale, searchHref, ...linksToFollow);
106+
}
107+
108+
/**
109+
* Get all collections the user is authorized to submit
70110
*
71111
* @param query limit the returned collection to those with metadata values
72112
* matching the query terms.
@@ -77,7 +117,27 @@ export class CollectionDataService extends ComColDataService<Collection> {
77117
* requested after the response becomes stale
78118
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
79119
* {@link HALLink}s should be automatically resolved
120+
* @return Observable<RemoteData<PaginatedList<Collection>>>
121+
* collection list
122+
*/
123+
getSubmitAuthorizedCollection(query: string,options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Collection>[]): Observable<RemoteData<PaginatedList<Collection>>> {
124+
const searchHref = 'findSubmitAuthorized';
125+
return this.getAuthorizedCollection(query, options, useCachedVersionIfAvailable, reRequestOnStale, searchHref, ...linksToFollow);
126+
}
127+
128+
/**
129+
* Get all collections the user is authorized to perform a specific action on
130+
*
131+
* @param query limit the returned collection to those with metadata values
132+
* matching the query terms.
133+
* @param options The [[FindListOptions]] object
134+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
135+
* no valid cached version. Defaults to true
136+
* @param reRequestOnStale Whether or not the request should automatically be re-
137+
* requested after the response becomes stale
80138
* @param searchHref The backend search endpoint to use (default to submit)
139+
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
140+
* {@link HALLink}s should be automatically resolved
81141
* @return Observable<RemoteData<PaginatedList<Collection>>>
82142
* collection list
83143
*/

src/app/core/data/community-data.service.ts

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,66 @@ export class CommunityDataService extends ComColDataService<Community> {
4040
super('communities', requestService, rdbService, objectCache, halService, comparator, notificationsService, bitstreamDataService);
4141
}
4242

43+
/**
44+
* Get all communities the user is admin of
45+
*
46+
* @param query limit the returned collection to those with metadata values
47+
* matching the query terms.
48+
* @param options The [[FindListOptions]] object
49+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
50+
* no valid cached version. Defaults to true
51+
* @param reRequestOnStale Whether or not the request should automatically be re-
52+
* requested after the response becomes stale
53+
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
54+
* {@link HALLink}s should be automatically resolved
55+
* @return Observable<RemoteData<PaginatedList<Community>>>
56+
* community list
57+
*/
58+
getAdminAuthorizedCommunity(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Community>[]): Observable<RemoteData<PaginatedList<Community>>> {
59+
const searchHref = 'findAdminAuthorized';
60+
return this.getAuthorizedCommunity(query, options, useCachedVersionIfAvailable, reRequestOnStale, searchHref, ...linksToFollow);
61+
}
62+
63+
/**
64+
* Get all communities the user is authorized to add a new subcommunity or collection to
65+
*
66+
* @param query limit the returned collection to those with metadata values
67+
* matching the query terms.
68+
* @param options The [[FindListOptions]] object
69+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
70+
* no valid cached version. Defaults to true
71+
* @param reRequestOnStale Whether or not the request should automatically be re-
72+
* requested after the response becomes stale
73+
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
74+
* {@link HALLink}s should be automatically resolved
75+
* @return Observable<RemoteData<PaginatedList<Community>>>
76+
* community list
77+
*/
78+
getAddAuthorizedCommunity(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Community>[]): Observable<RemoteData<PaginatedList<Community>>> {
79+
const searchHref = 'findAddAuthorized';
80+
return this.getAuthorizedCommunity(query, options, useCachedVersionIfAvailable, reRequestOnStale, searchHref, ...linksToFollow);
81+
}
82+
83+
/**
84+
* Get all communities the user is authorized to edit
85+
*
86+
* @param query limit the returned collection to those with metadata values
87+
* matching the query terms.
88+
* @param options The [[FindListOptions]] object
89+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
90+
* no valid cached version. Defaults to true
91+
* @param reRequestOnStale Whether or not the request should automatically be re-
92+
* requested after the response becomes stale
93+
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
94+
* {@link HALLink}s should be automatically resolved
95+
* @return Observable<RemoteData<PaginatedList<Community>>>
96+
* community list
97+
*/
98+
getEditAuthorizedCommunity(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Community>[]): Observable<RemoteData<PaginatedList<Community>>> {
99+
const searchHref = 'findEditAuthorized';
100+
return this.getAuthorizedCommunity(query, options, useCachedVersionIfAvailable, reRequestOnStale, searchHref, ...linksToFollow);
101+
}
102+
43103
/**
44104
* Get all communities the user is authorized to submit to
45105
*
@@ -50,13 +110,13 @@ export class CommunityDataService extends ComColDataService<Community> {
50110
* no valid cached version. Defaults to true
51111
* @param reRequestOnStale Whether or not the request should automatically be re-
52112
* requested after the response becomes stale
113+
* @param searchHref The search endpoint to use, defaults to 'findAdminAuthorized'
53114
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
54115
* {@link HALLink}s should be automatically resolved
55116
* @return Observable<RemoteData<PaginatedList<Community>>>
56117
* community list
57118
*/
58-
getAuthorizedCommunity(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Community>[]): Observable<RemoteData<PaginatedList<Community>>> {
59-
const searchHref = 'findAdminAuthorized';
119+
getAuthorizedCommunity(query: string, options: FindListOptions = {}, useCachedVersionIfAvailable = true, reRequestOnStale = true, searchHref: string = 'findAdminAuthorized', ...linksToFollow: FollowLinkConfig<Community>[]): Observable<RemoteData<PaginatedList<Community>>> {
60120
options = Object.assign({}, options, {
61121
searchParams: [new RequestParam('query', query)],
62122
});

src/app/core/data/item-data.service.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
switchMap,
1919
take,
2020
} from 'rxjs/operators';
21+
import { FollowLinkConfig } from 'src/app/shared/utils/follow-link-config.model';
2122

2223
import {
2324
hasValue,
@@ -57,6 +58,7 @@ import {
5758
PatchData,
5859
PatchDataImpl,
5960
} from './base/patch-data';
61+
import { SearchDataImpl } from './base/search-data';
6062
import { BundleDataService } from './bundle-data.service';
6163
import { DSOChangeAnalyzer } from './dso-change-analyzer.service';
6264
import { FindListOptions } from './find-list-options.model';
@@ -83,6 +85,7 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
8385
private createData: CreateData<Item>;
8486
private patchData: PatchData<Item>;
8587
private deleteData: DeleteData<Item>;
88+
private searchData: SearchDataImpl<Item>;
8689

8790
protected constructor(
8891
protected linkPath,
@@ -101,6 +104,7 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
101104
this.createData = new CreateDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive);
102105
this.patchData = new PatchDataImpl<Item>(this.linkPath, requestService, rdbService, objectCache, halService, comparator, this.responseMsToLive, this.constructIdEndpoint);
103106
this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint);
107+
this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
104108
}
105109

106110
/**
@@ -348,6 +352,26 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
348352
);
349353
}
350354

355+
/**
356+
* Find the list of items for which the current user has editing rights.
357+
*
358+
* @param query limit the returned collection to those with metadata values
359+
* matching the query terms
360+
* @param options The [[FindListOptions]] object
361+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
362+
* no valid cached version. Defaults to true
363+
* @param reRequestOnStale Whether or not the request should automatically be re-
364+
* requested after the response becomes stale
365+
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
366+
* {@link HALLink}s should be automatically resolved
367+
* @return Observable<RemoteData<PaginatedList<Item>>>
368+
* item list
369+
*/
370+
public findEditAuthorized(query: string, options: FindListOptions, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig<Item>[]): Observable<RemoteData<PaginatedList<Item>>> {
371+
options = { ...options, searchParams: [new RequestParam('query', query)] };
372+
return this.searchBy('findEditAuthorized', options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
373+
}
374+
351375
/**
352376
* Invalidate the cache of the item
353377
* @param itemUUID
@@ -364,6 +388,24 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
364388
this.patchData.commitUpdates(method);
365389
}
366390

391+
/**
392+
* Make a new FindListRequest with given search method
393+
*
394+
* @param searchMethod The search method for the object
395+
* @param options The [[FindListOptions]] object
396+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
397+
* no valid cached version. Defaults to true
398+
* @param reRequestOnStale Whether or not the request should automatically be re-
399+
* requested after the response becomes stale
400+
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
401+
* {@link HALLink}s should be automatically resolved
402+
* @return {Observable<RemoteData<PaginatedList<T>>}
403+
* Return an observable that emits response from the server
404+
*/
405+
public searchBy(searchMethod: string, options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<Item>[]): Observable<RemoteData<PaginatedList<Item>>> {
406+
return this.searchData.searchBy(searchMethod, options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow);
407+
}
408+
367409
/**
368410
* Send a patch request for a specified object
369411
* @param {T} object The object to send a patch request for

0 commit comments

Comments
 (0)