Browse Source

Funciones EndPoint y token, v4

master
Samuel Gamez 4 months ago
parent
commit
7b769285f1
  1. 1
      ProyectoInventario-ejb/src/java/xforce/bl/PaisesBL.java
  2. 29
      ProyectoInventario-war/src/java/xforce/servicios/PaisesEndpoint.java

1
ProyectoInventario-ejb/src/java/xforce/bl/PaisesBL.java

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

29
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("<h1>Token no valido</h1>");
//response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Token no válido");
List<Paises> listaPaises = paisesBL.buscarValidos(true);
if (listaPaises != null && !listaPaises.isEmpty()) {
for (Paises pais : listaPaises) {
out.println("<p>" + pais.getId() + " || " + pais.getNombre() + "</p>");
}
}
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,12 +92,30 @@ 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();
}
}
if (listas == true) {
out.println("<p>Se encontro el pais " + paises.getNombre() + "</p>");
List<Paises> listaPaises = paisesBL.buscarValidos(true);
if (listaPaises != null && !listaPaises.isEmpty()) {
for (Paises pais : listaPaises) {
out.println("<p>" + pais.getId() + " || " + pais.getNombre() + "</p>");
}
}
} else {
List<Paises> listaPaises = paisesBL.buscarValidos(true);
out.print("<h1>" + m + "</h1>");
if (listaPaises != null && !listaPaises.isEmpty()) {
@ -111,6 +124,8 @@ public class PaisesEndpoint extends HttpServlet {
}
}
}
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">

Loading…
Cancel
Save