Skip to content

Commit

Permalink
ADD mongoDriver library as first step to move the code to new MongoDB…
Browse files Browse the repository at this point in the history
… new driver
  • Loading branch information
fgalan committed Feb 7, 2020
1 parent 685698a commit 4335e0e
Show file tree
Hide file tree
Showing 39 changed files with 4,481 additions and 322 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ SET (ORION_LIBS
ngsi
cache
mongoBackend
mongoDriver
parse
apiTypesV2
orionTypes
Expand Down Expand Up @@ -287,6 +288,7 @@ if (error EQUAL 0)
ADD_SUBDIRECTORY(src/lib/jsonParseV2)
ADD_SUBDIRECTORY(src/lib/rest)
ADD_SUBDIRECTORY(src/lib/mongoBackend)
ADD_SUBDIRECTORY(src/lib/mongoDriver)
ADD_SUBDIRECTORY(src/lib/cache)
ADD_SUBDIRECTORY(src/lib/alarmMgr)
ADD_SUBDIRECTORY(src/lib/metricsMgr)
Expand Down
1 change: 1 addition & 0 deletions scripts/style_check_in_makefile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ style_check src/lib/logSummary
style_check src/lib/jsonParseV2
style_check src/lib/apiTypesV2
style_check src/lib/mongoBackend
style_check src/lib/mongoDriver
style_check src/lib/logMsg
style_check src/lib/parseArgs
style_check src/lib/cache
Expand Down
43 changes: 14 additions & 29 deletions src/lib/apiTypesV2/HttpInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,16 @@
#include <string>
#include <map>

#include "mongo/client/dbclient.h"
#include "logMsg/logMsg.h"

#include "common/JsonHelper.h"
#include "mongoBackend/dbConstants.h"
#include "mongoBackend/safeMongo.h"
#include "apiTypesV2/HttpInfo.h"


#include "apiTypesV2/HttpInfo.h"

/* ****************************************************************************
*
* USING
*/
using mongo::BSONObj;
using mongo::BSONElement;
#include "mongoBackend/dbConstants.h"

#include "mongoDriver/BSONObj.h"
#include "mongoDriver/BSONElement.h"
#include "mongoDriver/safeMongo.h"


namespace ngsiv2
Expand Down Expand Up @@ -108,7 +101,7 @@ std::string HttpInfo::toJson()
*
* HttpInfo::fill -
*/
void HttpInfo::fill(const BSONObj& bo)
void HttpInfo::fill(const orion::BSONObj& bo)
{
this->url = bo.hasField(CSUB_REFERENCE)? getStringFieldF(bo, CSUB_REFERENCE) : "";
this->custom = bo.hasField(CSUB_CUSTOM)? getBoolFieldF(bo, CSUB_CUSTOM) : false;
Expand All @@ -122,30 +115,22 @@ void HttpInfo::fill(const BSONObj& bo)
this->verb = str2Verb(getStringFieldF(bo, CSUB_METHOD));
}

// FIXME P10: toStringMap could raise exception if array elements are not strings
// (the parsing stage should avoid the case, but better to be protetec with a catch statement)
// qs
if (bo.hasField(CSUB_QS))
{
BSONObj qs = getObjectFieldF(bo, CSUB_QS);

for (BSONObj::iterator i = qs.begin(); i.more();)
{
BSONElement e = i.next();

this->qs[e.fieldName()] = e.String();
}
orion::BSONObj qs = getObjectFieldF(bo, CSUB_QS);
qs.toStringMap(&this->qs);
}

// FIXME P10: toStringMap could raise exception if array elements are not strings
// (the parsing stage should avoid the case, but better to be protetec with a catch statement)
// headers
if (bo.hasField(CSUB_HEADERS))
{
BSONObj headers = getObjectFieldF(bo, CSUB_HEADERS);

for (BSONObj::iterator i = headers.begin(); i.more();)
{
BSONElement e = i.next();

this->headers[e.fieldName()] = e.String();
}
orion::BSONObj headers = getObjectFieldF(bo, CSUB_HEADERS);
headers.toStringMap(&this->headers);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/apiTypesV2/HttpInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
#include <string>
#include <map>

#include "mongo/client/dbclient.h"
#include "rest/Verb.h"

#include "mongoDriver/BSONObj.h"



namespace ngsiv2
Expand All @@ -52,7 +53,7 @@ struct HttpInfo
explicit HttpInfo(const std::string& _url);

std::string toJson();
void fill(const mongo::BSONObj& bo);
void fill(const orion::BSONObj& bo);
};
}

Expand Down
Loading

0 comments on commit 4335e0e

Please sign in to comment.