Search in sources :

Example 1 with ResourceAccessException

use of org.springframework.web.client.ResourceAccessException in project spring-security-oauth by spring-projects.

the class AbstractAuthorizationCodeProviderTests method setupAccessTokenProvider.

@BeforeOAuth2Context
public void setupAccessTokenProvider() {
    accessTokenProvider = new AuthorizationCodeAccessTokenProvider() {

        private ResponseExtractor<OAuth2AccessToken> extractor = super.getResponseExtractor();

        private ResponseExtractor<ResponseEntity<Void>> authExtractor = super.getAuthorizationResponseExtractor();

        private ResponseErrorHandler errorHandler = super.getResponseErrorHandler();

        @Override
        protected ResponseErrorHandler getResponseErrorHandler() {
            return new DefaultResponseErrorHandler() {

                public void handleError(ClientHttpResponse response) throws IOException {
                    response.getHeaders();
                    response.getStatusCode();
                    tokenEndpointResponse = response;
                    errorHandler.handleError(response);
                }
            };
        }

        @Override
        protected ResponseExtractor<OAuth2AccessToken> getResponseExtractor() {
            return new ResponseExtractor<OAuth2AccessToken>() {

                public OAuth2AccessToken extractData(ClientHttpResponse response) throws IOException {
                    try {
                        response.getHeaders();
                        response.getStatusCode();
                        tokenEndpointResponse = response;
                        return extractor.extractData(response);
                    } catch (ResourceAccessException e) {
                        return null;
                    }
                }
            };
        }

        @Override
        protected ResponseExtractor<ResponseEntity<Void>> getAuthorizationResponseExtractor() {
            return new ResponseExtractor<ResponseEntity<Void>>() {

                public ResponseEntity<Void> extractData(ClientHttpResponse response) throws IOException {
                    response.getHeaders();
                    response.getStatusCode();
                    tokenEndpointResponse = response;
                    return authExtractor.extractData(response);
                }
            };
        }
    };
    context.setAccessTokenProvider(accessTokenProvider);
}
Also used : DefaultResponseErrorHandler(org.springframework.web.client.DefaultResponseErrorHandler) DefaultResponseErrorHandler(org.springframework.web.client.DefaultResponseErrorHandler) ResponseErrorHandler(org.springframework.web.client.ResponseErrorHandler) ResponseExtractor(org.springframework.web.client.ResponseExtractor) IOException(java.io.IOException) ResourceAccessException(org.springframework.web.client.ResourceAccessException) ResponseEntity(org.springframework.http.ResponseEntity) OAuth2AccessToken(org.springframework.security.oauth2.common.OAuth2AccessToken) AuthorizationCodeAccessTokenProvider(org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider) ClientHttpResponse(org.springframework.http.client.ClientHttpResponse) BeforeOAuth2Context(org.springframework.security.oauth2.client.test.BeforeOAuth2Context)

Example 2 with ResourceAccessException

use of org.springframework.web.client.ResourceAccessException in project sic by belluccifranco.

the class BuscarClientesGUI method buscar.

