use of org.candlepin.model.activationkeys.ActivationKeyPool in project candlepin by candlepin.
the class PoolCurator method getActivationKeysForPool.
public List<ActivationKey> getActivationKeysForPool(Pool p) {
List<ActivationKey> activationKeys = new ArrayList<>();
List<ActivationKeyPool> activationKeyPools = currentSession().createCriteria(ActivationKeyPool.class).add(Restrictions.eq("pool", p)).list();
for (ActivationKeyPool akp : activationKeyPools) {
activationKeys.add(akp.getKey());
}
return activationKeys;
}
use of org.candlepin.model.activationkeys.ActivationKeyPool in project candlepin by candlepin.
the class ConsumerBindUtil method handleActivationKeyAutoBind.
private void handleActivationKeyAutoBind(Consumer consumer, ActivationKey key) throws AutobindDisabledForOwnerException {
try {
Set<String> productIds = new HashSet<>();
List<String> poolIds = new ArrayList<>();
for (Product akp : key.getProducts()) {
productIds.add(akp.getId());
}
for (ConsumerInstalledProduct cip : consumer.getInstalledProducts()) {
productIds.add(cip.getProductId());
}
for (ActivationKeyPool p : key.getPools()) {
poolIds.add(p.getPool().getId());
}
Owner owner = ownerCurator.findOwnerById(consumer.getOwnerId());
AutobindData autobindData = AutobindData.create(consumer, owner).forProducts(productIds.toArray(new String[0])).withPools(poolIds);
List<Entitlement> ents = entitler.bindByProducts(autobindData);
entitler.sendEvents(ents);
} catch (ForbiddenException fe) {
throw fe;
} catch (CertVersionConflictException cvce) {
throw cvce;
} catch (RuntimeException re) {
log.warn("Unable to attach a subscription for a product that " + "has no pool: " + re.getMessage());
}
}
Aggregations