use of org.candlepin.common.exceptions.ForbiddenException in project candlepin by candlepin.
the class OwnerContentResource method updateContent.
@ApiOperation(notes = "Updates a Content", value = "updateContent")
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{content_id}")
public ContentDTO updateContent(@PathParam("owner_key") String ownerKey, @PathParam("content_id") String contentId, @ApiParam(name = "content", required = true) ContentDTO content) {
Owner owner = this.getOwnerByKey(ownerKey);
Content existing = this.fetchContent(owner, contentId);
if (existing.isLocked()) {
throw new ForbiddenException(i18n.tr("content \"{0}\" is locked", existing.getId()));
}
existing = this.contentManager.updateContent(content, owner, true);
ownerManager.refreshOwnerForContentAccess(owner);
return this.translator.translate(existing, ContentDTO.class);
}
use of org.candlepin.common.exceptions.ForbiddenException 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