CVOC : add HTTP request headers (Ontoportal integration)
What this PR does / why we need it:
Add HTTP headers customization for :CVocConf settings. This is needed for Ontoportal integration as a external vocabulary services, which required API KEY provided by HTTP request headers.
Which issue(s) this PR closes:
Closes #10316
Suggestions on how to test this:
Add :CVocConf to a external vocabulary service, with header customization :
"headers": {
"Accept": "application/xml",
"Cache-Control": "no-cache"
}
Replace XXX below by the external vocabulary service protocol configured.
Verify if span[data-cvoc-protocol="XXX"][data-cvoc-headers] in advanced search page and dataset page (with metadata tab open) have the configuration previously configured. Verify if input[data-cvoc-protocol="XXX"][data-cvoc-headers] in edition dataset page have also the configuration.
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No
coverage: 20.274% (-0.002%) from 20.276% when pulling 61ecb32e1e9836a613cea2f71e8376dee400ac4f on Recherche-Data-Gouv:10316_cvoc_http_headers into 82585f91e2a4367b284350c2b8923387a507685e on IQSS:develop.
This pull request is in need of documentation. It probably shouldn't have been approved.
But I'll add what I can @jeromeroucou while I'm testing it.
I'll also merge from develop to get the latest code.
@jeromeroucou I don't have permission to push to your branch:
$ git push Recherche-Data-Gouv 10316_cvoc_http_headers
ERROR: Permission to Recherche-Data-Gouv/dataverse.git denied to pdurbin.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Can you please...
- merge the latest from develop into your branch
- add documentation for the future version of https://guides.dataverse.org/en/6.2/installation/config.html#cvocconf
- add a short release note snippet at
doc/release-notes/10316_cvoc_http_headers.md(see https://guides.dataverse.org/en/6.2/developers/version-control.html#writing-a-release-note-snippet )
FWIW: There is documentation in https://github.com/gdcc/dataverse-external-vocab-support/pull/19/files
FWIW: There is a combined release note in #10404. There is no documentation of the contents of the Cvoc conf setting in the guides as it references the repository with all of the scripts and the schema etc.
@jeromeroucou no pressure, but there's a box you can check to allow edits:
Hi @pdurbin
I merge develop branch and add a minimal release note snippet. But I doesn't have the checkbox "Allow edits by maintainers". Is it related to this discussion ? If needed, I'll verify to allow you to push on dataverse project on Recherche-Data-Gouv organization.
FWIW: There is a combined release note in #10404. There is no documentation of the contents of the Cvoc conf setting in the guides as it references the repository with all of the scripts and the schema etc.
A combined release note yes, but nothing at the future version of https://guides.dataverse.org/en/6.2/installation/config.html#cvocconf
I'm not very happy with this situation that there is basically no documentation in the guides proper. Pull requests like this one are changing the behavior of the main app.
I'm not picky about where in the guides the documentation goes. Would you prefer it in https://guides.dataverse.org/en/6.2/admin/metadatacustomization.html#using-external-vocabulary-services than https://guides.dataverse.org/en/6.2/installation/config.html#cvocconf ?
@jeromeroucou thanks for merging the latest from the develop and adding a release not snippet. I think the lack of docs is the last thing (though I haven't tested anything).
As for giving me push access to your entire fork, I didn't realize that's what I was asking for. I always assumed checking that box (which you don't have!) allowed me to push to that specific branch, not the entire repo.
I have two suggested changes and I also can't see how to commit to or create a PR against your branch. f4da07d puts in a sleep to address a failing test and fa4a03c notes that adding headers is now allowed in the docs (also notes we have an ROR example script along with SkosMos and ORCID these days.
@qqmyers I would suggest making a PR into this PR, like I did:
- https://github.com/Recherche-Data-Gouv/dataverse/pull/4
For some reason, Recherche-Data-Gouv isn't showing as a possible target when I try to make a PR: https://github.com/IQSS/dataverse/compare/develop...GlobalDataverseCommunityConsortium:dataverse:10316_cvoc_http_headers_QA_changes?expand=1 . I'm not sure why.
@qqmyers I had to hack on the URL like this:
https://github.com/Recherche-Data-Gouv/dataverse/compare/10316_cvoc_http_headers...IQSS:dataverse:10316-docs
OK - that worked - I was able to make PR #5. Thanks!
I configured the following:
[
{
"headers": {
"Accept": "application/json",
"Authorization": "Basic YWxhZGRpbjpvcGVuc2VzYW1l"
},
"field-name": "authorAffiliation",
"term-uri-field": "authorAffiliation",
"js-url": ["/logos/cvoc/js/ror.js","/logos/cvoc/js/cvocutils.js"],
"protocol": "ror",
"retrieval-uri": "https://api.ror.org/organizations/{0}",
"allow-free-text": true,
"prefix": "https://ror.org/",
"managed-fields": {},
"languages":"",
"vocabs": {
"rors": {
"uriSpace": "https://ror.org/"
}
},
"retrieval-filtering": {
"@context": {
"termName": "https://schema.org/name",
"scheme": "http://www.w3.org/2004/02/skos/core#inScheme",
"lang": "@language",
"content": "@value"
},
"scheme": {
"pattern": "http://www.grid.ac/ontology/"
},
"termName": {
"pattern": "{0}",
"params": ["/name"]
},
"@type": {
"pattern": "https://schema.org/Organization"
}
}
}
]
I used https://github.com/gdcc/dataverse-external-vocab-support/blob/02928cb3148143506e41c7904cdf4f934a595bad/scripts/ror.js as a starting point but added the "headers" object from this PR and put the js in the logos directory because it's served up. Here's my Docker container:
payara@dataverse:/dv/docroot$ find /dv/docroot/logos
/dv/docroot/logos
/dv/docroot/logos/temp
/dv/docroot/logos/cvoc
/dv/docroot/logos/cvoc/js
/dv/docroot/logos/cvoc/js/cvocutils.js
/dv/docroot/logos/cvoc/js/ror.js
/dv/docroot/logos/1
/dv/docroot/logos/1/9568-homer.png
Lookup in ROR for author affiliation works fine and the headers seem to be present in the three places I was asked to check:
Merging.