Search in sources :

Example 1 with FetchResponse

use of br.jus.trf2.balcaojus.CertidaoEmitirRequisitanteCpfcnpjPost.FetchResponse in project balcaovirtual by trf2-jus-br.

the class CertidaoReimprimirNumeroCpfcnpjGet method run.

@Override
public void run(Request req, Response resp, BalcaojusContext ctx) throws Exception {
    if (!CertidaoObterTokenGet.isValidToken(req.token, req.numero, null, req.cpfcnpj))
        throw new PresentableException("Token inválido");
    FetchResponse r = CertidaoEmitirRequisitanteCpfcnpjPost.fetch(Utils.getCertApiUrl(req.sistema) + "/bv_cons_cert_lib.asp", Utils.getCertApiPassword(req.sistema), "POST", "Botao=Emitir&NumProt=" + req.numero + "&NumDocPess=" + req.cpfcnpj);
    if (r.headerFields.containsKey(Utils.ERROR_MESSAGE))
        throw new PresentableUnloggedException(r.headerFields.get(Utils.ERROR_MESSAGE).get(0));
    resp.html = r.html;
    if (r.headerFields.containsKey(Utils.RESULT_KIND)) {
        resp.tipo = r.headerFields.get(Utils.RESULT_KIND).get(0);
        resp.html = Utils.obterHtml(resp.html, resp.tipo);
    }
    if (r.headerFields.containsKey(Utils.CERT_NUMBER))
        resp.numero = r.headerFields.get(Utils.CERT_NUMBER).get(0);
}
Also used : PresentableUnloggedException(com.crivano.swaggerservlet.PresentableUnloggedException) PresentableException(com.crivano.swaggerservlet.PresentableException) FetchResponse(br.jus.trf2.balcaojus.CertidaoEmitirRequisitanteCpfcnpjPost.FetchResponse)

Example 2 with FetchResponse

use of br.jus.trf2.balcaojus.CertidaoEmitirRequisitanteCpfcnpjPost.FetchResponse in project balcaovirtual by trf2-jus-br.

the class CertidaoAutenticarNumeroCpfcnpjGet method run.

@Override
public void run(Request req, Response resp, BalcaojusContext ctx) throws Exception {
    if (!CertidaoObterTokenGet.isValidToken(req.token, req.numero, null, req.cpfcnpj))
        throw new PresentableException("Token inválido");
    FetchResponse r = CertidaoEmitirRequisitanteCpfcnpjPost.fetch(Utils.getCertApiUrl(req.sistema) + "/bv_consul_cert_neg.asp", Utils.getCertApiPassword(req.sistema), "POST", "Botao=Consultar&NumProt=" + req.numero + "&NumDocPess=" + req.cpfcnpj);
    if (r.headerFields.containsKey(Utils.ERROR_MESSAGE))
        throw new PresentableUnloggedException(r.headerFields.get(Utils.ERROR_MESSAGE).get(0));
    resp.html = r.html;
    if (r.headerFields.containsKey(Utils.RESULT_KIND)) {
        resp.tipo = r.headerFields.get(Utils.RESULT_KIND).get(0);
        resp.html = Utils.obterHtml(resp.html, resp.tipo);
    }
    if (r.headerFields.containsKey(Utils.CERT_NUMBER))
        resp.numero = r.headerFields.get(Utils.CERT_NUMBER).get(0);
}
Also used : PresentableUnloggedException(com.crivano.swaggerservlet.PresentableUnloggedException) PresentableException(com.crivano.swaggerservlet.PresentableException) FetchResponse(br.jus.trf2.balcaojus.CertidaoEmitirRequisitanteCpfcnpjPost.FetchResponse)

Example 3 with FetchResponse

use of br.jus.trf2.balcaojus.CertidaoEmitirRequisitanteCpfcnpjPost.FetchResponse in project balcaovirtual by trf2-jus-br.

the class CertidaoRequererRequisitanteCpfcnpjPost method run.

@Override
public void run(Request req, Response resp, BalcaojusContext ctx) throws Exception {
    if (!CertidaoObterTokenGet.isValidToken(req.token, null, req.requisitante, req.cpfcnpj))
        throw new PresentableException("Token inválido");
    FetchResponse r = CertidaoEmitirRequisitanteCpfcnpjPost.fetch(Utils.getCertApiUrl(req.sistema) + "/bv_conf_req_cert.asp", Utils.getCertApiPassword(req.sistema), "POST", "Botao=Requerer&NumDocPessReq=" + req.requisitante + "&NumDoc=" + req.cpfcnpj + "&Nome=" + URLEncoder.encode(req.nome, "ISO-8859-1"));
    if (r.headerFields.containsKey(Utils.ERROR_MESSAGE))
        throw new PresentableUnloggedException(r.headerFields.get(Utils.ERROR_MESSAGE).get(0));
    resp.html = r.html;
    if (r.headerFields.containsKey(Utils.RESULT_KIND)) {
        resp.tipo = r.headerFields.get(Utils.RESULT_KIND).get(0);
        resp.html = Utils.obterHtml(resp.html, resp.tipo);
    }
    if (r.headerFields.containsKey(Utils.CERT_NUMBER))
        resp.numero = r.headerFields.get(Utils.CERT_NUMBER).get(0);
}
Also used : PresentableUnloggedException(com.crivano.swaggerservlet.PresentableUnloggedException) PresentableException(com.crivano.swaggerservlet.PresentableException) FetchResponse(br.jus.trf2.balcaojus.CertidaoEmitirRequisitanteCpfcnpjPost.FetchResponse)

Aggregations

FetchResponse (br.jus.trf2.balcaojus.CertidaoEmitirRequisitanteCpfcnpjPost.FetchResponse)3 PresentableException (com.crivano.swaggerservlet.PresentableException)3 PresentableUnloggedException (com.crivano.swaggerservlet.PresentableUnloggedException)3