From: Hauke Mehrtens Date: Thu, 17 Sep 2015 16:51:33 +0000 (+0200) Subject: android: add misssing error codes to stackResultToStr() X-Git-Tag: 1.2.0+RC1~1065 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8487deda0f5ee888267c53322c6197a463c1b88;p=platform%2Fupstream%2Fiotivity.git android: add misssing error codes to stackResultToStr() The OC_STACK_UNAUTHORIZED_REQ error code and some others were missing in the method for translating them into strings. Without this patch it resulted in this exception: org.iotivity.base.OcException: stack error in onObserveCallback JNI_INVALID_VALUE Change-Id: I739dfecafff55c035702a27a9b5d8dcb925993f4 Signed-off-by: Hauke Mehrtens Reviewed-on: https://gerrit.iotivity.org/gerrit/2643 Tested-by: jenkins-iotivity Reviewed-by: Tim Kourt Reviewed-by: Patrick Lankswert --- diff --git a/android/android_api/base/jni/JniUtils.h b/android/android_api/base/jni/JniUtils.h index c87de9e..63d6391 100644 --- a/android/android_api/base/jni/JniUtils.h +++ b/android/android_api/base/jni/JniUtils.h @@ -130,6 +130,7 @@ public: { switch (result) { + /** Success status code - START HERE.*/ case OC_STACK_OK: return "OK"; case OC_STACK_RESOURCE_CREATED: @@ -138,21 +139,20 @@ public: return "RESOURCE_DELETED"; case OC_STACK_CONTINUE: return "CONTINUE"; - /* Success status code - END HERE */ - /* Error status code - START HERE */ + /* Error status code - START HERE */ case OC_STACK_INVALID_URI: return "INVALID_URI"; case OC_STACK_INVALID_QUERY: return "INVALID_QUERY"; case OC_STACK_INVALID_IP: return "INVALID_IP"; - case OC_STACK_INVALID_PORT: return "INVALID_PORT"; case OC_STACK_INVALID_CALLBACK: return "INVALID_CALLBACK"; case OC_STACK_INVALID_METHOD: return "INVALID_METHOD"; + /** Invalid parameter.*/ case OC_STACK_INVALID_PARAM: return "INVALID_PARAM"; case OC_STACK_INVALID_OBSERVE_PARAM: @@ -161,16 +161,23 @@ public: return "NO_MEMORY"; case OC_STACK_COMM_ERROR: return "COMM_ERROR"; + case OC_STACK_TIMEOUT: + return "TIMEOUT"; + case OC_STACK_ADAPTER_NOT_ENABLED: + return "ADAPTER_NOT_ENABLED"; case OC_STACK_NOTIMPL: return "NOTIMPL"; + /** Resource not found.*/ case OC_STACK_NO_RESOURCE: return "NO_RESOURCE"; + /** e.g: not supported method or interface.*/ case OC_STACK_RESOURCE_ERROR: return "RESOURCE_ERROR"; case OC_STACK_SLOW_RESOURCE: return "SLOW_RESOURCE"; - //case OC_STACK_DUPLICATE_REQUEST: - // return "DUPLICATE_REQUEST"; + case OC_STACK_DUPLICATE_REQUEST: + return "DUPLICATE_REQUEST"; + /** Resource has no registered observers.*/ case OC_STACK_NO_OBSERVERS: return "NO_OBSERVERS"; case OC_STACK_OBSERVER_NOT_FOUND: @@ -179,6 +186,7 @@ public: return "VIRTUAL_DO_NOT_HANDLE"; case OC_STACK_INVALID_OPTION: return "INVALID_OPTION"; + /** The remote reply contained malformed data.*/ case OC_STACK_MALFORMED_RESPONSE: return "MALFORMED_RESPONSE"; case OC_STACK_PERSISTENT_BUFFER_REQUIRED: @@ -187,16 +195,27 @@ public: return "INVALID_REQUEST_HANDLE"; case OC_STACK_INVALID_DEVICE_INFO: return "INVALID_DEVICE_INFO"; - //case OC_STACK_INVALID_JSON: - // return "INVALID_JSON"; - + case OC_STACK_INVALID_JSON: + return "INVALID_JSON"; + /** Request is not authorized by Resource Server. */ + case OC_STACK_UNAUTHORIZED_REQ: + return "UNAUTHORIZED_REQ"; + /** Error code from PDM */ + case OC_STACK_PDM_IS_NOT_INITIALIZED: + return "PDM_IS_NOT_INITIALIZED"; + case OC_STACK_DUPLICATE_UUID: + return "DUPLICATE_UUID"; + case OC_STACK_INCONSISTENT_DB: + return "INCONSISTENT_DB"; + /** Insert all new error codes here!.*/ +#ifdef WITH_PRESENCE case OC_STACK_PRESENCE_STOPPED: return "PRESENCE_STOPPED"; case OC_STACK_PRESENCE_TIMEOUT: return "PRESENCE_TIMEOUT"; case OC_STACK_PRESENCE_DO_NOT_HANDLE: return "PRESENCE_DO_NOT_HANDLE"; - +#endif case OC_STACK_ERROR: return "ERROR"; diff --git a/android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java b/android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java index 5951750..5433c86 100644 --- a/android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java +++ b/android/android_api/base/src/main/java/org/iotivity/base/ErrorCode.java @@ -28,34 +28,44 @@ public enum ErrorCode { RESOURCE_CREATED("RESOURCE_CREATED", ""), RESOURCE_DELETED("RESOURCE_DELETED", ""), CONTINUE("CONTINUE", ""), - /* Success status code - END HERE */ - /* Error status code - START HERE */ + /** Success status code - END HERE.*/ + /* Error status code - START HERE */ INVALID_URI("INVALID_URI", ""), INVALID_QUERY("INVALID_QUERY", ""), INVALID_IP("INVALID_IP", ""), INVALID_PORT("INVALID_PORT", ""), INVALID_CALLBACK("INVALID_CALLBACK", ""), INVALID_METHOD("INVALID_METHOD", ""), - INVALID_PARAM("INVALID_PARAM", ""), + INVALID_PARAM("INVALID_PARAM", "Invalid parameter"), INVALID_OBSERVE_PARAM("INVALID_OBSERVE_PARAM", ""), NO_MEMORY("NO_MEMORY", ""), COMM_ERROR("COMM_ERROR", ""), + TIMEOUT("TIMEOUT", ""), + ADAPTER_NOT_ENABLED("ADAPTER_NOT_ENABLED", ""), NOT_IMPL("NOTIMPL", ""), NO_RESOURCE("NO_RESOURCE", "Resource not found"), RESOURCE_ERROR("RESOURCE_ERROR", "Not supported method or interface"), SLOW_RESOURCE("SLOW_RESOURCE", ""), + DUPLICATE_REQUEST("DUPLICATE_REQUEST", ""), NO_OBSERVERS("NO_OBSERVERS", "Resource has no registered observers"), OBSERVER_NOT_FOUND("OBSERVER_NOT_FOUND", ""), - PRESENCE_STOPPED("PRESENCE_STOPPED", ""), - PRESENCE_TIMEOUT("PRESENCE_TIMEOUT", ""), - PRESENCE_DO_NOT_HANDLE("PRESENCE_DO_NOT_HANDLE", ""), VIRTUAL_DO_NOT_HANDLE("VIRTUAL_DO_NOT_HANDLE", ""), INVALID_OPTION("INVALID_OPTION", ""), MALFORMED_RESPONSE("MALFORMED_RESPONSE", "Remote reply contained malformed data"), PERSISTENT_BUFFER_REQUIRED("PERSISTENT_BUFFER_REQUIRED", ""), INVALID_REQUEST_HANDLE("INVALID_REQUEST_HANDLE", ""), INVALID_DEVICE_INFO("INVALID_DEVICE_INFO", ""), - + INVALID_JSON("INVALID_JSON", ""), + UNAUTHORIZED_REQ("UNAUTHORIZED_REQ", "Request is not authorized by Resource Server"), + /** Error code from PDM */ + PDM_IS_NOT_INITIALIZED("PDM_IS_NOT_INITIALIZED", ""), + DUPLICATE_UUID("DUPLICATE_UUID", ""), + INCONSISTENT_DB("INCONSISTENT_DB", ""), + /** Insert all new error codes here!.*/ + PRESENCE_STOPPED("PRESENCE_STOPPED", ""), + PRESENCE_TIMEOUT("PRESENCE_TIMEOUT", ""), + PRESENCE_DO_NOT_HANDLE("PRESENCE_DO_NOT_HANDLE", ""), + /** ERROR in stack.*/ ERROR("ERROR", "Generic error"), JNI_EXCEPTION("JNI_EXCEPTION", "Generic Java binder error"),