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: * @param request
23: * the request send by the client to the server
24: * @param response
25: * the response send by the server to the client
26: * @throws ServletException
27: * if an error occurred
28: * @throws IOException
29: * 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
43: // String(request.getParameter("folderName").getBytes(charset),
44: // "utf-8");
45: String name = request.getParameter("folderName");
46:
47: try {
48: NotesFolder folder = new NotesFolder();
49: folder.setFolderName(name);
50: folder.setUsername(getAuthProfile(request).getUsername());
51: Long resId = NotesFolderController.saveFolder(
52: getAuthProfile(request), folder);
53: out.print(resId.toString());
54: } catch (Exception e) {
55: e.printStackTrace();
56: out.print("fail");
57: }
58: }
59:
60: }
|