{"action":"created","comment":{"url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/comments/41396767","id":41396767,"diff_hunk":"@@ -0,0 +1,710 @@\n+/*\n+*\n+* Copyright 2015 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+#include \"mongoBackend/MongoGlobal.h\"\n+#include \"mongoBackend/connectionOperations.h\"\n+#include \"logMsg/traceLevels.h\"\n+\n+#include \"mongo/client/dbclient.h\"\n+\n+using namespace mongo;\n+\n+// FIXME P5: this macro is also in other parts of the code (grep for 'FT(x)'). It should\n+// be moved to a common place\n+#define FT(x) (x == true)? \"true\" : \"false\"\n+\n+/* ****************************************************************************\n+*\n+* collectionQuery -\n+*\n+*/\n+bool collectionQuery\n+(\n+    const std::string&             col,\n+    const BSONObj&                 q,\n+    std::auto_ptr<DBClientCursor>* cursor,\n+    std::string*                   err\n+)\n+{\n+  DBClientBase* connection = getMongoConnection();\n+\n+  if (connection == NULL)\n+  {\n+     LM_E((\"Fatal Error (null DB connection)\"));\n+     *err = \"null DB connection\";\n+     return false;\n+  }\n+\n+  LM_T(LmtMongo, (\"query() in '%s' collection: '%s'\", col.c_str(), q.toString().c_str()));\n+\n+  try\n+  {\n+    *cursor = connection->query(col.c_str(), q);\n+\n+    // We have observed that in some cases of DB errors (e.g. the database daemon is down) instead of\n+    // raising an exception, the query() method sets the cursor to NULL. In this case, we raise the\n+    // exception ourselves\n+    //\n+    if (cursor->get() == NULL)\n+    {\n+      throw DBException(\"Null cursor from mongo (details on this is found in the source code)\", 0);\n+    }\n+    releaseMongoConnection(connection);\n+    LM_I((\"Database Operation Successful (query: %s)\", q.toString().c_str()));\n+  }\n+  catch (const DBException &e)\n+  {\n+    releaseMongoConnection(connection);       \n+    std::string msg = std::string(\"collection: \") + col +\n+      \" - query(): \" + q.toString() +\n+      \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col +\n+      \" - query(): \" + q.toString() +\n+      \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* collectionRangedQuery -\n+*\n+*/\n+extern bool collectionRangedQuery\n+(\n+    const std::string&             col,\n+    const Query&                   q,\n+    int                            limit,\n+    int                            offset,\n+    std::auto_ptr<DBClientCursor>* cursor,\n+    long long*                     count,\n+    std::string*                   err\n+)\n+{\n+  DBClientBase* connection = getMongoConnection();\n+\n+  if (connection == NULL)\n+  {\n+     LM_E((\"Fatal Error (null DB connection)\"));\n+     *err = \"null DB connection\";\n+     return false;\n+  }\n+\n+  LM_T(LmtMongo, (\"query() in '%s' collection: '%s'\", col.c_str(), q.toString().c_str()));\n+\n+  try\n+  {\n+    if (count != NULL)\n+    {\n+      *count = connection->count(col.c_str(), q);\n+    }\n+\n+    *cursor = connection->query(col.c_str(), q, limit, offset);\n+\n+    // We have observed that in some cases of DB errors (e.g. the database daemon is down) instead of\n+    // raising an exception, the query() method sets the cursor to NULL. In this case, we raise the\n+    // exception ourselves\n+    //\n+    if (cursor->get() == NULL)\n+    {\n+      throw DBException(\"Null cursor from mongo (details on this is found in the source code)\", 0);\n+    }\n+    releaseMongoConnection(connection);\n+    LM_I((\"Database Operation Successful (query: %s)\", q.toString().c_str()));\n+  }\n+  catch (const DBException &e)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - query(): \" + q.toString() +\n+      \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - query(): \" + q.toString() +\n+      \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* collectionCount -\n+*\n+*/\n+bool collectionCount\n+(\n+  const std::string&             col,\n+  const BSONObj&                 q,\n+  unsigned long long*            c,\n+  std::string*                   err\n+)\n+{\n+  DBClientBase* connection = getMongoConnection();\n+\n+  if (connection == NULL)\n+  {\n+     LM_E((\"Fatal Error (null DB connection)\"));\n+     *err = \"null DB connection\";\n+     return false;\n+  }\n+\n+  LM_T(LmtMongo, (\"count() in '%s' collection: '%s'\", col.c_str(), q.toString().c_str()));\n+\n+  try\n+  {\n+    *c = connection->count(col.c_str(), q);\n+    releaseMongoConnection(connection);\n+    LM_I((\"Database Operation Successful (count: %s)\", q.toString().c_str()));\n+\n+    return c;\n+  }\n+  catch (const DBException& e)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - count(): \" + q.toString() +\n+      \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - query(): \" + q.toString() +\n+      \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* collectionFindOne -\n+*\n+*/\n+extern bool collectionFindOne\n+(\n+    const std::string&             col,\n+    const BSONObj&                 q,\n+    BSONObj*                       doc,\n+    std::string*                   err\n+)\n+{\n+  DBClientBase* connection = getMongoConnection();\n+\n+  if (connection == NULL)\n+  {\n+    LM_E((\"Fatal Error (null DB connection)\"));\n+    *err = \"null DB connection\";\n+    return false;\n+  }\n+\n+  LM_T(LmtMongo, (\"findOne() in '%s' collection: '%s'\", col.c_str(), q.toString().c_str()));\n+  try\n+  {\n+    *doc = connection->findOne(col.c_str(), q);\n+    releaseMongoConnection(connection);\n+    LM_I((\"Database Operation Successful (findOne: %s)\", q.toString().c_str()));\n+  }\n+  catch (const DBException &e)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+        \" - findOne(): \" + q.toString() +\n+        \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+        \" - findOne(): \" + q.toString() +\n+        \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* collectionInsert -\n+*\n+*/\n+bool collectionInsert\n+(\n+    const std::string&             col,\n+    const BSONObj&                 doc,\n+    std::string*                   err\n+)\n+{\n+  DBClientBase* connection = getMongoConnection();\n+\n+  if (connection == NULL)\n+  {\n+     LM_E((\"Fatal Error (null DB connection)\"));\n+     *err = \"null DB connection\";\n+     return false;\n+  }\n+\n+  LM_T(LmtMongo, (\"insert() in '%s' collection: '%s'\", col.c_str(), doc.toString().c_str()));\n+\n+  try\n+  {\n+    connection->insert(col.c_str(), doc);\n+    releaseMongoConnection(connection);\n+    LM_I((\"Database Operation Successful (insert: %s)\", doc.toString().c_str()));\n+  }\n+  catch (const DBException &e)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - insert(): \" + doc.toString() +\n+      \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - insert(): \" + doc.toString() +\n+      \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* collectionUpdate -\n+*\n+*/\n+bool collectionUpdate\n+(\n+    const std::string&             col,\n+    const BSONObj&                 q,\n+    const BSONObj&                 doc,\n+    bool                           upsert,\n+    std::string*                   err\n+)\n+{\n+  DBClientBase* connection = getMongoConnection();\n+\n+  if (connection == NULL)\n+  {\n+     LM_E((\"Fatal Error (null DB connection)\"));\n+     *err = \"null DB connection\";\n+     return false;\n+  }\n+\n+  LM_T(LmtMongo, (\"update() in '%s' collection: query='%s' doc='%s', upsert=%s\", col.c_str(), q.toString().c_str(), doc.toString().c_str(), FT(upsert)));\n+\n+  try\n+  {\n+    connection->update(col.c_str(), q, doc, upsert);\n+    releaseMongoConnection(connection);\n+    LM_I((\"Database Operation Successful (update: <%s, %s>)\", q.toString().c_str(), doc.toString().c_str()));\n+  }\n+  catch (const DBException& e)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - update(): <\" + q.toString() + \",\" + doc.toString() + \">\" +\n+      \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - update(): <\" + q.toString() + \",\" + doc.toString() + \">\" +\n+      \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* collectionRemove -\n+*\n+*/\n+bool collectionRemove\n+(\n+    const std::string&             col,\n+    const BSONObj&                 q,\n+    std::string*                   err\n+)\n+{\n+  DBClientBase* connection = getMongoConnection();\n+\n+  if (connection == NULL)\n+  {\n+     LM_E((\"Fatal Error (null DB connection)\"));\n+     *err = \"null DB connection\";\n+     return false;\n+  }\n+\n+  LM_T(LmtMongo, (\"remove() in '%s' collection: {%s}\", col.c_str(), q.toString().c_str()));\n+\n+  try\n+  {\n+    connection->remove(col.c_str(), q);\n+    releaseMongoConnection(connection);\n+    LM_I((\"Database Operation Successful (remove: %s)\", q.toString().c_str()));\n+  }\n+  catch (const DBException &e)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - remove(): \" + q.toString() +\n+      \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - remove(): \" + q.toString() +\n+      \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* collectionCreateIndex -\n+*\n+*/\n+bool collectionCreateIndex\n+(\n+  const std::string&             col,\n+  const BSONObj&                 indexes,\n+  std::string*                   err\n+)\n+{\n+  DBClientBase* connection = getMongoConnection();\n+\n+  if (connection == NULL)\n+  {\n+    LM_E((\"Fatal Error (null DB connection)\"));\n+    return false;\n+  }\n+\n+  LM_T(LmtMongo, (\"createIndex() in '%s' collection: '%s'\", col.c_str(), indexes.toString().c_str()));\n+\n+  try\n+  {\n+    connection->createIndex(col.c_str(), indexes);\n+    releaseMongoConnection(connection);\n+    LM_I((\"Database Operation Successful (createIndex: %s)\", indexes.toString().c_str()));\n+\n+  }\n+  catch (const DBException &e)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - createIndex(): \" + indexes.toString() +\n+      \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    releaseMongoConnection(connection);\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - createIndex(): \" + indexes.toString() +\n+      \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* runCollectionCommand -\n+*\n+*/\n+bool runCollectionCommand\n+(\n+  const std::string&             col,\n+  const BSONObj&                 command,\n+  BSONObj*                       result,\n+  std::string*                   err\n+)\n+{\n+  return runCollectionCommand(NULL, col, command, result, err);\n+}\n+\n+\n+/* ****************************************************************************\n+*\n+* runCollectionCommand -\n+*\n+*/\n+bool runCollectionCommand\n+(\n+  DBClientBase*                  connection,\n+  const std::string&             col,\n+  const BSONObj&                 command,\n+  BSONObj*                       result,\n+  std::string*                   err\n+)\n+{\n+  /* Different from other method in this module, this function can get the connection\n+   * in the params, instead of using getMongoConnection(). This is only done from\n+   * DB connection bootstrapping code */\n+  bool releaseConnection = connection == NULL? true : false;\n+  if (connection == NULL)\n+  {\n+    connection = getMongoConnection();\n+    if (connection == NULL)\n+    {\n+      LM_E((\"Fatal Error (null DB connection)\"));\n+      return false;\n+    }\n+  }\n+\n+  LM_T(LmtMongo, (\"runCommand() in '%s' collection: '%s'\", col.c_str(), command.toString().c_str()));\n+\n+  try\n+  {\n+    connection->runCommand(col.c_str(), command, *result);\n+    if (releaseConnection)\n+    {\n+      releaseMongoConnection(connection);\n+    }\n+    LM_I((\"Database Operation Successful (command: %s)\", command.toString().c_str()));\n+  }\n+  catch (const DBException &e)\n+  {\n+    if (releaseConnection)\n+    {\n+      releaseMongoConnection(connection);\n+    }\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - runCommand(): \" + command.toString() +\n+      \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    if (releaseConnection)\n+    {\n+      releaseMongoConnection(connection);\n+    }\n+    std::string msg = std::string(\"collection: \") + col.c_str() +\n+      \" - runCommand(): \" + command.toString() +\n+      \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* setWriteConcern -\n+*\n+*/\n+bool setWriteConcern\n+(\n+  DBClientBase*                  connection,\n+  const WriteConcern&            wc,\n+  std::string*                   err\n+)\n+{\n+  LM_T(LmtMongo, (\"setWritteConcern(): '%d'\", wc.nodes()));\n+\n+  try\n+  {\n+    connection->setWriteConcern(wc);\n+    LM_I((\"Database Operation Successful (setWriteConcern: %d)\", wc.nodes()));\n+  }\n+  catch (const DBException &e)\n+  {\n+    // FIXME: include wc.nodes() in the output message, + operator doesn't work with integers\n+    std::string msg = std::string(\"setWritteConcern(): \") + /*wc.nodes() +*/\n+      \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    // FIXME: include wc.nodes() in the output message, + operator doesn't work with integers\n+    std::string msg = std::string(\"setWritteConcern(): \") + /*wc.nodes() + */\n+      \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* getWriteConcern -\n+*\n+*/\n+bool getWriteConcern\n+(\n+  DBClientBase*                  connection,\n+  WriteConcern*                  wc,\n+  std::string*                   err\n+)\n+{\n+  LM_T(LmtMongo, (\"getWriteConcern()\"));\n+\n+  try\n+  {\n+    *wc = connection->getWriteConcern();\n+    LM_I((\"Database Operation Successful (getWriteConcern)\"));\n+  }\n+  catch (const DBException &e)\n+  {\n+    std::string msg = std::string(\"getWritteConern()\") +\n+      \" - exception: \" + e.what();\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    std::string msg = std::string(\"getWritteConern()\") +\n+      \" - exception: generic\";\n+    *err = \"Database Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}\n+\n+/* ****************************************************************************\n+*\n+* connectionAuth -\n+*\n+*/\n+extern bool connectionAuth\n+(\n+  DBClientBase*                  connection,\n+  const std::string              db,\n+  const std::string              user,\n+  const std::string              password,\n+  std::string*                   err\n+)\n+{\n+  try {\n+    std::string authErr;\n+    if (!connection->auth(db, user, password, authErr))\n+    {\n+      std::string msg = std::string(\"authentication fails: db=\") + db +\n+          \", username='\" + user + \"'\" +\n+          \", password='*****'\" +\n+          \", auth_error='\" + authErr + \"'\";\n+      *err = \"Database Startup Error (\" + msg + \")\";\n+      LM_E((err->c_str()));\n+      return false;\n+    }\n+  }\n+  catch (const DBException &e)\n+  {\n+    std::string msg = std::string(\"authentication fails: db=\") + db +\n+        \", username='\" + user + \"'\" +\n+        \", password='*****'\" +\n+        \", expection='\" + e.what() + \"'\";\n+    *err = \"Database Startup Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+  catch (...)\n+  {\n+    std::string msg = std::string(\"authentication fails: db=\") + db +\n+        \", username='\" + user + \"'\" +\n+        \", password='*****'\" +\n+        \", expection=generic\";\n+    *err = \"Database Startup Error (\" + msg + \")\";\n+    LM_E((err->c_str()));\n+    return false;\n+  }\n+\n+  return true;\n+}","path":"src/lib/mongoBackend/connectionOperations.cpp","position":710,"original_position":710,"commit_id":"31ff69ce4301e01acba0d48f235bc6cfd7948e4a","original_commit_id":"31ff69ce4301e01acba0d48f235bc6cfd7948e4a","user":{"login":"kzangeli","id":5338380,"avatar_url":"https://avatars.githubusercontent.com/u/5338380?v=3","gravatar_id":"","url":"https://api.github.com/users/kzangeli","html_url":"https://github.com/kzangeli","followers_url":"https://api.github.com/users/kzangeli/followers","following_url":"https://api.github.com/users/kzangeli/following{/other_user}","gists_url":"https://api.github.com/users/kzangeli/gists{/gist_id}","starred_url":"https://api.github.com/users/kzangeli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kzangeli/subscriptions","organizations_url":"https://api.github.com/users/kzangeli/orgs","repos_url":"https://api.github.com/users/kzangeli/repos","events_url":"https://api.github.com/users/kzangeli/events{/privacy}","received_events_url":"https://api.github.com/users/kzangeli/received_events","type":"User","site_admin":false},"body":"ok, pity ...\r\n\r\nNTC","created_at":"2015-10-07T14:29:54Z","updated_at":"2015-10-07T14:29:54Z","html_url":"https://github.com/telefonicaid/fiware-orion/pull/1333#discussion_r41396767","pull_request_url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/1333","_links":{"self":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/comments/41396767"},"html":{"href":"https://github.com/telefonicaid/fiware-orion/pull/1333#discussion_r41396767"},"pull_request":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/1333"}}},"pull_request":{"url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/1333","id":47029016,"html_url":"https://github.com/telefonicaid/fiware-orion/pull/1333","diff_url":"https://github.com/telefonicaid/fiware-orion/pull/1333.diff","patch_url":"https://github.com/telefonicaid/fiware-orion/pull/1333.patch","issue_url":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/1333","number":1333,"state":"open","locked":false,"title":"REFACTOR connection operations in a common module under mongoBackend","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":"Almost all connection functions factorized into connectionOperations.cpp/h, greatly improving readibility and manteniability of the code.\r\n\r\nOnly one module has been left out in this refactor: MongoCommonUpdate.cpp (in order to collide with ongoing PR https://github.com/telefonicaid/fiware-orion/pull/1295). The refactoring work in that file is deferred to the future.\r\n\r\nUnit test and test harness 100% ok.","created_at":"2015-10-07T13:47:55Z","updated_at":"2015-10-07T14:29:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1a9bcc1129af0bfa23c770d29524b7109bc897f3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/1333/commits","review_comments_url":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/1333/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/1333/comments","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-orion/statuses/31ff69ce4301e01acba0d48f235bc6cfd7948e4a","head":{"label":"telefonicaid:hardening/mongoBackend_ops_refactor","ref":"hardening/mongoBackend_ops_refactor","sha":"31ff69ce4301e01acba0d48f235bc6cfd7948e4a","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}","created_at":"2013-09-13T11:55:25Z","updated_at":"2015-09-18T15:15:11Z","pushed_at":"2015-10-07T14:28:12Z","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":28052,"stargazers_count":30,"watchers_count":30,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":42,"mirror_url":null,"open_issues_count":206,"forks":42,"open_issues":206,"watchers":30,"default_branch":"develop"}},"base":{"label":"telefonicaid:develop","ref":"develop","sha":"9dd72805d7cc2785d799b63747d3ede2cc0fa384","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}","created_at":"2013-09-13T11:55:25Z","updated_at":"2015-09-18T15:15:11Z","pushed_at":"2015-10-07T14:28:12Z","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":28052,"stargazers_count":30,"watchers_count":30,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":42,"mirror_url":null,"open_issues_count":206,"forks":42,"open_issues":206,"watchers":30,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/1333"},"html":{"href":"https://github.com/telefonicaid/fiware-orion/pull/1333"},"issue":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/1333"},"comments":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/issues/1333/comments"},"review_comments":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/pulls/1333/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/1333/commits"},"statuses":{"href":"https://api.github.com/repos/telefonicaid/fiware-orion/statuses/31ff69ce4301e01acba0d48f235bc6cfd7948e4a"}}}}