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:
Mark Diggory
2008-07-30 16:02:47 +00:00
parent 11f50df64a
commit c489a2241f
2 changed files with 38 additions and 18 deletions

View File

@@ -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 :

View File

@@ -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,16 +195,16 @@ 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())
{
// if handle is NOT in list of deleted objects, index it:
/* 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))
{
try
{
DSIndexer.indexContent(ctx, iu, true);
if (log.isDebugEnabled())
log.debug("Indexed "
+ Constants.typeText[iu.getType()]
+ ", id=" + String.valueOf(iu.getID())
@@ -207,7 +216,6 @@ public class SearchConsumer implements Consumer
}
}
}
}
for (String hdl : handlesToDelete)
{