-
Notifications
You must be signed in to change notification settings - Fork 531
Adds configurable storage quotas on individual datasets #11997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8feb8d0
A straightforward implementation of extending configurable stoage quo…
landreev 05ad1a9
Adding utility methods to the RestAssured suite for the dataset-level…
landreev 19cfbe9
Adding RestAssured tests, the Guide entries and a short release note.…
landreev 87de3e7
Switching the permission required for viewing current storageuse; it …
landreev 90395fd
Merge branch 'develop' into 11987-storage-quotas-on-datasets
landreev 388af25
a typo in the release note. #11987
landreev 4337c47
Added an optional parameter to the quota APIs to show the quota that …
landreev 43678bb
Cosmetic, fixes the comments in the command #11987
landreev 4c61b5e
Fixed the required permissions in the API guide. #11987
landreev 764ba9a
A quick experiment - add the remaining storage quota and/or file coun…
landreev cc9f9a2
cleanup per review #11987
landreev 16dbd5d
Merge branch 'develop' into 11987-storage-quotas-on-datasets
landreev ac5620b
Extra documentation. #11987
landreev cbc098c
typo in the guide #11987
landreev 1fbbff0
moving the dynamic, remaining upload allocations from /storageDriver …
landreev b832a2f
doc changes #11987
landreev 2c7f928
Merge branch 'develop' into 11987-storage-quotas-on-datasets
landreev 92141d4
Some refactoring per suggestions during QA #11987
landreev aa84df1
These 2 lines were a leftover of an earlier experiment, removed. #11987
landreev 4c7b190
corrected an error in the guide. #11987
landreev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| It is now possible to define storage quotas on individual datasets. See the API guide for more information. | ||
| The practical use case is for datasets in the top-level, root collection. This does not address the use case of a user creating multiple datasets. But there is an open dev. issue for adding per-user storage quotas as well. | ||
|
|
||
| A convenience API `/api/datasets/{id}/uploadlimits` has been added to show the remaining storage and/or number of files quotas, if present. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/edu/harvard/iq/dataverse/engine/command/impl/DeleteDatasetQuotaCommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package edu.harvard.iq.dataverse.engine.command.impl; | ||
|
|
||
| import edu.harvard.iq.dataverse.Dataset; | ||
| import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser; | ||
| import edu.harvard.iq.dataverse.engine.command.AbstractVoidCommand; | ||
| import edu.harvard.iq.dataverse.engine.command.CommandContext; | ||
| import edu.harvard.iq.dataverse.engine.command.DataverseRequest; | ||
| import edu.harvard.iq.dataverse.engine.command.RequiredPermissions; | ||
| import edu.harvard.iq.dataverse.engine.command.exception.CommandException; | ||
| import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException; | ||
| import edu.harvard.iq.dataverse.engine.command.exception.PermissionException; | ||
| import edu.harvard.iq.dataverse.storageuse.StorageQuota; | ||
| import edu.harvard.iq.dataverse.util.BundleUtil; | ||
| import java.util.logging.Logger; | ||
|
|
||
| /** | ||
| * | ||
| * @author landreev | ||
| * | ||
| * A superuser-only command: | ||
| */ | ||
| @RequiredPermissions({}) | ||
| public class DeleteDatasetQuotaCommand extends AbstractVoidCommand { | ||
|
|
||
| private static final Logger logger = Logger.getLogger(DeleteDatasetQuotaCommand.class.getCanonicalName()); | ||
|
|
||
| private final Dataset targetDataset; | ||
|
|
||
| public DeleteDatasetQuotaCommand(DataverseRequest aRequest, Dataset target) { | ||
| super(aRequest, target); | ||
| targetDataset = target; | ||
| } | ||
|
|
||
| @Override | ||
| public void executeImpl(CommandContext ctxt) throws CommandException { | ||
| // first check if user is a superuser | ||
| if ( (!(getUser() instanceof AuthenticatedUser) || !getUser().isSuperuser() ) ) { | ||
| throw new PermissionException(BundleUtil.getStringFromBundle("dataset.storage.quota.superusersonly"), | ||
| this, null, targetDataset); | ||
| } | ||
|
|
||
| if (targetDataset == null) { | ||
| throw new IllegalCommandException("", this); | ||
| } | ||
|
|
||
| StorageQuota storageQuota = targetDataset.getStorageQuota(); | ||
|
|
||
| if (storageQuota != null && storageQuota.getAllocation() != null) { | ||
| // The method below, in dataverseServiceBean, can be used to delete | ||
| // quotas defined on either of the DvObjectContainer classes: | ||
| ctxt.dataverses().disableStorageQuota(storageQuota); | ||
| } | ||
| // ... and if no quota was enabled on the dataset - nothing to do = success | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any check to prevent negative numbers? I guess 0 or negative will just block the ability to store more data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is the answer - it is possible to set it to a negative number. But it will be equivalent to zero in practice.
Tbh, I am generally less concerned about preventing invalid or meaningless values from being entered when it comes to superusers-only APIs. Under the assumption that they should know what they are doing, and/or can be expected to own the consequences of their actions.