Skip to content

Commit 4069180

Browse files
authored
Merge branch 'develop' into 11733-api-get-file-citation-format
2 parents 4370bb7 + ec1b65b commit 4069180

45 files changed

Lines changed: 568 additions & 105 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## Bug: Publish and Submit for review must contain files
2+
When `requireFilesToPublishDataset` is set on a Dataverse a Dataset must contain files to be published or submitted for review. This fix make sure the dataset version contains files, and not just the dataset. It also adds this check to the `Submit for Review` functionality.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This release changes the display behavior of the file, dataset and collection ("dataverse") pages for tabular files. They will show the original file name and information, and will allow editing of the original file name. The ingested *.tab version is still available from the download menu.
2+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Feature: Extend List File Access Requests API ###
2+
3+
Added ability to get access request history via the `/datafile/{id}/listRequests` API. The API returns a list of users/groups where the request for access is waiting for an accept or reject. Already accepted or rejected requests are not returned.
4+
5+
By adding the flag 'includeHistory=true' all of the requests will be returned. Pagination is also implemented in this feature. Adding a start page parameter and max list size (`&start=0` and `&per_page=20`) can limit the amount of data being returned.
6+
7+
See https://guides.dataverse.org/en/latest/api/dataaccess.html#list-file-access-requests
8+

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ This API changelog is experimental and we would love feedback on its usefulness.
1010
v6.11
1111
-----
1212

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.
13+
- The following API will now return ``403`` if the ``requireFilesToPublishDataset`` flag is set and the dataset version contains 0 files.
14+
15+
- **/api/datasets/{Id}/submitForReview**
16+
17+
- 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. The unused ``wd`` property has been dropped.
1418

1519
v6.10
1620
-----

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,22 @@ This method returns a list of Authenticated Users who have requested access to t
460460

461461
A curl example using an ``id``::
462462

463-
curl -H "X-Dataverse-key:$API_TOKEN" -X GET http://$SERVER/api/access/datafile/{id}/listRequests
463+
curl -H "X-Dataverse-key:$API_TOKEN" -X GET $SERVER/api/access/datafile/{id}/listRequests
464+
465+
Query parameters have been added to retrieve the historical list of "created", "granted", and "rejected" requests:
466+
467+
* `includeHistory` When `true` this will force the return of all requests and not just the "created" ones.
468+
* `start` For pagination, use this to request a specific page.
469+
* `per_page` For pagination, use this to limit the number of items in each paged list.
470+
471+
.. note:: Pagination is only available when `includeHistory` is `true`
472+
473+
If requesting a page beyond the last page this API will return a 404 "There are no access requests for this file:..."
474+
If requesting a page before page 1 or requesting the number of items to be 0 or less this API will ignore these parameters and return the entire list.
475+
476+
A curl example using an ``id``::
477+
478+
curl -H "X-Dataverse-key:$API_TOKEN" -X GET "$SERVER/api/access/datafile/{id}/listRequests?includeHistory=true&start=1&per_page=20"
464479

465480
User Has Requested Access to a File:
466481
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -471,7 +486,7 @@ This method returns true or false depending on whether or not the calling user h
471486

472487
A curl example using an ``id``::
473488

474-
curl -H "X-Dataverse-key:$API_TOKEN" -X GET "http://$SERVER/api/access/datafile/{id}/userFileAccessRequested"
489+
curl -H "X-Dataverse-key:$API_TOKEN" -X GET "$SERVER/api/access/datafile/{id}/userFileAccessRequested"
475490

476491

477492
Get User Permissions on a File:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ The following attributes are supported:
12991299
* ``description`` Description
13001300
* ``affiliation`` Affiliation
13011301
* ``filePIDsEnabled`` ("true" or "false") Restricted to use by superusers and only when the :ref:`:AllowEnablingFilePIDsPerCollection <:AllowEnablingFilePIDsPerCollection>` setting is true. Enables or disables registration of file-level PIDs in datasets within the collection (overriding the instance-wide setting).
1302-
* ``requireFilesToPublishDataset`` ("true" or "false") Restricted to use by superusers. Defines if Dataset needs files in order to be published. If not set the determination will be made through inheritance by checking the owners of this collection. Publishing by a superusers will not be blocked.
1302+
* ``requireFilesToPublishDataset`` ("true" or "false") Restricted to use by superusers. Defines if Dataset version needs files in order to be published or submitted for review. If not set the determination will be made through inheritance by checking the owners of this collection. Publishing by a superusers will not be blocked.
13031303
* ``allowedDatasetTypes`` Restricted to use by superusers. By default "dataset" is implied. Pass a comma-separated list of dataset types (e.g. "dataset,software"). You cannot unset this attribute so if you want to delete a dataset type, set ``allowedDatasetTypes`` to a dataset type you won't be deleting. See also :ref:`dataset-types`.
13041304

