From 71656ed9c08335498950d9e08203c32d3f0a47f4 Mon Sep 17 00:00:00 2001 From: kenstir Date: Sun, 9 Aug 2015 17:32:47 -0400 Subject: [PATCH] Auto download fm_IDL at run time instead of including it as an asset. Safer and slower, about 225ms as opposed to 22ms, on my Nexus 5. --- .../org/evergreen_ils/globals/GlobalConfigs.java | 15 +- .../services/ScheduledIntentService.java | 3 +- Open-ILS/src/Android/cwmars_app/assets/fm_IDL.xml | 589 --------------------- 3 files changed, 12 insertions(+), 595 deletions(-) delete mode 100644 Open-ILS/src/Android/cwmars_app/assets/fm_IDL.xml diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/GlobalConfigs.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/GlobalConfigs.java index 3d02947216..a6c33bfbc1 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/GlobalConfigs.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/globals/GlobalConfigs.java @@ -37,7 +37,7 @@ import java.util.*; public class GlobalConfigs { - public static String IDL_FILE_FROM_ROOT = "/reports/fm_IDL.xml"; + public static String IDL_FILE_FROM_ROOT = "/reports/fm_IDL.xml?class=acn&class=acp&class=ahr&class=ahtc&class=au&class=bmp&class=cbreb&class=cbrebi&class=cbrebin&class=cbrebn&class=ccs&class=circ&class=ex&class=mbt&class=mbts&class=mous&class=mus&class=mvr&class=perm_ex"; public static String IDL_FILE_FROM_ASSETS = "fm_IDL.xml"; public static String httpAddress = ""; @@ -112,12 +112,19 @@ public class GlobalConfigs { try { Log.d(TAG, "loadIDLFile start"); - //@TODO maybe switch back to IDL_FILE_FROM_ROOT?class=circ&class=au&class=mvr&class=acp - InputStream in_IDL = context.getAssets().open(IDL_FILE_FROM_ASSETS); + long start_ms = System.currentTimeMillis(); + InputStream in_IDL; + if (false) { + // Use IDL file from assets. Much faster than downloading it, but it risks an NPE + // if the asset version is out of sync with the site version. + in_IDL = context.getAssets().open(IDL_FILE_FROM_ASSETS); + } else { + // Download IDL file from server. Safest and slowest. + in_IDL = Utils.getNetInputStream(GlobalConfigs.httpAddress + IDL_FILE_FROM_ROOT); + } IDLParser parser = new IDLParser(in_IDL); parser.setKeepIDLObjects(false); Log.d(TAG, "loadIDLFile parse"); - long start_ms = System.currentTimeMillis(); parser.parse(); long duration_ms = System.currentTimeMillis() - start_ms; Log.d(TAG, "loadIDLFile parse took "+duration_ms+"ms"); diff --git a/Open-ILS/src/Android/core/src/org/evergreen_ils/services/ScheduledIntentService.java b/Open-ILS/src/Android/core/src/org/evergreen_ils/services/ScheduledIntentService.java index a043b1a82e..72df1cb5fa 100644 --- a/Open-ILS/src/Android/core/src/org/evergreen_ils/services/ScheduledIntentService.java +++ b/Open-ILS/src/Android/core/src/org/evergreen_ils/services/ScheduledIntentService.java @@ -82,8 +82,7 @@ public class ScheduledIntentService extends IntentService { * Download the necessary IDL files for checkout items operations like * au (for auth), circ, mvr and acp */ - String idlFile = GlobalConfigs.IDL_FILE_FROM_ROOT - + "?class=circ&class=au&class=mvr&class=acp"; + String idlFile = GlobalConfigs.IDL_FILE_FROM_ROOT; try { Log.d(TAG, "Load IDL start"); InputStream in_IDL = Utils.getNetInputStream(GlobalConfigs.httpAddress + idlFile); diff --git a/Open-ILS/src/Android/cwmars_app/assets/fm_IDL.xml b/Open-ILS/src/Android/cwmars_app/assets/fm_IDL.xml deleted file mode 100644 index b36c1a82b9..0000000000 --- a/Open-ILS/src/Android/cwmars_app/assets/fm_IDL.xml +++ /dev/null @@ -1,589 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file -- 2.11.0