2014-05-13 56 views
1

我正在使用Worklight 6.0.0.2進行Android 4.4「KitKit」中與JSONStore相關的修復。IBM Worklight - 直接更新後JSONStore無法初始化

它工作正常,除了一個問題:直接更新後應用程序重新啓動,但然後JSONStore初始化失敗;如果我們退出應用程序並重新啓動,那麼它運行良好。

在android 4.4中複製問題的步驟。 「奇巧」:

  1. 觸發直接更新
  2. 允許應用程序更新

    後推出它自己然後你看到logcat中:

    05-13 16:28:57.010 :E/jsonstore-core(16691):錯誤驗證模式 05-13 16:28:57.010:E/jsonstore-core(16691):java.lang.Throwable:節點 名稱「_id」已經存在於模式05 -13 16:28:57.010: E/jsonstore芯(16691):在 com.worklight.androidgap.jsonstore.database.DatabaseSchema.addNode(DatabaseSchema.java:124)

  3. 關閉應用程序。
  4. 重新啓動它。

內部initoptions.js

var wlInitOptions = { 
connectOnStartup : false, 
heartBeatIntervalInSecs : 5, 

logger : { 
    enabled : true, 
    level : 'debug', 
    stringify : true, 
    pretty : false, 
    tag : { 
     level : false, 
     pkg : true 
    }, 
    whitelist : [], 
    blacklist : [] 
}, 
analytics : { 
    enabled : false 
}, 

};

裏面的JS文件:

function wlCommonInit(){ 
    collections["Videos"] = { 
    searchFields:{"BrandID":"string","VideoType":"string","CategoryID":"string","CourseID":"string","ISDeleted":"string","IsDownload":"string","VideoID":"string"} 
     }; 
     var options = {"username":"*","password":"*","localKeyGen":false,"clear":false}; 

WL.JSONStore.init(collections, options) 
     .then(function (resp) { 
     Brands=WL.JSONStore.get('Brands'); 
     Categories=WL.JSONStore.get('Categories'); 
     Courses=WL.JSONStore.get('Courses'); 
     Videos=WL.JSONStore.get('Videos'); 
     Notification=WL.JSONStore.get('Notification'); 
     UserInformationColl = WL.JSONStore.get('UserInformation'); 
     BrandListCollection = WL.JSONStore.get('BrandList'); 
     VideosList = WL.JSONStore.get('VideoList'); 
     BusinessType= WL.JSONStore.get('BusinessType'); 

     connectToServer(); 
    // initializeAnalytics(2000,131); 

      var query={"IsDownload":"2"}; 
      WL.JSONStore.get('Videos').find(query, {exact:true}) 
      .then(function (result2) { 
       if(result2.length > 0){ 
        for(var i=0; i<result2.length; i++){ 
         result2[i].json.IsDownload = 0; 
         Videos.replace(result2[i], {}) 
         .then(function (numberOfDocumentsReplaced) { 
          WL.Logger.info("The number of document replaced are:--->"+numberOfDocumentsReplaced); 
         }) 

         .fail(function (errorObject) { 
          WL.Logger.error("Error in document:---->"+errorObject); 
         }); 
        } 
       } 
       errorvideodownloading(); 
      }) 
      .fail(function (errorObject) { 
       WL.Logger.debug('error' +errorObject.toString()); 

      }); 
     }) 
     .fail(function (errorObject) { 
      WL.Logger.error("init notification error:----->"+errorObject); 
      if(errorObject.err === -2){ 
       WL.Logger.error("In the errorObject so destroying JSON store and recreating it."); 
       WL.JSONStore.destroy(); 
       JsonStoreinit(); 
       localStorage.clear(); 
       connectToServer(); 
      } 
      else if(errorObject.err === 16) 
      { 
      hideSplashScreenPlatForm(); 
      } 
     }); 
} 
else{ 
    WL.Logger.debug('[JSONStore] Check your dependencies.'); 

} 
}catch(e){ 
    WL.Logger.error("Exception is:--->"+e); 
} 

}

+0

SRam還請添加您的JSONStore初始化代碼。 –

+0

idan請參考上面的代碼。 – SRam

+0

它正在失敗功能。 – SRam

回答

0

我不知道你的初始化代碼。但是你會得到像

java.lang.Throwable: node with name "_id" already exists in schema 

當你使用集合,直到成功的回調。

請參閱this回答獲取更多信息。

相關問題