}
int numDocs = ids.size(); // for debuging
try {
ids = checkRepresentations(ids); // returns the ids found in the solrIndex
} catch (SolrServerException e) {
throw new YardException("Error while searching for alredy present documents "
+ "before executing the actual update for the parsed Representations", e);
} catch (IOException e) {
throw new YardException("Unable to access SolrServer", e);
}
long checked = System.currentTimeMillis();
List<SolrInputDocument> inputDocs = new ArrayList<SolrInputDocument>(ids.size());
List<Representation> updated = new ArrayList<Representation>();
for (Representation representation : representations) {
if (representation != null && ids.contains(representation.getId())) { // null parsed or not
// already present
inputDocs.add(createSolrInputDocument(representation));
updated.add(representation);
}
}
long created = System.currentTimeMillis();
if (!inputDocs.isEmpty()) {
try {
final UpdateRequest update = new UpdateRequest();
if (!immediateCommit) {
update.setCommitWithin(commitWithin);
}
update.add(inputDocs);
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public UpdateResponse run() throws IOException, SolrServerException {
update.process(server);
if (immediateCommit) {
server.commit();
}
return null;
}
});
} catch (PrivilegedActionException pae){
if(pae.getException() instanceof SolrServerException){
throw new YardException("Error while adding updated Documents to the SolrServer",
pae.getException());
} else if( pae.getException() instanceof IOException){
throw new YardException("Unable to access SolrServer", pae.getException());
} else {
throw RuntimeException.class.cast(pae.getException());
}
}
}