Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. @Path("/foto/{imovel.codImovel}/")
  2.     public void upload(final UploadedFile imagem, final Imovel imovel, final Foto foto) {
  3.         final Integer qtdeMaximaUpload = Integer.parseInt(this.parameterLoader.getParameter("qtde.maxima.upload"));
  4.         final Imovel imovelBanco = this.imovelDAO.carrega(imovel.getCodImovel());
  5.         validator.onErrorRedirectTo(this).adiciona(imovel.getCodImovel());
  6.         validator.checking(new Validations() {         
  7.             {
  8.                
  9.                 if (that(imagem, is(notNullValue()), "imagem", "imagem.nula")) {
  10.                     that(imagem.getContentType(), startsWith("image"), "imagem", "nao.eh.imagem");
  11.                 }
  12.                
  13.                 if (that((foto != null), "img.nome", "imgNome.obrigatorio")) {
  14.                        that(!StringUtils.isBlank(foto.getNome()), "img.nome", "imgNome.obrigatorio");
  15.                     }
  16.                 //that(!(fotoDAO.getTotalFotos(imovel) >= qtdeMaximaUpload), "img.qtd", "qtd.exceed");
  17.                 that(!(imovelBanco.getQuantidadeFotos() >= qtdeMaximaUpload), "img.qtd", "qtd.exceed");
  18.                    
  19.             }              
  20.         });
  21.        
  22.         validator.onErrorRedirectTo(this).adiciona(imovel.getCodImovel());
  23.         imagens.salva(imagem,imovel,foto);             
  24.         // Retornando mensagem de sucesso na inclusão
  25.         result.include("mensagem", "Imagem adicionada com sucesso");
  26.         result.use(Results.logic()).redirectTo(FotoController.class).adiciona(imovel.getCodImovel());
  27.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement