Skip to content

Replace the element permission check with a batch endpoint - #209

Open
flomillot wants to merge 2 commits into
mainfrom
feat/batch-element-permissions
Open

Replace the element permission check with a batch endpoint#209
flomillot wants to merge 2 commits into
mainfrom
feat/batch-element-permissions

Conversation

@flomillot

@flomillot flomillot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Depends on gridsuite/directory-server#267.

HEAD /explore/elements/{uuid}?permission=… answers a single element with a 200 or a 403, so a client resolving several elements needs one call per element.

It is replaced by GET /explore/elements/accessible?ids=…&accessType=…, which returns the uuids the user has the given right on, the forbidden and the unknown ones being left out. It delegates to the directory-server endpoint added in the PR above.

HEAD /elements/{uuid} answered a single element with a 200 or a 403. The
new GET /elements/permission takes a list of element uuids and returns the
ones the user has the given right on, so a client resolving several
elements no longer needs one call per element.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b95e4928-ec66-44e5-858d-0615f7ae65f4


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

directoryService.checkPermission(List.of(elementUuid), null, userId, permission);
return ResponseEntity.ok().build();
public ResponseEntity<List<UUID>> getAccessibleElements(@RequestParam("ids") List<UUID> elementUuids,
@RequestParam(name = "accessType") PermissionType permission,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@RequestParam(name = "accessType") PermissionType permissionType,

@RequestParam(name = "accessType") PermissionType permission,
@RequestHeader(QUERY_PARAM_USER_ID) String userId) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON)
.body(directoryService.getAccessibleElements(elementUuids, userId, permission));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

.body(directoryService.getAccessibleElements(elementUuids, userId, permissionType));


@GetMapping(value = "/explore/elements/{elementUuid}")
@Operation(summary = "Check if user has a given right on a directory, or a single element by checking its parent")
@GetMapping(value = "/explore/elements/permission", produces = MediaType.APPLICATION_JSON_VALUE)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@GetMapping(value = "/explore/elements/accessible"

@GetMapping(value = "/explore/elements/{elementUuid}")
@Operation(summary = "Check if user has a given right on a directory, or a single element by checking its parent")
@GetMapping(value = "/explore/elements/permission", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get, among the given elements, the ones the user has the given right on, "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@operation(summary = "Filter the given elements to the ones the user has the given permission on, "
+ "a directory is checked on itself, any other element on its parent directory")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the , instead of and is not correct but OK for the rest

@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The user has the right on the element"),
@ApiResponse(responseCode = "204", description = "The user has not the right on the element"),
@ApiResponse(responseCode = "200", description = "The uuids of the elements the user has the right on"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

description = "The uuids of the given elements the user has the permission on"

HttpHeaders headers = new HttpHeaders();
headers.add(HEADER_USER_ID, userId);

String path = UriComponentsBuilder.fromPath(ELEMENTS_SERVER_ROOT_PATH + "/permission")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

String path = UriComponentsBuilder.fromPath(ELEMENTS_SERVER_ROOT_PATH + "/accessible")

The endpoint returns elements, not a permission, which its name now reflects,
along with the path it calls on directory-server. The controller parameter is
renamed permissionType, as the service it delegates to already named it, and
the operation and response descriptions are reworded accordingly.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants