Commit c873df328a66e7cb60af71224d0573bc85a65c94
1 parent
7935705b
Exists in
master
and in
1 other branch
Utiliza FastDateFormat para tratar datas
- Utilização do FastDateFormat em substituição ao SimpleDateFormat - Criação de mais constantes String
Showing
6 changed files
with
14 additions
and
18 deletions
Show diff stats
src/main/java/br/gov/ans/integracao/sei/rest/DocumentoResource.java
@@ -105,9 +105,7 @@ public class DocumentoResource { | @@ -105,9 +105,7 @@ public class DocumentoResource { | ||
105 | 105 | ||
106 | @Inject | 106 | @Inject |
107 | private UserTransaction userTransaction; | 107 | private UserTransaction userTransaction; |
108 | - | ||
109 | - private static String NAO = "N"; | ||
110 | - | 108 | + |
111 | /** | 109 | /** |
112 | * @api {get} /:unidade/documentos/:documento Consultar documento | 110 | * @api {get} /:unidade/documentos/:documento Consultar documento |
113 | * @apiName consultarDocumento | 111 | * @apiName consultarDocumento |
@@ -510,7 +508,7 @@ public class DocumentoResource { | @@ -510,7 +508,7 @@ public class DocumentoResource { | ||
510 | @Produces(MediaType.APPLICATION_OCTET_STREAM) | 508 | @Produces(MediaType.APPLICATION_OCTET_STREAM) |
511 | public Response exportarDocumento(@PathParam("unidade") String unidade, @PathParam("documento") String documento) throws Exception{ | 509 | public Response exportarDocumento(@PathParam("unidade") String unidade, @PathParam("documento") String documento) throws Exception{ |
512 | RetornoConsultaDocumento retorno = seiNativeService.consultarDocumento(Constantes.SEI_BROKER, Operacao.CONSULTAR_DOCUMENTO, unidadeResource.consultarCodigo(unidade), documento, | 510 | RetornoConsultaDocumento retorno = seiNativeService.consultarDocumento(Constantes.SEI_BROKER, Operacao.CONSULTAR_DOCUMENTO, unidadeResource.consultarCodigo(unidade), documento, |
513 | - NAO, NAO, NAO, NAO); | 511 | + Constantes.NAO, Constantes.NAO, Constantes.NAO, Constantes.NAO); |
514 | 512 | ||
515 | String linkAcesso = retorno.getLinkAcesso(); | 513 | String linkAcesso = retorno.getLinkAcesso(); |
516 | 514 | ||
@@ -723,7 +721,7 @@ public class DocumentoResource { | @@ -723,7 +721,7 @@ public class DocumentoResource { | ||
723 | 721 | ||
724 | return encodeBase64(html); | 722 | return encodeBase64(html); |
725 | }catch(JsonParseException ex){ | 723 | }catch(JsonParseException ex){ |
726 | - logger.warn(conteudo); | 724 | + logger.debug(conteudo); |
727 | throw new BusinessException(messages.getMessage("erro.processar.conteudo.json")); | 725 | throw new BusinessException(messages.getMessage("erro.processar.conteudo.json")); |
728 | } | 726 | } |
729 | } | 727 | } |
src/main/java/br/gov/ans/integracao/sei/rest/UnidadeResource.java
@@ -67,7 +67,7 @@ public class UnidadeResource { | @@ -67,7 +67,7 @@ public class UnidadeResource { | ||
67 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | 67 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
68 | public br.gov.ans.integracao.sei.client.Unidade[] listarUnidades() throws Exception{ | 68 | public br.gov.ans.integracao.sei.client.Unidade[] listarUnidades() throws Exception{ |
69 | Unidade[] lista = seiNativeService.listarUnidades(Constantes.SEI_BROKER, Operacao.LISTAR_UNIDADES, null, null); | 69 | Unidade[] lista = seiNativeService.listarUnidades(Constantes.SEI_BROKER, Operacao.LISTAR_UNIDADES, null, null); |
70 | - | 70 | + |
71 | carregarMapUnidades(lista); | 71 | carregarMapUnidades(lista); |
72 | 72 | ||
73 | return lista; | 73 | return lista; |
src/main/java/br/gov/ans/integracao/sei/utils/Constantes.java
@@ -10,13 +10,16 @@ public class Constantes { | @@ -10,13 +10,16 @@ public class Constantes { | ||
10 | public static final int AXIS_TIMEOUT = 1000 * (60 * AXIS_TIMEOUT_IN_MINUTES); | 10 | public static final int AXIS_TIMEOUT = 1000 * (60 * AXIS_TIMEOUT_IN_MINUTES); |
11 | public static final String CODIGO_BRASIL = "76"; | 11 | public static final String CODIGO_BRASIL = "76"; |
12 | public static final String CODIGO_ORGAO_ANS = "0"; | 12 | public static final String CODIGO_ORGAO_ANS = "0"; |
13 | + public static final String DATE_PATTERN = "dd/MM/yyyy"; | ||
13 | public static final String DOCUMENTO_GERAL = "G"; | 14 | public static final String DOCUMENTO_GERAL = "G"; |
14 | public static final String DOCUMENTO_RECEBIDO = "R"; | 15 | public static final String DOCUMENTO_RECEBIDO = "R"; |
15 | public static final String MASCARA_PROCESSO_17 = "#####.######/####-##"; | 16 | public static final String MASCARA_PROCESSO_17 = "#####.######/####-##"; |
16 | public static final String MASCARA_PROCESSO_21 = "#######.########/####-##"; | 17 | public static final String MASCARA_PROCESSO_21 = "#######.########/####-##"; |
18 | + public static String NAO = "N"; | ||
17 | public static final String JBOSS_HOME = System.getProperty("jboss.home.dir"); | 19 | public static final String JBOSS_HOME = System.getProperty("jboss.home.dir"); |
18 | public static final String NOME_SISTEMA = "sei-broker"; | 20 | public static final String NOME_SISTEMA = "sei-broker"; |
19 | public static final String REGEX_MASCARA_PROCESSO = "(\\d)(\\d)(\\d)(\\d)(\\d)(\\.)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\/)(\\d)(\\d)(\\d)(\\d)(-)(\\d)(\\d)"; | 21 | public static final String REGEX_MASCARA_PROCESSO = "(\\d)(\\d)(\\d)(\\d)(\\d)(\\.)(\\d)(\\d)(\\d)(\\d)(\\d)(\\d)(\\/)(\\d)(\\d)(\\d)(\\d)(-)(\\d)(\\d)"; |
22 | + public static final String REGEX_SOMENTE_NUMEROS = "\\D+"; | ||
20 | public static final String SEI_BROKER = "SEI-Broker"; | 23 | public static final String SEI_BROKER = "SEI-Broker"; |
21 | public static final int TAMANHO_MAXIMO_ARQUIVO = 16777216; | 24 | public static final int TAMANHO_MAXIMO_ARQUIVO = 16777216; |
22 | public static final int TAMANHO_MAXIMO_DOCUMENTO = 22020096; | 25 | public static final int TAMANHO_MAXIMO_DOCUMENTO = 22020096; |
src/main/java/br/gov/ans/integracao/sei/utils/ContatoHelper.java
@@ -3,12 +3,11 @@ package br.gov.ans.integracao.sei.utils; | @@ -3,12 +3,11 @@ package br.gov.ans.integracao.sei.utils; | ||
3 | import static br.gov.ans.integracao.sei.utils.Util.getSOuN; | 3 | import static br.gov.ans.integracao.sei.utils.Util.getSOuN; |
4 | 4 | ||
5 | import java.rmi.RemoteException; | 5 | import java.rmi.RemoteException; |
6 | -import java.text.DateFormat; | ||
7 | -import java.text.SimpleDateFormat; | ||
8 | 6 | ||
9 | import javax.inject.Inject; | 7 | import javax.inject.Inject; |
10 | 8 | ||
11 | import org.apache.commons.lang3.StringUtils; | 9 | import org.apache.commons.lang3.StringUtils; |
10 | +import org.apache.commons.lang3.time.FastDateFormat; | ||
12 | 11 | ||
13 | import br.gov.ans.exceptions.BusinessException; | 12 | import br.gov.ans.exceptions.BusinessException; |
14 | import br.gov.ans.integracao.sei.client.Contato; | 13 | import br.gov.ans.integracao.sei.client.Contato; |
@@ -23,7 +22,7 @@ import br.gov.ans.integracao.sei.modelo.enums.TipoPessoa; | @@ -23,7 +22,7 @@ import br.gov.ans.integracao.sei.modelo.enums.TipoPessoa; | ||
23 | 22 | ||
24 | public class ContatoHelper { | 23 | public class ContatoHelper { |
25 | 24 | ||
26 | - private DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); | 25 | + private static final FastDateFormat formatter = FastDateFormat.getInstance(Constantes.DATE_PATTERN); |
27 | 26 | ||
28 | @Inject | 27 | @Inject |
29 | private ContatoDAO contatoDAO; | 28 | private ContatoDAO contatoDAO; |
src/main/java/br/gov/ans/integracao/sei/utils/PessoaHelper.java
1 | package br.gov.ans.integracao.sei.utils; | 1 | package br.gov.ans.integracao.sei.utils; |
2 | 2 | ||
3 | import java.lang.reflect.Field; | 3 | import java.lang.reflect.Field; |
4 | -import java.text.DateFormat; | ||
5 | import java.text.ParseException; | 4 | import java.text.ParseException; |
6 | -import java.text.SimpleDateFormat; | ||
7 | import java.util.ArrayList; | 5 | import java.util.ArrayList; |
8 | import java.util.List; | 6 | import java.util.List; |
9 | 7 | ||
@@ -12,6 +10,7 @@ import javax.inject.Inject; | @@ -12,6 +10,7 @@ import javax.inject.Inject; | ||
12 | import org.apache.commons.lang3.ArrayUtils; | 10 | import org.apache.commons.lang3.ArrayUtils; |
13 | import org.apache.commons.lang3.StringUtils; | 11 | import org.apache.commons.lang3.StringUtils; |
14 | import org.apache.commons.lang3.reflect.FieldUtils; | 12 | import org.apache.commons.lang3.reflect.FieldUtils; |
13 | +import org.apache.commons.lang3.time.FastDateFormat; | ||
15 | import org.jboss.logging.Logger; | 14 | import org.jboss.logging.Logger; |
16 | 15 | ||
17 | import br.gov.ans.exceptions.BusinessException; | 16 | import br.gov.ans.exceptions.BusinessException; |
@@ -41,7 +40,7 @@ public class PessoaHelper { | @@ -41,7 +40,7 @@ public class PessoaHelper { | ||
41 | @Inject | 40 | @Inject |
42 | private MessageUtils messages; | 41 | private MessageUtils messages; |
43 | 42 | ||
44 | - private DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); | 43 | + private static final FastDateFormat formatter = FastDateFormat.getInstance(Constantes.DATE_PATTERN); |
45 | 44 | ||
46 | public List<Pessoa> buildPessoa(Contato[] contatos) throws ParseException, BusinessException, IllegalAccessException, ResourceNotFoundException{ | 45 | public List<Pessoa> buildPessoa(Contato[] contatos) throws ParseException, BusinessException, IllegalAccessException, ResourceNotFoundException{ |
47 | if(ArrayUtils.isNotEmpty(contatos)){ | 46 | if(ArrayUtils.isNotEmpty(contatos)){ |
src/main/java/br/gov/ans/integracao/sei/utils/Util.java
@@ -2,17 +2,16 @@ package br.gov.ans.integracao.sei.utils; | @@ -2,17 +2,16 @@ package br.gov.ans.integracao.sei.utils; | ||
2 | 2 | ||
3 | import java.io.IOException; | 3 | import java.io.IOException; |
4 | import java.text.ParseException; | 4 | import java.text.ParseException; |
5 | -import java.text.SimpleDateFormat; | ||
6 | import java.util.Date; | 5 | import java.util.Date; |
7 | import java.util.HashMap; | 6 | import java.util.HashMap; |
8 | import java.util.Map; | 7 | import java.util.Map; |
9 | -import java.util.regex.Pattern; | ||
10 | 8 | ||
11 | import javax.persistence.Query; | 9 | import javax.persistence.Query; |
12 | import javax.swing.text.MaskFormatter; | 10 | import javax.swing.text.MaskFormatter; |
13 | 11 | ||
14 | import org.apache.commons.codec.binary.Base64; | 12 | import org.apache.commons.codec.binary.Base64; |
15 | import org.apache.commons.lang3.StringUtils; | 13 | import org.apache.commons.lang3.StringUtils; |
14 | +import org.apache.commons.lang3.time.FastDateFormat; | ||
16 | import org.codehaus.jackson.JsonParseException; | 15 | import org.codehaus.jackson.JsonParseException; |
17 | import org.codehaus.jackson.map.JsonMappingException; | 16 | import org.codehaus.jackson.map.JsonMappingException; |
18 | import org.codehaus.jackson.map.ObjectMapper; | 17 | import org.codehaus.jackson.map.ObjectMapper; |
@@ -21,7 +20,7 @@ import org.codehaus.jackson.type.TypeReference; | @@ -21,7 +20,7 @@ import org.codehaus.jackson.type.TypeReference; | ||
21 | import br.gov.ans.exceptions.BusinessException; | 20 | import br.gov.ans.exceptions.BusinessException; |
22 | 21 | ||
23 | public class Util { | 22 | public class Util { |
24 | - private static final String REGEX_SOMENTE_NUMEROS = "\\D+"; | 23 | + private static final FastDateFormat dateFormater = FastDateFormat.getInstance(Constantes.DATE_PATTERN); |
25 | 24 | ||
26 | public static String getSOuN(String valor){ | 25 | public static String getSOuN(String valor){ |
27 | if("S".equals(valor) || "s".equals(valor)){ | 26 | if("S".equals(valor) || "s".equals(valor)){ |
@@ -40,8 +39,6 @@ public class Util { | @@ -40,8 +39,6 @@ public class Util { | ||
40 | } | 39 | } |
41 | 40 | ||
42 | public static String formatarData(Date data){ | 41 | public static String formatarData(Date data){ |
43 | - SimpleDateFormat dateFormater = new SimpleDateFormat("dd/MM/yyyy"); | ||
44 | - | ||
45 | if(data != null){ | 42 | if(data != null){ |
46 | return dateFormater.format(data); | 43 | return dateFormater.format(data); |
47 | } | 44 | } |
@@ -167,6 +164,6 @@ public class Util { | @@ -167,6 +164,6 @@ public class Util { | ||
167 | } | 164 | } |
168 | 165 | ||
169 | public static String getOnlyNumbers(String string) throws Exception{ | 166 | public static String getOnlyNumbers(String string) throws Exception{ |
170 | - return string.replaceAll(REGEX_SOMENTE_NUMEROS,""); | 167 | + return string.replaceAll(Constantes.REGEX_SOMENTE_NUMEROS,""); |
171 | } | 168 | } |
172 | } | 169 | } |