Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / src / OCResourceRequest.cpp
index 16abce1..d600017 100644 (file)
 
 #include <vector>
 #include <map>
-#include <cereal/cereal.hpp>
-#include <OicJsonSerializer.hpp>
+#include "ocpayload.h"
 
 using namespace OC;
-using namespace std;
 
-void OCResourceRequest::setPayload(const std::string& requestPayload)
+void OCResourceRequest::setPayload(OCPayload* payload)
 {
     MessageContainer info;
 
-    if(requestPayload.empty())
+    if(payload == nullptr)
     {
         return;
     }
-
-    try
-    {
-        info.setJSONRepresentation(requestPayload);
-    }
-    catch(cereal::RapidJSONException& ex)
+    if(payload->type != PAYLOAD_TYPE_REPRESENTATION)
     {
-        oclog() << "RapidJSON Exception in setPayload: "<<ex.what()<<std::endl<<
-            "Data was:"<<requestPayload<<std::flush;
-        return;
-    }
-    catch(cereal::Exception& ex)
-    {
-        oclog() << "Cereal Exception in setPayload: "<<ex.what()<<std::endl<<
-            "Data was:"<<requestPayload<<std::flush;
+        throw std::logic_error("Wrong payload type");
         return;
     }
 
+    info.setPayload(payload);
+
     const std::vector<OCRepresentation>& reps = info.representations();
     if(reps.size() >0)
     {