Rev 468 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 468 | Rev 472 | ||
|---|---|---|---|
| Line 42... | Line 42... | ||
| 42 | public UploadedFile getFotoParaUpload() { |
42 | public UploadedFile getFotoParaUpload() { |
| 43 | return fotoParaUpload; |
43 | return fotoParaUpload; |
| 44 | }
|
44 | }
|
| 45 | public void setFotoParaUpload(UploadedFile fotoParaUpload) { |
45 | public void setFotoParaUpload(UploadedFile fotoParaUpload) { |
| 46 | this.fotoParaUpload = fotoParaUpload; |
46 | this.fotoParaUpload = fotoParaUpload; |
| - | 47 | }
|
|
| - | 48 | ||
| - | 49 | /**********************************************/
|
|
| - | 50 | ||
| - | 51 | public String getCaminhoPadraoFotos() { |
|
| - | 52 | return ConstantesSEC.TESTE_LOCAL? ConstantesSEC.Foto.CAMINHO_PADRAO_LOCAL : ConstantesSEC.Foto.CAMINHO_PADRAO_SERVIDOR; |
|
| - | 53 | }
|
|
| - | 54 | ||
| - | 55 | public String getCaminhoPastaFotos() { |
|
| - | 56 | ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); |
|
| - | 57 | return ConstantesSEC.TESTE_LOCAL? |
|
| - | 58 | servletContext.getRealPath("") + File.separator + "fotos" + File.separator : |
|
| - | 59 | servletContext.getRealPath("") + File.separator + ".." + File.separator + "fotos" + File.separator; |
|
| 47 | }
|
60 | }
|
| 48 | 61 | ||
| 49 | public String fotoPadraoProduto(ProdutoDTO produtoDTO) { |
62 | public String fotoPadraoProduto(ProdutoDTO produtoDTO) { |
| 50 | try { |
63 | try { |
| 51 | if (VerificadorUtil.naoEstaNulo(produtoDTO)) { |
64 | if (VerificadorUtil.naoEstaNulo(produtoDTO)) { |
| 52 | if (VerificadorUtil.naoEstaNuloOuVazio(produtoDTO.getCodigo())) { |
65 | if (VerificadorUtil.naoEstaNuloOuVazio(produtoDTO.getCodigo())) { |
| 53 | File foto = new File(getCaminhoPastaFotos() + produtoDTO.getCodigoProdutoPadrao() + ".jpg"); |
66 | File foto = new File(getCaminhoPastaFotos() + produtoDTO.getCodigoProdutoPadrao() + ".jpg"); |
| 54 | if (foto.exists()) { |
- | |
| 55 | return getCaminhoPadraoFotos() + produtoDTO.getCodigoProdutoPadrao() + ".jpg"; |
- | |
| 56 | } else { |
- | |
| 57 | return getCaminhoPadraoFotos() + "SEM_FOTO.jpg"; |
- | |
| 58 | }
|
- | |
| - | 67 | return foto.exists()? getCaminhoPadraoFotos() + produtoDTO.getCodigoProdutoPadrao() + ".jpg" : getCaminhoPadraoFotos() + "SEM_FOTO.jpg"; |
|
| 59 | }
|
68 | }
|
| 60 | }
|
69 | }
|
| 61 | } catch (Exception e) { |
70 | } catch (Exception e) { |
| 62 | e.printStackTrace(); |
71 | e.printStackTrace(); |
| 63 | }
|
72 | }
|
| 64 | - | ||
| 65 | return getCaminhoPadraoFotos() + "SEM_FOTO.jpg"; |
73 | return getCaminhoPadraoFotos() + "SEM_FOTO.jpg"; |
| 66 | }
|
74 | }
|
| 67 | 75 | ||
| 68 | public String fotoPadraoProdutoComCodigo(String codigo) { |
76 | public String fotoPadraoProdutoComCodigo(String codigo) { |
| - | 77 | ProdutoDTO produtoDTO = new ProdutoDTO(); |
|
| - | 78 | produtoDTO.setCodigo(codigo); |
|
| - | 79 | return fotoPadraoProduto(produtoDTO); |
|
| - | 80 | }
|
|
| - | 81 | ||
| - | 82 | public String fotoPadraoProduto(Produto produto) { |
|
| 69 | try { |
83 | try { |
| 70 | Produto produto = new Produto(); |
- | |
| 71 | produto.setCodigo(codigo); |
- | |
| 72 | if (VerificadorUtil.naoEstaNuloOuVazio(produto.getCodigo())) { |
- | |
| 73 | File foto = new File(getCaminhoPastaFotos() + produto.getCodigoProdutoPadrao() + ".jpg"); |
- | |
| 74 | if (foto.exists()) { |
- | |
| 75 | return getCaminhoPadraoFotos() + produto.getCodigoProdutoPadrao() + ".jpg"; |
- | |
| 76 | } else { |
- | |
| 77 | return getCaminhoPadraoFotos() + "SEM_FOTO.jpg"; |
- | |
| - | 84 | if (VerificadorUtil.naoEstaNulo(produto)) { |
|
| - | 85 | if (VerificadorUtil.naoEstaNuloOuVazio(produto.getCodigo())) { |
|
| - | 86 | File foto = new File(getCaminhoPastaFotos() + produto.getCodigoProdutoPadrao() + ".jpg"); |
|
| - | 87 | return foto.exists()? getCaminhoPadraoFotos() + produto.getCodigoProdutoPadrao() + ".jpg" : getCaminhoPadraoFotos() + "SEM_FOTO.jpg"; |
|
| 78 | }
|
88 | }
|
| 79 | }
|
89 | }
|
| 80 | } catch (Exception e) { |
90 | } catch (Exception e) { |
| 81 | e.printStackTrace(); |
91 | e.printStackTrace(); |
| 82 | }
|
92 | }
|
| 83 | - | ||
| 84 | return getCaminhoPadraoFotos() + "SEM_FOTO.jpg"; |
93 | return getCaminhoPadraoFotos() + "SEM_FOTO.jpg"; |
| 85 | }
|
94 | }
|
| - | 95 | ||
| - | 96 | /**********************************************
|
|
| 86 | 97 |
|
|
| 87 | @Transient |
98 | @Transient
|
| 88 | public List<String> fotosProdutoComFotoPadrao(Produto produto) { |
99 | public List<String> fotosProdutoComFotoPadrao(Produto produto) {
|
| 89 | List<String> fotos = new ArrayList<String>(); |
100 | List<String> fotos = new ArrayList<String>();
|
| 90 | if (VerificadorUtil.naoEstaNulo(produto)) { |
101 | if (VerificadorUtil.naoEstaNulo(produto)) {
|
| Line 116... | Line 127... | ||
| 116 | }
|
127 | }
|
| 117 | return fotos; |
128 | return fotos;
|
| 118 | }
|
129 | }
|
| 119 | }
|
130 | }
|
| 120 | return fotos; |
131 | return fotos;
|
| 121 | }
|
- | |
| 122 | - | ||
| 123 | public String getCaminhoPadraoFotos() { |
- | |
| 124 | if (ConstantesSEC.TESTE_LOCAL) { |
- | |
| 125 | return ConstantesSEC.Foto.CAMINHO_PADRAO_LOCAL; |
- | |
| 126 | }
|
- | |
| 127 | return ConstantesSEC.Foto.CAMINHO_PADRAO_SERVIDOR; |
- | |
| 128 | }
|
- | |
| 129 | - | ||
| 130 | public String getCaminhoPastaFotos() { |
- | |
| 131 | if (ConstantesSEC.TESTE_LOCAL) { |
- | |
| 132 | ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); |
- | |
| 133 | return servletContext.getRealPath("") + File.separator + "fotos" + File.separator; |
- | |
| 134 | }
|
- | |
| 135 | ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); |
- | |
| 136 | return servletContext.getRealPath("") + File.separator + ".." + File.separator + "fotos" + File.separator; |
- | |
| 137 | }
|
132 | }
|
| 138 | 133 |
|
|
| 139 | public void prepararUploadFoto(Produto produto) { |
134 | public void prepararUploadFoto(Produto produto) {
|
| 140 | FotoDTO fotoNova = new FotoDTO(); |
135 | FotoDTO fotoNova = new FotoDTO();
|
| 141 | fotoNova.setDescricao(produto.getCodigoProdutoPadrao()); |
136 | fotoNova.setDescricao(produto.getCodigoProdutoPadrao());
|
| Line 248... | Line 243... | ||
| 248 | }
|
243 | }
|
| 249 | } catch (Exception e1) { |
244 | } catch (Exception e1) {
|
| 250 | LancadorMensagem.lancarErro("Erro ao excluir imagem"); |
245 | LancadorMensagem.lancarErro("Erro ao excluir imagem");
|
| 251 | }
|
246 | }
|
| 252 | }
|
247 | }
|
| - | 248 |
|
|
| - | 249 | ****/
|
|
| 253 | 250 | ||
| 254 | /*********************************/
|
251 | /*********************************/
|
| 255 | 252 | ||
| - | 253 | /*
|
|
| 256 | private static Integer quantidadeFotosDisponiveis() { |
254 | private static Integer quantidadeFotosDisponiveis() {
|
| 257 | // ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
|
255 | // ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
|
| 258 | // String caminhoArquivoPadrao = servletContext.getRealPath("") + File.separator + "imagens" + File.separator + "temp" + File.separator;
|
256 | // String caminhoArquivoPadrao = servletContext.getRealPath("") + File.separator + "imagens" + File.separator + "temp" + File.separator;
|
| 259 | ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); |
257 | ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
|
| 260 | String caminhoArquivoPadrao = servletContext.getRealPath("") + File.separator + "fotos" + File.separator + "SEM_FOTO.jpg"; |
258 | String caminhoArquivoPadrao = servletContext.getRealPath("") + File.separator + "fotos" + File.separator + "SEM_FOTO.jpg";
|
| Line 273... | Line 271... | ||
| 273 | public static void main(String[] args) { |
271 | public static void main(String[] args) {
|
| 274 | String foto = "espacocase/fotos/010632_1.jpg"; |
272 | String foto = "espacocase/fotos/010632_1.jpg";
|
| 275 | String caminhoFoto = foto.substring(foto.indexOf("fotos/")+6); |
273 | String caminhoFoto = foto.substring(foto.indexOf("fotos/")+6);
|
| 276 | System.out.println(caminhoFoto); |
274 | System.out.println(caminhoFoto);
|
| 277 | }
|
275 | }
|
| - | 276 | */
|
|
| 278 | 277 | ||
| 279 | }
|
278 | }
|