Skip to content
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

8191 require toa or req access #8308

Merged
merged 98 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
7ffa9e9
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Nov 9, 2021
811422e
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Nov 9, 2021
12fba42
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Nov 15, 2021
a849d6c
#8191 update ui and bundle, etc.
sekmiller Nov 30, 2021
a6785b7
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Nov 30, 2021
0778ca8
#8191 disable save on Terms when invalid
sekmiller Nov 30, 2021
a952c95
#8191 only validate terms if restricted files are present
sekmiller Dec 1, 2021
b206e02
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Dec 1, 2021
316ac05
#8191 redirect to TOA if invalid
sekmiller Dec 9, 2021
dc03b62
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Dec 9, 2021
28d8ba5
#8191 disable Publish if invalid TOA/RA
sekmiller Dec 10, 2021
2b0e7e5
#8191 fix help for popup/edit terms
sekmiller Dec 10, 2021
622416d
#8191 ui update
sekmiller Dec 13, 2021
b748694
#8191 stray ;
sekmiller Dec 13, 2021
f9fc435
#8191 remove debut code
sekmiller Dec 13, 2021
90141b3
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Dec 14, 2021
839cf1f
adding release note file
djbrooke Dec 14, 2021
71e9847
release note text
djbrooke Dec 14, 2021
74a4e3a
add query to find datasets and owners to contact
djbrooke Dec 14, 2021
bfb0979
note linking to query
djbrooke Dec 14, 2021
733bca2
one more update to the release note
djbrooke Dec 14, 2021
cf4f799
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Dec 15, 2021
8026778
#8191 fix tests and update query
sekmiller Dec 15, 2021
2a59521
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Jan 3, 2022
47945fa
#8191 move validation message to Bundle
sekmiller Jan 3, 2022
c826517
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Jan 5, 2022
8fd45e4
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Jan 5, 2022
a20fbd5
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Jan 14, 2022
37a8630
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Jan 14, 2022
021fde6
#8191 code cleanup fix file page
sekmiller Jan 20, 2022
b7cef02
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Jan 20, 2022
f64cfd0
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Jan 24, 2022
4c799e3
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Jan 26, 2022
64a40ea
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Jan 31, 2022
70ea695
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 3, 2022
5a07521
#8191 remove duplicate popup
sekmiller Feb 9, 2022
318d490
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 9, 2022
f5e2cfe
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 9, 2022
1f949f3
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 10, 2022
70363aa
#8191 update terms page
sekmiller Feb 11, 2022
1d3dade
#8191 update from dev
sekmiller Feb 11, 2022
bf7b218
#8191 remove debug line
sekmiller Feb 11, 2022
eb402aa
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 11, 2022
a7875ce
#8191 remove out of date comment/code
sekmiller Feb 11, 2022
e260f50
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 15, 2022
5f015bf
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 16, 2022
a84a5d7
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 17, 2022
019b42a
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 18, 2022
7279c80
#8191 consolidate delete function
sekmiller Feb 23, 2022
56084a6
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 23, 2022
f4c8172
#8191 delete duplicate popup
sekmiller Feb 23, 2022
29e0dc4
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Feb 24, 2022
247fda1
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 4, 2022
76c7c70
#8191 fix edit metadata popup
sekmiller Mar 4, 2022
c124642
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 4, 2022
22fde43
#8191 hide block ds on cancel
sekmiller Mar 7, 2022
9b782a7
#8191 add validate or die to commands
sekmiller Mar 9, 2022
e8be115
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 9, 2022
5781394
#8191 add integration test for req/toa validation
sekmiller Mar 9, 2022
8da1b43
#8191 fix default values disable edits
sekmiller Mar 10, 2022
157dc2c
#8191 disable files buttons
sekmiller Mar 10, 2022
4ad680b
#8191 test edit version for valid toua
sekmiller Mar 10, 2022
c904902
#8191 disable metadata tab edit
sekmiller Mar 10, 2022
f479b1e
#8191 add more info to popup terms page
sekmiller Mar 10, 2022
3a84f83
#8191 update render on terms help
sekmiller Mar 11, 2022
02ad3c9
#8191 format terms of access help text
sekmiller Mar 11, 2022
a03a42d
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 14, 2022
595d8c9
#8191 fix link to guides
sekmiller Mar 14, 2022
db3e27f
#8191 fix label and close tabs by default
sekmiller Mar 14, 2022
a162ede
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 14, 2022
bfe03bf
#8191 add TOUA validation messages
sekmiller Mar 14, 2022
6ee5313
#8191 ui changes requested
sekmiller Mar 15, 2022
c3d5ce0
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 16, 2022
77870cc
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 17, 2022
6988cc7
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 21, 2022
41a00bc
Update dataset-license-terms.xhtml
sekmiller Mar 21, 2022
6c9d0ed
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 22, 2022
8ce5c88
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 28, 2022
ab57f63
#8191 remove unused dialogs
sekmiller Mar 29, 2022
869b6ce
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 29, 2022
98795f1
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Mar 31, 2022
f2a24d5
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Apr 6, 2022
3079af5
#8191 add warning for TOA out of compliance
sekmiller Apr 6, 2022
cbbeed1
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Apr 6, 2022
f19e521
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Apr 8, 2022
e4c1c3b
#8191 prelim ui updates
sekmiller Apr 12, 2022
28f7c6e
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Apr 12, 2022
2b3c8b7
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Apr 12, 2022
231a15f
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Apr 12, 2022
b7c9997
#8191 update popup validation
sekmiller Apr 14, 2022
cd068f6
#8191 fix for filepage and terms
sekmiller Apr 14, 2022
18c13c1
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Apr 14, 2022
0188084
#8191 resolve merge
sekmiller Apr 14, 2022
d1fa0ce
#8191 fix create ds
sekmiller Apr 14, 2022
ebec3bd
#8191 fix success message posting
sekmiller Apr 15, 2022
e46f614
#8191 fix add terms to Sword DB
sekmiller Apr 19, 2022
040a46f
Merge branch 'develop' into 8191-require-TOA-or-req-access
sekmiller Apr 19, 2022
3eb6f4b
#8191 fix save buttons
sekmiller Apr 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions doc/release-notes/8191-require-toa-or-request-access.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Release Highlights

