From: kenstir Date: Sun, 3 Nov 2013 18:21:08 +0000 (-0500) Subject: Bah, added a couple more missing classes to fm_IDL.xml. In developer/debug mode... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bcaa8d1f521a0502e536a4ffd895da6938ad81c6;p=working%2FEvergreen.git Bah, added a couple more missing classes to fm_IDL.xml. In developer/debug mode, failure to deserialize an OSRF response will throw an NPE; in production it will return null. --- diff --git a/Open-ILS/src/Android/assets/fm_IDL.xml b/Open-ILS/src/Android/assets/fm_IDL.xml index eb917e0348..fc7491ff89 100644 --- a/Open-ILS/src/Android/assets/fm_IDL.xml +++ b/Open-ILS/src/Android/assets/fm_IDL.xml @@ -21,6 +21,16 @@ + + + + + + + + + + @@ -82,6 +92,23 @@ + + + + + + + + + + + + + + + + + @@ -275,6 +302,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java index c9c49fa516..ea4de75f0e 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/globals/GlobalConfigs.java @@ -49,6 +49,8 @@ public class GlobalConfigs { private boolean init = false; private static String TAG = "GlobalConfigs"; + + private static boolean debugMode = true;//KCXXX make a developer preference public static boolean loadedIDL = false; @@ -139,6 +141,14 @@ public class GlobalConfigs { return false; } + public static boolean isDebugMode() { + return debugMode; + } + + public static void setDebugMode(boolean debugMode) { + GlobalConfigs.debugMode = debugMode; + } + public void loadIDLFile(Context context) { try { diff --git a/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java b/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java index 7c95c13d62..d6f2bd97e1 100644 --- a/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java +++ b/Open-ILS/src/Android/src/org/evergreen/android/globals/Utils.java @@ -44,9 +44,11 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.util.Log; import android.widget.ImageView; public class Utils { + private static final String TAG = "osrf"; /** * Gets the net page content. @@ -246,18 +248,29 @@ public class Utils { // TODO check params and throw errors Method method = new Method(methodName); - System.out.println("doRequest Method :" + methodName + ": token :"+authToken+":"); + Log.d(TAG, "doRequest Method :" + methodName + ": token :"+authToken+":"); for (int i = 0; i < params.length; i++) { method.addParam(params[i]); - System.out.println("Param " + i + ":" + params[i]); + Log.d(TAG, "Param " + i + ":" + params[i]); } // sync request HttpRequest req = new GatewayRequest(conn, service, method).send(); - Object resp; + Object resp = null; - while ((resp = req.recv()) != null) { - System.out.println("Sync Response: " + resp); + try { + resp = req.recv(); + } catch (NullPointerException e) { + // I know it's bad form to catch NPE. But until I implement some kind of on-demand IDL parsing, + // this is what happens when the JSONReader tries to parse a response of an unregistered class. + // Crash if debugMode, fail if not. + Log.d(TAG, "NPE...unregistered type?", e); + if (GlobalConfigs.isDebugMode()) { + throw(e); + } + } + if (resp != null) { + Log.d(TAG, "Sync Response: " + resp); Object response = (Object) resp; String textcode = null; @@ -269,7 +282,7 @@ public class Utils { if (textcode != null) { if (textcode.equals("NO_SESSION")) { - System.out.println(textcode); + Log.d(TAG, textcode); throw new SessionNotFoundException(); } }