{"action":"created","comment":{"url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/comments/63021291","id":63021291,"diff_hunk":"@@ -0,0 +1,61 @@\n+package com.benine.backend.http;\n+\n+import com.benine.backend.camera.CameraController;\n+import com.sun.net.httpserver.Headers;\n+import com.sun.net.httpserver.HttpExchange;\n+\n+import java.io.File;\n+import java.io.FileInputStream;\n+import java.io.IOException;\n+import java.io.OutputStream;\n+import java.net.URI;\n+\n+/**\n+ * Handles static files like the images of a preset.\n+ */\n+public class FileHandler extends RequestHandler {\n+  \n+  /**\n+   * Constructor of this request handler.\n+   * @param controller of the camera's.\n+   */\n+  public FileHandler(CameraController controller) {\n+    super(controller);\n+\n+  }\n+\n+  /**\n+   * Handle incoming requests.\n+   * Checks if the file requested exists and returns it.\n+   * @param exchange incoming request.\n+   * @throws IOException when file could not be send.\n+   */\n+  public void handle(HttpExchange exchange) throws IOException {\n+    URI uri = exchange.getRequestURI();\n+    String path = uri.getPath();\n+    File file = new File(\".\" + path).getCanonicalFile();\n+    //check if the requested file exists\n+    if (!file.isFile()) {\n+      respond(exchange, \"{\\\"succes\\\":\\\"false\\\"}\");\n+    } else {\n+      String mime = \"text/html\";\n+      if (path.substring(path.length() - 4).equals(\".jpg\")) {","path":"backend/src/main/java/com/benine/backend/http/FileHandler.java","position":42,"original_position":42,"commit_id":"8bc12c27bbfcb5250347c3713441d9f5e2e66f09","original_commit_id":"8bc12c27bbfcb5250347c3713441d9f5e2e66f09","user":{"login":"Kingdorian","id":8640174,"avatar_url":"https://avatars.githubusercontent.com/u/8640174?v=3","gravatar_id":"","url":"https://api.github.com/users/Kingdorian","html_url":"https://github.com/Kingdorian","followers_url":"https://api.github.com/users/Kingdorian/followers","following_url":"https://api.github.com/users/Kingdorian/following{/other_user}","gists_url":"https://api.github.com/users/Kingdorian/gists{/gist_id}","starred_url":"https://api.github.com/users/Kingdorian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kingdorian/subscriptions","organizations_url":"https://api.github.com/users/Kingdorian/orgs","repos_url":"https://api.github.com/users/Kingdorian/repos","events_url":"https://api.github.com/users/Kingdorian/events{/privacy}","received_events_url":"https://api.github.com/users/Kingdorian/received_events","type":"User","site_admin":false},"body":"I think it would be cleaner to make a get mime method that uses the String.split(\".\") method and uses the last part to check what the extention is. You could even create a \"extention\"->\"meme\" map for an even cleaner implementation because this style might grow into a forest of if statements or a switch statement.","created_at":"2016-05-12T13:40:47Z","updated_at":"2016-05-12T13:40:47Z","html_url":"https://github.com/Kingdorian/Contextproject-BeNine/pull/72#discussion_r63021291","pull_request_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/72","_links":{"self":{"href":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/comments/63021291"},"html":{"href":"https://github.com/Kingdorian/Contextproject-BeNine/pull/72#discussion_r63021291"},"pull_request":{"href":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/72"}}},"pull_request":{"url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/72","id":69835601,"html_url":"https://github.com/Kingdorian/Contextproject-BeNine/pull/72","diff_url":"https://github.com/Kingdorian/Contextproject-BeNine/pull/72.diff","patch_url":"https://github.com/Kingdorian/Contextproject-BeNine/pull/72.patch","issue_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/issues/72","number":72,"state":"open","locked":false,"title":"Preset ui","user":{"login":"bvanwijk","id":9803346,"avatar_url":"https://avatars.githubusercontent.com/u/9803346?v=3","gravatar_id":"","url":"https://api.github.com/users/bvanwijk","html_url":"https://github.com/bvanwijk","followers_url":"https://api.github.com/users/bvanwijk/followers","following_url":"https://api.github.com/users/bvanwijk/following{/other_user}","gists_url":"https://api.github.com/users/bvanwijk/gists{/gist_id}","starred_url":"https://api.github.com/users/bvanwijk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bvanwijk/subscriptions","organizations_url":"https://api.github.com/users/bvanwijk/orgs","repos_url":"https://api.github.com/users/bvanwijk/repos","events_url":"https://api.github.com/users/bvanwijk/events{/privacy}","received_events_url":"https://api.github.com/users/bvanwijk/received_events","type":"User","site_admin":false},"body":"The UI can now load the presets for every camera.\r\nIt can load the preset image from the backend.\r\nThe presets don't have an ID yet, because this is not yet implemented in the backend. \r\nThe call to recall a preset in the backend has also to be added.\r\nI think it would be good to merge this when theses things are available.","created_at":"2016-05-12T13:25:38Z","updated_at":"2016-05-12T13:40:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a426c6c18bf50d1a19727132ad8c778811d48348","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/72/commits","review_comments_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/72/comments","review_comment_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/issues/72/comments","statuses_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/statuses/8bc12c27bbfcb5250347c3713441d9f5e2e66f09","head":{"label":"Kingdorian:preset-ui","ref":"preset-ui","sha":"8bc12c27bbfcb5250347c3713441d9f5e2e66f09","user":{"login":"Kingdorian","id":8640174,"avatar_url":"https://avatars.githubusercontent.com/u/8640174?v=3","gravatar_id":"","url":"https://api.github.com/users/Kingdorian","html_url":"https://github.com/Kingdorian","followers_url":"https://api.github.com/users/Kingdorian/followers","following_url":"https://api.github.com/users/Kingdorian/following{/other_user}","gists_url":"https://api.github.com/users/Kingdorian/gists{/gist_id}","starred_url":"https://api.github.com/users/Kingdorian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kingdorian/subscriptions","organizations_url":"https://api.github.com/users/Kingdorian/orgs","repos_url":"https://api.github.com/users/Kingdorian/repos","events_url":"https://api.github.com/users/Kingdorian/events{/privacy}","received_events_url":"https://api.github.com/users/Kingdorian/received_events","type":"User","site_admin":false},"repo":{"id":56487193,"name":"Contextproject-BeNine","full_name":"Kingdorian/Contextproject-BeNine","owner":{"login":"Kingdorian","id":8640174,"avatar_url":"https://avatars.githubusercontent.com/u/8640174?v=3","gravatar_id":"","url":"https://api.github.com/users/Kingdorian","html_url":"https://github.com/Kingdorian","followers_url":"https://api.github.com/users/Kingdorian/followers","following_url":"https://api.github.com/users/Kingdorian/following{/other_user}","gists_url":"https://api.github.com/users/Kingdorian/gists{/gist_id}","starred_url":"https://api.github.com/users/Kingdorian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kingdorian/subscriptions","organizations_url":"https://api.github.com/users/Kingdorian/orgs","repos_url":"https://api.github.com/users/Kingdorian/repos","events_url":"https://api.github.com/users/Kingdorian/events{/privacy}","received_events_url":"https://api.github.com/users/Kingdorian/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Kingdorian/Contextproject-BeNine","description":"","fork":false,"url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine","forks_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/forks","keys_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/teams","hooks_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/hooks","issue_events_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/issues/events{/number}","events_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/events","assignees_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/assignees{/user}","branches_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/branches{/branch}","tags_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/tags","blobs_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/statuses/{sha}","languages_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/languages","stargazers_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/stargazers","contributors_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/contributors","subscribers_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/subscribers","subscription_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/subscription","commits_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/contents/{+path}","compare_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/merges","archive_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/downloads","issues_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/issues{/number}","pulls_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls{/number}","milestones_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/milestones{/number}","notifications_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/labels{/name}","releases_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/releases{/id}","deployments_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/deployments","created_at":"2016-04-18T07:39:56Z","updated_at":"2016-05-09T18:38:09Z","pushed_at":"2016-05-12T13:25:38Z","git_url":"git://github.com/Kingdorian/Contextproject-BeNine.git","ssh_url":"git@github.com:Kingdorian/Contextproject-BeNine.git","clone_url":"https://github.com/Kingdorian/Contextproject-BeNine.git","svn_url":"https://github.com/Kingdorian/Contextproject-BeNine","homepage":null,"size":5063,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":19,"forks":0,"open_issues":19,"watchers":3,"default_branch":"master"}},"base":{"label":"Kingdorian:develop","ref":"develop","sha":"b0b7a2e09c903f0b8e9e847548cca3135de54051","user":{"login":"Kingdorian","id":8640174,"avatar_url":"https://avatars.githubusercontent.com/u/8640174?v=3","gravatar_id":"","url":"https://api.github.com/users/Kingdorian","html_url":"https://github.com/Kingdorian","followers_url":"https://api.github.com/users/Kingdorian/followers","following_url":"https://api.github.com/users/Kingdorian/following{/other_user}","gists_url":"https://api.github.com/users/Kingdorian/gists{/gist_id}","starred_url":"https://api.github.com/users/Kingdorian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kingdorian/subscriptions","organizations_url":"https://api.github.com/users/Kingdorian/orgs","repos_url":"https://api.github.com/users/Kingdorian/repos","events_url":"https://api.github.com/users/Kingdorian/events{/privacy}","received_events_url":"https://api.github.com/users/Kingdorian/received_events","type":"User","site_admin":false},"repo":{"id":56487193,"name":"Contextproject-BeNine","full_name":"Kingdorian/Contextproject-BeNine","owner":{"login":"Kingdorian","id":8640174,"avatar_url":"https://avatars.githubusercontent.com/u/8640174?v=3","gravatar_id":"","url":"https://api.github.com/users/Kingdorian","html_url":"https://github.com/Kingdorian","followers_url":"https://api.github.com/users/Kingdorian/followers","following_url":"https://api.github.com/users/Kingdorian/following{/other_user}","gists_url":"https://api.github.com/users/Kingdorian/gists{/gist_id}","starred_url":"https://api.github.com/users/Kingdorian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kingdorian/subscriptions","organizations_url":"https://api.github.com/users/Kingdorian/orgs","repos_url":"https://api.github.com/users/Kingdorian/repos","events_url":"https://api.github.com/users/Kingdorian/events{/privacy}","received_events_url":"https://api.github.com/users/Kingdorian/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Kingdorian/Contextproject-BeNine","description":"","fork":false,"url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine","forks_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/forks","keys_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/teams","hooks_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/hooks","issue_events_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/issues/events{/number}","events_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/events","assignees_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/assignees{/user}","branches_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/branches{/branch}","tags_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/tags","blobs_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/statuses/{sha}","languages_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/languages","stargazers_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/stargazers","contributors_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/contributors","subscribers_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/subscribers","subscription_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/subscription","commits_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/contents/{+path}","compare_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/merges","archive_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/downloads","issues_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/issues{/number}","pulls_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls{/number}","milestones_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/milestones{/number}","notifications_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/labels{/name}","releases_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/releases{/id}","deployments_url":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/deployments","created_at":"2016-04-18T07:39:56Z","updated_at":"2016-05-09T18:38:09Z","pushed_at":"2016-05-12T13:25:38Z","git_url":"git://github.com/Kingdorian/Contextproject-BeNine.git","ssh_url":"git@github.com:Kingdorian/Contextproject-BeNine.git","clone_url":"https://github.com/Kingdorian/Contextproject-BeNine.git","svn_url":"https://github.com/Kingdorian/Contextproject-BeNine","homepage":null,"size":5063,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":19,"forks":0,"open_issues":19,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/72"},"html":{"href":"https://github.com/Kingdorian/Contextproject-BeNine/pull/72"},"issue":{"href":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/issues/72"},"comments":{"href":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/issues/72/comments"},"review_comments":{"href":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/72/comments"},"review_comment":{"href":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/pulls/72/commits"},"statuses":{"href":"https://api.github.com/repos/Kingdorian/Contextproject-BeNine/statuses/8bc12c27bbfcb5250347c3713441d9f5e2e66f09"}}}}