13051305
See also :ref:`update-dataverse-api`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public DataCitation(FileMetadata fm, boolean direct) {
135135
getCommonValuesFrom(dsv);
136136

137137
// file Title for direct File citation
138-
fileTitle = fm.getLabel();
138+
fileTitle = fm.getLabelForOriginal();
139139
DataFile df = fm.getDataFile();
140140

141141
// File description

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

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,31 @@ public String toUri() {
247247
inverseJoinColumns = @JoinColumn(name = "authenticated_user_id"))
248248
private List<AuthenticatedUser> fileAccessRequesters;
249249

250-
251-
public List<FileAccessRequest> getFileAccessRequests(){
252-
return fileAccessRequests;
250+
public List<FileAccessRequest> getFileAccessRequests() {
251+
return getFileAccessRequests(0, 0);
253252
}
254-
253+
254+
/**
255+
* Get Requests with pagination option
256+
* @param numResultsPerPageRequested
257+
* @param paginationStart starts at 1
258+
* @return
259+
*/
260+
public List<FileAccessRequest> getFileAccessRequests(int numResultsPerPageRequested, int paginationStart) {
261+
if (numResultsPerPageRequested < 1 || paginationStart < 1) {
262+
return fileAccessRequests;
263+
} else {
264+
int startIndex = (paginationStart - 1) * numResultsPerPageRequested;
265+
int endIndex = startIndex + numResultsPerPageRequested;
266+
if (startIndex >= fileAccessRequests.size()) {
267+
return List.of();
268+
} else if (endIndex > fileAccessRequests.size()) {
269+
endIndex = fileAccessRequests.size();
270+
}
271+
return fileAccessRequests.subList(startIndex, endIndex);
272+
}
273+
}
274+
255275
public List<FileAccessRequest> getFileAccessRequests(FileAccessRequest.RequestState state){
256276
return fileAccessRequests.stream().filter(far -> far.getState() == state).collect(Collectors.toList());
257277
}
@@ -527,6 +547,11 @@ public Long getOriginalFileSize() {
527547
return null;
528548
}
529549

550+
public String getFriendlyOriginalFileSize() {
551+
Long size = (getOriginalFileSize()==null) ? filesize : getOriginalFileSize();
552+
return getFriendlySize(size);
553+
}
554+
530555
public String getOriginalFileName() {
531556
if (isTabularData()) {
532557
DataTable dataTable = getDataTable();
@@ -539,7 +564,7 @@ public String getOriginalFileName() {
539564
}
540565

541566

542-
private String getDerivedOriginalFileName() {
567+
public String getDerivedOriginalFileName() {
543568
FileMetadata fm = getFileMetadata();
544569
String filename = fm.getLabel();
545570
String originalExtension = FileUtil.generateOriginalExtension(getOriginalFileFormat());
@@ -689,8 +714,12 @@ public void setFilesize(long filesize) {
689714
* @return
690715
*/
691716
public String getFriendlySize() {
692-
if (filesize != null) {
693-
return FileSizeChecker.bytesToHumanReadable(filesize);
717+
return getFriendlySize(filesize);
718+
}
719+
720+
private String getFriendlySize(Long size) {
721+
if (size != null) {
722+
return FileSizeChecker.bytesToHumanReadable(size);
694723
} else {
695724
return BundleUtil.getStringFromBundle("file.sizeNotAvailable");
696725
}
@@ -849,6 +878,15 @@ public void addFileAccessRequest(FileAccessRequest request) {
849878
this.fileAccessRequests.add(request);
850879
}
851880

881+
public List<FileAccessRequest> getAccessRequestsForAssignee(RoleAssignee roleAssignee) {
882+
if (this.fileAccessRequests == null) {
883+
return null;
884+
}
885+
886+
return this.fileAccessRequests.stream()
887+
.filter(fileAccessRequest -> fileAccessRequest.getRequester().equals(roleAssignee)).toList();
888+
}
889+
852890
public FileAccessRequest getAccessRequestForAssignee(RoleAssignee roleAssignee) {
853891
if (this.fileAccessRequests == null) {
854892
return null;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,18 @@ public String getReminderString(Dataset dataset, boolean canPublishDataset, bool
835835

836836
String reminderString;
837837

838+
if (dataset.getOwner().getEffectiveRequiresFilesToPublishDataset()) {
839+
List<FileMetadata> files = dataset.getLatestVersion().getFileMetadatas();
840+
if (files.size() < 1) {
841+
if (canPublishDataset) {
842+
reminderString = BundleUtil.getStringFromBundle("dataset.mayNotPublish.FilesRequired");
843+
} else {
844+
reminderString = BundleUtil.getStringFromBundle("dataset.mayNotSubmitForReview.FilesRequired");
845+
}
846+
return reminderString;
847+
}
848+
}
849+
838850
if (canPublishDataset) {
839851
reminderString = BundleUtil.getStringFromBundle("dataset.message.publish.warning");
840852
} else {

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Date;
55

66
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
7+
import edu.harvard.iq.dataverse.util.BundleUtil;
78
import jakarta.persistence.Column;
89
import jakarta.persistence.Entity;
910
import jakarta.persistence.EnumType;
@@ -143,6 +144,20 @@ public String getStateLabel() {
143144
}
144145
return null;
145146
}
147+
148+
// For use by UI to allow for internationalization
149+
public String getStateLabelNationalized() {
150+
if(isStateCreated()) {
151+
return BundleUtil.getStringFromBundle("permission.fileAccess.created");
152+
}
153+
if(isStateGranted()) {
154+
return BundleUtil.getStringFromBundle("permission.fileAccess.granted");
155+
}
156+
if(isStateRejected()) {
157+
return BundleUtil.getStringFromBundle("permission.fileAccess.rejected");
158+
}
159+
return null;
160+
}
146161

147162
public void setStateCreated() {
148163
this.requestState = RequestState.CREATED;
@@ -197,4 +212,4 @@ public boolean equals(Object object) {
197212
}
198213

199214

200-
}
215+
}

0 commit comments

Comments
 (0)