1 package org.kuali.ole;
2
3 import org.kuali.rice.core.api.impex.xml.XmlDocCollection;
4 import org.kuali.rice.core.api.impex.xml.XmlIngesterService;
5
6 import java.io.File;
7 import java.io.FileWriter;
8 import java.util.List;
9
10
11
12
13 public class OlePatronsXMLPollerServiceImpl extends OleXmlPollerServiceImpl{
14 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OlePatronsXMLPollerServiceImpl.class);
15 private PatronsIngesterService patronsIngesterService;
16
17 @Override
18 protected XmlIngesterService getIngesterService() {
19 return patronsIngesterService;
20 }
21
22 public void setPatronsIngesterService(PatronsIngesterService patronsIngesterService) {
23 this.patronsIngesterService = patronsIngesterService;
24 }
25
26 @Override
27 protected void processReportContent(List<XmlDocCollection> collections, String loadTime) {
28 StringBuffer reportContent = new StringBuffer();
29 for (XmlDocCollection xmlDocCollection : collections) {
30 if (xmlDocCollection.getXmlDocs() != null && xmlDocCollection.getXmlDocs().size() > 0) {
31 reportContent.append(xmlDocCollection.getXmlDocs().get(0).getProcessingMessage());
32 }
33 }
34 if (reportContent.length() > 0 && getXmlReportLocation() != null) {
35 File reportDir = new File(getXmlReportLocation());
36 if (reportDir.isDirectory() || (!reportDir.isDirectory() && reportDir.mkdirs())) {
37 try {
38 FileWriter out = new FileWriter(reportDir + "/" + loadTime + ".txt");
39 out.write(reportContent.toString());
40 out.close();
41 } catch (Exception e) {
42 LOG.error("Unable to create patron reports file");
43 }
44 } else {
45 LOG.error("Unable to create patron reports directory " + reportDir.getPath());
46 }
47 }
48 }
49
50 public PatronsIngesterService getPatronsIngesterService() {
51 return patronsIngesterService;
52 }
53 }