1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.web;
17
18 import org.kuali.ole.RepositoryBrowser;
19
20 import javax.servlet.RequestDispatcher;
21 import javax.servlet.ServletException;
22 import javax.servlet.http.HttpServlet;
23 import javax.servlet.http.HttpServletRequest;
24 import javax.servlet.http.HttpServletResponse;
25 import java.io.IOException;
26 import java.util.ArrayList;
27 import java.util.List;
28
29
30
31
32
33
34
35
36 public class GetUUIDServlet extends HttpServlet {
37 private static final String RESULTS_JSP =
38 "/getUUIDResults.jsp";
39 private RepositoryBrowser repositoryBrowser;
40
41 @Override
42 protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
43 List<String> uuidsList = new ArrayList<String>();
44 String category = req.getParameter("category");
45 String type = req.getParameter("type");
46 String format = req.getParameter("format");
47 String numUUIDs = req.getParameter("numUUIDs");
48 try {
49 if (null != category && null != format && null != numUUIDs) {
50 uuidsList = getRepositoryBrowser().getUUIDs(category.toLowerCase(), type.toLowerCase(), format.toLowerCase(), new Integer(numUUIDs));
51 }
52 } catch (Exception e) {
53 uuidsList.add(e.getMessage());
54 }
55 RequestDispatcher rd = getServletContext().getRequestDispatcher(RESULTS_JSP);
56 req.setAttribute("result", uuidsList);
57 rd.forward(req, resp);
58 }
59
60
61 public RepositoryBrowser getRepositoryBrowser() {
62 if (null == repositoryBrowser) {
63 repositoryBrowser = new RepositoryBrowser();
64 }
65 return repositoryBrowser;
66 }
67 }