Package org.candlepin.common.exceptions

Examples of org.candlepin.common.exceptions.BadRequestException


        ConflictOverrides overrides = null;
        try {
            overrides = new ConflictOverrides(overrideConflicts);
        }
        catch (IllegalArgumentException e) {
            throw new BadRequestException(i18n.tr("Unknown conflict to force"));
        }

        String filename = "";
        Owner owner = findOwner(ownerKey);
        Map<String, Object> data = new HashMap<String, Object>();
        try {
            InputPart part = input.getParts().get(0);
            MultivaluedMap<String, String> headers = part.getHeaders();
            String contDis = headers.getFirst("Content-Disposition");
            StringTokenizer st = new StringTokenizer(contDis, ";");
            while (st.hasMoreTokens()) {
                String entry = st.nextToken().trim();
                if (entry.startsWith("filename")) {
                    filename = entry.substring(entry.indexOf("=") + 2, entry.length() - 1);
                    break;
                }
            }
            File archive = part.getBody(new GenericType<File>() {
            });
            log.info("Importing archive " + archive.getAbsolutePath() +
                " for owner " + owner.getDisplayName());
            data = importer.loadExport(owner, archive, overrides);

            sink.emitImportCreated(owner);
            recordImportSuccess(owner, data, overrides, filename);
        }
        catch (IOException e) {
            recordImportFailure(owner, data, e, filename);
            throw new IseException(i18n.tr("Error reading export archive"), e);
        }
        // These come back with internationalized messages, so we can transfer:
        catch (SyncDataFormatException e) {
            recordImportFailure(owner, data, e, filename);
            throw new BadRequestException(e.getMessage(), e);
        }
        catch (ImporterException e) {
            recordImportFailure(owner, data, e, filename);
            throw new IseException(e.getMessage(), e);
        }
View Full Code Here


        try {
            return ueberCertGenerator.generate(o, principal);
        }
        catch (Exception e) {
            log.error("Problem generating ueber cert for owner: " + o.getKey(), e);
            throw new BadRequestException(i18n.tr(
                "Problem generating ueber cert for owner {0}", e));
        }
    }
View Full Code Here

        if (OWNER.equals(entity)) {
            return migrateOwner(key, url, delete);
        }

        throw new BadRequestException(i18n.tr("Bad entity value."));
    }
View Full Code Here

                " for virtual systems.", pool.getId());
        }
        else {
            msg = error;
        }
        throw new BadRequestException(msg);
    }
View Full Code Here

        return detail;
    }

    private static void validateInput(String key, String uri) {
        if (StringUtils.isEmpty(key)) {
            throw new BadRequestException("Invalid owner key");
        }

        if (StringUtils.isEmpty(uri)) {
            throw new BadRequestException("Invalid URL [" + uri + "]");
        }

        try {
            new URL(uri);
        }
        catch (MalformedURLException e) {
            throw new BadRequestException("Invalid URL [" + uri + "]", e);
        }

    }
View Full Code Here

     */
    @Transactional
    public List<Consumer> getGuests(Consumer consumer) {
        if (consumer.getFact("virt.uuid") != null &&
            !consumer.getFact("virt.uuid").trim().equals("")) {
            throw new BadRequestException(i18n.tr(
                "The system with UUID {0} is a virtual guest. " +
                "It does not have guests.",
                consumer.getUuid()));
        }
        List<Consumer> guests = new ArrayList<Consumer>();
View Full Code Here

            }
        }
        if (!invalidOverrides.isEmpty()) {
            String error = i18n.tr("Not allowed to override values for: {0}",
                StringUtils.join(invalidOverrides, ", "));
            throw new BadRequestException(error);
        }
    }
View Full Code Here

        }
        if (!invalidServiceLevels.isEmpty()) {
            String error = i18n.tr("Service level ''{0}'' is not available " +
                "to units of organization {1}.",
                StringUtils.join(invalidServiceLevels, ", "), owner.getKey());
            throw new BadRequestException(error);
        }
    }
View Full Code Here

        @PathParam("report_key") String reportKey) {
        Report r = this.reportFactory.getReport(reportKey);
        if (r == null) {
            // TODO: Throw an appropriate exception once they are moved
            //       into candlepin-common.
            throw new BadRequestException("Report " + reportKey + " not found.");
        }
        return r.run(uriInfo.getQueryParameters());
    }
View Full Code Here

                String label = type.getLabel();
                if (labels.contains(label)) {
                    invalidLabels.remove(label);
                }
            }
            throw new BadRequestException(i18n.tr("No such unit type(s): {0}",
                StringUtils.join(invalidLabels, ", ")));
        }
        return types;
    }
View Full Code Here

TOP

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

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.