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: import org.claros.intouch.notes.models.Note;
13:
14: public class SetPosService extends BaseService {
15:
16: /**
17: *
18: */
19: private static final long serialVersionUID = -6059932042409057155L;
20:
21: /**
22: * The doPost method of the servlet. <br>
23: *
24: * This method is called when a form has its tag value method equals to post.
25: *
26: * @param request the request send by the client to the server
27: * @param response the response send by the server to the client
28: * @throws ServletException if an error occurred
29: * @throws IOException if an error occurred
30: */
31: public void doPost(HttpServletRequest request,
32: HttpServletResponse response) throws ServletException,
33: IOException {
34:
35: response.setHeader("Expires", "-1");
36: response.setHeader("Pragma", "no-cache");
37: response.setHeader("Cache-control", "no-cache");
38: response.setHeader("Content-Type", "text/html; charset=utf-8");
39: PrintWriter out = response.getWriter();
40:
41: String sId = request.getParameter("id");
42: String left = request.getParameter("left");
43: String top = request.getParameter("top");
44: String width = request.getParameter("width");
45: String height = request.getParameter("height");
46:
47: if (sId != null) {
48: try {
49: Note note = NotesController.getNoteById(
50: getAuthProfile(request), new Long(sId));
51: if (note != null) {
52: note.setPosHeight(new Integer(height));
53: note.setPosLeft(new Integer(left));
54: note.setPosTop(new Integer(top));
55: note.setPosWidth(new Integer(width));
56:
57: NotesController.saveNote(getAuthProfile(request),
58: note);
59: }
60: out.print("ok");
61: } catch (Exception e) {
62: out.print("fail");
63: }
64: } else {
65: out.print("fail");
66: }
67: }
68: }
|