D2D Get request error fix
authorOleksandr Dmytrenko <o.dmytrenko@samsung.com>
Wed, 9 Nov 2016 15:33:44 +0000 (17:33 +0200)
committerRandeep Singh <randeep.s@samsung.com>
Tue, 22 Nov 2016 06:18:30 +0000 (06:18 +0000)
Removed payload type check in Get request

Change-Id: I405a7a6bba7255d8c05cc8a34342217c6e04e819
Signed-off-by: Oleksandr Dmytrenko <o.dmytrenko@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14163
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/provisioning/sample/cloud/cloudResource.c

index bf43744..35ec5c2 100644 (file)
@@ -55,12 +55,16 @@ static OCRepPayload* getPayload(const char* uri, int64_t power, bool state)
 static OCEntityHandlerResult ProcessRequest (OCEntityHandlerRequest *request,
         OCRepPayload **payload)
 {
-    if(!request || !request->payload || request->payload->type != PAYLOAD_TYPE_REPRESENTATION)
+    OIC_LOG_V(DEBUG, TAG, "%s: IN",  __func__);
+
+    if(!request)
     {
-        OIC_LOG(ERROR, TAG, "Incoming payload not a representation");
+        OIC_LOG_V(ERROR, TAG, "%s: OUT: request is NULL",__func__);
         return OC_EH_ERROR;
     }
 
+    OIC_LOG_V(DEBUG, TAG, "%s: method: %d",  __func__, request->method);
+
     LEDResource *currLEDResource = &LED;
 
     if (request->resource == gLedInstance[0].handle)
@@ -76,6 +80,12 @@ static OCEntityHandlerResult ProcessRequest (OCEntityHandlerRequest *request,
 
     if(OC_REST_PUT == request->method)
     {
+        if (!request->payload || request->payload->type != PAYLOAD_TYPE_REPRESENTATION)
+        {
+            OIC_LOG_V(ERROR, TAG, "%s: OUT: Incoming payload type(%d) is not a representation",
+                      __func__, request->payload ? request->payload->type : 0);
+            return OC_EH_ERROR;
+        }
         OCRepPayload* input = (OCRepPayload*)request->payload;
         // Get pointer to query
         int64_t pow;
@@ -93,7 +103,9 @@ static OCEntityHandlerResult ProcessRequest (OCEntityHandlerRequest *request,
 
     *payload = getPayload(gResourceUri, currLEDResource->power, currLEDResource->state);
 
-    return (*payload)? OC_EH_OK : OC_EH_ERROR;
+    OIC_LOG_V(DEBUG, TAG, "%s: OUT",  __func__);
+
+    return (*payload) ? OC_EH_OK : OC_EH_ERROR;
 }
 
 static OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *request,