isIndexed = fieldType.isIndexed();
}
if (isIndexed == null)
{
throw new SSAFSolrException("Pointer item, "
+ pointerItem.getItemName()
+ ", is not defined in semantics");
}
if (Boolean.valueOf(isIndexed))
{
DataType dataType =
DataType.fromValue(fieldType.getDataType());
String fieldName =
pointerItem.getItemName() + "_" + dataType.value();
String pointerValue = "";
switch (dataType)
{
case STRING:
pointerValue =
pointerItem.getItemValue().toLowerCase();
break;
case DATE:
// Assuming the coming in date is of format YYYY-MM-DD,
// we concatenate the string
// with T00:00:00Z.
pointerValue =
pointerItem.getItemValue().concat(DATE_SUFFIX);
break;
default:
pointerValue = pointerItem.getItemValue();
break;
}
doc.addField(fieldName, pointerValue);
}
}
docs.add(doc);
}
// Add Docs to Server & Commit
// Records will not be stored into Index until commit is performed.
try
{
for (Pointer pointer : pointers)
{
SolrDocument solrDocument = ssafSearchImpl.searchWithRecordUri(
solrLocation, pointer.getRecordUri() );
if (solrDocument != null)
{
String pointerFilePath = (String) solrDocument
.get( "pointer_filepath" );
deleteFile( pointerFilePath );
String stashFilePath = (String) solrDocument
.get( "stash_filepath" );
deleteFile( stashFilePath );
}
}
server.add(docs);
server.commit();
}
catch (SolrServerException e)
{
log.error("Unable to Stash pointers", e);
e.printStackTrace();
throw new SSAFSolrException(SSAFSolrErrorCodes.UNABLE_TO_STASH);
}
catch (IOException e)
{
log.error("Unable to Stash pointers", e);
e.printStackTrace();
throw new SSAFSolrException(SSAFSolrErrorCodes.UNABLE_TO_STASH);
}
}