Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Path("/foto/{imovel.codImovel}/")
- public void upload(final UploadedFile imagem, final Imovel imovel, final Foto foto) {
- final Integer qtdeMaximaUpload = Integer.parseInt(this.parameterLoader.getParameter("qtde.maxima.upload"));
- final Imovel imovelBanco = this.imovelDAO.carrega(imovel.getCodImovel());
- validator.onErrorRedirectTo(this).adiciona(imovel.getCodImovel());
- validator.checking(new Validations() {
- {
- if (that(imagem, is(notNullValue()), "imagem", "imagem.nula")) {
- that(imagem.getContentType(), startsWith("image"), "imagem", "nao.eh.imagem");
- }
- if (that((foto != null), "img.nome", "imgNome.obrigatorio")) {
- that(!StringUtils.isBlank(foto.getNome()), "img.nome", "imgNome.obrigatorio");
- }
- //that(!(fotoDAO.getTotalFotos(imovel) >= qtdeMaximaUpload), "img.qtd", "qtd.exceed");
- that(!(imovelBanco.getQuantidadeFotos() >= qtdeMaximaUpload), "img.qtd", "qtd.exceed");
- }
- });
- validator.onErrorRedirectTo(this).adiciona(imovel.getCodImovel());
- imagens.salva(imagem,imovel,foto);
- // Retornando mensagem de sucesso na inclusão
- result.include("mensagem", "Imagem adicionada com sucesso");
- result.use(Results.logic()).redirectTo(FotoController.class).adiciona(imovel.getCodImovel());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement