CommitRest { @GET @Path("{commitId}/history") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Retrieves the Commit history specified by the provided ID.") public Response getCommitHistory(@Context UriInfo uriInfo, @PathParam("commitId") String commitId, @QueryParam("targetId") String targetId, @QueryParam("entityId") String entityId, @QueryParam("offset") int offset, @QueryParam("limit") int limit) { long start = System.currentTimeMillis(); try { LinksUtils.validateParams(limit, offset); try { final List<Commit> commits; if (StringUtils.isBlank(targetId) && StringUtils.isBlank(entityId)) { commits = catalogManager.getCommitChain(vf.createIRI(commitId)); } else if (StringUtils.isNotBlank(targetId) && StringUtils.isBlank(entityId)) { commits = catalogManager.getCommitChain(vf.createIRI(commitId), vf.createIRI(targetId)); } else if (StringUtils.isBlank(targetId) && StringUtils.isNotBlank(entityId)) { commits = catalogManager.getCommitEntityChain(vf.createIRI(commitId), vf.createIRI(entityId)); } else { commits = catalogManager.getCommitEntityChain(vf.createIRI(commitId), vf.createIRI(targetId), vf.createIRI(entityId)); } Stream<Commit> result = commits.stream(); if (limit > 0) { result = result.skip(offset) .limit(limit); } ArrayNode commitChain = mapper.createArrayNode(); result.map(r -> createCommitJson(r, vf, engineManager)) .forEach(commitChain::add); return createPaginatedResponseWithJsonNode(uriInfo, commitChain, commits.size(), limit, offset); } 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); } } finally { logger.trace("getCommitHistory took {}ms", System.currentTimeMillis() - start); } }  @GET @Path("{commitId}") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Retrieves the Commit specified by the provided ID.") Response getCommit(@PathParam("commitId") String commitId,
                       @DefaultValue("jsonld") @QueryParam("format") String format); @GET @Path("{commitId}/history") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Retrieves the Commit history specified by the provided ID.") Response getCommitHistory(@Context UriInfo uriInfo,
                              @PathParam("commitId") String commitId,
                              @QueryParam("targetId") String targetId,
                              @QueryParam("entityId") String entityId,
                              @QueryParam("offset") int offset,
                              @QueryParam("limit") int limit); @GET @Path("{commitId}/resource") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Retrieves the Commit specified by the provided ID.") Response getCompiledResource(@PathParam("commitId") String commitId,
                                 @QueryParam("entityId") String entityId); @GET @Path("{sourceId}/difference") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Retrieves the Difference of the two specified Commits.") Response getDifference(@PathParam("sourceId") String sourceId,
                                  @QueryParam("targetId") String targetId,
                                  @DefaultValue("jsonld") @QueryParam("format") String rdfFormat);  }
@Test public void getCommitHistoryTest() { Response response = target().path("commits/" + encode(COMMIT_IRIS[1]) + "/history") .request().get(); assertEquals(response.getStatus(), 200); verify(catalogManager).getCommitChain(vf.createIRI(COMMIT_IRIS[1])); MultivaluedMap<String, Object> headers = response.getHeaders(); assertEquals(headers.get("X-Total-Count").get(0), "" + COMMIT_IRIS.length); assertEquals(response.getLinks().size(), 0); try { JSONArray array = JSONArray.fromObject(response.readEntity(String.class)); assertEquals(array.size(), COMMIT_IRIS.length); array.forEach(result -> { JSONObject commitObj = JSONObject.fromObject(result); assertTrue(commitObj.containsKey("id")); assertTrue(Arrays.asList(COMMIT_IRIS).contains(commitObj.getString("id"))); }); } catch (Exception e) { fail("Expected no exception, but got: " + e.getMessage()); } }