Commit 5c9a4667ae0290578ff8388c052ff8283868c07a
1 parent
a4b23e81
Exists in
master
and in
1 other branch
Adicionando Controllers aos serviços já criados.
Ajustando retorno de mensagem devido a problemas com o InfraException.
Showing
14 changed files
with
685 additions
and
158 deletions
Show diff stats
controlador_ws.php
| @@ -6,6 +6,29 @@ | @@ -6,6 +6,29 @@ | ||
| 6 | require_once dirname(__FILE__).'/../../SEI.php'; | 6 | require_once dirname(__FILE__).'/../../SEI.php'; |
| 7 | require_once dirname(__FILE__).'/vendor/autoload.php'; | 7 | require_once dirname(__FILE__).'/vendor/autoload.php'; |
| 8 | 8 | ||
| 9 | +//echo '<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>'; | ||
| 10 | +mb_internal_encoding('utf-8'); | ||
| 11 | + | ||
| 12 | + | ||
| 13 | +function response_to_utf8($item){ | ||
| 14 | + if(is_array($item)){ | ||
| 15 | + $itemArr = $item; | ||
| 16 | + }else if(is_object($item)) { | ||
| 17 | + $itemArr = get_object_vars($item); | ||
| 18 | + }else if(is_bool($item)){ | ||
| 19 | + return $item; | ||
| 20 | + }else{ | ||
| 21 | + //return mb_convert_encoding($item, "ISO-8859-1", mb_detect_encoding($item, "UTF-8, ISO-8859-1, ISO-8859-15, ASCII", true)); | ||
| 22 | + return utf8_encode(htmlspecialchars($item)); | ||
| 23 | + } | ||
| 24 | + $response = array(); | ||
| 25 | + foreach($itemArr as $key => $val){ | ||
| 26 | + $response[$key] = response_to_utf8($val); | ||
| 27 | + } | ||
| 28 | + return $response; | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | + | ||
| 9 | class TokenValidationMiddleware{ | 32 | class TokenValidationMiddleware{ |
| 10 | public function __invoke($request, $response, $next) | 33 | public function __invoke($request, $response, $next) |
| 11 | { | 34 | { |
| @@ -14,13 +37,12 @@ class TokenValidationMiddleware{ | @@ -14,13 +37,12 @@ class TokenValidationMiddleware{ | ||
| 14 | $token = $request->getHeader('token'); | 37 | $token = $request->getHeader('token'); |
| 15 | 38 | ||
| 16 | if(!$token){ | 39 | if(!$token){ |
| 17 | - return $response->withJson(array('sucesso' => false, 'mensagem' => 'Acesso negado!'), 401); | 40 | + return $response->withJson(response_to_utf8(array('sucesso' => false, 'mensagem' => 'Acesso negado!')), 401); |
| 18 | } | 41 | } |
| 19 | $rn = new MdWsSeiUsuarioRN(); | 42 | $rn = new MdWsSeiUsuarioRN(); |
| 20 | $result = $rn->autenticarToken($token[0]); | 43 | $result = $rn->autenticarToken($token[0]); |
| 21 | if(!$result['sucesso']){ | 44 | if(!$result['sucesso']){ |
| 22 | - var_dump($result); | ||
| 23 | - return $response->withJson($result, 403); | 45 | + return $response->withJson(response_to_utf8($result), 403); |
| 24 | } | 46 | } |
| 25 | $response = $next($request, $response); | 47 | $response = $next($request, $response); |
| 26 | return $response; | 48 | return $response; |
| @@ -38,18 +60,18 @@ $app = new \Slim\App($config); | @@ -38,18 +60,18 @@ $app = new \Slim\App($config); | ||
| 38 | /** | 60 | /** |
| 39 | * Grupo para a versao v1 de servicos REST | 61 | * Grupo para a versao v1 de servicos REST |
| 40 | */ | 62 | */ |
| 41 | -$app->group('/v1',function(){ | 63 | +$app->group('/api/v1',function(){ |
| 42 | /** | 64 | /** |
| 43 | * Grupo de autenticacao <publico> | 65 | * Grupo de autenticacao <publico> |
| 44 | */ | 66 | */ |
| 45 | $this->post('/autenticar', function($request, $response, $args){ | 67 | $this->post('/autenticar', function($request, $response, $args){ |
| 46 | - var_dump(111);exit; | 68 | + /** @var $response Slim\Http\Response */ |
| 47 | $rn = new MdWsSeiUsuarioRN(); | 69 | $rn = new MdWsSeiUsuarioRN(); |
| 48 | $usuarioDTO = new UsuarioDTO(); | 70 | $usuarioDTO = new UsuarioDTO(); |
| 49 | $usuarioDTO->setStrSigla($request->getParam('usuario')); | 71 | $usuarioDTO->setStrSigla($request->getParam('usuario')); |
| 50 | $usuarioDTO->setStrSenha($request->getParam('senha')); | 72 | $usuarioDTO->setStrSenha($request->getParam('senha')); |
| 51 | 73 | ||
| 52 | - return $response->withJSON($rn->autenticar($usuarioDTO)); | 74 | + return $response->withJSON(response_to_utf8($rn->autenticar($usuarioDTO))); |
| 53 | }); | 75 | }); |
| 54 | 76 | ||
| 55 | /** | 77 | /** |
| @@ -59,7 +81,7 @@ $app->group('/v1',function(){ | @@ -59,7 +81,7 @@ $app->group('/v1',function(){ | ||
| 59 | $this->post('/', function($request, $response, $args){ | 81 | $this->post('/', function($request, $response, $args){ |
| 60 | $rn = new MdWsSeiAnotacaoRN(); | 82 | $rn = new MdWsSeiAnotacaoRN(); |
| 61 | $dto = $rn->encapsulaAnotacao($request->getParams()); | 83 | $dto = $rn->encapsulaAnotacao($request->getParams()); |
| 62 | - return $response->withJSON($rn->cadastrarAnotacao($dto)); | 84 | + return $response->withJSON(response_to_utf8($rn->cadastrarAnotacao($dto))); |
| 63 | })->setName('v1_anotacao_cadastrar'); | 85 | })->setName('v1_anotacao_cadastrar'); |
| 64 | 86 | ||
| 65 | })->add( new TokenValidationMiddleware()); | 87 | })->add( new TokenValidationMiddleware()); |
| @@ -68,37 +90,102 @@ $app->group('/v1',function(){ | @@ -68,37 +90,102 @@ $app->group('/v1',function(){ | ||
| 68 | * Grupo de controlador de bloco | 90 | * Grupo de controlador de bloco |
| 69 | */ | 91 | */ |
| 70 | $this->group('/bloco', function(){ | 92 | $this->group('/bloco', function(){ |
| 71 | - $this->get('/listar/bloco/unidade/{unidade}', function($request, $response, $args){ | 93 | + $this->get('/listar/bloco/{unidade}', function($request, $response, $args){ |
| 72 | /** @var $request Slim\Http\Request */ | 94 | /** @var $request Slim\Http\Request */ |
| 73 | $rn = new MdWsSeiBlocoRN(); | 95 | $rn = new MdWsSeiBlocoRN(); |
| 74 | $dto = new UnidadeDTO(); | 96 | $dto = new UnidadeDTO(); |
| 75 | $dto->setNumIdUnidade($request->getAttribute('route')->getArgument('unidade')); | 97 | $dto->setNumIdUnidade($request->getAttribute('route')->getArgument('unidade')); |
| 76 | $dto->setNumMaxRegistrosRetorno($request->getParam('limit')); | 98 | $dto->setNumMaxRegistrosRetorno($request->getParam('limit')); |
| 77 | $dto->setNumPaginaAtual($request->getParam('start')); | 99 | $dto->setNumPaginaAtual($request->getParam('start')); |
| 78 | - return $response->withJSON($rn->listarBlocoUnidade($dto)); | 100 | + return $response->withJSON(response_to_utf8($rn->listarBlocoUnidade($dto))); |
| 79 | }); | 101 | }); |
| 80 | - $this->get('/listar/bloco/documentos/{bloco}', function($request, $response, $args){ | ||
| 81 | - var_dump(111);exit; | 102 | + $this->get('/listar/{bloco}/documentos', function($request, $response, $args){ |
| 82 | /** @var $request Slim\Http\Request */ | 103 | /** @var $request Slim\Http\Request */ |
| 83 | $rn = new MdWsSeiBlocoRN(); | 104 | $rn = new MdWsSeiBlocoRN(); |
| 84 | $dto = new BlocoDTO(); | 105 | $dto = new BlocoDTO(); |
| 85 | $dto->setNumIdBloco($request->getAttribute('route')->getArgument('bloco')); | 106 | $dto->setNumIdBloco($request->getAttribute('route')->getArgument('bloco')); |
| 86 | $dto->setNumMaxRegistrosRetorno($request->getParam('limit')); | 107 | $dto->setNumMaxRegistrosRetorno($request->getParam('limit')); |
| 87 | $dto->setNumPaginaAtual($request->getParam('start')); | 108 | $dto->setNumPaginaAtual($request->getParam('start')); |
| 88 | - return $response->withJSON($rn->listarDocumentosBloco($dto)); | 109 | + return $response->withJSON(response_to_utf8($rn->listarDocumentosBloco($dto))); |
| 110 | + }); | ||
| 111 | + $this->post('/{bloco}/anotacao', function($request, $response, $args){ | ||
| 112 | + /** @var $request Slim\Http\Request */ | ||
| 113 | + $rn = new MdWsSeiBlocoRN(); | ||
| 114 | + $dto = new RelBlocoProtocoloDTO(); | ||
| 115 | + $dto->setNumIdBloco($request->getAttribute('route')->getArgument('bloco')); | ||
| 116 | + $dto->setDblIdProtocolo($request->getParam('protocolo')); | ||
| 117 | + $dto->setStrAnotacao($request->getParam('anotacao')); | ||
| 118 | + return $response->withJSON(response_to_utf8($rn->cadastrarAnotacaoBloco($dto))); | ||
| 89 | }); | 119 | }); |
| 90 | 120 | ||
| 91 | })->add( new TokenValidationMiddleware()); | 121 | })->add( new TokenValidationMiddleware()); |
| 92 | -}); | ||
| 93 | 122 | ||
| 123 | + /** | ||
| 124 | + * Grupo de controlador de documentos | ||
| 125 | + */ | ||
| 126 | + $this->group('/documento', function(){ | ||
| 127 | + $this->get('/listar/ciencia/{protocolo}', function($request, $response, $args){ | ||
| 128 | + /** @var $request Slim\Http\Request */ | ||
| 129 | + $rn = new MdWsSeiDocumentoRN(); | ||
| 130 | + $dto = new MdWsSeiProcessoDTO(); | ||
| 131 | + $dto->setStrValor($request->getAttribute('route')->getArgument('protocolo')); | ||
| 132 | + return $response->withJSON(response_to_utf8($rn->listarCienciaDocumento($dto))); | ||
| 133 | + }); | ||
| 134 | + $this->get('/listar/assinaturas/{documento}', function($request, $response, $args){ | ||
| 135 | + /** @var $request Slim\Http\Request */ | ||
| 136 | + $rn = new MdWsSeiDocumentoRN(); | ||
| 137 | + $dto = new DocumentoDTO(); | ||
| 138 | + $dto->setDblIdDocumento($request->getAttribute('route')->getArgument('documento')); | ||
| 139 | + return $response->withJSON(response_to_utf8($rn->listarAssinaturasDocumento($dto))); | ||
| 140 | + }); | ||
| 141 | + $this->post('/ciencia', function($request, $response, $args){ | ||
| 142 | + /** @var $request Slim\Http\Request */ | ||
| 143 | + $rn = new MdWsSeiDocumentoRN(); | ||
| 144 | + $dto = new DocumentoDTO(); | ||
| 145 | + $dto->setDblIdDocumento($request->getParam('documento')); | ||
| 146 | + return $response->withJSON(response_to_utf8($rn->darCiencia($dto))); | ||
| 147 | + }); | ||
| 148 | + $this->post('/assinar/bloco', function($request, $response, $args){ | ||
| 149 | + /** @var $request Slim\Http\Request */ | ||
| 150 | + $rn = new MdWsSeiDocumentoRN(); | ||
| 151 | + return $response->withJSON(response_to_utf8($rn->apiAssinarDocumentos( | ||
| 152 | + $request->getParam('arrDocumento'), | ||
| 153 | + $request->getParam('documento'), | ||
| 154 | + $request->getParam('orgao'), | ||
| 155 | + $request->getParam('cargo'), | ||
| 156 | + $request->getParam('login'), | ||
| 157 | + $request->getParam('senha'), | ||
| 158 | + $request->getParam('usuario') | ||
| 159 | + ))); | ||
| 160 | + }); | ||
| 161 | + $this->post('/assinar', function($request, $response, $args){ | ||
| 162 | + /** @var $request Slim\Http\Request */ | ||
| 163 | + $rn = new MdWsSeiDocumentoRN(); | ||
| 164 | + return $response->withJSON(response_to_utf8($rn->apiAssinarDocumento( | ||
| 165 | + $request->getParam('documento'), | ||
| 166 | + $request->getParam('documento'), | ||
| 167 | + $request->getParam('orgao'), | ||
| 168 | + $request->getParam('cargo'), | ||
| 169 | + $request->getParam('login'), | ||
| 170 | + $request->getParam('senha'), | ||
| 171 | + $request->getParam('usuario') | ||
| 172 | + ))); | ||
| 173 | + }); | ||
| 174 | + | ||
| 175 | + })->add( new TokenValidationMiddleware()); | ||
| 176 | + | ||
| 177 | + /** | ||
| 178 | + * Grupo de controlador de processos | ||
| 179 | + */ | ||
| 180 | + $this->group('/processo', function(){ | ||
| 181 | + $this->post('/cancelar/sobrestar', function($request, $response, $args){ | ||
| 182 | + /** @var $request Slim\Http\Request */ | ||
| 183 | + $rn = new MdWsSeiProcedimentoRN(); | ||
| 184 | + $dto = new ProcedimentoDTO(); | ||
| 185 | + $dto->setDblIdProcedimento($request->getParam('procedimento')); | ||
| 186 | + return $response->withJSON(response_to_utf8($rn->removerSobrestamentoProcesso($dto))); | ||
| 187 | + }); | ||
| 94 | 188 | ||
| 189 | + })->add( new TokenValidationMiddleware()); | ||
| 190 | +}); | ||
| 95 | $app->run(); | 191 | $app->run(); |
| 96 | -$c = $app->getContainer(); | ||
| 97 | -$c['errorHandler'] = function ($c) { | ||
| 98 | - return function ($request, $response, $exception) use ($c) { | ||
| 99 | - var_dump($exception);exit; | ||
| 100 | - return $c['response']->withStatus(500) | ||
| 101 | - ->withHeader('Content-Type', 'text/html') | ||
| 102 | - ->write('Something went wrong!'); | ||
| 103 | - }; | ||
| 104 | -}; |
rn/MdWsSeiAcompanhamentoRN.php
| @@ -53,9 +53,25 @@ class MdWsSeiAcompanhamentoRN extends InfraRN { | @@ -53,9 +53,25 @@ class MdWsSeiAcompanhamentoRN extends InfraRN { | ||
| 53 | "mensagem" => 'Acompanhamento realizado com sucesso!' | 53 | "mensagem" => 'Acompanhamento realizado com sucesso!' |
| 54 | ); | 54 | ); |
| 55 | }catch (Exception $e){ | 55 | }catch (Exception $e){ |
| 56 | + $mensagem = $e->getMessage(); | ||
| 57 | + if($e instanceof InfraException){ | ||
| 58 | + if(!$e->getStrDescricao()){ | ||
| 59 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 60 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 61 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 62 | + }else{ | ||
| 63 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 64 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + }else{ | ||
| 68 | + $mensagem = $e->getStrDescricao(); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + } | ||
| 56 | return array ( | 72 | return array ( |
| 57 | "sucesso" => false, | 73 | "sucesso" => false, |
| 58 | - "mensagem" => $e->getMessage(), | 74 | + "mensagem" => $mensagem, |
| 59 | "exception" => $e | 75 | "exception" => $e |
| 60 | ); | 76 | ); |
| 61 | } | 77 | } |
rn/MdWsSeiAnotacaoRN.php
| @@ -42,7 +42,7 @@ class MdWsSeiAnotacaoRN extends InfraRN { | @@ -42,7 +42,7 @@ class MdWsSeiAnotacaoRN extends InfraRN { | ||
| 42 | try{ | 42 | try{ |
| 43 | $anotacaoRN = new AnotacaoRN(); | 43 | $anotacaoRN = new AnotacaoRN(); |
| 44 | if(!$anotacaoDTO->getDblIdProtocolo()){ | 44 | if(!$anotacaoDTO->getDblIdProtocolo()){ |
| 45 | - throw new InfraException('Protocolo não informado.'); | 45 | + throw new InfraException('Protocolo n�o informado.'); |
| 46 | } | 46 | } |
| 47 | $anotacaoConsulta = new AnotacaoDTO(); | 47 | $anotacaoConsulta = new AnotacaoDTO(); |
| 48 | $anotacaoConsulta->setDblIdProtocolo($anotacaoDTO->getDblIdProtocolo()); | 48 | $anotacaoConsulta->setDblIdProtocolo($anotacaoDTO->getDblIdProtocolo()); |
| @@ -57,12 +57,28 @@ class MdWsSeiAnotacaoRN extends InfraRN { | @@ -57,12 +57,28 @@ class MdWsSeiAnotacaoRN extends InfraRN { | ||
| 57 | } | 57 | } |
| 58 | return array ( | 58 | return array ( |
| 59 | "sucesso" => true, | 59 | "sucesso" => true, |
| 60 | - "mensagem" => 'Anotação cadastrada com sucesso!' | 60 | + "mensagem" => 'Anotação cadastrada com sucesso!' |
| 61 | ); | 61 | ); |
| 62 | }catch (Exception $e){ | 62 | }catch (Exception $e){ |
| 63 | + $mensagem = $e->getMessage(); | ||
| 64 | + if($e instanceof InfraException){ | ||
| 65 | + if(!$e->getStrDescricao()){ | ||
| 66 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 67 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 68 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 69 | + }else{ | ||
| 70 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 71 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + }else{ | ||
| 75 | + $mensagem = $e->getStrDescricao(); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + } | ||
| 63 | return array ( | 79 | return array ( |
| 64 | "sucesso" => false, | 80 | "sucesso" => false, |
| 65 | - "mensagem" => $e->getMessage(), | 81 | + "mensagem" => $mensagem, |
| 66 | "exception" => $e | 82 | "exception" => $e |
| 67 | ); | 83 | ); |
| 68 | } | 84 | } |
rn/MdWsSeiAssinanteRN.php
| @@ -37,10 +37,26 @@ class MdWsSeiAssinanteRN extends InfraRN { | @@ -37,10 +37,26 @@ class MdWsSeiAssinanteRN extends InfraRN { | ||
| 37 | 'total' => $assinanteDTO->getNumTotalRegistros() | 37 | 'total' => $assinanteDTO->getNumTotalRegistros() |
| 38 | ); | 38 | ); |
| 39 | }catch (Exception $e){ | 39 | }catch (Exception $e){ |
| 40 | - return array( | ||
| 41 | - 'sucesso' => false, | ||
| 42 | - 'mensagem' => $e->getMessage(), | ||
| 43 | - 'exception' => $e | 40 | + $mensagem = $e->getMessage(); |
| 41 | + if($e instanceof InfraException){ | ||
| 42 | + if(!$e->getStrDescricao()){ | ||
| 43 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 44 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 45 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 46 | + }else{ | ||
| 47 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 48 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 49 | + } | ||
| 50 | + } | ||
| 51 | + }else{ | ||
| 52 | + $mensagem = $e->getStrDescricao(); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + } | ||
| 56 | + return array ( | ||
| 57 | + "sucesso" => false, | ||
| 58 | + "mensagem" => $mensagem, | ||
| 59 | + "exception" => $e | ||
| 44 | ); | 60 | ); |
| 45 | } | 61 | } |
| 46 | } | 62 | } |
rn/MdWsSeiAtividadeRN.php
| @@ -19,7 +19,7 @@ class MdWsSeiAtividadeRN extends InfraRN { | @@ -19,7 +19,7 @@ class MdWsSeiAtividadeRN extends InfraRN { | ||
| 19 | foreach($arrParameters as $parameter) { | 19 | foreach($arrParameters as $parameter) { |
| 20 | $parameter = '@' . $parameter . '@'; | 20 | $parameter = '@' . $parameter . '@'; |
| 21 | 21 | ||
| 22 | - $restrito = 'não restrito'; | 22 | + $restrito = 'n�o restrito'; |
| 23 | 23 | ||
| 24 | $nome = ($atividadeDTO->getNumIdUsuarioOrigem())? $atividadeDTO->getStrNomeUsuarioOrigem() : null; | 24 | $nome = ($atividadeDTO->getNumIdUsuarioOrigem())? $atividadeDTO->getStrNomeUsuarioOrigem() : null; |
| 25 | $sigla = ($atividadeDTO->getNumIdUsuarioOrigem())? $atividadeDTO->getStrSiglaUsuarioOrigem() : null; | 25 | $sigla = ($atividadeDTO->getNumIdUsuarioOrigem())? $atividadeDTO->getStrSiglaUsuarioOrigem() : null; |
| @@ -162,10 +162,26 @@ class MdWsSeiAtividadeRN extends InfraRN { | @@ -162,10 +162,26 @@ class MdWsSeiAtividadeRN extends InfraRN { | ||
| 162 | 'total' => $atividadeDTO->getNumTotalRegistros() | 162 | 'total' => $atividadeDTO->getNumTotalRegistros() |
| 163 | ); | 163 | ); |
| 164 | }catch (Exception $e){ | 164 | }catch (Exception $e){ |
| 165 | - return array( | ||
| 166 | - 'sucesso' => false, | ||
| 167 | - 'mensagem' => $e->getMessage(), | ||
| 168 | - 'exception' => $e | 165 | + $mensagem = $e->getMessage(); |
| 166 | + if($e instanceof InfraException){ | ||
| 167 | + if(!$e->getStrDescricao()){ | ||
| 168 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 169 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 170 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 171 | + }else{ | ||
| 172 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 173 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + }else{ | ||
| 177 | + $mensagem = $e->getStrDescricao(); | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + } | ||
| 181 | + return array ( | ||
| 182 | + "sucesso" => false, | ||
| 183 | + "mensagem" => $mensagem, | ||
| 184 | + "exception" => $e | ||
| 169 | ); | 185 | ); |
| 170 | } | 186 | } |
| 171 | } | 187 | } |
rn/MdWsSeiBlocoRN.php
| @@ -69,13 +69,29 @@ class MdWsSeiBlocoRN extends InfraRN { | @@ -69,13 +69,29 @@ class MdWsSeiBlocoRN extends InfraRN { | ||
| 69 | return array( | 69 | return array( |
| 70 | 'sucesso' => true, | 70 | 'sucesso' => true, |
| 71 | 'data' => $result, | 71 | 'data' => $result, |
| 72 | - 'total' => !$result ? 0 : $blocoDTOConsulta->getNumTotalRegistros() | 72 | + 'total' => $blocoDTOConsulta->getNumTotalRegistros() |
| 73 | ); | 73 | ); |
| 74 | }catch (Exception $e){ | 74 | }catch (Exception $e){ |
| 75 | - return array( | ||
| 76 | - 'sucesso' => false, | ||
| 77 | - 'mensagem' => $e->getMessage(), | ||
| 78 | - 'exception' => $e | 75 | + $mensagem = $e->getMessage(); |
| 76 | + if($e instanceof InfraException){ | ||
| 77 | + if(!$e->getStrDescricao()){ | ||
| 78 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 79 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 80 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 81 | + }else{ | ||
| 82 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 83 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + }else{ | ||
| 87 | + $mensagem = $e->getStrDescricao(); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + } | ||
| 91 | + return array ( | ||
| 92 | + "sucesso" => false, | ||
| 93 | + "mensagem" => $mensagem, | ||
| 94 | + "exception" => $e | ||
| 79 | ); | 95 | ); |
| 80 | } | 96 | } |
| 81 | } | 97 | } |
| @@ -88,7 +104,7 @@ class MdWsSeiBlocoRN extends InfraRN { | @@ -88,7 +104,7 @@ class MdWsSeiBlocoRN extends InfraRN { | ||
| 88 | protected function listarDocumentosBlocoConectado(BlocoDTO $blocoDTOConsulta){ | 104 | protected function listarDocumentosBlocoConectado(BlocoDTO $blocoDTOConsulta){ |
| 89 | try{ | 105 | try{ |
| 90 | if(!$blocoDTOConsulta->getNumIdBloco()){ | 106 | if(!$blocoDTOConsulta->getNumIdBloco()){ |
| 91 | - throw new InfraException('Bloco nao informado.'); | 107 | + throw new InfraException('Bloco não informado.'); |
| 92 | } | 108 | } |
| 93 | $relBlocoProtocoloRN = new RelBlocoProtocoloRN(); | 109 | $relBlocoProtocoloRN = new RelBlocoProtocoloRN(); |
| 94 | $relBlocoProtocoloDTOConsulta = new RelBlocoProtocoloDTO(); | 110 | $relBlocoProtocoloDTOConsulta = new RelBlocoProtocoloDTO(); |
| @@ -181,10 +197,26 @@ class MdWsSeiBlocoRN extends InfraRN { | @@ -181,10 +197,26 @@ class MdWsSeiBlocoRN extends InfraRN { | ||
| 181 | 'total' => $relBlocoProtocoloDTOConsulta->getNumTotalRegistros() | 197 | 'total' => $relBlocoProtocoloDTOConsulta->getNumTotalRegistros() |
| 182 | ); | 198 | ); |
| 183 | }catch (Exception $e){ | 199 | }catch (Exception $e){ |
| 184 | - return array( | ||
| 185 | - 'sucesso' => false, | ||
| 186 | - 'mensagem' => $e->getMessage(), | ||
| 187 | - 'exception' => $e | 200 | + $mensagem = $e->getMessage(); |
| 201 | + if($e instanceof InfraException){ | ||
| 202 | + if(!$e->getStrDescricao()){ | ||
| 203 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 204 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 205 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 206 | + }else{ | ||
| 207 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 208 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | + }else{ | ||
| 212 | + $mensagem = $e->getStrDescricao(); | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + } | ||
| 216 | + return array ( | ||
| 217 | + "sucesso" => false, | ||
| 218 | + "mensagem" => $mensagem, | ||
| 219 | + "exception" => $e | ||
| 188 | ); | 220 | ); |
| 189 | } | 221 | } |
| 190 | } | 222 | } |
| @@ -215,15 +247,16 @@ class MdWsSeiBlocoRN extends InfraRN { | @@ -215,15 +247,16 @@ class MdWsSeiBlocoRN extends InfraRN { | ||
| 215 | * @return array | 247 | * @return array |
| 216 | */ | 248 | */ |
| 217 | protected function cadastrarAnotacaoBlocoControlado(RelBlocoProtocoloDTO $relBlocoProtocoloDTOParam){ | 249 | protected function cadastrarAnotacaoBlocoControlado(RelBlocoProtocoloDTO $relBlocoProtocoloDTOParam){ |
| 218 | - try{ | ||
| 219 | - if(!$relBlocoProtocoloDTOParam->isSetNumIdBloco()){ | 250 | + |
| 251 | + try { | ||
| 252 | + if (!$relBlocoProtocoloDTOParam->isSetNumIdBloco()) { | ||
| 220 | throw new InfraException('O bloco deve ser informado.'); | 253 | throw new InfraException('O bloco deve ser informado.'); |
| 221 | } | 254 | } |
| 222 | - if(!$relBlocoProtocoloDTOParam->isSetNumIdBloco()){ | 255 | + if (!$relBlocoProtocoloDTOParam->isSetNumIdBloco()) { |
| 223 | throw new InfraException('O protocolo deve ser informado.'); | 256 | throw new InfraException('O protocolo deve ser informado.'); |
| 224 | } | 257 | } |
| 225 | - if(!$relBlocoProtocoloDTOParam->isSetStrAnotacao()){ | ||
| 226 | - throw new InfraException('A anotacao deve ser informada.'); | 258 | + if (!$relBlocoProtocoloDTOParam->isSetStrAnotacao()) { |
| 259 | + throw new InfraException('A anotação deve ser informada.'); | ||
| 227 | } | 260 | } |
| 228 | $relBlocoProtocoloDTO = new RelBlocoProtocoloDTO(); | 261 | $relBlocoProtocoloDTO = new RelBlocoProtocoloDTO(); |
| 229 | $relBlocoProtocoloDTO->setNumIdBloco($relBlocoProtocoloDTOParam->getNumIdBloco()); | 262 | $relBlocoProtocoloDTO->setNumIdBloco($relBlocoProtocoloDTOParam->getNumIdBloco()); |
| @@ -231,8 +264,8 @@ class MdWsSeiBlocoRN extends InfraRN { | @@ -231,8 +264,8 @@ class MdWsSeiBlocoRN extends InfraRN { | ||
| 231 | $relBlocoProtocoloDTO->retTodos(); | 264 | $relBlocoProtocoloDTO->retTodos(); |
| 232 | $relBlocoProtocoloRN = new RelBlocoProtocoloRN(); | 265 | $relBlocoProtocoloRN = new RelBlocoProtocoloRN(); |
| 233 | $relBlocoProtocoloDTO = $relBlocoProtocoloRN->consultarRN1290($relBlocoProtocoloDTO); | 266 | $relBlocoProtocoloDTO = $relBlocoProtocoloRN->consultarRN1290($relBlocoProtocoloDTO); |
| 234 | - if(!$relBlocoProtocoloDTO){ | ||
| 235 | - throw new InfraException('Documento nao encontrado no bloco informado.'); | 267 | + if (!$relBlocoProtocoloDTO) { |
| 268 | + throw new InfraException('Documento não encontrado no bloco informado.'); | ||
| 236 | } | 269 | } |
| 237 | $relBlocoProtocoloDTO->setStrAnotacao($relBlocoProtocoloDTOParam->getStrAnotacao()); | 270 | $relBlocoProtocoloDTO->setStrAnotacao($relBlocoProtocoloDTOParam->getStrAnotacao()); |
| 238 | $relBlocoProtocoloRN->alterarRN1288($relBlocoProtocoloDTO); | 271 | $relBlocoProtocoloRN->alterarRN1288($relBlocoProtocoloDTO); |
| @@ -242,9 +275,25 @@ class MdWsSeiBlocoRN extends InfraRN { | @@ -242,9 +275,25 @@ class MdWsSeiBlocoRN extends InfraRN { | ||
| 242 | 'mensagem' => 'Anotação realizada com sucesso.' | 275 | 'mensagem' => 'Anotação realizada com sucesso.' |
| 243 | ); | 276 | ); |
| 244 | }catch (Exception $e){ | 277 | }catch (Exception $e){ |
| 278 | + $message = $e->getMessage(); | ||
| 279 | + if($e instanceof InfraException){ | ||
| 280 | + if(!$e->getStrDescricao()){ | ||
| 281 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 282 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 283 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 284 | + }else{ | ||
| 285 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 286 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 287 | + } | ||
| 288 | + } | ||
| 289 | + }else{ | ||
| 290 | + $mensagem = $e->getStrDescricao(); | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + } | ||
| 245 | return array( | 294 | return array( |
| 246 | 'sucesso' => false, | 295 | 'sucesso' => false, |
| 247 | - 'mensagem' => $e->getMessage(), | 296 | + 'mensagem' => $message, |
| 248 | 'exception' => $e | 297 | 'exception' => $e |
| 249 | ); | 298 | ); |
| 250 | } | 299 | } |
rn/MdWsSeiDocumentoRN.php
| @@ -19,7 +19,7 @@ class MdWsSeiDocumentoRN extends InfraRN { | @@ -19,7 +19,7 @@ class MdWsSeiDocumentoRN extends InfraRN { | ||
| 19 | * @param $idUsuario | 19 | * @param $idUsuario |
| 20 | * @return array | 20 | * @return array |
| 21 | */ | 21 | */ |
| 22 | - public function apiAssinarDocumentos(array $arrIdDocumento, $idOrgao, $strCargoFuncao, $siglaUsuario, $senhaUsuario, $idUsuario){ | 22 | + public function apiAssinarDocumentos($arrIdDocumento, $idOrgao, $strCargoFuncao, $siglaUsuario, $senhaUsuario, $idUsuario){ |
| 23 | $arrDocumentoDTO = array(); | 23 | $arrDocumentoDTO = array(); |
| 24 | foreach($arrIdDocumento as $dblIdDocumento){ | 24 | foreach($arrIdDocumento as $dblIdDocumento){ |
| 25 | $documentoDTO = new DocumentoDTO(); | 25 | $documentoDTO = new DocumentoDTO(); |
| @@ -62,7 +62,7 @@ class MdWsSeiDocumentoRN extends InfraRN { | @@ -62,7 +62,7 @@ class MdWsSeiDocumentoRN extends InfraRN { | ||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | /** | 64 | /** |
| 65 | - * Realizar Assinatura Eletrônica | 65 | + * Realizar Assinatura Eletr?nica |
| 66 | * @param AssinaturaDTO $assinaturaDTO | 66 | * @param AssinaturaDTO $assinaturaDTO |
| 67 | * @return array | 67 | * @return array |
| 68 | */ | 68 | */ |
| @@ -77,10 +77,26 @@ class MdWsSeiDocumentoRN extends InfraRN { | @@ -77,10 +77,26 @@ class MdWsSeiDocumentoRN extends InfraRN { | ||
| 77 | 'mensagem' => 'Documento em bloco assinado com sucesso.' | 77 | 'mensagem' => 'Documento em bloco assinado com sucesso.' |
| 78 | ); | 78 | ); |
| 79 | }catch (Exception $e){ | 79 | }catch (Exception $e){ |
| 80 | - return array( | ||
| 81 | - 'sucesso' => false, | ||
| 82 | - 'mensagem' => $e->getMessage(), | ||
| 83 | - 'exception' => $e | 80 | + $mensagem = $e->getMessage(); |
| 81 | + if($e instanceof InfraException){ | ||
| 82 | + if(!$e->getStrDescricao()){ | ||
| 83 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 84 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 85 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 86 | + }else{ | ||
| 87 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 88 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + }else{ | ||
| 92 | + $mensagem = $e->getStrDescricao(); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + } | ||
| 96 | + return array ( | ||
| 97 | + "sucesso" => false, | ||
| 98 | + "mensagem" => $mensagem, | ||
| 99 | + "exception" => $e | ||
| 84 | ); | 100 | ); |
| 85 | } | 101 | } |
| 86 | } | 102 | } |
| @@ -93,7 +109,7 @@ class MdWsSeiDocumentoRN extends InfraRN { | @@ -93,7 +109,7 @@ class MdWsSeiDocumentoRN extends InfraRN { | ||
| 93 | protected function darCienciaControlado(DocumentoDTO $documentoDTO){ | 109 | protected function darCienciaControlado(DocumentoDTO $documentoDTO){ |
| 94 | try{ | 110 | try{ |
| 95 | $documentoRN = new DocumentoRN(); | 111 | $documentoRN = new DocumentoRN(); |
| 96 | - if(!$documentoDTO->getDblIdDocumento()){ | 112 | + if(!$documentoDTO->isSetDblIdDocumento()){ |
| 97 | throw new InfraException('O documento não foi informado.'); | 113 | throw new InfraException('O documento não foi informado.'); |
| 98 | } | 114 | } |
| 99 | $documentoRN->darCiencia($documentoDTO); | 115 | $documentoRN->darCiencia($documentoDTO); |
| @@ -102,10 +118,26 @@ class MdWsSeiDocumentoRN extends InfraRN { | @@ -102,10 +118,26 @@ class MdWsSeiDocumentoRN extends InfraRN { | ||
| 102 | 'mensagem' => 'Ciência documento realizado com sucesso.' | 118 | 'mensagem' => 'Ciência documento realizado com sucesso.' |
| 103 | ); | 119 | ); |
| 104 | }catch (Exception $e){ | 120 | }catch (Exception $e){ |
| 105 | - return array( | ||
| 106 | - 'sucesso' => false, | ||
| 107 | - 'mensagem' => $e->getMessage(), | ||
| 108 | - 'exception' => $e | 121 | + $mensagem = $e->getMessage(); |
| 122 | + if($e instanceof InfraException){ | ||
| 123 | + if(!$e->getStrDescricao()){ | ||
| 124 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 125 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 126 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 127 | + }else{ | ||
| 128 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 129 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + }else{ | ||
| 133 | + $mensagem = $e->getStrDescricao(); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + } | ||
| 137 | + return array ( | ||
| 138 | + "sucesso" => false, | ||
| 139 | + "mensagem" => $mensagem, | ||
| 140 | + "exception" => $e | ||
| 109 | ); | 141 | ); |
| 110 | } | 142 | } |
| 111 | } | 143 | } |
| @@ -146,10 +178,26 @@ class MdWsSeiDocumentoRN extends InfraRN { | @@ -146,10 +178,26 @@ class MdWsSeiDocumentoRN extends InfraRN { | ||
| 146 | $anexo = $resultAnexo[0]; | 178 | $anexo = $resultAnexo[0]; |
| 147 | SeiINT::download($anexo); | 179 | SeiINT::download($anexo); |
| 148 | }catch (Exception $e){ | 180 | }catch (Exception $e){ |
| 149 | - return array( | ||
| 150 | - 'sucesso' => false, | ||
| 151 | - 'mensagem' => $e->getMessage(), | ||
| 152 | - 'exception' => $e | 181 | + $mensagem = $e->getMessage(); |
| 182 | + if($e instanceof InfraException){ | ||
| 183 | + if(!$e->getStrDescricao()){ | ||
| 184 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 185 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 186 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 187 | + }else{ | ||
| 188 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 189 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + }else{ | ||
| 193 | + $mensagem = $e->getStrDescricao(); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + } | ||
| 197 | + return array ( | ||
| 198 | + "sucesso" => false, | ||
| 199 | + "mensagem" => $mensagem, | ||
| 200 | + "exception" => $e | ||
| 153 | ); | 201 | ); |
| 154 | } | 202 | } |
| 155 | } | 203 | } |
| @@ -201,10 +249,26 @@ class MdWsSeiDocumentoRN extends InfraRN { | @@ -201,10 +249,26 @@ class MdWsSeiDocumentoRN extends InfraRN { | ||
| 201 | 'data' => $result | 249 | 'data' => $result |
| 202 | ); | 250 | ); |
| 203 | }catch (Exception $e){ | 251 | }catch (Exception $e){ |
| 204 | - return array( | ||
| 205 | - 'sucesso' => false, | ||
| 206 | - 'mensagem' => $e->getMessage(), | ||
| 207 | - 'exception' => $e | 252 | + $mensagem = $e->getMessage(); |
| 253 | + if($e instanceof InfraException){ | ||
| 254 | + if(!$e->getStrDescricao()){ | ||
| 255 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 256 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 257 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 258 | + }else{ | ||
| 259 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 260 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 261 | + } | ||
| 262 | + } | ||
| 263 | + }else{ | ||
| 264 | + $mensagem = $e->getStrDescricao(); | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + } | ||
| 268 | + return array ( | ||
| 269 | + "sucesso" => false, | ||
| 270 | + "mensagem" => $mensagem, | ||
| 271 | + "exception" => $e | ||
| 208 | ); | 272 | ); |
| 209 | } | 273 | } |
| 210 | } | 274 | } |
| @@ -241,10 +305,26 @@ class MdWsSeiDocumentoRN extends InfraRN { | @@ -241,10 +305,26 @@ class MdWsSeiDocumentoRN extends InfraRN { | ||
| 241 | 'data' => $result | 305 | 'data' => $result |
| 242 | ); | 306 | ); |
| 243 | }catch (Exception $e){ | 307 | }catch (Exception $e){ |
| 244 | - return array( | ||
| 245 | - 'sucesso' => false, | ||
| 246 | - 'mensagem' => $e->getMessage(), | ||
| 247 | - 'exception' => $e | 308 | + $mensagem = $e->getMessage(); |
| 309 | + if($e instanceof InfraException){ | ||
| 310 | + if(!$e->getStrDescricao()){ | ||
| 311 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 312 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 313 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 314 | + }else{ | ||
| 315 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 316 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 317 | + } | ||
| 318 | + } | ||
| 319 | + }else{ | ||
| 320 | + $mensagem = $e->getStrDescricao(); | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + } | ||
| 324 | + return array ( | ||
| 325 | + "sucesso" => false, | ||
| 326 | + "mensagem" => $mensagem, | ||
| 327 | + "exception" => $e | ||
| 248 | ); | 328 | ); |
| 249 | } | 329 | } |
| 250 | } | 330 | } |
rn/MdWsSeiGrupoAcompanhamentoRN.php
| @@ -44,10 +44,26 @@ class MdWsSeiGrupoAcompanhamentoRN extends InfraRN { | @@ -44,10 +44,26 @@ class MdWsSeiGrupoAcompanhamentoRN extends InfraRN { | ||
| 44 | 'total' => $grupoAcompanhamentoDTO->getNumTotalRegistros() | 44 | 'total' => $grupoAcompanhamentoDTO->getNumTotalRegistros() |
| 45 | ); | 45 | ); |
| 46 | }catch (Exception $e){ | 46 | }catch (Exception $e){ |
| 47 | - return array( | ||
| 48 | - 'sucesso' => false, | ||
| 49 | - 'mensagem' => $e->getMessage(), | ||
| 50 | - 'exception' => $e | 47 | + $mensagem = $e->getMessage(); |
| 48 | + if($e instanceof InfraException){ | ||
| 49 | + if(!$e->getStrDescricao()){ | ||
| 50 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 51 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 52 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 53 | + }else{ | ||
| 54 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 55 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + }else{ | ||
| 59 | + $mensagem = $e->getStrDescricao(); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + } | ||
| 63 | + return array ( | ||
| 64 | + "sucesso" => false, | ||
| 65 | + "mensagem" => $mensagem, | ||
| 66 | + "exception" => $e | ||
| 51 | ); | 67 | ); |
| 52 | } | 68 | } |
| 53 | } | 69 | } |
rn/MdWsSeiObservacaoRN.php
| @@ -38,13 +38,29 @@ class MdWsSeiObservacaoRN extends InfraRN { | @@ -38,13 +38,29 @@ class MdWsSeiObservacaoRN extends InfraRN { | ||
| 38 | 38 | ||
| 39 | return array( | 39 | return array( |
| 40 | 'sucesso' => true, | 40 | 'sucesso' => true, |
| 41 | - 'mensagem' => 'Observação cadastrada com sucesso!' | 41 | + 'mensagem' => 'Observação cadastrada com sucesso!' |
| 42 | ); | 42 | ); |
| 43 | }catch (Exception $e){ | 43 | }catch (Exception $e){ |
| 44 | - return array( | ||
| 45 | - 'sucesso' => false, | ||
| 46 | - 'mensagem' => $e->getMessage(), | ||
| 47 | - 'exception' => $e | 44 | + $mensagem = $e->getMessage(); |
| 45 | + if($e instanceof InfraException){ | ||
| 46 | + if(!$e->getStrDescricao()){ | ||
| 47 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 48 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 49 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 50 | + }else{ | ||
| 51 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 52 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + }else{ | ||
| 56 | + $mensagem = $e->getStrDescricao(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + } | ||
| 60 | + return array ( | ||
| 61 | + "sucesso" => false, | ||
| 62 | + "mensagem" => $mensagem, | ||
| 63 | + "exception" => $e | ||
| 48 | ); | 64 | ); |
| 49 | } | 65 | } |
| 50 | } | 66 | } |
rn/MdWsSeiOrgaoRN.php
| @@ -10,7 +10,7 @@ class MdWsSeiOrgaoRN extends InfraRN { | @@ -10,7 +10,7 @@ class MdWsSeiOrgaoRN extends InfraRN { | ||
| 10 | /** | 10 | /** |
| 11 | * Retorna todos os orgaos ativos cadastrados | 11 | * Retorna todos os orgaos ativos cadastrados |
| 12 | * @param OrgaoDTO $orgaoDTO | 12 | * @param OrgaoDTO $orgaoDTO |
| 13 | - * @info para páginacao e necessário informar dentro do DTO os parametros abaixo: | 13 | + * @info para p�ginacao e necess�rio informar dentro do DTO os parametros abaixo: |
| 14 | * - setNumMaxRegistrosRetorno | 14 | * - setNumMaxRegistrosRetorno |
| 15 | * - setNumPaginaAtual | 15 | * - setNumPaginaAtual |
| 16 | * @return array | 16 | * @return array |
| @@ -48,10 +48,26 @@ class MdWsSeiOrgaoRN extends InfraRN { | @@ -48,10 +48,26 @@ class MdWsSeiOrgaoRN extends InfraRN { | ||
| 48 | 'total' => $orgaoDTO->getNumTotalRegistros() | 48 | 'total' => $orgaoDTO->getNumTotalRegistros() |
| 49 | ); | 49 | ); |
| 50 | }catch (Exception $e){ | 50 | }catch (Exception $e){ |
| 51 | - return array( | ||
| 52 | - 'sucesso' => false, | ||
| 53 | - 'mensagem' => $e->getMessage(), | ||
| 54 | - 'exception' => $e | 51 | + $mensagem = $e->getMessage(); |
| 52 | + if($e instanceof InfraException){ | ||
| 53 | + if(!$e->getStrDescricao()){ | ||
| 54 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 55 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 56 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 57 | + }else{ | ||
| 58 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 59 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + }else{ | ||
| 63 | + $mensagem = $e->getStrDescricao(); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + } | ||
| 67 | + return array ( | ||
| 68 | + "sucesso" => false, | ||
| 69 | + "mensagem" => $mensagem, | ||
| 70 | + "exception" => $e | ||
| 55 | ); | 71 | ); |
| 56 | } | 72 | } |
| 57 | } | 73 | } |
rn/MdWsSeiProcedimentoRN.php
| @@ -14,7 +14,7 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -14,7 +14,7 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 14 | protected function removerSobrestamentoProcessoControlado(ProcedimentoDTO $procedimentoDTOParam){ | 14 | protected function removerSobrestamentoProcessoControlado(ProcedimentoDTO $procedimentoDTOParam){ |
| 15 | try{ | 15 | try{ |
| 16 | if(!$procedimentoDTOParam->getDblIdProcedimento()){ | 16 | if(!$procedimentoDTOParam->getDblIdProcedimento()){ |
| 17 | - throw new InfraException('Procedimento não informado.'); | 17 | + throw new InfraException('Procedimento n�o informado.'); |
| 18 | } | 18 | } |
| 19 | $seiRN = new SeiRN(); | 19 | $seiRN = new SeiRN(); |
| 20 | $entradaRemoverSobrestamentoProcessoAPI = new EntradaRemoverSobrestamentoProcessoAPI(); | 20 | $entradaRemoverSobrestamentoProcessoAPI = new EntradaRemoverSobrestamentoProcessoAPI(); |
| @@ -27,10 +27,26 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -27,10 +27,26 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 27 | 'mensagem' => 'Sobrestar cancelado com sucesso.' | 27 | 'mensagem' => 'Sobrestar cancelado com sucesso.' |
| 28 | ); | 28 | ); |
| 29 | }catch (Exception $e){ | 29 | }catch (Exception $e){ |
| 30 | - return array( | ||
| 31 | - 'sucesso' => false, | ||
| 32 | - 'mensagem' => $e->getMessage(), | ||
| 33 | - 'exception' => $e | 30 | + $mensagem = $e->getMessage(); |
| 31 | + if($e instanceof InfraException){ | ||
| 32 | + if(!$e->getStrDescricao()){ | ||
| 33 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 34 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 35 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 36 | + }else{ | ||
| 37 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 38 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 39 | + } | ||
| 40 | + } | ||
| 41 | + }else{ | ||
| 42 | + $mensagem = $e->getStrDescricao(); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + } | ||
| 46 | + return array ( | ||
| 47 | + "sucesso" => false, | ||
| 48 | + "mensagem" => $mensagem, | ||
| 49 | + "exception" => $e | ||
| 34 | ); | 50 | ); |
| 35 | } | 51 | } |
| 36 | } | 52 | } |
| @@ -73,10 +89,26 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -73,10 +89,26 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 73 | 'total' => $mdWsSeiProtocoloDTOConsulta->getNumTotalRegistros() | 89 | 'total' => $mdWsSeiProtocoloDTOConsulta->getNumTotalRegistros() |
| 74 | ); | 90 | ); |
| 75 | }catch (Exception $e){ | 91 | }catch (Exception $e){ |
| 76 | - return array( | ||
| 77 | - 'sucesso' => false, | ||
| 78 | - 'mensagem' => $e->getMessage(), | ||
| 79 | - 'exception' => $e | 92 | + $mensagem = $e->getMessage(); |
| 93 | + if($e instanceof InfraException){ | ||
| 94 | + if(!$e->getStrDescricao()){ | ||
| 95 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 96 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 97 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 98 | + }else{ | ||
| 99 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 100 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + }else{ | ||
| 104 | + $mensagem = $e->getStrDescricao(); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + } | ||
| 108 | + return array ( | ||
| 109 | + "sucesso" => false, | ||
| 110 | + "mensagem" => $mensagem, | ||
| 111 | + "exception" => $e | ||
| 80 | ); | 112 | ); |
| 81 | } | 113 | } |
| 82 | } | 114 | } |
| @@ -101,7 +133,7 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -101,7 +133,7 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 101 | } | 133 | } |
| 102 | 134 | ||
| 103 | if(!$mdWsSeiProtocoloDTOConsulta->isSetNumIdUnidadeAtividade()){ | 135 | if(!$mdWsSeiProtocoloDTOConsulta->isSetNumIdUnidadeAtividade()){ |
| 104 | - throw new InfraException('É obrigatório informar a unidade.'); | 136 | + throw new InfraException('� obrigat�rio informar a unidade.'); |
| 105 | } | 137 | } |
| 106 | $mdWsSeiProtocoloDTO->setNumIdUnidadeAtividade($mdWsSeiProtocoloDTOConsulta->getNumIdUnidadeAtividade()); | 138 | $mdWsSeiProtocoloDTO->setNumIdUnidadeAtividade($mdWsSeiProtocoloDTOConsulta->getNumIdUnidadeAtividade()); |
| 107 | 139 | ||
| @@ -151,10 +183,26 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -151,10 +183,26 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 151 | 'total' => $mdWsSeiProtocoloDTO->getNumTotalRegistros() | 183 | 'total' => $mdWsSeiProtocoloDTO->getNumTotalRegistros() |
| 152 | ); | 184 | ); |
| 153 | }catch (Exception $e){ | 185 | }catch (Exception $e){ |
| 154 | - return array( | ||
| 155 | - 'sucesso' => false, | ||
| 156 | - 'mensagem' => $e->getMessage(), | ||
| 157 | - 'exception' => $e | 186 | + $mensagem = $e->getMessage(); |
| 187 | + if($e instanceof InfraException){ | ||
| 188 | + if(!$e->getStrDescricao()){ | ||
| 189 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 190 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 191 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 192 | + }else{ | ||
| 193 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 194 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 195 | + } | ||
| 196 | + } | ||
| 197 | + }else{ | ||
| 198 | + $mensagem = $e->getStrDescricao(); | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + } | ||
| 202 | + return array ( | ||
| 203 | + "sucesso" => false, | ||
| 204 | + "mensagem" => $mensagem, | ||
| 205 | + "exception" => $e | ||
| 158 | ); | 206 | ); |
| 159 | } | 207 | } |
| 160 | 208 | ||
| @@ -309,13 +357,29 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -309,13 +357,29 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 309 | 357 | ||
| 310 | return array( | 358 | return array( |
| 311 | 'sucesso' => true, | 359 | 'sucesso' => true, |
| 312 | - 'mensagem' => 'Ciência processo realizado com sucesso!' | 360 | + 'mensagem' => 'Ciência processo realizado com sucesso!' |
| 313 | ); | 361 | ); |
| 314 | }catch (Exception $e){ | 362 | }catch (Exception $e){ |
| 315 | - return array( | ||
| 316 | - 'sucesso' => false, | ||
| 317 | - 'mensagem' => $e->getMessage(), | ||
| 318 | - 'exception' => $e | 363 | + $mensagem = $e->getMessage(); |
| 364 | + if($e instanceof InfraException){ | ||
| 365 | + if(!$e->getStrDescricao()){ | ||
| 366 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 367 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 368 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 369 | + }else{ | ||
| 370 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 371 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 372 | + } | ||
| 373 | + } | ||
| 374 | + }else{ | ||
| 375 | + $mensagem = $e->getStrDescricao(); | ||
| 376 | + } | ||
| 377 | + | ||
| 378 | + } | ||
| 379 | + return array ( | ||
| 380 | + "sucesso" => false, | ||
| 381 | + "mensagem" => $mensagem, | ||
| 382 | + "exception" => $e | ||
| 319 | ); | 383 | ); |
| 320 | } | 384 | } |
| 321 | } | 385 | } |
| @@ -323,7 +387,7 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -323,7 +387,7 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 323 | /** | 387 | /** |
| 324 | * Metodo que conclui o procedimento/processo | 388 | * Metodo que conclui o procedimento/processo |
| 325 | * @param EntradaConcluirProcessoAPI $entradaConcluirProcessoAPI | 389 | * @param EntradaConcluirProcessoAPI $entradaConcluirProcessoAPI |
| 326 | - * @info ele recebe o número do ProtocoloProcedimentoFormatadoPesquisa da tabela protocolo | 390 | + * @info ele recebe o n�mero do ProtocoloProcedimentoFormatadoPesquisa da tabela protocolo |
| 327 | * @return array | 391 | * @return array |
| 328 | */ | 392 | */ |
| 329 | protected function concluirProcessoControlado(EntradaConcluirProcessoAPI $entradaConcluirProcessoAPI){ | 393 | protected function concluirProcessoControlado(EntradaConcluirProcessoAPI $entradaConcluirProcessoAPI){ |
| @@ -337,13 +401,29 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -337,13 +401,29 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 337 | 401 | ||
| 338 | return array( | 402 | return array( |
| 339 | 'sucesso' => true, | 403 | 'sucesso' => true, |
| 340 | - 'mensagem' => 'Processo concluído com sucesso!' | 404 | + 'mensagem' => 'Processo concluÃdo com sucesso!' |
| 341 | ); | 405 | ); |
| 342 | }catch (Exception $e){ | 406 | }catch (Exception $e){ |
| 343 | - return array( | ||
| 344 | - 'sucesso' => false, | ||
| 345 | - 'mensagem' => $e->getMessage(), | ||
| 346 | - 'exception' => $e | 407 | + $mensagem = $e->getMessage(); |
| 408 | + if($e instanceof InfraException){ | ||
| 409 | + if(!$e->getStrDescricao()){ | ||
| 410 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 411 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 412 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 413 | + }else{ | ||
| 414 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 415 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 416 | + } | ||
| 417 | + } | ||
| 418 | + }else{ | ||
| 419 | + $mensagem = $e->getStrDescricao(); | ||
| 420 | + } | ||
| 421 | + | ||
| 422 | + } | ||
| 423 | + return array ( | ||
| 424 | + "sucesso" => false, | ||
| 425 | + "mensagem" => $mensagem, | ||
| 426 | + "exception" => $e | ||
| 347 | ); | 427 | ); |
| 348 | } | 428 | } |
| 349 | } | 429 | } |
| @@ -352,7 +432,7 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -352,7 +432,7 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 352 | * Metodo que atribui o processo a uma pessoa | 432 | * Metodo que atribui o processo a uma pessoa |
| 353 | * @param EntradaAtribuirProcessoAPI $entradaAtribuirProcessoAPI | 433 | * @param EntradaAtribuirProcessoAPI $entradaAtribuirProcessoAPI |
| 354 | * @info Os parametros IdUsuario, ProtocoloProcedimento e SinReabrir sao obrigatorios. O parametro ProtocoloProcedimento | 434 | * @info Os parametros IdUsuario, ProtocoloProcedimento e SinReabrir sao obrigatorios. O parametro ProtocoloProcedimento |
| 355 | - * recebe o número do ProtocoloProcedimentoFormatadoPesquisa da tabela protocolo | 435 | + * recebe o n�mero do ProtocoloProcedimentoFormatadoPesquisa da tabela protocolo |
| 356 | * @return array | 436 | * @return array |
| 357 | */ | 437 | */ |
| 358 | protected function atribuirProcessoControlado(EntradaAtribuirProcessoAPI $entradaAtribuirProcessoAPI){ | 438 | protected function atribuirProcessoControlado(EntradaAtribuirProcessoAPI $entradaAtribuirProcessoAPI){ |
| @@ -361,7 +441,7 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -361,7 +441,7 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 361 | throw new InfraException('E obrigatorio informar o protocolo do processo!'); | 441 | throw new InfraException('E obrigatorio informar o protocolo do processo!'); |
| 362 | } | 442 | } |
| 363 | if(!$entradaAtribuirProcessoAPI->getIdUsuario()){ | 443 | if(!$entradaAtribuirProcessoAPI->getIdUsuario()){ |
| 364 | - throw new InfraException('E obrigatorio informar o usuário do processo!'); | 444 | + throw new InfraException('E obrigatorio informar o usu�rio do processo!'); |
| 365 | } | 445 | } |
| 366 | 446 | ||
| 367 | $objSeiRN = new SeiRN(); | 447 | $objSeiRN = new SeiRN(); |
| @@ -369,13 +449,29 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -369,13 +449,29 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 369 | 449 | ||
| 370 | return array( | 450 | return array( |
| 371 | 'sucesso' => true, | 451 | 'sucesso' => true, |
| 372 | - 'mensagem' => 'Processo atribuído com sucesso!' | 452 | + 'mensagem' => 'Processo atribuÃdo com sucesso!' |
| 373 | ); | 453 | ); |
| 374 | }catch (Exception $e){ | 454 | }catch (Exception $e){ |
| 375 | - return array( | ||
| 376 | - 'sucesso' => false, | ||
| 377 | - 'mensagem' => 'Nao foi possível atribuir o processo!', | ||
| 378 | - 'exception' => $e | 455 | + $mensagem = $e->getMessage(); |
| 456 | + if($e instanceof InfraException){ | ||
| 457 | + if(!$e->getStrDescricao()){ | ||
| 458 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 459 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 460 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 461 | + }else{ | ||
| 462 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 463 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 464 | + } | ||
| 465 | + } | ||
| 466 | + }else{ | ||
| 467 | + $mensagem = $e->getStrDescricao(); | ||
| 468 | + } | ||
| 469 | + | ||
| 470 | + } | ||
| 471 | + return array ( | ||
| 472 | + "sucesso" => false, | ||
| 473 | + "mensagem" => $mensagem, | ||
| 474 | + "exception" => $e | ||
| 379 | ); | 475 | ); |
| 380 | } | 476 | } |
| 381 | } | 477 | } |
| @@ -434,10 +530,26 @@ class MdWsSeiProcedimentoRN extends InfraRN { | @@ -434,10 +530,26 @@ class MdWsSeiProcedimentoRN extends InfraRN { | ||
| 434 | 'mensagem' => 'Processo enviado com sucesso!' | 530 | 'mensagem' => 'Processo enviado com sucesso!' |
| 435 | ); | 531 | ); |
| 436 | }catch (Exception $e){ | 532 | }catch (Exception $e){ |
| 437 | - return array( | ||
| 438 | - 'sucesso' => false, | ||
| 439 | - 'mensagem' => 'Nao foi possível enviar o processo!', | ||
| 440 | - 'exception' => $e | 533 | + $mensagem = $e->getMessage(); |
| 534 | + if($e instanceof InfraException){ | ||
| 535 | + if(!$e->getStrDescricao()){ | ||
| 536 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 537 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 538 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 539 | + }else{ | ||
| 540 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 541 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 542 | + } | ||
| 543 | + } | ||
| 544 | + }else{ | ||
| 545 | + $mensagem = $e->getStrDescricao(); | ||
| 546 | + } | ||
| 547 | + | ||
| 548 | + } | ||
| 549 | + return array ( | ||
| 550 | + "sucesso" => false, | ||
| 551 | + "mensagem" => $mensagem, | ||
| 552 | + "exception" => $e | ||
| 441 | ); | 553 | ); |
| 442 | } | 554 | } |
| 443 | } | 555 | } |
rn/MdWsSeiRetornoProgramadoRN.php
| @@ -46,10 +46,26 @@ class MdWsSeiRetornoProgramadoRN extends InfraRN { | @@ -46,10 +46,26 @@ class MdWsSeiRetornoProgramadoRN extends InfraRN { | ||
| 46 | 'mensagem' => 'Retorno Programado agendado com sucesso!' | 46 | 'mensagem' => 'Retorno Programado agendado com sucesso!' |
| 47 | ); | 47 | ); |
| 48 | }catch (Exception $e){ | 48 | }catch (Exception $e){ |
| 49 | - return array( | ||
| 50 | - 'sucesso' => false, | ||
| 51 | - 'mensagem' => $e->getMessage(), | ||
| 52 | - 'exception' => $e | 49 | + $mensagem = $e->getMessage(); |
| 50 | + if($e instanceof InfraException){ | ||
| 51 | + if(!$e->getStrDescricao()){ | ||
| 52 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 53 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 54 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 55 | + }else{ | ||
| 56 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 57 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + }else{ | ||
| 61 | + $mensagem = $e->getStrDescricao(); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + } | ||
| 65 | + return array ( | ||
| 66 | + "sucesso" => false, | ||
| 67 | + "mensagem" => $mensagem, | ||
| 68 | + "exception" => $e | ||
| 53 | ); | 69 | ); |
| 54 | } | 70 | } |
| 55 | } | 71 | } |
rn/MdWsSeiUnidadeRN.php
| @@ -32,10 +32,26 @@ class MdWsSeiUnidadeRN extends InfraRN { | @@ -32,10 +32,26 @@ class MdWsSeiUnidadeRN extends InfraRN { | ||
| 32 | 'data' => $result | 32 | 'data' => $result |
| 33 | ); | 33 | ); |
| 34 | }catch (Exception $e){ | 34 | }catch (Exception $e){ |
| 35 | - return array( | ||
| 36 | - 'sucesso' => false, | ||
| 37 | - 'mensagem' => $e->getMessage(), | ||
| 38 | - 'exception' => $e | 35 | + $mensagem = $e->getMessage(); |
| 36 | + if($e instanceof InfraException){ | ||
| 37 | + if(!$e->getStrDescricao()){ | ||
| 38 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 39 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 40 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 41 | + }else{ | ||
| 42 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 43 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + }else{ | ||
| 47 | + $mensagem = $e->getStrDescricao(); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + } | ||
| 51 | + return array ( | ||
| 52 | + "sucesso" => false, | ||
| 53 | + "mensagem" => $mensagem, | ||
| 54 | + "exception" => $e | ||
| 39 | ); | 55 | ); |
| 40 | } | 56 | } |
| 41 | } | 57 | } |
rn/MdWsSeiUsuarioRN.php
| @@ -10,7 +10,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -10,7 +10,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | - * Método que retorna o serviço SOAP do SIP | 13 | + * Metodo que retorna o servico SOAP do SIP |
| 14 | * @return SoapClient | 14 | * @return SoapClient |
| 15 | * @throws InfraException | 15 | * @throws InfraException |
| 16 | */ | 16 | */ |
| @@ -19,7 +19,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -19,7 +19,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 19 | try{ | 19 | try{ |
| 20 | if (!InfraUtil::isBolUrlValida($strWSDL)){ | 20 | if (!InfraUtil::isBolUrlValida($strWSDL)){ |
| 21 | if(!@file_get_contents($strWSDL)) { | 21 | if(!@file_get_contents($strWSDL)) { |
| 22 | - throw new InfraException('Arquivo WSDL '.$strWSDL.' n?o encontrado.'); | 22 | + throw new InfraException('Arquivo WSDL '.$strWSDL.' nao encontrado.'); |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| 25 | }catch(Exception $e){ | 25 | }catch(Exception $e){ |
| @@ -27,7 +27,13 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -27,7 +27,13 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | try{ | 29 | try{ |
| 30 | - $objSipWS = new SoapClient($strWSDL, array('encoding'=>'ISO-8859-1')); | 30 | + $objSipWS = new SoapClient( |
| 31 | + $strWSDL, | ||
| 32 | + array( | ||
| 33 | + 'encoding' => 'ISO-8859-1', | ||
| 34 | + 'exceptions' => true | ||
| 35 | + ) | ||
| 36 | + ); | ||
| 31 | return $objSipWS; | 37 | return $objSipWS; |
| 32 | }catch(Exception $e){ | 38 | }catch(Exception $e){ |
| 33 | throw new InfraException('Erro acessando o Sistema de Permissões.'); | 39 | throw new InfraException('Erro acessando o Sistema de Permissões.'); |
| @@ -35,7 +41,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -35,7 +41,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 35 | } | 41 | } |
| 36 | 42 | ||
| 37 | /** | 43 | /** |
| 38 | - * Método que descriptografa o token | 44 | + * M?todo que descriptografa o token |
| 39 | * @param $token | 45 | * @param $token |
| 40 | * @return string | 46 | * @return string |
| 41 | */ | 47 | */ |
| @@ -54,7 +60,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -54,7 +60,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 54 | } | 60 | } |
| 55 | 61 | ||
| 56 | /** | 62 | /** |
| 57 | - * Método que criptografa o token | 63 | + * M?todo que criptografa o token |
| 58 | * @param $sigla | 64 | * @param $sigla |
| 59 | * @param $senha | 65 | * @param $senha |
| 60 | * @return string | 66 | * @return string |
| @@ -77,7 +83,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -77,7 +83,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 77 | } | 83 | } |
| 78 | 84 | ||
| 79 | /** | 85 | /** |
| 80 | - * Go horse para autenticar usuário... Não ha como instanciar o SessaoSEI por metodos convencionais. | 86 | + * Go horse para autenticar usuario... Nao ha como instanciar o SessaoSEI por metodos convencionais. |
| 81 | * @param stdClass $loginData | 87 | * @param stdClass $loginData |
| 82 | */ | 88 | */ |
| 83 | private function setaVariaveisAutenticacao(stdClass $loginData){ | 89 | private function setaVariaveisAutenticacao(stdClass $loginData){ |
| @@ -90,7 +96,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -90,7 +96,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 90 | } | 96 | } |
| 91 | 97 | ||
| 92 | /** | 98 | /** |
| 93 | - * Método que autentica o usuário pelo token | 99 | + * Metodo que autentica o usuario pelo token |
| 94 | * @param $token | 100 | * @param $token |
| 95 | * @return bool | 101 | * @return bool |
| 96 | * @throws InfraException | 102 | * @throws InfraException |
| @@ -100,7 +106,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -100,7 +106,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 100 | 106 | ||
| 101 | $tokenData = $this->tokenDecode($token); | 107 | $tokenData = $this->tokenDecode($token); |
| 102 | if(!$tokenData){ | 108 | if(!$tokenData){ |
| 103 | - throw new InfraException('Token inválido!'); | 109 | + throw new InfraException('Token inv?lido!'); |
| 104 | } | 110 | } |
| 105 | 111 | ||
| 106 | $usuarioDTO = new UsuarioDTO(); | 112 | $usuarioDTO = new UsuarioDTO(); |
| @@ -114,16 +120,32 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -114,16 +120,32 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 114 | 120 | ||
| 115 | return $result; | 121 | return $result; |
| 116 | }catch (Exception $e){ | 122 | }catch (Exception $e){ |
| 117 | - return array( | ||
| 118 | - 'sucesso' => false, | ||
| 119 | - 'mensagem' => $e->getMessage(), | ||
| 120 | - 'exception' => $e | 123 | + $mensagem = $e->getMessage(); |
| 124 | + if($e instanceof InfraException){ | ||
| 125 | + if(!$e->getStrDescricao()){ | ||
| 126 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 127 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 128 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 129 | + }else{ | ||
| 130 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 131 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + }else{ | ||
| 135 | + $mensagem = $e->getStrDescricao(); | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + } | ||
| 139 | + return array ( | ||
| 140 | + "sucesso" => false, | ||
| 141 | + "mensagem" => $mensagem, | ||
| 142 | + "exception" => $e | ||
| 121 | ); | 143 | ); |
| 122 | } | 144 | } |
| 123 | } | 145 | } |
| 124 | 146 | ||
| 125 | /** | 147 | /** |
| 126 | - * MÈtodo de autenticação de usuários usando SIP | 148 | + * Metodo de autenticacao de usuarios usando SIP |
| 127 | * @param UsuarioDTO | 149 | * @param UsuarioDTO |
| 128 | * @param $sigla | 150 | * @param $sigla |
| 129 | * @param $senha | 151 | * @param $senha |
| @@ -145,7 +167,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -145,7 +167,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 145 | $usuarioDTO->setNumIdOrgao($orgaoCarregdo->getNumIdOrgao()); | 167 | $usuarioDTO->setNumIdOrgao($orgaoCarregdo->getNumIdOrgao()); |
| 146 | } | 168 | } |
| 147 | $objSipWs = $this->retornaServicoSip(); | 169 | $objSipWs = $this->retornaServicoSip(); |
| 148 | - $ret = $objSipWs->autenticar( | 170 | + $ret = $objSipWs->autenticarCompleto( |
| 149 | $usuarioDTO->getNumIdOrgao(), | 171 | $usuarioDTO->getNumIdOrgao(), |
| 150 | null, | 172 | null, |
| 151 | $usuarioDTO->getStrSigla(), | 173 | $usuarioDTO->getStrSigla(), |
| @@ -153,6 +175,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -153,6 +175,7 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 153 | ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaSistema'), | 175 | ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaSistema'), |
| 154 | ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaOrgaoSistema') | 176 | ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaOrgaoSistema') |
| 155 | ); | 177 | ); |
| 178 | + | ||
| 156 | if(!$ret){ | 179 | if(!$ret){ |
| 157 | throw new InfraException('Usuário ou senha inválido!'); | 180 | throw new InfraException('Usuário ou senha inválido!'); |
| 158 | } | 181 | } |
| @@ -162,17 +185,33 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -162,17 +185,33 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 162 | 'token' => $this->tokenEncode($usuarioDTO->getStrSigla(), $usuarioDTO->getStrSenha()) | 185 | 'token' => $this->tokenEncode($usuarioDTO->getStrSigla(), $usuarioDTO->getStrSenha()) |
| 163 | ); | 186 | ); |
| 164 | }catch (Exception $e){ | 187 | }catch (Exception $e){ |
| 165 | - return array( | ||
| 166 | - 'sucesso' => false, | ||
| 167 | - 'mensagem' => $e->getMessage(), | ||
| 168 | - 'exception' => $e | 188 | + $mensagem = $e->getMessage(); |
| 189 | + if($e instanceof InfraException){ | ||
| 190 | + if(!$e->getStrDescricao()){ | ||
| 191 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 192 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 193 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 194 | + }else{ | ||
| 195 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 196 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + }else{ | ||
| 200 | + $mensagem = $e->getStrDescricao(); | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + } | ||
| 204 | + return array ( | ||
| 205 | + "sucesso" => false, | ||
| 206 | + "mensagem" => $mensagem, | ||
| 207 | + "exception" => $e | ||
| 169 | ); | 208 | ); |
| 170 | } | 209 | } |
| 171 | 210 | ||
| 172 | } | 211 | } |
| 173 | 212 | ||
| 174 | /** | 213 | /** |
| 175 | - * Retorna a lista de usuários por unidade | 214 | + * Retorna a lista de usuarios por unidade |
| 176 | * @param UsuarioDTO | 215 | * @param UsuarioDTO |
| 177 | * @param $idUsuario | 216 | * @param $idUsuario |
| 178 | */ | 217 | */ |
| @@ -186,11 +225,27 @@ class MdWsSeiUsuarioRN extends InfraRN { | @@ -186,11 +225,27 @@ class MdWsSeiUsuarioRN extends InfraRN { | ||
| 186 | 'sucesso' => true, | 225 | 'sucesso' => true, |
| 187 | 'data' => $result | 226 | 'data' => $result |
| 188 | ); | 227 | ); |
| 189 | - }catch(Exception $e){ | ||
| 190 | - return array( | ||
| 191 | - 'sucesso' => false, | ||
| 192 | - 'mensagem' => 'Erro no serviço de listagem de usuários.', | ||
| 193 | - 'exception' => $e | 228 | + }catch (Exception $e){ |
| 229 | + $mensagem = $e->getMessage(); | ||
| 230 | + if($e instanceof InfraException){ | ||
| 231 | + if(!$e->getStrDescricao()){ | ||
| 232 | + /** @var InfraValidacaoDTO $validacaoDTO */ | ||
| 233 | + if(count($e->getArrObjInfraValidacao()) == 1){ | ||
| 234 | + $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | ||
| 235 | + }else{ | ||
| 236 | + foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | ||
| 237 | + $mensagem[] = $validacaoDTO->getStrDescricao(); | ||
| 238 | + } | ||
| 239 | + } | ||
| 240 | + }else{ | ||
| 241 | + $mensagem = $e->getStrDescricao(); | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + } | ||
| 245 | + return array ( | ||
| 246 | + "sucesso" => false, | ||
| 247 | + "mensagem" => $mensagem, | ||
| 248 | + "exception" => $e | ||
| 194 | ); | 249 | ); |
| 195 | } | 250 | } |
| 196 | } | 251 | } |