org.primefaces.event.FileUploadEvent Java Examples

The following examples show how to use org.primefaces.event.FileUploadEvent. 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: TestScriptsBean.java    From sailfish-core with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: EnvironmentBean.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
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 #3
Source File: WorkbookService.java    From Html5_Spreadsheet_Editor_by_Aspose.Cells_for_Java with MIT License 5 votes vote down vote up
public void onFileUpload(FileUploadEvent e) {
    try {
        this.current = loader.fromInputStream(e.getFile().getInputstream(), e.getFile().getFileName());
    } catch (IOException x) {
        LOGGER.throwing(null, null, x);
        msg.sendMessage("Could not read the uploaded file", x.getMessage());
    }
}
 
Example #4
Source File: FileUploadManagedBean.java    From journaldev with MIT License 5 votes vote down vote up
public void fileUploadListener(FileUploadEvent e){
	// Get uploaded file from the FileUploadEvent
	this.file = e.getFile();
	// Print out the information of the file
	System.out.println("Uploaded File Name Is :: "+file.getFileName()+" :: Uploaded File Size :: "+file.getSize());
	// Add message
	FacesContext.getCurrentInstance().addMessage(null,new FacesMessage("File Uploaded Successfully"));
}
 
Example #5
Source File: InputFieldBean.java    From ctsms with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 #6
Source File: JobBean.java    From ctsms with GNU Lesser General Public License v2.1 5 votes vote down vote up
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: PhotoBeanBase.java    From ctsms with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 #8
Source File: MediaController.java    From aws-photosharing-example with Apache License 2.0 5 votes vote down vote up
public void handleFileUpload(FileUploadEvent e) {
	try {			
		ContentFacade facade = new ContentFacade();
		facade.uploadPictureToS3(getSessionUser(), e.getFile().getFileName(), e.getFile().getInputstream(), e.getFile().getContentType(), (Comment[]) null);
		facade.done();
		_userMedia = null;
	} catch (IOException e1) {
		e1.printStackTrace();
	}		
}
 
Example #9
Source File: DictionariesBean.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
public void handleFileUpload(FileUploadEvent event) {

        this.uploadFile = event.getFile();

        if(!getModel().handleFileUpload(uploadFile)) {
            this.uploadFile = null;
        }
    }
 
Example #10
Source File: EnvironmentBean.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
public synchronized void handleVariableSetsImport(FileUploadEvent event) throws FileNotFoundException {
    logger.info("handleVariableSetsImport invoked {}", getUser());

    try {
        TestToolsAPI.getInstance().importVariableSets(event.getFile().getInputstream(), replaceExistingVariableSets);
    } catch(Exception e) {
        logger.error("Failed to import variable sets", e);
        BeanUtil.showMessage(FacesMessage.SEVERITY_ERROR, "", e.getMessage());
        return;
    }

    RequestContext.getCurrentInstance().update("form");

    logger.info("Import finished");
}
 
Example #11
Source File: FileBean.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
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 #12
Source File: ToolsBean.java    From sailfish-core with Apache License 2.0 4 votes vote down vote up
public void handleFileUpload(FileUploadEvent event) {
    logger.info("{} has been uploaded", event.getFile().getFileName());
    uploadedFiles.add(getFile(event.getFile()));
}
 
Example #13
Source File: UpdateOrganizationAction.java    From oxTrust with MIT License 4 votes vote down vote up
public void setOxTrustLogoImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveLogo(uploadedFile);
}
 
Example #14
Source File: UpdateOrganizationAction.java    From oxTrust with MIT License 4 votes vote down vote up
public void setOxTrustFaviconImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveFavIcon(uploadedFile);
}
 
Example #15
Source File: UpdateOrganizationAction.java    From oxTrust with MIT License 4 votes vote down vote up
public void setOxAuthLogoImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveOxAuthLogo(uploadedFile);
}
 
Example #16
Source File: UpdateOrganizationAction.java    From oxTrust with MIT License 4 votes vote down vote up
public void setOxAuthFaviconImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveOxAuthFavIcon(uploadedFile);
}
 
Example #17
Source File: UpdateOrganizationAction.java    From oxTrust with MIT License 4 votes vote down vote up
public void setIdpLogoImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveIdpLogo(uploadedFile);
}
 
Example #18
Source File: UpdateOrganizationAction.java    From oxTrust with MIT License 4 votes vote down vote up
public void setdpFaviconImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveIdpFavIcon(uploadedFile);
}
 
Example #19
Source File: UpdateOrganizationAction.java    From oxTrust with MIT License 4 votes vote down vote up
public void addNewOxtrustLib(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	addLib(uploadedFile, true);
}
 
Example #20
Source File: UpdateOrganizationAction.java    From oxTrust with MIT License 4 votes vote down vote up
public void addNewOxauthLib(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	addLib(uploadedFile, false);
}
 
Example #21
Source File: AttributeImportAction.java    From oxTrust with MIT License 4 votes vote down vote up
public void uploadFile(FileUploadEvent event) {
	removeFileToImport();
	this.uploadedFile = event.getFile();
	this.fileData = this.uploadedFile.getContent();
}
 
Example #22
Source File: PersonImportAction.java    From oxTrust with MIT License 4 votes vote down vote up
public void handleFileUpload(FileUploadEvent event) {
	this.file = null;
	this.fileDataToImport.reset();
	this.file = event.getFile();
	this.fileData = this.file.getContent();
}