Package org.candlepin.common.exceptions

Examples of org.candlepin.common.exceptions.NotFoundException


        Consumer c = null;
        Owner o = null;
        if (consumerUuid != null) {
            c = consumerCurator.findByUuid(consumerUuid);
            if (c == null) {
                throw new NotFoundException(i18n.tr("Unit: {0} not found",
                    consumerUuid));
            }

            // Now that we have a consumer, check that this principal can access it:
            if (!principal.canAccess(c, SubResource.NONE, Access.READ_ONLY)) {
                throw new ForbiddenException(i18n.tr("User {0} cannot access unit {1}",
                    principal.getPrincipalName(), consumerUuid));
            }

            if (listAll) {
                o = c.getOwner();
            }
        }
        if (ownerId != null) {
            o = ownerCurator.secureFind(ownerId);
            if (o == null) {
                throw new NotFoundException(i18n.tr("owner: {0}", ownerId));
            }
            // Now that we have an owner, check that this principal can access it:
            if (!principal.canAccess(o, SubResource.POOLS, Access.READ_ONLY)) {
                throw new ForbiddenException(i18n.tr("User {0} cannot access owner {1}",
                    principal.getPrincipalName(), o.getKey()));
View Full Code Here


        Consumer c = null;
        if (consumerUuid != null) {
            c = consumerCurator.findByUuid(consumerUuid);
            if (c == null) {
                throw new NotFoundException(i18n.tr("consumer: {0} not found",
                    consumerUuid));
            }

            if (!principal.canAccess(c, SubResource.NONE, Access.READ_ONLY)) {
                throw new ForbiddenException(i18n.tr("User {0} cannot access consumer {1}",
                    principal.getPrincipalName(), c.getUuid()));
            }
        }

        if (toReturn != null) {
            Date activeOnDate = new Date();
            if (activeOn != null) {
                activeOnDate = ResourceDateParser.parseDateString(activeOn);
            }
            toReturn.setCalculatedAttributes(
                calculatedAttributesUtil
                    .buildCalculatedAttributes(toReturn, c, activeOnDate));
            return toReturn;
        }

        throw new NotFoundException(i18n.tr(
            "Subscription Pool with ID ''{0}'' could not be found.", id));
    }
View Full Code Here

    @Path("/{pool_id}")
    @Produces(MediaType.APPLICATION_JSON)
    public void deletePool(@PathParam("pool_id") String id) {
        Pool pool = poolManager.find(id);
        if (pool == null) {
            throw new NotFoundException(i18n.tr(
                "Entitlement Pool with ID ''{0}'' could not be found.", id));
        }

        poolManager.deletePool(pool);
    }
View Full Code Here

                            @Context Principal principal) {

        Pool pool = poolManager.find(id);

        if (pool == null) {
            throw new NotFoundException(i18n.tr(
                "Subscription Pool with ID ''{0}'' could not be found.", id));
        }

        List<Entitlement> entitlements = new ArrayList<Entitlement>();
        entitlements.addAll(pool.getEntitlements());
View Full Code Here

        guestIdCurator.delete(toDelete);
    }

    private GuestId validateGuestId(GuestId guest, String guestUuid) {
        if (guest == null) {
            throw new NotFoundException(i18n.tr(
                "Guest with uuid {0} could not be found.", guestUuid));
        }
        return guest;
    }
View Full Code Here

            if (e.getProductId().equals(productId)) {
                return e;
            }
        }

        throw new NotFoundException(i18n.tr(
            "Unit ''{0}'' has no subscription for product ''{1}''.",
                consumerUuid, productId));
    }
View Full Code Here

        List<Entitlement> tempList = Arrays.asList(toReturn);
        poolManager.regenerateDirtyEntitlements(tempList);
        if (toReturn != null) {
            return toReturn;
        }
        throw new NotFoundException(
            i18n.tr("Entitlement with ID ''{0}'' could not be found.", dbid));
    }
View Full Code Here

                entitler.adjustEntitlementQuantity(consumer, entitlement,
                    update.getQuantity());
            }
        }
        else {
            throw new NotFoundException(
                i18n.tr("Entitlement with ID ''{0}'' could not be found.", id));
        }
    }
View Full Code Here

    @Path("{dbid}/upstream_cert")
    public String getUpstreamCert(
        @PathParam("dbid") String entitlementId) {
        Entitlement ent = entitlementCurator.find(entitlementId);
        if (ent == null) {
            throw new NotFoundException(i18n.tr(
                "Entitlement with ID ''{0}'' could not be found.", entitlementId));
        }

        String subscriptionId = null;
        Pool entPool = ent.getPool();
        if (StringUtils.isBlank(entPool.getSourceStackId())) {
            subscriptionId = entPool.getSubscriptionId();
        }
        /*
         * A derived pool originating from a stacked parent pool will have no subscription
         * ID as the pool is technically from many subscriptions. (i.e. all the
         * entitlements in the stack) In this case we must look up an active entitlement
         * in the hosts stack, and use this as our upstream certificate.
         */
        else {
            log.debug("Entitlement is from a stack derived pool, searching for oldest " +
                "active entitlements in source stack.");
            Entitlement e = entitlementCurator.findUpstreamEntitlementForStack(
                entPool.getSourceConsumer(),
                entPool.getSourceStackId());
            if (e != null) {
                subscriptionId = e.getPool().getSubscriptionId();
            }
        }

        if (subscriptionId == null) {
            throw new NotFoundException(
                i18n.tr("Unable to find upstream certificate for entitlement: {0}",
                    entitlementId));
        }

        return subResource.getSubCertAsPem(subscriptionId);
View Full Code Here

        Entitlement toDelete = entitlementCurator.find(dbid);
        if (toDelete != null) {
            poolManager.revokeEntitlement(toDelete);
            return;
        }
        throw new NotFoundException(
            i18n.tr("Entitlement with ID ''{0}'' could not be found.", dbid));
    }
View Full Code Here

TOP

Related Classes of org.candlepin.common.exceptions.NotFoundException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.