{"action":"created","comment":{"url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/comments/63492447","id":63492447,"diff_hunk":"@@ -0,0 +1,172 @@\n+#ifndef SRC_LIB_MONGO_BACKEND_MONGOCOMMONSUBSCRIPTION_H\n+#define SRC_LIB_MONGO_BACKEND_MONGOCOMMONSUBSCRIPTION_H\n+\n+/*\n+* Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U\n+*\n+* This file is part of Orion Context Broker.\n+*\n+* Orion Context Broker is free software: you can redistribute it and/or\n+* modify it under the terms of the GNU Affero General Public License as\n+* published by the Free Software Foundation, either version 3 of the\n+* License, or (at your option) any later version.\n+*\n+* Orion Context Broker is distributed in the hope that it will be useful,\n+* but WITHOUT ANY WARRANTY; without even the implied warranty of\n+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n+* General Public License for more details.\n+*\n+* You should have received a copy of the GNU Affero General Public License\n+* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/.\n+*\n+* For those usages not covered by this license please contact with\n+* iot_support at tid dot es\n+*\n+* Author: Fermín Galán\n+*\n+*/\n+\n+#include <string>\n+#include <vector>\n+#include \"mongo/client/dbclient.h\"\n+#include \"apiTypesV2/Subscription.h\"\n+\n+/* ****************************************************************************\n+*\n+* setNewSubscriptionId -\n+*\n+*/\n+extern std::string setNewSubscriptionId(mongo::BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setExpiration -\n+*\n+*/\n+extern void setExpiration(const ngsiv2::Subscription& sub, mongo::BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setHttpInfo -\n+*\n+*/\n+extern void setHttpInfo(const ngsiv2::Subscription& sub, mongo::BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setThrottling -\n+*\n+*/\n+extern void setThrottling(const ngsiv2::Subscription& sub, mongo::BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setServicePath -\n+*\n+*/\n+extern void setServicePath(std::string servicePath, mongo::BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setDescription -\n+*\n+*/\n+extern void setDescription(const ngsiv2::Subscription& sub, mongo::BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setStatus -\n+*\n+*/\n+extern void setStatus(const ngsiv2::Subscription& sub, mongo::BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setEntities -\n+*\n+*/\n+extern void setEntities(const ngsiv2::Subscription& sub, mongo::BSONObjBuilder* b);\n+\n+\n+/* ****************************************************************************\n+*\n+* setAttrs -\n+*\n+*/\n+extern void setAttrs(const ngsiv2::Subscription& sub, mongo::BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setCondsAndInitialNotify -\n+*\n+*/\n+extern void setCondsAndInitialNotify\n+(\n+  const ngsiv2::Subscription&      sub,\n+  const std::string&               subId,\n+  const std::string&               status,\n+  const std::string&               url,\n+  RenderFormat                     attrsFormat,\n+  const std::string&               tenant,\n+  const std::vector<std::string>&  servicePathV,\n+  const std::string&               xauthToken,\n+  const std::string&               fiwareCorrelator,\n+  BSONObjBuilder*                  b,\n+  bool*                            notificationDone\n+);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setLastNotification -\n+*\n+*/\n+void setLastNotification(long long lastNotification, BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setCount -\n+*\n+*/\n+void setCount(long long count, BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setExpression -\n+*\n+*/\n+extern void setExpression(const ngsiv2::Subscription& sub, mongo::BSONObjBuilder* b);\n+\n+\n+\n+/* ****************************************************************************\n+*\n+* setFormat -\n+*\n+*/\n+extern void setFormat(const ngsiv2::Subscription& sub, mongo::BSONObjBuilder* b);\n+\n+\n+#endif // SRC_LIB_MONGO_BACKEND_MONGOCOMMONSUBSCRIPTION_H\n+","path":"src/lib/mongoBackend/MongoCommonSubscription.h","position":null,"original_position":172,"commit_id":"fab0ac646d985dcfecadd59d98c43281737d85e5","original_commit_id":"fb156d03e81bfe975097d82a060beb8a4818d9c6","user":{"login":"fgalan","id":1534240,"avatar_url":"https://avatars.githubusercontent.com/u/1534240?v=3","gravatar_id":"","url":"https://api.github.com/users/fgalan","html_url":"https://github.com/fgalan","followers_url":"https://api.github.com/users/fgalan/followers","following_url":"https://api.github.com/users/fgalan/following{/other_user}","gists_url":"https://api.github.com/users/fgalan/gists{/gist_id}","starred_url":"https://api.github.com/users/fgalan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgalan/subscriptions","organizations_url":"https://api.github.com/users/fgalan/orgs","repos_url":"https://api.github.com/users/fgalan/repos","events_url":"https://api.github.com/users/fgalan/events{/privacy}","received_events_url":"https://api.github.com/users/fgalan/received_events","type":"User","site_admin":false},"body":"Fixed in a83018c07aaddda04d94a8f6cff35b3187ba5261","created_at":"2016-05-17T09:40:23Z","updated_at":"2016-05-17T09:40:24Z","html_url":"https://github.com/telefonicaid/fiware-orion/pull/2144#discussion_r63492447","pull_request_url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/2144","_links":{"self":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/comments/63492447"},"html":{"href":"https://github.com/telefonicaid/fiware-orion/pull/2144#discussion_r63492447"},"pull_request":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/2144"}}},"pull_request":{"url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/2144","id":70018416,"html_url":"https://github.com/telefonicaid/fiware-orion/pull/2144","diff_url":"https://github.com/telefonicaid/fiware-orion/pull/2144.diff","patch_url":"https://github.com/telefonicaid/fiware-orion/pull/2144.patch","issue_url":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/2144","number":2144,"state":"open","locked":false,"title":"Refactor subscription logic in NGSIv2","user":{"login":"fgalan","id":1534240,"avatar_url":"https://avatars.githubusercontent.com/u/1534240?v=3","gravatar_id":"","url":"https://api.github.com/users/fgalan","html_url":"https://github.com/fgalan","followers_url":"https://api.github.com/users/fgalan/followers","following_url":"https://api.github.com/users/fgalan/following{/other_user}","gists_url":"https://api.github.com/users/fgalan/gists{/gist_id}","starred_url":"https://api.github.com/users/fgalan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgalan/subscriptions","organizations_url":"https://api.github.com/users/fgalan/orgs","repos_url":"https://api.github.com/users/fgalan/repos","events_url":"https://api.github.com/users/fgalan/events{/privacy}","received_events_url":"https://api.github.com/users/fgalan/received_events","type":"User","site_admin":false},"body":"This PR is a deep refactor create/update subscription logic in NGSIv2. Parsing and mongoBackend logic has been rewritten (in the later case, new function mongoCreateSubscription() and mongoUpdateSubscription() exists, independent from the corresponding ones in NGSIv1).\r\n\r\nmake unit_test and make ft pass ok.\r\n\r\nThis is a combinated work by @crbrox and @fgalan. Thus, triple-LGTM is required:\r\n\r\n@kzangeli \r\n@crbrox \r\n@fgalan\r\n\r\nA important point to remark is that .test weren't modified (except some error message texts). That provides a good guarantee that the refactor hasn't modified the functional behavior of the NGSIv2 subscription management logic.","created_at":"2016-05-13T15:55:19Z","updated_at":"2016-05-17T09:40:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f8f9224a773e93e4e494c314bb3bbbd37e4e6900","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/2144/commits","review_comments_url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/2144/comments","review_comment_url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/comments{/number}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/2144/comments","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-orion/statuses/fab0ac646d985dcfecadd59d98c43281737d85e5","head":{"label":"telefonicaid:hardening/create_subscription_at_mongoBackend","ref":"hardening/create_subscription_at_mongoBackend","sha":"fab0ac646d985dcfecadd59d98c43281737d85e5","user":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"repo":{"id":12808420,"name":"fiware-orion","full_name":"telefonicaid/fiware-orion","owner":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/telefonicaid/fiware-orion","description":"FIWARE Orion Context Broker","fork":false,"url":"https://api.github.com/repos/telefonicaid/fiware-orion","forks_url":"https://api.github.com/repos/telefonicaid/fiware-orion/forks","keys_url":"https://api.github.com/repos/telefonicaid/fiware-orion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/telefonicaid/fiware-orion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/telefonicaid/fiware-orion/teams","hooks_url":"https://api.github.com/repos/telefonicaid/fiware-orion/hooks","issue_events_url":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/events{/number}","events_url":"https://api.github.com/repos/telefonicaid/fiware-orion/events","assignees_url":"https://api.github.com/repos/telefonicaid/fiware-orion/assignees{/user}","branches_url":"https://api.github.com/repos/telefonicaid/fiware-orion/branches{/branch}","tags_url":"https://api.github.com/repos/telefonicaid/fiware-orion/tags","blobs_url":"https://api.github.com/repos/telefonicaid/fiware-orion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/telefonicaid/fiware-orion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/telefonicaid/fiware-orion/git/refs{/sha}","trees_url":"https://api.github.com/repos/telefonicaid/fiware-orion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-orion/statuses/{sha}","languages_url":"https://api.github.com/repos/telefonicaid/fiware-orion/languages","stargazers_url":"https://api.github.com/repos/telefonicaid/fiware-orion/stargazers","contributors_url":"https://api.github.com/repos/telefonicaid/fiware-orion/contributors","subscribers_url":"https://api.github.com/repos/telefonicaid/fiware-orion/subscribers","subscription_url":"https://api.github.com/repos/telefonicaid/fiware-orion/subscription","commits_url":"https://api.github.com/repos/telefonicaid/fiware-orion/commits{/sha}","git_commits_url":"https://api.github.com/repos/telefonicaid/fiware-orion/git/commits{/sha}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-orion/comments{/number}","issue_comment_url":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/comments{/number}","contents_url":"https://api.github.com/repos/telefonicaid/fiware-orion/contents/{+path}","compare_url":"https://api.github.com/repos/telefonicaid/fiware-orion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/telefonicaid/fiware-orion/merges","archive_url":"https://api.github.com/repos/telefonicaid/fiware-orion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/telefonicaid/fiware-orion/downloads","issues_url":"https://api.github.com/repos/telefonicaid/fiware-orion/issues{/number}","pulls_url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls{/number}","milestones_url":"https://api.github.com/repos/telefonicaid/fiware-orion/milestones{/number}","notifications_url":"https://api.github.com/repos/telefonicaid/fiware-orion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/telefonicaid/fiware-orion/labels{/name}","releases_url":"https://api.github.com/repos/telefonicaid/fiware-orion/releases{/id}","deployments_url":"https://api.github.com/repos/telefonicaid/fiware-orion/deployments","created_at":"2013-09-13T11:55:25Z","updated_at":"2016-04-25T18:41:04Z","pushed_at":"2016-05-17T09:38:58Z","git_url":"git://github.com/telefonicaid/fiware-orion.git","ssh_url":"git@github.com:telefonicaid/fiware-orion.git","clone_url":"https://github.com/telefonicaid/fiware-orion.git","svn_url":"https://github.com/telefonicaid/fiware-orion","homepage":"http://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context-broker","size":25916,"stargazers_count":38,"watchers_count":38,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":61,"mirror_url":null,"open_issues_count":336,"forks":61,"open_issues":336,"watchers":38,"default_branch":"develop"}},"base":{"label":"telefonicaid:develop","ref":"develop","sha":"a7c998eab832d3a931f62d2b32c585fd180ba02f","user":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"repo":{"id":12808420,"name":"fiware-orion","full_name":"telefonicaid/fiware-orion","owner":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/telefonicaid/fiware-orion","description":"FIWARE Orion Context Broker","fork":false,"url":"https://api.github.com/repos/telefonicaid/fiware-orion","forks_url":"https://api.github.com/repos/telefonicaid/fiware-orion/forks","keys_url":"https://api.github.com/repos/telefonicaid/fiware-orion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/telefonicaid/fiware-orion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/telefonicaid/fiware-orion/teams","hooks_url":"https://api.github.com/repos/telefonicaid/fiware-orion/hooks","issue_events_url":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/events{/number}","events_url":"https://api.github.com/repos/telefonicaid/fiware-orion/events","assignees_url":"https://api.github.com/repos/telefonicaid/fiware-orion/assignees{/user}","branches_url":"https://api.github.com/repos/telefonicaid/fiware-orion/branches{/branch}","tags_url":"https://api.github.com/repos/telefonicaid/fiware-orion/tags","blobs_url":"https://api.github.com/repos/telefonicaid/fiware-orion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/telefonicaid/fiware-orion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/telefonicaid/fiware-orion/git/refs{/sha}","trees_url":"https://api.github.com/repos/telefonicaid/fiware-orion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-orion/statuses/{sha}","languages_url":"https://api.github.com/repos/telefonicaid/fiware-orion/languages","stargazers_url":"https://api.github.com/repos/telefonicaid/fiware-orion/stargazers","contributors_url":"https://api.github.com/repos/telefonicaid/fiware-orion/contributors","subscribers_url":"https://api.github.com/repos/telefonicaid/fiware-orion/subscribers","subscription_url":"https://api.github.com/repos/telefonicaid/fiware-orion/subscription","commits_url":"https://api.github.com/repos/telefonicaid/fiware-orion/commits{/sha}","git_commits_url":"https://api.github.com/repos/telefonicaid/fiware-orion/git/commits{/sha}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-orion/comments{/number}","issue_comment_url":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/comments{/number}","contents_url":"https://api.github.com/repos/telefonicaid/fiware-orion/contents/{+path}","compare_url":"https://api.github.com/repos/telefonicaid/fiware-orion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/telefonicaid/fiware-orion/merges","archive_url":"https://api.github.com/repos/telefonicaid/fiware-orion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/telefonicaid/fiware-orion/downloads","issues_url":"https://api.github.com/repos/telefonicaid/fiware-orion/issues{/number}","pulls_url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls{/number}","milestones_url":"https://api.github.com/repos/telefonicaid/fiware-orion/milestones{/number}","notifications_url":"https://api.github.com/repos/telefonicaid/fiware-orion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/telefonicaid/fiware-orion/labels{/name}","releases_url":"https://api.github.com/repos/telefonicaid/fiware-orion/releases{/id}","deployments_url":"https://api.github.com/repos/telefonicaid/fiware-orion/deployments","created_at":"2013-09-13T11:55:25Z","updated_at":"2016-04-25T18:41:04Z","pushed_at":"2016-05-17T09:38:58Z","git_url":"git://github.com/telefonicaid/fiware-orion.git","ssh_url":"git@github.com:telefonicaid/fiware-orion.git","clone_url":"https://github.com/telefonicaid/fiware-orion.git","svn_url":"https://github.com/telefonicaid/fiware-orion","homepage":"http://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context-broker","size":25916,"stargazers_count":38,"watchers_count":38,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":61,"mirror_url":null,"open_issues_count":336,"forks":61,"open_issues":336,"watchers":38,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/2144"},"html":{"href":"https://github.com/telefonicaid/fiware-orion/pull/2144"},"issue":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/2144"},"comments":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/2144/comments"},"review_comments":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/2144/comments"},"review_comment":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/2144/commits"},"statuses":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/statuses/fab0ac646d985dcfecadd59d98c43281737d85e5"}}}}