class BadgeResource extends AlpineResource {

    private static final String SVG_MEDIA_TYPE = "image/svg+xml";

    private boolean isBadgeSupportEnabled(final QueryManager qm) {
        ConfigProperty property = qm.getConfigProperty(
                GENERAL_BADGE_ENABLED.getGroupName(), GENERAL_BADGE_ENABLED.getPropertyName());
        return BooleanUtil.valueOf(property.getPropertyValue());
    }

    @GET
    @Path("/vulns/project/{uuid}")
    @Produces(SVG_MEDIA_TYPE)
    @ApiOperation(
            value = "Returns current metrics for a specific project",
            response = ProjectMetrics.class
    )
    @ApiResponses(value = {
            @ApiResponse(code = 204, message = "Badge support is disabled. No content will be returned."),
            @ApiResponse(code = 401, message = "Unauthorized"),
            @ApiResponse(code = 404, message = "The project could not be found")
    })
    @AuthenticationNotRequired
    public Response getProjectVulnerabilitiesBadge(
            @ApiParam(value = "The UUID of the project to retrieve metrics for", format = "uuid", required = true)
            @PathParam("uuid") @ValidUuid String uuid) {
        try (QueryManager qm = new QueryManager()) {
            if (isBadgeSupportEnabled(qm)) {
                final Project project = qm.getObjectByUuid(Project.class, uuid);
                if (project != null) {
                    final ProjectMetrics metrics = qm.getMostRecentProjectMetrics(project);
                    final Badger badger = new Badger();
                    return Response.ok(badger.generateVulnerabilities(metrics)).build();
                } else {
                    return Response.status(Response.Status.NOT_FOUND).entity("The project could not be found.").build();
                }
            } else {
                return Response.status(Response.Status.NO_CONTENT).build();
            }
        }
    }

    @GET
    @Path("/vulns/project/{name}/{version}")
    @Produces(SVG_MEDIA_TYPE)
    @ApiOperation(
            value = "Returns current metrics for a specific project",
            response = ProjectMetrics.class
    )
    @ApiResponses(value = {
            @ApiResponse(code = 204, message = "Badge support is disabled. No content will be returned."),
            @ApiResponse(code = 401, message = "Unauthorized"),
            @ApiResponse(code = 404, message = "The project could not be found")
    })
    @AuthenticationNotRequired
    public Response getProjectVulnerabilitiesBadge(
            @ApiParam(value = "The name of the project to query on", required = true)
            @PathParam("name") String name,
            @ApiParam(value = "The version of the project to query on", required = true)
            @PathParam("version") String version) {
        try (QueryManager qm = new QueryManager()) {
            if (isBadgeSupportEnabled(qm)) {
                final Project project = qm.getProject(name, version);
                if (project != null) {
                    final ProjectMetrics metrics = qm.getMostRecentProjectMetrics(project);
                    final Badger badger = new Badger();
                    return Response.ok(badger.generateVulnerabilities(metrics)).build();
                } else {
                    return Response.status(Response.Status.NOT_FOUND).entity("The project could not be found.").build();
                }
            } else {
                return Response.status(Response.Status.NO_CONTENT).build();
            }
        }
    }

    @GET
    @Path("/violations/project/{uuid}")
    @Produces(SVG_MEDIA_TYPE)
    @ApiOperation(
            value = "Returns a policy violations badge for a specific project",
            response = String.class
    )
    @ApiResponses(value = {
            @ApiResponse(code = 204, message = "Badge support is disabled. No content will be returned."),
            @ApiResponse(code = 401, message = "Unauthorized"),
            @ApiResponse(code = 404, message = "The project could not be found")
    })
    @AuthenticationNotRequired
    public Response getProjectPolicyViolationsBadge(
            @ApiParam(value = "The UUID of the project to retrieve a badge for", format = "uuid", required = true)
            @PathParam("uuid") @ValidUuid String uuid) {
        try (QueryManager qm = new QueryManager()) {
            if (isBadgeSupportEnabled(qm)) {
                final Project project = qm.getObjectByUuid(Project.class, uuid);
                if (project != null) {
                    final ProjectMetrics metrics = qm.getMostRecentProjectMetrics(project);
                    final Badger badger = new Badger();
                    return Response.ok(badger.generateViolations(metrics)).build();
                } else {
                    return Response.status(Response.Status.NOT_FOUND).entity("The project could not be found.").build();
                }
            } else {
                return Response.status(Response.Status.NO_CONTENT).build();
            }
        }
    }

    @GET
    @Path("/violations/project/{name}/{version}")
    @Produces(SVG_MEDIA_TYPE)
    @ApiOperation(
            value = "Returns a policy violations badge for a specific project",
            response = String.class
    )
    @ApiResponses(value = {
            @ApiResponse(code = 204, message = "Badge support is disabled. No content will be returned."),
            @ApiResponse(code = 401, message = "Unauthorized"),
            @ApiResponse(code = 404, message = "The project could not be found")
    })
    @AuthenticationNotRequired
    public Response getProjectPolicyViolationsBadge(
            @ApiParam(value = "The name of the project to query on", required = true)
            @PathParam("name") String name,
            @ApiParam(value = "The version of the project to query on", required = true)
            @PathParam("version") String version) {<FILL_FUNCTION_BODY>}
}

        try (QueryManager qm = new QueryManager()) {
            if (isBadgeSupportEnabled(qm)) {
                final Project project = qm.getProject(name, version);
                if (project != null) {
                    final ProjectMetrics metrics = qm.getMostRecentProjectMetrics(project);
                    final Badger badger = new Badger();
                    return Response.ok(badger.generateViolations(metrics)).build();
                } else {
                    return Response.status(Response.Status.NOT_FOUND).entity("The project could not be found.").build();
                }
            } else {
                return Response.status(Response.Status.NO_CONTENT).build();
            }
        }
    
<no_super_class>