Merge pull request #139 from atmire/DS-1345

Ds 1345,DS-1346 Bugfix for the fact that all versions where searchable/browsable
This commit is contained in:
Robin Taylor
2012-11-26 01:37:31 -08:00
4 changed files with 9 additions and 9 deletions

View File

@@ -166,7 +166,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
* Make sure the item is not in the index if it is not in
* archive or withwrawn.
*/
unIndexContent(context, handle);
unIndexContent(context, item);
log.info("Removed Item: " + handle + " from Index");
}
break;

View File

@@ -275,7 +275,7 @@ public class DSIndexer
{
try
{
IndexingTask task = prepareIndexingTask(dso, force);
IndexingTask task = prepareIndexingTask(context, dso, force);
if (task != null)
{
processIndexingTask(task);
@@ -653,9 +653,9 @@ public class DSIndexer
}
static IndexingTask prepareIndexingTask(DSpaceObject dso, boolean force) throws SQLException, IOException, DCInputsReaderException
static IndexingTask prepareIndexingTask(Context context, DSpaceObject dso, boolean force) throws SQLException, IOException, DCInputsReaderException
{
String handle = dso.getHandle();
String handle = HandleManager.findHandle(context, dso);
Term term = new Term("handle", handle);
IndexingTask action = null;
switch (dso.getType())
@@ -668,7 +668,7 @@ public class DSIndexer
if (requiresIndexing(term, ((Item)dso).getLastModified()) || force)
{
log.info("Writing Item: " + handle + " to Index");
action = new IndexingTask(IndexingTask.Action.UPDATE, term, buildDocumentForItem((Item)dso));
action = new IndexingTask(IndexingTask.Action.UPDATE, term, buildDocumentForItem(context, (Item)dso));
}
}
else
@@ -1041,9 +1041,9 @@ public class DSIndexer
* @throws SQLException
* @throws IOException
*/
private static Document buildDocumentForItem(Item item) throws SQLException, IOException, DCInputsReaderException
private static Document buildDocumentForItem(Context context, Item item) throws SQLException, IOException, DCInputsReaderException
{
String handle = item.getHandle();
String handle = HandleManager.findHandle(context, item);
// get the location string (for searching by collection & community)
String location = buildItemLocationString(item);

View File

@@ -50,6 +50,7 @@ public class VersioningConsumer implements Consumer {
if(previous != null){
Item previousItem = previous.getItem();
if(previousItem != null){
previousItem.setArchived(false);
itemsToProcess.add(previousItem);
//Fire a new modify event for our previous item
//Due to the need to reindex the item in the search & browse index we need to fire a new event
@@ -66,7 +67,6 @@ public class VersioningConsumer implements Consumer {
for(Item item : itemsToProcess){
ctx.turnOffAuthorisationSystem();
try {
item.setArchived(false);
item.update();
} finally {
ctx.restoreAuthSystemState();