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 | 105 | |
106 | 106 | @Inject |
107 | 107 | private UserTransaction userTransaction; |
108 | - | |
109 | - private static String NAO = "N"; | |
110 | - | |
108 | + | |
111 | 109 | /** |
112 | 110 | * @api {get} /:unidade/documentos/:documento Consultar documento |
113 | 111 | * @apiName consultarDocumento |
... | ... | @@ -510,7 +508,7 @@ public class DocumentoResource { |
510 | 508 | @Produces(MediaType.APPLICATION_OCTET_STREAM) |
511 | 509 | public Response exportarDocumento(@PathParam("unidade") String unidade, @PathParam("documento") String documento) throws Exception{ |
512 | 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 | 513 | String linkAcesso = retorno.getLinkAcesso(); |
516 | 514 | |
... | ... | @@ -723,7 +721,7 @@ public class DocumentoResource { |
723 | 721 | |
724 | 722 | return encodeBase64(html); |
725 | 723 | }catch(JsonParseException ex){ |
726 | - logger.warn(conteudo); | |
724 | + logger.debug(conteudo); | |
727 | 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 | 67 | @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) |
68 | 68 | public br.gov.ans.integracao.sei.client.Unidade[] listarUnidades() throws Exception{ |
69 | 69 | Unidade[] lista = seiNativeService.listarUnidades(Constantes.SEI_BROKER, Operacao.LISTAR_UNIDADES, null, null); |
70 | - | |
70 | + | |
71 | 71 | carregarMapUnidades(lista); |
72 | 72 | |
73 | 73 | return lista; | ... | ... |
src/main/java/br/gov/ans/integracao/sei/utils/Constantes.java
... | ... | @@ -10,13 +10,16 @@ public class Constantes { |
10 | 10 | public static final int AXIS_TIMEOUT = 1000 * (60 * AXIS_TIMEOUT_IN_MINUTES); |
11 | 11 | public static final String CODIGO_BRASIL = "76"; |
12 | 12 | public static final String CODIGO_ORGAO_ANS = "0"; |
13 | + public static final String DATE_PATTERN = "dd/MM/yyyy"; | |
13 | 14 | public static final String DOCUMENTO_GERAL = "G"; |
14 | 15 | public static final String DOCUMENTO_RECEBIDO = "R"; |
15 | 16 | public static final String MASCARA_PROCESSO_17 = "#####.######/####-##"; |
16 | 17 | public static final String MASCARA_PROCESSO_21 = "#######.########/####-##"; |
18 | + public static String NAO = "N"; | |
17 | 19 | public static final String JBOSS_HOME = System.getProperty("jboss.home.dir"); |
18 | 20 | public static final String NOME_SISTEMA = "sei-broker"; |
19 | 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 | 23 | public static final String SEI_BROKER = "SEI-Broker"; |
21 | 24 | public static final int TAMANHO_MAXIMO_ARQUIVO = 16777216; |
22 | 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 | 3 | import static br.gov.ans.integracao.sei.utils.Util.getSOuN; |
4 | 4 | |
5 | 5 | import java.rmi.RemoteException; |
6 | -import java.text.DateFormat; | |
7 | -import java.text.SimpleDateFormat; | |
8 | 6 | |
9 | 7 | import javax.inject.Inject; |
10 | 8 | |
11 | 9 | import org.apache.commons.lang3.StringUtils; |
10 | +import org.apache.commons.lang3.time.FastDateFormat; | |
12 | 11 | |
13 | 12 | import br.gov.ans.exceptions.BusinessException; |
14 | 13 | import br.gov.ans.integracao.sei.client.Contato; |
... | ... | @@ -23,7 +22,7 @@ import br.gov.ans.integracao.sei.modelo.enums.TipoPessoa; |
23 | 22 | |
24 | 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 | 27 | @Inject |
29 | 28 | private ContatoDAO contatoDAO; | ... | ... |
src/main/java/br/gov/ans/integracao/sei/utils/PessoaHelper.java
1 | 1 | package br.gov.ans.integracao.sei.utils; |
2 | 2 | |
3 | 3 | import java.lang.reflect.Field; |
4 | -import java.text.DateFormat; | |
5 | 4 | import java.text.ParseException; |
6 | -import java.text.SimpleDateFormat; | |
7 | 5 | import java.util.ArrayList; |
8 | 6 | import java.util.List; |
9 | 7 | |
... | ... | @@ -12,6 +10,7 @@ import javax.inject.Inject; |
12 | 10 | import org.apache.commons.lang3.ArrayUtils; |
13 | 11 | import org.apache.commons.lang3.StringUtils; |
14 | 12 | import org.apache.commons.lang3.reflect.FieldUtils; |
13 | +import org.apache.commons.lang3.time.FastDateFormat; | |
15 | 14 | import org.jboss.logging.Logger; |
16 | 15 | |
17 | 16 | import br.gov.ans.exceptions.BusinessException; |
... | ... | @@ -41,7 +40,7 @@ public class PessoaHelper { |
41 | 40 | @Inject |
42 | 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 | 45 | public List<Pessoa> buildPessoa(Contato[] contatos) throws ParseException, BusinessException, IllegalAccessException, ResourceNotFoundException{ |
47 | 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 | 2 | |
3 | 3 | import java.io.IOException; |
4 | 4 | import java.text.ParseException; |
5 | -import java.text.SimpleDateFormat; | |
6 | 5 | import java.util.Date; |
7 | 6 | import java.util.HashMap; |
8 | 7 | import java.util.Map; |
9 | -import java.util.regex.Pattern; | |
10 | 8 | |
11 | 9 | import javax.persistence.Query; |
12 | 10 | import javax.swing.text.MaskFormatter; |
13 | 11 | |
14 | 12 | import org.apache.commons.codec.binary.Base64; |
15 | 13 | import org.apache.commons.lang3.StringUtils; |
14 | +import org.apache.commons.lang3.time.FastDateFormat; | |
16 | 15 | import org.codehaus.jackson.JsonParseException; |
17 | 16 | import org.codehaus.jackson.map.JsonMappingException; |
18 | 17 | import org.codehaus.jackson.map.ObjectMapper; |
... | ... | @@ -21,7 +20,7 @@ import org.codehaus.jackson.type.TypeReference; |
21 | 20 | import br.gov.ans.exceptions.BusinessException; |
22 | 21 | |
23 | 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 | 25 | public static String getSOuN(String valor){ |
27 | 26 | if("S".equals(valor) || "s".equals(valor)){ |
... | ... | @@ -40,8 +39,6 @@ public class Util { |
40 | 39 | } |
41 | 40 | |
42 | 41 | public static String formatarData(Date data){ |
43 | - SimpleDateFormat dateFormater = new SimpleDateFormat("dd/MM/yyyy"); | |
44 | - | |
45 | 42 | if(data != null){ |
46 | 43 | return dateFormater.format(data); |
47 | 44 | } |
... | ... | @@ -167,6 +164,6 @@ public class Util { |
167 | 164 | } |
168 | 165 | |
169 | 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 | } | ... | ... |