1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.oodt.cas.curation.servlet;
20
21
22 import org.apache.oodt.cas.curation.policymgr.CurationPolicyManager;
23 import org.apache.oodt.cas.metadata.util.PathUtils;
24
25
26 import java.io.IOException;
27 import java.io.PrintWriter;
28 import javax.servlet.RequestDispatcher;
29 import javax.servlet.ServletConfig;
30 import javax.servlet.ServletException;
31 import javax.servlet.http.HttpServletRequest;
32 import javax.servlet.http.HttpServletResponse;
33 import javax.servlet.http.HttpSession;
34
35
36
37
38
39
40 public class ShowExistingPoliciesServlet extends SSOConfiguredCuratorWebService {
41
42 private String stagingAreaPath;
43
44 private String policyDirPath;
45
46 private static final long serialVersionUID = 4844652723865688280L;
47
48 public ShowExistingPoliciesServlet() {
49 }
50
51 public void init(ServletConfig conf) throws ServletException {
52 super.init(conf);
53 this.stagingAreaPath = PathUtils.replaceEnvVariables(getServletContext().getInitParameter(STAGING_AREA_PATH));
54 this.policyDirPath = PathUtils.replaceEnvVariables(getServletContext().getInitParameter(POLICY_UPLOAD_PATH));
55 }
56
57 public void doPost(HttpServletRequest req, HttpServletResponse res)
58 throws ServletException, IOException {
59
60 HttpSession session = req.getSession();
61 session.setAttribute("errorMsg", "You must use GET to access this page");
62 RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(
63 "/error.jsp");
64 dispatcher.forward(req, res);
65 }
66
67
68 public void doGet(HttpServletRequest req, HttpServletResponse res)
69 throws ServletException, IOException {
70
71 this.configureSingleSignOn(req, res);
72
73
74 if (!this.sso.isLoggedIn()) {
75 res.sendRedirect("/login.jsp?from=" + req.getRequestURL());
76 return;
77 }
78
79 PrintWriter out = res.getWriter();
80 CurationPolicyManager pm = new CurationPolicyManager(this.policyDirPath, this.stagingAreaPath);
81 out.println(pm.getExistingPoliciesAsHTML());
82
83 return;
84 }
85 }