Skip to content

Commit e85010c

Browse files
committed
Merge remote-tracking branch 'IQSS/develop' into indexingperf3
2 parents 6b8ba34 + f214ee4 commit e85010c

22 files changed

Lines changed: 572 additions & 81 deletions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## New Endpoint: POST `/dataverses/{id}/template/default/{templateId}`
2+
3+
A new endpoint has been implemented to set the default template to a given dataverse collection.
4+
5+
### Functionality
6+
- Sets the default template of the given dataverse collection.
7+
- You must have edit dataverse permission in the collection in order to use this endpoint.
8+
9+
## New Endpoint: DELETE `/dataverses/{id}/template/default`
10+
11+
A new endpoint has been implemented to remove the default template to a given dataverse collection.
12+
13+
### Functionality
14+
- Removes the default template of the given dataverse collection.
15+
- You must have edit dataverse permission in the collection in order to use this endpoint.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The My Data API now supports the `metadata_fields`, `sort` and `order`, `show_collections` and `fq` parameters, which enhances its functionality and brings it in line with the search API.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Bug Fix
2+
3+
Handles from hdl.handle.net with urls of `/citation` instead of `/dataset.xhtml` were not properly redirecting. This fix adds a lookup for alternate PID so `/citation` endpoint will redirect to `/dataset.xhtml`
4+
5+

doc/sphinx-guides/source/api/native-api.rst

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,50 @@ The fully expanded example above (without environment variables) looks like this
16391639
16401640
curl -H "X-Dataverse-key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X POST "https://demo.dataverse.org/api/dataverses/1/templates" --upload-file dataverse-template.json
16411641
1642+
Set a Default Template for a Collection
1643+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1644+
1645+
Sets a template as the default template for a collection:
1646+
1647+
.. code-block:: bash
1648+
1649+
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
1650+
export SERVER_URL=https://demo.dataverse.org
1651+
export ID=1
1652+
export TEMPLATEID=2
1653+
1654+
curl -H "X-Dataverse-key:$API_TOKEN" -X POST "$SERVER_URL/api/dataverses/$ID/template/default/$TEMPLATEID"
1655+
1656+
The fully expanded example above (without environment variables) looks like this:
1657+
1658+
.. code-block:: bash
1659+
1660+
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X POST "https://demo.dataverse.org/api/dataverses/1/template/default/2"
1661+
1662+
You must have Edit Dataverse permission within the given dataverse collection to invoke this api.
1663+
1664+
Remove a Default Template for a Collection
1665+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1666+
1667+
Remove a template as the default template for a collection(Note: the template is not deleted; it will still be available for use in the collection):
1668+
1669+
.. code-block:: bash
1670+
1671+
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
1672+
export SERVER_URL=https://demo.dataverse.org
1673+
export ID=1
1674+
1675+
1676+
curl -H "X-Dataverse-key:$API_TOKEN" -X DELETE "$SERVER_URL/api/dataverses/$ID/template/default"
1677+
1678+
The fully expanded example above (without environment variables) looks like this:
1679+
1680+
.. code-block:: bash
1681+
1682+
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X DELETE "https://demo.dataverse.org/api/dataverses/1/template/default"
1683+
1684+
You must have Edit Dataverse permission within the given dataverse collection to invoke this api.
1685+
16421686

16431687
Dataverse Role Assignment History
16441688
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -8690,6 +8734,16 @@ Parameters:
86908734
86918735
``per_page`` Number of results returned per page.
86928736
8737+
``metadata_fields`` Includes the requested fields for each dataset in the response. Multiple "metadata_fields" parameters can be used to include several fields. See :doc:`search` for further information on this parameter.
8738+
8739+
``show_collections`` Whether or not to include a list of parent and linked collections for each dataset search result.
8740+
8741+
``sort`` The sort field. Supported values include "name", "date" and "relevance".
8742+
8743+
``order`` The order in which to sort. Can either be "asc" or "desc".
8744+
8745+
``fq`` A filter query to filter the list returned. Multiple "fq" parameters can be used.
8746+
86938747
MyData Collection List
86948748
~~~~~~~~~~~~~~~~~~~~~~
86958749

doc/sphinx-guides/source/api/search.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Name Type Description
2727
q string The search term or terms. Using "title:data" will search only the "title" field. "*" can be used as a wildcard either alone or adjacent to a term (i.e. "bird*"). For example, https://demo.dataverse.org/api/search?q=title:data . For a list of fields to search, please see https://github.com/IQSS/dataverse/issues/2558 (for now).
2828
type string Can be either "dataverse", "dataset", or "file". Multiple "type" parameters can be used to include multiple types (i.e. ``type=dataset&type=file``). If omitted, all types will be returned. For example, https://demo.dataverse.org/api/search?q=*&type=dataset
2929
subtree string The identifier of the Dataverse collection to which the search should be narrowed. The subtree of this Dataverse collection and all its children will be searched. Multiple "subtree" parameters can be used to include multiple Dataverse collections. For example, https://demo.dataverse.org/api/search?q=data&subtree=birds&subtree=cats .
30-
sort string The sort field. Supported values include "name" and "date". See example under "order".
30+
sort string The sort field. Supported values include "name", "date" and "relevance". See example under "order".
3131
order string The order in which to sort. Can either be "asc" or "desc". For example, https://demo.dataverse.org/api/search?q=data&sort=name&order=asc
3232
per_page int The number of results to return per request. The default is 10. The max is 1000. See :ref:`iteration example <iteration-example>`.
3333
start int A cursor for paging through search results. See :ref:`iteration example <iteration-example>`.

