From b02298220c919903c93614afc3f16007d4e2e03a Mon Sep 17 00:00:00 2001 From: erick.sato Date: Thu, 12 May 2016 10:29:31 -0300 Subject: [PATCH] [Redmine Atendimento #4863]Validação null rascunho --- cit-portal-api/src/main/java/br/com/centralit/api/service/impl/RascunhoServiceImpl.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cit-portal-api/src/main/java/br/com/centralit/api/service/impl/RascunhoServiceImpl.java b/cit-portal-api/src/main/java/br/com/centralit/api/service/impl/RascunhoServiceImpl.java index 3bf4b28..55474e6 100644 --- a/cit-portal-api/src/main/java/br/com/centralit/api/service/impl/RascunhoServiceImpl.java +++ b/cit-portal-api/src/main/java/br/com/centralit/api/service/impl/RascunhoServiceImpl.java @@ -40,9 +40,14 @@ public class RascunhoServiceImpl extends GenericServiceImpl impl @Override public Rascunho merge(Rascunho entity) { + boolean rascunhoNull = false; if(!UtilObjeto.isReferencia(entity.getAutor()) && !UtilObjeto.isReferencia(entity.getEditor()) && UtilObjeto.isReferencia(entity.getDetentor())){ Rascunho rascunho = this.find(entity.getId()); - entity.setAutor(rascunho.getAutor()); + if(rascunho != null){ + entity.setAutor(rascunho.getAutor()); + }else{ + rascunhoNull = true; + } }else{ Usuario usuario = null; if (SecurityContextHolder.getContext().getAuthentication() != null) { @@ -52,12 +57,15 @@ public class RascunhoServiceImpl extends GenericServiceImpl impl } entity.setDetentor(usuario); } - return salvar(entity); + return !rascunhoNull ? salvar(entity) : null; } private Rascunho salvar(Rascunho entity) { - validarEntidade(entity, this.validator); - return super.save(entity); + if(entity != null){ + validarEntidade(entity, this.validator); + return super.save(entity); + } + return null; } @Override -- libgit2 0.21.2