Skip to content
Snippets Groups Projects
Commit 8150f1fc authored by Fnac's avatar Fnac
Browse files

Creando esta mierda

parents
Branches master
No related tags found
No related merge requests found
Showing
with 1323 additions and 0 deletions
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package conexionDB;
import java.sql.*;
import javax.sql.DataSource;
import javax.naming.InitialContext;
/**
*
* @author kikog
*/
public class ConnectionPool {
private static ConnectionPool pool = null;
private static DataSource dataSource = null;
private ConnectionPool() {
try {
InitialContext ic = new InitialContext();
dataSource = (DataSource) ic.lookup("java:/comp/env/jdbc/filenookdb");
}
catch(Exception e) {
e.printStackTrace();
}
}
public static ConnectionPool getInstance() {
if (pool == null) {
pool = new ConnectionPool();
}
return pool;
}
public Connection getConnection() {
try {
return dataSource.getConnection();
}
catch (SQLException sqle) {
sqle.printStackTrace();
return null;
}
}
public void freeConnection(Connection c) {
try {
c.close();
}
catch (SQLException sqle) {
sqle.printStackTrace();
}
}
}
\ No newline at end of file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package conexionDB;
/**
*
* @author Fnac
*/
public class nookDB {
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package conexionDB;
import java.sql.*;
import modelo.Usuario;
import java.util.ArrayList;
import java.util.List;
public class usuarioDB {
public static int insert(Usuario user) {
ConnectionPool pool = ConnectionPool.getInstance();
Connection connection = pool.getConnection();
String query="INSERT INTO Usuario (nombre,apellidos,nombreUsuario,clave,correo) VALUES (?, ?, ?, ?, ?)";
try {
PreparedStatement ps =connection.prepareStatement(query);
ps.setString(1, user.getNombre());
ps.setString(2, user.getApellidos());
ps.setString(3, user.getNombreUsuario());
ps.setString(4, user.getClave());
ps.setString(5, user.getCorreo());
int res = ps.executeUpdate();
ps.close();
pool.freeConnection(connection);
return res;
} catch (SQLException e) {
e.printStackTrace();
return 0;
}
}
public static boolean emailExists(String correo) {
ConnectionPool pool = ConnectionPool.getInstance();
Connection connection = pool.getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
String query = "SELECT correo FROM Usuario "+ "WHERE correo = ?";
try{
ps = connection.prepareStatement(query);
ps.setString(1, correo);
rs = ps.executeQuery();
boolean res = rs.next();
rs.close();
ps.close();
pool.freeConnection(connection);
return res;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
public static boolean dniExists(String dni) {
ConnectionPool pool = ConnectionPool.getInstance();
Connection connection = pool.getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
String query = "SELECT dni FROM Usuario WHERE dni = ?";
try{
ps = connection.prepareStatement(query);
ps.setString(1, dni);
rs = ps.executeQuery();
boolean res = rs.next();
rs.close();
ps.close();
pool.freeConnection(connection);
return res;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
public static boolean login(String dni,String passwd) {
ConnectionPool pool= ConnectionPool.getInstance();
Connection connection=pool.getConnection();
ResultSet rs=null;
String loginSQL="SELECT * FROM Usuario "+ "WHERE (dni = ? AND contraseña=? )";
try{
PreparedStatement ps =connection.prepareStatement(loginSQL);
ps.setString(1, dni);
ps.setString(2, passwd);
rs=ps.executeQuery();
boolean res=rs.next();
rs.close();
ps.close();
pool.freeConnection(connection);
return res;
}
catch(SQLException e){
e.printStackTrace();
return false;
}
}
public static List getRoles(String rol) {
ConnectionPool pool= ConnectionPool.getInstance();
Connection connection=pool.getConnection();
List roles=new ArrayList();
ResultSet rs=null;
String loginSQL="SELECT dni FROM Usuario "+ "WHERE rol=?";
try{
PreparedStatement ps =connection.prepareStatement(loginSQL);
ps.setString(1, rol);
rs=ps.executeQuery();
pool.freeConnection(connection);
while (rs.next()) {
String dni=rs.getString("dni");
roles.add(dni);
}
rs.close();
ps.close();
pool.freeConnection(connection);
return roles;
}
catch(SQLException e){
e.printStackTrace();
return null;
}
}
public static ArrayList<String> getJugadores(String parameter){
ConnectionPool pool= ConnectionPool.getInstance();
Connection connection=pool.getConnection();
String query = "SELECT u.nombre AS nombreUser, u.apellidos AS apellidosUser, u.dni AS dniUser, u.FECHA_REGISTRO AS fechaUser, e.nombre AS nombreEquipo, e.ID_EQUIPO as idEquipo "
+ "from USUARIO u CROSS JOIN PERTENENCIA p CROSS JOIN Equipo e "
+ "WHERE u.dni = p.dni AND p.ID_EQUIPO = e.ID_EQUIPO AND u.nombre = ?";
ResultSet rs = null;
try{
PreparedStatement ps =connection.prepareStatement(query);
ps.setString(1, parameter);
rs=ps.executeQuery();
ArrayList<String> res = parseResultSet(rs);
rs.close();
ps.close();
pool.freeConnection(connection);
return res;
}
catch(SQLException e){
e.printStackTrace();
pool.freeConnection(connection);
return null;
}
}
public static ArrayList<String> parseResultSet(ResultSet rs) throws SQLException{
ArrayList<String> au = new ArrayList<>();
while(rs.next()){
au.add(
rs.getString("nombreUser")+"///"+
rs.getString("apellidosUser")+"///"+
rs.getString("dniUser")+"///"+
rs.getDate("fechaUser").toString()+"///"+
rs.getString("nombreEquipo")+"///"+
rs.getInt("idEquipo")
);
}
return au;
} //IMPLEMENTAR <-------------------------
}
\ No newline at end of file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package modelo;
public class ClasificacionCategorias {
private Nook idNook;
private String categoria;
public ClasificacionCategorias(Nook idNook, String categoria) {
this.idNook = idNook;
this.categoria = categoria;
}
public Nook getIdNook() {
return idNook;
}
public void setIdNook(Nook idNook) {
this.idNook = idNook;
}
public String getCategoria() {
return categoria;
}
public void setCategoria(String categoria) {
this.categoria = categoria;
}
}
\ No newline at end of file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package modelo;
import java.util.Date;
public class Comentario {
private int idComentario;
private Date fecha;
private Usuario autor;
private String texto;
public Comentario(int idComentario, Date fecha, Usuario autor, String texto) {
this.idComentario = idComentario;
this.fecha = fecha;
this.autor = autor;
this.texto = texto;
}
public int getIdComentario() {
return idComentario;
}
public void setIdComentario(int idComentario) {
this.idComentario = idComentario;
}
public Date getFecha() {
return fecha;
}
public void setFecha(Date fecha) {
this.fecha = fecha;
}
public Usuario getAutor() {
return autor;
}
public void setAutor(Usuario autor) {
this.autor = autor;
}
public String getTexto() {
return texto;
}
public void setTexto(String texto) {
this.texto = texto;
}
}
\ No newline at end of file
package modelo;
import java.util.Date;
public class Documento {
private int nook;
private String nombre;
private String resumen;
private Date fechaCreacion;
private Date fechaModificacion;
public Documento(int nook, String nombre, String resumen, Date fechaCreacion, Date fechaModificacion) {
this.nook = nook;
this.nombre = nombre;
this.resumen = resumen;
this.fechaCreacion = fechaCreacion;
this.fechaModificacion = fechaModificacion;
}
public int getNook() {
return nook;
}
public void setNook(int nook) {
this.nook = nook;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getResumen() {
return resumen;
}
public void setResumen(String resumen) {
this.resumen = resumen;
}
public Date getFechaCreacion() {
return fechaCreacion;
}
public void setFechaCreacion(Date fechaCreacion) {
this.fechaCreacion = fechaCreacion;
}
public Date getFechaModificacion() {
return fechaModificacion;
}
public void setFechaModificacion(Date fechaModificacion) {
this.fechaModificacion = fechaModificacion;
}
}
\ No newline at end of file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package modelo;
import java.util.Date;
public class Mensaje {
private int idMensaje;
private String texto;
private Date fecha;
private int leido;
private String tipo;
private Usuario autor;
private Usuario destinatario;
public Mensaje(int idMensaje, String texto, Date fecha, int leido, String tipo, Usuario autor, Usuario destinatario) {
this.idMensaje = idMensaje;
this.texto = texto;
this.fecha = fecha;
this.leido = leido;
this.tipo = tipo;
this.autor = autor;
this.destinatario = destinatario;
}
public int getIdMensaje() {
return idMensaje;
}
public void setIdMensaje(int idMensaje) {
this.idMensaje = idMensaje;
}
public String getTexto() {
return texto;
}
public void setTexto(String texto) {
this.texto = texto;
}
public Date getFecha() {
return fecha;
}
public void setFecha(Date fecha) {
this.fecha = fecha;
}
public int getLeido() {
return leido;
}
public void setLeido(int leido) {
this.leido = leido;
}
public String getTipo() {
return tipo;
}
public void setTipo(String tipo) {
this.tipo = tipo;
}
public Usuario getAutor() {
return autor;
}
public void setAutor(Usuario autor) {
this.autor = autor;
}
public Usuario getDestinatario() {
return destinatario;
}
public void setDestinatario(Usuario destinatario) {
this.destinatario = destinatario;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package modelo;
import java.util.Date;
public class Nook {
private int idNook;
private String nombre;
private String resumen;
private String autor;
private Date fechaCreacion;
private Date fechaModificacion;
private int descargas;
public Nook(int idNook, String nombre, String resumen, String autor, Date fechaCreacion, Date fechaModificacion, int descargas) {
this.idNook = idNook;
this.nombre = nombre;
this.resumen = resumen;
this.autor = autor;
this.fechaCreacion = fechaCreacion;
this.fechaModificacion = fechaModificacion;
this.descargas = descargas;
}
public int getIdNook() {
return idNook;
}
public void setIdNook(int idNook) {
this.idNook = idNook;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getResumen() {
return resumen;
}
public void setResumen(String resumen) {
this.resumen = resumen;
}
public String getAutor() {
return autor;
}
public void setAutor(String autor) {
this.autor = autor;
}
public Date getFechaCreacion() {
return fechaCreacion;
}
public void setFechaCreacion(Date fechaCreacion) {
this.fechaCreacion = fechaCreacion;
}
public Date getFechaModificaion() {
return fechaModificacion;
}
public void setFechaModificacion(Date fechaModificacion) {
this.fechaModificacion = fechaModificacion;
}
public int getDescargas() {
return descargas;
}
public void setDescargas(int descargas) {
this.descargas = descargas;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package modelo;
public class Usuario {
private String nombre;
private String apellidos;
private String nombreUsuario;
private String clave;
private String correo;
private String imagenPerfil;
public Usuario(){
}
public Usuario(String nombre, String apellidos, String nombreUsuario, String contraseña, String correo, String imagenPerfil) {
this.nombre = nombre;
this.apellidos = apellidos;
this.nombreUsuario = nombreUsuario;
this.clave = contraseña;
this.correo = correo;
this.imagenPerfil = imagenPerfil;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getApellidos() {
return apellidos;
}
public void setApellidos(String apellidos) {
this.apellidos = apellidos;
}
public String getNombreUsuario() {
return nombreUsuario;
}
public void setNombreUsuario(String nombreUsuario) {
this.nombreUsuario = nombreUsuario;
}
public String getClave() {
return clave;
}
public void setClave(String clave) {
this.clave = clave;
}
public String getCorreo() {
return correo;
}
public void setCorreo(String correo) {
this.correo = correo;
}
public String getImagenPerfil() {
return imagenPerfil;
}
public void setImagenPerfil(String imagenPerfil) {
this.imagenPerfil = imagenPerfil;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package modelo;
public class ValoracionAutor {
private Usuario autor;
private double puntuacion;
public ValoracionAutor(Usuario autor, double puntuacion) {
this.autor = autor;
this.puntuacion = puntuacion;
}
public Usuario getAutor() {
return autor;
}
public void getAutor(Usuario autor) {
this.autor = autor;
}
public double getPuntuacion() {
return puntuacion;
}
public void setPuntuacion(double puntuacion) {
this.puntuacion = puntuacion;
}
}
\ No newline at end of file
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package modelo;
import java.util.Date;
public class ValoracionComentario {
private Comentario comentario;
private int puntuacion;
private Date fecha;
private Usuario usuario;
public ValoracionComentario(Comentario comentario, int puntuacion, Date fecha, Usuario usuario) {
this.comentario = comentario;
this.puntuacion = puntuacion;
this.fecha = fecha;
this.usuario = usuario;
}
public Comentario getComentario() {
return comentario;
}
public void setComentario(Comentario comentario) {
this.comentario = comentario;
}
public int getPuntuacion() {
return puntuacion;
}
public void setPuntuacion(int puntuacion) {
this.puntuacion = puntuacion;
}
public Date getFecha() {
return fecha;
}
public void setFecha(Date fecha) {
this.fecha = fecha;
}
public Usuario getUsuario() {
return usuario;
}
public void setUsuario(Usuario usuario) {
this.usuario = usuario;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package modelo;
import java.util.Date;
public class ValoracionesNook {
private Nook nook;
private Usuario usuario;
private int puntuacion;
private Date fecha;
public ValoracionesNook(Nook nook, Usuario usuario, int puntuacion, Date fecha) {
this.nook = nook;
this.usuario = usuario;
this.puntuacion = puntuacion;
this.fecha = fecha;
}
public Nook getNook() {
return nook;
}
public void setNook(Nook nook) {
this.nook = nook;
}
public Usuario getUsuario() {
return usuario;
}
public void setUsuario(Usuario usuario) {
this.usuario = usuario;
}
public int getPuntuacion() {
return puntuacion;
}
public void setPuntuacion(int resumen) {
this.puntuacion = puntuacion;
}
public Date getFecha() {
return fecha;
}
public void setFecha(Date autor) {
this.fecha = fecha;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package servlet;
import conexionDB.usuarioDB;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
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 modelo.Nook;
/**
*
* @author Fnac
*/
@WebServlet(name = "inicial", urlPatterns = {"/inicial"})
public class inicial extends HttpServlet {
/**
* 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");
ArrayList<Nook> nooks=nookDB.getInicial();
ArrayList<Usuario> usuarios=ArrayList<Usuario>();
for (Nook n:nooks){
usuarios.add(usuarioDB.getUsuario(n.getAutor()));
}
String url = "/inicial.jsp";
request.setAttribute("nooks", nooks);
request.setAttribute("usuarios",usuarios);
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
dispatcher.forward(request, response);
}
// <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>
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package servlet;
import conexionDB.usuarioDB;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
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 modelo.Usuario;
/**
*
* @author Fnac
*/
@WebServlet(name = "inicio", urlPatterns = {"/inicio"})
public class inicio extends HttpServlet {
/**
* 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");
String correo = request.getParameter("email");
String nombre = request.getParameter("nom");
String usuario = request.getParameter("usr");
String clave = request.getParameter("psw");
Usuario pepito = new Usuario();
pepito.setNombre(nombre);
pepito.setApellidos(nombre);
pepito.setNombreUsuario(usuario);
pepito.setClave(clave);
pepito.setCorreo(correo);
usuarioDB.insert(pepito);
String url = "/inicial";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
dispatcher.forward(request, response);
}
// <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>
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author Fnac
*/
@WebServlet(name = "nookSV", urlPatterns = {"/nookSV"})
public class nookSV extends HttpServlet {
/**
* 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()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet nookSV</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet nookSV at " + request.getContextPath() + "</h1>");
out.println("</body>");
out.println("</html>");
}
}
// <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>
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- 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 -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="FileNook" default="default" basedir=".">
<description>Builds, tests, and runs the project FileNook.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-dist: called before archive building
-post-dist: called after archive building
-post-clean: called after cleaning build products
-pre-run-deploy: called before deploying
-post-run-deploy: called after deploying
Example of pluging an obfuscator after the compilation could look like
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Other way how to customize the build is by overriding existing main targets.
The target of interest are:
init-macrodef-javac: defines macro for javac compilation
init-macrodef-junit: defines macro for junit execution
init-macrodef-debug: defines macro for class debugging
do-dist: archive building
run: execution of project
javadoc-build: javadoc generation
Example of overriding the target for project execution could look like
<target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in
nbproject/build-impl.xml file.
-->
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) 2006, 2016 Oracle and/or its affiliates. All rights reserved.
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://www.netbeans.org/cddl-gplv2.html
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License file at
nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
particular file as subject to the "Classpath" exception as provided
by Oracle in the GPL Version 2 section of the License file that
accompanied this code. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 2, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 2] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 2 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 2 code and therefore, elected the GPL
Version 2 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
-->
<project default="-deploy-ant" basedir=".">
<target name="-init" if="deploy.ant.enabled">
<property file="${deploy.ant.properties.file}"/>
<tempfile property="temp.module.folder" prefix="tomcat" destdir="${java.io.tmpdir}"/>
<unwar src="${deploy.ant.archive}" dest="${temp.module.folder}">
<patternset includes="META-INF/context.xml"/>
</unwar>
<xmlproperty file="${temp.module.folder}/META-INF/context.xml"/>
<delete dir="${temp.module.folder}"/>
</target>
<target name="-check-credentials" if="deploy.ant.enabled" depends="-init">
<fail message="Tomcat password has to be passed as tomcat.password property.">
<condition>
<not>
<isset property="tomcat.password"/>
</not>
</condition>
</fail>
</target>
<target name="-deploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials">
<echo message="Deploying ${deploy.ant.archive} to ${Context(path)}"/>
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
classpath="${tomcat.home}/server/lib/catalina-ant.jar"/>
<deploy url="${tomcat.url}/manager" username="${tomcat.username}"
password="${tomcat.password}" path="${Context(path)}"
war="${deploy.ant.archive}"/>
<property name="deploy.ant.client.url" value="${tomcat.url}${Context(path)}"/>
</target>
<target name="-undeploy-ant" if="deploy.ant.enabled" depends="-init,-check-credentials">
<echo message="Undeploying ${Context(path)}"/>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"
classpath="${tomcat.home}/server/lib/catalina-ant.jar"/>
<undeploy url="${tomcat.url}/manager" username="${tomcat.username}"
password="${tomcat.password}" path="${Context(path)}"/>
</target>
</project>
This diff is collapsed.
build.xml.data.CRC32=f4714e76
build.xml.script.CRC32=df895d31
build.xml.stylesheet.CRC32=651128d4@1.77.1.1
# 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.
nbproject/build-impl.xml.data.CRC32=f4714e76
nbproject/build-impl.xml.script.CRC32=8e6a1fb5
nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=true
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
auxiliary.org-netbeans-modules-css-prep.less_2e_configured=true
build.classes.dir=${build.web.dir}/WEB-INF/classes
build.classes.excludes=**/*.java,**/*.form
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
build.web.dir=${build.dir}/web
build.web.excludes=${build.classes.excludes}
client.urlPart=
compile.jsps=false
conf.dir=${source.root}/conf
debug.classpath=${build.classes.dir}:${javac.classpath}
debug.test.classpath=\
${run.test.classpath}
display.browser=true
# Files to be excluded from distribution war
dist.archive.excludes=
dist.dir=dist
dist.ear.war=${dist.dir}/${war.ear.name}
dist.javadoc.dir=${dist.dir}/javadoc
dist.war=${dist.dir}/${war.name}
endorsed.classpath=\
${libs.javaee-endorsed-api-7.0.classpath}
excludes=
file.reference.derby.jar=usr/lib/jvm/java-8-oracle/db/lib/derby.jar
file.reference.derbyclient.jar=usr/lib/jvm/java-8-oracle/db/lib/derbyclient.jar
includes=**
j2ee.compile.on.save=true
j2ee.copy.static.files.on.save=true
j2ee.deploy.on.save=true
j2ee.platform=1.7-web
j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/derby.jar:${j2ee.server.home}/lib/derbyclient.jar:${j2ee.server.home}/lib/ecj-4.9.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-cs.jar:${j2ee.server.home}/lib/tomcat-i18n-de.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-i18n-ko.jar:${j2ee.server.home}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.home}/lib/tomcat-i18n-ru.jar:${j2ee.server.home}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar
j2ee.server.type=Tomcat
jar.compress=false
javac.classpath=\
${file.reference.derby.jar}:\
${file.reference.derbyclient.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.debug=true
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.preview=true
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
lib.dir=${web.docbase.dir}/WEB-INF/lib
persistence.xml.dir=${conf.dir}
platform.active=default_platform
resource.dir=setup
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
# Space-separated list of JVM arguments used when running a class with a main method or a unit test
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value):
runmain.jvmargs=
source.encoding=UTF-8
source.root=src
src.Source%20Packages.dir=Source Packages
test.src.dir=test
war.content.additional=
war.ear.name=${war.name}
war.name=filenookapp.war
web.docbase.dir=web
webinf.dir=web/WEB-INF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment