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);
|
HttpResponse response = httpRequestApi(url);
|
||||||
|
|
||||||
log.info("Response API limparCache: " + response);
|
log.info("Response API limparCache: " + response);
|
||||||
|
message = obterMensagemResponse(response);
|
||||||
|
|
||||||
if (response.getStatusLine().getStatusCode() == 500) {
|
if(message.contains("em processamento.")) {
|
||||||
log.error("Ocorreu uma falha de comunicação com o endpoint da API de limpar cache, executando novamente o processo de cache");
|
message = "A limpeza de cache se encontra em processamento.";
|
||||||
response = httpRequestApi(url);
|
} 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) {
|
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.";
|
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");
|
log.error("Ocorreu uma falha de comunicação com o endpoint da API de limpar cache na 2º tentativa");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.getStatusLine().getStatusCode() == 401) {
|
if (response.getStatusLine().getStatusCode() == 401) {
|
||||||
message = "Acesso negado";
|
message = "Acesso negado";
|
||||||
|
|
||||||
} else if (response.getStatusLine().getStatusCode() == 200) {
|
} else if (response.getStatusLine().getStatusCode() == 200) {
|
||||||
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
message = obterMensagemResponse(response);
|
||||||
|
|
||||||
String line = "";
|
|
||||||
|
|
||||||
StringBuilder result = new StringBuilder("");
|
|
||||||
|
|
||||||
while ((line = rd.readLine()) != null) {
|
|
||||||
result.append(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
message = result.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ClientProtocolException e) {
|
} 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);
|
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 {
|
private HttpResponse httpRequestApi(String url) throws JOSEException, AuthenticationException, IOException, ClientProtocolException {
|
||||||
HttpClient client = new DefaultHttpClient();
|
HttpClient client = new DefaultHttpClient();
|
||||||
HttpGet request = new HttpGet(url);
|
HttpGet request = new HttpGet(url);
|
||||||
|
|
Loading…
Reference in New Issue