Commit 5fad83cfe179c3add5f943a62fda8d917e2bfa6d

Authored by Guilherme Andrade Del Cantoni
1 parent 291d4332

[Fixed #14] Melhoria em tratamentos de erros provenientes de webservices

Showing 1 changed file with 115 additions and 168 deletions   Show diff stats
rn/ProcessoEletronicoRN.php
@@ -38,8 +38,6 @@ class ProcessoEletronicoRN extends InfraRN { @@ -38,8 +38,6 @@ class ProcessoEletronicoRN extends InfraRN {
38 // 02 a 18 estão registrados na tabela rel_tarefa_operacao 38 // 02 a 18 estão registrados na tabela rel_tarefa_operacao
39 public static $OP_OPERACAO_REGISTRO = "01"; 39 public static $OP_OPERACAO_REGISTRO = "01";
40 40
41 -  
42 -  
43 const ALGORITMO_HASH_DOCUMENTO = 'SHA256'; 41 const ALGORITMO_HASH_DOCUMENTO = 'SHA256';
44 42
45 /** 43 /**
@@ -73,7 +71,6 @@ class ProcessoEletronicoRN extends InfraRN { @@ -73,7 +71,6 @@ class ProcessoEletronicoRN extends InfraRN {
73 "99" => "Outro" 71 "99" => "Outro"
74 ); 72 );
75 73
76 -  
77 private $strWSDL = null; 74 private $strWSDL = null;
78 private $objPenWs = null; 75 private $objPenWs = null;
79 private $options = null; 76 private $options = null;
@@ -140,8 +137,7 @@ class ProcessoEletronicoRN extends InfraRN { @@ -140,8 +137,7 @@ class ProcessoEletronicoRN extends InfraRN {
140 @exec($strCommand, $arrOutput, $numRetorno); 137 @exec($strCommand, $arrOutput, $numRetorno);
141 138
142 if($numRetorno > 0){ 139 if($numRetorno > 0){
143 -  
144 - throw new InfraException('Falha de comunicação com o Barramento de Serviços. Por favor, tente novamente mais tarde.', $e); 140 + throw new InfraException('Falha de comunicação com o Processo Eletrônico Nacional. Por favor, tente novamente mais tarde.');
145 } 141 }
146 } 142 }
147 143
@@ -170,8 +166,9 @@ class ProcessoEletronicoRN extends InfraRN { @@ -170,8 +166,9 @@ class ProcessoEletronicoRN extends InfraRN {
170 $this->objPenWs = new BeSimple\SoapClient\SoapClient($this->strWSDL, $this->options); 166 $this->objPenWs = new BeSimple\SoapClient\SoapClient($this->strWSDL, $this->options);
171 } 167 }
172 } catch (Exception $e) { 168 } catch (Exception $e) {
173 - $mensagem = InfraException::inspecionar($e);  
174 - throw new InfraException('Erro acessando serviço: ' . $mensagem, $e); 169 + $mensagem = "Falha de comunicação com o Processo Eletrônico Nacional";
  170 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  171 + throw new InfraException($mensagem, $e, $detalhes);
175 } 172 }
176 } 173 }
177 174
@@ -206,7 +203,10 @@ class ProcessoEletronicoRN extends InfraRN { @@ -206,7 +203,10 @@ class ProcessoEletronicoRN extends InfraRN {
206 } 203 }
207 } 204 }
208 } catch(Exception $e){ 205 } catch(Exception $e){
209 - throw new InfraException("Erro durante obtenção dos repositórios", $e); 206 + //throw new InfraException("Erro durante obtenção dos repositórios", $e);
  207 + $mensagem = "Falha na obtenção dos Repositórios de Estruturas Organizacionais";
  208 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  209 + throw new InfraException($mensagem, $e, $detalhes);
210 } 210 }
211 211
212 return $objRepositorioDTO; 212 return $objRepositorioDTO;
@@ -238,7 +238,10 @@ class ProcessoEletronicoRN extends InfraRN { @@ -238,7 +238,10 @@ class ProcessoEletronicoRN extends InfraRN {
238 } 238 }
239 } 239 }
240 } catch(Exception $e){ 240 } catch(Exception $e){
241 - throw new InfraException("Erro durante obtenção dos repositórios", $e); 241 + //throw new InfraException("Erro durante obtenção dos repositórios", $e);
  242 + $mensagem = "Falha na obtenção dos Repositórios de Estruturas Organizacionais";
  243 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  244 + throw new InfraException($mensagem, $e, $detalhes);
242 } 245 }
243 246
244 return $arrObjRepositorioDTO; 247 return $arrObjRepositorioDTO;
@@ -247,6 +250,7 @@ class ProcessoEletronicoRN extends InfraRN { @@ -247,6 +250,7 @@ class ProcessoEletronicoRN extends InfraRN {
247 public function consultarEstrutura($idRepositorioEstrutura, $numeroDeIdentificacaoDaEstrutura, $bolRetornoRaw = false) { 250 public function consultarEstrutura($idRepositorioEstrutura, $numeroDeIdentificacaoDaEstrutura, $bolRetornoRaw = false) {
248 251
249 try { 252 try {
  253 +
250 $parametros = new stdClass(); 254 $parametros = new stdClass();
251 $parametros->filtroDeEstruturas = new stdClass(); 255 $parametros->filtroDeEstruturas = new stdClass();
252 $parametros->filtroDeEstruturas->identificacaoDoRepositorioDeEstruturas = $idRepositorioEstrutura; 256 $parametros->filtroDeEstruturas->identificacaoDoRepositorioDeEstruturas = $idRepositorioEstrutura;
@@ -276,7 +280,6 @@ class ProcessoEletronicoRN extends InfraRN { @@ -276,7 +280,6 @@ class ProcessoEletronicoRN extends InfraRN {
276 return $objEstrutura; 280 return $objEstrutura;
277 } 281 }
278 else { 282 else {
279 -  
280 $objEstruturaDTO = new EstruturaDTO(); 283 $objEstruturaDTO = new EstruturaDTO();
281 $objEstruturaDTO->setNumNumeroDeIdentificacaoDaEstrutura($objEstrutura->numeroDeIdentificacaoDaEstrutura); 284 $objEstruturaDTO->setNumNumeroDeIdentificacaoDaEstrutura($objEstrutura->numeroDeIdentificacaoDaEstrutura);
282 $objEstruturaDTO->setStrNome($objEstrutura->nome); 285 $objEstruturaDTO->setStrNome($objEstrutura->nome);
@@ -289,48 +292,51 @@ class ProcessoEletronicoRN extends InfraRN { @@ -289,48 +292,51 @@ class ProcessoEletronicoRN extends InfraRN {
289 } 292 }
290 } 293 }
291 catch (Exception $e) { 294 catch (Exception $e) {
292 - throw new InfraException("Erro durante obtenção das unidades", $e); 295 + //throw new InfraException("Erro durante obtenção das unidades", $e);
  296 + $mensagem = "Falha na obtenção de unidades externas";
  297 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  298 + throw new InfraException($mensagem, $e, $detalhes);
293 } 299 }
294 } 300 }
295 301
296 public function listarEstruturas($idRepositorioEstrutura, $nome='') 302 public function listarEstruturas($idRepositorioEstrutura, $nome='')
297 - {  
298 - $arrObjEstruturaDTO = array(); 303 + {
  304 + $arrObjEstruturaDTO = array();
299 305
300 - try{  
301 - $idRepositorioEstrutura = filter_var($idRepositorioEstrutura, FILTER_SANITIZE_NUMBER_INT);  
302 - if(!$idRepositorioEstrutura) {  
303 - throw new InfraException("Repositório de Estruturas inválido");  
304 - } 306 + try{
  307 + $idRepositorioEstrutura = filter_var($idRepositorioEstrutura, FILTER_SANITIZE_NUMBER_INT);
  308 + if(!$idRepositorioEstrutura) {
  309 + throw new InfraException("Repositório de Estruturas inválido");
  310 + }
305 311
306 - $parametros = new stdClass();  
307 - $parametros->filtroDeEstruturas = new stdClass();  
308 - $parametros->filtroDeEstruturas->identificacaoDoRepositorioDeEstruturas = $idRepositorioEstrutura;  
309 - $parametros->filtroDeEstruturas->apenasAtivas = true;  
310 -  
311 - $nome = trim($nome);  
312 - if(is_numeric($nome)) {  
313 - $parametros->filtroDeEstruturas->numeroDeIdentificacaoDaEstrutura = intval($nome);  
314 - } else {  
315 - $parametros->filtroDeEstruturas->nome = utf8_encode($nome);  
316 - } 312 + $parametros = new stdClass();
  313 + $parametros->filtroDeEstruturas = new stdClass();
  314 + $parametros->filtroDeEstruturas->identificacaoDoRepositorioDeEstruturas = $idRepositorioEstrutura;
  315 + $parametros->filtroDeEstruturas->apenasAtivas = true;
  316 +
  317 + $nome = trim($nome);
  318 + if(is_numeric($nome)) {
  319 + $parametros->filtroDeEstruturas->numeroDeIdentificacaoDaEstrutura = intval($nome);
  320 + } else {
  321 + $parametros->filtroDeEstruturas->nome = utf8_encode($nome);
  322 + }
317 323
318 - $result = $this->getObjPenWs()->consultarEstruturas($parametros); 324 + $result = $this->getObjPenWs()->consultarEstruturas($parametros);
319 325
320 - if($result->estruturasEncontradas->totalDeRegistros > 0) { 326 + if($result->estruturasEncontradas->totalDeRegistros > 0) {
321 327
322 - if(!is_array($result->estruturasEncontradas->estrutura)) {  
323 - $result->estruturasEncontradas->estrutura = array($result->estruturasEncontradas->estrutura);  
324 - } 328 + if(!is_array($result->estruturasEncontradas->estrutura)) {
  329 + $result->estruturasEncontradas->estrutura = array($result->estruturasEncontradas->estrutura);
  330 + }
325 331
326 - foreach ($result->estruturasEncontradas->estrutura as $estrutura) {  
327 - $item = new EstruturaDTO();  
328 - $item->setNumNumeroDeIdentificacaoDaEstrutura($estrutura->numeroDeIdentificacaoDaEstrutura);  
329 - $item->setStrNome(utf8_decode($estrutura->nome));  
330 - $item->setStrSigla(utf8_decode($estrutura->sigla));  
331 - $item->setBolAtivo($estrutura->ativo);  
332 - $item->setBolAptoParaReceberTramites($estrutura->aptoParaReceberTramites);  
333 - $item->setStrCodigoNoOrgaoEntidade($estrutura->codigoNoOrgaoEntidade); 332 + foreach ($result->estruturasEncontradas->estrutura as $estrutura) {
  333 + $item = new EstruturaDTO();
  334 + $item->setNumNumeroDeIdentificacaoDaEstrutura($estrutura->numeroDeIdentificacaoDaEstrutura);
  335 + $item->setStrNome(utf8_decode($estrutura->nome));
  336 + $item->setStrSigla(utf8_decode($estrutura->sigla));
  337 + $item->setBolAtivo($estrutura->ativo);
  338 + $item->setBolAptoParaReceberTramites($estrutura->aptoParaReceberTramites);
  339 + $item->setStrCodigoNoOrgaoEntidade($estrutura->codigoNoOrgaoEntidade);
334 340
335 if(!empty($estrutura->hierarquia->nivel)) { 341 if(!empty($estrutura->hierarquia->nivel)) {
336 $array = array(); 342 $array = array();
@@ -345,7 +351,10 @@ class ProcessoEletronicoRN extends InfraRN { @@ -345,7 +351,10 @@ class ProcessoEletronicoRN extends InfraRN {
345 } 351 }
346 352
347 } catch (Exception $e) { 353 } catch (Exception $e) {
348 - throw new InfraException("Erro durante obtenção das unidades", $e); 354 + //throw new InfraException("Erro durante obtenção das unidades", $e);
  355 + $mensagem = "Falha na obtenção de unidades externas";
  356 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  357 + throw new InfraException($mensagem, $e, $detalhes);
349 } 358 }
350 359
351 return $arrObjEstruturaDTO; 360 return $arrObjEstruturaDTO;
@@ -391,21 +400,14 @@ class ProcessoEletronicoRN extends InfraRN { @@ -391,21 +400,14 @@ class ProcessoEletronicoRN extends InfraRN {
391 { 400 {
392 try { 401 try {
393 return $this->getObjPenWs()->enviarProcesso($parametros); 402 return $this->getObjPenWs()->enviarProcesso($parametros);
394 - } catch (\SoapFault $fault) {  
395 -  
396 -  
397 - if (!empty($fault->detail->interoperabilidadeException->codigoErro) && $fault->detail->interoperabilidadeException->codigoErro == '0005') {  
398 - $mensagem = 'O código mapeado para a unidade ' . utf8_decode($parametros->novoTramiteDeProcesso->processo->documento[0]->produtor->unidade->nome) . ' está incorreto.';  
399 - } else {  
400 - $mensagem = $this->tratarFalhaWebService($fault); 403 + } catch (\Exception $e) {
  404 + $mensagem = "Falha no envio externo do processo";
  405 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  406 + if ($e instanceof \SoapFault && !empty($e->detail->interoperabilidadeException->codigoErro) && $e->detail->interoperabilidadeException->codigoErro == '0005') {
  407 + $detalhes = 'O código mapeado para a unidade ' . utf8_decode($parametros->novoTramiteDeProcesso->processo->documento[0]->produtor->unidade->nome) . ' está incorreto.';
401 } 408 }
402 - //TODO: Remover formatação do javascript após resolução do BUG enviado para Mairon  
403 - //relacionado ao a renderização de mensagens de erro na barra de progresso  
404 - error_log($mensagem);  
405 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault);  
406 409
407 - } catch (\Exception $e) {  
408 - throw new InfraException("Error Processing Request", $e); 410 + throw new InfraException($mensagem, $e, $detalhes);
409 } 411 }
410 } 412 }
411 413
@@ -433,27 +435,20 @@ class ProcessoEletronicoRN extends InfraRN { @@ -433,27 +435,20 @@ class ProcessoEletronicoRN extends InfraRN {
433 $arrObjPendenciaDTO[] = $item; 435 $arrObjPendenciaDTO[] = $item;
434 } 436 }
435 } 437 }
436 - } catch (\SoapFault $fault) {  
437 - //$mensagem = $this->tratarFalhaWebService($fault);  
438 - $mensagem = InfraException::inspecionar($fault);  
439 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault); 438 + } catch (\Exception $e) {
  439 + $mensagem = "Falha na listagem de pendências de trâmite de processos";
  440 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  441 + throw new InfraException($mensagem, $e, $detalhes);
440 } 442 }
441 - // catch (\Exception $e) {  
442 - // $mensagem = InfraException::inspecionar($e);  
443 - // throw new InfraException("Error Processing Request", $e);  
444 - // }  
445 443
446 return $arrObjPendenciaDTO; 444 return $arrObjPendenciaDTO;
447 } 445 }
448 446
449 //TODO: Tratar cada um dos possíveis erros gerados pelos serviços de integração do PEN 447 //TODO: Tratar cada um dos possíveis erros gerados pelos serviços de integração do PEN
450 - private function tratarFalhaWebService(SoapFault $fault) 448 + private function tratarFalhaWebService(Exception $fault)
451 { 449 {
452 - error_log('$e->faultcode:' . $fault->faultcode);  
453 - error_log('$e->detail:' . print_r($fault->detail, true));  
454 -  
455 - $mensagem = $fault->getMessage();  
456 - if(isset($fault->detail->interoperabilidadeException)){ 450 + $mensagem = InfraException::inspecionar($fault);
  451 + if($fault instanceof SoapFault && isset($fault->detail->interoperabilidadeException)){
457 $strWsException = $fault->detail->interoperabilidadeException; 452 $strWsException = $fault->detail->interoperabilidadeException;
458 453
459 switch ($strWsException->codigoErro) { 454 switch ($strWsException->codigoErro) {
@@ -498,34 +493,24 @@ class ProcessoEletronicoRN extends InfraRN { @@ -498,34 +493,24 @@ class ProcessoEletronicoRN extends InfraRN {
498 { 493 {
499 try { 494 try {
500 return $this->getObjPenWs()->enviarComponenteDigital($parametros); 495 return $this->getObjPenWs()->enviarComponenteDigital($parametros);
501 - } catch (\SoapFault $fault) {  
502 - $mensagem = $this->tratarFalhaWebService($fault);  
503 -  
504 - //TODO: Remover formatação do javascript após resolução do BUG enviado para Mairon  
505 - //relacionado ao a renderização de mensagens de erro na barra de progresso  
506 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault);  
507 } catch (\Exception $e) { 496 } catch (\Exception $e) {
508 - throw new InfraException("Error Processing Request", $e); 497 + $mensagem = "Falha no envio de componentes digitais";
  498 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  499 + throw new InfraException($mensagem, $e, $detalhes);
509 } 500 }
510 } 501 }
511 502
512 503
513 - public function solicitarMetadados($parNumIdentificacaoTramite) {  
514 -  
515 - try  
516 - { 504 + public function solicitarMetadados($parNumIdentificacaoTramite)
  505 + {
  506 + try {
517 $parametros = new stdClass(); 507 $parametros = new stdClass();
518 $parametros->IDT = $parNumIdentificacaoTramite; 508 $parametros->IDT = $parNumIdentificacaoTramite;
519 return $this->getObjPenWs()->solicitarMetadados($parametros); 509 return $this->getObjPenWs()->solicitarMetadados($parametros);
520 - } catch (\SoapFault $fault) {  
521 - $mensagem = $this->tratarFalhaWebService($fault);  
522 - //TODO: Remover formatação do javascript após resolução do BUG enviado para Mairon  
523 - //relacionado ao a renderização de mensagens de erro na barra de progresso  
524 - error_log($mensagem);  
525 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault);  
526 -  
527 } catch (\Exception $e) { 510 } catch (\Exception $e) {
528 - throw new InfraException("Error Processing Request", $e); 511 + $mensagem = "Falha na solicitação de metadados do processo";
  512 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  513 + throw new InfraException($mensagem, $e, $detalhes);
529 } 514 }
530 } 515 }
531 516
@@ -871,9 +856,6 @@ class ProcessoEletronicoRN extends InfraRN { @@ -871,9 +856,6 @@ class ProcessoEletronicoRN extends InfraRN {
871 856
872 } catch (\SoapFault $fault) { 857 } catch (\SoapFault $fault) {
873 $mensagem = $this->tratarFalhaWebService($fault); 858 $mensagem = $this->tratarFalhaWebService($fault);
874 - //TODO: Remover formatação do javascript após resolução do BUG enviado para Mairon  
875 - //rlacionado ao a renderização de mensagens de erro na barra de progresso  
876 - error_log($mensagem);  
877 throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault); 859 throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault);
878 } catch (\Exception $e) { 860 } catch (\Exception $e) {
879 throw new InfraException("Error Processing Request", $e); 861 throw new InfraException("Error Processing Request", $e);
@@ -921,12 +903,10 @@ class ProcessoEletronicoRN extends InfraRN { @@ -921,12 +903,10 @@ class ProcessoEletronicoRN extends InfraRN {
921 903
922 return $arrObjTramite; 904 return $arrObjTramite;
923 905
924 - } catch (\SoapFault $fault) {  
925 - $mensagem = $this->tratarFalhaWebService($fault);  
926 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault);  
927 -  
928 } catch (\Exception $e) { 906 } catch (\Exception $e) {
929 - throw new InfraException("Error Processing Request", $e); 907 + $mensagem = "Falha na consulta de trâmites de processo";
  908 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  909 + throw new InfraException($mensagem, $e, $detalhes);
930 } 910 }
931 } 911 }
932 912
@@ -951,12 +931,10 @@ class ProcessoEletronicoRN extends InfraRN { @@ -951,12 +931,10 @@ class ProcessoEletronicoRN extends InfraRN {
951 931
952 return $arrObjTramite; 932 return $arrObjTramite;
953 933
954 - } catch (\SoapFault $fault) {  
955 - $mensagem = $this->tratarFalhaWebService($fault);  
956 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault);  
957 -  
958 } catch (\Exception $e) { 934 } catch (\Exception $e) {
959 - throw new InfraException("Error Processing Request", $e); 935 + $mensagem = "Falha na consulta de trâmites de processo";
  936 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  937 + throw new InfraException($mensagem, $e, $detalhes);
960 } 938 }
961 } 939 }
962 940
@@ -966,15 +944,11 @@ class ProcessoEletronicoRN extends InfraRN { @@ -966,15 +944,11 @@ class ProcessoEletronicoRN extends InfraRN {
966 { 944 {
967 $parametro = new stdClass(); 945 $parametro = new stdClass();
968 $parametro->IDT = $parNumIdTramite; 946 $parametro->IDT = $parNumIdTramite;
969 -  
970 return $this->getObjPenWs()->cienciaRecusa($parametro); 947 return $this->getObjPenWs()->cienciaRecusa($parametro);
971 -  
972 - } catch (\SoapFault $fault) {  
973 - $mensagem = $this->tratarFalhaWebService($fault);  
974 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault);  
975 -  
976 } catch (\Exception $e) { 948 } catch (\Exception $e) {
977 - throw new InfraException("Error Processing Request", $e); 949 + $mensagem = "Falha no registro de ciência da recusa de trâmite";
  950 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  951 + throw new InfraException($mensagem, $e, $detalhes);
978 } 952 }
979 } 953 }
980 954
@@ -1129,53 +1103,30 @@ class ProcessoEletronicoRN extends InfraRN { @@ -1129,53 +1103,30 @@ class ProcessoEletronicoRN extends InfraRN {
1129 $parametro->dadosDoReciboDeTramite->hashDaAssinatura = $strHashDaAssinaturaBase64; 1103 $parametro->dadosDoReciboDeTramite->hashDaAssinatura = $strHashDaAssinaturaBase64;
1130 1104
1131 $this->getObjPenWs()->enviarReciboDeTramite($parametro); 1105 $this->getObjPenWs()->enviarReciboDeTramite($parametro);
1132 -  
1133 return $strHashDaAssinaturaBase64; 1106 return $strHashDaAssinaturaBase64;
1134 1107
1135 - } catch (\SoapFault $fault) {  
1136 -  
1137 - $strMensagem = '[ SOAP Request ]'.PHP_EOL;  
1138 - $strMensagem .= 'Method: enviarReciboDeTramite (FAIL)'.PHP_EOL;  
1139 - $strMensagem .= 'Request: '.$this->getObjPenWs()->__getLastRequest().PHP_EOL;  
1140 - $strMensagem .= 'Response: '.$this->getObjPenWs()->__getLastResponse().PHP_EOL;  
1141 -  
1142 - file_put_contents('/tmp/pen.log', $strMensagem.PHP_EOL, FILE_APPEND);  
1143 -  
1144 - if(isset($objPrivatekey)){  
1145 - openssl_free_key($objPrivatekey);  
1146 - }  
1147 -  
1148 - $mensagem = $this->tratarFalhaWebService($fault);  
1149 -  
1150 - //TODO: Remover formatação do javascript após resolução do BUG enviado para Mairon  
1151 - //relacionado ao a renderização de mensagens de erro na barra de progresso  
1152 - error_log($mensagem);  
1153 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault);  
1154 } catch (\Exception $e) { 1108 } catch (\Exception $e) {
  1109 + $mensagem = "Falha no envio de recibo de trâmite de processo";
  1110 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  1111 + throw new InfraException($mensagem, $e, $detalhes);
  1112 + } finally {
1155 if(isset($objPrivatekey)){ 1113 if(isset($objPrivatekey)){
1156 openssl_free_key($objPrivatekey); 1114 openssl_free_key($objPrivatekey);
1157 } 1115 }
1158 -  
1159 - throw new InfraException("Error Processing Request", $e);  
1160 } 1116 }
1161 } 1117 }
1162 1118
1163 public function receberReciboDeTramite($parNumIdTramite) 1119 public function receberReciboDeTramite($parNumIdTramite)
1164 { 1120 {
1165 - try  
1166 - {  
1167 - $parametro = new stdClass();  
1168 - $parametro->IDT = $parNumIdTramite;  
1169 -  
1170 - $resultado = $this->getObjPenWs()->receberReciboDeTramite($parametro);  
1171 -  
1172 - return $resultado;  
1173 - }  
1174 - catch (\SoapFault $fault) {  
1175 - $mensagem = $this->tratarFalhaWebService($fault);  
1176 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault); 1121 + try {
  1122 + $parametro = new stdClass();
  1123 + $parametro->IDT = $parNumIdTramite;
  1124 + $resultado = $this->getObjPenWs()->receberReciboDeTramite($parametro);
  1125 + return $resultado;
1177 } catch (\Exception $e) { 1126 } catch (\Exception $e) {
1178 - throw new InfraException("Error Processing Request", $e); 1127 + $mensagem = "Falha no recebimento de recibo de trâmite";
  1128 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  1129 + throw new InfraException($mensagem, $e, $detalhes);
1179 } 1130 }
1180 } 1131 }
1181 1132
@@ -1190,19 +1141,14 @@ class ProcessoEletronicoRN extends InfraRN { @@ -1190,19 +1141,14 @@ class ProcessoEletronicoRN extends InfraRN {
1190 try { 1141 try {
1191 $parametro = new stdClass(); 1142 $parametro = new stdClass();
1192 $parametro->IDT = $parNumIdTramite; 1143 $parametro->IDT = $parNumIdTramite;
1193 -  
1194 $resultado = $this->getObjPenWs()->receberReciboDeEnvio($parametro); 1144 $resultado = $this->getObjPenWs()->receberReciboDeEnvio($parametro);
1195 -  
1196 return $resultado->conteudoDoReciboDeEnvio; 1145 return $resultado->conteudoDoReciboDeEnvio;
1197 } 1146 }
1198 - catch (\SoapFault $fault) {  
1199 - $mensagem = $this->tratarFalhaWebService($fault);  
1200 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault);  
1201 - }  
1202 catch (\Exception $e) { 1147 catch (\Exception $e) {
1203 - throw new InfraException("Error Processing Request", $e); 1148 + $mensagem = "Falha no recebimento de recibo de trâmite";
  1149 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  1150 + throw new InfraException($mensagem, $e, $detalhes);
1204 } 1151 }
1205 - throw new InfraException("Error Processing Request", $e);  
1206 } 1152 }
1207 1153
1208 //TODO: Implementar mapeamento entre operações do PEN e tarefas do SEI 1154 //TODO: Implementar mapeamento entre operações do PEN e tarefas do SEI
@@ -1302,8 +1248,10 @@ class ProcessoEletronicoRN extends InfraRN { @@ -1302,8 +1248,10 @@ class ProcessoEletronicoRN extends InfraRN {
1302 try{ 1248 try{
1303 $this->getObjPenWs()->cancelarEnvioDeTramite($parametros); 1249 $this->getObjPenWs()->cancelarEnvioDeTramite($parametros);
1304 } 1250 }
1305 - catch(\SoapFault $e) {  
1306 - throw new InfraException($e->getMessage(), null, $e); 1251 + catch(\Exception $e) {
  1252 + $mensagem = "Falha no cancelamento de trâmite de processo";
  1253 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  1254 + throw new InfraException($mensagem, $e, $detalhes);
1307 } 1255 }
1308 } 1256 }
1309 1257
@@ -1325,16 +1273,12 @@ class ProcessoEletronicoRN extends InfraRN { @@ -1325,16 +1273,12 @@ class ProcessoEletronicoRN extends InfraRN {
1325 $parametros->recusaDeTramite->IDT = $idTramite; 1273 $parametros->recusaDeTramite->IDT = $idTramite;
1326 $parametros->recusaDeTramite->justificativa = utf8_encode($justificativa); 1274 $parametros->recusaDeTramite->justificativa = utf8_encode($justificativa);
1327 $parametros->recusaDeTramite->motivo = $motivo; 1275 $parametros->recusaDeTramite->motivo = $motivo;
1328 -  
1329 $resultado = $this->getObjPenWs()->recusarTramite($parametros); 1276 $resultado = $this->getObjPenWs()->recusarTramite($parametros);
1330 1277
1331 - } catch (SoapFault $fault) {  
1332 -  
1333 - $mensagem = $this->tratarFalhaWebService($fault);  
1334 - throw new InfraException(InfraString::formatarJavaScript($mensagem), $fault);  
1335 -  
1336 } catch (Exception $e) { 1278 } catch (Exception $e) {
1337 - return $e->getMessage(); 1279 + $mensagem = "Falha na recusa de trâmite de processo";
  1280 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  1281 + throw new InfraException($mensagem, $e, $detalhes);
1338 } 1282 }
1339 } 1283 }
1340 1284
@@ -1344,14 +1288,13 @@ class ProcessoEletronicoRN extends InfraRN { @@ -1344,14 +1288,13 @@ class ProcessoEletronicoRN extends InfraRN {
1344 $tramitePendenteDTO = new TramitePendenteDTO(); 1288 $tramitePendenteDTO = new TramitePendenteDTO();
1345 $tramitePendenteDTO->setNumIdTramite($numIdentificacaoTramite); 1289 $tramitePendenteDTO->setNumIdTramite($numIdentificacaoTramite);
1346 $tramitePendenteDTO->setNumIdAtividade($idAtividadeExpedicao); 1290 $tramitePendenteDTO->setNumIdAtividade($idAtividadeExpedicao);
1347 -  
1348 $tramitePendenteBD = new TramitePendenteBD($this->getObjInfraIBanco()); 1291 $tramitePendenteBD = new TramitePendenteBD($this->getObjInfraIBanco());
1349 $tramitePendenteBD->cadastrar($tramitePendenteDTO); 1292 $tramitePendenteBD->cadastrar($tramitePendenteDTO);
1350 1293
1351 - } catch (\InfraException $ex) {  
1352 - throw new InfraException($ex->getStrDescricao());  
1353 - } catch (\Exception $ex) {  
1354 - throw new InfraException($ex->getMessage()); 1294 + } catch (\Exception $e) {
  1295 + $mensagem = "Falha no cadastramento de trâmite pendente";
  1296 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  1297 + throw new InfraException($mensagem, $e, $detalhes);
1355 } 1298 }
1356 } 1299 }
1357 1300
@@ -1445,7 +1388,9 @@ class ProcessoEletronicoRN extends InfraRN { @@ -1445,7 +1388,9 @@ class ProcessoEletronicoRN extends InfraRN {
1445 return $hipoteses; 1388 return $hipoteses;
1446 1389
1447 } catch(Exception $e){ 1390 } catch(Exception $e){
1448 - throw new InfraException("Erro durante obtenção da resposta das hipóteses legais", $e); 1391 + $mensagem = "Falha na obtenção de hipóteses legais";
  1392 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  1393 + throw new InfraException($mensagem, $e, $detalhes);
1449 } 1394 }
1450 } 1395 }
1451 1396
@@ -1454,7 +1399,9 @@ class ProcessoEletronicoRN extends InfraRN { @@ -1454,7 +1399,9 @@ class ProcessoEletronicoRN extends InfraRN {
1454 $objProcessoEletronicoBD = new ProcessoEletronicoBD($this->getObjInfraIBanco()); 1399 $objProcessoEletronicoBD = new ProcessoEletronicoBD($this->getObjInfraIBanco());
1455 return $objProcessoEletronicoBD->contar($objProcessoEletronicoDTO); 1400 return $objProcessoEletronicoBD->contar($objProcessoEletronicoDTO);
1456 }catch(Exception $e){ 1401 }catch(Exception $e){
1457 - throw new InfraException('Erro contando Processos Externos.',$e); 1402 + $mensagem = "Falha na contagem de processos eletrônicos registrados";
  1403 + $detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
  1404 + throw new InfraException($mensagem, $e, $detalhes);
1458 } 1405 }
1459 } 1406 }
1460 } 1407 }