{"action":"created","comment":{"url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/comments/200064486","pull_request_review_id":134296419,"id":200064486,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDA2NDQ4Ng==","diff_hunk":"@@ -0,0 +1,133 @@\n+package org.upgrad.controllers;\n+\n+import com.google.common.hash.Hashing;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.http.HttpStatus;\n+import org.springframework.http.ResponseEntity;\n+import org.springframework.stereotype.Component;\n+import org.springframework.stereotype.Controller;\n+import org.springframework.stereotype.Service;\n+import org.springframework.web.bind.annotation.*;\n+import org.upgrad.models.User;\n+import org.upgrad.services.UserService;\n+import org.upgrad.services.UserServiceImp ;\n+\n+import java.nio.charset.StandardCharsets;\n+import java.text.SimpleDateFormat;\n+\n+/*\n+Author - Sugandha\n+Date - 1 July 2018\n+Description - This class contains rest api corresponding to user related methods.\n+ */\n+@RestController\n+public class UserController {\n+\n+    @Autowired\n+    private UserService userService ;\n+\n+    /*\n+        This returns true if username already exists.\n+        Otherwise it returns false.\n+     */\n+    public Boolean registerUserWithExistingUsername(String userName) throws Exception{\n+        String userPresent = String.valueOf(userService.findUserByUsername(userName));\n+        if ( ! (userPresent.equalsIgnoreCase(\"null\") )) {\n+            return true ;\n+        } else  {\n+            return false ;\n+        }\n+    }\n+\n+    /*\n+        This returns true if email already exists.\n+        Otherwise it returns false.\n+     */\n+    public Boolean registerUserWithExistingEmail(String email) throws Exception{\n+        String userPresent = String.valueOf(userService.findUserByEmail(email));\n+        if ( ! (userPresent.equalsIgnoreCase(\"null\") )) {\n+            return true ;\n+        } else  {\n+            return false ;\n+        }\n+    }\n+\n+\n+    /*\n+     It checks signup the user along with it's details if user is not already present.\n+     This method gives relevant messages in case username or email is already registered.\n+     */\n+\n+    @PostMapping(\"/api/user/signup/\")\n+    public ResponseEntity registerUser(@RequestParam String userName, @RequestParam String email, @RequestParam String password , @RequestParam String firstName, @RequestParam String lastName, @RequestParam String aboutMe, @RequestParam String contactNumber, @RequestParam String dob, @RequestParam String country) throws Exception{\n+\n+        // Setting url data into user model class.\n+        User user = new User();\n+        user.setPassword(hashPassword(password));\n+        user.setLastName(lastName);\n+        user.setFirstName(firstName);\n+        user.setEmail(email);\n+        user.setCountry(country);\n+        user.setContactNumber(contactNumber);\n+        user.setUserName(userName);\n+        user.setDob(new SimpleDateFormat(\"dd/MM/yyyy\").parse(dob));\n+        user.setAboutMe(aboutMe);\n+\n+        String message = null ;\n+\n+       if ( registerUserWithExistingUsername(user.getUserName()) )\n+       {\n+            message = \"Try any other Username, this Username has already been taken.\" ;\n+            return new ResponseEntity<>( message , HttpStatus.OK) ;","path":"Exercise-master/src/main/java/org/upgrad/controllers/UserController.java","position":81,"original_position":81,"commit_id":"61665574e6a7e50ee2db3afb309e229786eeba9d","original_commit_id":"61665574e6a7e50ee2db3afb309e229786eeba9d","user":{"login":"Apoorva2405","id":24796697,"node_id":"MDQ6VXNlcjI0Nzk2Njk3","avatar_url":"https://avatars2.githubusercontent.com/u/24796697?v=4","gravatar_id":"","url":"https://api.github.com/users/Apoorva2405","html_url":"https://github.com/Apoorva2405","followers_url":"https://api.github.com/users/Apoorva2405/followers","following_url":"https://api.github.com/users/Apoorva2405/following{/other_user}","gists_url":"https://api.github.com/users/Apoorva2405/gists{/gist_id}","starred_url":"https://api.github.com/users/Apoorva2405/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Apoorva2405/subscriptions","organizations_url":"https://api.github.com/users/Apoorva2405/orgs","repos_url":"https://api.github.com/users/Apoorva2405/repos","events_url":"https://api.github.com/users/Apoorva2405/events{/privacy}","received_events_url":"https://api.github.com/users/Apoorva2405/received_events","type":"User","site_admin":false},"body":"HttpStatus should not be Ok here.It should be HttpStatus.FORBIDDEN","created_at":"2018-07-04T09:29:44Z","updated_at":"2018-07-04T09:52:35Z","html_url":"https://github.com/sundarsv/upgrad_course5_ass1gnment/pull/1#discussion_r200064486","pull_request_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/1","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/comments/200064486"},"html":{"href":"https://github.com/sundarsv/upgrad_course5_ass1gnment/pull/1#discussion_r200064486"},"pull_request":{"href":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/1","id":199169853,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk5MTY5ODUz","html_url":"https://github.com/sundarsv/upgrad_course5_ass1gnment/pull/1","diff_url":"https://github.com/sundarsv/upgrad_course5_ass1gnment/pull/1.diff","patch_url":"https://github.com/sundarsv/upgrad_course5_ass1gnment/pull/1.patch","issue_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/issues/1","number":1,"state":"open","locked":false,"title":"Feat/user","user":{"login":"sugandhakhera","id":8520439,"node_id":"MDQ6VXNlcjg1MjA0Mzk=","avatar_url":"https://avatars0.githubusercontent.com/u/8520439?v=4","gravatar_id":"","url":"https://api.github.com/users/sugandhakhera","html_url":"https://github.com/sugandhakhera","followers_url":"https://api.github.com/users/sugandhakhera/followers","following_url":"https://api.github.com/users/sugandhakhera/following{/other_user}","gists_url":"https://api.github.com/users/sugandhakhera/gists{/gist_id}","starred_url":"https://api.github.com/users/sugandhakhera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sugandhakhera/subscriptions","organizations_url":"https://api.github.com/users/sugandhakhera/orgs","repos_url":"https://api.github.com/users/sugandhakhera/repos","events_url":"https://api.github.com/users/sugandhakhera/events{/privacy}","received_events_url":"https://api.github.com/users/sugandhakhera/received_events","type":"User","site_admin":false},"body":"Please review the code. \r\nReviewer -> Apoorva ","created_at":"2018-07-04T08:08:54Z","updated_at":"2018-07-04T09:52:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"54b6a1e81e2d70193a7788a2cdb5acf1b507928e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/1/commits","review_comments_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/1/comments","review_comment_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/issues/1/comments","statuses_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/statuses/61665574e6a7e50ee2db3afb309e229786eeba9d","head":{"label":"sundarsv:feat/user","ref":"feat/user","sha":"61665574e6a7e50ee2db3afb309e229786eeba9d","user":{"login":"sundarsv","id":4122675,"node_id":"MDQ6VXNlcjQxMjI2NzU=","avatar_url":"https://avatars2.githubusercontent.com/u/4122675?v=4","gravatar_id":"","url":"https://api.github.com/users/sundarsv","html_url":"https://github.com/sundarsv","followers_url":"https://api.github.com/users/sundarsv/followers","following_url":"https://api.github.com/users/sundarsv/following{/other_user}","gists_url":"https://api.github.com/users/sundarsv/gists{/gist_id}","starred_url":"https://api.github.com/users/sundarsv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sundarsv/subscriptions","organizations_url":"https://api.github.com/users/sundarsv/orgs","repos_url":"https://api.github.com/users/sundarsv/repos","events_url":"https://api.github.com/users/sundarsv/events{/privacy}","received_events_url":"https://api.github.com/users/sundarsv/received_events","type":"User","site_admin":false},"repo":{"id":138807628,"node_id":"MDEwOlJlcG9zaXRvcnkxMzg4MDc2Mjg=","name":"upgrad_course5_ass1gnment","full_name":"sundarsv/upgrad_course5_ass1gnment","owner":{"login":"sundarsv","id":4122675,"node_id":"MDQ6VXNlcjQxMjI2NzU=","avatar_url":"https://avatars2.githubusercontent.com/u/4122675?v=4","gravatar_id":"","url":"https://api.github.com/users/sundarsv","html_url":"https://github.com/sundarsv","followers_url":"https://api.github.com/users/sundarsv/followers","following_url":"https://api.github.com/users/sundarsv/following{/other_user}","gists_url":"https://api.github.com/users/sundarsv/gists{/gist_id}","starred_url":"https://api.github.com/users/sundarsv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sundarsv/subscriptions","organizations_url":"https://api.github.com/users/sundarsv/orgs","repos_url":"https://api.github.com/users/sundarsv/repos","events_url":"https://api.github.com/users/sundarsv/events{/privacy}","received_events_url":"https://api.github.com/users/sundarsv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sundarsv/upgrad_course5_ass1gnment","description":"Course 5 assignment for Upgrad","fork":false,"url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment","forks_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/forks","keys_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/teams","hooks_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/hooks","issue_events_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/issues/events{/number}","events_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/events","assignees_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/assignees{/user}","branches_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/branches{/branch}","tags_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/tags","blobs_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/git/refs{/sha}","trees_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/statuses/{sha}","languages_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/languages","stargazers_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/stargazers","contributors_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/contributors","subscribers_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/subscribers","subscription_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/subscription","commits_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/commits{/sha}","git_commits_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/git/commits{/sha}","comments_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/comments{/number}","issue_comment_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/issues/comments{/number}","contents_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/contents/{+path}","compare_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/merges","archive_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/downloads","issues_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/issues{/number}","pulls_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls{/number}","milestones_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/milestones{/number}","notifications_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/labels{/name}","releases_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/releases{/id}","deployments_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/deployments","created_at":"2018-06-27T00:14:36Z","updated_at":"2018-06-27T00:27:56Z","pushed_at":"2018-07-04T08:08:55Z","git_url":"git://github.com/sundarsv/upgrad_course5_ass1gnment.git","ssh_url":"git@github.com:sundarsv/upgrad_course5_ass1gnment.git","clone_url":"https://github.com/sundarsv/upgrad_course5_ass1gnment.git","svn_url":"https://github.com/sundarsv/upgrad_course5_ass1gnment","homepage":null,"size":40,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"sundarsv:master","ref":"master","sha":"7eab1dbd0750c9d31de3afdb6ae8fecfb3c65787","user":{"login":"sundarsv","id":4122675,"node_id":"MDQ6VXNlcjQxMjI2NzU=","avatar_url":"https://avatars2.githubusercontent.com/u/4122675?v=4","gravatar_id":"","url":"https://api.github.com/users/sundarsv","html_url":"https://github.com/sundarsv","followers_url":"https://api.github.com/users/sundarsv/followers","following_url":"https://api.github.com/users/sundarsv/following{/other_user}","gists_url":"https://api.github.com/users/sundarsv/gists{/gist_id}","starred_url":"https://api.github.com/users/sundarsv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sundarsv/subscriptions","organizations_url":"https://api.github.com/users/sundarsv/orgs","repos_url":"https://api.github.com/users/sundarsv/repos","events_url":"https://api.github.com/users/sundarsv/events{/privacy}","received_events_url":"https://api.github.com/users/sundarsv/received_events","type":"User","site_admin":false},"repo":{"id":138807628,"node_id":"MDEwOlJlcG9zaXRvcnkxMzg4MDc2Mjg=","name":"upgrad_course5_ass1gnment","full_name":"sundarsv/upgrad_course5_ass1gnment","owner":{"login":"sundarsv","id":4122675,"node_id":"MDQ6VXNlcjQxMjI2NzU=","avatar_url":"https://avatars2.githubusercontent.com/u/4122675?v=4","gravatar_id":"","url":"https://api.github.com/users/sundarsv","html_url":"https://github.com/sundarsv","followers_url":"https://api.github.com/users/sundarsv/followers","following_url":"https://api.github.com/users/sundarsv/following{/other_user}","gists_url":"https://api.github.com/users/sundarsv/gists{/gist_id}","starred_url":"https://api.github.com/users/sundarsv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sundarsv/subscriptions","organizations_url":"https://api.github.com/users/sundarsv/orgs","repos_url":"https://api.github.com/users/sundarsv/repos","events_url":"https://api.github.com/users/sundarsv/events{/privacy}","received_events_url":"https://api.github.com/users/sundarsv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sundarsv/upgrad_course5_ass1gnment","description":"Course 5 assignment for Upgrad","fork":false,"url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment","forks_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/forks","keys_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/teams","hooks_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/hooks","issue_events_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/issues/events{/number}","events_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/events","assignees_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/assignees{/user}","branches_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/branches{/branch}","tags_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/tags","blobs_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/git/refs{/sha}","trees_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/statuses/{sha}","languages_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/languages","stargazers_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/stargazers","contributors_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/contributors","subscribers_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/subscribers","subscription_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/subscription","commits_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/commits{/sha}","git_commits_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/git/commits{/sha}","comments_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/comments{/number}","issue_comment_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/issues/comments{/number}","contents_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/contents/{+path}","compare_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/merges","archive_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/downloads","issues_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/issues{/number}","pulls_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls{/number}","milestones_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/milestones{/number}","notifications_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/labels{/name}","releases_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/releases{/id}","deployments_url":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/deployments","created_at":"2018-06-27T00:14:36Z","updated_at":"2018-06-27T00:27:56Z","pushed_at":"2018-07-04T08:08:55Z","git_url":"git://github.com/sundarsv/upgrad_course5_ass1gnment.git","ssh_url":"git@github.com:sundarsv/upgrad_course5_ass1gnment.git","clone_url":"https://github.com/sundarsv/upgrad_course5_ass1gnment.git","svn_url":"https://github.com/sundarsv/upgrad_course5_ass1gnment","homepage":null,"size":40,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/1"},"html":{"href":"https://github.com/sundarsv/upgrad_course5_ass1gnment/pull/1"},"issue":{"href":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/issues/1"},"comments":{"href":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/sundarsv/upgrad_course5_ass1gnment/statuses/61665574e6a7e50ee2db3afb309e229786eeba9d"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"Apoorva2405"}}