public void process(LocalDocument doc) throws Exception {
Map<String, Object> urls = FieldHelper.getFieldMatchingPattern(doc.getContentMap(),
urlFieldPattern);
UriParser uriParser = new UriParser();
DocumentParserHelper documentParserHelper = new DocumentParserHelper(addMetaData, addLanguage);
InputStreamParser inputStreamParser = new InputStreamParser(parser);
for (String field : urls.keySet()) {
Iterator<URL> it = uriParser.getUrlsFromObject(urls.get(field)).iterator();
for (int i = 1; it.hasNext(); i++) {
String num = (i > 1) ? "" + i : "";
URL url = it.next();
URLConnection connection = createConnection(url);
final InputStream inputStream = connection.getInputStream();
try {
String prefix = field + num + "_";
ParsedData parsedData = inputStreamParser.parse(inputStream);
documentParserHelper.addParsedDataToDocument(parsedData, doc, prefix);
} finally {
inputStream.close();
}
}