Document document = db.parse(url.openStream());
// Need to get the unique key and all the fields
NodeList uniqueKeys = document.getElementsByTagName("uniqueKey");
if (uniqueKeys == null || uniqueKeys.getLength() != 1) {
throw new AvroBaseException("Invalid schema configuration, must have 1 unique key");
}
uniqueKey = uniqueKeys.item(0).getTextContent();
// Now get all the fields we are going to index and query
NodeList fieldList = document.getElementsByTagName("field");
fields = new ArrayList<String>(fieldList.getLength());
for (int i = 0; i < fieldList.getLength(); i++) {
Node field = fieldList.item(i);
String name = field.getAttributes().getNamedItem("name").getTextContent();
fields.add(name);
}
} catch (MalformedURLException e) {
throw new AvroBaseException("Invalid Solr URL: " + solrURL, e);
} catch (ParserConfigurationException e) {
throw new AvroBaseException(e);
} catch (SAXException e) {
throw new AvroBaseException("Failed to parse schema", e);
} catch (IOException e) {
throw new AvroBaseException("Failed to read schema", e);
}
}