I have a Hybrid app created using MobileFirst Platform 7 that is working perfectly on a number of physical Android devices, AVDs, as well as the MFP Console Preview/Emulator. In all cases, the devices and the AVDs are running KitKat (v4.4.4).
For persistence of information, I am using the JSONStore Javascript API.
However, on one single device (A Panasonic Toughpad FZ-B2). The JSONstore refuses to initialize and all it throws the PERSISTENT_STORE_FAILURE failure when trying to init the collection.
Believing it may be my code, I downloaded, compiled and installed the sample JSONStore JavaScript API project from the MFP Developer Center.
I installed this to all devices (A Samsung Galaxy Tab2, Sony Xperia Z3, THL T6S, and the Toughpad). On all devices the application runs happily, but on the ToughPad, I again get PERSISTENT_STORE_FAILURE.
What do I do to investigate/resolve the cause?
A screenshot of the error and what I believe is relevant information on the device: http://files.interestingmix.com.au/stack/toughpadJSON.png
I have tried compiling the apk with API levels 19 and 22 to no difference in behavior (on the devices it worked, it always works, but the toughpad does not co-operate)
UPDATE
I have been able to change the runtime on the device from Dalvik (Old) to ART (new), and now the error thrown is OPERATION_FAILED_ON_SPECIFIC_DOCUMENT (same place in the Getting Started App (at the bottom), so need new for another screenshot), which I am now investigating
UPDATE 2 (Revised with Toughpad Results)
I was finally able to get an ADB Conn ection to the Toughpad device and therefore get LogCat. It seems the error is related to trying to open libcrypto.so.1.0.0. From what I can ascertain the library file required is not present in the package for the specific runtime. (Note I have returned the device to running on Dalvik as this is supposedly the more stable and supported base for KitKat)
Could this be to do with the Tougpad device (I suspect) being an x86_64 bit runtime, and therefore the libraries are not supplied? How do we check/resolve this?
Logcat output is as follows:
04-10 05:02:31.810: D/dalvikvm(6889): Late-enabling CheckJNI
04-10 05:02:31.810: D/dalvikvm(6889): Try to disable coredump for pid 6889
04-10 05:02:31.810: D/dalvikvm(6889): Process 6889 nice name: com.JSONStoreAPI
04-10 05:02:31.810: D/dalvikvm(6889): Extra Options: not specified
04-10 05:02:31.830: E/jdwp(6889): Failed sending reply to debugger: Broken pipe
04-10 05:02:31.830: D/dalvikvm(6889): Debugger has detached; object registry had 1 entries
04-10 05:02:31.840: I/CordovaLog(6889): Changing log level to DEBUG(3)
04-10 05:02:31.850: W/WLClient(6889): WLClient.createInstance in WLClient.java:220 :: You should pass a context that is assignable from the Activity class. WLClient instance may be used to start an activity.
04-10 05:02:31.900: D/wl.splashscreen(6889): WLSplashScreen.show in WLSplashScreen.java:64 :: Showing Splash Screen
04-10 05:02:31.910: D/CordovaActivity(6889): Resuming the App
04-10 05:02:31.910: D/WLClient(6889): WLClient$ActivityListener.onActivityStarted in WLClient.java:1434 :: on activity started com.JSONStoreAPI.JSONStoreAPI
04-10 05:02:31.920: D/WLClient(6889): WLClient$ActivityListener.onActivityResumed in WLClient.java:1423 :: on activity resumed com.JSONStoreAPI.JSONStoreAPI . activity count = 1
04-10 05:02:31.920: D/prepackagedAssetManager(6889): PrepackagedAssetsManager.copyPrepackagedAssetsToLocalStorage in PrepackagedAssetsManager.java:68 :: New installation/upgrade detected, copying resources and saving new checksum
04-10 05:02:31.940: I/ufoGralloc(6889): Hello, this is UFO GRALLOC/Intel Corporation
04-10 05:02:31.940: D/(6889): droid_create_context : config id = 5 conf->NativeVisualID=1
04-10 05:02:31.940: D/(6889): Pixel Format : GGL_PIXEL_FORMAT_RGBA_8888
04-10 05:02:31.940: I/(6889): Requested context : GLES 2.0
04-10 05:02:31.950: D/(6889): Pixel Format : GGL_PIXEL_FORMAT_RGBA_8888
04-10 05:02:31.950: D/OpenGLRenderer(6889): Enabling debug mode 0
04-10 05:02:31.950: D/(6889): Pixel Format : GGL_PIXEL_FORMAT_RGBA_8888
04-10 05:02:31.960: D/wl(6889): WL.doPrepareAssetsWork in WL.java:293 :: no need to check web resource integrity
04-10 05:02:32.000: D/CordovaActivity(6889): CordovaActivity.init()
04-10 05:02:32.000: V/WebViewChromiumFactoryProvider(6889): Binding Chromium to main looper Looper (main, tid 1) {26733be0}
04-10 05:02:32.000: I/LibraryLoader(6889): Expected native library version number "",actual native library version number ""
04-10 05:02:32.010: I/chromium(6889): [INFO:library_loader_hooks.cc(116)] Chromium logging enabled: level = 0, default verbosity = 0
04-10 05:02:32.010: I/BrowserStartupController(6889): Initializing chromium process, renderers=0
04-10 05:02:32.020: E/AudioManagerAndroid(6889): BLUETOOTH permission is missing!
04-10 05:02:32.020: D/(6889): Pixel Format : GGL_PIXEL_FORMAT_RGBA_8888
04-10 05:02:32.020: D/(6889): droid_create_context : config id = 1 conf->NativeVisualID=1
04-10 05:02:32.020: D/(6889): Pixel Format : GGL_PIXEL_FORMAT_RGBA_8888
04-10 05:02:32.020: I/(6889): Requested context : GLES 2.0
04-10 05:02:32.050: W/chromium(6889): [WARNING:proxy_service.cc(890)] PAC support disabled because there is no system implementation
04-10 05:02:32.060: D/CordovaWebView(6889): CordovaWebView is running on device made by: PANASONIC
04-10 05:02:32.060: D/CordovaActivity(6889): CordovaActivity.createViews()
04-10 05:02:32.060: D/CordovaWebView(6889): >>> loadUrl(file:///android_asset/www/skinLoader.html)
04-10 05:02:32.060: D/PluginManager(6889): init()
04-10 05:02:32.060: I/dalvikvm(6889): Could not find method android.webkit.CookieManager.setAcceptThirdPartyCookies, referenced from method com.worklight.androidgap.plugin.WLInitializationPlugin.initialize
04-10 05:02:32.060: W/dalvikvm(6889): VFY: unable to resolve virtual method 580: Landroid/webkit/CookieManager;.setAcceptThirdPartyCookies (Landroid/webkit/WebView;Z)V
04-10 05:02:32.060: D/dalvikvm(6889): VFY: replacing opcode 0x6e at 0x001a
04-10 05:02:32.140: D/CordovaWebView(6889): >>> loadUrlNow()
04-10 05:02:32.150: D/SoftKeyboardDetect(6889): Ignore this event
04-10 05:02:32.190: D/CordovaWebViewClient(6889): onPageStarted(file:///android_asset/www/skinLoader.html)
04-10 05:02:32.190: D/CordovaActivity(6889): onMessage(onPageStarted,file:///android_asset/www/skinLoader.html)
04-10 05:02:32.250: D/JsMessageQueue(6889): Set native->JS mode to OnlineEventsBridgeMode
04-10 05:02:32.250: D/CordovaWebViewClient(6889): onPageFinished(file:///android_asset/www/skinLoader.html)
04-10 05:02:32.250: D/CordovaActivity(6889): onMessage(onPageFinished,file:///android_asset/www/skinLoader.html)
04-10 05:02:32.390: V/StatusBar(6889): StatusBar: initialization
04-10 05:02:32.390: V/StatusBar(6889): Executing action: _ready
04-10 05:02:32.400: W/CordovaPlugin(6889): Attempted to send a second callback for ID: StatusBar1173806884
04-10 05:02:32.400: W/CordovaPlugin(6889): Result was: "Invalid action"
04-10 05:02:32.410: D/CordovaActivity(6889): onMessage(spinner,stop)
04-10 05:02:32.450: D/skuwa(6889): Detected device 0F31:14 family 15:9
04-10 05:02:32.760: D/CordovaNetworkManager(6889): Connection Type: wifi
04-10 05:02:32.760: D/CordovaNetworkManager(6889): Connection Extra Info: "eBlueprint-X6-anac2"
04-10 05:02:32.770: D/CordovaNetworkManager(6889): Connection Type: wifi
04-10 05:02:32.770: D/CordovaNetworkManager(6889): Connection Extra Info: "eBlueprint-X6-anac2"
04-10 05:02:32.770: D/CordovaActivity(6889): onMessage(networkconnection,wifi)
04-10 05:02:32.800: W/PluginManager(6889): THREAD WARNING: exec() call to WLApp.writeUserPref blocked the main thread for 22ms. Plugin should use CordovaInterface.getThreadPool().
04-10 05:02:32.810: D/CordovaWebViewClient(6889): onPageStarted(file:///android_asset/www/default/index.html)
04-10 05:02:32.810: D/JsMessageQueue(6889): Set native->JS mode to null
04-10 05:02:32.810: D/CordovaActivity(6889): onMessage(onPageStarted,file:///android_asset/www/default/index.html)
04-10 05:02:32.850: W/chromium(6889): [WARNING:simple_index_file.cc(338)] Could not map Simple Index file.
04-10 05:02:32.850: I/chromium(6889): [INFO:simple_index_file.cc(437)] Simple Cache Index is being restored from disk.
04-10 05:02:32.860: D/JsMessageQueue(6889): Set native->JS mode to OnlineEventsBridgeMode
04-10 05:02:33.200: V/StatusBar(6889): Executing action: _ready
04-10 05:02:33.200: W/CordovaPlugin(6889): Attempted to send a second callback for ID: StatusBar1365464329
04-10 05:02:33.200: W/CordovaPlugin(6889): Result was: "Invalid action"
04-10 05:02:33.200: D/CordovaActivity(6889): onMessage(spinner,stop)
04-10 05:02:33.210: D/CordovaNetworkManager(6889): Connection Type: wifi
04-10 05:02:33.210: D/CordovaNetworkManager(6889): Connection Extra Info: "eBlueprint-X6-anac2"
04-10 05:02:34.260: D/CordovaActivity(6889): onMessage(spinner,stop)
04-10 05:02:37.860: D/CordovaLog(6889): file:///android_asset/www/default/worklight/cordova.js: Line 1171 : deviceready has not fired after 5 seconds.
04-10 05:02:37.860: I/chromium(6889): [INFO:CONSOLE(1171)] "deviceready has not fired after 5 seconds.", source: file:///android_asset/www/default/worklight/cordova.js (1171)
04-10 05:02:37.870: D/CordovaLog(6889): file:///android_asset/www/default/worklight/cordova.js: Line 1164 : Channel not fired: onDOMContentLoaded
04-10 05:02:37.870: I/chromium(6889): [INFO:CONSOLE(1164)] "Channel not fired: onDOMContentLoaded", source: file:///android_asset/www/default/worklight/cordova.js (1164)
04-10 05:03:52.370: D/dalvikvm(6889): Debugger has detached; object registry had 1 entries
04-10 05:03:59.810: D/CordovaActivity(6889): Paused the application!
04-10 05:03:59.810: D/CordovaWebView(6889): Handle the pause
04-10 05:03:59.810: D/WLClient(6889): WLClient$ActivityListener.onActivityPaused in WLClient.java:1416 :: on activity paused com.JSONStoreAPI.JSONStoreAPI . activity count = 0
04-10 05:03:59.880: D/(6889): Surface destroy: ANDROID_NATIVE_WINDOW_MAGIC
04-10 05:03:59.900: D/(6889): Surface destroy: ANDROID_NATIVE_WINDOW_MAGIC
04-10 05:04:00.140: D/WLClient(6889): WLClient$ActivityListener.onActivitySaveInstanceState in WLClient.java:1428 :: on activity save instance state com.JSONStoreAPI.JSONStoreAPI
04-10 05:04:00.140: D/WLClient(6889): WLClient$ActivityListener.onActivityStopped in WLClient.java:1440 :: on activity stopped com.JSONStoreAPI.JSONStoreAPI
04-10 05:04:00.150: D/(6889): Pixel Format : GGL_PIXEL_FORMAT_RGBA_8888
04-10 05:04:01.410: D/(6889): Pixel Format : GGL_PIXEL_FORMAT_RGBA_8888
04-10 05:04:01.410: D/CordovaActivity(6889): Resuming the App
04-10 05:04:01.410: D/WLClient(6889): WLClient$ActivityListener.onActivityStarted in WLClient.java:1434 :: on activity started com.JSONStoreAPI.JSONStoreAPI
04-10 05:04:01.410: D/WLClient(6889): WLClient$ActivityListener.onActivityResumed in WLClient.java:1423 :: on activity resumed com.JSONStoreAPI.JSONStoreAPI . activity count = 1
04-10 05:04:01.440: D/(6889): Pixel Format : GGL_PIXEL_FORMAT_RGBA_8888
04-10 05:04:40.270: I/dalvikvm(6889): Total arena pages for JIT: 11
04-10 05:04:40.290: D/CordovaWebViewClient(6889): onPageFinished(file:///android_asset/www/default/index.html)
04-10 05:04:40.290: D/CordovaActivity(6889): onMessage(onPageFinished,file:///android_asset/www/default/index.html)
04-10 05:04:40.320: D/NONE(6889): ondeviceready event dispatched
04-10 05:04:40.360: D/NONE(6889): wlclient init started
04-10 05:04:40.360: D/NONE(6889): Read cookies: null
04-10 05:04:40.360: D/NONE(6889): CookieMgr read cookies: {}
04-10 05:04:40.370: W/NONE(6889): Note that if your application targets Android 3.0 (API level 11) or higher, WL.OptionsMenu might have no effect, depending on the device.
04-10 05:04:40.410: D/(6889): Surface destroy: ANDROID_NATIVE_WINDOW_MAGIC
04-10 05:04:40.410: D/NONE(6889): before: initOptions.onSuccess
04-10 05:04:40.430: I/dalvikvm(6889): Could not find method com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable, referenced from method com.worklight.wlclient.push.common.GCMClientFactory.useGooglePlayServices
04-10 05:04:40.430: W/dalvikvm(6889): VFY: unable to resolve static method 721: Lcom/google/android/gms/common/GooglePlayServicesUtil;.isGooglePlayServicesAvailable (Landroid/content/Context;)I
04-10 05:04:40.430: D/dalvikvm(6889): VFY: replacing opcode 0x71 at 0x0006
04-10 05:04:40.430: D/GCMClientFactory(6889): GCMClientFactory.useGooglePlayServices in GCMClientFactory.java:42 :: Google Play Services is not used because the play services library is not found. So using the default GCM helper implementation.
04-10 05:04:40.440: D/GCMClientFactory(6889): GCMClientFactory.getInstance in GCMClientFactory.java:28 :: Using GCMHelperClient
04-10 05:04:40.440: W/GCMHelperClient(6889): GCMHelperClient.unregisterReceivers in GCMHelperClient.java:95 :: unregister:Receiver not registered: null
04-10 05:04:40.440: W/GCMHelperClient(6889): GCMHelperClient.unregisterReceivers in GCMHelperClient.java:101 :: unregister:Receiver not registered: null
04-10 05:04:40.450: D/NONE(6889): after: initOptions.onSuccess
04-10 05:04:40.460: D/NONE(6889): added onPause and onResume event handlers
04-10 05:04:40.460: D/NONE(6889): wlclient init success
04-10 05:04:45.360: D/CordovaLog(6889): : Line 0 : event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
04-10 05:04:45.360: I/chromium(6889): [INFO:CONSOLE(0)] "event.returnValue is deprecated. Please use the standard event.preventDefault() instead.", source: (0)
04-10 05:04:45.390: D/com.worklight.nativeandroid.common.WLUtils(6889): WLUtils.loadLib in WLUtils.java:545 :: Extracting zip file: featurelibs/armeabi/libcrypto.so.1.0.0
04-10 05:04:45.430: I/dalvikvm(6889): Total arena pages for JIT: 12
04-10 05:04:45.430: I/dalvikvm(6889): Total arena pages for JIT: 13
04-10 05:04:45.430: I/dalvikvm(6889): Total arena pages for JIT: 14
04-10 05:04:45.430: I/dalvikvm(6889): Total arena pages for JIT: 15
04-10 05:04:45.490: D/dalvikvm(6889): Trying to load lib /data/data/com.JSONStoreAPI/files/libcrypto.so.1.0.0 0x4ce6b1d0
04-10 05:04:45.490: D/com.worklight.nativeandroid.common.WLUtils(6889): WLUtils.loadLib in WLUtils.java:555 :: Loading library using System.load: /data/data/com.JSONStoreAPI/files/libcrypto.so.1.0.0
04-10 05:04:45.530: D/houdini(6889): [7174] Loading library(version: 4.0.6.44921 RELEASE)... successfully.
04-10 05:04:45.540: D/dalvikvm(6889): Added shared lib /data/data/com.JSONStoreAPI/files/libcrypto.so.1.0.0 0x4ce6b1d0
04-10 05:04:45.540: D/dalvikvm(6889): No JNI_OnLoad found in /data/data/com.JSONStoreAPI/files/libcrypto.so.1.0.0 0x4ce6b1d0, skipping init
04-10 05:04:45.560: I/NONE(6889): Destroy finished succesfully
04-10 05:04:48.920: D/dalvikvm(6889): GC_FOR_ALLOC freed 2437K, 26% free 7398K/9880K, paused 5ms, total 5ms
04-10 05:04:48.980: D/dalvikvm(6889): Trying to load lib /data/app-lib/com.JSONStoreAPI-1/libstlport_shared.so 0x4ce6b1d0
04-10 05:04:48.980: D/dalvikvm(6889): Added shared lib /data/app-lib/com.JSONStoreAPI-1/libstlport_shared.so 0x4ce6b1d0
04-10 05:04:48.980: D/dalvikvm(6889): No JNI_OnLoad found in /data/app-lib/com.JSONStoreAPI-1/libstlport_shared.so 0x4ce6b1d0, skipping init
04-10 05:04:48.980: D/dalvikvm(6889): Trying to load lib /data/app-lib/com.JSONStoreAPI-1/libsqlcipher_android.so 0x4ce6b1d0
04-10 05:04:48.980: E/dalvikvm(6889): dlopen("/data/app-lib/com.JSONStoreAPI-1/libsqlcipher_android.so") failed: dlopen failed: could not load library "libcrypto.so.1.0.0" needed by "libsqlcipher_android.so"; caused by library "libcrypto.so.1.0.0" not found
04-10 05:04:48.990: E/JSONSTORE(6889): JSONStoreLogger.logError in JSONStoreLogger.java:189 :: Error during provision
04-10 05:04:48.990: E/JSONSTORE(6889): java.lang.UnsatisfiedLinkError: dlopen failed: could not load library "libcrypto.so.1.0.0" needed by "libsqlcipher_android.so"; caused by library "libcrypto.so.1.0.0" not found
04-10 05:04:48.990: E/JSONSTORE(6889): at java.lang.Runtime.loadLibrary(Runtime.java:364)
04-10 05:04:48.990: E/JSONSTORE(6889): at java.lang.System.loadLibrary(System.java:526)
04-10 05:04:48.990: E/JSONSTORE(6889): at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:142)
04-10 05:04:48.990: E/JSONSTORE(6889): at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:136)
04-10 05:04:48.990: E/JSONSTORE(6889): at com.worklight.jsonstore.database.DatabaseManager.openDatabaseIfNecessary(DatabaseManager.java:179)
04-10 05:04:48.990: E/JSONSTORE(6889): at com.worklight.jsonstore.database.DatabaseManager.checkDatabaseAgainstSchema(DatabaseManager.java:98)
04-10 05:04:48.990: E/JSONSTORE(6889): at com.worklight.jsonstore.database.DatabaseSchema.isSchemaMismatched(DatabaseSchema.java:416)
04-10 05:04:48.990: E/JSONSTORE(6889): at com.worklight.jsonstore.api.WLJSONStore.provisionDatabase(WLJSONStore.java:149)
04-10 05:04:48.990: E/JSONSTORE(6889): at com.worklight.jsonstore.api.WLJSONStore.openCollections(WLJSONStore.java:345)
04-10 05:04:48.990: E/JSONSTORE(6889): at com.worklight.androidgap.jsonstore.dispatchers.ProvisionActionDispatcher.initializeCollection(ProvisionActionDispatcher.java:146)
04-10 05:04:48.990: E/JSONSTORE(6889): at com.worklight.androidgap.jsonstore.dispatchers.ProvisionActionDispatcher.databaseActionDispatch(ProvisionActionDispatcher.java:132)
04-10 05:04:48.990: E/JSONSTORE(6889): at com.worklight.androidgap.jsonstore.dispatchers.BaseDatabaseActionDispatcher.actionDispatch(BaseDatabaseActionDispatcher.java:36)
04-10 05:04:48.990: E/JSONSTORE(6889): at com.worklight.androidgap.jsonstore.dispatchers.BaseActionDispatcher.dispatch(BaseActionDispatcher.java:90)
04-10 05:04:48.990: E/JSONSTORE(6889): at com.worklight.androidgap.plugin.DispatchingPlugin$ActionDispatcherRunnable.run(DispatchingPlugin.java:79)
04-10 05:04:48.990: E/JSONSTORE(6889): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
04-10 05:04:48.990: E/JSONSTORE(6889): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
04-10 05:04:48.990: E/JSONSTORE(6889): at java.lang.Thread.run(Thread.java:841)
04-10 05:04:49.000: I/NONE(6889): PERSISTENT_STORE_FAILURE
04-10 05:04:49.000: E/wl.jsonstore(6889): {"src":"initCollection","err":-1,"msg":"PERSISTENT_STORE_FAILURE","col":"people","usr":"jsonstore","doc":{},"res":{}}
04-10 05:05:35.740: D/CordovaActivity(6889): Paused the application!
04-10 05:05:35.740: D/CordovaWebView(6889): Handle the pause
04-10 05:05:35.740: D/WLClient(6889): WLClient$ActivityListener.onActivityPaused in WLClient.java:1416 :: on activity paused com.JSONStoreAPI.JSONStoreAPI . activity count = 0
04-10 05:05:35.750: D/NONE(6889): Flush called
04-10 05:05:35.770: D/(6889): Surface destroy: ANDROID_NATIVE_WINDOW_MAGIC
04-10 05:05:35.780: D/WLClient(6889): WLClient$ActivityListener.onActivitySaveInstanceState in WLClient.java:1428 :: on activity save instance state com.JSONStoreAPI.JSONStoreAPI
04-10 05:05:35.780: D/WLClient(6889): WLClient$ActivityListener.onActivityStopped in WLClient.java:1440 :: on activity stopped com.JSONStoreAPI.JSONStoreAPI
04-10 05:05:35.790: W/IInputConnectionWrapper(6889): showStatusIcon on inactive InputConnection
The JSONSTORE Code is the application from the Getting Started MFP Developer Center as I wanted to use clean trusted code base (for brevity and length limitations on the post, only the relevant sections of main.js are provided):
//Dependencies
var $ = jQuery,
_ = lodash;
//CONSTANTS
var PEOPLE_COLLECTION_NAME = 'people',
KEY_VALUE_COLLECTION_NAME = 'keyvalue',
INIT_FIRST_MSG = 'PERSISTENT_STORE_NOT_OPEN',
NAME_FIELD_EMPTY_MSG = 'Name field is empty',
AGE_FIELD_EMPTY_MSG = 'Age field is empty',
ID_FIELD_EMPTY_MSG = 'Id field is empty',
EMPTY_TABLE_MSG = 'No documents found',
DESTROY_MSG = 'Destroy finished succesfully',
INIT_MSG = 'Collection initialized',
ADD_MSG = 'Data added to the collection',
REPLACE_MSG = 'Document replaced succesfully, call find.',
REMOVE_MSG = 'Documents removed: ',
COUNT_MSG = 'Documents in the collection: ',
CLOSE_ALL_MSG = 'JSONStore closed',
REMOVE_COLLECTION_MSG = 'Removed all data in the collection',
LOAD_MSG = 'New documents loaded from adapter: ',
PUSH_MSG_FAILED = 'Could not push some docs, res: ',
PUSH_MSG = 'Push finished',
PASS_CHANGED_MSG = 'Password changed succesfully',
COUNT_QUERY_ERROR_MSG = 'FIND_BY_QUERY_EXPECTED_A_STRING',
COUNT_QUERY_MSG = "Documents in the collection with name = ";
...
...
...
...
...
//init
$('button#init').on('click', function () {
//Get references to the input fields DOM elements
var usernameField = $('input#init-username'),
passwordField = $('input#init-password');
//Get values from the input fields
var username = usernameField.val() || '',
password = passwordField.val() || '';
//Create the optional options object passed to init
var options = {};
//Check if a username was passed
if (username.length > 0) {
options.username = username;
}
//If if a password was passed
if (password.length > 0) {
options.password = password;
}
//JSONStore collections metadata
var collections = {};
//Define the 'people' collection and list the search fields
collections[PEOPLE_COLLECTION_NAME] = {
searchFields : {name: 'string', age: 'integer'},
//-- Start optional adapter metadata
adapter : {
name: 'People',
add: 'addPerson',
remove: 'removePerson',
replace: 'replacePerson',
load: {
procedure: 'getPeople',
params: [],
key: 'peopleList'
}
}
//-- End optional adapter metadata
};
//Define the 'keyvalue' collection and use additional search fields
collections[KEY_VALUE_COLLECTION_NAME] = {
searchFields : {},
additionalSearchFields : { key: 'string' }
};
//Initialize the people collection
WL.JSONStore.init(collections, options)
.then(function () {
_logMessage(INIT_MSG);
_callEnhanceToAddKeyValueMethods();
})
.fail(function (errorObject) {
_logError(errorObject.msg);
});
});