From 7b769285f11c73df418a2af7f3d64897cac7aabc Mon Sep 17 00:00:00 2001 From: Samuel Gamez Date: Tue, 28 May 2024 13:10:05 -0500 Subject: [PATCH] Funciones EndPoint y token, v4 --- .../src/java/xforce/bl/PaisesBL.java | 3 +- .../java/xforce/servicios/PaisesEndpoint.java | 39 +++++++++++++------ 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/ProyectoInventario-ejb/src/java/xforce/bl/PaisesBL.java b/ProyectoInventario-ejb/src/java/xforce/bl/PaisesBL.java index e95eeac..6bb0302 100644 --- a/ProyectoInventario-ejb/src/java/xforce/bl/PaisesBL.java +++ b/ProyectoInventario-ejb/src/java/xforce/bl/PaisesBL.java @@ -57,7 +57,7 @@ public class PaisesBL implements PaisesBLLocal { } return m; - } catch (NullPointerException e){ + } catch (NullPointerException e) { return Mensaje.DATOS_INCORRECTOS; } } @@ -136,6 +136,7 @@ public class PaisesBL implements PaisesBLLocal { return paisesDao.buscarId(paises); } else { System.out.println("Se encontro el pais"); + System.out.println(paisesDao.buscarId(paises)); return paisesDao.buscarId(paises); } } diff --git a/ProyectoInventario-war/src/java/xforce/servicios/PaisesEndpoint.java b/ProyectoInventario-war/src/java/xforce/servicios/PaisesEndpoint.java index d22796e..04d85ee 100644 --- a/ProyectoInventario-war/src/java/xforce/servicios/PaisesEndpoint.java +++ b/ProyectoInventario-war/src/java/xforce/servicios/PaisesEndpoint.java @@ -57,13 +57,6 @@ public class PaisesEndpoint extends HttpServlet { if (s == null) { // Token no válido out.println("

Token no valido

"); - //response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Token no válido"); - List listaPaises = paisesBL.buscarValidos(true); - if (listaPaises != null && !listaPaises.isEmpty()) { - for (Paises pais : listaPaises) { - out.println("

" + pais.getId() + " || " + pais.getNombre() + "

"); - } - } return; } @@ -75,6 +68,8 @@ public class PaisesEndpoint extends HttpServlet { String nombre = request.getParameter("nombre"); Mensaje m = null; + boolean listas = false; + if (opc != null) { switch (Integer.parseInt(opc)) { @@ -97,19 +92,39 @@ public class PaisesEndpoint extends HttpServlet { m = paisesBL.eliminar(paises); + break; + case 4: + + paises.setNombre(nombre); + + paisesBL.buscarNombre(paises); + + listas = true; + break; default: throw new AssertionError(); } } - List listaPaises = paisesBL.buscarValidos(true); - out.print("

" + m + "

"); - if (listaPaises != null && !listaPaises.isEmpty()) { - for (Paises pais : listaPaises) { - out.println("

" + pais.getId() + " || " + pais.getNombre() + "

"); + if (listas == true) { + out.println("

Se encontro el pais " + paises.getNombre() + "

"); + List listaPaises = paisesBL.buscarValidos(true); + if (listaPaises != null && !listaPaises.isEmpty()) { + for (Paises pais : listaPaises) { + out.println("

" + pais.getId() + " || " + pais.getNombre() + "

"); + } + } + } else { + List listaPaises = paisesBL.buscarValidos(true); + out.print("

" + m + "

"); + if (listaPaises != null && !listaPaises.isEmpty()) { + for (Paises pais : listaPaises) { + out.println("

" + pais.getId() + " || " + pais.getNombre() + "

"); + } } } + } }