{"action":"created","comment":{"url":"https://api.github.com/repos/codingmentor/homeworks/pulls/comments/74578435","id":74578435,"diff_hunk":"@@ -0,0 +1,97 @@\n+package com.webshop.demo.service;\n+\n+import com.webshop.demo.db.UserDB;\n+import com.webshop.demo.dto.User;\n+import com.webshop.demo.exception.UsernameAlreadyRegisteredException;\n+import com.webshop.demo.exception.UsernameNotRegisteredException;\n+import com.webshop.demo.service.exception.PermissionDeniedException;\n+import java.io.Serializable;\n+import java.util.Collection;\n+import javax.enterprise.context.SessionScoped;\n+import javax.inject.Inject;\n+import javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpSession;\n+import javax.ws.rs.Consumes;\n+import javax.ws.rs.POST;\n+import javax.ws.rs.DELETE;\n+import javax.ws.rs.GET;\n+import javax.ws.rs.Path;\n+import javax.ws.rs.PathParam;\n+import javax.ws.rs.Produces;\n+import javax.ws.rs.core.Context;\n+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;\n+import static javax.ws.rs.core.MediaType.TEXT_PLAIN;\n+\n+/**\n+ *\n+ * @author istvan.mosonyi\n+ */\n+@Path(\"/users\")\n+@SessionScoped\n+public class UserRESTService extends RestAssistant implements Serializable {\n+\n+    @Inject\n+    private UserDB userDatabase;\n+    \n+    @GET\n+    @Produces(APPLICATION_JSON)\n+    public Collection<User> getAllUsers() {\n+        return userDatabase.getUsers();\n+    }\n+    \n+    @GET\n+    @Path(\"/{username}\")\n+    @Produces(APPLICATION_JSON)\n+    public User getUserByUsername(@PathParam(\"username\") String username) throws UsernameNotRegisteredException {\n+        return userDatabase.getUserByUsername(username);\n+    }\n+    \n+    @POST\n+    @Path(\"/add\")\n+    @Consumes(APPLICATION_JSON)\n+    @Produces(TEXT_PLAIN)\n+    public boolean addNewUser(@Context HttpServletRequest request, User user) throws UsernameAlreadyRegisteredException {\n+        User currentUser = checkSession(request);\n+        return addUserIfCurrentHasPermission(currentUser, user);\n+    }\n+    \n+    @POST\n+    @Path(\"/login\")\n+    @Consumes(APPLICATION_JSON)\n+    @Produces(TEXT_PLAIN)\n+    public boolean login(@Context HttpServletRequest request, User user) throws UsernameNotRegisteredException {\n+        HttpSession session = request.getSession(true);\n+        if(userDatabase.authenticate(user.getUsername(), user.getPassword())) {\n+            session.setMaxInactiveInterval(DEFAULT_MAX_SESSION_INTERVAL);\n+            session.setAttribute(USER_ATTRIBUTE, user);\n+            return true;\n+        }\n+        return false;\n+    }\n+    \n+    @DELETE\n+    @Path(\"/delete\")","path":"istvan.mosonyi/2-Homework-Webshop/Webshop.Istvan.Mosonyi/Webshop.Istvan.Mosonyi-web/src/main/java/com/webshop/demo/service/UserRESTService.java","position":73,"original_position":73,"commit_id":"d0a5cce98c6855ae47e7441d28946cc1b06bde8c","original_commit_id":"d0a5cce98c6855ae47e7441d28946cc1b06bde8c","user":{"login":"deneslaszlo","id":16327999,"avatar_url":"https://avatars.githubusercontent.com/u/16327999?v=3","gravatar_id":"","url":"https://api.github.com/users/deneslaszlo","html_url":"https://github.com/deneslaszlo","followers_url":"https://api.github.com/users/deneslaszlo/followers","following_url":"https://api.github.com/users/deneslaszlo/following{/other_user}","gists_url":"https://api.github.com/users/deneslaszlo/gists{/gist_id}","starred_url":"https://api.github.com/users/deneslaszlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deneslaszlo/subscriptions","organizations_url":"https://api.github.com/users/deneslaszlo/orgs","repos_url":"https://api.github.com/users/deneslaszlo/repos","events_url":"https://api.github.com/users/deneslaszlo/events{/privacy}","received_events_url":"https://api.github.com/users/deneslaszlo/received_events","type":"User","site_admin":false},"body":"a REST konvenciók szerint alakítsd ki itt a patht, ez egy egyszerű resource","created_at":"2016-08-12T11:49:29Z","updated_at":"2016-08-12T11:49:29Z","html_url":"https://github.com/codingmentor/homeworks/pull/63#discussion_r74578435","pull_request_url":"https://api.github.com/repos/codingmentor/homeworks/pulls/63","_links":{"self":{"href":"https://api.github.com/repos/codingmentor/homeworks/pulls/comments/74578435"},"html":{"href":"https://github.com/codingmentor/homeworks/pull/63#discussion_r74578435"},"pull_request":{"href":"https://api.github.com/repos/codingmentor/homeworks/pulls/63"}}},"pull_request":{"url":"https://api.github.com/repos/codingmentor/homeworks/pulls/63","id":81103641,"html_url":"https://github.com/codingmentor/homeworks/pull/63","diff_url":"https://github.com/codingmentor/homeworks/pull/63.diff","patch_url":"https://github.com/codingmentor/homeworks/pull/63.patch","issue_url":"https://api.github.com/repos/codingmentor/homeworks/issues/63","number":63,"state":"open","locked":false,"title":"Add HW-02/2: Webshop ","user":{"login":"Mosonyi15p","id":18261489,"avatar_url":"https://avatars.githubusercontent.com/u/18261489?v=3","gravatar_id":"","url":"https://api.github.com/users/Mosonyi15p","html_url":"https://github.com/Mosonyi15p","followers_url":"https://api.github.com/users/Mosonyi15p/followers","following_url":"https://api.github.com/users/Mosonyi15p/following{/other_user}","gists_url":"https://api.github.com/users/Mosonyi15p/gists{/gist_id}","starred_url":"https://api.github.com/users/Mosonyi15p/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mosonyi15p/subscriptions","organizations_url":"https://api.github.com/users/Mosonyi15p/orgs","repos_url":"https://api.github.com/users/Mosonyi15p/repos","events_url":"https://api.github.com/users/Mosonyi15p/events{/privacy}","received_events_url":"https://api.github.com/users/Mosonyi15p/received_events","type":"User","site_admin":false},"body":"Sonar link:\r\nhttp://sonar.codingmentor.xyz/overview?id=com.mycompany%3AWebshop.Istvan.Mosonyi\r\n\r\nTesztelve:\r\nWildfly 10.0.0","created_at":"2016-08-12T11:16:04Z","updated_at":"2016-08-12T11:49:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a834080125ba973def0e4cd90e189e994b4e619d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/codingmentor/homeworks/pulls/63/commits","review_comments_url":"https://api.github.com/repos/codingmentor/homeworks/pulls/63/comments","review_comment_url":"https://api.github.com/repos/codingmentor/homeworks/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codingmentor/homeworks/issues/63/comments","statuses_url":"https://api.github.com/repos/codingmentor/homeworks/statuses/d0a5cce98c6855ae47e7441d28946cc1b06bde8c","head":{"label":"Mosonyi15p:EE-2-2","ref":"EE-2-2","sha":"d0a5cce98c6855ae47e7441d28946cc1b06bde8c","user":{"login":"Mosonyi15p","id":18261489,"avatar_url":"https://avatars.githubusercontent.com/u/18261489?v=3","gravatar_id":"","url":"https://api.github.com/users/Mosonyi15p","html_url":"https://github.com/Mosonyi15p","followers_url":"https://api.github.com/users/Mosonyi15p/followers","following_url":"https://api.github.com/users/Mosonyi15p/following{/other_user}","gists_url":"https://api.github.com/users/Mosonyi15p/gists{/gist_id}","starred_url":"https://api.github.com/users/Mosonyi15p/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mosonyi15p/subscriptions","organizations_url":"https://api.github.com/users/Mosonyi15p/orgs","repos_url":"https://api.github.com/users/Mosonyi15p/repos","events_url":"https://api.github.com/users/Mosonyi15p/events{/privacy}","received_events_url":"https://api.github.com/users/Mosonyi15p/received_events","type":"User","site_admin":false},"repo":{"id":63486512,"name":"homeworks","full_name":"Mosonyi15p/homeworks","owner":{"login":"Mosonyi15p","id":18261489,"avatar_url":"https://avatars.githubusercontent.com/u/18261489?v=3","gravatar_id":"","url":"https://api.github.com/users/Mosonyi15p","html_url":"https://github.com/Mosonyi15p","followers_url":"https://api.github.com/users/Mosonyi15p/followers","following_url":"https://api.github.com/users/Mosonyi15p/following{/other_user}","gists_url":"https://api.github.com/users/Mosonyi15p/gists{/gist_id}","starred_url":"https://api.github.com/users/Mosonyi15p/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mosonyi15p/subscriptions","organizations_url":"https://api.github.com/users/Mosonyi15p/orgs","repos_url":"https://api.github.com/users/Mosonyi15p/repos","events_url":"https://api.github.com/users/Mosonyi15p/events{/privacy}","received_events_url":"https://api.github.com/users/Mosonyi15p/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Mosonyi15p/homeworks","description":"Homeworks of codingmentor training","fork":true,"url":"https://api.github.com/repos/Mosonyi15p/homeworks","forks_url":"https://api.github.com/repos/Mosonyi15p/homeworks/forks","keys_url":"https://api.github.com/repos/Mosonyi15p/homeworks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mosonyi15p/homeworks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mosonyi15p/homeworks/teams","hooks_url":"https://api.github.com/repos/Mosonyi15p/homeworks/hooks","issue_events_url":"https://api.github.com/repos/Mosonyi15p/homeworks/issues/events{/number}","events_url":"https://api.github.com/repos/Mosonyi15p/homeworks/events","assignees_url":"https://api.github.com/repos/Mosonyi15p/homeworks/assignees{/user}","branches_url":"https://api.github.com/repos/Mosonyi15p/homeworks/branches{/branch}","tags_url":"https://api.github.com/repos/Mosonyi15p/homeworks/tags","blobs_url":"https://api.github.com/repos/Mosonyi15p/homeworks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mosonyi15p/homeworks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mosonyi15p/homeworks/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mosonyi15p/homeworks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mosonyi15p/homeworks/statuses/{sha}","languages_url":"https://api.github.com/repos/Mosonyi15p/homeworks/languages","stargazers_url":"https://api.github.com/repos/Mosonyi15p/homeworks/stargazers","contributors_url":"https://api.github.com/repos/Mosonyi15p/homeworks/contributors","subscribers_url":"https://api.github.com/repos/Mosonyi15p/homeworks/subscribers","subscription_url":"https://api.github.com/repos/Mosonyi15p/homeworks/subscription","commits_url":"https://api.github.com/repos/Mosonyi15p/homeworks/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mosonyi15p/homeworks/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mosonyi15p/homeworks/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mosonyi15p/homeworks/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mosonyi15p/homeworks/contents/{+path}","compare_url":"https://api.github.com/repos/Mosonyi15p/homeworks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mosonyi15p/homeworks/merges","archive_url":"https://api.github.com/repos/Mosonyi15p/homeworks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mosonyi15p/homeworks/downloads","issues_url":"https://api.github.com/repos/Mosonyi15p/homeworks/issues{/number}","pulls_url":"https://api.github.com/repos/Mosonyi15p/homeworks/pulls{/number}","milestones_url":"https://api.github.com/repos/Mosonyi15p/homeworks/milestones{/number}","notifications_url":"https://api.github.com/repos/Mosonyi15p/homeworks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mosonyi15p/homeworks/labels{/name}","releases_url":"https://api.github.com/repos/Mosonyi15p/homeworks/releases{/id}","deployments_url":"https://api.github.com/repos/Mosonyi15p/homeworks/deployments","created_at":"2016-07-16T14:26:27Z","updated_at":"2016-07-16T14:00:02Z","pushed_at":"2016-08-12T11:20:33Z","git_url":"git://github.com/Mosonyi15p/homeworks.git","ssh_url":"git@github.com:Mosonyi15p/homeworks.git","clone_url":"https://github.com/Mosonyi15p/homeworks.git","svn_url":"https://github.com/Mosonyi15p/homeworks","homepage":null,"size":91,"stargazers_count":0,"watchers_count":0,"language":null,"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":"codingmentor:istvan.mosonyi","ref":"istvan.mosonyi","sha":"5e98a6b64c619fd93130fd559dd709ea765de77b","user":{"login":"codingmentor","id":17640460,"avatar_url":"https://avatars.githubusercontent.com/u/17640460?v=3","gravatar_id":"","url":"https://api.github.com/users/codingmentor","html_url":"https://github.com/codingmentor","followers_url":"https://api.github.com/users/codingmentor/followers","following_url":"https://api.github.com/users/codingmentor/following{/other_user}","gists_url":"https://api.github.com/users/codingmentor/gists{/gist_id}","starred_url":"https://api.github.com/users/codingmentor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codingmentor/subscriptions","organizations_url":"https://api.github.com/users/codingmentor/orgs","repos_url":"https://api.github.com/users/codingmentor/repos","events_url":"https://api.github.com/users/codingmentor/events{/privacy}","received_events_url":"https://api.github.com/users/codingmentor/received_events","type":"Organization","site_admin":false},"repo":{"id":63485226,"name":"homeworks","full_name":"codingmentor/homeworks","owner":{"login":"codingmentor","id":17640460,"avatar_url":"https://avatars.githubusercontent.com/u/17640460?v=3","gravatar_id":"","url":"https://api.github.com/users/codingmentor","html_url":"https://github.com/codingmentor","followers_url":"https://api.github.com/users/codingmentor/followers","following_url":"https://api.github.com/users/codingmentor/following{/other_user}","gists_url":"https://api.github.com/users/codingmentor/gists{/gist_id}","starred_url":"https://api.github.com/users/codingmentor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codingmentor/subscriptions","organizations_url":"https://api.github.com/users/codingmentor/orgs","repos_url":"https://api.github.com/users/codingmentor/repos","events_url":"https://api.github.com/users/codingmentor/events{/privacy}","received_events_url":"https://api.github.com/users/codingmentor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codingmentor/homeworks","description":"Homeworks of codingmentor training","fork":false,"url":"https://api.github.com/repos/codingmentor/homeworks","forks_url":"https://api.github.com/repos/codingmentor/homeworks/forks","keys_url":"https://api.github.com/repos/codingmentor/homeworks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codingmentor/homeworks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codingmentor/homeworks/teams","hooks_url":"https://api.github.com/repos/codingmentor/homeworks/hooks","issue_events_url":"https://api.github.com/repos/codingmentor/homeworks/issues/events{/number}","events_url":"https://api.github.com/repos/codingmentor/homeworks/events","assignees_url":"https://api.github.com/repos/codingmentor/homeworks/assignees{/user}","branches_url":"https://api.github.com/repos/codingmentor/homeworks/branches{/branch}","tags_url":"https://api.github.com/repos/codingmentor/homeworks/tags","blobs_url":"https://api.github.com/repos/codingmentor/homeworks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codingmentor/homeworks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codingmentor/homeworks/git/refs{/sha}","trees_url":"https://api.github.com/repos/codingmentor/homeworks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codingmentor/homeworks/statuses/{sha}","languages_url":"https://api.github.com/repos/codingmentor/homeworks/languages","stargazers_url":"https://api.github.com/repos/codingmentor/homeworks/stargazers","contributors_url":"https://api.github.com/repos/codingmentor/homeworks/contributors","subscribers_url":"https://api.github.com/repos/codingmentor/homeworks/subscribers","subscription_url":"https://api.github.com/repos/codingmentor/homeworks/subscription","commits_url":"https://api.github.com/repos/codingmentor/homeworks/commits{/sha}","git_commits_url":"https://api.github.com/repos/codingmentor/homeworks/git/commits{/sha}","comments_url":"https://api.github.com/repos/codingmentor/homeworks/comments{/number}","issue_comment_url":"https://api.github.com/repos/codingmentor/homeworks/issues/comments{/number}","contents_url":"https://api.github.com/repos/codingmentor/homeworks/contents/{+path}","compare_url":"https://api.github.com/repos/codingmentor/homeworks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codingmentor/homeworks/merges","archive_url":"https://api.github.com/repos/codingmentor/homeworks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codingmentor/homeworks/downloads","issues_url":"https://api.github.com/repos/codingmentor/homeworks/issues{/number}","pulls_url":"https://api.github.com/repos/codingmentor/homeworks/pulls{/number}","milestones_url":"https://api.github.com/repos/codingmentor/homeworks/milestones{/number}","notifications_url":"https://api.github.com/repos/codingmentor/homeworks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codingmentor/homeworks/labels{/name}","releases_url":"https://api.github.com/repos/codingmentor/homeworks/releases{/id}","deployments_url":"https://api.github.com/repos/codingmentor/homeworks/deployments","created_at":"2016-07-16T13:54:09Z","updated_at":"2016-08-08T18:38:22Z","pushed_at":"2016-08-12T11:44:47Z","git_url":"git://github.com/codingmentor/homeworks.git","ssh_url":"git@github.com:codingmentor/homeworks.git","clone_url":"https://github.com/codingmentor/homeworks.git","svn_url":"https://github.com/codingmentor/homeworks","homepage":null,"size":2079,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":8,"forks":12,"open_issues":8,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codingmentor/homeworks/pulls/63"},"html":{"href":"https://github.com/codingmentor/homeworks/pull/63"},"issue":{"href":"https://api.github.com/repos/codingmentor/homeworks/issues/63"},"comments":{"href":"https://api.github.com/repos/codingmentor/homeworks/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/codingmentor/homeworks/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/codingmentor/homeworks/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codingmentor/homeworks/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/codingmentor/homeworks/statuses/d0a5cce98c6855ae47e7441d28946cc1b06bde8c"}}}}
{"actor":{"display_login":"deneslaszlo"}}