Skip to content

Commit bafd4df

Browse files
Adicionado Melhorias JaxB
1 parent 4c0dd24 commit bafd4df

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ ________________________________________________________________________________
4848
- Atualizado Servidro DFe Homologação
4949
- Adicionado Compatibilidade com Java 14+
5050
- Adicionado Envento Ator Interessado
51+
- Corrigido erro de Logs
52+
- Adicionado Melhorias JaxB
5153

5254
Snapshot é a versão que se encontra em teste, só use em caso de extrema necessidade.
5355
Para usar, adicione o repositorio de Snapshot ao Maven:

src/main/java/br/com/swconsultoria/nfe/util/RetornoUtil.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@
1212
*/
1313
public class RetornoUtil {
1414

15+
/**
16+
* Valida Retorno Assincrono Trasmissão de Contingencia!
17+
*
18+
* @param retorno
19+
* @throws NfeException
20+
*/
21+
public static void validaSincronoTrasmissaoContingencia(TRetEnviNFe retorno) throws NfeException {
22+
23+
if (!retorno.getCStat().equals(StatusEnum.LOTE_RECEBIDO.getCodigo()) && !retorno.getCStat().equals(StatusEnum.LOTE_PROCESSADO.getCodigo())) {
24+
throw new NfeException(retorno.getCStat() + " - " + retorno.getXMotivo());
25+
}
26+
27+
if (!retorno.getProtNFe().getInfProt().getCStat().equals(StatusEnum.AUTORIZADO.getCodigo()) && !retorno.getProtNFe().getInfProt().getCStat().equals(StatusEnum.AUTORIZADO_FORA_PRAZO.getCodigo())) {
28+
throw new NfeException(retorno.getProtNFe().getInfProt().getCStat() + " - " + retorno.getProtNFe().getInfProt().getXMotivo());
29+
}
30+
}
31+
1532
/**
1633
* Valida o Retorno Do Cancelamento
1734
*

src/main/java/br/com/swconsultoria/nfe/util/XmlNfeUtil.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,7 @@ public class XmlNfeUtil {
103103
* @return T
104104
*/
105105
public static <T> T xmlToObject(String xml, Class<T> classe) throws JAXBException {
106-
107-
JAXBContext context = JAXBContext.newInstance(classe);
108-
Unmarshaller unmarshaller = context.createUnmarshaller();
109-
110-
return unmarshaller.unmarshal(new StreamSource(new StringReader(xml)), classe).getValue();
106+
return JAXB.unmarshal(new StreamSource(new StringReader(xml)), classe);
111107
}
112108

113109
/**

0 commit comments

Comments
 (0)