use of org.candlepin.version.CertVersionConflictException 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