Commit 216d35ac09559c4315ffbbd3bd5ecc7318a3e704
1 parent
8b36b7ea
Exists in
master
and in
6 other branches
[Fixed #43] Componente digital do documento XYZ não pode ser localizado
Showing
2 changed files
with
53 additions
and
42 deletions
Show diff stats
rn/ExpedirProcedimentoRN.php
@@ -1108,6 +1108,7 @@ class ExpedirProcedimentoRN extends InfraRN { | @@ -1108,6 +1108,7 @@ class ExpedirProcedimentoRN extends InfraRN { | ||
1108 | //$this->atribuirAssinaturaEletronica($objDocumento->componenteDigital, $objDocumentoDTO); | 1108 | //$this->atribuirAssinaturaEletronica($objDocumento->componenteDigital, $objDocumentoDTO); |
1109 | 1109 | ||
1110 | $objDocumento->componenteDigital->idAnexo = $arrInformacaoArquivo['ID_ANEXO']; | 1110 | $objDocumento->componenteDigital->idAnexo = $arrInformacaoArquivo['ID_ANEXO']; |
1111 | + | ||
1111 | return $objDocumento; | 1112 | return $objDocumento; |
1112 | } | 1113 | } |
1113 | 1114 | ||
@@ -1238,52 +1239,61 @@ class ExpedirProcedimentoRN extends InfraRN { | @@ -1238,52 +1239,61 @@ class ExpedirProcedimentoRN extends InfraRN { | ||
1238 | 1239 | ||
1239 | $objAnexoDTO = $this->consultarAnexo($objDocumentoDTO->getDblIdDocumento()); | 1240 | $objAnexoDTO = $this->consultarAnexo($objDocumentoDTO->getDblIdDocumento()); |
1240 | 1241 | ||
1241 | - if(!isset($objAnexoDTO)){ | ||
1242 | - throw new InfraException("Componente digital do documento {$strProtocoloDocumentoFormatado} não pode ser localizado."); | ||
1243 | - } | ||
1244 | - | ||
1245 | - //VALIDAO DE TAMANHO DE DOCUMENTOS EXTERNOS PARA A EXPEDIO | ||
1246 | - $objPenParametroRN = new PenParametroRN(); | ||
1247 | - if($objAnexoDTO->getNumTamanho() > ($objPenParametroRN->getParametro('PEN_TAMANHO_MAXIMO_DOCUMENTO_EXPEDIDO') * 1024 * 1024) && $objDocumentoDTO->getStrStaEstadoProtocolo() != ProtocoloRN::$TE_DOCUMENTO_CANCELADO){ | ||
1248 | - $strTamanhoFormatado = round(($objAnexoDTO->getNumTamanho() / 1024) / 1024,2); | ||
1249 | - throw new InfraException("O tamanho do documento {$strTamanhoFormatado} MB é maior que os {$objPenParametroRN->getParametro('PEN_TAMANHO_MAXIMO_DOCUMENTO_EXPEDIDO')} MB permitidos para trâmite externo de documentos."); | ||
1250 | - } | 1242 | + if(isset($objAnexoDTO)){ |
1243 | + //VALIDAO DE TAMANHO DE DOCUMENTOS EXTERNOS PARA A EXPEDIO | ||
1244 | + $objPenParametroRN = new PenParametroRN(); | ||
1245 | + if($objAnexoDTO->getNumTamanho() > ($objPenParametroRN->getParametro('PEN_TAMANHO_MAXIMO_DOCUMENTO_EXPEDIDO') * 1024 * 1024) && $objDocumentoDTO->getStrStaEstadoProtocolo() != ProtocoloRN::$TE_DOCUMENTO_CANCELADO){ | ||
1246 | + $strTamanhoFormatado = round(($objAnexoDTO->getNumTamanho() / 1024) / 1024,2); | ||
1247 | + throw new InfraException("O tamanho do documento {$strTamanhoFormatado} MB é maior que os {$objPenParametroRN->getParametro('PEN_TAMANHO_MAXIMO_DOCUMENTO_EXPEDIDO')} MB permitidos para trâmite externo de documentos."); | ||
1248 | + } | ||
1251 | 1249 | ||
1252 | - //Obtenção do conteúdo do documento externo | ||
1253 | - //TODO: Particionar o documento em tamanho menor caso ultrapasse XX megabytes | ||
1254 | - $strCaminhoAnexo = $this->objAnexoRN->obterLocalizacao($objAnexoDTO); | ||
1255 | - | ||
1256 | - $fp = fopen($strCaminhoAnexo, "rb"); | ||
1257 | - try { | ||
1258 | - $strConteudoAssinatura = fread($fp, filesize($strCaminhoAnexo)); | ||
1259 | - fclose($fp); | ||
1260 | - } catch(Exception $e) { | ||
1261 | - fclose($fp); | ||
1262 | - throw new InfraException("Erro obtendo conteúdo do anexo do documento {$strProtocoloDocumentoFormatado}", $e); | ||
1263 | - } | 1250 | + //Obtenção do conteúdo do documento externo |
1251 | + $strCaminhoAnexo = $this->objAnexoRN->obterLocalizacao($objAnexoDTO); | ||
1264 | 1252 | ||
1265 | - $finfo = finfo_open(FILEINFO_MIME_TYPE); | ||
1266 | - try { | ||
1267 | - $strMimeType = finfo_file($finfo, $strCaminhoAnexo); | ||
1268 | - $strDadosComplementaresDoTipoDeArquivo = ""; | ||
1269 | - if(!array_search($strMimeType, $this->arrPenMimeTypes)){ | ||
1270 | - $strDadosComplementaresDoTipoDeArquivo = $strMimeType; | ||
1271 | - $strMimeType = 'outro'; | 1253 | + $fp = fopen($strCaminhoAnexo, "rb"); |
1254 | + try { | ||
1255 | + $strConteudoAssinatura = fread($fp, filesize($strCaminhoAnexo)); | ||
1256 | + fclose($fp); | ||
1257 | + } catch(Exception $e) { | ||
1258 | + fclose($fp); | ||
1259 | + throw new InfraException("Erro obtendo conteúdo do anexo do documento {$strProtocoloDocumentoFormatado}", $e); | ||
1272 | } | 1260 | } |
1273 | 1261 | ||
1274 | - finfo_close($finfo); | ||
1275 | - } catch(Exception $e) { | ||
1276 | - finfo_close($finfo); | ||
1277 | - throw new InfraException("Erro obtendo informações do anexo do documento {$strProtocoloDocumentoFormatado}", $e); | ||
1278 | - } | 1262 | + $finfo = finfo_open(FILEINFO_MIME_TYPE); |
1263 | + try { | ||
1264 | + $strMimeType = finfo_file($finfo, $strCaminhoAnexo); | ||
1265 | + $strDadosComplementaresDoTipoDeArquivo = ""; | ||
1266 | + if(!array_search($strMimeType, $this->arrPenMimeTypes)){ | ||
1267 | + $strDadosComplementaresDoTipoDeArquivo = $strMimeType; | ||
1268 | + $strMimeType = 'outro'; | ||
1269 | + } | ||
1279 | 1270 | ||
1280 | - $arrInformacaoArquivo['NOME'] = $objAnexoDTO->getStrNome(); | ||
1281 | - $arrInformacaoArquivo['CONTEUDO'] = $strConteudoAssinatura; | ||
1282 | - $arrInformacaoArquivo['TAMANHO'] = $objAnexoDTO->getNumTamanho(); | ||
1283 | - $arrInformacaoArquivo['MIME_TYPE'] = $strMimeType; | ||
1284 | - $arrInformacaoArquivo['ID_ANEXO'] = $objAnexoDTO->getNumIdAnexo(); | ||
1285 | - $arrInformacaoArquivo['dadosComplementaresDoTipoDeArquivo'] = $strDadosComplementaresDoTipoDeArquivo; | ||
1286 | 1271 | ||
1272 | + finfo_close($finfo); | ||
1273 | + } catch(Exception $e) { | ||
1274 | + finfo_close($finfo); | ||
1275 | + throw new InfraException("Erro obtendo informações do anexo do documento {$strProtocoloDocumentoFormatado}", $e); | ||
1276 | + } | ||
1277 | + | ||
1278 | + $arrInformacaoArquivo['NOME'] = $objAnexoDTO->getStrNome(); | ||
1279 | + $arrInformacaoArquivo['CONTEUDO'] = $strConteudoAssinatura; | ||
1280 | + $arrInformacaoArquivo['TAMANHO'] = $objAnexoDTO->getNumTamanho(); | ||
1281 | + $arrInformacaoArquivo['MIME_TYPE'] = $strMimeType; | ||
1282 | + $arrInformacaoArquivo['ID_ANEXO'] = $objAnexoDTO->getNumIdAnexo(); | ||
1283 | + $arrInformacaoArquivo['dadosComplementaresDoTipoDeArquivo'] = $strDadosComplementaresDoTipoDeArquivo; | ||
1284 | + | ||
1285 | + } elseif ($objDocumentoDTO->getStrStaEstadoProtocolo() == ProtocoloRN::$TE_DOCUMENTO_CANCELADO) { | ||
1286 | + //Quando não é localizado um Anexo para um documento cancelado, os dados de componente digital precisam ser enviados | ||
1287 | + //pois o Barramento considera o componente digital do documento de forma obrigatória | ||
1288 | + $arrInformacaoArquivo['NOME'] = 'cancelado.html'; | ||
1289 | + $arrInformacaoArquivo['CONTEUDO'] = "[documento cancelado]"; | ||
1290 | + $arrInformacaoArquivo['TAMANHO'] = 0; | ||
1291 | + $arrInformacaoArquivo['ID_ANEXO'] = null; | ||
1292 | + $arrInformacaoArquivo['MIME_TYPE'] = 'text/html'; | ||
1293 | + $arrInformacaoArquivo['dadosComplementaresDoTipoDeArquivo'] = 'outro'; | ||
1294 | + } else { | ||
1295 | + throw new InfraException("Componente digital do documento {$strProtocoloDocumentoFormatado} não pode ser localizado."); | ||
1296 | + } | ||
1287 | } | 1297 | } |
1288 | else { | 1298 | else { |
1289 | $objDocumentoDTO2 = new DocumentoDTO(); | 1299 | $objDocumentoDTO2 = new DocumentoDTO(); |
rn/ReceberProcedimentoRN.php
@@ -1799,8 +1799,9 @@ class ReceberProcedimentoRN extends InfraRN | @@ -1799,8 +1799,9 @@ class ReceberProcedimentoRN extends InfraRN | ||
1799 | $arquivoExtensaoDTO->retStrExtensao(); | 1799 | $arquivoExtensaoDTO->retStrExtensao(); |
1800 | 1800 | ||
1801 | if($arquivoExtensaoBD->contar($arquivoExtensaoDTO) == 0){ | 1801 | if($arquivoExtensaoBD->contar($arquivoExtensaoDTO) == 0){ |
1802 | - $this->objProcessoEletronicoRN->recusarTramite($parIdTramite, 'Componentes digitais com formato inválido no destinatário. ', ProcessoEletronicoRN::MTV_RCSR_TRAM_CD_FORMATO); | ||
1803 | - throw new InfraException("Processo recusado devido a existência de documento em formato {$extDocumento} não permitido pelo sistema. "); | 1802 | + $strMensagem = "Processo recusado devido a existência de documento em formato {$extDocumento} não permitido pelo sistema."; |
1803 | + $this->objProcessoEletronicoRN->recusarTramite($parIdTramite, $strMensagem, ProcessoEletronicoRN::MTV_RCSR_TRAM_CD_FORMATO); | ||
1804 | + throw new InfraException($strMensagem); | ||
1804 | } | 1805 | } |
1805 | } | 1806 | } |
1806 | } | 1807 | } |