try {
PageList<?> results = null;
if (next.getSearchSubsystem() == SearchSubsystem.RESOURCE) {
ResourceCriteria criteria = new ResourceCriteria();
criteria.setRestriction(Restriction.COUNT_ONLY);
criteria.setSearchExpression(next.getPattern());
totalMillis -= System.currentTimeMillis();
results = resourceManager.findResourcesByCriteria(overlord, criteria);
totalMillis += System.currentTimeMillis();
} else if (next.getSearchSubsystem() == SearchSubsystem.GROUP) {
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.setRestriction(Restriction.COUNT_ONLY);
criteria.setSearchExpression(next.getPattern());
totalMillis -= System.currentTimeMillis();
results = resourceGroupManager.findResourceGroupsByCriteria(overlord, criteria);
totalMillis += System.currentTimeMillis();
}