private <T> void processItems( final CrestApiProcessor<T> processor, final CrestContainer<T> container, final JsonParser jsonParser) throws IOException { if (jsonParser.isExpectedStartArrayToken()) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { container.addEntry(processor.parseEntry((JsonNode) mapper.readTree(jsonParser))); } } }
public <T> T downloadAndProcessData(final CrestApiProcessor<T> processor) { T result = null; try { final String data = accessor.getData(processor.getPath()); if (StringUtils.isNotBlank(data)) { final JsonNode node = mapper.readTree(data); result = processor.parseEntry(node); } else if (LOGGER.isWarnEnabled()) { LOGGER.warn("No data to parse for " + processor.getClass().getSimpleName()); } } catch (final IOException e) { if (LOGGER.isErrorEnabled()) { LOGGER.error("Could not download data", e); } } return result; }