Java Code Examples for org.primefaces.event.FileUploadEvent#getFile()

The following examples show how to use org.primefaces.event.FileUploadEvent#getFile() . 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: 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 4
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 5
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 6
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 7
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 8
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();
}
 
Example 9
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 10
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 11
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 12
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 13
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 14
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 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 setOxTrustFaviconImage(FileUploadEvent event) {
	UploadedFile uploadedFile = event.getFile();
	saveFavIcon(uploadedFile);
}
 
Example 17
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 18
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);
			}
		}
	}
}