class CatalogRest {

    @GET
    @Path("{catalogId}/records/{recordId}/branches")
    @Produces(MediaType.APPLICATION_JSON)
    @RolesAllowed("user")
    @ApiOperation("Gets list of Branches associated with a specific VersionedRDFRecord.")
    @ResourceId(type = ValueType.PATH, value = "recordId")
    public Response getBranches(@Context ContainerRequestContext context,
                         @Context UriInfo uriInfo,
                         @PathParam("catalogId") String catalogId,
                         @PathParam("recordId") String recordId,
                         @QueryParam("sort") String sort,
                         @DefaultValue("0") @QueryParam("offset") int offset,
                         @DefaultValue("100") @QueryParam("limit") int limit,
                         @DefaultValue("true") @QueryParam("ascending") boolean asc,
                         @DefaultValue("false") @QueryParam("applyUserFilter") boolean applyUserFilter) {
        try {
            validatePaginationParams(sort, SORT_RESOURCES, limit, offset);
            Set<Branch> branches = catalogManager.getBranches(vf.createIRI(catalogId), vf.createIRI(recordId));
            Function<Branch, Boolean> filterFunction = null;
            if (applyUserFilter) {
                User activeUser = getActiveUser(context, engineManager);
                filterFunction = branch -> {
                    Set<String> types = branch.getProperties(vf.createIRI(RDF.TYPE.stringValue())).stream()
                            .map(Value::stringValue)
                            .collect(Collectors.toSet());
                    return !types.contains(UserBranch.TYPE)
                           || branch.getProperty(vf.createIRI(DCTERMS.PUBLISHER.stringValue())).get()
                                    .stringValue().equals(activeUser.getResource().stringValue());
                };
            }
            return createPaginatedThingResponseJackson(uriInfo, branches, vf.createIRI(sort), offset, limit,
                    asc, filterFunction,
                    Branch.TYPE, transformer, bNodeService);
        } catch (IllegalArgumentException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.BAD_REQUEST);
        } catch (MobiException ex) {
            throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
        }
    }

}