Refactor ItemCounter and ItemCountDAO to act like other DSpace beans. Also ensure they do not cache a Context object.

This commit is contained in:
Tim Donohue
2024-05-15 09:22:35 -05:00
parent 1517e8cd0f
commit 78f1e4190e
15 changed files with 77 additions and 268 deletions

View File

@@ -31,7 +31,6 @@ import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.ResourcePolicy;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.authorize.service.ResourcePolicyService;
import org.dspace.browse.ItemCountException;
import org.dspace.browse.ItemCounter;
import org.dspace.content.dao.CollectionDAO;
import org.dspace.content.service.BitstreamService;
@@ -122,6 +121,9 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
@Autowired(required = true)
protected ConfigurationService configurationService;
@Autowired
protected ItemCounter itemCounter;
protected CollectionServiceImpl() {
super();
}
@@ -1112,12 +1114,12 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
/**
* Returns total collection archived items
*
* @param context DSpace Context
* @param collection Collection
* @return total collection archived items
* @throws ItemCountException
*/
@Override
public int countArchivedItems(Collection collection) throws ItemCountException {
return ItemCounter.getInstance().getCount(collection);
public int countArchivedItems(Context context, Collection collection) {
return itemCounter.getCount(context, collection);
}
}