protected ImportManager importManager;
public Map<Locale,Properties> extract() throws Exception {
Map<Locale,Properties> bundles = new HashMap<Locale, Properties>();
if (xmlFile != null && xmlFile.exists()) {
ImportResults importResults = importManager.parse(new FileInputStream(xmlFile));
// Check parsing results.
MessageList messages = importResults.getMessages();
Locale locale = LocaleManager.currentLocale();
Iterator it = messages.iterator();
while (it.hasNext()) {
Message message = (Message) it.next();
switch (message.getMessageType()) {
case Message.ERROR: throw new Exception(message.getMessage(locale));
case Message.WARNING: log.warn(message.getMessage(locale)); break;
case Message.INFO: log.info(message.getMessage(locale)); break;
}
}
// Extract i18n literals from data providers
Set<DataProvider> dataProviders = importResults.getDataProviders();
for (DataProvider dataProvider : dataProviders) {
processDataProvider(dataProvider, bundles);
}
// Extract i18n literals from KPIs
Set<KPI> kpis = importResults.getKPIs();
for (KPI kpi : kpis) {
processKPI(kpi, bundles);
}
}
return bundles;