-
Notifications
You must be signed in to change notification settings - Fork 487
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
Expose export formats in native API #10739
base: develop
Are you sure you want to change the base?
Expose export formats in native API #10739
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@julian-schneider good idea! Thanks for the pull request. I left you some comments.
@GET | ||
@Path("exportFormats") | ||
public Response getExportFormats() { | ||
JsonArrayBuilder responseModel = Json.createArrayBuilder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider returning an object instead? Just this week I pushed a commit to return MPCONFIG options via API and I played with returning an array but ended up liking object better. Here's the code: 771d85a
I'm suggesting something like this:
{
"status": "OK",
"data": {
"OAI_ORE": {
"displayName": "OAI_ORE"
},
"oai_dc": {
"displayName": "Dublin Core"
}
}
}
Alternatively, perhaps you could add a second endpoint for getting info about a single export format (e.g. /api/info/exportFormats/oai_dc). That way you can easily get info on that format instead of having to search through an array to find the element that matches oai_dc
.
Just some thoughts! 😄 Maybe the array is actually better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah an object is probably better, especially with the increased amount of properties, so I switched this in cc99729
@Path("exportFormats") | ||
public Response getExportFormats() { | ||
JsonArrayBuilder responseModel = Json.createArrayBuilder(); | ||
ExportService.getInstance().getExportersLabels().forEach(labels -> responseModel.add(Json.createObjectBuilder().add("displayName", labels[0]).add("formatName", labels[1]))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is displayName and formatName enough? While we're doing this, should we add isHarvestable, mediaType, and isAvailableToUsers (isVisibleInUserInterface might be better)?
For XML exporters there even these methods:
public String getXMLNameSpace();
public String getXMLSchemaLocation();
public String getXMLSchemaVersion();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In cc99729 the additional properties you mentioned have been added, thanks for the recommendation!
@@ -4618,6 +4618,25 @@ The fully expanded example above (without environment variables) looks like this | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs look great. Can you please add a release note snippet? Please see https://guides.dataverse.org/en/6.3/developers/version-control.html#writing-a-release-note-snippet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has been added in 3f81981.
Get Export Formats | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Get the available export formats. The response contains a list of objects each containing the display name and format name for an available exporter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this include external exporters? I assume so. Can we please mention they are included as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, all exporters, standard and custom, are managed by the ExportService
, and are consequently all listed. I improved the docs in 3b2c8e5.
ExportService.getInstance().getExportersLabels().forEach(labels -> responseModel.add(Json.createObjectBuilder().add("displayName", labels[0]).add("formatName", labels[1]))); | ||
return ok(responseModel); | ||
} | ||
|
||
private Response getSettingResponseByKey(SettingsServiceBean.Key key) { | ||
String setting = settingsService.getValueForKey(key); | ||
if (setting != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just put this comment at the bottom. An API test would be nice. I can help you get started if you need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A basic API test has been added in 95d34c8, which compares the response to what should be expected from a Dataverse installation with the default set of exporters. Is this what you had in mind?
Thanks for your feedback @pdurbin - I will be absent for two weeks, so some time will pass before I revise this. See you then! |
The response is now an object, and contains more properties per format, as suggested. New response looks like this: (expand response)
|
@pdurbin I believe I have addressed all the feedback you gave, have a nice day! |
What this PR does / why we need it: The PR adds a method that exposes the full list of available exporters (display- and format names). This is especially useful for instances that have added custom formats.
Which issue(s) this PR closes: I know no pre-existing issues for this.
Suggestions on how to test this: New method found here:
/api/info/exportFormats
Does this PR introduce a user interface change? If mockups are available, please link/include them here: No, just API and documentation changes.
API answer looks like this:
Rendered docs entry looks like this:
Is there a release notes update needed for this change?:
New API method for listing the available exporters. Found at
/api/info/exportFormats
, produces display names and format names.