Skip to content

Commit 42aa30c

Browse files
committed
Merge branch 'develop' into 11912-edit-template-api
2 parents 1bba876 + 6a144ac commit 42aa30c

23 files changed

Lines changed: 1161 additions & 261 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Croissant 1.1 (Summary Statistics)
2+
3+
The Croissant metadata export format has been updated from version 1.0 to 1.1.
4+
5+
Summary statistics (mean, min, max, etc.) are now included for tabular files that were successfully ingested.
6+
7+
You can download an example Croissant file from the [Supported Metadata Export Formats](https://dataverse-guide--12214.org.readthedocs.build/en/12214/user/dataset-management.html#supported-metadata-export-formats) section of the guides.
8+
9+
Minor backward-incompatible changes were made, which are noted below.
10+
11+
See #12014 and #12214
12+
13+
## Backward Incompatible Changes
14+
15+
Generally speaking, see the [API Changelog](https://guides.dataverse.org/en/latest/api/changelog.html) for a list of backward-incompatible API changes.
16+
17+
Minor changes in the `croissant` format are noted in the [API changelog](https://dataverse-guide--12214.org.readthedocs.build/en/12214/api/changelog.html).
18+
19+
## Upgrade Instructions
20+
21+
1. Re-export metadata export formats
22+
23+
We re-export because the Croissant format was updated.
24+
25+
`curl http://localhost:8080/api/admin/metadata/reExportAll`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## BUG
2+
Fixes 2 bugs
3+
1. missing "gbrids" in the signed url query parameter list will no longer include "&gbrids=" without a value
4+
2. For SPA, when a user attempting to download files with a guestbook response has no api token but is authenticated by bearer token, a temporary api token will be generated with an expiration of 1 minute which is used for signing and decoding the signed url.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a problem with S3 direct upload to datasets which using lower- or mixed-case PID authority/identifier in the database and to datasets using an alternative identifier for file storage.

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.11
11+
-----
12+
13+
- The Croissant :ref:`metadata export format <metadata-export-formats>` has been updated from version 1.0 to 1.1, which is reflected in the ``conformsTo`` property. ``@vocab`` and ``sc`` properties now use "http" as `recommended <https://github.com/mlcommons/croissant/pull/929#pullrequestreview-3079137662>`_. The unused ``wd`` property has been dropped.
14+
1015
v6.10
1116
-----
1217
- The following GET APIs will now return ``400`` if a required Guestbook Response is not supplied. A Guestbook Response can be passed to these APIs in the JSON body using a POST call. See the notes under :ref:`basic-file-access` and :ref:`download-by-dataset-by-version` for details.

doc/sphinx-guides/source/user/dataset-management.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Supported Metadata Export Formats
2828

2929
Once a dataset has been published, its metadata can be exported in a variety of other metadata standards and formats, which help make datasets more :doc:`discoverable </admin/discoverability>` and usable in other systems, such as other data repositories. On each dataset page's metadata tab, the following exports are available:
3030

31-
- Croissant
31+
- Croissant (example: :download:`max-croissant.json <../../../../src/test/resources/croissant/max/expected/max-croissant.json>`)
3232
- Dublin Core
3333
- DDI (Data Documentation Initiative Codebook 2.5)
3434
- DDI HTML Codebook (A more human-readable, HTML version of the DDI Codebook 2.5 metadata export)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,10 @@ public String getIdentifierForFileStorage(){
662662
return retVal;
663663
}
664664

665+
public String getGlobalIdForFileStorageAsString() {
666+
return getProtocolForFileStorage() + ":" + getAuthorityForFileStorage() + "/" + getIdentifierForFileStorage();
667+
}
668+
665669
public String getNextMajorVersionString() {
666670
// Never need to get the next major version for harvested studies.
667671
if (isHarvested()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ public void requestDirectUploadUrls() {
17061706
String storageIdentifier = null;
17071707
try {
17081708
storageIdentifier = FileUtil.getStorageIdentifierFromLocation(s3io.getStorageLocation());
1709-
urls = s3io.generateTemporaryS3UploadUrls(dataset.getGlobalId().asString(), storageIdentifier, fileSize);
1709+
urls = s3io.generateTemporaryS3UploadUrls(dataset.getGlobalIdForFileStorageAsString(), storageIdentifier, fileSize);
17101710

17111711
} catch (IOException io) {
17121712
logger.warning(io.getMessage());

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import edu.harvard.iq.dataverse.*;
1010
import edu.harvard.iq.dataverse.api.auth.AuthRequired;
11+
import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
1112
import edu.harvard.iq.dataverse.authorization.DataverseRole;
1213
import edu.harvard.iq.dataverse.authorization.Permission;
1314
import edu.harvard.iq.dataverse.authorization.RoleAssignee;
@@ -422,7 +423,7 @@ private Response processDatafileWithGuestbookResponse(ContainerRequestContext cr
422423

423424
// Handle Guestbook Responses
424425
String displayName = "";
425-
String gbrids = "";
426+
String gbrids = null;
426427
Long datasetId = null;
427428
try {
428429
// since all files must be in the same Dataset we can generate a Guestbook Response once and just replace the DataFile for each file in the list
@@ -487,8 +488,15 @@ private Response returnSignedUrl(ContainerRequestContext crc, UriInfo uriInfo, U
487488
if (user != null && user instanceof AuthenticatedUser) {
488489
AuthenticatedUser requestor = (AuthenticatedUser) user;
489490
userIdentifier = requestor.getUserIdentifier();
491+
// Find the latest token: Use for signing
492+
// Could be null if no token was generated: Generate one to be used for signing (expire in 1 minute to match timeout in signedUrl)
493+
// Could be expired: The user was already authenticated (possible by bearer token). Only used for signing so we don't care
490494
ApiToken apiToken = authSvc.findApiTokenByUser(requestor);
491-
if (apiToken != null && !apiToken.isExpired() && !apiToken.isDisabled()) {
495+
if (apiToken == null) {
496+
logger.fine("Generating temporary API token for user " + userIdentifier);
497+
apiToken = authSvc.generateApiTokenForUser(requestor, AuthenticationServiceBean.INTERVAL.MINUTES, 1);
498+
}
499+
if (apiToken != null) {
492500
key = apiToken.getTokenString();
493501
}
494502
} else {
@@ -499,7 +507,9 @@ private Response returnSignedUrl(ContainerRequestContext crc, UriInfo uriInfo, U
499507

500508
UriBuilder builder = UriBuilder.fromUri(uriInfo.getRequestUri());
501509
builder.replaceQueryParam("gbrecs", true);
502-
builder.replaceQueryParam("gbrids", gbrids);
510+
if (gbrids != null && !gbrids.isEmpty()) {
511+
builder.replaceQueryParam("gbrids", gbrids);
512+
}
503513
builder.replaceQueryParam("persistentId", null); // remove this as a parm and add the id to the path
504514
crc.setProperty("gbrids", gbrids);
505515
String baseUrlEncoded = builder.build().toString();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,7 @@ public Response getMPUploadUrls(@Context ContainerRequestContext crc, @PathParam
27982798
String storageIdentifier = null;
27992799
try {
28002800
storageIdentifier = FileUtil.getStorageIdentifierFromLocation(s3io.getStorageLocation());
2801-
response = s3io.generateTemporaryS3UploadUrls(dataset.getGlobalId().asString(), storageIdentifier, fileSize);
2801+
response = s3io.generateTemporaryS3UploadUrls(dataset.getGlobalIdForFileStorageAsString(), storageIdentifier, fileSize);
28022802

28032803
} catch (IOException io) {
28042804
logger.warning(io.getMessage());

0 commit comments

Comments
 (0)