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

View File

@@ -67,10 +67,10 @@ public class SearchConsumer implements Consumer
private static Logger log = Logger.getLogger(SearchConsumer.class); private static Logger log = Logger.getLogger(SearchConsumer.class);
// collect Items, Collections, Communities that need indexing // 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. // handles to delete since IDs are not useful by now.
private Set handlesToDelete = null; private Set<String> handlesToDelete = null;
public void initialize() throws Exception public void initialize() throws Exception
{ {
@@ -92,8 +92,8 @@ public class SearchConsumer implements Consumer
if (objectsToUpdate == null) if (objectsToUpdate == null)
{ {
objectsToUpdate = new HashSet(); objectsToUpdate = new HashSet<DSpaceObject>();
handlesToDelete = new HashSet(); handlesToDelete = new HashSet<String>();
} }
int st = event.getSubjectType(); 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 // 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 (iu.getType() != Constants.ITEM || ((Item) iu).isArchived())
{ {
// if handle is NOT in list of deleted objects, index it: // 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 try
{ {
DSIndexer.unIndexContent(ctx, hdl); DSIndexer.unIndexContent(ctx, hdl);