org.primefaces.model.UploadedFile Java Examples
The following examples show how to use
org.primefaces.model.UploadedFile.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DictionaryEditorModel.java From sailfish-core with Apache License 2.0 | 6 votes |
public boolean handleFileUpload(UploadedFile uploadFile) { ModifiableXmlDictionaryStructureLoader loader = new ModifiableXmlDictionaryStructureLoader(); try { try (InputStream in = uploadFile.getInputstream()) { this.uploadDict = loader.load(in); } populateDictFieldModels(fieldsToFieldEditorModels(uploadDict.getImplFieldStructures(), true)); return true; } catch (Exception ex) { logger.error("Can't parse uploaded dictionary", ex); BeanUtil.addErrorMessage("Error", "Can't parse uploaded dictionary"); this.uploadDict = null; return false; } }
Example #2
Source File: TestScriptsBean.java From sailfish-core with Apache License 2.0 | 6 votes |
public void handleFileUpload(FileUploadEvent event) { logger.debug("Upload invoked {}", BeanUtil.getUser()); UploadedFile uploadedFile = event.getFile() ; try { BeanUtil.getSfContext().getMatrixStorage().addMatrix(uploadedFile.getInputstream(), uploadedFile.getFileName(), null, "Unknown creator", null, null, null); } catch (Exception e) { logger.error("Could not store uploaded file", e); BeanUtil.showMessage(FacesMessage.SEVERITY_ERROR, "Error", "Could not store uploaded file " + e.getMessage() ); return; } logger.debug("Upload finished"); }
Example #3
Source File: EnvironmentBean.java From sailfish-core with Apache License 2.0 | 5 votes |
public synchronized void handleServicesUpload(FileUploadEvent event) throws FileNotFoundException { logger.info("handleServicesUpload invoked {}", getUser()); UploadedFile uploadedFile = event.getFile() ; InputStream stream; try { stream = uploadedFile.getInputstream(); } catch (IOException e) { logger.error("Could not get stream from uploaded file", e); BeanUtil.showMessage(FacesMessage.SEVERITY_ERROR, "", e.getMessage() ); return; } if (respectFileName) { int index = uploadedFile.getFileName().indexOf("_environment.zip"); if (index != -1) { currentEnvironment = uploadedFile.getFileName().substring(0, index); } } // For getting an environment name from environment_description.xml file ImportServicesResult importServicesResult = TestToolsAPI.getInstance().importServices(stream, uploadedFile.getFileName().endsWith(".zip"), currentEnvironment, replaceExistingServices, skipExistingServices, !respectFileName, notifyListener); setCurrentEnvironment(importServicesResult.getEnvironment()); changeEnvironment(); RequestContext.getCurrentInstance().update("form"); logger.info("Upload finished"); }
Example #4
Source File: ToolsBean.java From sailfish-core with Apache License 2.0 | 5 votes |
@NotNull private File getFile(UploadedFile uploadedFile) { try { Path tmpFile = Files.createTempFile(FilenameUtils.getBaseName(uploadedFile.getFileName()), "." + FilenameUtils.getExtension(uploadedFile.getFileName())); Files.copy(uploadedFile.getInputstream(), tmpFile, StandardCopyOption.REPLACE_EXISTING); return tmpFile.toFile(); } catch (IOException e) { logger.error(e.getMessage(), e); BeanUtil.showMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), ExceptionUtils.getStackTrace(e)); return null; } }
Example #5
Source File: PhotoBeanBase.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
public void handleFileUpload(FileUploadEvent event) { UploadedFile uploadedFile = event.getFile(); setFileName(uploadedFile.getFileName()); setMimeType(uploadedFile.getContentType()); setData(uploadedFile.getContents()); setTimestamp(new Date()); storeImage(); Messages.addLocalizedMessage(FacesMessage.SEVERITY_INFO, MessageCodes.UPLOAD_OPERATION_SUCCESSFUL); }
Example #6
Source File: JobBean.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
public void handleFileUpload(FileUploadEvent event) { UploadedFile uploadedFile = event.getFile(); in.setFileName(uploadedFile.getFileName()); in.setMimeType(uploadedFile.getContentType()); in.setDatas(uploadedFile.getContents()); addOperationSuccessMessage(MessageCodes.UPLOAD_OPERATION_SUCCESSFUL); }
Example #7
Source File: InputFieldBean.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
public void handleFileUpload(FileUploadEvent event) { UploadedFile uploadedFile = event.getFile(); in.setFileName(uploadedFile.getFileName()); in.setMimeType(uploadedFile.getContentType()); in.setDatas(uploadedFile.getContents()); in.setWidth(null); in.setHeight(null); addOperationSuccessMessage(MessageCodes.UPLOAD_OPERATION_SUCCESSFUL); }
Example #8
Source File: FileBean.java From ctsms with GNU Lesser General Public License v2.1 | 4 votes |
public void handleFileUpload(FileUploadEvent event) { if (streamUploadEnabled == null) { Messages.addLocalizedMessage(FacesMessage.SEVERITY_ERROR, MessageCodes.FILE_STREAM_UPLOAD_MODE_UNDEFINED); return; } UploadedFile uploadedFile = event.getFile(); if (streamUploadEnabled) { contentIn = null; streamIn = new FileStreamInVO(); streamIn.setFileName(uploadedFile.getFileName()); streamIn.setMimeType(uploadedFile.getContentType()); streamIn.setSize(uploadedFile.getSize()); try { streamIn.setStream(uploadedFile.getInputstream()); addOperationSuccessMessage(MessageCodes.UPLOAD_OPERATION_SUCCESSFUL); } catch (IOException e) { streamIn = null; Messages.addMessage(FacesMessage.SEVERITY_ERROR, e.getMessage()); return; } } else { streamIn = null; contentIn = new FileContentInVO(); contentIn.setFileName(uploadedFile.getFileName()); contentIn.setMimeType(uploadedFile.getContentType()); contentIn.setDatas(uploadedFile.getContents()); addOperationSuccessMessage(MessageCodes.UPLOAD_OPERATION_SUCCESSFUL); } if (!(in.getTitle() != null && in.getTitle().length() > 0) || in.getTitle().equals(Messages.getString(MessageCodes.FILE_TITLE_PRESET))) { in.setTitle(uploadedFile.getFileName()); if (isCreateable()) { String path = CommonUtil.fixLogicalPathFolderName(in.getLogicalPath()); if (ADD_OUTCOME.equals(addAction(false))) { lastUploadedOut = out; out = null; initIn(); in.setLogicalPath(path); } } } }
Example #9
Source File: FileUploadManagedBean.java From journaldev with MIT License | 4 votes |
public void setFile(UploadedFile file) { this.file = file; }
Example #10
Source File: FileUploadManagedBean.java From journaldev with MIT License | 4 votes |
public UploadedFile getFile() { return file; }
Example #11
Source File: ModelTemplateController.java From ipst with Mozilla Public License 2.0 | 4 votes |
public void setDataFile(UploadedFile dataFile) { this.dataFile = dataFile; }
Example #12
Source File: ModelTemplateController.java From ipst with Mozilla Public License 2.0 | 4 votes |
public UploadedFile getDataFile() { return dataFile; }
Example #13
Source File: ModelTemplateContainerController.java From ipst with Mozilla Public License 2.0 | 4 votes |
public void setUploadData(UploadedFile uploadData) { this.uploadData = uploadData; }
Example #14
Source File: ModelTemplateContainerController.java From ipst with Mozilla Public License 2.0 | 4 votes |
public UploadedFile getUploadData() { return uploadData; }
Example #15
Source File: DictionariesBean.java From sailfish-core with Apache License 2.0 | 4 votes |
public void setUploadFile(UploadedFile uploadFile) { this.uploadFile = uploadFile; }
Example #16
Source File: DictionariesBean.java From sailfish-core with Apache License 2.0 | 4 votes |
public UploadedFile getUploadFile() { return uploadFile; }
Example #17
Source File: BigButtonBean.java From sailfish-core with Apache License 2.0 | 4 votes |
public void setUploadedFile(UploadedFile uploadedFile) { this.uploadedFile = uploadedFile; }
Example #18
Source File: BigButtonBean.java From sailfish-core with Apache License 2.0 | 4 votes |
public UploadedFile getUploadedFile() { return uploadedFile; }