mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Improve DSIndexer logic in both branches to support removal of items from index when withdrawn from repository. Remove decision making logic in SearchConsumer to allow DSIndexer to make the decisions where its more appropriate.
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@3013 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -290,11 +290,23 @@ public class DSIndexer
|
||||
Item item = (Item)dso;
|
||||
if (item.isArchived() && !item.isWithdrawn())
|
||||
{
|
||||
/** If the item is in the repository now, add it to the index*/
|
||||
if (requiresIndexing(t, ((Item)dso).getLastModified()) || force)
|
||||
{
|
||||
buildDocument(context, (Item) dso, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* Make sure the item is not in the index if it is not in archive.
|
||||
* TODO: Someday DSIndexer should block withdrawn
|
||||
* content on search/retrieval and allow admins the ablitity to
|
||||
* still search for withdrawn Items.
|
||||
*/
|
||||
DSIndexer.unIndexContent(context, handle);
|
||||
log.info("Removed Item: " + handle + " from Index");
|
||||
}
|
||||
break;
|
||||
|
||||
case Constants.COLLECTION :
|
||||
|
@@ -141,7 +141,10 @@ public class SearchConsumer implements Consumer
|
||||
+ String.valueOf(event.getSubjectID())
|
||||
+ ", perhaps it has been deleted.");
|
||||
else
|
||||
{
|
||||
log.debug("consume() adding event to update queue: " + event.toString());
|
||||
objectsToUpdate.add(subject);
|
||||
}
|
||||
break;
|
||||
|
||||
case Event.REMOVE:
|
||||
@@ -152,7 +155,10 @@ public class SearchConsumer implements Consumer
|
||||
+ String.valueOf(event.getObjectID())
|
||||
+ ", perhaps it has been deleted.");
|
||||
else
|
||||
{
|
||||
log.debug("consume() adding event to update queue: " + event.toString());
|
||||
objectsToUpdate.add(object);
|
||||
}
|
||||
break;
|
||||
|
||||
case Event.DELETE:
|
||||
@@ -160,7 +166,10 @@ public class SearchConsumer implements Consumer
|
||||
if (detail == null)
|
||||
log.warn("got null detail on DELETE event, skipping it.");
|
||||
else
|
||||
{
|
||||
log.debug("consume() adding event to delete queue: " + event.toString());
|
||||
handlesToDelete.add(detail);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log
|
||||
@@ -186,25 +195,24 @@ public class SearchConsumer implements Consumer
|
||||
// update the changed Items not deleted because they were on create list
|
||||
for (DSpaceObject iu : objectsToUpdate)
|
||||
{
|
||||
if (iu.getType() != Constants.ITEM || ((Item) iu).isArchived())
|
||||
/* we let all types through here and
|
||||
* allow the search DSIndexer to make
|
||||
* decisions on indexing and/or removal
|
||||
*/
|
||||
String hdl = iu.getHandle();
|
||||
if (hdl != null && !handlesToDelete.contains(hdl))
|
||||
{
|
||||
// if handle is NOT in list of deleted objects, index it:
|
||||
String hdl = iu.getHandle();
|
||||
if (hdl != null && !handlesToDelete.contains(hdl))
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
DSIndexer.indexContent(ctx, iu, true);
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Indexed "
|
||||
+ Constants.typeText[iu.getType()]
|
||||
+ ", id=" + String.valueOf(iu.getID())
|
||||
+ ", handle=" + hdl);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("Failed while indexing object: ", e);
|
||||
}
|
||||
DSIndexer.indexContent(ctx, iu, true);
|
||||
log.debug("Indexed "
|
||||
+ Constants.typeText[iu.getType()]
|
||||
+ ", id=" + String.valueOf(iu.getID())
|
||||
+ ", handle=" + hdl);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("Failed while indexing object: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user