1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.docstore.process;
17
18 import org.apache.camel.CamelContext;
19 import org.apache.camel.builder.RouteBuilder;
20 import org.apache.camel.support.TokenXMLPairExpressionIterator;
21 import org.kuali.ole.docstore.model.enums.DocCategory;
22 import org.kuali.ole.docstore.model.enums.DocFormat;
23 import org.kuali.ole.docstore.model.enums.DocType;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27
28
29
30
31
32
33
34 public class BulkIngestDocStoreRequestBuilder
35 extends RouteBuilder {
36
37 private static Logger log = LoggerFactory.getLogger(BulkIngestDocStoreRequestBuilder.class);
38 private String folder = null;
39 private String user = null;
40 private String action = null;
41 private String category;
42 private String type;
43 private String format;
44 private String target;
45
46
47
48
49
50
51
52
53
54 public BulkIngestDocStoreRequestBuilder(String folder, String user, String action, CamelContext context,
55 String category, String type, String format, String target) {
56 super(context);
57 this.folder = folder;
58 this.user = user;
59 this.action = action;
60 this.category = category;
61 this.type = type;
62 this.format = format;
63 this.target = target;
64 }
65
66
67
68
69
70
71 @Override
72 public void configure() throws Exception {
73 log.debug("Loading Bulk Ingest DocStore Request Builder Process @" + folder);
74 if (DocCategory.WORK.isEqualTo(category) && DocType.BIB.isEqualTo(type) && DocFormat.MARC.isEqualTo(format)) {
75 from("file:" + folder + "?noop=false&move=.done")
76 .split(new TokenXMLPairExpressionIterator("<record>", "</record>", "<collection>"))
77 .process(new BulkIngestDocumentReqProcessor(user, action, category, type, format, target));
78 }
79 else if (DocCategory.WORK.isEqualTo(category) && DocType.BIB.isEqualTo(type) && DocFormat.DUBLIN_CORE
80 .isEqualTo(format)) {
81 from("file:" + folder + "?noop=false&move=.done")
82 .split(new TokenXMLPairExpressionIterator("<dublin_core>", "</dublin_core>", "<>"))
83 .process(new BulkIngestDocumentReqProcessor(user, action, category, type, format, target));
84 }
85 else if (DocCategory.WORK.isEqualTo(category) && DocType.BIB.isEqualTo(type) && DocFormat.DUBLIN_UNQUALIFIED
86 .isEqualTo(format)) {
87 from("file:" + folder + "?noop=false&move=.done")
88 .split(new TokenXMLPairExpressionIterator("<record>", "</record>", "<ListRecords>"))
89 .process(new BulkIngestDocumentReqProcessor(user, action, category, type, format, target));
90 }
91 else {
92 log.error("Un Supported Document Category/Type/Format : " + category + "/" + type + "/" + format);
93 throw new Exception("Un Supported Document Category/Type/Format : " + category + "/" + type + "/" + format);
94 }
95 log.info("Loaded Bulk Ingest DocStore Request Builder Process @" + folder);
96 }
97
98 }