Browse Source

token

master
nayelivilchismariscal 6 months ago
parent
commit
00f77c4446
  1. 136
      Inventario-ejb/build.xml
  2. 2506
      Inventario-ejb/nbproject/build-impl.xml
  3. 16
      Inventario-ejb/nbproject/genfiles.properties
  4. 40
      Inventario-ejb/nbproject/project.xml
  5. 19
      Inventario-ejb/src/java/mx/edu/tjs/chapala/sistemas/bl/CategoriaBL.java
  6. 6
      Inventario-ejb/src/java/mx/edu/tjs/chapala/sistemas/bl/CategoriaBLLocal.java
  7. 13
      Inventario-ejb/src/java/mx/edu/tjs/chapala/sistemas/dao/CategoriaDAO.java
  8. 158
      Inventario-war/src/java/mx/edu/tjs/servicios/CategoriaEndpoint.java
  9. 4
      Inventario-war/web/resources/css/cssLayout.css
  10. 82
      nbproject/project.properties

136
Inventario-ejb/build.xml

@ -1,68 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for --> <!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. --> <!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) --> <!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. --> <!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if --> <!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. --> <!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> <!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.--> <!-- in the project's Project Properties dialog box.-->
<project name="Inventario-ejb" default="default" basedir="." xmlns:ejbjarproject="http://www.netbeans.org/ns/j2ee-ejbjarproject/3"> <project name="Inventario-ejb" default="default" basedir="." xmlns:ejbjarproject="http://www.netbeans.org/ns/j2ee-ejbjarproject/3">
<description>Builds, tests, and runs the project Inventario-ejb.</description> <description>Builds, tests, and runs the project Inventario-ejb.</description>
<import file="nbproject/build-impl.xml"/> <import file="nbproject/build-impl.xml"/>
<!-- <!--
There exist several targets which are by default empty and which can be There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed used for execution of your tasks. These targets are usually executed
before and after some main targets. They are: before and after some main targets. They are:
-pre-init: called before initialization of project properties -pre-init: called before initialization of project properties
-post-init: called after initialization of project properties -post-init: called after initialization of project properties
-pre-compile: called before javac compilation -pre-compile: called before javac compilation
-post-compile: called after javac compilation -post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file -pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file -post-compile-single: called after javac compilation of single file
-pre-dist: called before archive building -pre-dist: called before archive building
-post-dist: called after archive building -post-dist: called after archive building
-post-clean: called after cleaning build products -post-clean: called after cleaning build products
-pre-run-deploy: called before deploying -pre-run-deploy: called before deploying
-post-run-deploy: called after deploying -post-run-deploy: called after deploying
(Targets beginning with '-' are not intended to be called on their own.) (Targets beginning with '-' are not intended to be called on their own.)
Example of pluging an obfuscator after the compilation could look like Example of pluging an obfuscator after the compilation could look like
<target name="-post-compile"> <target name="-post-compile">
<obfuscate> <obfuscate>
<fileset dir="${build.classes.dir}"/> <fileset dir="${build.classes.dir}"/>
</obfuscate> </obfuscate>
</target> </target>
For list of available properties check the imported For list of available properties check the imported
nbproject/build-impl.xml file. nbproject/build-impl.xml file.
Other way how to customize the build is by overriding existing main targets. Other way how to customize the build is by overriding existing main targets.
The target of interest are: The target of interest are:
init-macrodef-javac: defines macro for javac compilation init-macrodef-javac: defines macro for javac compilation
init-macrodef-debug: defines macro for class debugging init-macrodef-debug: defines macro for class debugging
do-dist: archive building do-dist: archive building
run: execution of project run: execution of project
javadoc-build: javadoc generation javadoc-build: javadoc generation
Example of overriding the target for project execution could look like Example of overriding the target for project execution could look like
<target name="run" depends="<PROJNAME>-impl.jar"> <target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe"> <exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/> <arg file="${dist.jar}"/>
</exec> </exec>
</target> </target>
Notice that overridden target depends on jar target and not only on Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in properties which you can use check the target you are overriding in
nbproject/build-impl.xml file. nbproject/build-impl.xml file.
--> -->
</project> </project>

2506
Inventario-ejb/nbproject/build-impl.xml

File diff suppressed because it is too large

16
Inventario-ejb/nbproject/genfiles.properties

@ -1,8 +1,8 @@
build.xml.data.CRC32=369704af build.xml.data.CRC32=369704af
build.xml.script.CRC32=d98c699b build.xml.script.CRC32=d98c699b
build.xml.stylesheet.CRC32=a737d6c5@1.75 build.xml.stylesheet.CRC32=a737d6c5@1.75
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=369704af nbproject/build-impl.xml.data.CRC32=369704af
nbproject/build-impl.xml.script.CRC32=27f3e739 nbproject/build-impl.xml.script.CRC32=27f3e739
nbproject/build-impl.xml.stylesheet.CRC32=62693482@1.75 nbproject/build-impl.xml.stylesheet.CRC32=62693482@1.75

