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

Refactor/remove custom MultipartFileSender to use Spring Boot Range requests #3009

Merged

Conversation

jonas-atmire
Copy link
Contributor

@jonas-atmire jonas-atmire commented Oct 15, 2020

References

Description

The custom MultipartFileSender was completely bypassing Spring Security & Spring automated tools.
This PR makes sure that we lean more towards the 'default' usages of the previously mentioned Spring Boot etc.

Instructions for Reviewers

Please add a more detailed description of the changes made by your PR. At a minimum, providing a bulleted list of changes in your PR is helpful to reviewers.

List of changes in this PR:

  • MultipartFileSender is renamed to HttpHeadersInitializer to more correctly reflect the functionality/usage
  • HttpHeadersInitializer been 'changed' to now only initialise the HTTPHeaders, apart from trying to handle a whole bunch of code itself (So that we can rely on the spring framework to handle the MultiPart file sending)
    • The HTTPHeaders will be used in the ResponseEntity given by any methods that need to reply with a downloaded file
  • The SitemapRestController is altered to adhere to the guidelines of returning a ResponseEntity as well
  • the BitstreamRestController returns a new ResponseEntity for the bitstream resource to properly handle the multipart file sending

Testing steps using REST

  • Setup the related REST code
  • Trigger a script that keeps output in a file
  • Trigger a GET call to that particular output bitstream (With an origin header)
  • Check that the header "Access-Control-Allow-Origin:" is returned as expected

Testing steps using Angular

  • Setup the related REST code
  • Setup the following Angular PR
  • Make sure to trigger a script that keeps output in a file.
  • Try to download that particular output bitstream
  • The bitstream should be properly 'downloaded', no CORS error should be logged, and the information of the logs should be shown in the UI

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & integration tests). Exceptions may be made if previously agreed upon.
  • My PR passes Checkstyle validation based on the Code Style Guide.
  • My PR includes Javadoc for all new (or modified) public methods and classes. It also includes Javadoc for large or complex private methods.
  • My PR passes all tests and includes new/updated Unit or Integration Tests based on the Code Testing Guide.
  • If my PR includes new, third-party dependencies (in any pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR modifies the REST API, I've linked to the REST Contract page (or open PR) related to this change.

@jonas-atmire jonas-atmire force-pushed the w2p-72494_export-script-output-travis-test branch from 4f5040f to 867aec4 Compare October 15, 2020 16:31
@jonas-atmire jonas-atmire changed the title W2p 72494 export script output travis test Refactor/remove custom MultipartFileSender to use Spring Boot Range requests Oct 15, 2020
@tdonohue tdonohue added this to Needs Reviewers Assigned in DSpace 7 Beta 5 via automation Oct 20, 2020
@tdonohue tdonohue added this to the 7.0beta5 milestone Oct 20, 2020
@tdonohue tdonohue self-requested a review October 22, 2020 14:54
@jonas-atmire jonas-atmire marked this pull request as ready for review October 27, 2020 10:56
@jonas-atmire jonas-atmire added hacktoberfest-accepted interface: REST API v7+ REST API for v7 and later (dspace-server-webapp module) labels Oct 27, 2020
@tdonohue tdonohue moved this from Needs Reviewers Assigned to Under Review in DSpace 7 Beta 5 Oct 29, 2020
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

@jonas-atmire : I gave this a code review & some basic testing today. First off, the code looks good.. there's just some missing JavaDocs & a few inline questions below that require cleanup.

I also tested this from commandline (using the same commands that I reported previously didn't work in this comment)... and I've found this seems to work great! I'm now seeing the headers that are automatically added by Spring Security like Access-Control-Allow-Origin and Access-Control-Expose-Headers. Previously, those were missing.

I've not yet had a chance to test it with the corresponding Angular UI PR (DSpace/dspace-angular#827) simply because that PR is outdated & needs a rebase to make it easier to test.

Overall this looks/works great. So, I'm only requesting JavaDocs additions / minor cleanup here. Once the Angular PR is ready again, I'll do a test of both together & then I expect to approve both. Thanks!

@tdonohue tdonohue self-requested a review November 12, 2020 15:42
@crosenbeck
Copy link

@jonas-atmire Thank you for your hard work on this PR and the changes that were made to this PR. It looks good to me as long as @tdonohue requested changes have been made.

Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

👍 @jonas-atmire and @Raf-atmire : Code looks great now. I also tested this today with the frontend PR (DSpace/dspace-angular#827) and it all works perfectly. Thanks again!

DSpace 7 Beta 5 automation moved this from Under Review to Reviewer Approved Nov 20, 2020
@tdonohue tdonohue merged commit d166d97 into DSpace:main Nov 20, 2020
DSpace 7 Beta 5 automation moved this from Reviewer Approved to Done Nov 20, 2020
DSpace 7 Beta 5 automation moved this from Done to Under Review Apr 15, 2021
DSpace 7 Beta 5 automation moved this from Under Review to Reviewer Approved Apr 15, 2021
DSpace 7 Beta 5 automation moved this from Reviewer Approved to Done Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interface: REST API v7+ REST API for v7 and later (dspace-server-webapp module)
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Refactor/remove custom MultipartFileSender to use Spring Boot Range requests
4 participants