Diff of /src/org/esb/api/JsonServer.cpp [617a65] .. [379103] Maximize Restore

  Switch to unified view

a/src/org/esb/api/JsonServer.cpp b/src/org/esb/api/JsonServer.cpp
...
...
19
#include "boost/lexical_cast.hpp"
19
#include "boost/lexical_cast.hpp"
20
#include "JsonProfileHandler.h"
20
#include "JsonProfileHandler.h"
21
#include "JsonEncodingHandler.h"
21
#include "JsonEncodingHandler.h"
22
#include "JsonStatisticsHandler.h"
22
#include "JsonStatisticsHandler.h"
23
#include "JsonMediaHandler.h"
23
#include "JsonMediaHandler.h"
24
#include "JsonSystemHandler.h"
24
#include "boost/archive/iterators/base64_from_binary.hpp"
25
#include "boost/archive/iterators/base64_from_binary.hpp"
25
#include "boost/archive/iterators/binary_from_base64.hpp"
26
#include "boost/archive/iterators/binary_from_base64.hpp"
26
#include "boost/archive/iterators/transform_width.hpp"
27
#include "boost/archive/iterators/transform_width.hpp"
27
#include "boost/thread/locks.hpp"
28
#include "boost/thread/locks.hpp"
28
#include <string>
29
#include <string>
...
...
162
          //_db.begin();
163
          //_db.begin();
163
          db::HiveDb db=org::esb::hive::DatabaseService::getDatabase();
164
          db::HiveDb db=org::esb::hive::DatabaseService::getDatabase();
164
165
165
          boost::uuids::uuid uuid = boost::uuids::random_generator()();
166
          boost::uuids::uuid uuid = boost::uuids::random_generator()();
166
          std::string requestId = boost::lexical_cast<std::string > (uuid);
167
          std::string requestId = boost::lexical_cast<std::string > (uuid);
167
      org::esb::io::File tmpFile("/tmp/test.avi");
168
      //org::esb::io::File tmpFile("/tmp/test.avi");
168
      org::esb::io::FileOutputStream fos(&tmpFile);
169
      //org::esb::io::FileOutputStream fos(&tmpFile);
169
          std::string postdata;
170
          std::string postdata;
170
          if (strcmp(request_info->request_method, "POST") == 0) {
171
          if (strcmp(request_info->request_method, "POST") == 0) {
171
            /*reading the post data that comes in*/
172
            /*reading the post data that comes in*/
172
            int bytes = 0, max = 1500, recv=0;
173
            int bytes = 0, max = 1500, recv=0;
173
            char buffer[100000];
174
            char buffer[100000];
174
            while ((bytes = mg_read(conn, buffer, sizeof (buffer))) > 0 ) {
175
            while ((bytes = mg_read(conn, buffer, sizeof (buffer))) > 0 ) {
175
              postdata = postdata.append(buffer, bytes);
176
              postdata = postdata.append(buffer, bytes);
176
              fos.write(buffer, bytes);
177
              //fos.write(buffer, bytes);
177
              max -= bytes;
178
              max -= bytes;
178
              recv+=bytes;
179
              recv+=bytes;
179
              LOGDEBUG("Recv:" << recv);
180
              //LOGDEBUG("Recv:" << recv);
180
            }
181
            }
181
          }
182
          }
182
        //  return processed;
183
        //  return processed;
183
          LOGDEBUG("PostData:" << postdata);
184
          //LOGDEBUG("PostData:" << postdata);
184
          std::string request = request_info->uri;
185
          std::string request = request_info->uri;
185
186
186
          //db::Request req(_db);
187
          //db::Request req(_db);
187
          //req.requestId = requestId;
188
          //req.requestId = requestId;
188
          if (request_info->query_string != NULL) {
189
          if (request_info->query_string != NULL) {
...
...
288
            std::string json_s = n.write_formatted();
289
            std::string json_s = n.write_formatted();
289
            mg_write(conn, json_s.c_str(), json_s.length());
290
            mg_write(conn, json_s.c_str(), json_s.length());
290
            //req.response = json_s;
291
            //req.response = json_s;
291
            //req.update();
292
            //req.update();
292
293
294
          }else if (request == BASE_API_URL"/system") {
295
            mg_printf(conn, "%s", reply_start);
296
            JSONNode n = JsonSystemHandler::handle(conn, request_info, db, postdata);
297
            n.push_back(JSONNode("requestId", requestId));
298
            std::string json_s = n.write_formatted();
299
            mg_write(conn, json_s.c_str(), json_s.length());
300
            //req.response = json_s;
301
            //req.update();
302
293
          }else{
303
          }else{
294
304
295
            //mg_printf(conn, "%s", request_info->uri);
305
            //mg_printf(conn, "%s", request_info->uri);
296
            if (strcmp(request_info->request_method, "GET") == 0) {
306
            if (strcmp(request_info->request_method, "GET") == 0) {
297
            processed = NULL;
307
            processed = NULL;