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 ShowExistingDatasetsByPolicyServlet extends
41 SSOConfiguredCuratorWebService {
42
43 private String stagingAreaPath;
44
45 private String policyDirPath;
46
47 private static final long serialVersionUID = 4844652723865688280L;
48
49 public ShowExistingDatasetsByPolicyServlet() {
50 }
51
52 public void init(ServletConfig conf) throws ServletException {
53 super.init(conf);
54 this.stagingAreaPath = PathUtils.replaceEnvVariables(getServletContext().getInitParameter(STAGING_AREA_PATH));
55 this.policyDirPath = PathUtils.replaceEnvVariables(getServletContext().getInitParameter(POLICY_UPLOAD_PATH));
56 }
57
58 public void doPost(HttpServletRequest req, HttpServletResponse res)
59 throws ServletException, IOException {
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
69 public void doGet(HttpServletRequest req, HttpServletResponse res)
70 throws ServletException, IOException {
71
72 this.configureSingleSignOn(req, res);
73
74
75 if (!this.sso.isLoggedIn()) {
76 res.sendRedirect("/login.jsp?from=" + req.getRequestURL());
77 return;
78 }
79
80 String policy = req.getParameter("policy");
81 PrintWriter out = res.getWriter();
82
83
84 if (policy == null) {
85 out.println("");
86 return;
87 }
88
89 CurationPolicyManager pm = new CurationPolicyManager(this.policyDirPath, this.stagingAreaPath);
90 out.println(pm.getDatasetsByPolicyAsJSON(policy));
91
92 return;
93 }
94 }