Skip to content
Snippets Groups Projects
Commit 4b38ea90 authored by andres's avatar andres
Browse files

Eliminar temporales, contador de descargas (Remove prints)

parent 6dd6a68e
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,25 @@ public class nookDB {
return 0;
}
}
public static int actualizarDescargas(int idNook, int descargas) {
ConnectionPool pool = ConnectionPool.getInstance();
Connection connection = pool.getConnection();
String query="UPDATE Nook SET descargas = ? WHERE idNook = ?";
try {
PreparedStatement ps =connection.prepareStatement(query);
ps.setDouble(1, descargas);
ps.setInt(2, idNook);
int res = ps.executeUpdate();
ps.close();
pool.freeConnection(connection);
return res;
} catch (SQLException e) {
e.printStackTrace();
return 0;
}
}
//obtener lista de nooks populares
public static ArrayList<Nook> getNooksPopulares() {
......
......@@ -30,7 +30,6 @@ public class valoracionesAutorDB {
ps.setString(1, valoracion.getAutor());
ps.setString(2, valoracion.getUsuario());
rs = ps.executeQuery();
System.out.println(rs);
if(!rs.next()){
consulta = "INSERT INTO ValoracionesAutor (autor, usuario, puntuacion)"
+ " VALUES (?, ?, ?)";
......
......@@ -32,7 +32,6 @@ public class valoracionesNookDB {
ps.setInt(1, valoracion.getNook());
ps.setString(2, valoracion.getUsuario());
rs = ps.executeQuery();
System.out.println(rs);
if(!rs.next()){
consulta = "INSERT INTO valoracionesNook (nook, usuario, puntuacion, fecha)"
+ " VALUES (?, ?, ?, ?)";
......
......@@ -48,7 +48,6 @@ public class agregarArchivoSV extends HttpServlet {
HttpSession sesion = request.getSession();
String userName = (String) sesion.getAttribute("usuario");
System.out.println("\n\n\n" + documento.getSize() + "\n\n\n");
java.util.Date date = new java.util.Date();
Date fecha = new Date(date.getTime());
......
......@@ -61,7 +61,6 @@ public class descargarNookSV extends HttpServlet {
for(int i=0; i<documentos.size(); i++){
archivos.add("temp" + File.separator + nook + File.separator + documentos.get(i).getNombre());
System.out.println(archivos.get(i));
}
for (int i=0; i < archivos.size(); i++) {
......@@ -86,7 +85,6 @@ public class descargarNookSV extends HttpServlet {
File file = new File(rutaZip);
OutputStream outStream = null;
FileInputStream inputStream = null;
System.out.println(file.getName());
if(file.exists()){
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment; filename=\"" + file.getName() + "\"");
......@@ -115,6 +113,21 @@ public class descargarNookSV extends HttpServlet {
response.setContentType("text/html");
response.getWriter().println("<h3>File \"+ fileName +\" Is Not Present .....!</h3>");
}
deleteDirectory(new File("temp" + File.separator + nook));
nookDB.actualizarDescargas(nook, nookO.getDescargas()+1);
}
boolean deleteDirectory(File directorio) {
File[] contenidos = directorio.listFiles();
if (contenidos != null) {
for (File file : contenidos) {
deleteDirectory(file);
}
}
return directorio.delete();
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment