1 package org.kuali.ole.web;
2
3 import org.kuali.ole.docstore.model.enums.DocCategory;
4 import org.kuali.ole.docstore.model.enums.DocFormat;
5 import org.kuali.ole.docstore.model.enums.DocType;
6 import org.kuali.ole.docstore.process.LinkingInstanceNBibHandler;
7 import org.kuali.ole.logger.DocStoreLogger;
8
9 import javax.servlet.ServletException;
10 import javax.servlet.http.HttpServlet;
11 import javax.servlet.http.HttpServletRequest;
12 import javax.servlet.http.HttpServletResponse;
13 import java.io.IOException;
14 import java.io.PrintWriter;
15
16
17
18
19
20
21
22
23 public class LinkingBibNInstanceAfterBulkIngest
24 extends HttpServlet {
25
26 DocStoreLogger docStoreLogger = new DocStoreLogger(getClass().getName());
27
28 @Override
29 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
30 doPost(req, resp);
31 }
32
33 @Override
34 protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
35 outputMessage(resp, "Linking of Instsnce and Bib records started. Please check logs for further details");
36 try {
37 String action = req.getParameter("action");
38 LinkingInstanceNBibHandler link = LinkingInstanceNBibHandler
39 .getInstance(DocCategory.WORK.getCode(), DocType.INSTANCE.getDescription(),
40 DocFormat.OLEML.getCode());
41 if (!link.isRunning()) {
42 link.startProcess();
43 } else {
44 outputMessage(resp, "Rebuild Indexes Process is already running");
45 }
46
47 } catch (Exception e) {
48 docStoreLogger.log("Error during rebuilding of the indexes from documentstore", e);
49 }
50 }
51
52 private void outputMessage(HttpServletResponse resp, String s) throws IOException {
53 PrintWriter out = resp.getWriter();
54 out.println(s);
55 out.flush();
56 out.close();
57 }
58
59 }