-
Notifications
You must be signed in to change notification settings - Fork 533
11772 api terms of access #11893
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
11772 api terms of access #11893
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
26818a7
#11772 prelim check in
sekmiller 66e7572
Merge branch 'develop' into 11772-api-terms-of-access
sekmiller 9fff5df
#11772 fix parser
sekmiller 8a51ebc
#11772 fix parser and tests
sekmiller 7085021
Merge branch 'develop' into 11772-api-terms-of-access
sekmiller 9933f16
#11772 add content test
sekmiller 3649cd4
#11772 fix typo
sekmiller 10c0727
Merge branch 'develop' into 11772-api-terms-of-access
sekmiller c0c1f86
#11772 public install update/test
sekmiller 7d16522
#11772 more tests for public install
sekmiller 5881ef4
Merge branch 'develop' into 11772-api-terms-of-access
sekmiller fb5f911
#11772 remove unused file
sekmiller dda50b8
#11772 fix json/tests
sekmiller 7bb99f9
#11772 add cleanup to tests
sekmiller 653b93c
#11772 update command test
sekmiller b5fa671
#11772 update command test
sekmiller f612afb
#11772 update test
sekmiller 97ffb6f
Merge branch 'develop' into 11772-api-terms-of-access
sekmiller ca15366
#11772 fix unit test
sekmiller a3b89bf
#11772 add another test
sekmiller 682f78e
Merge branch 'develop' into 11772-api-terms-of-access
sekmiller 327242b
#11772 fix test clean up
sekmiller d0af69f
#11772 split access update from terms
sekmiller 4f6e277
#11772 separate parser for just access
sekmiller c0a64cc
Update native-api.rst
sekmiller aaf42ae
#11772 update json parser to match doc
sekmiller 1a92c4c
#11772 clean up unit test
sekmiller 3d9376c
#11771 add release notes
sekmiller 9cf870b
#11772 rename release notes
sekmiller 9cec541
Merge branch 'develop' into 11772-api-terms-of-access
sekmiller 5390790
Update native-api.rst
sekmiller 1252f38
Update native-api.rst
sekmiller a5daff4
Merge branch 'develop' into 11772-api-terms-of-access
sekmiller 6e1ab29
Merge branch 'develop' into 11772-api-terms-of-access
stevenwinship 7eddb70
Merge branch '11772-api-terms-of-access' of https://github.com/IQSS/d…
sekmiller 621fe0a
#11772 updates from review/clarify
sekmiller 1e594d7
#11772 changes suggested in CR
sekmiller ec9033a
Update doc/release-notes/11772-update-dataset-terms-of-access-api.md
ofahimIQSS f648084
Merge branch 'develop' into 11772-api-terms-of-access
ofahimIQSS 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
12 changes: 12 additions & 0 deletions
12
doc/release-notes/11772-update-dataset-terms-of-access-api.md
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,12 @@ | ||
| ## New Endpoint: `/datasets/{id}/access` | ||
|
|
||
| A new endpoint has been implemented to manage dataset terms of access for restricted files. | ||
|
|
||
| ### Functionality | ||
| - Updates the terms of access of a dataset by applying it to the draft version. | ||
| - If no draft exists, a new one is automatically created. | ||
|
|
||
| ### Usage | ||
|
|
||
| **Custom Terms of Access** – Provide a JSON body with the `customTermsOfAccess` object. | ||
| - All fields are optional **except** if there are restricted files in which case `fileAccessRequest` must be set to true or `termsOfAccess` must be provided. | ||
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
63 changes: 63 additions & 0 deletions
63
.../java/edu/harvard/iq/dataverse/engine/command/impl/UpdateDatasetTermsOfAccessCommand.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,63 @@ | ||
|
|
||
| package edu.harvard.iq.dataverse.engine.command.impl; | ||
|
|
||
| import edu.harvard.iq.dataverse.Dataset; | ||
| import edu.harvard.iq.dataverse.DatasetVersion; | ||
| import edu.harvard.iq.dataverse.TermsOfUseAndAccess; | ||
| import edu.harvard.iq.dataverse.authorization.Permission; | ||
| 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; | ||
|
|
||
|
|
||
| /** | ||
| * | ||
| * @author stephenkraffmiller | ||
| */ | ||
| @RequiredPermissions(Permission.EditDataset) | ||
| public class UpdateDatasetTermsOfAccessCommand extends AbstractDatasetCommand<Dataset>{ | ||
|
|
||
|
|
||
| private final Dataset dataset; | ||
| private final TermsOfUseAndAccess termsOfUseAndAccess; | ||
| private final UpdateDatasetVersionCommand updateDatasetVersionCommand; | ||
|
|
||
| public UpdateDatasetTermsOfAccessCommand(Dataset dataset, TermsOfUseAndAccess termsOfUseAndAccess, DataverseRequest request) { | ||
| this(dataset, termsOfUseAndAccess, request, null); | ||
| } | ||
|
|
||
| //Command included for testing purposes | ||
| public UpdateDatasetTermsOfAccessCommand( Dataset dataset, TermsOfUseAndAccess termsOfUseAndAccess, DataverseRequest aRequest, UpdateDatasetVersionCommand updateDatasetVersionCommand ) { | ||
| super(aRequest, dataset); | ||
| this.dataset = dataset; | ||
| this.termsOfUseAndAccess = termsOfUseAndAccess; | ||
| this.updateDatasetVersionCommand = updateDatasetVersionCommand; | ||
| } | ||
|
|
||
| @Override | ||
| public Dataset execute(CommandContext ctxt) throws CommandException { | ||
| DatasetVersion datasetVersion = dataset.getOrCreateEditVersion(); | ||
|
|
||
| datasetVersion.setTermsOfUseAndAccess(merge(datasetVersion,termsOfUseAndAccess)); | ||
|
|
||
| datasetVersion.setVersionState(DatasetVersion.VersionState.DRAFT); | ||
| return ctxt.engine().submit(updateDatasetVersionCommand == null ? new UpdateDatasetVersionCommand(this.dataset, getRequest()) : updateDatasetVersionCommand); | ||
| } | ||
|
|
||
| private TermsOfUseAndAccess merge(DatasetVersion editVersion, TermsOfUseAndAccess incoming) { | ||
| //only update the access parts | ||
| TermsOfUseAndAccess termsToUpdate = editVersion.getTermsOfUseAndAccess(); | ||
| termsToUpdate.setFileAccessRequest(incoming.isFileAccessRequest()); | ||
| termsToUpdate.setTermsOfAccess(incoming.getTermsOfAccess()); | ||
| termsToUpdate.setDataAccessPlace(incoming.getDataAccessPlace()); | ||
| termsToUpdate.setOriginalArchive(incoming.getOriginalArchive()); | ||
| termsToUpdate.setAvailabilityStatus(incoming.getAvailabilityStatus()); | ||
| termsToUpdate.setContactForAccess(incoming.getContactForAccess()); | ||
| termsToUpdate.setSizeOfCollection(incoming.getSizeOfCollection()); | ||
| termsToUpdate.setStudyCompletion(incoming.getStudyCompletion()); | ||
| return termsToUpdate; | ||
| } | ||
|
|
||
|
|
||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.