1 package ecar.servlet.componente;
2
3 import java.io.IOException;
4 import java.io.PrintWriter;
5
6 import javax.servlet.ServletException;
7 import javax.servlet.http.HttpServlet;
8 import javax.servlet.http.HttpServletRequest;
9 import javax.servlet.http.HttpServletResponse;
10
11 import org.apache.log4j.Logger;
12
13 import comum.util.Pagina;
14
15 import ecar.dao.ItemEstrtIndResultLocalIettirlDao;
16
17 public class ExcluirIndicadorPorLocalServlet extends HttpServlet{
18
19
20 private static final long serialVersionUID = 8006183415879658218L;
21
22 private Logger logger = Logger.getLogger(this.getClass());
23
24 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
25 logger.info("request :: GET:: Classe:: " + this.getClass().getName() );
26 StringBuilder conteudo = new StringBuilder();
27 conteudo.append("false");
28 logger.error("Acesso nao autorizado:: acesso GET ao servico de salvar indicador por local");
29 responseToHTML( response, conteudo.toString());
30 }
31
32 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
33 logger.info("request :: POST:: Classe:: " + this.getClass().getName() );
34 execute(request,response);
35
36 }
37
38 private void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
39
40 final ItemEstrtIndResultLocalIettirlDao dao = new ItemEstrtIndResultLocalIettirlDao(request);
41 StringBuilder conteudo = new StringBuilder();
42
43 try {
44
45 Long codIettirLong = Pagina.getParamLong(request, "codIettir");
46 dao.deleteBycodIettir( codIettirLong );
47
48
49 conteudo.append("true");
50 responseToHTML(response, conteudo.toString() );
51
52 } catch(Exception e){
53 logger.error(e);
54 StringBuilder responseHTML = new StringBuilder();
55
56
57
58 responseHTML.append("false");
59 responseToHTML(response, responseHTML.toString());
60 }
61 }
62
63 private void responseToHTML ( HttpServletResponse response, String conteudo ) throws IOException {
64 response.setContentType("text/html");
65 PrintWriter writer = response.getWriter();
66 writer.append(conteudo);
67 writer.flush();
68 writer.close();
69 }
70
71
72 }