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; Item item = (Item)dso;
if (item.isArchived() && !item.isWithdrawn()) 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) if (requiresIndexing(t, ((Item)dso).getLastModified()) || force)
{ {
buildDocument(context, (Item) dso, t); 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; break;
case Constants.COLLECTION : case Constants.COLLECTION :

View File

@@ -141,7 +141,10 @@ public class SearchConsumer implements Consumer
+ String.valueOf(event.getSubjectID()) + String.valueOf(event.getSubjectID())
+ ", perhaps it has been deleted."); + ", perhaps it has been deleted.");
else else
{
log.debug("consume() adding event to update queue: " + event.toString());
objectsToUpdate.add(subject); objectsToUpdate.add(subject);
}
break; break;
case Event.REMOVE: case Event.REMOVE:
@@ -152,7 +155,10 @@ public class SearchConsumer implements Consumer
+ String.valueOf(event.getObjectID()) + String.valueOf(event.getObjectID())
+ ", perhaps it has been deleted."); + ", perhaps it has been deleted.");
else else
{
log.debug("consume() adding event to update queue: " + event.toString());
objectsToUpdate.add(object); objectsToUpdate.add(object);
}
break; break;
case Event.DELETE: case Event.DELETE:
@@ -160,7 +166,10 @@ public class SearchConsumer implements Consumer
if (detail == null) if (detail == null)
log.warn("got null detail on DELETE event, skipping it."); log.warn("got null detail on DELETE event, skipping it.");
else else
{
log.debug("consume() adding event to delete queue: " + event.toString());
handlesToDelete.add(detail); handlesToDelete.add(detail);
}
break; break;
default: default:
log log
@@ -186,25 +195,24 @@ public class SearchConsumer implements Consumer
// update the changed Items not deleted because they were on create list // update the changed Items not deleted because they were on create list
for (DSpaceObject iu : objectsToUpdate) 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: try
String hdl = iu.getHandle();
if (hdl != null && !handlesToDelete.contains(hdl))
{ {
try DSIndexer.indexContent(ctx, iu, true);
{ log.debug("Indexed "
DSIndexer.indexContent(ctx, iu, true); + Constants.typeText[iu.getType()]
if (log.isDebugEnabled()) + ", id=" + String.valueOf(iu.getID())
log.debug("Indexed " + ", handle=" + hdl);
+ Constants.typeText[iu.getType()] }
+ ", id=" + String.valueOf(iu.getID()) catch (Exception e)
+ ", handle=" + hdl); {
} log.error("Failed while indexing object: ", e);
catch (Exception e)
{
log.error("Failed while indexing object: ", e);
}
} }
} }
} }