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.NotesFolderController;
12: import org.claros.intouch.notes.models.NotesFolder;
13:
14: public class AddNotebookService extends BaseService {
15:
16: /**
17: *
18: */
19: private static final long serialVersionUID = 1100948823133187378L;
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 charset = Constants.charset;
42: // String name = new String(request.getParameter("folderName").getBytes(charset), "utf-8");
43: String name = request.getParameter("folderName");
44:
45: try {
46: NotesFolder folder = new NotesFolder();
47: folder.setFolderName(name);
48: folder.setUsername(getAuthProfile(request).getUsername());
49: Long resId = NotesFolderController.saveFolder(
50: getAuthProfile(request), folder);
51: out.print(resId.toString());
52: } catch (Exception e) {
53: e.printStackTrace();
54: out.print("fail");
55: }
56: }
57:
58: }
|