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

make the application build w/ PrimeFaces 7 #6281

Merged
merged 1 commit into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
<version>7.0</version>
Copy link
Member

Choose a reason for hiding this comment

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

7.0.8 is shown at https://www.primefaces.org/downloads/ but my understanding is that we cannot use it without paying for it. There seem to be a variety of bug fixes in https://github.com/primefaces/primefaces/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A7.0.8 for example. Longer term I think we should not depend on software where that requires you to pay for security updates. primefaces/primefaces#4913 is an example of a cross-site scripting vulnerability that was fixed in PrimeFaces 7.0.5. See also some related discussion about security concerns for open source projects using PrimeFaces in the following places:

</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
Expand Down
56 changes: 28 additions & 28 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
import org.primefaces.model.UploadedFile;
import javax.validation.ConstraintViolation;
import org.apache.commons.httpclient.HttpClient;
import org.primefaces.context.RequestContext;
//import org.primefaces.context.RequestContext;
import java.util.Arrays;
import java.util.HashSet;
import javax.faces.model.SelectItem;
Expand Down Expand Up @@ -1039,8 +1039,8 @@ public boolean showComputeButton(FileMetadata metadata) {
public boolean canComputeAllFiles(boolean isCartCompute){
for (FileMetadata fmd : workingVersion.getFileMetadatas()) {
if (!fileDownloadHelper.canDownloadFile(fmd)) {
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('computeInvalid').show()");
//RequestContext requestContext = RequestContext.getCurrentInstance();
PrimeFaces.current().executeScript("PF('computeInvalid').show()");
return false;
}
}
Expand Down Expand Up @@ -2805,8 +2805,8 @@ public void validateFilesForDownload(boolean guestbookRequired, boolean download
setSelectedNonDownloadableFiles(new ArrayList<>());

if (this.selectedFiles.isEmpty()) {
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('selectFilesForDownload').show()");
//RequestContext requestContext = RequestContext.getCurrentInstance();
PrimeFaces.current().executeScript("PF('selectFilesForDownload').show()");
return;
}
for (FileMetadata fmd : this.selectedFiles){
Expand All @@ -2821,8 +2821,8 @@ public void validateFilesForDownload(boolean guestbookRequired, boolean download
// list, and NONE of the files are left on the downloadable list
// - we show them a "you're out of luck" popup:
if(getSelectedDownloadableFiles().isEmpty() && !getSelectedNonDownloadableFiles().isEmpty()){
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('downloadInvalid').show()");
//RequestContext requestContext = RequestContext.getCurrentInstance();
PrimeFaces.current().executeScript("PF('downloadInvalid').show()");
return;
}

Expand Down Expand Up @@ -2858,8 +2858,8 @@ public void validateFilesForDownload(boolean guestbookRequired, boolean download
// we are showing them this "you are somewhat in luck" popup; that will
// then direct them to the download, or popup, as needed:
if(!getSelectedDownloadableFiles().isEmpty() && !getSelectedNonDownloadableFiles().isEmpty()){
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('downloadMixed').show()");
//RequestContext requestContext = RequestContext.getCurrentInstance();
PrimeFaces.current().executeScript("PF('downloadMixed').show()");
}

}
Expand Down Expand Up @@ -3031,9 +3031,9 @@ public boolean isShowAccessPopup() {
public void setShowAccessPopup(boolean showAccessPopup) {} // dummy set method

public String testSelectedFilesForRestrict(){
RequestContext requestContext = RequestContext.getCurrentInstance();
//RequestContext requestContext = RequestContext.getCurrentInstance();
if (selectedFiles.isEmpty()) {
requestContext.execute("PF('selectFilesForRestrict').show()");
PrimeFaces.current().executeScript("PF('selectFilesForRestrict').show()");
return "";
} else {
boolean validSelection = true;
Expand All @@ -3044,24 +3044,24 @@ public String testSelectedFilesForRestrict(){
}
}
if (!validSelection) {
requestContext.execute("PF('selectFilesForRestrict').show()");
PrimeFaces.current().executeScript("PF('selectFilesForRestrict').show()");
return "";
}
testSelectedFilesForMapData();
requestContext.execute("PF('accessPopup').show()");
PrimeFaces.current().executeScript("PF('accessPopup').show()");
return "";
}
}


public String restrictSelectedFiles(boolean restricted) throws CommandException{

RequestContext requestContext = RequestContext.getCurrentInstance();
//RequestContext requestContext = RequestContext.getCurrentInstance();
if (selectedFiles.isEmpty()) {
if (restricted) {
requestContext.execute("PF('selectFilesForRestrict').show()");
PrimeFaces.current().executeScript("PF('selectFilesForRestrict').show()");
} else {
requestContext.execute("PF('selectFilesForUnRestrict').show()");
PrimeFaces.current().executeScript("PF('selectFilesForUnRestrict').show()");
}
return "";
} else {
Expand All @@ -3074,10 +3074,10 @@ public String restrictSelectedFiles(boolean restricted) throws CommandException{
}
if (!validSelection) {
if (restricted) {
requestContext.execute("PF('selectFilesForRestrict').show()");
PrimeFaces.current().executeScript("PF('selectFilesForRestrict').show()");
}
if (!restricted) {
requestContext.execute("PF('selectFilesForUnRestrict').show()");
PrimeFaces.current().executeScript("PF('selectFilesForUnRestrict').show()");
}
return "";
}
Expand Down Expand Up @@ -3858,8 +3858,8 @@ public void setDownloadType(String downloadType) {

public void openDownloadPopupForMultipleFileDownload() {
if (this.selectedFiles.isEmpty()) {
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('selectFilesForDownload').show()");
//RequestContext requestContext = RequestContext.getCurrentInstance();
PrimeFaces.current().executeScript("PF('selectFilesForDownload').show()");
return;
}

Expand All @@ -3869,8 +3869,8 @@ public void openDownloadPopupForMultipleFileDownload() {
// that's the case. -- L.A.

this.guestbookResponse.setDownloadtype("Download");
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('downloadPopup').show();handleResizeDialog('downloadPopup');");
//RequestContext requestContext = RequestContext.getCurrentInstance();
PrimeFaces.current().executeScript("PF('downloadPopup').show();handleResizeDialog('downloadPopup');");
}

public void initGuestbookMultipleResponse(String selectedFileIds){
Expand All @@ -3885,9 +3885,9 @@ public void initGuestbookResponse(FileMetadata fileMetadata, String downloadForm


public void compareVersionDifferences() {
RequestContext requestContext = RequestContext.getCurrentInstance();
//RequestContext requestContext = RequestContext.getCurrentInstance();
if (this.selectedVersions.size() != 2) {
requestContext.execute("openCompareTwo();");
PrimeFaces.current().executeScript("openCompareTwo();");
} else {
//order depends on order of selection - needs to be chronological order
if (this.selectedVersions.get(0).getId().intValue() > this.selectedVersions.get(1).getId().intValue()) {
Expand Down Expand Up @@ -4716,17 +4716,17 @@ public boolean isRequestAccessPopupRequired() {
public String requestAccessMultipleFiles() {

if (selectedFiles.isEmpty()) {
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('selectFilesForRequestAccess').show()");
//RequestContext requestContext = RequestContext.getCurrentInstance();
PrimeFaces.current().executeScript("PF('selectFilesForRequestAccess').show()");
return "";
} else {
fileDownloadHelper.clearRequestAccessFiles();
for (FileMetadata fmd : selectedFiles){
fileDownloadHelper.addMultipleFilesForRequestAccess(fmd.getDataFile());
}
if (isRequestAccessPopupRequired()) {
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('requestAccessPopup').show()");
//RequestContext requestContext = RequestContext.getCurrentInstance();
PrimeFaces.current().executeScript("PF('requestAccessPopup').show()");
return "";
} else {
//No popup required
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.apache.commons.lang.StringUtils;
import org.primefaces.context.RequestContext;
import org.primefaces.PrimeFaces;
//import org.primefaces.context.RequestContext;

/**
*
Expand Down Expand Up @@ -1755,9 +1756,11 @@ public void uploadFinished() {
}

if(isFileReplaceOperation() && fileReplacePageHelper.hasContentTypeWarning()){
RequestContext context = RequestContext.getCurrentInstance();
RequestContext.getCurrentInstance().update("datasetForm:fileTypeDifferentPopup");
context.execute("PF('fileTypeDifferentPopup').show();");
//RequestContext context = RequestContext.getCurrentInstance();
//RequestContext.getCurrentInstance().update("datasetForm:fileTypeDifferentPopup");
PrimeFaces.current().ajax().update("datasetForm:fileTypeDifferentPopup");
//context.execute("PF('fileTypeDifferentPopup').show();");
PrimeFaces.current().executeScript("PF('fileTypeDifferentPopup').show();");
}

// We clear the following duplicate warning labels, because we want to
Expand Down Expand Up @@ -1892,9 +1895,11 @@ public void handleFileUpload(FileUploadEvent event) throws IOException {
event,
null);
if(fileReplacePageHelper.hasContentTypeWarning()){
RequestContext context = RequestContext.getCurrentInstance();
RequestContext.getCurrentInstance().update("datasetForm:fileTypeDifferentPopup");
context.execute("PF('fileTypeDifferentPopup').show();");
//RequestContext context = RequestContext.getCurrentInstance();
//RequestContext.getCurrentInstance().update("datasetForm:fileTypeDifferentPopup");
//context.execute("PF('fileTypeDifferentPopup').show();");
PrimeFaces.current().ajax().update("datasetForm:fileTypeDifferentPopup");
PrimeFaces.current().executeScript("PF('fileTypeDifferentPopup').show();");
}
return;

Expand Down
37 changes: 23 additions & 14 deletions src/main/java/edu/harvard/iq/dataverse/FileDownloadHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.primefaces.context.RequestContext;
import org.primefaces.PrimeFaces;
//import org.primefaces.context.RequestContext;

/**
*
Expand Down Expand Up @@ -224,13 +225,14 @@ private boolean validateGuestbookResponse(GuestbookResponse guestbookResponse){
// file downloads and multiple (batch) downloads - sice both use the same
// terms/etc. popup.
public void writeGuestbookAndStartDownload(GuestbookResponse guestbookResponse) {
RequestContext requestContext = RequestContext.getCurrentInstance();
//RequestContext requestContext = RequestContext.getCurrentInstance();
boolean valid = validateGuestbookResponse(guestbookResponse);

if (!valid) {
JH.addMessage(FacesMessage.SEVERITY_ERROR, BundleUtil.getStringFromBundle("dataset.message.validationError"));
} else {
requestContext.execute("PF('downloadPopup').hide()");
//requestContext.execute("PF('downloadPopup').hide()");
PrimeFaces.current().executeScript("PF('downloadPopup').hide()");
guestbookResponse.setDownloadtype("Download");

// Note that this method is only ever called from the file-download-popup -
Expand All @@ -252,14 +254,16 @@ public void writeGuestbookAndStartDownload(GuestbookResponse guestbookResponse)
}

public void writeGuestbookAndOpenSubset(GuestbookResponse guestbookResponse) {
RequestContext requestContext = RequestContext.getCurrentInstance();
//RequestContext requestContext = RequestContext.getCurrentInstance();
boolean valid = validateGuestbookResponse(guestbookResponse);

if (!valid) {

} else {
requestContext.execute("PF('downloadPopup').hide()");
requestContext.execute("PF('downloadDataSubsetPopup').show()");
//requestContext.execute("PF('downloadPopup').hide()");
PrimeFaces.current().executeScript("PF('downloadPopup').hide()");
//requestContext.execute("PF('downloadDataSubsetPopup').show()");
PrimeFaces.current().executeScript("PF('downloadDataSubsetPopup').show()");
guestbookResponse.setDownloadtype("Subset");
fileDownloadService.writeGuestbookResponseRecord(guestbookResponse);
}
Expand Down Expand Up @@ -298,42 +302,47 @@ public void writeGuestbookAndLaunchExploreTool(GuestbookResponse guestbookRespon
}
}

RequestContext requestContext = RequestContext.getCurrentInstance();
//RequestContext requestContext = RequestContext.getCurrentInstance();
boolean valid = validateGuestbookResponse(guestbookResponse);

if (!valid) {
return;
}
fileDownloadService.explore(guestbookResponse, fmd, externalTool);
requestContext.execute("PF('downloadPopup').hide()");
//requestContext.execute("PF('downloadPopup').hide()");
PrimeFaces.current().executeScript("PF('downloadPopup').hide()");
}

public void writeGuestbookAndLaunchPackagePopup(GuestbookResponse guestbookResponse) {
RequestContext requestContext = RequestContext.getCurrentInstance();
//RequestContext requestContext = RequestContext.getCurrentInstance();
boolean valid = validateGuestbookResponse(guestbookResponse);

if (!valid) {
JH.addMessage(FacesMessage.SEVERITY_ERROR, BundleUtil.getStringFromBundle("dataset.message.validationError"));
} else {
requestContext.execute("PF('downloadPopup').hide()");
requestContext.execute("PF('downloadPackagePopup').show()");
requestContext.execute("handleResizeDialog('downloadPackagePopup')");
//requestContext.execute("PF('downloadPopup').hide()");
PrimeFaces.current().executeScript("PF('downloadPopup').hide()");
//requestContext.execute("PF('downloadPackagePopup').show()");
PrimeFaces.current().executeScript("PF('downloadPackagePopup').show()");
//requestContext.execute("handleResizeDialog('downloadPackagePopup')");
PrimeFaces.current().executeScript("handleResizeDialog('downloadPackagePopup')");

fileDownloadService.writeGuestbookResponseRecord(guestbookResponse);
}
}

public String startWorldMapDownloadLink(GuestbookResponse guestbookResponse, FileMetadata fmd){

RequestContext requestContext = RequestContext.getCurrentInstance();
//RequestContext requestContext = RequestContext.getCurrentInstance();
boolean valid = validateGuestbookResponse(guestbookResponse);

if (!valid) {
return "";
}
guestbookResponse.setDownloadtype("WorldMap");
String retVal = fileDownloadService.startWorldMapDownloadLink(guestbookResponse, fmd);
requestContext.execute("PF('downloadPopup').hide()");
//requestContext.execute("PF('downloadPopup').hide()");
PrimeFaces.current().executeScript("PF('downloadPopup').hide()");
return retVal;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import javax.servlet.http.HttpServletResponse;

import org.primefaces.PrimeFaces;
import org.primefaces.context.RequestContext;
//import org.primefaces.context.RequestContext;

/**
*
Expand Down

This file was deleted.

Loading