class CatalogRest {

    @GET
    @Path("{catalogId}/records/{recordId}/branches/{branchId}/commits/{commitId}/resource")
    @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
    @RolesAllowed("user")
    @ApiOperation("Gets the compiled resource for a the entity identified by a specific Commit.")
    @ResourceId(type = ValueType.PATH, value = "recordId")
    public Response getCompiledResource(@Context ContainerRequestContext context,
                                 @PathParam("catalogId") String catalogId,
                                 @PathParam("recordId") String recordId,
                                 @PathParam("branchId") String branchId,
                                 @PathParam("commitId") String commitId,
                                 @DefaultValue("jsonld") @QueryParam("format") String rdfFormat,
                                 @DefaultValue("false") @QueryParam("applyInProgressCommit") boolean apply) {
        try {
            Resource catalogIRI = vf.createIRI(catalogId);
            Resource recordIRI = vf.createIRI(recordId);
            Resource commitIRI = vf.createIRI(commitId);
            catalogManager.getCommit(catalogIRI, recordIRI, vf.createIRI(branchId), commitIRI);
            Model resource = catalogManager.getCompiledResource(commitIRI);
            if (apply) {
                User activeUser = getActiveUser(context, engineManager);
                Optional<InProgressCommit> inProgressCommit = catalogManager.getInProgressCommit(catalogIRI, recordIRI,
                        activeUser);
                if (inProgressCommit.isPresent()) {
                    resource = catalogManager.applyInProgressCommit(inProgressCommit.get().getResource(), resource);
                }
            }
            return Response.ok(modelToSkolemizedString(resource, rdfFormat, transformer, bNodeService)).build();
        } catch (IllegalArgumentException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.BAD_REQUEST);
        } catch (IllegalStateException | MobiException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
        }
    }

}