Advertisement
Guest User

Untitled

a guest
Apr 12th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.67 KB | None | 0 0
  1.     public static ClientServiceWSOut clientServiceWs(ClientServiceWSIn input) throws Exception {
  2.         RequestContext rc = new RequestContext();
  3.         rc = input.getRequestContext();
  4.  
  5.         /** Desativar a validação de certificações **/
  6.         SSLTool.disableCertificateValidation();
  7.  
  8.         /** Ler WebService **/
  9.         ClientServiceWSOut output = new ClientServiceWSOut();
  10.  
  11.         ConsultaProxyOut outputProxy = consultaProxy(rc);
  12.         ArrayList<GenProperties> listaPropriedades = consultaPropriedades(rc, "gprsns");
  13.         GenProperties url = listaPropriedades.stream().filter(p -> p.getPropCod().contains("url")).findFirst().get();
  14.         GenProperties startdate = listaPropriedades.stream().filter(p -> p.getPropCod().contains("startdate")).findFirst().get();
  15.         GenProperties enddate = listaPropriedades.stream().filter(p -> p.getPropCod().contains("enddate")).findFirst().get();
  16.         GenProperties snsusername = listaPropriedades.stream().filter(p -> p.getPropCod().contains("snsusername")).findFirst().get();
  17.         GenProperties snspassword = listaPropriedades.stream().filter(p -> p.getPropCod().contains("snspassword")).findFirst().get();
  18.         ClientResponse response = new ClientResponse(0, null, null, null);
  19.         if (!input.isGprsnsAutoSync()) {
  20.             response = lerServico(outputProxy.getProxyUrl(), outputProxy.getProxyPort(), url.getPropValue(), snsusername.getPropValue(), snspassword.getPropValue(), startdate.getPropValue(), enddate.getPropValue());
  21.         } else {
  22.             /** Data Atual **/
  23.             Calendar calendar = Calendar.getInstance();
  24.             Date dataHoje = calendar.getTime();
  25.             String dataHojeFormatada = new SimpleDateFormat("dd-MM-yyyy").format(dataHoje);
  26.             /** Data 2 meses atrás da atual **/
  27.             calendar.add(Calendar.MONTH, -7);
  28.             Date dataFim = calendar.getTime();
  29.             String dataFimFormatada = new SimpleDateFormat("dd-MM-yyyy").format(dataFim);
  30.             response = lerServico(outputProxy.getProxyUrl(), outputProxy.getProxyPort(), url.getPropValue(), snsusername.getPropValue(), snspassword.getPropValue(), dataFimFormatada, dataHojeFormatada);
  31.  
  32.         }
  33.         WSGprsns[] resposta = response.getEntity(WSGprsns[].class);
  34.         if (!input.isGprsnsAutoSync()) {
  35.             SgesTablesDao dao = new SgesTablesDao(rc);
  36.             lerServicoGprsBKO(resposta, dao, rc);
  37.         } else {
  38.             SgesTablesInternoDao dao = new SgesTablesInternoDao();
  39.             try {
  40.                 lerServicoGprs(resposta, dao, rc);
  41.                 dao.commit();
  42.             }catch(Exception e){
  43.                 log.info(rc, e);
  44.                 log.error(rc, "Erro na sincronização automática dos Acordos GPRSNS");
  45.                 dao.rollback();
  46.                 throw new SGESFunctionalException(e, "[WSClienteService:clientServiceWs]");
  47.             } finally {
  48.                 dao.getSessionFactory().getCurrentSession().close();
  49.             }
  50.         }
  51.  
  52.         output.setWsResponse(resposta);
  53.         return output;
  54.  
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement