Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: partial snapshot download requestes turned into POST #5633

Merged

Conversation

sfiorani
Copy link
Contributor

@sfiorani sfiorani commented Jan 7, 2025

This PR follows #5627 improving the snapshot download mechanism.

The Snapshot download request is now turned into a more robus POST request, removing the link to the native javascript code from the DownloadHelper class used before.

This PR also avoids also the problem that occurs when the session expires during the selection of the PIDs to be downloaded: indeed, if the session expired after the snapshot download popup spawned, clicking on one of the download button led to a sort of undefined state of the webUI that would stop working. With this PR, if the session expires the token generation fails and the correct error popup is shown correctly.


this.downloadJson.addClickHandler(e -> {
this.downloadModal.hide();
this.wiregraphDownloadConsumer.accept("JSON");
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to externalise the JSON and XML in constants?
It should help in keeping the alignment in the code in case of changes/refactorings

&& !checkBox.getText().equals(MSGS.removeAllAnchorText())) {
selectedPids.add(checkBox.getText());
if (checkBox.getValue().booleanValue()) {
selectedPidsBuilder.append(checkBox.getText() + ",");
Copy link
Contributor

Choose a reason for hiding this comment

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

is the trailing comma an issue for the last entry of this builder?

Copy link
Contributor Author

@sfiorani sfiorani Jan 8, 2025

Choose a reason for hiding this comment

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

The servlet that finally downloads the snapshot splits the string using the comma as separator, so the last comma just disappear without any effect. If you prefare I can add a final check that remove the last comma, let me know

Copy link
Contributor

Choose a reason for hiding this comment

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

up to you. just wanted to make sure we are aware and is covered for any potential corner case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a line that removes the last comma. The payload is more clear and it's more maintanable

private void downloadEntireSnapshot(Long snapshotId, String format) {
RequestQueue.submit(context -> this.gwtXSRFService.generateSecurityToken(context.callback(token -> {
xsrfTokenField.setValue(token.getToken());
pidsListField.setValue("EntireSnapshot");
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make more sense to download the entire snapshot if no pidsList is specified?
I am kind of scared of those magic values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you. Indeed, I started with the idea "EmptyValue --> Download All", but then I changed my mind to avoid empty values...but thinking about it, it's probably more secure and robust. I'll change it

@MMaiero MMaiero merged commit c78b94d into eclipse-kura:develop Jan 9, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants