use of com.hack23.cia.service.external.riksdagen.api.DataFailureException in project cia by Hack23.
the class WorldbankIndicatorApiImpl method getIndicators.
/* (non-Javadoc)
* @see com.hack23.cia.service.external.worldbank.api.WorldBankIndicatorApi#getIndicators()
*/
@Override
public List<IndicatorElement> getIndicators() throws DataFailureException {
final List<IndicatorElement> result = new ArrayList<>();
try {
final IndicatorsElement firstPage = (IndicatorsElement) getXmlAgent().unmarshallXml(indicatorsUnmarshaller, INDICATORS, null, XMLNS_WB_HTTP_WWW_WORLDBANK_ORG, XMLNS_WB_HTTP_INDICATORS_WORLDBANK_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL);
result.addAll(firstPage.getIndicator());
for (int pageNumber = SECOND_PAGE; pageNumber < firstPage.getPages().intValue(); pageNumber++) {
final IndicatorsElement otherPageResult = (IndicatorsElement) getXmlAgent().unmarshallXml(indicatorsUnmarshaller, INDICATORS + PAGE_NUMBER + pageNumber, null, XMLNS_WB_HTTP_WWW_WORLDBANK_ORG, XMLNS_WB_HTTP_INDICATORS_WORLDBANK_EXTERNAL_MODEL_CIA_HACK23_COM_IMPL);
result.addAll(otherPageResult.getIndicator());
}
} catch (final XmlAgentException e) {
LOGGER.warn(PROBLEM_GETTING_WORLDBANK_INDICATOR_LIST);
throw new DataFailureException(e);
}
return result;
}
Aggregations