molgenis / molgenis-emx2

MOLGENIS EMX2, the latest version of the MOLGENIS data platform.
GNU Lesser General Public License v3.0
11 stars 16 forks source link

fix: FDP API various fixes #3833

Closed svandenhoek closed 1 month ago

svandenhoek commented 1 month ago

Sidenote: Not that familiar with sparkjava yet, so if there's something obvious I overlooked, do let me know.

What are the main changes you did:

  1. Fixed a bug where /api/fdp didn’t work if metadata was missing and being accessed by non-MANAGER. New behaviour simply returns the default String (and has a try-catch to set the metadata that fails until a MANAGER tried accessing it at least once).
  2. Fixed a bug where /api/fdp/ returned the output instead of /api/fdp (the latter one should be the actual URL according to the MOLGENIS documentation). Additionally, the non-slash version is used as IRI within the triples to indicate the FAIR data point.
  3. Changed head with text/turtle content type to be only triggered where a GET response is present returning Turtle data (=removed wildcard head call). This way a non text/turtle should indicate the user is using an invalid API URL.
  4. Fixed a bug where the triples belonging to the same subject weren’t outputted together.
    • Current fix requires the FAIR Data Point root metadata “Advanced settings” key to contain fully valid Turtle data. This will break instances where metadata is already stored in this variable! It will return an error message like “Namespace prefix 'lang' used but not defined [line 8]” and can easily be fixed by removing the keypair, as this will generate a new one which is valid.

how to test:

  1. On a FRESH INSTALL: Create a FAIR_DATA_HUB database with example data & check if /api/fdp works out-of-the-box while anonymous (f.e. curl http://localhost:8080/api/fdp)
  2. curl http://localhost:8080/api/fdp should now return data instead of curl http://localhost:8080/api/fdp/
  3. curl -I http://localhost:8080/api/fdp & curl -I http://localhost:8080/api/fdp/catalog/<fair_data_hub_database>/catalogId01 should still return Content-Type: text/turtle but f.e. curl -I http://localhost:8080/api/fdp/ or curl -I http://localhost:8080/api/fdp/catalog should not.
  4. curl -I http://localhost:8080/api/fdp should now have all triples belonging to http://localhost:8080/api/fdp together instead of some extra triples being pasted at the end.

todo:

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
4 New issues
0 Accepted issues

Measures
0 Security Hotspots
95.1% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud