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 }
44 else {
45 outputMessage(resp, "Rebuild Indexes Process is already running");
46 }
47
48 }
49 catch (Exception e) {
50 docStoreLogger.log("Error during rebuilding of the indexes from documentstore", e);
51 }
52 }
53
54 private void outputMessage(HttpServletResponse resp, String s) throws IOException {
55 PrintWriter out = resp.getWriter();
56 out.println(s);
57 out.flush();
58 out.close();
59 }
60
61 }