use of org.jboss.resteasy.spi.BadRequestException in project candlepin by candlepin.
the class HealEntireOrgJob method toExecute.
@Override
public void toExecute(JobExecutionContext ctx) throws JobExecutionException {
try {
// NOTE: ownerId is actually the owner key here.
JobDataMap map = ctx.getMergedJobDataMap();
String ownerId = (String) map.get("ownerId");
Owner owner = ownerCurator.lookupByKey(ownerId);
if (owner.isAutobindDisabled()) {
throw new BadRequestException(i18n.tr("Auto-attach is disabled for owner {0}.", owner.getKey()));
}
Date entitleDate = (Date) map.get("entitle_date");
for (String uuid : ownerCurator.getConsumerUuids(owner).list()) {
// of looking up the non or partially compliant products to bind.
try {
Consumer consumer = consumerCurator.getConsumer(uuid);
healSingleConsumer(consumer, owner, entitleDate);
}// Perhaps add something to surface errors later
catch (Exception e) {
log.debug("Healing failed for UUID \"{}\" with message: {}", uuid, e.getMessage());
}
}
} catch (Exception e) {
log.error("EntitlerJob encountered a problem.", e);
ctx.setResult(e.getMessage());
throw new JobExecutionException(e.getMessage(), e, false);
}
}
Aggregations