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

Correct response of get controlled vocabulary by metadata and collection when NO controlled vocabulary is available for the specified metadata and collection #9239

Conversation

toniprieto
Copy link
Contributor

@toniprieto toniprieto commented Dec 20, 2023

References

Description

According to the RESTContract the operation to get controlled vocabulary by metadata and collection should return a 204 HTTP Code if the operation succeed but NO controlled vocabulary is available for the specified metadata and collection, but it returns a 400 HTTP code because of a NullPointerException. This PR corrects it avoiding this NPE.

Instructions for Reviewers

List of changes in this PR:

  • Avoids a NPE
  • Add a related missing test

This operation is not used by the current UI, I have seen it using DSpace/dspace-angular#2653, but it could be tested in HAL Browser:

  • Login into HAL Browser
  • Go to endpoint vocabularies
  • Perform a GET operation using dc.title as metadata and a valid uuid collection against /api/submission/vocabularies/search/byMetadataAndCollection?metadata=dc.title&collection=[valid-uuid-collection]

Checklist

  • 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 libraries/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 REST API endpoints, I've opened a separate REST Contract PR related to this change.
  • If my PR includes new configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

…ocabularies Endpoint when no controlled vocabulary is available for the specified metadata and collection
@tdonohue tdonohue added bug 1 APPROVAL pull request only requires a single approval to merge. component: controlled vocabulary Related to internal controlled vocabulary system port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release labels Dec 20, 2023
@alanorth
Copy link
Contributor

alanorth commented Jan 4, 2024

Good catch, @toniprieto! Tested on DSpace 7.6.1.

I verified that before the patch I was receiving an HTTP 400 in the HAL Browser and dspace.log:

2024-01-04 10:14:08,920 WARN unknown c144d168-8bd1-468c-89d1-ad5e92561a44 org.dspace.app.rest.exception.DSpaceApiExceptionControllerAdvice @ Request is invalid or incorrect (status: 400 exception: No choices plugin was configured for authorityName "null". at: org.dspace.content.authority.ChoiceAuthorityServiceImpl.getChoiceAuthorityByAuthorityName(ChoiceAuthorityServiceImpl.java:483))

After the patch I receive an HTTP 204 and an empty JSON body, which is exactly what the REST contract says should happen.

@alanorth alanorth self-requested a review January 4, 2024 07:31
@alanorth alanorth removed the port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release label Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 APPROVAL pull request only requires a single approval to merge. bug component: controlled vocabulary Related to internal controlled vocabulary system
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants