当前位置: 首页>>代码示例>>Java>>正文


Java UploadItem类代码示例

本文整理汇总了Java中org.richfaces.model.UploadItem的典型用法代码示例。如果您正苦于以下问题:Java UploadItem类的具体用法?Java UploadItem怎么用?Java UploadItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UploadItem类属于org.richfaces.model包,在下文中一共展示了UploadItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uploadListener

import org.richfaces.model.UploadItem; //导入依赖的package包/类
public void uploadListener(UploadEvent event) {
    UploadItem item = event.getUploadItem();
    if (item.isTempFile()) {
    } else {
        try {
            String fname = item.getFileName();
            int i = fname.lastIndexOf('/');
            if (i == -1) {
                i = fname.lastIndexOf('\\');
            }
            if (i != -1) {
                fname = fname.substring(i);
            }

            FileOutputStream fout = new FileOutputStream(getFwPath() + fname);
            fout.write(item.getData());
            fout.close();
        } catch (Exception e) {
            // TODO: handle exception
        }

    }
}
 
开发者ID:navisidhu,项目名称:libreacs,代码行数:24,代码来源:SoftwaresBean.java

示例2: atualizaLogotipoEmpresa

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Transforma qualquer arquivo que vier (img, zip, gzip, pdf, word) numa colecao de imagens para processamento
 * @param uploadedFile
 * @return
 */
protected void atualizaLogotipoEmpresa(UploadItem uploadItem) {
	String contentType = uploadItem.getContentType();
	byte[] data = getData(uploadItem);

	ByteArrayInputStream bais = new ByteArrayInputStream(data);
	
	BufferedImage bufferedImage;
	try {
		bufferedImage = ImageIO.read(bais);
	} catch (IOException e) {
		throw new JazzRuntimeException("Erro ao tentar ler imagem contida no array de bytes",e);
	}
	
	getEmpresaVO().getLogos().clear();
	
	ImageLogoVO imageLogoVO = new ImageLogoVO();
	imageLogoVO.setImage(bufferedImage);
	
	getEmpresaVO().getLogos().add(imageLogoVO);

}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:27,代码来源:ConfiguracoesJSFBean.java

示例3: actionHandleFileUpload

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
* Action
* @param event
* @throws IOException 
*/
public void actionHandleFileUpload(UploadEvent event) throws IOException {  
	QuestionVO editQuestion = getEditQuestion();
	
	if(editQuestion==null){
		return;
	}
	
	if(editQuestion.getImageVOs().size()>=QuestionnaireJSFBean.MAX_IMAGES_PER_QUESTION){
		addMessage(FacesMessage.SEVERITY_ERROR, "Não é possível carregar mais de "+QuestionnaireJSFBean.MAX_IMAGES_PER_QUESTION+" imagens por questão!", "");
		return;
	}
	

	List<UploadItem> files = event.getUploadItems();
	
	for (UploadItem uploadItem : files) {
		if(isImage(uploadItem)){
			attachQuestionImage(editQuestion, uploadItem);
		}
}  	
	
  addMessage(FacesMessage.SEVERITY_INFO, "Imagens carregadas com sucesso!", "");
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:29,代码来源:QuestionnaireJSFBean.java

示例4: isImage

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * @param uploadItem
 * @return
 */
protected boolean isImage(UploadItem uploadItem) {
	String contentType=uploadItem.getContentType();
	
	String imageTypes = 
	
	"#"+"image/gif"+"#"+
	"#"+"image/jpeg"+"#"+
	"#"+"image/png"+"#"+
	"#"+"image/x-png"+"#"+
	"#"+"image/pjpeg"+"#"+
	"#"+"image/tiff"+"#"+
	"#"+"image/bmp"+"#";
	
	return imageTypes.contains(contentType);
	
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:21,代码来源:QuestionnaireJSFBean.java

示例5: onReadAvailableLanguages

import org.richfaces.model.UploadItem; //导入依赖的package包/类
public void onReadAvailableLanguages(ActionEvent event) throws IOException {
    this.availableLanguages.clear();

    for (UploadItem item : this.uploadedConcepts) {
        byte[] fileData;
        if (item.isTempFile()) {
            fileData = FileUtils.readFileToByteArray(item.getFile());
        } else {
            fileData = item.getData();
        }

        String xml = new String(fileData);

        String[] languages = metaDataFacade.getLanguagesAvailableForImport(
                xml);

        for (String lang : languages) {
            lang = lang.replaceAll("-", "_");
            Locale locale = LocaleUtils.toLocale(lang);
            this.availableLanguages.put(locale.getDisplayLanguage(), lang);
        }
    }
}
 
开发者ID:getconverge,项目名称:converge-1.x,代码行数:24,代码来源:Concepts.java

示例6: onImport

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Event handler for importing the uploaded subject files.
 *
 * @param event Event that invoked the handler
 * @throws IOException If any of the uploaded files could not be read
 */
public void onImport(ActionEvent event) throws IOException {
    int imported = 0;
    for (UploadItem item : this.uploadedConcepts) {

        byte[] fileData;
        if (item.isTempFile()) {
            fileData = FileUtils.readFileToByteArray(item.getFile());
        } else {
            fileData = item.getData();
        }

        String xml = new String(fileData);

        if (getImportLanguage() != null) {
            imported += metaDataFacade.importKnowledgeItem(xml,
                    getImportLanguage());
        }
    }

    JsfUtils.createMessage("frmSubjects", FacesMessage.SEVERITY_INFO, Bundle.i18n.name(),
            "Concepts_X_SUBJECTS_IMPORTED", new Object[]{imported});
}
 
开发者ID:getconverge,项目名称:converge-1.x,代码行数:29,代码来源:Concepts.java

示例7: onUploadRendition

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Event handler for uploading a new {@link Rendition} to the
 * {@link MediaItem}
 *
 * @param event Event that invoked the handler
 * @throws IOException If the file could not be uploaded
 */
public void onUploadRendition(UploadEvent event) throws IOException {
    UploadItem item = event.getUploadItem();
    LOG.log(Level.FINE, "Uploading {0}", item.getFileName());

    MediaItemRendition mediaItemRendition;
    try {
        mediaItemRendition = catalogueFacade.create(item.getFile(),
                getSelectedMediaItem(),
                getUploadRendition(),
                item.getFileName(),
                item.getContentType(),
                true);
        LOG.log(Level.FINE, "New media item rendition created: {0}", mediaItemRendition.getId());
    } catch (IOException ex) {
        LOG.log(Level.SEVERE, "Could not create media item rendition. {0}", ex.getMessage());
        LOG.log(Level.FINEST, "", ex);
    }
}
 
开发者ID:getconverge,项目名称:converge-1.x,代码行数:26,代码来源:MediaItemDetails.java

示例8: onUploadReplaceRendition

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Event handler for uploading a replacement for an existing
 * {@link Rendition}.
 *
 * @param event Event that invoked the handler
 * @throws IOException If the file could not be uploaded
 */
public void onUploadReplaceRendition(UploadEvent event) throws IOException {
    UploadItem item = event.getUploadItem();
    LOG.log(Level.FINE, "Uploading {0}", item.getFileName());

    MediaItemRendition mediaItemRendition;
    try {
        mediaItemRendition = catalogueFacade.update(item.getFile(),
                item.getFileName(),
                item.getContentType(),
                getSelectedRendition(),
                true);
        LOG.log(Level.FINE, "Media item rendition #{0} was updated.", mediaItemRendition.getId());
    } catch (IOException ex) {
        LOG.log(Level.SEVERE, "Could not create media item rendition. {0}", ex.getMessage());
    }
}
 
开发者ID:getconverge,项目名称:converge-1.x,代码行数:24,代码来源:MediaItemDetails.java

示例9: prepararArquivoParaEnviar

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Prepara o UploadItem com o arquivo de producao.xlf
 */
public void prepararArquivoParaEnviar(){
 	String nome_arquivo = "producao.xfl";
 	String caminho = Constantes.CAMINHO_ABSOLUTO_ARQUIVOS_CARGA + nome_arquivo;
	java.io.File file = new java.io.File(caminho);
	
	byte[] b = new byte[(int) file.length()];
	
	try {
		FileInputStream fileInputStream = new FileInputStream(file);
		fileInputStream.read(b);
	} catch (FileNotFoundException e) {
		System.out.println("File Not Found.");
		e.printStackTrace();
	} catch (IOException e1) {
		System.out.println("Error Reading The File.");
		e1.printStackTrace();
	}
	
	itemParaEnvio = new UploadItem(nome_arquivo,(int)file.length(),"xfl",b);
}
 
开发者ID:dayse,项目名称:gesplan,代码行数:24,代码来源:CargaEstudoIncluiModelagemFuzzy.java

示例10: salvarArquivoModelagemFuzzy

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Metodo resposavel por salvar os dados de um arquivo de modelagem fuzzy(.xfl).
 * Chama o motor de inferencia e utiliza o metodo salvarArquivoModelagem passando o caminho do arquivo
 * e os dados a serem incluidos.
 * Se o metodo anterior jogar uma motorInferencia exception ele a converte para uma applicationexception e joga para cima.
 * Com isso a parte que lida com a gravacao dos dados em arquivo fica ligada apenas ao motorinferencia.
 * 
 */
@Transacional
public void salvarArquivoModelagemFuzzy(UploadItem item) throws AplicacaoException {

   	String caminhoDoArquivo = Constantes.CAMINHO_ABSOLUTO_MODELAGEM_UPLOADFILE;

   	System.out.println("Destino do arquivo="+caminhoDoArquivo);
   	System.out.println("original="+item.getFileName());
   	
   	String filePathName = item.getFileName();
   	String fileName = "";
   	StringTokenizer st = new StringTokenizer(filePathName,"\\");    	
   	while(st.hasMoreElements()){
   		fileName = st.nextToken();
   	}
   	
   	
   	caminhoDoArquivo = caminhoDoArquivo  + fileName;
   	
   	try {
		MotorInferencia.salvarArquivoModelagem(caminhoDoArquivo, item.getData());
	} catch (MotorInferenciaException e) {
		throw new AplicacaoException(e.getMessage());
	}
}
 
开发者ID:dayse,项目名称:gesplan,代码行数:33,代码来源:ModelagemFuzzyAppService.java

示例11: incluiComUpload

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * Inclui uma modelagem fuzzy junto com o arquivo que foi feito upload, dessa forma ambos os passos ficam ligados.
 * Apois incluir a modelagem fuzzy desejada no BD, ele tenta salvar o arquivo em si no sistema.
 * Se um dos passos falhar ele volta sem deixar lixo.
 * @param modelagemFuzzy
 * @param item
 * @return
 * @throws AplicacaoException
 */
@Transacional
public long incluiComUpload(ModelagemFuzzy modelagemFuzzy, UploadItem item) throws AplicacaoException {
	
	
	long retorno = -1;
	
	try {
		modelagemFuzzyDAO.recuperaModelagemFuzzyPeloNome(modelagemFuzzy.getNomeModelagemFuzzy());
		throw new AplicacaoException("modelagem.CODIGO_MODELAGEM_EXISTENTE");
	} catch (ObjetoNaoEncontradoException e) {		
			retorno = modelagemFuzzyDAO.inclui(modelagemFuzzy).getId();		
			salvarArquivoModelagemFuzzy(item);
	}		

	return retorno;
}
 
开发者ID:dayse,项目名称:gesplan,代码行数:26,代码来源:ModelagemFuzzyAppService.java

示例12: uploadListener

import org.richfaces.model.UploadItem; //导入依赖的package包/类
public void uploadListener(UploadEvent event) {
    UploadItem item = event.getUploadItem();

    System.out.println("item : '" + item);
    System.out.println("File : '" + item.getFileName() + "' was uploaded");
    System.out.println("Content-type : '" + item.getContentType());
    System.out.println("Data : '" + item.getData());
    System.out.println("IsTemporary : '" + item.isTempFile());
    //        System.out.println("Length : '" + item.getData().length);
    System.out.println("javaFile : '" + item.getFile());

    String fname = item.getFileName();
    int i = fname.lastIndexOf('/');
    if (i == -1) {
        i = fname.lastIndexOf('\\');
    }
    if (i != -1) {
        fname = fname.substring(i);
    }
    fname = getFwPath() + fname;
    if (item.isTempFile()) {
        try {
            File tmpfile = item.getFile();
            if (!tmpfile.renameTo(new File(fname))) {
                setErrorMessage("Failed to rename file '" + tmpfile.getCanonicalPath() + "' to '" + fname + "'");
            }
        } catch (Exception ex) {
            setErrorMessage(ex.getMessage());
        }
    } else {
        try {
            FileOutputStream fout = new FileOutputStream(fname);
            fout.write(item.getData());
            fout.close();
        } catch (Exception e) {
            setErrorMessage(e.getMessage());
        }

    }
}
 
开发者ID:navisidhu,项目名称:libreacs,代码行数:41,代码来源:SoftwareJsfBean.java

示例13: processUploadFiles

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
  * Inicia processamento de cada arquivo enviado via upload
  * @param files
  */
public void processUploadFiles(List<UploadItem> files) {
	for (UploadItem uploadItem : files) {
		
		//transforma qualquer arquivo que vier (img, zip, gzip, pdf, word) numa colecao de imagens para processamento
 		readImagesFromFile(uploadItem);
 		
	}
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:13,代码来源:EventProcJSFBean.java

示例14: getrelatorioVO

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
 * 
 * @param uploadItem
 * @return
 */
protected RelatorioVO getrelatorioVO(UploadItem uploadItem) {
	byte[] data = getData(uploadItem);
	
	
	JRFileVO jrFileVO = new JRFileVO();
	jrFileVO.setJasperReport(data);
	
	RelatorioVO relatorioVO = new RelatorioVO();
	relatorioVO.getJrFileVOs().add(jrFileVO);

	String datePart = LABEL_DTFORMAT.format(new Date());
	relatorioVO.setDescription("Modelo de Prova ("+datePart+")");
	return relatorioVO;
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:20,代码来源:ConfiguracoesJSFBean.java

示例15: actionLogoImgUpload

import org.richfaces.model.UploadItem; //导入依赖的package包/类
/**
* Processa upload de imagem contendo novo logotipo da empresa
* @param event
*/
public void actionLogoImgUpload(UploadEvent event) {  
	List<UploadItem> files = event.getUploadItems();
	for (UploadItem uploadItem : files) {
	//transforma qualquer arquivo que vier (img, zip, gzip, pdf, word) numa colecao de imagens para processamento
	atualizaLogotipoEmpresa(uploadItem);
}
FacesContext context = FacesContext.getCurrentInstance();					
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Imagens carregadas com sucesso!", "Imagens carregadas com sucesso!"));
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:14,代码来源:ConfiguracoesJSFBean.java


注:本文中的org.richfaces.model.UploadItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。