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);
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations