Cleanup for loops and collections.

git-svn-id: http://scm.dspace.org/svn/repo/trunk@2164 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Mark Diggory
2007-08-25 04:31:17 +00:00
parent 62a5122f6e
commit 5178afaabe
2 changed files with 11 additions and 14 deletions

View File

@@ -84,7 +84,7 @@ public class BrowseConsumer implements Consumer
private static Logger log = Logger.getLogger(BrowseConsumer.class);
// items to be updated in browse index
private Set toUpdate = null;
private Set<Item> toUpdate = null;
public void initialize()
throws Exception
@@ -97,7 +97,7 @@ public class BrowseConsumer implements Consumer
{
if(toUpdate == null)
{
toUpdate = new HashSet();
toUpdate = new HashSet<Item>();
}
DSpaceObject subj = event.getSubject(ctx);
@@ -110,14 +110,14 @@ public class BrowseConsumer implements Consumer
// If an Item is created or modified..
case Constants.ITEM:
toUpdate.add(subj);
toUpdate.add((Item)subj);
break;
// track ADD and REMOVE from collections, that changes browse index.
case Constants.COLLECTION:
if (event.getObjectType() == Constants.ITEM
&& (et == Event.ADD || et == Event.REMOVE))
{
DSpaceObject obj = event.getObject(ctx);
Item obj = (Item)event.getObject(ctx);
if (obj != null)
toUpdate.add(obj);
}
@@ -137,9 +137,8 @@ public class BrowseConsumer implements Consumer
{
// Update/Add items
for (Iterator ui = toUpdate.iterator(); ui.hasNext();)
for (Item i : toUpdate)
{
Item i = (Item) ui.next();
// FIXME: there is an exception handling problem here
try
{

View File

@@ -67,10 +67,10 @@ public class SearchConsumer implements Consumer
private static Logger log = Logger.getLogger(SearchConsumer.class);
// collect Items, Collections, Communities that need indexing
private Set objectsToUpdate = null;
private Set<DSpaceObject> objectsToUpdate = null;
// handles to delete since IDs are not useful by now.
private Set handlesToDelete = null;
private Set<String> handlesToDelete = null;
public void initialize() throws Exception
{
@@ -92,8 +92,8 @@ public class SearchConsumer implements Consumer
if (objectsToUpdate == null)
{
objectsToUpdate = new HashSet();
handlesToDelete = new HashSet();
objectsToUpdate = new HashSet<DSpaceObject>();
handlesToDelete = new HashSet<String>();
}
int st = event.getSubjectType();
@@ -179,9 +179,8 @@ public class SearchConsumer implements Consumer
{
// update the changed Items not deleted because they were on create list
for (Iterator ii = objectsToUpdate.iterator(); ii.hasNext();)
for (DSpaceObject iu : objectsToUpdate)
{
DSpaceObject iu = (DSpaceObject) ii.next();
if (iu.getType() != Constants.ITEM || ((Item) iu).isArchived())
{
// if handle is NOT in list of deleted objects, index it:
@@ -205,9 +204,8 @@ public class SearchConsumer implements Consumer
}
}
for (Iterator ii = handlesToDelete.iterator(); ii.hasNext();)
for (String hdl : handlesToDelete)
{
String hdl = (String) ii.next();
try
{
DSIndexer.unIndexContent(ctx, hdl);