{"action":"created","comment":{"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments/61013676","id":61013676,"diff_hunk":"@@ -0,0 +1,147 @@\n+package edu.wpi.grip.core.http;\n+\n+import java.io.IOException;\n+import java.util.HashSet;\n+import java.util.Set;\n+\n+import javax.annotation.Nullable;\n+import javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpServletResponse;\n+\n+import org.eclipse.jetty.server.handler.AbstractHandler;\n+\n+import static com.google.common.base.Preconditions.checkNotNull;\n+\n+/**\n+ * Generic Jetty handler.\n+ * <p>\n+ * Instances of this class can either claim a context, preventing other instances from handling\n+ * events on that context, or not, in which case it will run on any context. The second type may use\n+ * {@link #isClaimed(String) isClaimed} to check if a context has been claimed if it shouldn't run on a claimed context.\n+ */\n+public abstract class GenericHandler extends AbstractHandler {\n+\n+    /**\n+     * Claimed contexts.\n+     */\n+    private static final Set<String> claimedContexts = new HashSet<>();\n+\n+    /**\n+     * The context that this handles.\n+     */\n+    protected final String context;\n+\n+    /**\n+     * HTTP content type for json.\n+     */\n+    public static final String CONTENT_TYPE_JSON = \"application/json\";\n+\n+    /**\n+     * HTTP content type for HTML.\n+     */\n+    public static final String CONTENT_TYPE_HTML = \"text/html\";\n+\n+    /**\n+     * Creates a generic handler for all contexts on the server.\n+     */\n+    protected GenericHandler() {\n+        context = null;\n+    }\n+\n+    /**\n+     * Creates a generic handler that handles requests for the given context. That context will not be claimed.\n+     * <p>\n+     * Note that the context <strong>is case sensitive</strong>.\n+     * </p>\n+     *\n+     * @param context the context for this handler\n+     * @throws IllegalArgumentException if the given context has already been claimed\n+     */\n+    protected GenericHandler(String context) {\n+        this(context, false);\n+    }\n+\n+    /**\n+     * Creates a generic handler that handles requests for the given context.\n+     * <p>\n+     * Note that the context <strong>is case sensitive</strong>.\n+     * </p>\n+     *\n+     * @param context the context for this handler\n+     * @param doClaim flag marking if the given context should be claimed\n+     * @throws IllegalArgumentException if the given context has already been claimed\n+     */\n+    protected GenericHandler(String context, boolean doClaim) {","path":"core/src/main/java/edu/wpi/grip/core/http/GenericHandler.java","position":74,"original_position":74,"commit_id":"c836292dd20c7ea725035ea3d51731aea62dc253","original_commit_id":"c836292dd20c7ea725035ea3d51731aea62dc253","user":{"login":"WPIRoboticsProjects-Bot","id":14011429,"avatar_url":"https://avatars.githubusercontent.com/u/14011429?v=3","gravatar_id":"","url":"https://api.github.com/users/WPIRoboticsProjects-Bot","html_url":"https://github.com/WPIRoboticsProjects-Bot","followers_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/followers","following_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/following{/other_user}","gists_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/gists{/gist_id}","starred_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/subscriptions","organizations_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/orgs","repos_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/repos","events_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/events{/privacy}","received_events_url":"https://api.github.com/users/WPIRoboticsProjects-Bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/assets/images/favicon.png) Issue found: [It is a good practice to call super() in a constructor](https://www.codacy.com/app/WPIRoboticsProjects/GRIP/file/2460306303/issues/source?bid=2943107&fileBranchId=3205212#l74)","created_at":"2016-04-26T00:36:03Z","updated_at":"2016-04-26T00:36:03Z","html_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/551#discussion_r61013676","pull_request_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/551","_links":{"self":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments/61013676"},"html":{"href":"https://github.com/WPIRoboticsProjects/GRIP/pull/551#discussion_r61013676"},"pull_request":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/551"}}},"pull_request":{"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/551","id":63943653,"html_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/551","diff_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/551.diff","patch_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/551.patch","issue_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/551","number":551,"state":"open","locked":false,"title":"Added HTTP publishing and image source operations","user":{"login":"SamCarlberg","id":6320992,"avatar_url":"https://avatars.githubusercontent.com/u/6320992?v=3","gravatar_id":"","url":"https://api.github.com/users/SamCarlberg","html_url":"https://github.com/SamCarlberg","followers_url":"https://api.github.com/users/SamCarlberg/followers","following_url":"https://api.github.com/users/SamCarlberg/following{/other_user}","gists_url":"https://api.github.com/users/SamCarlberg/gists{/gist_id}","starred_url":"https://api.github.com/users/SamCarlberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamCarlberg/subscriptions","organizations_url":"https://api.github.com/users/SamCarlberg/orgs","repos_url":"https://api.github.com/users/SamCarlberg/repos","events_url":"https://api.github.com/users/SamCarlberg/events{/privacy}","received_events_url":"https://api.github.com/users/SamCarlberg/received_events","type":"User","site_admin":false},"body":"## How to use the publishing operations\r\n Use them in the UI just like a NetworkTable publish operation\r\n\r\n#### Getting the data\r\nAll data published will be at `http://localhost:8080/GRIP/data` (or whatever port you set in the settings) in json format. To get specific data, put their names as parameters in the URL -- e.g. if you want `myContoursReport` and `myBlobsReport`, go to `http://localhost:8080/GRIP/data?myContoursReport&myBlobsReport`\r\n\r\n### HTTP image source\r\n\r\n#### GRIP-side\r\nJust use it like a normal image source. It may be a good idea to have the URL be specifiable rather than the static `/GRIP/upload/image` path.\r\n\r\n#### Supplier-side\r\nPerform an HTTP `POST` operation to `http://localhost:8080/GRIP/upload/image` with the image bytes as the data. The server will send those bytes to handlers (currently just one, the `HTTPSource` instance on `/GRIP/upload/image`) that will encode those bytes into `Mats`.\r\n\r\n## Known issues\r\n~~Every other GET/POST request to the server will time out. You can see this by just pointing to http://localhost:8080/GRIP/data in your browser and refreshing the page~~. Fixed in 3162f50","created_at":"2016-03-23T20:00:38Z","updated_at":"2016-04-26T00:36:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ac76ce59a98a33909904430217eb8f0ca6550e6f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/551/commits","review_comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/551/comments","review_comment_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/551/comments","statuses_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/c836292dd20c7ea725035ea3d51731aea62dc253","head":{"label":"SamCarlberg:feat/http","ref":"feat/http","sha":"c836292dd20c7ea725035ea3d51731aea62dc253","user":{"login":"SamCarlberg","id":6320992,"avatar_url":"https://avatars.githubusercontent.com/u/6320992?v=3","gravatar_id":"","url":"https://api.github.com/users/SamCarlberg","html_url":"https://github.com/SamCarlberg","followers_url":"https://api.github.com/users/SamCarlberg/followers","following_url":"https://api.github.com/users/SamCarlberg/following{/other_user}","gists_url":"https://api.github.com/users/SamCarlberg/gists{/gist_id}","starred_url":"https://api.github.com/users/SamCarlberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamCarlberg/subscriptions","organizations_url":"https://api.github.com/users/SamCarlberg/orgs","repos_url":"https://api.github.com/users/SamCarlberg/repos","events_url":"https://api.github.com/users/SamCarlberg/events{/privacy}","received_events_url":"https://api.github.com/users/SamCarlberg/received_events","type":"User","site_admin":false},"repo":{"id":54142171,"name":"GRIP","full_name":"SamCarlberg/GRIP","owner":{"login":"SamCarlberg","id":6320992,"avatar_url":"https://avatars.githubusercontent.com/u/6320992?v=3","gravatar_id":"","url":"https://api.github.com/users/SamCarlberg","html_url":"https://github.com/SamCarlberg","followers_url":"https://api.github.com/users/SamCarlberg/followers","following_url":"https://api.github.com/users/SamCarlberg/following{/other_user}","gists_url":"https://api.github.com/users/SamCarlberg/gists{/gist_id}","starred_url":"https://api.github.com/users/SamCarlberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamCarlberg/subscriptions","organizations_url":"https://api.github.com/users/SamCarlberg/orgs","repos_url":"https://api.github.com/users/SamCarlberg/repos","events_url":"https://api.github.com/users/SamCarlberg/events{/privacy}","received_events_url":"https://api.github.com/users/SamCarlberg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SamCarlberg/GRIP","description":"Program for rapidly developing computer vision applications","fork":true,"url":"https://api.github.com/repos/SamCarlberg/GRIP","forks_url":"https://api.github.com/repos/SamCarlberg/GRIP/forks","keys_url":"https://api.github.com/repos/SamCarlberg/GRIP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SamCarlberg/GRIP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SamCarlberg/GRIP/teams","hooks_url":"https://api.github.com/repos/SamCarlberg/GRIP/hooks","issue_events_url":"https://api.github.com/repos/SamCarlberg/GRIP/issues/events{/number}","events_url":"https://api.github.com/repos/SamCarlberg/GRIP/events","assignees_url":"https://api.github.com/repos/SamCarlberg/GRIP/assignees{/user}","branches_url":"https://api.github.com/repos/SamCarlberg/GRIP/branches{/branch}","tags_url":"https://api.github.com/repos/SamCarlberg/GRIP/tags","blobs_url":"https://api.github.com/repos/SamCarlberg/GRIP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SamCarlberg/GRIP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SamCarlberg/GRIP/git/refs{/sha}","trees_url":"https://api.github.com/repos/SamCarlberg/GRIP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SamCarlberg/GRIP/statuses/{sha}","languages_url":"https://api.github.com/repos/SamCarlberg/GRIP/languages","stargazers_url":"https://api.github.com/repos/SamCarlberg/GRIP/stargazers","contributors_url":"https://api.github.com/repos/SamCarlberg/GRIP/contributors","subscribers_url":"https://api.github.com/repos/SamCarlberg/GRIP/subscribers","subscription_url":"https://api.github.com/repos/SamCarlberg/GRIP/subscription","commits_url":"https://api.github.com/repos/SamCarlberg/GRIP/commits{/sha}","git_commits_url":"https://api.github.com/repos/SamCarlberg/GRIP/git/commits{/sha}","comments_url":"https://api.github.com/repos/SamCarlberg/GRIP/comments{/number}","issue_comment_url":"https://api.github.com/repos/SamCarlberg/GRIP/issues/comments{/number}","contents_url":"https://api.github.com/repos/SamCarlberg/GRIP/contents/{+path}","compare_url":"https://api.github.com/repos/SamCarlberg/GRIP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SamCarlberg/GRIP/merges","archive_url":"https://api.github.com/repos/SamCarlberg/GRIP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SamCarlberg/GRIP/downloads","issues_url":"https://api.github.com/repos/SamCarlberg/GRIP/issues{/number}","pulls_url":"https://api.github.com/repos/SamCarlberg/GRIP/pulls{/number}","milestones_url":"https://api.github.com/repos/SamCarlberg/GRIP/milestones{/number}","notifications_url":"https://api.github.com/repos/SamCarlberg/GRIP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SamCarlberg/GRIP/labels{/name}","releases_url":"https://api.github.com/repos/SamCarlberg/GRIP/releases{/id}","deployments_url":"https://api.github.com/repos/SamCarlberg/GRIP/deployments","created_at":"2016-03-17T18:30:55Z","updated_at":"2016-03-17T18:30:56Z","pushed_at":"2016-04-26T00:33:35Z","git_url":"git://github.com/SamCarlberg/GRIP.git","ssh_url":"git@github.com:SamCarlberg/GRIP.git","clone_url":"https://github.com/SamCarlberg/GRIP.git","svn_url":"https://github.com/SamCarlberg/GRIP","homepage":"http://wpiroboticsprojects.github.io/GRIP","size":40584,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"WPIRoboticsProjects:master","ref":"master","sha":"18a7a4ad86227a3e4996ab3393ef96247878258d","user":{"login":"WPIRoboticsProjects","id":14004340,"avatar_url":"https://avatars.githubusercontent.com/u/14004340?v=3","gravatar_id":"","url":"https://api.github.com/users/WPIRoboticsProjects","html_url":"https://github.com/WPIRoboticsProjects","followers_url":"https://api.github.com/users/WPIRoboticsProjects/followers","following_url":"https://api.github.com/users/WPIRoboticsProjects/following{/other_user}","gists_url":"https://api.github.com/users/WPIRoboticsProjects/gists{/gist_id}","starred_url":"https://api.github.com/users/WPIRoboticsProjects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPIRoboticsProjects/subscriptions","organizations_url":"https://api.github.com/users/WPIRoboticsProjects/orgs","repos_url":"https://api.github.com/users/WPIRoboticsProjects/repos","events_url":"https://api.github.com/users/WPIRoboticsProjects/events{/privacy}","received_events_url":"https://api.github.com/users/WPIRoboticsProjects/received_events","type":"Organization","site_admin":false},"repo":{"id":41505521,"name":"GRIP","full_name":"WPIRoboticsProjects/GRIP","owner":{"login":"WPIRoboticsProjects","id":14004340,"avatar_url":"https://avatars.githubusercontent.com/u/14004340?v=3","gravatar_id":"","url":"https://api.github.com/users/WPIRoboticsProjects","html_url":"https://github.com/WPIRoboticsProjects","followers_url":"https://api.github.com/users/WPIRoboticsProjects/followers","following_url":"https://api.github.com/users/WPIRoboticsProjects/following{/other_user}","gists_url":"https://api.github.com/users/WPIRoboticsProjects/gists{/gist_id}","starred_url":"https://api.github.com/users/WPIRoboticsProjects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPIRoboticsProjects/subscriptions","organizations_url":"https://api.github.com/users/WPIRoboticsProjects/orgs","repos_url":"https://api.github.com/users/WPIRoboticsProjects/repos","events_url":"https://api.github.com/users/WPIRoboticsProjects/events{/privacy}","received_events_url":"https://api.github.com/users/WPIRoboticsProjects/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WPIRoboticsProjects/GRIP","description":"Program for rapidly developing computer vision applications","fork":false,"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP","forks_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/forks","keys_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/teams","hooks_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/hooks","issue_events_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/events{/number}","events_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/events","assignees_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/assignees{/user}","branches_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/branches{/branch}","tags_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/tags","blobs_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/refs{/sha}","trees_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/{sha}","languages_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/languages","stargazers_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/stargazers","contributors_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/contributors","subscribers_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/subscribers","subscription_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/subscription","commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/commits{/sha}","git_commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/commits{/sha}","comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/comments{/number}","issue_comment_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/comments{/number}","contents_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/contents/{+path}","compare_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/merges","archive_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/downloads","issues_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues{/number}","pulls_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls{/number}","milestones_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/milestones{/number}","notifications_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/labels{/name}","releases_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/releases{/id}","deployments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/deployments","created_at":"2015-08-27T18:59:07Z","updated_at":"2016-04-15T15:15:17Z","pushed_at":"2016-04-26T00:30:22Z","git_url":"git://github.com/WPIRoboticsProjects/GRIP.git","ssh_url":"git@github.com:WPIRoboticsProjects/GRIP.git","clone_url":"https://github.com/WPIRoboticsProjects/GRIP.git","svn_url":"https://github.com/WPIRoboticsProjects/GRIP","homepage":"http://wpiroboticsprojects.github.io/GRIP","size":46488,"stargazers_count":102,"watchers_count":102,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":42,"mirror_url":null,"open_issues_count":97,"forks":42,"open_issues":97,"watchers":102,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/551"},"html":{"href":"https://github.com/WPIRoboticsProjects/GRIP/pull/551"},"issue":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/551"},"comments":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/551/comments"},"review_comments":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/551/comments"},"review_comment":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/551/commits"},"statuses":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/c836292dd20c7ea725035ea3d51731aea62dc253"}}}}