Commit b02298220c919903c93614afc3f16007d4e2e03a
1 parent
203d693e
Exists in
master
[Redmine Atendimento #4863]Validação null rascunho
Showing
1 changed file
with
12 additions
and
4 deletions
Show diff stats
cit-portal-api/src/main/java/br/com/centralit/api/service/impl/RascunhoServiceImpl.java
... | ... | @@ -40,9 +40,14 @@ public class RascunhoServiceImpl extends GenericServiceImpl<Rascunho, Long> impl |
40 | 40 | |
41 | 41 | @Override |
42 | 42 | public Rascunho merge(Rascunho entity) { |
43 | + boolean rascunhoNull = false; | |
43 | 44 | if(!UtilObjeto.isReferencia(entity.getAutor()) && !UtilObjeto.isReferencia(entity.getEditor()) && UtilObjeto.isReferencia(entity.getDetentor())){ |
44 | 45 | Rascunho rascunho = this.find(entity.getId()); |
45 | - entity.setAutor(rascunho.getAutor()); | |
46 | + if(rascunho != null){ | |
47 | + entity.setAutor(rascunho.getAutor()); | |
48 | + }else{ | |
49 | + rascunhoNull = true; | |
50 | + } | |
46 | 51 | }else{ |
47 | 52 | Usuario usuario = null; |
48 | 53 | if (SecurityContextHolder.getContext().getAuthentication() != null) { |
... | ... | @@ -52,12 +57,15 @@ public class RascunhoServiceImpl extends GenericServiceImpl<Rascunho, Long> impl |
52 | 57 | } |
53 | 58 | entity.setDetentor(usuario); |
54 | 59 | } |
55 | - return salvar(entity); | |
60 | + return !rascunhoNull ? salvar(entity) : null; | |
56 | 61 | } |
57 | 62 | |
58 | 63 | private Rascunho salvar(Rascunho entity) { |
59 | - validarEntidade(entity, this.validator); | |
60 | - return super.save(entity); | |
64 | + if(entity != null){ | |
65 | + validarEntidade(entity, this.validator); | |
66 | + return super.save(entity); | |
67 | + } | |
68 | + return null; | |
61 | 69 | } |
62 | 70 | |
63 | 71 | @Override | ... | ... |