*/
private void addStashDocumentToSOLRIndex(String solrLocation, List<Pointer> pointers) throws SSAFSolrException {
try {
// Establish Connection
SolrServer server = new SolrConnection().getSolrServer(solrLocation);
// Create List of SolrInputDocuments Object
List<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
// Iterate through pointers
for (int j=0 ; j < pointers.size(); j++) {
// Get a Pointer Object
Pointer pointer = pointers.get(j);
// Create SolrInputDocument Object
SolrInputDocument doc = new SolrInputDocument();
// Get values from Pointer Values into local Variables
String recordUri = pointer.getRecordUri();
String stashFilePath = pointer.getStashFilepath();
String stashType = pointer.getStashType();
XMLGregorianCalendar stashDate = pointer.getStashDatetime();
String pointerFilePath = pointer.getPointerFilepath();
PointerItems pointerItems = pointer.getPointerItems();
// Peform Mandatory Check
if ( recordUri != null &&
stashFilePath != null &&
stashType != null &&
stashDate != null &&
pointerItems != null &&
pointerFilePath != null)
{
// Add local Variables values to SolrInputDocument
doc.addField( "record-uri", recordUri);
doc.addField("stash-filepath", stashFilePath);
doc.addField("stash-type", stashType);
doc.addField("stash-date", stashDate);
doc.addField("pointer-filepath", pointerFilePath);
List<PointerItem> pointerItemList = pointerItems.getPointerItem();
// Get Pointer Items and add to SolrInputDocument
for (int i = 0; i < pointerItemList.size(); i++)
{
PointerItem pointerItem = pointerItemList.get(i);
if (pointerItem != null && (pointerItem.isIndexed()!=null && pointerItem.isIndexed() ))
{
if ((pointerItem.getPointerValue() != null) && (pointerItem.getPointerName() != null)) {
doc.addField("stash-content", pointerItem.getPointerName().toLowerCase().replace(' ', '_')+"_"+pointerItem.getPointerValue().toLowerCase().replace(' ', '_'));
} else {
if ( (pointerItem.getPointerBase64Value() != null) ||
(pointerItem.getPointerHexValue() != null) ||
(pointerItem.getPointerUriValue() != null)
)
{
throw new SSAFSolrException();
}
}
}
}
} else {
SSAFSolrException ssafException = new SSAFSolrException();
ssafException.setFatalError(SSAFSolrErrorCodes.MISSING_DATA_ERROR);
throw ssafException;
}
docs.add(doc);
}
// Add Docs to Server & Commit
// Records will not be stored into Index until commit is performed.
server.add(docs);
server.commit();
}
catch (Exception e)
{
SSAFSolrException ssafException = new SSAFSolrException();
ssafException.setFatalError(SSAFSolrErrorCodes.UNABLE_TO_STASH);