fixes bug#20349
dev: alberto qua: xxx Foi identificado que quando o cache está em processamento e a funcionalidade do adm de limpar cache é acionada, gerava erro em tela. Foi realizada uma tratativa para identificar caso o cache ja esteja em processamento. git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@103179 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
d040b886aa
commit
f1bdcd2598
|
@ -72,32 +72,27 @@ public class ItemMenuLimparCacheLocalidadesAPI extends DefaultItemMenuSistema {
|
|||
HttpResponse response = httpRequestApi(url);
|
||||
|
||||
log.info("Response API limparCache: " + response);
|
||||
message = obterMensagemResponse(response);
|
||||
|
||||
if (response.getStatusLine().getStatusCode() == 500) {
|
||||
log.error("Ocorreu uma falha de comunicação com o endpoint da API de limpar cache, executando novamente o processo de cache");
|
||||
response = httpRequestApi(url);
|
||||
}
|
||||
|
||||
if (response.getStatusLine().getStatusCode() == 500) {
|
||||
message = "Ocorreu uma falha de comunicação com o endpoint da API de limpar cache, favor executar novamente o processo de cache.";
|
||||
log.error("Ocorreu uma falha de comunicação com o endpoint da API de limpar cache na 2º tentativa");
|
||||
if(message.contains("em processamento.")) {
|
||||
message = "A limpeza de cache se encontra em processamento.";
|
||||
} else {
|
||||
if (response.getStatusLine().getStatusCode() == 500) {
|
||||
log.error("Ocorreu uma falha de comunicação com o endpoint da API de limpar cache, executando novamente o processo de cache");
|
||||
response = httpRequestApi(url);
|
||||
}
|
||||
|
||||
if (response.getStatusLine().getStatusCode() == 500) {
|
||||
message = "Ocorreu uma falha de comunicação com o endpoint da API de limpar cache, favor executar novamente o processo de cache.";
|
||||
log.error("Ocorreu uma falha de comunicação com o endpoint da API de limpar cache na 2º tentativa");
|
||||
}
|
||||
}
|
||||
|
||||
if (response.getStatusLine().getStatusCode() == 401) {
|
||||
message = "Acesso negado";
|
||||
|
||||
} else if (response.getStatusLine().getStatusCode() == 200) {
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
||||
|
||||
String line = "";
|
||||
|
||||
StringBuilder result = new StringBuilder("");
|
||||
|
||||
while ((line = rd.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
|
||||
message = result.toString();
|
||||
message = obterMensagemResponse(response);
|
||||
}
|
||||
|
||||
} catch (ClientProtocolException e) {
|
||||
|
@ -129,6 +124,21 @@ public class ItemMenuLimparCacheLocalidadesAPI extends DefaultItemMenuSistema {
|
|||
Clients.alert(message, org.zkoss.util.resource.Labels.getLabel("limparCacheLocalidadesAPI.title"), Messagebox.INFORMATION);
|
||||
}
|
||||
|
||||
private String obterMensagemResponse(HttpResponse response) throws IOException {
|
||||
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
||||
|
||||
String line = "";
|
||||
|
||||
StringBuilder result = new StringBuilder("");
|
||||
|
||||
while ((line = rd.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private HttpResponse httpRequestApi(String url) throws JOSEException, AuthenticationException, IOException, ClientProtocolException {
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
HttpGet request = new HttpGet(url);
|
||||
|
|
Loading…
Reference in New Issue