Skip to content

split table terms of use and access - #12659

Open
jo-pol wants to merge 80 commits into
IQSS:developfrom
DANS-KNAW-jp:split-terms-table
Open

jo-pol wants to merge 80 commits into
IQSS:developfrom
DANS-KNAW-jp:split-terms-table

Conversation

@jo-pol

@jo-pol jo-pol commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

This PR prepares the Dataverse codebase for file-specific licenses/terms by splitting the legacy model “TermsOfUseAndAccess” into two separate models (“TermsOfUseOrLicense” and “TermsOfAccess”) and updating persistence, API, UI, and tests accordingly.

Changes:

  • Introduces new termsofaccess and termsofuseorlicense tables (Flyway) and updates entity mappings and references.
  • Updates API/commands/JSON export-import paths to read/write the new split terms objects.
  • Updates UI (xhtml), exporters, and test fixtures to reflect the new model.
  • Added validation tests to DatasetVersionTest

Which issue(s) this PR closes:

  • Closes #

Special notes for your reviewer:

Suggestions on how to test this:

  • See my cheat sheet for DANS VM of v6.10

  • These tests clearly did not cover code flagged by Codepilot DANS-KNAW-jp@cf45fb2

  • After v6.10 new commands (UpdateTemplateLicense and UpdateTemplateTermsOfAccess) are introduced using the old TermsOfUseAndAccess. So additionally to the cheat sheet:

    curl -X PUT "$HOST/api/dataverses/1/licenseTerms" -H "X-Dataverse-key: $API_TOKEN" -H "Content-Type: application/json" -d '{ "name": "CC BY 4.0" }'
    curl -X PUT "$HOST/api/dataverses/1/licenseTerms" -H "X-Dataverse-key: $API_TOKEN" -H "Content-Type: application/json" \
           -d '{ "customTerms": { "termsOfUse": "Your terms of use", "restrictions": "Your restrictions" } }'
    curl -H "X-Dataverse-key:$API_TOKEN" -X PUT "$HOST/api/dataverses/1/access" -H "Content-Type: application/json" \
           -d '{ "customTermsOfAccess": { "fileAccessRequest": true, "termsOfAccess": "Your changed terms of access for restricted files" } }' 
    
  • Should I still have missed something: null pointer exceptions usually meant an omission in pairs of lines like

              termsOfAccess.setXxx(obj);
              obj.setTermsOfAccess(termsOfAccess);
    
              termsOfUseOrLicense.setXxx(obj);
              obj.setTermsOfUseOrLicense(termsOfUseOrLicense);
    

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Is there a release notes update needed for this change?:

Yes, a DB table is split into two tables and its references needs updates, so:

Upgrading requires a maintenance window and downtime. Please plan accordingly, create backups of your database, etc.

Additional documentation:

of DANS-KNAW#251 at 972a501 (irrelevant import changes)
@jo-pol
jo-pol marked this pull request as draft August 31, 2026 09:38
@jo-pol
jo-pol marked this pull request as ready for review September 3, 2026 10:05
# Conflicts:
#	src/main/webapp/dataset.xhtml
@pdurbin pdurbin moved this to Ready for Triage in IQSS Dataverse Project Sep 8, 2026
@pdurbin pdurbin moved this from Ready for Triage to In Review 🔎 in IQSS Dataverse Project Sep 8, 2026
@pdurbin pdurbin added the Size: 20 A percentage of a sprint. 14 hours. label Sep 8, 2026
@cmbz cmbz added FY27 Sprint 5 FY27 Sprint 5 (2026-08-26 - 2026-09-09) FY27 Sprint 6 FY27 Sprint 6 (2026-09-09 - 2026-09-23) labels Sep 9, 2026
@cmbz cmbz added the FY27 Sprint 7 FY27 Sprint 7 (2026-09-23 - 2026-10-07) label Sep 23, 2026
# Conflicts:
#	src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
#	src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java
#	src/main/webapp/guestbook-terms-popup-fragment.xhtml
@qqmyers qqmyers added this to the 6.13 milestone Oct 13, 2026

@qqmyers qqmyers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phew - a relatively simple goal (to split the tables to allow file licenses) but lots of changed lines! I've requested some changes / asked some questions.

I think most are minor/straight forward with one possible exception - the link between FileMetadata and TermsOfUseOrLicense is a) One-To-One and b) not represented in the TermsOfUseOrLicense class. I'm not sure whether the design is one-to-one (the design doc has a symbol that looks like many to one). If it is, I think the back-link from TermsOfUseOrLIcense (same as for dataset version and template) is needed. If it should be many-to-one that needs to change and a back-link is needed.

The test deletes the dataset’s only custom terms, leaving neither terms nor a license—a state the current validator rejects with HTTP 409. I’ll make the test assert that rejection, then restore CC0 through the semantic API and verify the custom terms are gone.

Updated testSemanticMetadataAPIs to expect HTTP 409 when deleting the only terms without a license, then restore CC0 and verify the custom terms disappear. Added regression coverage for that validation rule.
This reverts commit 0f64dad.
The test deletes the dataset’s only custom terms, leaving neither terms nor a license—a state the current validator rejects with HTTP 409. I’ll make the test assert that rejection, then restore CC0 through the semantic API and verify the custom terms are gone.

Updated testSemanticMetadataAPIs to expect HTTP 409 when deleting the only terms without a license, then restore CC0 and verify the custom terms disappear. Added regression coverage for that validation rule.
# Conflicts:
#	src/main/resources/db/migration/V6.12.1.1.sql
return false;
}
} else {
if (StringUtils.isBlank(value.getTermsOfUse())) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the meeting I understood the tests might also succeed with the following additional check and the validation annotation switched on. That would be better than never validating anything. For the web-ui and when publishing a dataset, we would like to ignore this setting.

On the other hand I assume we still have validation active with DatsetVersion.validate explicitly calling

validator.validate(this.defaultTermsOfUseOrLicense)
Suggested change
if (StringUtils.isBlank(value.getTermsOfUse())) {
if (StringUtils.isBlank(value.getTermsOfUse()) && ! JvmSettings.API_ALLOW_INCOMPLETE_METADATA.lookupOptional(Boolean.class).orElse(false) )) {

public class TermsOfUseAndAccess implements Serializable {
//TODO fix failing tests in DatasetTypesIT to re-enable @ValidateTermsOfUseOrLicense
//@ValidateTermsOfUseOrLicense

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comment

@qqmyers qqmyers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests passing, design issues resolved, existing bug(s) reported in #12922, etc. Thanks for al the back and forth to make this go.

@github-project-automation github-project-automation Bot moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project Nov 26, 2026
# Conflicts:
#	src/main/webapp/dataset.xhtml
#	src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FY27 Sprint 5 FY27 Sprint 5 (2026-08-26 - 2026-09-09) FY27 Sprint 6 FY27 Sprint 6 (2026-09-09 - 2026-09-23) FY27 Sprint 7 FY27 Sprint 7 (2026-09-23 - 2026-10-07) FY27 Sprint 8 FY27 Sprint 8 (2026-10-07 - 2026-10-21) Size: 20 A percentage of a sprint. 14 hours.

Projects

Status: Ready for QA ⏩

Development

Successfully merging this pull request may close these issues.

4 participants