Commit f1d4e972a457e9b03cdc5df3f19567fb4d5e4630
1 parent
50940266
Exists in
master
and in
1 other branch
Altera serviço de exportação do documento para PDF
Serviço de exportação para PDF passa a responder em um novo path. Também foi modificada a forma de leitura do número de versão.
Showing
10 changed files
with
66 additions
and
24 deletions
Show diff stats
pom.xml
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | <modelVersion>4.0.0</modelVersion> |
| 5 | 5 | <groupId>br.gov.ans</groupId> |
| 6 | 6 | <artifactId>sei-broker</artifactId> |
| 7 | - <version>2.5</version> | |
| 7 | + <version>2.5.1</version> | |
| 8 | 8 | <packaging>war</packaging> |
| 9 | 9 | <name>sei-broker</name> |
| 10 | 10 | <description>Camada de integração REST para comunicação com o SEI</description> |
| ... | ... | @@ -15,6 +15,13 @@ |
| 15 | 15 | |
| 16 | 16 | <build> |
| 17 | 17 | <plugins> |
| 18 | + <plugin> | |
| 19 | + <groupId>org.apache.maven.plugins</groupId> | |
| 20 | + <artifactId>maven-resources-plugin</artifactId> | |
| 21 | + <configuration> | |
| 22 | + <encoding>ISO-8859-1</encoding> | |
| 23 | + </configuration> | |
| 24 | + </plugin> | |
| 18 | 25 | <plugin> |
| 19 | 26 | <groupId>org.apache.maven.plugins</groupId> |
| 20 | 27 | <artifactId>maven-compiler-plugin</artifactId> |
| ... | ... | @@ -77,6 +84,12 @@ |
| 77 | 84 | </executions> |
| 78 | 85 | </plugin> |
| 79 | 86 | </plugins> |
| 87 | + <resources> | |
| 88 | + <resource> | |
| 89 | + <directory>src/main/resources</directory> | |
| 90 | + <filtering>true</filtering> | |
| 91 | + </resource> | |
| 92 | + </resources> | |
| 80 | 93 | </build> |
| 81 | 94 | |
| 82 | 95 | <dependencies> | ... | ... |
src/main/java/br/gov/ans/filters/LogRequestFilter.java
| ... | ... | @@ -62,7 +62,7 @@ public class LogRequestFilter implements ContainerRequestFilter{ |
| 62 | 62 | try{ |
| 63 | 63 | return securityContext.getUserPrincipal().getName(); |
| 64 | 64 | }catch (Exception ex) { |
| 65 | - logger.error(ex, ex); | |
| 65 | + logger.debug("Sem informações do usuário logado: " + ex); | |
| 66 | 66 | return messages.getMessage("sem.informacoes.usuario"); |
| 67 | 67 | } |
| 68 | 68 | } | ... | ... |
src/main/java/br/gov/ans/integracao/sei/rest/DocumentoResource.java
| ... | ... | @@ -472,7 +472,7 @@ public class DocumentoResource { |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
| 475 | - * @api {get} /:unidade/documentos/:documento/pdf Exportar documento | |
| 475 | + * @api {get} /:unidade/documentos/:documento Exportar documento | |
| 476 | 476 | * @apiName exportarDocumento |
| 477 | 477 | * @apiGroup Documento |
| 478 | 478 | * @apiVersion 2.0.0 |
| ... | ... | @@ -481,11 +481,13 @@ public class DocumentoResource { |
| 481 | 481 | * |
| 482 | 482 | * @apiDescription Exporta documentos do SEI em PDF. |
| 483 | 483 | * |
| 484 | + * @apiParam (Header Parameters) {String} Accept Utilize application/pdf | |
| 485 | + * | |
| 484 | 486 | * @apiParam (Path Parameters) {String} unidade Sigla da Unidade cadastrada no SEI |
| 485 | 487 | * @apiParam (Path Parameters) {String} documento Id do documento que deseja recuperar as informações |
| 486 | 488 | * |
| 487 | 489 | * @apiExample {curl} Exemplo de requisição: |
| 488 | - * curl -i https://<host>/sei-broker/service/COSIT/documentos/0003322/pdf | |
| 490 | + * curl -i https://<host>/sei-broker/service/COSIT/documentos/0003322 | |
| 489 | 491 | * |
| 490 | 492 | * @apiSuccess (Sucesso - 200) {PDF} binario Arquivo no formato PDF. |
| 491 | 493 | * |
| ... | ... | @@ -497,6 +499,13 @@ public class DocumentoResource { |
| 497 | 499 | * } |
| 498 | 500 | */ |
| 499 | 501 | @GET |
| 502 | + @Path("{unidade}/documentos/{documento}") | |
| 503 | + @Produces("application/pdf") | |
| 504 | + public Response exportarDocumentoV2(@PathParam("unidade") String unidade, @PathParam("documento") String documento) throws Exception{ | |
| 505 | + return exportarDocumento(unidade, documento); | |
| 506 | + } | |
| 507 | + | |
| 508 | + @GET | |
| 500 | 509 | @Path("{unidade}/documentos/{documento}/pdf") |
| 501 | 510 | @Produces(MediaType.APPLICATION_OCTET_STREAM) |
| 502 | 511 | public Response exportarDocumento(@PathParam("unidade") String unidade, @PathParam("documento") String documento) throws Exception{ |
| ... | ... | @@ -679,10 +688,11 @@ public class DocumentoResource { |
| 679 | 688 | public void validarAssinaturaDocumento(byte[] bytes, String documento) throws BusinessException{ |
| 680 | 689 | String body = new String(bytes); |
| 681 | 690 | |
| 682 | - String erroDocumentoNaoAssinado = messages.getMessage("documento.nao.assinado", documento); | |
| 691 | + String documentoNaoAssinado = messages.getMessage("documento.nao.assinado", documento); | |
| 692 | + String documentoSemAssinatura = messages.getMessage("documento.sem.assinatura"); | |
| 683 | 693 | |
| 684 | - if(body.contains(erroDocumentoNaoAssinado)){ | |
| 685 | - throw new BusinessException(erroDocumentoNaoAssinado); | |
| 694 | + if(body.contains(documentoNaoAssinado) || body.contains(documentoSemAssinatura)){ | |
| 695 | + throw new BusinessException(documentoNaoAssinado); | |
| 686 | 696 | } |
| 687 | 697 | } |
| 688 | 698 | ... | ... |
src/main/java/br/gov/ans/integracao/sei/rest/InfoResource.java
| ... | ... | @@ -39,10 +39,6 @@ public class InfoResource { |
| 39 | 39 | |
| 40 | 40 | @Inject |
| 41 | 41 | private SeiPortTypeProxy seiNativeService; |
| 42 | - | |
| 43 | - @Inject | |
| 44 | - @PropertiesInfo(file="config.properties", key="versao.sistema") | |
| 45 | - private String versao; | |
| 46 | 42 | |
| 47 | 43 | @PersistenceContext(unitName = "sei_pu", type = PersistenceContextType.EXTENDED) |
| 48 | 44 | private EntityManager emMySQL; |
| ... | ... | @@ -77,7 +73,7 @@ public class InfoResource { |
| 77 | 73 | @Path("/versao") |
| 78 | 74 | @Produces(MediaType.TEXT_PLAIN) |
| 79 | 75 | public String getNumeroVersao(){ |
| 80 | - return versao; | |
| 76 | + return messages.getMessage("versao.servico"); | |
| 81 | 77 | } |
| 82 | 78 | |
| 83 | 79 | /** | ... | ... |
src/main/java/br/gov/ans/integracao/sei/utils/JacksonConfig.java
| ... | ... | @@ -5,6 +5,7 @@ import javax.ws.rs.core.MediaType; |
| 5 | 5 | import javax.ws.rs.ext.ContextResolver; |
| 6 | 6 | import javax.ws.rs.ext.Provider; |
| 7 | 7 | |
| 8 | +import org.codehaus.jackson.map.DeserializationConfig; | |
| 8 | 9 | import org.codehaus.jackson.map.ObjectMapper; |
| 9 | 10 | import org.codehaus.jackson.map.SerializationConfig; |
| 10 | 11 | |
| ... | ... | @@ -17,6 +18,7 @@ public class JacksonConfig implements ContextResolver<ObjectMapper>{ |
| 17 | 18 | public JacksonConfig(){ |
| 18 | 19 | objectMapper = new ObjectMapper(); |
| 19 | 20 | objectMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); |
| 21 | + objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |
| 20 | 22 | } |
| 21 | 23 | |
| 22 | 24 | @Override | ... | ... |
src/main/resources/messages.properties
| 1 | +sei.broker.versao = ${project.version} | |
| 2 | + | |
| 1 | 3 | carregando.unidades = Carregando unidades cadastradas no SEI. |
| 2 | 4 | cliente.nao.autenticado = Cliente não autenticado. |
| 3 | 5 | cliente.nao.autorizado = Cliente não autorizado. |
| ... | ... | @@ -7,6 +9,7 @@ debug.novo.documento.enviado = Nova inclusão de documento enviada ao SEI. |
| 7 | 9 | debug.novo.documento.processado = Documento processado pelo SEI. |
| 8 | 10 | documento.nao.assinado = Documento {0} ainda não foi assinado. |
| 9 | 11 | documento.nao.suportado = Documento {0} não suportado. Content-Type {1} ainda não suportado. |
| 12 | +documento.sem.assinatura = Documento sem assinatura. | |
| 10 | 13 | erro.anexar.processo = Ocorreu um erro ao anexar o processo. |
| 11 | 14 | erro.bloquear.processo = Ocorreu um erro ao bloquear o processo. |
| 12 | 15 | erro.carregar.url.sei = A URL do sei não foi carregada. | ... | ... |
src/main/webapp/api-docs/api_data.js
| ... | ... | @@ -1352,9 +1352,9 @@ define({ "api": [ |
| 1352 | 1352 | "type": "", |
| 1353 | 1353 | "url": "", |
| 1354 | 1354 | "version": "0.0.0", |
| 1355 | - "filename": "sei-broker/target/sei-broker-2.5/api-docs/main.js", | |
| 1356 | - "group": "C__git_sei_broker_target_sei_broker_2_5_api_docs_main_js", | |
| 1357 | - "groupTitle": "C__git_sei_broker_target_sei_broker_2_5_api_docs_main_js", | |
| 1355 | + "filename": "sei-broker/target/sei-broker-2.5.1/api-docs/main.js", | |
| 1356 | + "group": "C__git_sei_broker_target_sei_broker_2_5_1_api_docs_main_js", | |
| 1357 | + "groupTitle": "C__git_sei_broker_target_sei_broker_2_5_1_api_docs_main_js", | |
| 1358 | 1358 | "name": "" |
| 1359 | 1359 | }, |
| 1360 | 1360 | { |
| ... | ... | @@ -3705,7 +3705,7 @@ define({ "api": [ |
| 3705 | 3705 | }, |
| 3706 | 3706 | { |
| 3707 | 3707 | "type": "get", |
| 3708 | - "url": "/:unidade/documentos/:documento/pdf", | |
| 3708 | + "url": "/:unidade/documentos/:documento", | |
| 3709 | 3709 | "title": "Exportar documento", |
| 3710 | 3710 | "name": "exportarDocumento", |
| 3711 | 3711 | "group": "Documento", |
| ... | ... | @@ -3718,6 +3718,15 @@ define({ "api": [ |
| 3718 | 3718 | "description": "<p>Exporta documentos do SEI em PDF.</p>", |
| 3719 | 3719 | "parameter": { |
| 3720 | 3720 | "fields": { |
| 3721 | + "Header Parameters": [ | |
| 3722 | + { | |
| 3723 | + "group": "Header Parameters", | |
| 3724 | + "type": "String", | |
| 3725 | + "optional": false, | |
| 3726 | + "field": "Accept", | |
| 3727 | + "description": "<p>Utilize application/pdf</p>" | |
| 3728 | + } | |
| 3729 | + ], | |
| 3721 | 3730 | "Path Parameters": [ |
| 3722 | 3731 | { |
| 3723 | 3732 | "group": "Path Parameters", |
| ... | ... | @@ -3739,7 +3748,7 @@ define({ "api": [ |
| 3739 | 3748 | "examples": [ |
| 3740 | 3749 | { |
| 3741 | 3750 | "title": "Exemplo de requisição:", |
| 3742 | - "content": "curl -i https://<host>/sei-broker/service/COSIT/documentos/0003322/pdf", | |
| 3751 | + "content": "curl -i https://<host>/sei-broker/service/COSIT/documentos/0003322", | |
| 3743 | 3752 | "type": "curl" |
| 3744 | 3753 | } |
| 3745 | 3754 | ], | ... | ... |
src/main/webapp/api-docs/api_data.json
| ... | ... | @@ -1352,9 +1352,9 @@ |
| 1352 | 1352 | "type": "", |
| 1353 | 1353 | "url": "", |
| 1354 | 1354 | "version": "0.0.0", |
| 1355 | - "filename": "sei-broker/target/sei-broker-2.5/api-docs/main.js", | |
| 1356 | - "group": "C__git_sei_broker_target_sei_broker_2_5_api_docs_main_js", | |
| 1357 | - "groupTitle": "C__git_sei_broker_target_sei_broker_2_5_api_docs_main_js", | |
| 1355 | + "filename": "sei-broker/target/sei-broker-2.5.1/api-docs/main.js", | |
| 1356 | + "group": "C__git_sei_broker_target_sei_broker_2_5_1_api_docs_main_js", | |
| 1357 | + "groupTitle": "C__git_sei_broker_target_sei_broker_2_5_1_api_docs_main_js", | |
| 1358 | 1358 | "name": "" |
| 1359 | 1359 | }, |
| 1360 | 1360 | { |
| ... | ... | @@ -3705,7 +3705,7 @@ |
| 3705 | 3705 | }, |
| 3706 | 3706 | { |
| 3707 | 3707 | "type": "get", |
| 3708 | - "url": "/:unidade/documentos/:documento/pdf", | |
| 3708 | + "url": "/:unidade/documentos/:documento", | |
| 3709 | 3709 | "title": "Exportar documento", |
| 3710 | 3710 | "name": "exportarDocumento", |
| 3711 | 3711 | "group": "Documento", |
| ... | ... | @@ -3718,6 +3718,15 @@ |
| 3718 | 3718 | "description": "<p>Exporta documentos do SEI em PDF.</p>", |
| 3719 | 3719 | "parameter": { |
| 3720 | 3720 | "fields": { |
| 3721 | + "Header Parameters": [ | |
| 3722 | + { | |
| 3723 | + "group": "Header Parameters", | |
| 3724 | + "type": "String", | |
| 3725 | + "optional": false, | |
| 3726 | + "field": "Accept", | |
| 3727 | + "description": "<p>Utilize application/pdf</p>" | |
| 3728 | + } | |
| 3729 | + ], | |
| 3721 | 3730 | "Path Parameters": [ |
| 3722 | 3731 | { |
| 3723 | 3732 | "group": "Path Parameters", |
| ... | ... | @@ -3739,7 +3748,7 @@ |
| 3739 | 3748 | "examples": [ |
| 3740 | 3749 | { |
| 3741 | 3750 | "title": "Exemplo de requisição:", |
| 3742 | - "content": "curl -i https://<host>/sei-broker/service/COSIT/documentos/0003322/pdf", | |
| 3751 | + "content": "curl -i https://<host>/sei-broker/service/COSIT/documentos/0003322", | |
| 3743 | 3752 | "type": "curl" |
| 3744 | 3753 | } |
| 3745 | 3754 | ], | ... | ... |
src/main/webapp/api-docs/api_project.js
src/main/webapp/api-docs/api_project.json