use of mork.MorkDocument in project janrufmonitor by tbrandt77.
the class ThunderbirdTransformer method getCallers.
public ICallerList getCallers() {
ICallerList cl = PIMRuntime.getInstance().getCallerFactory().createCallerList();
if (this.m_filename == null)
return cl;
File f = new File(this.m_filename);
if (!f.exists() || !f.isFile()) {
this.m_logger.warning("Mozilla Thunderbird file " + this.m_filename + " does not exists.");
PropagationFactory.getInstance().fire(new Message(Message.INFO, ThunderbirdCallerManager.NAMESPACE, "nofile", new Exception("Sync Mozilla Thunderbird Adressbook...")));
return cl;
}
if (this.m_sync)
PropagationFactory.getInstance().fire(new Message(Message.INFO, ThunderbirdCallerManager.NAMESPACE, "sync", new Exception("Sync Mozilla Thunderbird Adressbook...")));
try {
List rawData = new ArrayList();
FileInputStream fis = new FileInputStream(f);
MorkDocument md = new MorkDocument(new InputStreamReader(fis));
List l = md.getRows();
Row r = null;
for (int i = 0, j = l.size(); i < j; i++) {
r = (Row) l.get(i);
rawData.add(r.getAliases());
}
l = md.getTables();
Table t = null;
for (int i = 0, j = l.size(); i < j; i++) {
t = (Table) l.get(i);
for (int k = 0; k < t.getRows().size(); k++) {
r = (Row) t.getRows().get(k);
rawData.add(r.getAliases());
}
}
fis.close();
this.m_total = rawData.size();
if (rawData.size() > 0) {
this.m_logger.info("Found " + rawData.size() + " Mozilla Thunderbird contacts.");
this.parseContacts(cl, rawData);
}
} catch (FileNotFoundException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (IOException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
this.m_logger.info(cl.size() + " contacts from Mozilla Thunderbird available.");
return cl;
}
Aggregations