### Terms of Access or Request Access Required for Restricted Files

Beginning in this release, Restricted Files must have either Terms of Access or Request Access enabled. This change is to ensure that for each file in a Dataverse installation there is a clear path to get to the data, either through requesting access to the data or to provide context about why requesting access is not enabled.

In the "Notes for Dataverse Installation Administrators" section, we have provided a query to help proactively identify datasets that need to be updated.

## Notes for Dataverse Installation Administrators

### Identifying Datasets Requiring Terms of Access or Request Access Changes

In support of the change to require either Terms of Access or Request Access for all Restricted Files, we have provided a query to identify datasets in your installation where at least one file has neither Terms of Access or Request Access enabled:

https://github.com/IQSS/dataverse/raw/develop/scripts/issues/8191/

This will allow you to reach out to those dataset owners as appropriate.
28 changes: 28 additions & 0 deletions scripts/issues/8191/datasets_without_toa_or_request_access
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- this query will identify datasets where at least one file does not have either terms of access or request access enabled, and will include owner information for those datasets
djbrooke marked this conversation as resolved.
Show resolved Hide resolved

select au.email,
concat(au.firstname, ' ', au.lastname),
concat('$SERVERNAME/dataset.xhtml?persistentId=doi:' , dvo.authority , '/' , dvo.identifier)
from roleassignment ra, dataverserole dvr,
authenticateduser au, dvobject dvo
where
au.useridentifier = rtrim(substring(ra.assigneeidentifier, 2, 100))
and dvo.id = ra.definitionpoint_id
and
ra.role_id = dvr.id and
dvr.alias in (
'fullContributor',
'dsContributor',
'contributor',
'admin',
'curator'
) and
ra.definitionpoint_id in (
select dvo.id from datasetversion v
join termsofuseandaccess ua on ua.id = v.termsofuseandaccess_id
join filemetadata fm on v.id = fm.datasetversion_id
join datafile f on f.id = fm.datafile_id
join dvobject dvo on v.dataset_id = dvo.id
where ua.fileaccessrequest = false and ua.termsofaccess isnull
and f.restricted = true
)
2 changes: 1 addition & 1 deletion scripts/search/tests/data/dataset-finch1.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"http://schema.org/version": "DRAFT",
"http://schema.org/name": "Darwin's Finches",
"https://dataverse.org/schema/core#fileTermsOfAccess": {
"https://dataverse.org/schema/core#fileRequestAccess": false
"https://dataverse.org/schema/core#fileRequestAccess": true
},
"http://schema.org/includedInDataCatalog": "Root"
}
23 changes: 18 additions & 5 deletions src/main/java/edu/harvard/iq/dataverse/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ public void setVersions(List<DatasetVersion> versions) {
}

