use of org.primefaces.context.RequestContext in project dataverse by IQSS.
the class DatasetPage method modifyGuestbookMultipleResponse.
public void modifyGuestbookMultipleResponse() {
if (this.selectedFiles.isEmpty()) {
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('selectFilesForDownload').show()");
return;
}
this.guestbookResponse = this.guestbookResponseService.modifySelectedFileIds(guestbookResponse, getSelectedDownloadableFilesIdsString());
this.guestbookResponse.setDownloadtype("Download");
this.guestbookResponse.setFileFormat("Download");
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('downloadPopup').show();handleResizeDialog('downloadPopup');");
}
use of org.primefaces.context.RequestContext in project dataverse by IQSS.
the class DatasetPage method restrictSelectedFiles.
public String restrictSelectedFiles(boolean restricted) throws CommandException {
RequestContext requestContext = RequestContext.getCurrentInstance();
if (selectedFiles.isEmpty()) {
if (restricted) {
requestContext.execute("PF('selectFilesForRestrict').show()");
} else {
requestContext.execute("PF('selectFilesForUnRestrict').show()");
}
return "";
} else {
boolean validSelection = false;
for (FileMetadata fmd : selectedFiles) {
if ((fmd.isRestricted() && !restricted) || (!fmd.isRestricted() && restricted)) {
validSelection = true;
}
}
if (!validSelection) {
if (restricted) {
requestContext.execute("PF('selectFilesForRestrict').show()");
}
if (!restricted) {
requestContext.execute("PF('selectFilesForUnRestrict').show()");
}
return "";
}
}
if (editMode != EditMode.CREATE) {
if (bulkUpdateCheckVersion()) {
refreshSelectedFiles();
}
restrictFiles(restricted);
}
save();
return returnToDraftVersion();
}
use of org.primefaces.context.RequestContext in project dataverse by IQSS.
the class DatasetPage method requestAccessMultipleFiles.
public String requestAccessMultipleFiles() {
if (selectedFiles.isEmpty()) {
RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("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()");
return "";
} else {
// No popup required
fileDownloadHelper.requestAccessIndirect();
return "";
}
}
}
use of org.primefaces.context.RequestContext in project dataverse by IQSS.
the class EditDatafilesPage method handleFileUpload.
/**
* Handle native file replace
* @param event
* @throws java.io.IOException
*/
public void handleFileUpload(FileUploadEvent event) throws IOException {
if (!uploadInProgress) {
uploadInProgress = true;
}
if (event == null) {
throw new NullPointerException("event cannot be null");
}
UploadedFile uFile = event.getFile();
if (uFile == null) {
throw new NullPointerException("uFile cannot be null");
}
/**
* For File Replace, take a different code path
*/
if (isFileReplaceOperation()) {
handleReplaceFileUpload(event, uFile.getInputstream(), uFile.getFileName(), uFile.getContentType(), event, null);
if (fileReplacePageHelper.hasContentTypeWarning()) {
RequestContext context = RequestContext.getCurrentInstance();
RequestContext.getCurrentInstance().update("datasetForm:fileTypeDifferentPopup");
context.execute("PF('fileTypeDifferentPopup').show();");
}
return;
}
List<DataFile> dFileList = null;
try {
// Note: A single uploaded file may produce multiple datafiles -
// for example, multiple files can be extracted from an uncompressed
// zip file.
dFileList = FileUtil.createDataFiles(workingVersion, uFile.getInputstream(), uFile.getFileName(), uFile.getContentType(), systemConfig);
} catch (IOException ioex) {
logger.warning("Failed to process and/or save the file " + uFile.getFileName() + "; " + ioex.getMessage());
return;
}
/*catch (FileExceedsMaxSizeException ex) {
logger.warning("Failed to process and/or save the file " + uFile.getFileName() + "; " + ex.getMessage());
return;
}*/
// -----------------------------------------------------------
// These raw datafiles are then post-processed, in order to drop any files
// already in the dataset/already uploaded, and to correct duplicate file names, etc.
// -----------------------------------------------------------
String warningMessage = processUploadedFileList(dFileList);
if (warningMessage != null) {
uploadWarningMessage = warningMessage;
FacesContext.getCurrentInstance().addMessage(event.getComponent().getClientId(), new FacesMessage(FacesMessage.SEVERITY_ERROR, "upload warning", warningMessage));
// save the component id of the p:upload widget, so that we could
// send an info message there, from elsewhere in the code:
uploadComponentId = event.getComponent().getClientId();
}
}
use of org.primefaces.context.RequestContext in project dataverse by IQSS.
the class FileDownloadHelper method writeGuestbookAndOpenSubset.
public void writeGuestbookAndOpenSubset(GuestbookResponse guestbookResponse) {
RequestContext requestContext = RequestContext.getCurrentInstance();
boolean valid = validateGuestbookResponse(guestbookResponse);
if (!valid) {
} else {
requestContext.execute("PF('downloadPopup').hide()");
requestContext.execute("PF('downloadDataSubsetPopup').show()");
guestbookResponse.setDownloadtype("Subset");
fileDownloadService.writeGuestbookResponseRecord(guestbookResponse);
}
}
Aggregations