Fixed [IOT-1414]
authorSandeep Sharma <sandeep.s9@samsung.com>
Fri, 7 Oct 2016 12:52:55 +0000 (18:22 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Mon, 10 Oct 2016 08:41:14 +0000 (08:41 +0000)
Propagate INVALID_CALLBACK  instead of INVALID_PARAM when Listener is null

Change-Id: Id41c9be5dc33e9220c4809351b8269738eb95f56
Signed-off-by: Sandeep Sharma <sandeep.s9@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/12949
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
android/android_api/base/jni/JniOcCloudProvisioning.cpp
android/android_api/base/jni/JniOcSecureResource.cpp

index 72f94de..c1bac6a 100644 (file)
@@ -271,7 +271,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_requestCertifi
     LOGD("OcCloudProvisioning_requestCertificate");
     if (!jListener)
     {
-        ThrowOcException(OC_STACK_INVALID_PARAM, "Listener cannot be null");
+        ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listener cannot be null");
         return;
     }
 
@@ -314,12 +314,17 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getAclIdByDevi
   (JNIEnv *env, jobject thiz, jstring jdeviceId, jobject jListener)
 {
     LOGD("OcCloudProvisioning_getAclIdByDevice");
-    if (!jListener || !jdeviceId)
+    if (!jListener)
     {
-        ThrowOcException(OC_STACK_INVALID_PARAM, "Listener and deviceID cannot be null");
+        ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listener cannot be null");
         return;
     }
 
+    if (!jdeviceId)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "deviceID can not be null");
+        return;
+    }
     JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz);
     if (!cloud)
     {
@@ -368,9 +373,14 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getIndividualA
   (JNIEnv *env, jobject thiz, jstring jaclID, jobject jListener)
 {
     LOGD("OcCloudProvisioning_getIndividualAclInfo");
-    if (!jListener || !jaclID)
+    if (!jListener)
     {
-        ThrowOcException(OC_STACK_INVALID_PARAM, "Listener/aclID cannot be null");
+        ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listener cannot be null");
+        return;
+    }
+    if (!jaclID)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "aclID cannot be null");
         return;
     }
 
@@ -419,7 +429,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getCRL
     LOGD("OcCloudProvisioning_getCRL");
     if (!jListener)
     {
-        ThrowOcException(OC_STACK_INVALID_PARAM, "Listener cannot be null");
+        ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listener cannot be null");
         return;
     }
 
@@ -463,7 +473,12 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_postCRL0
    jobjectArray jserialnumArray, jobject jListener)
 {
     LOGD("OcCloudProvisioning_postCRL0");
-    if (!jListener || !jthisUpdate || !jnextUpdate || !jserialnumArray)
+     if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_CALLBACK,"Listener can not be null");
+        return;
+    }
+    if (!jthisUpdate || !jnextUpdate || !jserialnumArray)
     {
         ThrowOcException(OC_STACK_INVALID_PARAM, " Invalid parameter (NULL param)");
         return;
index b01059e..e36bacb 100644 (file)
@@ -591,7 +591,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcSecureResource_unlinkDevices
 #if defined(__WITH_X509__) || defined(__WITH_TLS__)
     if (!jListener)
     {
-        ThrowOcException(OC_STACK_INVALID_PARAM, "provisionTrustCertChainListener cannot be null");
+        ThrowOcException(OC_STACK_INVALID_CALLBACK, "provisionTrustCertChainListener cannot be null");
         return;
     }