| 1 | package com.popx.presentazione; | |
| 2 | ||
| 3 | import com.popx.persistenza.ProdottoDAO; | |
| 4 | import com.popx.persistenza.ProdottoDAOImpl; | |
| 5 | ||
| 6 | import javax.servlet.ServletException; | |
| 7 | import javax.servlet.annotation.WebServlet; | |
| 8 | import javax.servlet.http.HttpServlet; | |
| 9 | import javax.servlet.http.HttpServletRequest; | |
| 10 | import javax.servlet.http.HttpServletResponse; | |
| 11 | import java.io.IOException; | |
| 12 | import java.sql.SQLException; | |
| 13 | ||
| 14 | @WebServlet("/DeleteProductServlet") | |
| 15 | public class DeleteProductServlet extends HttpServlet { | |
| 16 | ||
| 17 | private ProdottoDAO prodottoDAO; | |
| 18 | ||
| 19 | // costruttore production | |
| 20 | public DeleteProductServlet() { | |
| 21 | this.prodottoDAO = new ProdottoDAOImpl(); | |
| 22 | } | |
| 23 | ||
| 24 | // costruttore test | |
| 25 | public DeleteProductServlet(ProdottoDAO prodottoDAO) { | |
| 26 | this.prodottoDAO = prodottoDAO; | |
| 27 | } | |
| 28 | ||
| 29 | @Override | |
| 30 | public void doPost(HttpServletRequest request, HttpServletResponse response) | |
| 31 | throws ServletException, IOException { | |
| 32 | ||
| 33 | String productId = request.getParameter("id"); | |
| 34 | ||
| 35 | try { | |
| 36 |
1
1. doPost : removed call to com/popx/persistenza/ProdottoDAO::deleteProductById → KILLED |
prodottoDAO.deleteProductById(productId); |
| 37 | ||
| 38 |
1
1. doPost : removed call to javax/servlet/http/HttpServletResponse::setStatus → KILLED |
response.setStatus(HttpServletResponse.SC_OK); |
| 39 | response.getWriter() | |
| 40 |
1
1. doPost : removed call to java/io/PrintWriter::write → KILLED |
.write("{\"success\": true, \"message\": \"Prodotto eliminato con successo.\"}"); |
| 41 | ||
| 42 | } catch (Exception e) { | |
| 43 |
1
1. doPost : removed call to javax/servlet/http/HttpServletResponse::setStatus → KILLED |
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); |
| 44 | response.getWriter() | |
| 45 |
1
1. doPost : removed call to java/io/PrintWriter::write → KILLED |
.write("{\"success\": false, \"message\": \"Errore nell'eliminazione del prodotto.\"}"); |
| 46 | } | |
| 47 | } | |
| 48 | } | |
Mutations | ||
| 36 |
1.1 |
|
| 38 |
1.1 |
|
| 40 |
1.1 |
|
| 43 |
1.1 |
|
| 45 |
1.1 |