Just realized, this code is in the EntitlementResource, but it should really be moved to EntitlementCurator, that's where I believe we try to do most "data integrity" things like this. I also think it's in line with your comment that we're doing too much in resources recently (I can't find where this was now though).
I just hit another scenario where I need to do something similar when deleting an entitlement.
Cheers,
Devan
On Mon, Mar 22, 2010 at 9:17 PM, Adam Young ayoung@redhat.com wrote:
If you see the above error, it seems to mean that a delete is violating a constraint.
I got this exception with the following code:
@DELETE @Path("/{dbid}") public void unbind(@PathParam("dbid") Long dbid) {
Entitlement toDelete = entitlementCurator.find(dbid); if (toDelete != null) { //toDelete.getConsumer().getEntitlements().remove(toDelete); entitlementCurator.delete(toDelete); return; } throw new NotFoundException( "Entitlement with ID '" + dbid + "' could not be found"); }
To get rid of the error, uncomment out the line //toDelete...
candlepin mailing list candlepin@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/candlepin