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: * @param request
22: * the request send by the client to the server
23: * @param response
24: * the response send by the server to the client
25: * @throws ServletException
26: * if an error occurred
27: * @throws IOException
28: * if an error occurred
29: */
30: public void doPost(HttpServletRequest request,
31: HttpServletResponse response) throws ServletException,
32: IOException {
33: response.setHeader("Expires", "-1");
34: response.setHeader("Pragma", "no-cache");
35: response.setHeader("Cache-control", "no-cache");
36: response.setHeader("Content-Type", "text/html; charset=utf-8");
37: PrintWriter out = response.getWriter();
38:
39: String sId = request.getParameter("id");
40:
41: if (sId != null) {
42: try {
43: NotesController.deleteNote(getAuthProfile(request),
44: new Long(sId));
45: out.print("ok");
46: } catch (Exception e) {
47: out.print("fail");
48: }
49: } else {
50: out.print("fail");
51: }
52: }
53:
54: }
|