{"action":"created","comment":{"url":"https://api.github.com/repos/openregister/presentation/pulls/comments/39273719","id":39273719,"diff_hunk":"@@ -0,0 +1,61 @@\n+package uk.gov.register.presentation.resource;\n+\n+import com.fasterxml.jackson.core.JsonGenerator;\n+import com.fasterxml.jackson.databind.JsonSerializer;\n+import com.fasterxml.jackson.databind.SerializerProvider;\n+import com.fasterxml.jackson.databind.annotation.JsonSerialize;\n+import uk.gov.register.presentation.Version;\n+import uk.gov.register.presentation.dao.RecentEntryIndexQueryDAO;\n+import uk.gov.register.thymeleaf.ThymeleafView;\n+\n+import javax.inject.Inject;\n+import javax.ws.rs.*;\n+import javax.ws.rs.core.MediaType;\n+import java.io.IOException;\n+import java.util.List;\n+import java.util.stream.Collectors;\n+\n+@Path(\"/\")\n+public class HistoryResource {\n+    private final RequestContext requestContext;\n+    private final RecentEntryIndexQueryDAO queryDAO;\n+\n+    @Inject\n+    public HistoryResource(RequestContext requestContext, RecentEntryIndexQueryDAO queryDAO) {\n+        this.requestContext = requestContext;\n+        this.queryDAO = queryDAO;\n+    }\n+\n+    @GET\n+    @Path(\"/{primaryKey}/{primaryKeyValue}/history\")\n+    @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})\n+    public ListVersionView history(@PathParam(\"primaryKey\") String key, @PathParam(\"primaryKeyValue\") String value) {\n+        String registerPrimaryKey = requestContext.getRegisterPrimaryKey();\n+        if (key.equals(registerPrimaryKey)) {\n+            return new ListVersionView(requestContext, queryDAO.findAllByKeyValue(key, value).stream().map(r -> new Version(r.getHash())).collect(Collectors.toList()));\n+        }\n+        throw new NotFoundException();\n+    }\n+\n+    @JsonSerialize(using = VersionJsonSerializer.class)\n+    public static class ListVersionView extends ThymeleafView {\n+        private final List<Version> versions;\n+\n+        public ListVersionView(RequestContext requestContext, List<Version> versions) {\n+            super(requestContext, \"versions.html\");\n+            this.versions = versions;\n+        }\n+\n+        public List<Version> getVersions() {\n+            return versions;\n+        }\n+    }\n+\n+    private static class VersionJsonSerializer extends JsonSerializer<ListVersionView> {","path":"src/main/java/uk/gov/register/presentation/resource/HistoryResource.java","position":null,"original_position":54,"commit_id":"01342ad42c9273d4506bf4052e48440f10121053","original_commit_id":"e8cdf05d0954eddc08da067540501165035060bd","user":{"login":"om-sharma","id":8011952,"avatar_url":"https://avatars.githubusercontent.com/u/8011952?v=3","gravatar_id":"","url":"https://api.github.com/users/om-sharma","html_url":"https://github.com/om-sharma","followers_url":"https://api.github.com/users/om-sharma/followers","following_url":"https://api.github.com/users/om-sharma/following{/other_user}","gists_url":"https://api.github.com/users/om-sharma/gists{/gist_id}","starred_url":"https://api.github.com/users/om-sharma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/om-sharma/subscriptions","organizations_url":"https://api.github.com/users/om-sharma/orgs","repos_url":"https://api.github.com/users/om-sharma/repos","events_url":"https://api.github.com/users/om-sharma/events{/privacy}","received_events_url":"https://api.github.com/users/om-sharma/received_events","type":"User","site_admin":false},"body":"Renamed to ListVersionViewJsonSerializer in next commit.","created_at":"2015-09-11T14:03:26Z","updated_at":"2015-09-11T14:03:26Z","html_url":"https://github.com/openregister/presentation/pull/56#discussion_r39273719","pull_request_url":"https://api.github.com/repos/openregister/presentation/pulls/56","_links":{"self":{"href":"https://api.github.com/repos/openregister/presentation/pulls/comments/39273719"},"html":{"href":"https://github.com/openregister/presentation/pull/56#discussion_r39273719"},"pull_request":{"href":"https://api.github.com/repos/openregister/presentation/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/openregister/presentation/pulls/56","id":44763501,"html_url":"https://github.com/openregister/presentation/pull/56","diff_url":"https://github.com/openregister/presentation/pull/56.diff","patch_url":"https://github.com/openregister/presentation/pull/56.patch","issue_url":"https://api.github.com/repos/openregister/presentation/issues/56","number":56,"state":"open","locked":false,"title":"Implemented history resource","user":{"login":"om-sharma","id":8011952,"avatar_url":"https://avatars.githubusercontent.com/u/8011952?v=3","gravatar_id":"","url":"https://api.github.com/users/om-sharma","html_url":"https://github.com/om-sharma","followers_url":"https://api.github.com/users/om-sharma/followers","following_url":"https://api.github.com/users/om-sharma/following{/other_user}","gists_url":"https://api.github.com/users/om-sharma/gists{/gist_id}","starred_url":"https://api.github.com/users/om-sharma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/om-sharma/subscriptions","organizations_url":"https://api.github.com/users/om-sharma/orgs","repos_url":"https://api.github.com/users/om-sharma/repos","events_url":"https://api.github.com/users/om-sharma/events{/privacy}","received_events_url":"https://api.github.com/users/om-sharma/received_events","type":"User","site_admin":false},"body":"Added history page and a resource to return all the versions of an entry.","created_at":"2015-09-11T09:41:20Z","updated_at":"2015-09-11T14:03:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b21fcef68b26479efa72b190985f3215162a317c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openregister/presentation/pulls/56/commits","review_comments_url":"https://api.github.com/repos/openregister/presentation/pulls/56/comments","review_comment_url":"https://api.github.com/repos/openregister/presentation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openregister/presentation/issues/56/comments","statuses_url":"https://api.github.com/repos/openregister/presentation/statuses/01342ad42c9273d4506bf4052e48440f10121053","head":{"label":"openregister:history","ref":"history","sha":"01342ad42c9273d4506bf4052e48440f10121053","user":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"repo":{"id":38381661,"name":"presentation","full_name":"openregister/presentation","owner":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openregister/presentation","description":"Read-only register application","fork":false,"url":"https://api.github.com/repos/openregister/presentation","forks_url":"https://api.github.com/repos/openregister/presentation/forks","keys_url":"https://api.github.com/repos/openregister/presentation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openregister/presentation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openregister/presentation/teams","hooks_url":"https://api.github.com/repos/openregister/presentation/hooks","issue_events_url":"https://api.github.com/repos/openregister/presentation/issues/events{/number}","events_url":"https://api.github.com/repos/openregister/presentation/events","assignees_url":"https://api.github.com/repos/openregister/presentation/assignees{/user}","branches_url":"https://api.github.com/repos/openregister/presentation/branches{/branch}","tags_url":"https://api.github.com/repos/openregister/presentation/tags","blobs_url":"https://api.github.com/repos/openregister/presentation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openregister/presentation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openregister/presentation/git/refs{/sha}","trees_url":"https://api.github.com/repos/openregister/presentation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openregister/presentation/statuses/{sha}","languages_url":"https://api.github.com/repos/openregister/presentation/languages","stargazers_url":"https://api.github.com/repos/openregister/presentation/stargazers","contributors_url":"https://api.github.com/repos/openregister/presentation/contributors","subscribers_url":"https://api.github.com/repos/openregister/presentation/subscribers","subscription_url":"https://api.github.com/repos/openregister/presentation/subscription","commits_url":"https://api.github.com/repos/openregister/presentation/commits{/sha}","git_commits_url":"https://api.github.com/repos/openregister/presentation/git/commits{/sha}","comments_url":"https://api.github.com/repos/openregister/presentation/comments{/number}","issue_comment_url":"https://api.github.com/repos/openregister/presentation/issues/comments{/number}","contents_url":"https://api.github.com/repos/openregister/presentation/contents/{+path}","compare_url":"https://api.github.com/repos/openregister/presentation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openregister/presentation/merges","archive_url":"https://api.github.com/repos/openregister/presentation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openregister/presentation/downloads","issues_url":"https://api.github.com/repos/openregister/presentation/issues{/number}","pulls_url":"https://api.github.com/repos/openregister/presentation/pulls{/number}","milestones_url":"https://api.github.com/repos/openregister/presentation/milestones{/number}","notifications_url":"https://api.github.com/repos/openregister/presentation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openregister/presentation/labels{/name}","releases_url":"https://api.github.com/repos/openregister/presentation/releases{/id}","created_at":"2015-07-01T16:17:58Z","updated_at":"2015-07-16T09:18:23Z","pushed_at":"2015-09-11T14:01:33Z","git_url":"git://github.com/openregister/presentation.git","ssh_url":"git@github.com:openregister/presentation.git","clone_url":"https://github.com/openregister/presentation.git","svn_url":"https://github.com/openregister/presentation","homepage":"","size":1840,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"openregister:master","ref":"master","sha":"e88bab14e1f4abf21b5a378f6ac89c0e753048a0","user":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"repo":{"id":38381661,"name":"presentation","full_name":"openregister/presentation","owner":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openregister/presentation","description":"Read-only register application","fork":false,"url":"https://api.github.com/repos/openregister/presentation","forks_url":"https://api.github.com/repos/openregister/presentation/forks","keys_url":"https://api.github.com/repos/openregister/presentation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openregister/presentation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openregister/presentation/teams","hooks_url":"https://api.github.com/repos/openregister/presentation/hooks","issue_events_url":"https://api.github.com/repos/openregister/presentation/issues/events{/number}","events_url":"https://api.github.com/repos/openregister/presentation/events","assignees_url":"https://api.github.com/repos/openregister/presentation/assignees{/user}","branches_url":"https://api.github.com/repos/openregister/presentation/branches{/branch}","tags_url":"https://api.github.com/repos/openregister/presentation/tags","blobs_url":"https://api.github.com/repos/openregister/presentation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openregister/presentation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openregister/presentation/git/refs{/sha}","trees_url":"https://api.github.com/repos/openregister/presentation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openregister/presentation/statuses/{sha}","languages_url":"https://api.github.com/repos/openregister/presentation/languages","stargazers_url":"https://api.github.com/repos/openregister/presentation/stargazers","contributors_url":"https://api.github.com/repos/openregister/presentation/contributors","subscribers_url":"https://api.github.com/repos/openregister/presentation/subscribers","subscription_url":"https://api.github.com/repos/openregister/presentation/subscription","commits_url":"https://api.github.com/repos/openregister/presentation/commits{/sha}","git_commits_url":"https://api.github.com/repos/openregister/presentation/git/commits{/sha}","comments_url":"https://api.github.com/repos/openregister/presentation/comments{/number}","issue_comment_url":"https://api.github.com/repos/openregister/presentation/issues/comments{/number}","contents_url":"https://api.github.com/repos/openregister/presentation/contents/{+path}","compare_url":"https://api.github.com/repos/openregister/presentation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openregister/presentation/merges","archive_url":"https://api.github.com/repos/openregister/presentation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openregister/presentation/downloads","issues_url":"https://api.github.com/repos/openregister/presentation/issues{/number}","pulls_url":"https://api.github.com/repos/openregister/presentation/pulls{/number}","milestones_url":"https://api.github.com/repos/openregister/presentation/milestones{/number}","notifications_url":"https://api.github.com/repos/openregister/presentation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openregister/presentation/labels{/name}","releases_url":"https://api.github.com/repos/openregister/presentation/releases{/id}","created_at":"2015-07-01T16:17:58Z","updated_at":"2015-07-16T09:18:23Z","pushed_at":"2015-09-11T14:01:33Z","git_url":"git://github.com/openregister/presentation.git","ssh_url":"git@github.com:openregister/presentation.git","clone_url":"https://github.com/openregister/presentation.git","svn_url":"https://github.com/openregister/presentation","homepage":"","size":1840,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openregister/presentation/pulls/56"},"html":{"href":"https://github.com/openregister/presentation/pull/56"},"issue":{"href":"https://api.github.com/repos/openregister/presentation/issues/56"},"comments":{"href":"https://api.github.com/repos/openregister/presentation/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/openregister/presentation/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/openregister/presentation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openregister/presentation/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/openregister/presentation/statuses/01342ad42c9273d4506bf4052e48440f10121053"}}}}