private DatasetVersion createNewDatasetVersion(Template template, FileMetadata fmVarMet) {

DatasetVersion dsv = new DatasetVersion();
dsv.setVersionState(DatasetVersion.VersionState.DRAFT);
dsv.setFileMetadatas(new ArrayList<>());
Expand All @@ -313,11 +314,11 @@ private DatasetVersion createNewDatasetVersion(Template template, FileMetadata f
if (latestVersion.getDatasetFields() != null && !latestVersion.getDatasetFields().isEmpty()) {
dsv.setDatasetFields(dsv.copyDatasetFields(latestVersion.getDatasetFields()));
}

if (latestVersion.getTermsOfUseAndAccess()!= null){
dsv.setTermsOfUseAndAccess(latestVersion.getTermsOfUseAndAccess().copyTermsOfUseAndAccess());
}

/*
adding file metadatas here and updating terms
because the terms need to know about the files
in a pre-save validation SEK 12/6/2021
*/
for (FileMetadata fm : latestVersion.getFileMetadatas()) {
FileMetadata newFm = new FileMetadata();
// TODO:
Expand Down Expand Up @@ -348,6 +349,18 @@ private DatasetVersion createNewDatasetVersion(Template template, FileMetadata f

dsv.getFileMetadatas().add(newFm);
}

if (latestVersion.getTermsOfUseAndAccess()!= null){
TermsOfUseAndAccess terms = latestVersion.getTermsOfUseAndAccess().copyTermsOfUseAndAccess();
terms.setDatasetVersion(dsv);
dsv.setTermsOfUseAndAccess(terms);
} else {
TermsOfUseAndAccess terms = new TermsOfUseAndAccess();
terms.setDatasetVersion(dsv);
terms.setLicense(null);
terms.setFileAccessRequest(true);
dsv.setTermsOfUseAndAccess(terms);
}
}

// I'm adding the version to the list so it will be persisted when
Expand Down
125 changes: 86 additions & 39 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
import edu.harvard.iq.dataverse.search.SearchServiceBean;
import edu.harvard.iq.dataverse.search.SearchUtil;
import edu.harvard.iq.dataverse.search.SolrClientService;
import edu.harvard.iq.dataverse.util.FileMetadataUtil;
import java.util.Comparator;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
Expand Down Expand Up @@ -391,6 +392,43 @@ public void setRsyncScript(String rsyncScript) {
public String getRsyncScriptFilename() {
return rsyncScriptFilename;
}

private Boolean hasValidTermsOfAccess = null;

public Boolean isHasValidTermsOfAccess() {
//cache in page to limit processing
if (hasValidTermsOfAccess != null){
return hasValidTermsOfAccess;
} else {
if (!isHasRestrictedFiles()){
hasValidTermsOfAccess = true;
return hasValidTermsOfAccess;
} else {
hasValidTermsOfAccess = TermsOfUseAndAccessValidator.isTOUAValid(dataset.getEditVersion().getTermsOfUseAndAccess(), null);
return hasValidTermsOfAccess;
}
}
}

private Boolean hasRestrictedFiles = null;

public Boolean isHasRestrictedFiles(){
//cache in page to limit processing
if (hasRestrictedFiles != null){
return hasRestrictedFiles;
} else {
hasRestrictedFiles = workingVersion.isHasRestrictedFile();
return hasRestrictedFiles;
}
}

public boolean getHasValidTermsOfAccess(){
return isHasValidTermsOfAccess(); //HasValidTermsOfAccess
}

public void setHasValidTermsOfAccess(boolean value){
//dummy for ui
}

private String thumbnailString = null;

Expand Down Expand Up @@ -2015,7 +2053,8 @@ private String init(boolean initFull) {
JH.addMessage(FacesMessage.SEVERITY_WARN, BundleUtil.getStringFromBundle("dataset.message.label.fileAccess"),
BundleUtil.getStringFromBundle("dataset.message.publicInstall"));
}

setFileAccessRequest(workingVersion.getTermsOfUseAndAccess().isFileAccessRequest());
setTermsOfAccess(workingVersion.getTermsOfUseAndAccess().getTermsOfAccess());
resetVersionUI();

// FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Add New Dataset", " - Enter metadata to create the dataset's citation. You can add more metadata about this dataset after it's created."));
Expand Down Expand Up @@ -2071,7 +2110,14 @@ private String init(boolean initFull) {
previewTools = externalToolService.findFileToolsByType(ExternalTool.Type.PREVIEW);
datasetExploreTools = externalToolService.findDatasetToolsByType(ExternalTool.Type.EXPLORE);
rowsPerPage = 10;

if (dataset.getId() != null && canUpdateDataset()) {
hasRestrictedFiles = workingVersion.isHasRestrictedFile();
hasValidTermsOfAccess = isHasValidTermsOfAccess();
if (!hasValidTermsOfAccess) {
String message = BundleUtil.getStringFromBundle("dataset.message.editMetadata.invalid.TOUA.message");
JsfHelper.addWarningMessage(message);
}
}
return null;
}

Expand Down Expand Up @@ -2435,17 +2481,15 @@ public void edit(EditMode editMode) {
}
workingVersion = dataset.getEditVersion();
clone = workingVersion.cloneDatasetVersion();
if (editMode == EditMode.INFO) {
// ?
} else if (editMode == EditMode.FILE) {
// JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.message.editFiles"));
// FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Upload + Edit Dataset Files", " - You can drag and drop your files from your desktop, directly into the upload widget."));
} else if (editMode.equals(EditMode.METADATA)) {
if (editMode.equals(EditMode.METADATA)) {
datasetVersionUI = datasetVersionUI.initDatasetVersionUI(workingVersion, true);
updateDatasetFieldInputLevels();
JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.message.editMetadata.label"), BundleUtil.getStringFromBundle("dataset.message.editMetadata.message"));
//FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Edit Dataset Metadata", " - Add more metadata about your dataset to help others easily find it."));
} else if (editMode.equals(EditMode.LICENSE)){
if(!isHasValidTermsOfAccess()){
workingVersion.getTermsOfUseAndAccess().setFileAccessRequest(true);
}
JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.message.editTerms.label"), BundleUtil.getStringFromBundle("dataset.message.editTerms.message"));
//FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Edit Dataset License and Terms", " - Update your dataset's license and terms of use."));
}
Expand Down Expand Up @@ -3235,15 +3279,17 @@ public List<Dataverse> completeHostDataverseMenuList(String query) {

public String restrictFiles(boolean restricted) throws CommandException {
List filesToRestrict = new ArrayList();

if (fileMetadataForAction != null) {
filesToRestrict.add(fileMetadataForAction);
} else {
filesToRestrict = this.getSelectedFiles();
}

restrictFiles(filesToRestrict, restricted);
return save();
if (editMode == EditMode.CREATE) {
return "";
} else {
return save();
}
}

private void restrictFiles(List<FileMetadata> filesToRestrict, boolean restricted) throws CommandException {
Expand Down Expand Up @@ -3327,7 +3373,16 @@ public String deleteFiles() throws CommandException{
}

deleteFiles(filesToDelete);
String retVal = save();
String retVal;

if (editMode == EditMode.CREATE) {
workingVersion.setFileMetadatas(new ArrayList<>());
retVal = "";
} else {
retVal = save();
}


//And delete them only after the dataset is updated
for(Embargo emb: orphanedEmbargoes) {
embargoService.deleteById(emb.getId(), ((AuthenticatedUser)session.getUser()).getUserIdentifier());
Expand Down Expand Up @@ -3362,32 +3417,12 @@ private void deleteFiles(List<FileMetadata> filesToDelete) {
// So below we are deleting the metadata from the version; we are
// NOT adding the file to the filesToBeDeleted list that will be
// passed to the UpdateDatasetCommand. -- L.A. Aug 2017
Iterator<FileMetadata> fmit = dataset.getEditVersion().getFileMetadatas().iterator();
while (fmit.hasNext()) {
FileMetadata fmd = fmit.next();
if (markedForDelete.getDataFile().getStorageIdentifier().equals(fmd.getDataFile().getStorageIdentifier())) {
// And if this is an image file that happens to be assigned
// as the dataset thumbnail, let's null the assignment here:

if (fmd.getDataFile().equals(dataset.getThumbnailFile())) {
dataset.setThumbnailFile(null);
}
/* It should not be possible to get here if this file
is not in fact released! - so the code block below
is not needed.
//if not published then delete identifier
if (!fmd.getDataFile().isReleased()){
try{
commandEngine.submit(new DeleteDataFileCommand(fmd.getDataFile(), dvRequestService.getDataverseRequest()));
} catch (CommandException e){
//this command is here to delete the identifier of unreleased files
//if it fails then a reserved identifier may still be present on the remote provider
}
} */
fmit.remove();
break;
}
}

FileMetadataUtil.removeFileMetadataFromList(workingVersion.getFileMetadatas(), markedForDelete);

FileMetadataUtil.removeDataFileFromList(newFiles, markedForDelete.getDataFile());
FileUtil.deleteTempFile(markedForDelete.getDataFile(), dataset, ingestService);

}
}

Expand Down Expand Up @@ -3577,6 +3612,7 @@ public String save() {

if (editMode != null) {
if (editMode.equals(EditMode.CREATE)) {

// We allow users to upload files on Create:
int nNewFiles = newFiles.size();
logger.fine("NEW FILES: "+nNewFiles);
Expand Down Expand Up @@ -4506,12 +4542,23 @@ public void setCategoriesByName(List<String> dummy){
}

public void refreshTagsPopUp(){
if(!isHasValidTermsOfAccess()){
this.editMode = EditMode.LICENSE;
PrimeFaces.current().executeScript("PF('blockDatasetForm').show()");
PrimeFaces.current().executeScript("PF('accessPopup').show()");
JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.message.editTerms.label"), BundleUtil.getStringFromBundle("dataset.message.editTerms.message"));
this.readOnly = false;
return;
}

if (workingVersion.isReleased()) {
refreshSelectedFiles(selectedFiles);
}
updateFileCounts();
refreshCategoriesByName();
refreshCategoriesByName();

refreshTabFileTagsByName();
PrimeFaces.current().executeScript("PF('fileTagsPopup').show()");
}

private List<String> tabFileTagsByName;
Expand Down
Loading