Commit d29944c45322a667abe93cf54c5c43551d6cb297
1 parent
c4573b7d
Exists in
master
Alteração no método que verifica a conexão da url.
Verificação do retorno da nota do ws do eselo.
Showing
3 changed files
with
27 additions
and
20 deletions
Show diff stats
src/main/java/br/com/ases/business/impl/AvaliacaoBusinessImpl.java
@@ -359,8 +359,13 @@ public class AvaliacaoBusinessImpl implements AvaliacaoBusiness { | @@ -359,8 +359,13 @@ public class AvaliacaoBusinessImpl implements AvaliacaoBusiness { | ||
359 | postParams.addParam("relatorioAvaliacao.qtdeLinhas", Integer.toString(totalLinhas)); | 359 | postParams.addParam("relatorioAvaliacao.qtdeLinhas", Integer.toString(totalLinhas)); |
360 | 360 | ||
361 | Gson g = new GsonBuilder().create(); | 361 | Gson g = new GsonBuilder().create(); |
362 | - nota = g.fromJson(postParams.execute().getContent(), Nota.class); | ||
363 | 362 | ||
363 | + String jsonNota = postParams.execute().getContent(); | ||
364 | + | ||
365 | + if(jsonNota.contains("nota\":")) | ||
366 | + { | ||
367 | + nota = g.fromJson(jsonNota, Nota.class); | ||
368 | + } | ||
364 | 369 | ||
365 | } catch (IOException e) { | 370 | } catch (IOException e) { |
366 | 371 |
src/main/java/br/com/ases/controller/AvaliacaoController.java
@@ -210,7 +210,7 @@ public class AvaliacaoController { | @@ -210,7 +210,7 @@ public class AvaliacaoController { | ||
210 | mapaListaOcorrencias, false); | 210 | mapaListaOcorrencias, false); |
211 | // Altera a cor de webaxscore de acordo a pontuacao | 211 | // Altera a cor de webaxscore de acordo a pontuacao |
212 | 212 | ||
213 | - if (nota.getValor() != null) { | 213 | + if (nota != null) { |
214 | DefinirCorWebaxscore(nota.getValor()); | 214 | DefinirCorWebaxscore(nota.getValor()); |
215 | 215 | ||
216 | VRaptorRequestHolder.currentRequest().getServletContext() | 216 | VRaptorRequestHolder.currentRequest().getServletContext() |
@@ -381,7 +381,7 @@ public class AvaliacaoController { | @@ -381,7 +381,7 @@ public class AvaliacaoController { | ||
381 | 381 | ||
382 | nota = avaliacaoBusiness.obterNotaEselo(checker.getDocument(), url, mapaListaOcorrencias, false); | 382 | nota = avaliacaoBusiness.obterNotaEselo(checker.getDocument(), url, mapaListaOcorrencias, false); |
383 | 383 | ||
384 | - if (nota.getValor() != null) { | 384 | + if (nota != null) { |
385 | DefinirCorWebaxscore(nota.getValor()); | 385 | DefinirCorWebaxscore(nota.getValor()); |
386 | 386 | ||
387 | VRaptorRequestHolder.currentRequest().getServletContext() | 387 | VRaptorRequestHolder.currentRequest().getServletContext() |
@@ -643,7 +643,7 @@ public class AvaliacaoController { | @@ -643,7 +643,7 @@ public class AvaliacaoController { | ||
643 | tituloSite + " - " + sdf.format(new Date()), mapaListaOcorrencias, false); | 643 | tituloSite + " - " + sdf.format(new Date()), mapaListaOcorrencias, false); |
644 | // Altera a cor de webaxscore de acordo a pontuacao | 644 | // Altera a cor de webaxscore de acordo a pontuacao |
645 | 645 | ||
646 | - if (nota.getValor() != null) { | 646 | + if (nota != null) { |
647 | DefinirCorWebaxscore(nota.getValor()); | 647 | DefinirCorWebaxscore(nota.getValor()); |
648 | 648 | ||
649 | VRaptorRequestHolder.currentRequest().getServletContext() | 649 | VRaptorRequestHolder.currentRequest().getServletContext() |
src/main/java/br/com/ases/model/utilities/Validate.java
@@ -76,6 +76,10 @@ public class Validate { | @@ -76,6 +76,10 @@ public class Validate { | ||
76 | 76 | ||
77 | boolean isValido = true; | 77 | boolean isValido = true; |
78 | int codResponse; | 78 | int codResponse; |
79 | + | ||
80 | + // HttpMethod metodoRequisicaoGET = null; | ||
81 | + //HttpClient clienteHTTPJakartaCommons; | ||
82 | + //URL UrlConvertida; | ||
79 | 83 | ||
80 | if (campo == null || campo.length() <= 10) { | 84 | if (campo == null || campo.length() <= 10) { |
81 | this.validator | 85 | this.validator |
@@ -85,26 +89,24 @@ public class Validate { | @@ -85,26 +89,24 @@ public class Validate { | ||
85 | isValido = false; | 89 | isValido = false; |
86 | } else { | 90 | } else { |
87 | 91 | ||
88 | - codResponse = verificarConexao(campo, "user-agent", "NewUseAgent/1.0"); | ||
89 | - | ||
90 | - if (codResponse != 200) { | ||
91 | - codResponse = verificarConexao(campo, "http.agent", "Jakarta Commons-HttpClient/3.1"); | ||
92 | - if (codResponse != 200) { | ||
93 | - this.validator.add(new ValidationMessage( | ||
94 | - "Não foi possível realizar a avaliação! URL " + campo | ||
95 | - + " é considerada inválida.", "warning")); | ||
96 | - isValido = false; | ||
97 | - } else { | ||
98 | - isValido = true; | ||
99 | - } | ||
100 | - } else { | ||
101 | - isValido = true; | ||
102 | - } | 92 | + codResponse = verificarConexao(campo, "http.agent", "Jakarta Commons-HttpClient/3.1"); |
93 | + if (codResponse != 200) { | ||
94 | + codResponse = verificarConexao(campo, "user-agent", "NewUseAgent/1.0"); | ||
95 | + if (codResponse == -1) { | ||
96 | + this.validator.add(new ValidationMessage( | ||
97 | + "Não foi possível realizar a avaliação! URL " + campo | ||
98 | + + " é considerada inválida.", "warning")); | ||
99 | + isValido = false; | ||
100 | + } | ||
101 | + } | ||
102 | + | ||
103 | 103 | ||
104 | } | 104 | } |
105 | 105 | ||
106 | return isValido; | 106 | return isValido; |
107 | } | 107 | } |
108 | + | ||
109 | + | ||
108 | 110 | ||
109 | private Integer verificarConexao(String campo, String usuario, String agente) { | 111 | private Integer verificarConexao(String campo, String usuario, String agente) { |
110 | 112 | ||
@@ -120,7 +122,7 @@ public class Validate { | @@ -120,7 +122,7 @@ public class Validate { | ||
120 | 122 | ||
121 | clienteHTTPJakartaCommons = new HttpClient(); | 123 | clienteHTTPJakartaCommons = new HttpClient(); |
122 | clienteHTTPJakartaCommons.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, | 124 | clienteHTTPJakartaCommons.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, |
123 | - new DefaultHttpMethodRetryHandler(3, false)); | 125 | + new DefaultHttpMethodRetryHandler(5, false)); |
124 | clienteHTTPJakartaCommons.getParams().setParameter("http.protocol.allow-circular-redirects", | 126 | clienteHTTPJakartaCommons.getParams().setParameter("http.protocol.allow-circular-redirects", |
125 | true); | 127 | true); |
126 | 128 |