docker-compose-dev.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ services:
141141
restart: on-failure
142142
ports:
143143
- "8983:8983"
144+
environment:
145+
- SOLR_OPTS=-Dsolr.jetty.request.header.size=102400
144146
networks:
145147
- dataverse
146148
command:

docker/compose/demo/compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ services:
141141
restart: on-failure
142142
ports:
143143
- "8983:8983"
144+
environment:
145+
- SOLR_OPTS=-Dsolr.jetty.request.header.size=102400
144146
networks:
145147
- dataverse
146148
command:

src/main/java/edu/harvard/iq/dataverse/CitationServlet.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
3838

3939
String persistentId = request.getParameter("persistentId");
4040
if (persistentId != null) {
41-
DvObject dob = dvObjectService.findByGlobalId(PidUtil.parseAsGlobalID(persistentId));
41+
GlobalId globalId = PidUtil.parseAsGlobalID(persistentId);
42+
DvObject dob = dvObjectService.findByGlobalId(globalId);
43+
if (dob == null) {
44+
// try to find with alternative PID
45+
dob = dvObjectService.findByAltGlobalId(globalId, DvObject.DType.Dataset);
46+
}
4247
if (dob != null) {
4348
if (dob instanceof Dataset) {
4449
response.sendRedirect("dataset.xhtml?persistentId=" + persistentId);

src/main/java/edu/harvard/iq/dataverse/api/AbstractApiBean.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,25 @@ protected Dataverse findDataverseOrDie( String dvIdtf ) throws WrappedResponse {
370370
}
371371
return dv;
372372
}
373+
374+
protected Template findTemplateOrDie(Long templateId, Dataverse dataverse) throws WrappedResponse {
375+
376+
List<Template> templates = new ArrayList<>();
377+
378+
templates.addAll(dataverse.getTemplates());
379+
templates.addAll(dataverse.getParentTemplates());
380+
381+
Template template = templates.stream()
382+
.filter(t -> Objects.equals(t.getId(), templateId))
383+
.findFirst()
384+
.orElse(null);
385+
386+
if (template == null) {
387+
throw new WrappedResponse(
388+
error(Response.Status.NOT_FOUND, "Can't find template with identifier='" + templateId + "'"));
389+
}
390+
return template;
391+
}
373392

374393
protected DataverseLinkingDataverse findDataverseLinkingDataverseOrDie(String dataverseId, String linkedDataverseId) throws WrappedResponse {
375394
DataverseLinkingDataverse dvld;

src/main/java/edu/harvard/iq/dataverse/api/Dataverses.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,6 +2031,45 @@ public Response createTemplate(@Context ContainerRequestContext crc, String body
20312031
}
20322032
}
20332033

2034+
@POST
2035+
@AuthRequired
2036+
@Path("{identifier}/template/default/{templateId}")
2037+
public Response setDefaultTemplate(@Context ContainerRequestContext crc,
2038+
@PathParam("identifier") String dvId,
2039+
@PathParam("templateId") Long templateId) {
2040+
2041+
try {
2042+
2043+
Dataverse dataverse = findDataverseOrDie(dvId);
2044+
Template template = findTemplateOrDie(templateId, dataverse);
2045+
DataverseRequest dvReq = createDataverseRequest(getRequestUser(crc));
2046+
SetDefaultTemplateCommand command = new SetDefaultTemplateCommand(template, dvReq, dataverse);
2047+
2048+
execCommand(command);
2049+
2050+
return ok(BundleUtil.getStringFromBundle("dataverse.setDefaultTemplate.success"));
2051+
2052+
} catch (WrappedResponse e) {
2053+
return e.getResponse();
2054+
}
2055+
}
2056+
2057+
@DELETE
2058+
@AuthRequired
2059+
@Path("{identifier}/template/default")
2060+
public Response removeDefaultTemplate(@Context ContainerRequestContext crc,
2061+
@PathParam("identifier") String dvId) {
2062+
try {
2063+
Dataverse dataverse = findDataverseOrDie(dvId);
2064+
RemoveDefaultTemplateCommand command = new RemoveDefaultTemplateCommand(createDataverseRequest(getRequestUser(crc)), dataverse);
2065+
execCommand(command);
2066+
return ok(BundleUtil.getStringFromBundle("dataverse.removeDefaultTemplate.success"));
2067+
} catch (WrappedResponse e) {
2068+
return e.getResponse();
2069+
}
2070+
}
2071+
2072+
20342073
@GET
20352074
@AuthRequired
20362075
@Path("{identifier}/allowedMetadataLanguages")

0 commit comments

Comments
 (0)