40
Inventario-ejb/nbproject/project.xml

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1"> <project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.j2ee.ejbjarproject</type> <type>org.netbeans.modules.j2ee.ejbjarproject</type>
<configuration> <configuration>
<data xmlns="http://www.netbeans.org/ns/j2ee-ejbjarproject/3"> <data xmlns="http://www.netbeans.org/ns/j2ee-ejbjarproject/3">
<name>Inventario-ejb</name> <name>Inventario-ejb</name>
<minimum-ant-version>1.6.5</minimum-ant-version> <minimum-ant-version>1.6.5</minimum-ant-version>
<explicit-platform explicit-source-supported="true"/> <explicit-platform explicit-source-supported="true"/>
<source-roots> <source-roots>
<root id="src.dir"/> <root id="src.dir"/>
</source-roots> </source-roots>
<test-roots> <test-roots>
<root id="test.src.dir"/> <root id="test.src.dir"/>
</test-roots> </test-roots>
</data> </data>
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1"> <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>.././lib/nblibraries.properties</definitions> <definitions>.././lib/nblibraries.properties</definitions>
</libraries> </libraries>
</configuration> </configuration>
</project> </project>

19
Inventario-ejb/src/java/mx/edu/tjs/chapala/sistemas/bl/CategoriaBL.java

@ -56,6 +56,12 @@ public class CategoriaBL implements CategoriaBLLocal {
return m; return m;
} }
public void agregarC (Categoria categoria){
CategoriaDAO categoriaDAO = new CategoriaDAO();
categoriaDAO.agregar(categoria);
}
// Add business logic below. (Right-click in editor and choose // Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method") // "Insert Code > Add Business Method")
@ -124,6 +130,10 @@ public class CategoriaBL implements CategoriaBLLocal {
} }
return m; return m;
} }
public void eliminarC (Categoria categoria){
CategoriaDAO a = new CategoriaDAO();
a.eliminar(categoria);
}
@Override @Override
public Mensaje editar(Categoria categoria) { public Mensaje editar(Categoria categoria) {
@ -151,6 +161,15 @@ public class CategoriaBL implements CategoriaBLLocal {
CategoriaDAO p = new CategoriaDAO(); CategoriaDAO p = new CategoriaDAO();
return p.buscarStatus(true); return p.buscarStatus(true);
} }
public Categoria buscarIdInt(int id) {
CategoriaDAO categoriaDAO = new CategoriaDAO();
if(categoriaDAO==null){
return null;
}else{
return categoriaDAO.buscarIdInt(id);
}
}
} }

6
Inventario-ejb/src/java/mx/edu/tjs/chapala/sistemas/bl/CategoriaBLLocal.java

@ -27,5 +27,9 @@ public interface CategoriaBLLocal {
Mensaje eliminarId(Categoria categoria); Mensaje eliminarId(Categoria categoria);
Mensaje editar(Categoria p); Mensaje editar(Categoria p);
public Categoria buscarIdInt (int id) ;
public void agregarC(Categoria categoria);
public void eliminarC(Categoria categoria);
} }

13
Inventario-ejb/src/java/mx/edu/tjs/chapala/sistemas/dao/CategoriaDAO.java

@ -119,5 +119,18 @@ public class CategoriaDAO {
q.setParameter("status", s); q.setParameter("status", s);
return q.getResultList(); return q.getResultList();
} }
public Categoria buscarIdInt(int id){
if (id == 0 ) {
return null;
}
Query q = em.createNamedQuery("Categoria.findById");
q.setParameter("id", id);
if(q.getResultList().isEmpty()){
return null;
} else {
return (Categoria) q.getResultList().get(0);
}
}
} }

158
Inventario-war/src/java/mx/edu/tjs/servicios/CategoriaEndpoint.java

