consumerUuid));
}
// Now that we have a consumer, check that this principal can access it:
if (!principal.canAccess(c, SubResource.NONE, Access.READ_ONLY)) {
throw new ForbiddenException(i18n.tr("User {0} cannot access unit {1}",
principal.getPrincipalName(), consumerUuid));
}
if (listAll) {
o = c.getOwner();
}
}
if (ownerId != null) {
o = ownerCurator.secureFind(ownerId);
if (o == null) {
throw new NotFoundException(i18n.tr("owner: {0}", ownerId));
}
// Now that we have an owner, check that this principal can access it:
if (!principal.canAccess(o, SubResource.POOLS, Access.READ_ONLY)) {
throw new ForbiddenException(i18n.tr("User {0} cannot access owner {1}",
principal.getPrincipalName(), o.getKey()));
}
}
// If we have no consumer, and no owner specified, kick 'em out unless they
// have full system access (this is the same as requesting all pools in
// the system).
if (consumerUuid == null && ownerId == null && !principal.hasFullAccess()) {
throw new ForbiddenException(i18n.tr("User {0} cannot access all pools.",
principal.getPrincipalName()));
}
Page<List<Pool>> page = poolManager.listAvailableEntitlementPools(c, null, o,
productId, activeOnDate, true, listAll, new PoolFilterBuilder(), pageRequest);