01: package org.claros.intouch.notes.services;
02:
03: import java.io.IOException;
04: import java.io.PrintWriter;
05:
06: import javax.servlet.ServletException;
07: import javax.servlet.http.HttpServletRequest;
08: import javax.servlet.http.HttpServletResponse;
09:
10: import org.claros.intouch.common.services.BaseService;
11: import org.claros.intouch.notes.controllers.NotesController;
12:
13: public class DeleteNoteService extends BaseService {
14:
15: /**
16: *
17: */
18: private static final long serialVersionUID = 1629039255645939897L;
19:
20: /**
21: * The doPost method of the servlet. <br>
22: *
23: * This method is called when a form has its tag value method equals to post.
24: *
25: * @param request the request send by the client to the server
26: * @param response the response send by the server to the client
27: * @throws ServletException if an error occurred
28: * @throws IOException if an error occurred
29: */
30: public void doPost(HttpServletRequest request,
31: HttpServletResponse response) throws ServletException,
32: IOException {
33:
34: response.setHeader("Expires", "-1");
35: response.setHeader("Pragma", "no-cache");
36: response.setHeader("Cache-control", "no-cache");
37: response.setHeader("Content-Type", "text/html; charset=utf-8");
38: PrintWriter out = response.getWriter();
39:
40: String sId = request.getParameter("id");
41:
42: if (sId != null) {
43: try {
44: NotesController.deleteNote(getAuthProfile(request),
45: new Long(sId));
46: out.print("ok");
47: } catch (Exception e) {
48: out.print("fail");
49: }
50: } else {
51: out.print("fail");
52: }
53: }
54:
55: }
|