@ -0,0 +1,158 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
*/
package mx.edu.tjs.servicios;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mx.edu.tjs.chapala.sistemas.bl.CategoriaBLLocal;
import mx.edu.tjs.chapala.sistemas.modelo.Categoria;
/**
*
* @author nayelivilchismariscal
*/
@WebServlet(name = "CategoriaEndpoint", urlPatterns = {"/CategoriaEndpoint"})
public class CategoriaEndpoint extends HttpServlet {
@EJB
private CategoriaBLLocal categoriaBL;
Categoria m ;
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
String opcion = request.getParameter("opcion");
// Verificar el token
String token = request.getParameter("t");
if (!"h978HIJG87FD5757huuyujJJKAYtyywedh".equals(token)) {
out.print("Acceso Denegado");
return;
}
switch(opcion){
case "1":
m = categoriaBL.buscarIdInt(Integer.parseInt(request.getParameter("id")));
if(m.getStatus() == 0){
out.print("No existe la categoria");
}else{
out.print("<div style='font-family: Arial, sans-serif; padding: 20px;'>");
out.print("<h1 style='color: purple;'>Categoria </h1>");
out.print("<h2 style='color: blue;'>Nombre: " + m.getNombre() + "</h2>");
out.print("</div>");
}
break;
case "2":
m = categoriaBL.buscarIdInt(Integer.parseInt(request.getParameter("id")));
if(m.getStatus() == 0){
out.print("No existe ese elemento");
}else{
categoriaBL.eliminarC(m);
out.print("Se elimino la categoria");
}
break;
case "3":
Categoria nuevo = new Categoria();
nuevo.setStatus((short) 1);
nuevo.setNombre(request.getParameter("nombre"));
categoriaBL.agregarC(nuevo);
out.print("Se agrego la categoria");
break;
case "4":
try {
int id = Integer.parseInt(request.getParameter("id"));
Categoria categoriaExistente = categoriaBL.buscarIdInt(id);
if (categoriaExistente == null || categoriaExistente.getStatus() == 0) {
out.print("No existe la categoria");
} else {
String nuevoNombre = request.getParameter("nombre");
// Actualizar los campos necesarios
if (nuevoNombre != null && !nuevoNombre.isEmpty()) {
categoriaExistente.setNombre(nuevoNombre);
}
// Aquí puedes agregar más campos si es necesario
// marcaExistente.setOtroCampo(request.getParameter("otroCampo"));
categoriaBL.editar(categoriaExistente);
out.print("Editado con éxito");
}
} catch (NumberFormatException e) {
out.print("ID de marca no válido");
} catch (Exception e) {
out.print("Ocurrió un error al editar la marca");
}
break;
default:
out.print("<h1> No existe esa opcion </h1>");
break;
}
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}

4
Inventario-war/web/resources/css/cssLayout.css

@ -136,7 +136,9 @@ th.ui-state-default {
} }
.body1 {
background-image: url('https://img.freepik.com/vector-gratis/fondo-futurista-degradado-geometrico_23-2149116406.jpg?size=626&ext=jpg&ga=GA1.1.117944100.1709510400&semt=ais');
}

82
nbproject/project.properties

@ -1,41 +1,41 @@
build.classes.excludes=**/*.java,**/*.form,**/.nbattrs build.classes.excludes=**/*.java,**/*.form,**/.nbattrs
build.dir=build build.dir=build
build.generated.dir=${build.dir}/generated build.generated.dir=${build.dir}/generated
client.module.uri=Inventario-war client.module.uri=Inventario-war
client.urlPart= client.urlPart=
debug.classpath=${javac.classpath}::${jar.content.additional}:${run.classpath} debug.classpath=${javac.classpath}::${jar.content.additional}:${run.classpath}
display.browser=true display.browser=true
dist.dir=dist dist.dir=dist
dist.jar=${dist.dir}/${jar.name} dist.jar=${dist.dir}/${jar.name}
endorsed.classpath=\ endorsed.classpath=\
${libs.javaee-endorsed-api-7.0.classpath} ${libs.javaee-endorsed-api-7.0.classpath}
j2ee.appclient.mainclass.args=${j2ee.appclient.tool.args} j2ee.appclient.mainclass.args=${j2ee.appclient.tool.args}
j2ee.compile.on.save=true j2ee.compile.on.save=true
j2ee.deploy.on.save=true j2ee.deploy.on.save=true
j2ee.platform=1.7 j2ee.platform=1.7
j2ee.platform.classpath= j2ee.platform.classpath=${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar
j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar
j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsit.classpath= j2ee.platform.wsit.classpath=
j2ee.server.type=gfv4ee7 j2ee.server.type=gfv4ee7
jar.compress=false jar.compress=false
jar.content.additional=\ jar.content.additional=\
${reference.Inventario-war.dist-ear}:\ ${reference.Inventario-war.dist-ear}:\
${reference.Inventario-ejb.dist-ear} ${reference.Inventario-ejb.dist-ear}
jar.name=Inventario.ear jar.name=Inventario.ear
javac.debug=true javac.debug=true
javac.deprecation=false javac.deprecation=false
javac.source=1.7 javac.source=1.7
javac.target=1.7 javac.target=1.7
meta.inf=src/conf meta.inf=src/conf
no.dependencies=false no.dependencies=false
platform.active=default_platform platform.active=default_platform
project.Inventario-ejb=Inventario-ejb project.Inventario-ejb=Inventario-ejb
project.Inventario-war=Inventario-war project.Inventario-war=Inventario-war
reference.Inventario-ejb.dist-ear=${project.Inventario-ejb}/dist/Inventario-ejb.jar reference.Inventario-ejb.dist-ear=${project.Inventario-ejb}/dist/Inventario-ejb.jar
reference.Inventario-war.dist-ear=${project.Inventario-war}/dist/Inventario-war.war reference.Inventario-war.dist-ear=${project.Inventario-war}/dist/Inventario-war.war
resource.dir=setup resource.dir=setup
run.classpath= run.classpath=
source.root=. source.root=.

Loading…
Cancel
Save