01: package org.claros.intouch.webmail.services;
02:
03: import java.io.IOException;
04: import java.io.PrintWriter;
05: import java.net.URLDecoder;
06:
07: import javax.servlet.ServletException;
08: import javax.servlet.http.HttpServletRequest;
09: import javax.servlet.http.HttpServletResponse;
10:
11: import org.claros.commons.auth.models.AuthProfile;
12: import org.claros.commons.mail.models.ConnectionMetaHandler;
13: import org.claros.commons.mail.models.ConnectionProfile;
14: import org.claros.intouch.common.services.BaseService;
15: import org.claros.intouch.webmail.controllers.FolderController;
16: import org.claros.intouch.webmail.factory.FolderControllerFactory;
17:
18: public class EmptyMailFolderService extends BaseService {
19:
20: /**
21: *
22: */
23: private static final long serialVersionUID = 9147122046876396096L;
24:
25: /**
26: * The doPost method of the servlet. <br>
27: *
28: * This method is called when a form has its tag value method equals to post.
29: *
30: * @param request the request send by the client to the server
31: * @param response the response send by the server to the client
32: * @throws ServletException if an error occurred
33: * @throws IOException if an error occurred
34: */
35: public void doPost(HttpServletRequest request,
36: HttpServletResponse response) throws ServletException,
37: IOException {
38:
39: response.setHeader("Expires", "-1");
40: response.setHeader("Pragma", "no-cache");
41: response.setHeader("Cache-control", "no-cache");
42: response.setHeader("Content-Type", "text/html; charset=utf-8");
43: PrintWriter out = response.getWriter();
44:
45: AuthProfile auth = getAuthProfile(request);
46: ConnectionMetaHandler handler = (ConnectionMetaHandler) request
47: .getSession().getAttribute("handler");
48: ConnectionProfile profile = (ConnectionProfile) request
49: .getSession().getAttribute("profile");
50:
51: /*
52: String charset = Constants.charset;
53: String folder = new String(request.getParameter("fid").getBytes(charset), "utf-8");
54: */
55: String folder = URLDecoder.decode(request.getParameter("fid"),
56: "UTF-8");
57:
58: try {
59: FolderControllerFactory factory = new FolderControllerFactory(
60: auth, profile, handler);
61: FolderController foldCont = factory.getFolderController();
62: foldCont.emptyFolder(folder);
63:
64: out.print("ok");
65: } catch (Exception e) {
66: out.print("fail");
67: }
68: }
69:
70: }
|