use of com.crivano.swaggerservlet.SwaggerCallParameters in project balcaovirtual by trf2-jus-br.
the class AvisoConfirmadoContarGet method run.
@Override
public void run(Request req, Response resp, BalcaojusContext ctx) throws Exception {
Map<String, Object> jwt = AutenticarPost.assertUsuarioAutorizado();
Map<String, SwaggerCallParameters> mapp = new HashMap<>();
for (String system : Utils.getSystems()) {
mapp.put(system, new SwaggerCallParameters(system + " - obter quantidade de avisos confirmado", Utils.getApiPassword(system), "GET", Utils.getApiUrl(system) + "/usuario/" + jwt.get("username") + "/aviso-confirmado/contar?dias=100", null, IUsuarioUsernameAvisoConfirmadoContarGet.Response.class));
}
SwaggerMultipleCallResult mcr = SwaggerCall.callMultiple(mapp, BalcaojusServlet.TIMEOUT_MILLISECONDS);
resp.status = Utils.getStatus(mcr);
resp.list = new ArrayList<>();
for (String system : mcr.responses.keySet()) {
IUsuarioUsernameAvisoConfirmadoContarGet.Response r = (IUsuarioUsernameAvisoConfirmadoContarGet.Response) mcr.responses.get(system);
if (r.list != null)
for (QuantidadeConfirmada i : r.list) {
QuantidadeConfirmadaPorData t = new QuantidadeConfirmadaPorData();
t.data = i.data;
t.quantidadedousuarioporconfirmacao = i.quantidadeDoUsuarioPorConfirmacao;
t.quantidadedousuarioporomissao = i.quantidadeDoUsuarioPorOmissao;
t.quantidadedogrupoporconfirmacao = i.quantidadeDoGrupoPorConfirmacao;
t.quantidadedogrupoporomissao = i.quantidadeDoGrupoPorOmissao;
resp.list.add(t);
}
}
}
use of com.crivano.swaggerservlet.SwaggerCallParameters in project balcaovirtual by trf2-jus-br.
the class AvisoConfirmadoListarGet method run.
@Override
public void run(Request req, Response resp, BalcaojusContext ctx) throws Exception {
Map<String, Object> jwt = AutenticarPost.assertUsuarioAutorizado();
Date dtFim = Utils.parsearData(req.datafinal);
Date dtFimPlus1 = new Date(dtFim.getTime() + (1000 * 60 * 60 * 24));
String datafinal = Utils.formatarData(dtFimPlus1);
Map<String, SwaggerCallParameters> mapp = new HashMap<>();
for (String system : Utils.getSystems()) {
mapp.put(system, new SwaggerCallParameters(system + " - obter quantidade de avisos confirmado", Utils.getApiPassword(system), "GET", Utils.getApiUrl(system) + "/usuario/" + jwt.get("username") + "/aviso-confirmado/listar?dataInicial=" + req.datainicial + "&dataFinal=" + datafinal + "&confirmacao=" + req.confirmacao.toString() + "&omissao=" + req.omissao.toString() + "&grupo=" + req.grupo.toString(), null, IUsuarioUsernameAvisoConfirmadoListarGet.Response.class));
}
SwaggerMultipleCallResult mcr = SwaggerCall.callMultiple(mapp, BalcaojusServlet.TIMEOUT_MILLISECONDS);
resp.status = Utils.getStatus(mcr);
resp.list = new ArrayList<>();
resp.status = new ArrayList<>();
for (String system : mcr.responses.keySet()) {
IUsuarioUsernameAvisoConfirmadoListarGet.Response r = (IUsuarioUsernameAvisoConfirmadoListarGet.Response) mcr.responses.get(system);
if (r.list != null)
for (br.jus.trf2.sistemaprocessual.ISistemaProcessual.Aviso ra : r.list) {
Aviso a = new Aviso();
a.idaviso = ra.idAviso;
a.dataaviso = ra.dataAviso;
a.tipo = ra.tipo;
a.processo = ra.processo;
a.unidade = ra.unidade;
a.unidadetipo = ra.unidadeTipo;
a.sistema = system;
a.localidade = ra.localidade;
a.eventointimacao = ra.eventoIntimacao;
a.motivointimacao = ra.motivoIntimacao;
a.numeroprazo = ra.numeroPrazo;
a.tipoprazo = ra.tipoPrazo;
a.multiplicadorprazo = ra.multiplicadorPrazo;
a.datalimiteintimacaoautomatica = ra.dataLimiteIntimacaoAutomatica;
a.assunto = ra.assunto;
a.dataconfirmacao = Utils.parsearDataHoraMinutoSegundo(ra.dataConfirmacao);
a.usuarioconfirmacao = ra.usuarioConfirmacao;
a.teor = ra.teor;
resp.list.add(a);
}
}
}
use of com.crivano.swaggerservlet.SwaggerCallParameters in project balcaovirtual by trf2-jus-br.
the class ConfigEntidadesGet method run.
@Override
public void run(Request req, Response resp, BalcaojusContext ctx) throws Exception {
Map<String, SwaggerCallParameters> mapp = new HashMap<>();
for (String system : Utils.getSystems()) {
mapp.put(system, new SwaggerCallParameters(system + " - obter localidades", Utils.getApiPassword(system), "GET", Utils.getApiUrl(system) + "/orgao-publico/listar?tipodedocumento=cnpj", null, IAdvogadoDocumentoGet.Response.class));
}
SwaggerMultipleCallResult mcr = SwaggerCall.callMultiple(mapp, BalcaojusServlet.TIMEOUT_MILLISECONDS);
resp.status = Utils.getStatus(mcr);
resp.list = new ArrayList<>();
for (String system : mcr.responses.keySet()) {
IAdvogadoDocumentoGet.Response r = (IAdvogadoDocumentoGet.Response) mcr.responses.get(system);
if (r.list != null)
for (Pessoa p : r.list) {
Entidade o = new Entidade();
o.sistema = system;
o.id = p.id;
o.nome = p.nome;
o.documento = p.documento;
o.tipodedocumento = p.tipodedocumento;
resp.list.add(o);
}
}
}
use of com.crivano.swaggerservlet.SwaggerCallParameters in project balcaovirtual by trf2-jus-br.
the class PeticaoIntercorrenteListarGet method run.
@Override
public void run(Request req, Response resp, BalcaojusContext ctx) throws Exception {
Usuario u = BalcaojusServlet.getPrincipal();
Map<String, SwaggerCallParameters> mapp = new HashMap<>();
IUsuarioUsernamePeticaoIntercorrenteListarGet.Request q = new IUsuarioUsernamePeticaoIntercorrenteListarGet.Request();
q.data = req.data;
for (String system : Utils.getSystems()) {
mapp.put(system, new SwaggerCallParameters(system + " - obter resumos de petições intercorrentes", Utils.getApiPassword(system), "GET", Utils.getApiUrl(system) + "/usuario/" + u.usuario + "/peticao-intercorrente/listar", q, IUsuarioUsernamePeticaoIntercorrenteListarGet.Response.class));
}
SwaggerMultipleCallResult mcr = SwaggerCall.callMultiple(mapp, BalcaojusServlet.TIMEOUT_MILLISECONDS);
resp.status = Utils.getStatus(mcr);
resp.list = new ArrayList<>();
for (String system : mcr.responses.keySet()) {
IUsuarioUsernamePeticaoIntercorrenteListarGet.Response r = (IUsuarioUsernamePeticaoIntercorrenteListarGet.Response) mcr.responses.get(system);
if (r.list != null)
for (PeticaoIntercorrente i : r.list) {
PeticaoIntercorrenteResumo t = new PeticaoIntercorrenteResumo();
t.processo = i.processo;
t.protocolo = i.protocolo;
t.dataprotocolo = i.dataprotocolo;
t.classe = i.classe;
t.sistema = system;
t.unidade = i.unidade;
resp.list.add(t);
}
}
}
use of com.crivano.swaggerservlet.SwaggerCallParameters in project balcaovirtual by trf2-jus-br.
the class TrocarSenhaPost method run.
@Override
public void run(Request req, Response resp, BalcaojusContext ctx) throws Exception {
// Chama o método de autenticação
AutenticarPost auth = new AutenticarPost();
AutenticarPost.Request authReq = new AutenticarPost.Request();
AutenticarPost.Response authResp = new AutenticarPost.Response();
authReq.username = req.username;
authReq.password = req.password;
auth.run(authReq, authResp, ctx);
// Read list from connected systems
String[] systems = Utils.getSystems();
if (systems == null)
return;
String authorization = "Basic " + SwaggerUtils.base64Encode((req.username + ":" + req.newpassword).getBytes());
Map<String, SwaggerCallParameters> mapp = new HashMap<>();
for (ListStatus authStatus : authResp.status) {
String system = authStatus.system;
if (authStatus.errormsg != null || !system.contains(".apolo"))
continue;
String urlsys = Utils.getApiUrl(system);
IUsuarioUsernameTrocarSenhaPost.Request q = new IUsuarioUsernameTrocarSenhaPost.Request();
q.username = req.username;
mapp.put(system, new SwaggerCallParameters(system + "-trocar-senha-usuário", authorization, "POST", urlsys + "/usuario/" + req.username + "/trocar-senha", q, IUsuarioUsernameTrocarSenhaPost.Response.class));
}
/* Chama a troca de senha separadamente para evitar o bloqueio na sincronização das senhas*/
SwaggerMultipleCallResult mcr = new SwaggerMultipleCallResult();
Map<String, SwaggerCallParameters> mapAux = new HashMap<>();
SwaggerMultipleCallResult mcrAux;
for (String system : mapp.keySet()) {
SwaggerCallParameters scp = mapp.get(system);
mapAux.put(system, scp);
mcrAux = SwaggerCall.callMultiple(mapAux, BalcaojusServlet.TIMEOUT_MILLISECONDS);
mcr.responses.putAll(mcrAux.responses);
mcr.status.addAll(mcrAux.status);
mapAux.remove(system);
}
// faz a autenticação com a nova senha para obter o token
AutenticarPost auth2 = new AutenticarPost();
AutenticarPost.Request authReq2 = new AutenticarPost.Request();
AutenticarPost.Response authResp2 = new AutenticarPost.Response();
authReq2.username = req.username;
authReq2.password = req.newpassword;
auth2.run(authReq2, authResp2, ctx);
resp.status = Utils.getStatus(mcr);
resp.id_token = authResp2.id_token;
}
Aggregations