{"action":"created","comment":{"url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/comments/29145734","id":29145734,"diff_hunk":"@@ -82,37 +83,78 @@ with JacksonJsonSupport {\n                             \" does not validate properly. \" + head.path + \" \" + head.message))\n \n                     case Nil => {\n+                        // valid and non-empty json, write to db\n+                        writePreference(metadata, preferenceSlug, id, payload)\n+                    }\n+                }\n+            }\n+            case None => BadRequest(jsonifyError(\"Preferences for /\" + preferenceSlug + \" does not have any metadata\"))\n+        }\n+    }\n \n-                        db.withSession { implicit session =>\n-                            val prefsForIdandSlug = preferences.filter(prefs => prefs.id === id && prefs.preferencesMetadataId === metadata.id)\n-\n-                            prefsForIdandSlug.list match {\n-                                case List(_: Preferences) => {\n-\n-                                    preferences\n-                                        .filter(prefs => prefs.id === id && prefs.preferencesMetadataId === metadata.id)\n-                                        .map(prefs => (prefs.payload, prefs.updated))\n-                                        .update(payload, DateTime.now)\n-\n-                                    Ok()\n-                                }\n-                                case _ => {\n-\n-                                    preferences\n-                                        .map(p => (p.id, p.preferencesMetadataId, p.payload, p.alternateId))\n-                                        .insert(id, metadata.id.get, payload, getAlternateId(request))\n+    def writePreference(metadata: PreferencesMetadata, preferenceSlug: String, id: String, payload: String): ActionResult = {\n+        //write preference to db\n+        validateContent(payload) match {\n+            case PreferenceValidate.InvalidContainer => {\n+                // payload has bad container name(s)\n+                BadRequest(jsonifyError(\"Preferences for /\" + preferenceSlug + \" contains invalid container name\"))","path":"app/src/main/scala/com/rackspace/prefs/PreferencesService.scala","position":53,"original_position":53,"commit_id":"74a709b6caa8feff9b09441687f8aca9928286ab","original_commit_id":"74a709b6caa8feff9b09441687f8aca9928286ab","user":{"login":"shintasmith","id":3640870,"avatar_url":"https://avatars.githubusercontent.com/u/3640870?v=3","gravatar_id":"","url":"https://api.github.com/users/shintasmith","html_url":"https://github.com/shintasmith","followers_url":"https://api.github.com/users/shintasmith/followers","following_url":"https://api.github.com/users/shintasmith/following{/other_user}","gists_url":"https://api.github.com/users/shintasmith/gists{/gist_id}","starred_url":"https://api.github.com/users/shintasmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shintasmith/subscriptions","organizations_url":"https://api.github.com/users/shintasmith/orgs","repos_url":"https://api.github.com/users/shintasmith/repos","events_url":"https://api.github.com/users/shintasmith/events{/privacy}","received_events_url":"https://api.github.com/users/shintasmith/received_events","type":"User","site_admin":false},"body":"We should print the whole URL here. I.e: /preferenceSlug/tenantId. Also it would help printing the invalid URL.","created_at":"2015-04-27T13:32:53Z","updated_at":"2015-04-27T13:32:53Z","html_url":"https://github.com/rackerlabs/cloudfeeds-preferences-svc/pull/37#discussion_r29145734","pull_request_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/37","_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/comments/29145734"},"html":{"href":"https://github.com/rackerlabs/cloudfeeds-preferences-svc/pull/37#discussion_r29145734"},"pull_request":{"href":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/37"}}},"pull_request":{"url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/37","id":34082702,"html_url":"https://github.com/rackerlabs/cloudfeeds-preferences-svc/pull/37","diff_url":"https://github.com/rackerlabs/cloudfeeds-preferences-svc/pull/37.diff","patch_url":"https://github.com/rackerlabs/cloudfeeds-preferences-svc/pull/37.patch","issue_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/issues/37","number":37,"state":"open","locked":false,"title":"Cf 796 validation for container name","user":{"login":"VinnyQ","id":203223,"avatar_url":"https://avatars.githubusercontent.com/u/203223?v=3","gravatar_id":"","url":"https://api.github.com/users/VinnyQ","html_url":"https://github.com/VinnyQ","followers_url":"https://api.github.com/users/VinnyQ/followers","following_url":"https://api.github.com/users/VinnyQ/following{/other_user}","gists_url":"https://api.github.com/users/VinnyQ/gists{/gist_id}","starred_url":"https://api.github.com/users/VinnyQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VinnyQ/subscriptions","organizations_url":"https://api.github.com/users/VinnyQ/orgs","repos_url":"https://api.github.com/users/VinnyQ/repos","events_url":"https://api.github.com/users/VinnyQ/events{/privacy}","received_events_url":"https://api.github.com/users/VinnyQ/received_events","type":"User","site_admin":false},"body":"@shintasmith @usnavi @ChandraAddala \r\n\r\nPlease review, for story https://jira.rax.io/browse/CF-796, to throw 400 if users submit preference with bad container names.\r\n\r\nI am uncertain whether we want to do a negative test for invalid characters, or test for *only* valid characters, which I am also uncertain if they're just limited to ALPHANUMERIC, '.', '-', and '_'\r\n\r\nCurrent implementation is with negative test for invalid characters.  What do you guys think?\r\n","created_at":"2015-04-24T20:20:20Z","updated_at":"2015-04-27T13:32:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2834196bd28d24a9330fd1ffc13a08e6674f6299","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/37/commits","review_comments_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/37/comments","review_comment_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/issues/37/comments","statuses_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/statuses/74a709b6caa8feff9b09441687f8aca9928286ab","head":{"label":"VinnyQ:CF-796_validation_for_container_name","ref":"CF-796_validation_for_container_name","sha":"74a709b6caa8feff9b09441687f8aca9928286ab","user":{"login":"VinnyQ","id":203223,"avatar_url":"https://avatars.githubusercontent.com/u/203223?v=3","gravatar_id":"","url":"https://api.github.com/users/VinnyQ","html_url":"https://github.com/VinnyQ","followers_url":"https://api.github.com/users/VinnyQ/followers","following_url":"https://api.github.com/users/VinnyQ/following{/other_user}","gists_url":"https://api.github.com/users/VinnyQ/gists{/gist_id}","starred_url":"https://api.github.com/users/VinnyQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VinnyQ/subscriptions","organizations_url":"https://api.github.com/users/VinnyQ/orgs","repos_url":"https://api.github.com/users/VinnyQ/repos","events_url":"https://api.github.com/users/VinnyQ/events{/privacy}","received_events_url":"https://api.github.com/users/VinnyQ/received_events","type":"User","site_admin":false},"repo":{"id":34081913,"name":"cloudfeeds-preferences-svc","full_name":"VinnyQ/cloudfeeds-preferences-svc","owner":{"login":"VinnyQ","id":203223,"avatar_url":"https://avatars.githubusercontent.com/u/203223?v=3","gravatar_id":"","url":"https://api.github.com/users/VinnyQ","html_url":"https://github.com/VinnyQ","followers_url":"https://api.github.com/users/VinnyQ/followers","following_url":"https://api.github.com/users/VinnyQ/following{/other_user}","gists_url":"https://api.github.com/users/VinnyQ/gists{/gist_id}","starred_url":"https://api.github.com/users/VinnyQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VinnyQ/subscriptions","organizations_url":"https://api.github.com/users/VinnyQ/orgs","repos_url":"https://api.github.com/users/VinnyQ/repos","events_url":"https://api.github.com/users/VinnyQ/events{/privacy}","received_events_url":"https://api.github.com/users/VinnyQ/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/VinnyQ/cloudfeeds-preferences-svc","description":"A web service for managing flat JSON based preferences and metadata","fork":true,"url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc","forks_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/forks","keys_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/teams","hooks_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/hooks","issue_events_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/issues/events{/number}","events_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/events","assignees_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/assignees{/user}","branches_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/branches{/branch}","tags_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/tags","blobs_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/git/refs{/sha}","trees_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/statuses/{sha}","languages_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/languages","stargazers_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/stargazers","contributors_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/contributors","subscribers_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/subscribers","subscription_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/subscription","commits_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/commits{/sha}","git_commits_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/git/commits{/sha}","comments_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/comments{/number}","issue_comment_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/issues/comments{/number}","contents_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/contents/{+path}","compare_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/merges","archive_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/downloads","issues_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/issues{/number}","pulls_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/pulls{/number}","milestones_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/milestones{/number}","notifications_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/labels{/name}","releases_url":"https://api.github.com/repos/VinnyQ/cloudfeeds-preferences-svc/releases{/id}","created_at":"2015-04-16T21:35:49Z","updated_at":"2015-04-23T06:11:31Z","pushed_at":"2015-04-24T20:15:57Z","git_url":"git://github.com/VinnyQ/cloudfeeds-preferences-svc.git","ssh_url":"git@github.com:VinnyQ/cloudfeeds-preferences-svc.git","clone_url":"https://github.com/VinnyQ/cloudfeeds-preferences-svc.git","svn_url":"https://github.com/VinnyQ/cloudfeeds-preferences-svc","homepage":null,"size":247,"stargazers_count":0,"watchers_count":0,"language":"Scala","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":"rackerlabs:master","ref":"master","sha":"cab613789bce0496b5c04d3562856bac836f7c6e","user":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":26763049,"name":"cloudfeeds-preferences-svc","full_name":"rackerlabs/cloudfeeds-preferences-svc","owner":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rackerlabs/cloudfeeds-preferences-svc","description":"A web service for managing flat JSON based preferences and metadata","fork":false,"url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc","forks_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/forks","keys_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/teams","hooks_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/hooks","issue_events_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/issues/events{/number}","events_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/events","assignees_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/assignees{/user}","branches_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/branches{/branch}","tags_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/tags","blobs_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/git/refs{/sha}","trees_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/statuses/{sha}","languages_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/languages","stargazers_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/stargazers","contributors_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/contributors","subscribers_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/subscribers","subscription_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/subscription","commits_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/commits{/sha}","git_commits_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/git/commits{/sha}","comments_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/comments{/number}","issue_comment_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/issues/comments{/number}","contents_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/contents/{+path}","compare_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/merges","archive_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/downloads","issues_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/issues{/number}","pulls_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls{/number}","milestones_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/milestones{/number}","notifications_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/labels{/name}","releases_url":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/releases{/id}","created_at":"2014-11-17T15:30:38Z","updated_at":"2015-04-22T14:10:00Z","pushed_at":"2015-04-24T20:20:21Z","git_url":"git://github.com/rackerlabs/cloudfeeds-preferences-svc.git","ssh_url":"git@github.com:rackerlabs/cloudfeeds-preferences-svc.git","clone_url":"https://github.com/rackerlabs/cloudfeeds-preferences-svc.git","svn_url":"https://github.com/rackerlabs/cloudfeeds-preferences-svc","homepage":null,"size":1382,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":1,"forks":7,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/37"},"html":{"href":"https://github.com/rackerlabs/cloudfeeds-preferences-svc/pull/37"},"issue":{"href":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/issues/37"},"comments":{"href":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/rackerlabs/cloudfeeds-preferences-svc/statuses/74a709b6caa8feff9b09441687f8aca9928286ab"}}}}