Skip to content

Commit

Permalink
change how hierarchy works
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenwinship committed Nov 1, 2024
1 parent c0c4c89 commit 85af55f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## Feature: Prevent publishing Datasets without files
A new attribute was added to Collections in order to control the publishing of Datasets without files. Once set, the publishing of a Dataset within a Collection or Collection's hierarchy, without files, will be blocked for all non superusers.
In order to configure a Collection to block publishing a superuser must set the attribute "requireFilesToPublishDataset" to true.
Any Collection created under a Collection with this attribute will also be bound by this blocking. Setting this attribute on the Root Dataverse will essentially block the publishing of Datasets without files for the entire installation.
A new attribute was added to Collections in order to control the publishing of Datasets without files.
Once set to "True", the publishing of a Dataset within a Collection, without files, will be blocked for all non superusers.
In order to configure a Collection to block publishing a superuser must set the attribute "requireFilesToPublishDataset" to "True".
The collection's hierarchy will be checked if the collection's "requireFilesToPublishDataset" attribute is not set explicitly to "True" or "False".

```shell
curl -X PUT -H "X-Dataverse-key:$API_TOKEN" "$SERVER_URL/api/dataverses/$ID/attribute/requireFilesToPublishDataset?value=true"
```
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx-guides/source/api/native-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ The following attributes are supported:
* ``description`` Description
* ``affiliation`` Affiliation
* ``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).
* ``requireFilesToPublishDataset`` ("true" or "false") Dataset needs files in order to be published. Restricted to use by superusers. If any TRUE found in the ownership tree publishing will be blocked. Publishing by a superusers will not be blocked.
* ``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.

.. _collection-storage-quotas:

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/Dataverse.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,15 @@ public void setCitationDatasetFieldTypes(List<DatasetFieldType> citationDatasetF

@Column(nullable = true)
private Boolean requireFilesToPublishDataset;
/**
* Specifies whether the existance of files in a dataset is required when publishing
* @return {@code Boolean.TRUE} if explicitly enabled, {@code Boolean.FALSE} if explicitly disabled.
* {@code null} indicates that the behavior is not explicitly defined, in which
* case the behavior should follow the explicit configuration of the first
* direct ancestor collection.
* @Note: If present, this configuration therefore by default applies to all
* the sub-collections, unless explicitly overwritten there.
*/
public Boolean getRequireFilesToPublishDataset() {
return requireFilesToPublishDataset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,12 @@ private void verifyCommandArguments(CommandContext ctxt) throws IllegalCommandEx
}
private boolean requiresFilesToPublishDataset() {
if (!getUser().isSuperuser()) {
List<Dataverse> owners = getDataset().getOwner().getOwners();
for(Dataverse owner : owners) {
if (owner.getRequireFilesToPublishDataset() != null && owner.getRequireFilesToPublishDataset()) {
return true;
Dataverse parent = getDataset().getOwner();
while (parent != null) {
if (parent.getRequireFilesToPublishDataset() != null) {
return parent.getRequireFilesToPublishDataset();
}
parent = parent.getOwner();
}
}
return false;
Expand Down

0 comments on commit 85af55f

Please sign in to comment.