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 13 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
28 changes: 18 additions & 10 deletions src/main/java/edu/harvard/iq/dataverse/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,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 @@ -312,16 +313,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());
} else {
TermsOfUseAndAccess terms = new TermsOfUseAndAccess();
terms.setDatasetVersion(dsv);
terms.setLicense(TermsOfUseAndAccess.License.CC0);
dsv.setTermsOfUseAndAccess(terms);
}

/*
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 @@ -352,6 +348,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(TermsOfUseAndAccess.License.CC0);
terms.setFileAccessRequest(true);
dsv.setTermsOfUseAndAccess(terms);
}
}

// I'm adding the version to the list so it will be persisted when
Expand Down
80 changes: 77 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,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(workingVersion.getTermsOfUseAndAccess(), null);
Copy link
Member

Choose a reason for hiding this comment

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

It seems like the new validator is only called from the GUI? Are the same rules enforced via API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I mentioned before we all left for break, the validator is called by the commands via the validateOrDie method so it will be applied to all dataset versions created or updated using the various apis.

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 @@ -2052,7 +2089,17 @@ 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");
if(workingVersion.isDraft()){
message = message + " " + BundleUtil.getStringFromBundle("dataset.message.publish.invalid.TOUA.message");
}
JsfHelper.addWarningMessage(message);
}
}
return null;
}

Expand Down Expand Up @@ -2418,12 +2465,28 @@ public void edit(EditMode editMode) {
clone = workingVersion.cloneDatasetVersion();
if (editMode == EditMode.INFO) {
// ?
} else if (editMode == EditMode.FILE) {
} else if (editMode == EditMode.FILE) {;
djbrooke marked this conversation as resolved.
Show resolved Hide resolved
if(!hasValidTermsOfAccess){
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;
}
// 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)) {
datasetVersionUI = datasetVersionUI.initDatasetVersionUI(workingVersion, true);
updateDatasetFieldInputLevels();
if(!hasValidTermsOfAccess){
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;
}
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)){
Expand Down Expand Up @@ -4475,12 +4538,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
57 changes: 45 additions & 12 deletions src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,13 @@ public boolean isHasNonPackageFile(){
// The presence of any non-package file means that HTTP Upload was used (no mixing allowed) so we just check the first file.
return !this.fileMetadatas.get(0).getDataFile().getContentType().equals(DataFileServiceBean.MIME_TYPE_PACKAGE_FILE);
}

public boolean isHasRestrictedFile(){
if (this.fileMetadatas == null || this.fileMetadatas.isEmpty()){
return false;
}
return this.fileMetadatas.stream().anyMatch(fm -> (fm.isRestricted()));
}

public void updateDefaultValuesFromTemplate(Template template) {
if (!template.getDatasetFields().isEmpty()) {
Expand Down Expand Up @@ -591,15 +598,12 @@ public DatasetVersion cloneDatasetVersion(){
dsv.setDatasetFields(dsv.copyDatasetFields(this.getDatasetFields()));
}

if (this.getTermsOfUseAndAccess()!= null){
dsv.setTermsOfUseAndAccess(this.getTermsOfUseAndAccess().copyTermsOfUseAndAccess());
} else {
TermsOfUseAndAccess terms = new TermsOfUseAndAccess();
terms.setDatasetVersion(dsv);
terms.setLicense(TermsOfUseAndAccess.License.CC0);
dsv.setTermsOfUseAndAccess(terms);
}

/*
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 : this.getFileMetadatas()) {
FileMetadata newFm = new FileMetadata();
// TODO:
Expand All @@ -619,9 +623,17 @@ public DatasetVersion cloneDatasetVersion(){

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




if (this.getTermsOfUseAndAccess()!= null){
TermsOfUseAndAccess terms = this.getTermsOfUseAndAccess().copyTermsOfUseAndAccess();
terms.setDatasetVersion(dsv);
dsv.setTermsOfUseAndAccess(terms);
} else {
TermsOfUseAndAccess terms = new TermsOfUseAndAccess();
terms.setDatasetVersion(dsv);
terms.setLicense(TermsOfUseAndAccess.License.CC0);
dsv.setTermsOfUseAndAccess(terms);
}

dsv.setDataset(this.getDataset());
return dsv;
Expand All @@ -636,6 +648,11 @@ public void initDefaultValues() {
TermsOfUseAndAccess terms = new TermsOfUseAndAccess();
terms.setDatasetVersion(this);
terms.setLicense(TermsOfUseAndAccess.License.CC0);
/*
Added for https://github.com/IQSS/dataverse/issues/8191
set File Access Request to true
*/
terms.setFileAccessRequest(true);
this.setTermsOfUseAndAccess(terms);

}
Expand Down Expand Up @@ -1665,7 +1682,23 @@ public Set<ConstraintViolation> validate() {
}
}
}


TermsOfUseAndAccess toua = this.termsOfUseAndAccess;
//Only need to test Terms of Use and Access if there are restricted files
if (toua != null && this.isHasRestrictedFile()) {
Set<ConstraintViolation<TermsOfUseAndAccess>> constraintViolations = validator.validate(toua);
if (constraintViolations.size() > 0) {
ConstraintViolation<TermsOfUseAndAccess> violation = constraintViolations.iterator().next();
String message = "Constraint violation found in Terms of Use and Access. "
+ "If Request Access to restricted files is disabled then Terms of Access must be provided.";
Copy link
Member

Choose a reason for hiding this comment

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

Should this English text go in Bundle.properties?

logger.info(message);
this.termsOfUseAndAccess.setValidationMessage(message);
returnSet.add(violation);
}
}


return returnSet;
}

Expand Down
Loading