private void buscar() {
    try {
        clientes = new ArrayList(Arrays.asList(RestClient.getRestTemplate().getForObject("/clientes/busqueda/criteria?" + "&razonSocial=" + txt_TextoBusqueda.getText().trim() + "&nombreFantasia=" + txt_TextoBusqueda.getText().trim() + "&idFiscal=" + txt_TextoBusqueda.getText().trim() + "&idEmpresa=" + EmpresaActiva.getInstance().getEmpresa().getId_Empresa(), Cliente[].class)));
        this.cargarResultadosAlTable();
    } catch (RestClientResponseException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (ResourceAccessException ex) {
        LOGGER.error(ex.getMessage());
        JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : ArrayList(java.util.ArrayList) RestClientResponseException(org.springframework.web.client.RestClientResponseException) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 3 with ResourceAccessException

use of org.springframework.web.client.ResourceAccessException in project sic by belluccifranco.

the class DetalleCondicionIvaGUI method btn_AgregarActionPerformed.

//GEN-LAST:event_lst_CondicionesValueChanged
private void btn_AgregarActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_btn_AgregarActionPerformed
    CondicionIVA condicionIVA = new CondicionIVA();
    condicionIVA.setNombre(txt_Nombre.getText().trim());
    condicionIVA.setDiscriminaIVA(chk_DiscriminaIVA.isSelected());
    try {
        RestClient.getRestTemplate().postForObject("/condiciones-iva", condicionIVA, CondicionIVA.class);
        LOGGER.warn("La condicion de IVA " + txt_Nombre.getText().trim() + " se guardó correctamente.");
        this.limpiarYRecargarComponentes();
    } catch (RestClientResponseException ex) {
        JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (ResourceAccessException ex) {
        LOGGER.error(ex.getMessage());
        JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : CondicionIVA(sic.modelo.CondicionIVA) RestClientResponseException(org.springframework.web.client.RestClientResponseException) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 4 with ResourceAccessException

use of org.springframework.web.client.ResourceAccessException in project sic by belluccifranco.

the class CajaGUI method lanzarReporteFacturaVenta.

private void lanzarReporteFacturaVenta(Factura facturaVenta) {
    if (Desktop.isDesktopSupported()) {
        try {
            byte[] reporte = RestClient.getRestTemplate().getForObject("/facturas/" + facturaVenta.getId_Factura() + "/reporte", byte[].class);
            File f = new File(System.getProperty("user.home") + "/Factura.pdf");
            Files.write(f.toPath(), reporte);
            Desktop.getDesktop().open(f);
        } catch (IOException ex) {
            LOGGER.error(ex.getMessage());
            JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_IOException"), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (RestClientResponseException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (ResourceAccessException ex) {
            LOGGER.error(ex.getMessage());
            JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
        }
    } else {
        JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_plataforma_no_soportada"), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : IOException(java.io.IOException) RestClientResponseException(org.springframework.web.client.RestClientResponseException) File(java.io.File) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Example 5 with ResourceAccessException

use of org.springframework.web.client.ResourceAccessException in project sic by belluccifranco.

the class CerrarVentaGUI method lanzarReporteFactura.

private void lanzarReporteFactura(Factura factura, String nombreReporte) {
    if (Desktop.isDesktopSupported()) {
        try {
            byte[] reporte = RestClient.getRestTemplate().getForObject("/facturas/" + factura.getId_Factura() + "/reporte", byte[].class);
            File f = new File(System.getProperty("user.home") + "/" + nombreReporte + ".pdf");
            Files.write(f.toPath(), reporte);
            Desktop.getDesktop().open(f);
        } catch (IOException ex) {
            LOGGER.error(ex.getMessage());
            JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_IOException"), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (RestClientResponseException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        } catch (ResourceAccessException ex) {
            LOGGER.error(ex.getMessage());
            JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_conexion"), "Error", JOptionPane.ERROR_MESSAGE);
        }
    } else {
        JOptionPane.showMessageDialog(this, ResourceBundle.getBundle("Mensajes").getString("mensaje_error_plataforma_no_soportada"), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : IOException(java.io.IOException) RestClientResponseException(org.springframework.web.client.RestClientResponseException) File(java.io.File) ResourceAccessException(org.springframework.web.client.ResourceAccessException)

Aggregations

ResourceAccessException (org.springframework.web.client.ResourceAccessException)75 RestClientResponseException (org.springframework.web.client.RestClientResponseException)68 ArrayList (java.util.ArrayList)22 Point (java.awt.Point)9 Pais (sic.modelo.Pais)9 Provincia (sic.modelo.Provincia)9 RenglonFactura (sic.modelo.RenglonFactura)9 IOException (java.io.IOException)8 EstadoPedido (sic.modelo.EstadoPedido)8 Localidad (sic.modelo.Localidad)8 Pedido (sic.modelo.Pedido)8 RenglonPedido (sic.modelo.RenglonPedido)8 FormaDePago (sic.modelo.FormaDePago)6 File (java.io.File)5 Proveedor (sic.modelo.Proveedor)5 List (java.util.List)4 ExecutionException (java.util.concurrent.ExecutionException)4 SwingWorker (javax.swing.SwingWorker)4 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)4 HttpServerErrorException (org.springframework.web.client.HttpServerErrorException)4