|
6 | 6 | import br.com.swconsultoria.nfe.exception.NfeException; |
7 | 7 | import br.com.swconsultoria.nfe.schema_4.consReciNFe.TConsReciNFe; |
8 | 8 | import br.com.swconsultoria.nfe.schema_4.retConsReciNFe.TRetConsReciNFe; |
9 | | -import br.com.swconsultoria.nfe.util.*; |
| 9 | +import br.com.swconsultoria.nfe.util.ConstantesUtil; |
| 10 | +import br.com.swconsultoria.nfe.util.ObjetoUtil; |
| 11 | +import br.com.swconsultoria.nfe.util.WebServiceUtil; |
| 12 | +import br.com.swconsultoria.nfe.util.XmlNfeUtil; |
10 | 13 | import br.com.swconsultoria.nfe.wsdl.NFeRetAutorizacao.NFeRetAutorizacao4Stub; |
| 14 | +import lombok.extern.java.Log; |
11 | 15 | import org.apache.axiom.om.OMElement; |
12 | 16 | import org.apache.axiom.om.util.AXIOMUtil; |
13 | 17 | import org.apache.axis2.transport.http.HTTPConstants; |
|
21 | 25 | * |
22 | 26 | * @author Samuel Oliveira |
23 | 27 | */ |
| 28 | +@Log |
24 | 29 | class ConsultaRecibo { |
25 | 30 |
|
26 | | - /** |
27 | | - * Metodo Responsavel Por Pegar o Xml De Retorno. |
28 | | - * |
29 | | - * @param config Configuracoes |
30 | | - * @param recibo Número Do Recibo para Consulta |
31 | | - * @param tipoDocumento Informe {@link DocumentoEnum} |
32 | | - * @return |
33 | | - * @throws NfeException |
34 | | - */ |
35 | | - static TRetConsReciNFe reciboNfe(ConfiguracoesNfe config, String recibo, DocumentoEnum tipoDocumento) throws NfeException { |
| 31 | + /** |
| 32 | + * Metodo Responsavel Por Pegar o Xml De Retorno. |
| 33 | + * |
| 34 | + * @param config Configuracoes |
| 35 | + * @param recibo Número Do Recibo para Consulta |
| 36 | + * @param tipoDocumento Informe {@link DocumentoEnum} |
| 37 | + * @return |
| 38 | + * @throws NfeException |
| 39 | + */ |
| 40 | + static TRetConsReciNFe reciboNfe(ConfiguracoesNfe config, String recibo, DocumentoEnum tipoDocumento) throws NfeException { |
36 | 41 |
|
37 | | - try { |
| 42 | + try { |
38 | 43 |
|
39 | | - /** |
40 | | - * Informaçoes do Certificado Digital. |
41 | | - */ |
| 44 | + /** |
| 45 | + * Informaçoes do Certificado Digital. |
| 46 | + */ |
42 | 47 |
|
43 | | - TConsReciNFe consReciNFe = new TConsReciNFe(); |
44 | | - consReciNFe.setVersao(ConstantesUtil.VERSAO.NFE); |
45 | | - consReciNFe.setTpAmb(config.getAmbiente().getCodigo()); |
46 | | - consReciNFe.setNRec(recibo); |
| 48 | + TConsReciNFe consReciNFe = new TConsReciNFe(); |
| 49 | + consReciNFe.setVersao(ConstantesUtil.VERSAO.NFE); |
| 50 | + consReciNFe.setTpAmb(config.getAmbiente().getCodigo()); |
| 51 | + consReciNFe.setNRec(recibo); |
47 | 52 |
|
48 | | - String xml = XmlNfeUtil.objectToXml(consReciNFe); |
| 53 | + String xml = XmlNfeUtil.objectToXml(consReciNFe); |
49 | 54 |
|
50 | | - LoggerUtil.log(ConsultaRecibo.class,"[XML-ENVIO]: " +xml); |
| 55 | + log.info("[XML-ENVIO]: " + xml); |
51 | 56 |
|
52 | | - OMElement ome = AXIOMUtil.stringToOM(xml); |
53 | | - NFeRetAutorizacao4Stub.NfeDadosMsg dadosMsg = new NFeRetAutorizacao4Stub.NfeDadosMsg(); |
54 | | - dadosMsg.setExtraElement(ome); |
| 57 | + OMElement ome = AXIOMUtil.stringToOM(xml); |
| 58 | + NFeRetAutorizacao4Stub.NfeDadosMsg dadosMsg = new NFeRetAutorizacao4Stub.NfeDadosMsg(); |
| 59 | + dadosMsg.setExtraElement(ome); |
55 | 60 |
|
56 | | - NFeRetAutorizacao4Stub stub = new NFeRetAutorizacao4Stub(WebServiceUtil.getUrl(config, tipoDocumento, ServicosEnum.CONSULTA_RECIBO)); |
| 61 | + NFeRetAutorizacao4Stub stub = new NFeRetAutorizacao4Stub(WebServiceUtil.getUrl(config, tipoDocumento, ServicosEnum.CONSULTA_RECIBO)); |
57 | 62 |
|
58 | | - // Timeout |
59 | | - if (ObjetoUtil.verifica(config.getTimeout()).isPresent()) { |
60 | | - stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, config.getTimeout()); |
61 | | - stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, |
62 | | - config.getTimeout()); |
63 | | - } |
64 | | - NFeRetAutorizacao4Stub.NfeResultMsg result = stub.nfeRetAutorizacaoLote(dadosMsg); |
| 63 | + // Timeout |
| 64 | + if (ObjetoUtil.verifica(config.getTimeout()).isPresent()) { |
| 65 | + stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, config.getTimeout()); |
| 66 | + stub._getServiceClient().getOptions().setProperty(HTTPConstants.CONNECTION_TIMEOUT, |
| 67 | + config.getTimeout()); |
| 68 | + } |
| 69 | + NFeRetAutorizacao4Stub.NfeResultMsg result = stub.nfeRetAutorizacaoLote(dadosMsg); |
65 | 70 |
|
66 | | - LoggerUtil.log(ConsultaRecibo.class,"[XML-RETORNO]: " +result.getExtraElement().toString()); |
67 | | - return XmlNfeUtil.xmlToObject(result.getExtraElement().toString(), TRetConsReciNFe.class); |
| 71 | + log.info("[XML-RETORNO]: " + result.getExtraElement().toString()); |
| 72 | + return XmlNfeUtil.xmlToObject(result.getExtraElement().toString(), TRetConsReciNFe.class); |
68 | 73 |
|
69 | | - } catch (RemoteException | XMLStreamException | JAXBException e) { |
70 | | - throw new NfeException(e.getMessage()); |
71 | | - } |
| 74 | + } catch (RemoteException | XMLStreamException | JAXBException e) { |
| 75 | + throw new NfeException(e.getMessage()); |
| 76 | + } |
72 | 77 |
|
73 | | - } |
| 78 | + } |
74 | 79 | } |
0 commit comments