public void save() throws Exception { if (this.foto.getSize() < 1) { FacesContext.getCurrentInstance() .addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Foto Obrigatoria!", "")); return; } byte[] img = null; if (usuarioBO.isRenderizaImagem(this.foto.getSize())) { img = Util.decreaseSizeImg(this.foto.getInputstream(), 800, 600); usuario.setFotoByte(img); } else { usuario.convertiInputStremToByte(this.foto.getInputstream(), this.foto.getSize()); } String projeto = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/"); usuario.setSerialPlayerId(serialPlayer.getId()); if (usuarioBO.save(usuario, projeto).getId() != null) { this.redenderizaFoto = true; byte[] fotoBase64 = Base64.encodeBase64(usuario.getFotoByte()); usuario.setFoto("data:image/png;base64," + new String(fotoBase64)); FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_INFO, "Inscrição realizada com sucesso !", "")); } else { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Erro ao realizar a inscrição !", "")); } }