1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.docstore.service;
17
18 import org.apache.camel.CamelContext;
19 import org.kuali.ole.docstore.process.BulkIngestDocStoreRequestBuilder;
20 import org.kuali.ole.docstore.process.BulkLoadHandler;
21 import org.kuali.ole.docstore.process.DocStoreCamelContext;
22 import org.kuali.ole.docstore.process.ProcessParameters;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 import java.util.HashSet;
27 import java.util.Set;
28
29
30
31
32
33
34
35
36 public class BulkIngestProcessHandlerService {
37
38 private Logger logger = LoggerFactory.getLogger(BulkIngestProcessHandlerService.class);
39 private static Set<String> processMonitor = new HashSet<String>();
40 private BulkLoadHandler loadHandler = BulkLoadHandler.getInstance();
41
42
43
44
45
46
47 public void startBulkIngestForDocStoreRequestFormat(String folder) throws Exception {
48 loadHandler.loadBulk(folder, ProcessParameters.BULK_DEFAULT_USER, ProcessParameters.BULK_DEFUALT_ACTION);
49 }
50
51
52
53
54
55
56
57
58
59
60 public void startBulkIngestForStandardXMLFormat(String folder, String category, String type, String format,
61 String bulkIngestUploadDir) throws Exception {
62 String cmd = category + "/" + type + "/" + format + "@" + folder;
63 try {
64 logger.info("Bulk Ingest Process for " + cmd + " \t\t: STARTING...");
65 if (processMonitor.contains(cmd)) {
66 throw new Exception("Process Already Running : " + cmd);
67 }
68 CamelContext camelContext = DocStoreCamelContext.getInstance().getCamelContext();
69 BulkIngestDocStoreRequestBuilder builder = new BulkIngestDocStoreRequestBuilder(folder,
70 ProcessParameters.BULK_DEFAULT_USER,
71 ProcessParameters.BULK_DEFUALT_ACTION,
72 camelContext, category,
73 type, format,
74 bulkIngestUploadDir);
75 camelContext.addRoutes(builder);
76 camelContext.start();
77 processMonitor.add(cmd);
78 logger.info("Bulk Ingest Process for " + cmd + " \t\t: STARTED");
79 } catch (Exception e) {
80 logger.error("Unable to Start Bulk Ingest Process for " + cmd + ".\n Cuase: " + e.getMessage(), e);
81 throw new Exception("Unable to Start Bulk Ingest Process for " + cmd + ".\n Cuase: " + e.getMessage(), e);
82 }
83
84 }
85
86 public BulkLoadHandler getLoadHandler() {
87 return loadHandler;
88 }
89
90 public void setLoadHandler(BulkLoadHandler loadHandler) {
91 this.loadHandler = loadHandler;
92 }
93 }