Java Code Examples for org.primefaces.event.FileUploadEvent

The following examples show how to use org.primefaces.event.FileUploadEvent. These examples are extracted from open source projects. 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 Project: sailfish-core   Source File: TestScriptsBean.java    License: 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 Project: sailfish-core   Source File: EnvironmentBean.java    License: 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 Project: sailfish-core   Source File: EnvironmentBean.java    License: 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 4
Source Project: sailfish-core   Source File: DictionariesBean.java    License: 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 5
Source Project: aws-photosharing-example   Source File: MediaController.java    License: 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 6
Source Project: ctsms   Source File: PhotoBeanBase.java    License: 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 7
Source Project: ctsms   Source File: JobBean.java    License: 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 8
Source Project: ctsms   Source File: InputFieldBean.java    License: 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 9
Source Project: journaldev   Source File: FileUploadManagedBean.java    License: 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 10
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 11
Source Project: sailfish-core   Source File: ToolsBean.java    License: 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 12
Source Project: ctsms   Source File: FileBean.java    License: 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 13
Source Project: oxTrust   Source File: UpdateOrganizationAction.java    License: MIT License 4 votes vote down vote up
public void setOxTrustLogoImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveLogo(uploadedFile);
}
 
Example 14
Source Project: oxTrust   Source File: UpdateOrganizationAction.java    License: MIT License 4 votes vote down vote up
public void setOxTrustFaviconImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveFavIcon(uploadedFile);
}
 
Example 15
Source Project: oxTrust   Source File: UpdateOrganizationAction.java    License: MIT License 4 votes vote down vote up
public void setOxAuthLogoImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveOxAuthLogo(uploadedFile);
}
 
Example 16
Source Project: oxTrust   Source File: UpdateOrganizationAction.java    License: MIT License 4 votes vote down vote up
public void setOxAuthFaviconImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveOxAuthFavIcon(uploadedFile);
}
 
Example 17
Source Project: oxTrust   Source File: UpdateOrganizationAction.java    License: MIT License 4 votes vote down vote up
public void setIdpLogoImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveIdpLogo(uploadedFile);
}
 
Example 18
Source Project: oxTrust   Source File: UpdateOrganizationAction.java    License: MIT License 4 votes vote down vote up
public void setdpFaviconImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveIdpFavIcon(uploadedFile);
}
 
Example 19
Source Project: oxTrust   Source File: UpdateOrganizationAction.java    License: MIT License 4 votes vote down vote up
public void addNewOxtrustLib(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	addLib(uploadedFile, true);
}
 
Example 20
Source Project: oxTrust   Source File: UpdateOrganizationAction.java    License: MIT License 4 votes vote down vote up
public void addNewOxauthLib(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	addLib(uploadedFile, false);
}
 
Example 21
Source Project: oxTrust   Source File: AttributeImportAction.java    License: 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 Project: oxTrust   Source File: PersonImportAction.java    License: 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();
}