1 package xuml.tools.diagram;
2
3 import java.io.IOException;
4
5 import javax.servlet.ServletException;
6 import javax.servlet.http.HttpServlet;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9
10 public class PresentationServlet extends HttpServlet {
11
12 private static final long serialVersionUID = -8814285976808898809L;
13
14 @Override
15 protected void doGet(HttpServletRequest req, HttpServletResponse resp)
16 throws ServletException, IOException {
17 try {
18 String id = req.getParameter("id");
19 String result = PresentationPersistence.instance().get(id);
20 resp.setContentType("text/plain");
21 if (result != null)
22 resp.getOutputStream().write(result.getBytes());
23 } catch (RuntimeException e) {
24 e.printStackTrace();
25 throw e;
26 }
27 }
28
29 @Override
30 protected void doPost(HttpServletRequest req, HttpServletResponse resp)
31 throws ServletException, IOException {
32 String id = req.getParameter("id");
33 String value = req.getParameter("value");
34 try {
35
36 PresentationPersistence.instance().save(id, value);
37 } catch (RuntimeException e) {
38 resp.setStatus(500);
39 resp.getWriter().println(e.getMessage());
40 }
41 }
42 }