Improve debug logging and correct null pointer errors in Browse and Search Consumers.

git-svn-id: http://scm.dspace.org/svn/repo/trunk@3009 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Mark Diggory
2008-07-30 05:54:54 +00:00
parent 3cc6980155
commit 5920b3bb9f
2 changed files with 18 additions and 21 deletions

View File

@@ -93,7 +93,8 @@ public class BrowseConsumer implements Consumer
toUpdate = new HashSet<Item>();
}
DSpaceObject subj = event.getSubject(ctx);
log.debug("consume() evaluating event: " + event.toString());
int st = event.getSubjectType();
int et = event.getEventType();
@@ -101,9 +102,17 @@ public class BrowseConsumer implements Consumer
switch (st)
{
// If an Item is created or modified..
// If an Item is created or its metadata is modified..
case Constants.ITEM:
toUpdate.add((Item)subj);
if(et == Event.MODIFY_METADATA || et == Event.CREATE)
{
DSpaceObject subj = event.getSubject(ctx);
if (subj != null)
{
log.debug("consume() adding event to update queue: " + event.toString());
toUpdate.add((Item)subj);
}
}
break;
// track ADD and REMOVE from collections, that changes browse index.
case Constants.COLLECTION:
@@ -112,12 +121,14 @@ public class BrowseConsumer implements Consumer
{
Item obj = (Item)event.getObject(ctx);
if (obj != null)
{
log.debug("consume() adding event to update queue: " + event.toString());
toUpdate.add(obj);
}
}
break;
default:
log.warn("consume() got unrecognized event: " + event.toString());
log.debug("consume() ingnoring event: " + event.toString());
}
}
@@ -132,11 +143,6 @@ public class BrowseConsumer implements Consumer
// Update/Add items
for (Item i : toUpdate)
{
if (i == null)
{
continue;
}
// FIXME: there is an exception handling problem here
try
{

View File

@@ -99,17 +99,6 @@ public class SearchConsumer implements Consumer
int st = event.getSubjectType();
if (!(st == Constants.ITEM || st == Constants.BUNDLE
|| st == Constants.COLLECTION || st == Constants.COMMUNITY))
{
log.warn("SearchConsumer should not have been given this "
+ "kind of Subject in an event, skipping: "
+ event.toString());
return;
}
DSpaceObject subject = event.getSubject(ctx);
int obj = event.getSubjectType();
if (!(obj == Constants.ITEM || obj == Constants.BUNDLE
|| obj == Constants.COLLECTION || obj == Constants.COMMUNITY))
{
log
.warn("SearchConsumer should not have been given this kind of Object in an event, skipping: "
@@ -117,6 +106,8 @@ public class SearchConsumer implements Consumer
return;
}
DSpaceObject subject = event.getSubject(ctx);
DSpaceObject object = event.getObject(ctx);