use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.
the class FormasDePagoGUI method agregarFormaDePago.
private void agregarFormaDePago() {
try {
FormaDePago formaDePago = new FormaDePago();
formaDePago.setNombre(txt_Nombre.getText().trim());
formaDePago.setAfectaCaja(chk_AfectaCaja.isSelected());
formaDePago.setEmpresa(EmpresaActiva.getInstance().getEmpresa());
RestClient.getRestTemplate().postForObject("/formas-de-pago", formaDePago, FormaDePago.class);
txt_Nombre.setText("");
chk_AfectaCaja.setSelected(false);
this.getFormasDePagos();
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.RestClientResponseException in project sic by belluccifranco.
the class LoginGUI method validarUsuario.
private void validarUsuario() {
if (!txt_Usuario.getText().trim().equals("") || txt_Contrasenia.getPassword().length != 0) {
try {
Credencial credencial = new Credencial(txt_Usuario.getText().trim(), new String(txt_Contrasenia.getPassword()));
UsuarioActivo.getInstance().setToken(RestClient.getRestTemplate().postForObject("/login", credencial, String.class));
Usuario usuario = RestClient.getRestTemplate().getForObject("/usuarios/busqueda?nombre=" + credencial.getUsername(), Usuario.class);
UsuarioActivo.getInstance().setUsuario(usuario);
} 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_login_usuario_contrasenia_vacios"), "Error", JOptionPane.ERROR_MESSAGE);
}
}
use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.
the class DetalleTransportistaGUI method btn_GuardarActionPerformed.
//GEN-LAST:event_cmb_ProvinciaItemStateChanged
private void btn_GuardarActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_btn_GuardarActionPerformed
try {
if (operacion == TipoDeOperacion.ALTA) {
Transportista transportista = new Transportista();
transportista.setNombre(txt_Nombre.getText().trim());
transportista.setDireccion(txt_Direccion.getText().trim());
transportista.setLocalidad((Localidad) cmb_Localidad.getSelectedItem());
transportista.setTelefono(txt_Telefono.getText().trim());
transportista.setWeb(txt_Web.getText().trim());
transportista.setEmpresa(EmpresaActiva.getInstance().getEmpresa());
RestClient.getRestTemplate().postForObject("/transportistas", transportista, Transportista.class);
int respuesta = JOptionPane.showConfirmDialog(this, "El transportista se guardó correctamente.\n¿Desea dar de alta otro transportista?", "Aviso", JOptionPane.YES_NO_OPTION);
this.limpiarYRecargarComponentes();
if (respuesta == JOptionPane.NO_OPTION) {
this.dispose();
}
}
if (operacion == TipoDeOperacion.ACTUALIZACION) {
transportistaModificar.setNombre(txt_Nombre.getText().trim());
transportistaModificar.setDireccion(txt_Direccion.getText().trim());
transportistaModificar.setLocalidad((Localidad) cmb_Localidad.getSelectedItem());
transportistaModificar.setTelefono(txt_Telefono.getText().trim());
transportistaModificar.setWeb(txt_Web.getText().trim());
transportistaModificar.setEmpresa(EmpresaActiva.getInstance().getEmpresa());
RestClient.getRestTemplate().put("/transportistas", transportistaModificar);
JOptionPane.showMessageDialog(this, "El transportista se modificó correctamente!", "Aviso", JOptionPane.INFORMATION_MESSAGE);
this.dispose();
}
} 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.RestClientResponseException in project sic by belluccifranco.
the class DetalleUsuarioGUI method btn_GuardarActionPerformed.
// </editor-fold>//GEN-END:initComponents
private void btn_GuardarActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_btn_GuardarActionPerformed
try {
if (operacion == TipoDeOperacion.ALTA) {
if (new String(txt_Contrasenia.getPassword()).equals(new String(txt_RepetirContrasenia.getPassword()))) {
Usuario usuario = new Usuario();
usuario.setNombre(txt_Usuario.getText().trim());
usuario.setPassword(new String(txt_Contrasenia.getPassword()));
List<Rol> roles = new ArrayList<>();
if (chk_Administrador.isSelected()) {
roles.add(Rol.ADMINISTRADOR);
}
if (chk_Vendedor.isSelected()) {
roles.add(Rol.VENDEDOR);
}
if (chk_Viajante.isSelected()) {
roles.add(Rol.VIAJANTE);
}
usuario.setRoles(roles);
RestClient.getRestTemplate().postForObject("/usuarios", usuario, Usuario.class);
LOGGER.warn("El usuario " + usuario.getNombre() + " se creo correctamente.");
this.dispose();
} else {
JOptionPane.showMessageDialog(this, "Las contraseñas introducidas deben ser las mismas.", "Error", JOptionPane.ERROR_MESSAGE);
}
}
if (operacion == TipoDeOperacion.ACTUALIZACION) {
if (new String(txt_Contrasenia.getPassword()).equals(new String(txt_RepetirContrasenia.getPassword()))) {
Usuario usuarioModificado = new Usuario();
usuarioModificado.setId_Usuario(usuarioModificar.getId_Usuario());
usuarioModificado.setNombre(txt_Usuario.getText().trim());
usuarioModificado.setPassword(new String(txt_Contrasenia.getPassword()));
if (UsuarioActivo.getInstance().getUsuario().getNombre().equals(usuarioModificar.getNombre())) {
usuarioModificado.setToken(usuarioModificar.getToken());
}
List<Rol> roles = new ArrayList<>();
if (chk_Administrador.isSelected()) {
roles.add(Rol.ADMINISTRADOR);
}
if (chk_Vendedor.isSelected()) {
roles.add(Rol.VENDEDOR);
}
if (chk_Viajante.isSelected()) {
roles.add(Rol.VIAJANTE);
}
usuarioModificado.setRoles(roles);
RestClient.getRestTemplate().put("/usuarios", usuarioModificado);
LOGGER.warn("El usuario " + usuarioModificado.getNombre() + " se modifico correctamente.");
this.dispose();
} else {
JOptionPane.showMessageDialog(this, "Las contraseñas introducidas deben ser las mismas.", "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);
}
}
use of org.springframework.web.client.RestClientResponseException in project sic by belluccifranco.
the class DetalleRubroGUI method btn_ActualizarActionPerformed.
//GEN-LAST:event_lst_RubrosValueChanged
private void btn_ActualizarActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_btn_ActualizarActionPerformed
try {
if (rubroSeleccionado == null) {
JOptionPane.showMessageDialog(this, "Seleccione un rubro de la lista para poder continuar.", "Error", JOptionPane.ERROR_MESSAGE);
} else {
Rubro rubroModificado = new Rubro();
rubroModificado.setId_Rubro(rubroSeleccionado.getId_Rubro());
rubroModificado.setNombre(txt_ModicaElimina.getText().trim());
rubroModificado.setEmpresa(EmpresaActiva.getInstance().getEmpresa());
RestClient.getRestTemplate().put("/rubros", rubroModificado);
txt_ModicaElimina.setText("");
rubroSeleccionado = null;
this.cargarListRubros();
}
} 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);
}
}
Aggregations