Skip to content

Commit d6b36ef

Browse files
committed
Merge branch 'develop' of github.com:IQSS/dataverse into 11645-old-oidc-users-api-auth
2 parents 4697002 + e69cf6f commit d6b36ef

32 files changed

Lines changed: 1250 additions & 135 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Edit Dataset Metadata API extension
2+
3+
- This endpoint now allows removing fields (by sending empty values), as long as they are not required by the dataset.
4+
- New ``sourceLastUpdateTime`` optional query parameter, which prevents inconsistencies by managing updates that
5+
may occur from other users while a dataset is being edited.
6+
7+
NOTE: This release note was updated to conform to the refactoring of the validation as part of issue #11392
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
### Edit File Metadata empty values should clear data
2+
3+
Previously the API POST /files/{id}/metadata would ignore fields with empty values. Now the API updates the fields with the empty values essentially clearing the data. Missing fields will still be ignored.
4+
5+
An optional query parameter (sourceLastUpdateTime) was added to ensure the metadata update doesn't overwrite stale data.
6+
7+
See also [the guides](https://dataverse-guide--11359.org.readthedocs.build/en/11359/api/native-api.html#updating-file-metadata), #11392, and #11359.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The following APIs have now been blocked for Guest Users:
2+
3+
/api/v1/datasets/:persistentId/versions/:latest-published/downloadsize?persistentId=doi:10.5072/FK2/VSAYEM&includeDeaccessioned=true&mode=Archival
4+
/api/v1/datasets/:persistentId/versions/1.0/files/counts?persistentId=doi:10.5072/FK2/VSAYEM&includeDeaccessioned=true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The [API for listing the collections a dataset has been linked to](https://guides.dataverse.org/en/latest/admin/dataverses-datasets.html#list-collections-that-are-linked-from-a-dataset) (`api/datasets/$linked-dataset-id/links`) is no longer restricted to superusers. For unpublished datasets, users need the "View Unpublished Dataset" permission to access the API. Unpublished collections in the list require the "View Unpublished Dataverse" permission; otherwise, they are hidden.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
New endpoints have been implemented in the Dataverses API for the management of dataverse templates:
2+
3+
- POST `/dataverses/{id}/templates`: Creates a template for a given Dataverse collection ``id``.
4+
- GET `/dataverses/{id}/templates`: Lists the templates for a given Dataverse collection ``id``.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "Dataverse template",
3+
"isDefault": true,
4+
"fields": [
5+
{
6+
"typeName": "author",
7+
"value": [
8+
{
9+
"authorName": {
10+
"typeName": "authorName",
11+
"value": "Belicheck, Bill"
12+
},
13+
"authorAffiliation": {
14+
"typeName": "authorIdentifierScheme",
15+
"value": "ORCID"
16+
}
17+
}
18+
]
19+
}
20+
],
21+
"instructions": [
22+
{
23+
"instructionField": "author",
24+
"instructionText": "The author data"
25+
}
26+
]
27+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ This API changelog is experimental and we would love feedback on its usefulness.
77
:local:
88
:depth: 1
99

10+
v6.8
11+
----
12+
- For POST /api/files/{id}/metadata passing an empty string ("description":"") or array ("categories":[]) will no longer be ignored. Empty fields will now clear out the values in the file's metadata. To ignore the fields simply do not include them in the JSON string.
13+
- For PUT /api/datasets/{id}/editMetadata the query parameter "sourceInternalVersionNumber" has been removed and replaced with "sourceLastUpdateTime" to verify that the data being edited hasn't been modified and isn't stale.
14+
1015
v6.7
1116
----
1217

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

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,46 @@ The fully expanded example above (without environment variables) looks like this
14001400
14011401
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X GET "https://demo.dataverse.org/api/access/dataverseFeaturedItemImage/1"
14021402
1403+
List Templates of a Collection
1404+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1405+
1406+
Lists the templates for a given Dataverse collection ``id``:
1407+
1408+
.. code-block:: bash
1409+
1410+
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
1411+
export SERVER_URL=https://demo.dataverse.org
1412+
export ID=1
1413+
1414+
curl -H "X-Dataverse-key:$API_TOKEN" -X GET "$SERVER_URL/api/dataverses/{ID}/templates"
1415+
1416+
The fully expanded example above (without environment variables) looks like this:
1417+
1418+
.. code-block:: bash
1419+
1420+
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X GET "https://demo.dataverse.org/api/dataverses/1/templates"
1421+
1422+
Create a Template for a Collection
1423+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1424+
1425+
Creates a template for a given Dataverse collection ``id``.
1426+
1427+
To create the template, you must send a JSON file. Your JSON file might look like :download:`dataverse-template.json <../_static/api/dataverse-template.json>` which you would send to the Dataverse installation like this:
1428+
1429+
.. code-block:: bash
1430+
1431+
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
1432+
export SERVER_URL=https://demo.dataverse.org
1433+
export ID=1
1434+
1435+
curl -H "X-Dataverse-key: $API_TOKEN" -X POST "$SERVER_URL/api/dataverses/{ID}/templates" --upload-file dataverse-template.json
1436+
1437+
The fully expanded example above (without environment variables) looks like this:
1438+
1439+
.. code-block:: bash
1440+
1441+
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
1442+
14031443
Datasets
14041444
--------
14051445

@@ -1800,6 +1840,8 @@ The returned file counts are based on different criteria:
18001840
- Per tabular tag name
18011841
- Per access status (Possible values: Public, Restricted, EmbargoedThenRestricted, EmbargoedThenPublic, RetentionPeriodExpired)
18021842

1843+
Note: Authentication is required. This call will return a 403/Forbidden response for Guest users.
1844+
18031845
.. code-block:: bash
18041846
18051847
export SERVER_URL=https://demo.dataverse.org
@@ -2156,26 +2198,26 @@ For these edits your JSON file need only include those dataset fields which you
21562198

21572199
This endpoint also allows removing fields, as long as they are not required by the dataset. To remove a field, send an empty value (``""``) for individual fields. For multiple fields, send an empty array (``[]``). A sample JSON file for removing fields may be downloaded here: :download:`dataset-edit-metadata-delete-fields-sample.json <../_static/api/dataset-edit-metadata-delete-fields-sample.json>`
21582200

2159-
If another user updates the dataset version metadata before you send the update request, data inconsistencies may occur. To prevent this, you can use the optional ``sourceInternalVersionNumber`` query parameter. This parameter must include the internal version number corresponding to the dataset version being updated. Note that internal version numbers increase sequentially with each version update.
2201+
If another user updates the dataset version metadata before you send the update request, metadata inconsistencies may occur. To prevent this, you can use the optional ``sourceLastUpdateTime`` query parameter. This parameter must include the ``lastUpdateTime`` corresponding to the dataset version being updated. The date must be in the format ``yyyy-MM-dd'T'HH:mm:ss'Z'``.
21602202

2161-
If this parameter is provided, the update will proceed only if the internal version number remains unchanged. Otherwise, the request will fail with an error.
2203+
If this parameter is provided, the update will proceed only if the ``lastUpdateTime`` remains unchanged (meaning no one has updated the dataset metadata since you retrieved it). Otherwise, the request will fail with an error.
21622204

2163-
Example using ``sourceInternalVersionNumber``:
2205+
Example using ``sourceLastUpdateTime``:
21642206

21652207
.. code-block:: bash
21662208
21672209
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
21682210
export SERVER_URL=https://demo.dataverse.org
21692211
export PERSISTENT_IDENTIFIER=doi:10.5072/FK2/BCCP9Z
2170-
export SOURCE_INTERNAL_VERSION_NUMBER=5
2212+
export SOURCE_LAST_UPDATE_TIME=2025-04-25T13:58:28Z
21712213
2172-
curl -H "X-Dataverse-key: $API_TOKEN" -X PUT "$SERVER_URL/api/datasets/:persistentId/editMetadata?persistentId=$PERSISTENT_IDENTIFIER&replace=true&sourceInternalVersionNumber=$SOURCE_INTERNAL_VERSION_NUMBER" --upload-file dataset-update-metadata.json
2214+
curl -H "X-Dataverse-key: $API_TOKEN" -X PUT "$SERVER_URL/api/datasets/:persistentId/editMetadata?persistentId=$PERSISTENT_IDENTIFIER&replace=true&sourceLastUpdateTime=SOURCE_LAST_UPDATE_TIME" --upload-file dataset-update-metadata.json
21732215
21742216
The fully expanded example above (without environment variables) looks like this:
21752217

21762218
.. code-block:: bash
21772219
2178-
curl -H "X-Dataverse-key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X PUT "https://demo.dataverse.org/api/datasets/:persistentId/editMetadata/?persistentId=doi:10.5072/FK2/BCCP9Z&replace=true&sourceInternalVersionNumber=5" --upload-file dataset-update-metadata.json
2220+
curl -H "X-Dataverse-key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X PUT "https://demo.dataverse.org/api/datasets/:persistentId/editMetadata/?persistentId=doi:10.5072/FK2/BCCP9Z&replace=true&sourceLastUpdateTime=2025-04-25T13:58:28Z" --upload-file dataset-update-metadata.json
21792221
21802222
21812223
Delete Dataset Metadata
@@ -2781,6 +2823,7 @@ Get the size of Downloading all the files of a Dataset Version
27812823
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27822824

27832825
Shows the combined size in bytes of all the files available for download from version ``versionId`` of dataset ``id``.
2826+
Note: Authentication is required. This call will return a 403/Forbidden response for Guest users.
27842827

27852828
.. code-block:: bash
27862829
@@ -4730,6 +4773,8 @@ Updating File Metadata
47304773
47314774
Updates the file metadata for an existing file where ``ID`` is the database id of the file to update or ``PERSISTENT_ID`` is the persistent id (DOI or Handle) of the file. Requires a ``jsonString`` expressing the new metadata. No metadata from the previous version of this file will be persisted, so if you want to update a specific field first get the json with the above command and alter the fields you want.
47324775
4776+
An optional parameter, sourceLastUpdateTime=datetime (in format: ``yyyy-MM-dd'T'HH:mm:ss'Z'``), can be used to verify that the file metadata being edited has not been changed since you last retrieved it, thereby avoiding potential lost metadata updates. The value for sourceLastUpdateTime can be taken from ``lastUpdateTime`` in the response to get $SERVER_URL/api/files/$ID API call.
4777+
47334778
A curl example using an ``ID``
47344779
47354780
.. code-block:: bash
@@ -4750,25 +4795,26 @@ The fully expanded example above (without environment variables) looks like this
47504795
-F 'jsonData={"description":"My description bbb.","provFreeform":"Test prov freeform","categories":["Data"],"dataFileTags":["Survey"],"restrict":false}' \
47514796
"https://demo.dataverse.org/api/files/24/metadata"
47524797
4753-
A curl example using a ``PERSISTENT_ID``
4798+
A curl example using a ``PERSISTENT_ID`` and the sourceLastUpdateTime parameter:
47544799
47554800
.. code-block:: bash
47564801
47574802
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
47584803
export SERVER_URL=https://demo.dataverse.org
47594804
export PERSISTENT_ID=doi:10.5072/FK2/AAA000
4805+
export UPDATE_TIME=2025-04-25T13:58:28Z
47604806
47614807
curl -H "X-Dataverse-key:$API_TOKEN" -X POST \
47624808
-F 'jsonData={"description":"My description bbb.","provFreeform":"Test prov freeform","categories":["Data"],"dataFileTags":["Survey"],"restrict":false}' \
4763-
"$SERVER_URL/api/files/:persistentId/metadata?persistentId=$PERSISTENT_ID"
4809+
"$SERVER_URL/api/files/:persistentId/metadata?persistentId=$PERSISTENT_ID&sourceLastUpdateTime=$UPDATE_TIME"
47644810
47654811
The fully expanded example above (without environment variables) looks like this:
47664812
47674813
.. code-block:: bash
47684814
47694815
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -X POST \
47704816
-F 'jsonData={"description":"My description bbb.","provFreeform":"Test prov freeform","categories":["Data"],"dataFileTags":["Survey"],"restrict":false}' \
4771-
"https://demo.dataverse.org/api/files/:persistentId/metadata?persistentId=doi:10.5072/FK2/AAA000"
4817+
"https://demo.dataverse.org/api/files/:persistentId/metadata?persistentId=doi:10.5072/FK2/AAA000&sourceLastUpdateTime=2025-04-25T13:58:28Z"
47724818
47734819
Note: To update the 'tabularTags' property of file metadata, use the 'dataFileTags' key when making API requests. This property is used to update the 'tabularTags' of the file metadata.
47744820

doc/sphinx-guides/source/user/appendix.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ Supported Metadata
2323
Detailed below are what metadata schemas we support for Citation and Domain Specific Metadata in the Dataverse Project:
2424

2525
- Citation Metadata (`see .tsv <https://github.com/IQSS/dataverse/blob/master/scripts/api/data/metadatablocks/citation.tsv>`__): compliant with `DDI Lite <https://www.ddialliance.org/specification/ddi2.1/lite/index.html>`_, `DDI 2.5 Codebook <https://www.ddialliance.org/>`__, `DataCite 4.5 <https://schema.datacite.org/meta/kernel-4.5/>`__, and Dublin Core's `DCMI Metadata Terms <https://dublincore.org/documents/dcmi-terms/>`__ . Language field uses `ISO 639-1 <https://www.loc.gov/standards/iso639-2/php/English_list.php>`__ controlled vocabulary.
26-
- Geospatial Metadata (`see .tsv <https://github.com/IQSS/dataverse/blob/master/scripts/api/data/metadatablocks/geospatial.tsv>`__): compliant with `DDI Lite <https://www.ddialliance.org/specification/ddi2.1/lite/index.html>`_, `DDI 2.5 Codebook <https://www.ddialliance.org/>`__, `DataCite 4.5 <https://schema.datacite.org/meta/kernel-4.5/>`__, and Dublin Core. Country / Nation field uses `ISO 3166-1 <https://en.wikipedia.org/wiki/ISO_3166-1>`_ controlled vocabulary.
26+
- Geospatial Metadata (`see .tsv <https://github.com/IQSS/dataverse/blob/master/scripts/api/data/metadatablocks/geospatial.tsv>`__): compliant with `DDI Lite <https://www.ddialliance.org/specification/ddi2.1/lite/index.html>`_, `DDI 2.5 Codebook <https://www.ddialliance.org/>`__, `DataCite 4.5 <https://schema.datacite.org/meta/kernel-4.5/>`__, and Dublin Core. Country / Nation field uses `ISO 3166-1 <https://en.wikipedia.org/wiki/ISO_3166-1>`_ controlled vocabulary.
27+
28+
- Please note that a new and improved Geospatial metadata block is being proposed at `<https://github.com/IQSS/dataverse/pull/11507>`__. We encourage you to try the block and give feedback in that pull request.
2729
- Social Science & Humanities Metadata (`see .tsv <https://github.com/IQSS/dataverse/blob/master/scripts/api/data/metadatablocks/social_science.tsv>`__): compliant with `DDI Lite <https://www.ddialliance.org/specification/ddi2.1/lite/index.html>`_, `DDI 2.5 Codebook <https://www.ddialliance.org/>`__, and Dublin Core.
2830
- Astronomy and Astrophysics Metadata (`see .tsv <https://github.com/IQSS/dataverse/blob/master/scripts/api/data/metadatablocks/astrophysics.tsv>`__): These metadata elements can be mapped/exported to the International Virtual Observatory Alliance’s (IVOA)
2931
`VOResource Schema format <https://www.ivoa.net/documents/latest/RM.html>`__ and is based on

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
77
import edu.harvard.iq.dataverse.authorization.providers.builtin.BuiltinUserServiceBean;
88
import edu.harvard.iq.dataverse.dataverse.featured.DataverseFeaturedItemServiceBean;
9+
import edu.harvard.iq.dataverse.license.LicenseServiceBean;
910
import edu.harvard.iq.dataverse.util.cache.CacheFactoryBean;
1011
import edu.harvard.iq.dataverse.engine.DataverseEngine;
1112
import edu.harvard.iq.dataverse.authorization.Permission;
@@ -192,6 +193,9 @@ public class EjbDataverseEngine {
192193
@EJB
193194
DataverseFeaturedItemServiceBean dataverseFeaturedItemServiceBean;
194195

196+
@EJB
197+
LicenseServiceBean licenseServiceBean;
198+
195199
@EJB
196200
DatasetFieldsValidator datasetFieldsValidator;
197201

@@ -541,6 +545,11 @@ public DatasetFieldsValidator datasetFieldsValidator() {
541545
return datasetFieldsValidator;
542546
}
543547

548+
@Override
549+
public LicenseServiceBean licenses() {
550+
return licenseServiceBean;
551+
}
552+
544553
@Override
545554
public StorageUseServiceBean storageUse() {
546555
return storageUseService;

0 commit comments

Comments
 (0)