Merge branch '9m_rest' into hdf5

This commit is contained in:
Dhanya Maliakal
2016-12-15 14:33:38 +01:00
4 changed files with 163 additions and 118 deletions

View File

@ -18,6 +18,7 @@
#include <Poco/Timespan.h>
#include "JsonBox/Value.h"
#include "JsonBox/JsonParsingError.h"
//#include "logger.h"
@ -167,8 +168,8 @@ class RestHelper {
string answer;
int code = send_request(session, req, &answer);
if(code == 0 ) {
FILE_LOG(logDEBUG) << __AT__ << " REQUEST: " << " ANSWER: " << answer;
json_value->loadFromString(answer);
FILE_LOG(logDEBUG) << __AT__ << " REQUEST: " << " ANSWER: " << answer;
json_value->loadFromString(answer);
}
delete uri;
return code;
@ -220,7 +221,17 @@ class RestHelper {
string answer;
int code = send_request(session, req, &answer, request_body);
if(code==0){
json_value->loadFromString(answer);
try{
json_value->loadFromString(answer);
}
catch (JsonBox::JsonParsingError& e){
try{
json_value->loadFromString("{\"global_state\":\"" + answer + "\"}");
}
catch(exception &e){
FILE_LOG(logERROR) << "Exception converting answer: " << e.what() ;
}
}
}
delete uri;
return code;

View File

@ -42,8 +42,8 @@ public:
/**
* Get Rest State
*/
int get_rest_state(RestHelper * rest, string *rest_state);
string get_rest_state(RestHelper * rest/*, string *rest_state*/);
/*************************************************************************
* Setters ***************************************************************
@ -138,12 +138,15 @@ public:
*/
void closeFile(int i = -1);
uint64_t getTotalFramesCaught() const;
private:
bool isInitialized;
RestHelper * rest ;
int rest_port; // receiver backend port
string rest_hostname; // receiver hostname
bool is_main_receiver;
};