Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static ClientServiceWSOut clientServiceWs(ClientServiceWSIn input) throws Exception {
- RequestContext rc = new RequestContext();
- rc = input.getRequestContext();
- /** Desativar a validação de certificações **/
- SSLTool.disableCertificateValidation();
- /** Ler WebService **/
- ClientServiceWSOut output = new ClientServiceWSOut();
- ConsultaProxyOut outputProxy = consultaProxy(rc);
- ArrayList<GenProperties> listaPropriedades = consultaPropriedades(rc, "gprsns");
- GenProperties url = listaPropriedades.stream().filter(p -> p.getPropCod().contains("url")).findFirst().get();
- GenProperties startdate = listaPropriedades.stream().filter(p -> p.getPropCod().contains("startdate")).findFirst().get();
- GenProperties enddate = listaPropriedades.stream().filter(p -> p.getPropCod().contains("enddate")).findFirst().get();
- GenProperties snsusername = listaPropriedades.stream().filter(p -> p.getPropCod().contains("snsusername")).findFirst().get();
- GenProperties snspassword = listaPropriedades.stream().filter(p -> p.getPropCod().contains("snspassword")).findFirst().get();
- ClientResponse response = new ClientResponse(0, null, null, null);
- if (!input.isGprsnsAutoSync()) {
- response = lerServico(outputProxy.getProxyUrl(), outputProxy.getProxyPort(), url.getPropValue(), snsusername.getPropValue(), snspassword.getPropValue(), startdate.getPropValue(), enddate.getPropValue());
- } else {
- /** Data Atual **/
- Calendar calendar = Calendar.getInstance();
- Date dataHoje = calendar.getTime();
- String dataHojeFormatada = new SimpleDateFormat("dd-MM-yyyy").format(dataHoje);
- /** Data 2 meses atrás da atual **/
- calendar.add(Calendar.MONTH, -7);
- Date dataFim = calendar.getTime();
- String dataFimFormatada = new SimpleDateFormat("dd-MM-yyyy").format(dataFim);
- response = lerServico(outputProxy.getProxyUrl(), outputProxy.getProxyPort(), url.getPropValue(), snsusername.getPropValue(), snspassword.getPropValue(), dataFimFormatada, dataHojeFormatada);
- }
- WSGprsns[] resposta = response.getEntity(WSGprsns[].class);
- if (!input.isGprsnsAutoSync()) {
- SgesTablesDao dao = new SgesTablesDao(rc);
- lerServicoGprsBKO(resposta, dao, rc);
- } else {
- SgesTablesInternoDao dao = new SgesTablesInternoDao();
- try {
- lerServicoGprs(resposta, dao, rc);
- dao.commit();
- }catch(Exception e){
- log.info(rc, e);
- log.error(rc, "Erro na sincronização automática dos Acordos GPRSNS");
- dao.rollback();
- throw new SGESFunctionalException(e, "[WSClienteService:clientServiceWs]");
- } finally {
- dao.getSessionFactory().getCurrentSession().close();
- }
- }
- output.setWsResponse(resposta);
- return output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement