void processSyncCommand(String strCmd, JSONEntry oCmdEntry, boolean bCheckUIRequest) { JSONStructIterator objIter = new JSONStructIterator(oCmdEntry); for( ; !objIter.isEnd() && getSync().isContinueSync(); objIter.next() ) { String strObject = objIter.getCurKey(); JSONStructIterator attrIter = new JSONStructIterator( objIter.getCurValue() ); try { if ( m_bSchemaSource ) processServerCmd_Ver3_Schema(strCmd,strObject,attrIter); else { for( ; !attrIter.isEnd() && getSync().isContinueSync(); attrIter.next() ) { String strAttrib = attrIter.getCurKey(); String strValue = attrIter.getCurString(); processServerCmd_Ver3(strCmd,strObject,strAttrib,strValue); } } }catch(DBException exc) { LOG.ERROR("Sync of server changes failed for " + getName() + ";object: " + strObject, exc); } if ( getSyncType().compareTo("none") == 0 ) continue; if ( bCheckUIRequest ) { int nSyncObjectCount = getNotify().incLastSyncObjectCount(getID()); if ( getProgressStep() > 0 && (nSyncObjectCount%getProgressStep() == 0) ) getNotify().fireSyncNotification(this, false, RhoAppAdapter.ERR_NONE, ""); if ( getDB().isUIWaitDB() ) { LOG.INFO("Commit transaction because of UI request."); getDB().endTransaction(); SyncThread.sleep(1000); getDB().startTransaction(); } } } }
//{"create-error":{"0_broken_object_id":{"name":"wrongname","an_attribute":"error create"},"0_broken_object_id-error":{"message":"error create"}}} boolean processServerErrors(JSONEntry oCmds) { String[] arErrTypes = {"source-error", "search-error", "create-error", "update-error", "delete-error", null}; boolean bRes = false; for( int i = 0; ; i++ ) { if ( arErrTypes[i] == null ) break; if ( !oCmds.hasName(arErrTypes[i]) ) continue; bRes = true; m_nErrCode = RhoAppAdapter.ERR_CUSTOMSYNCSERVER; JSONEntry errSrc = oCmds.getEntry(arErrTypes[i]); JSONStructIterator errIter = new JSONStructIterator(errSrc); for( ; !errIter.isEnd(); errIter.next() ) { String strKey = errIter.getCurKey(); if ( i == 0 || i == 1 )//"source-error", "search-error" { if ( errIter.getCurValue().hasName("message") ) { if ( m_strServerError.length() > 0 ) m_strServerError += "&"; m_strServerError += "server_errors[" + URI.urlEncode(strKey) + "][message]=" + URI.urlEncode(errIter.getCurValue().getString("message")); } } else { //"create-error", "update-error", "delete-error" String strObject = strKey; if ( strObject.endsWith("-error") ) { strObject = strObject.substring(0, strKey.length()-6); if ( m_strServerError.length() > 0 ) m_strServerError += "&"; m_strServerError += "server_errors[" + arErrTypes[i] + "][" + URI.urlEncode(strObject) + "][message]=" + URI.urlEncode(errIter.getCurValue().getString("message")); }else { JSONStructIterator attrIter = new JSONStructIterator(errIter.getCurValue()); for( ; !attrIter.isEnd(); attrIter.next() ) { String strAttrName = attrIter.getCurKey(); String strAttrValue = attrIter.getCurString(); if ( m_strServerError.length() > 0 ) m_strServerError += "&"; m_strServerError += "server_errors[" + arErrTypes[i] + "][" + URI.urlEncode(strObject) + "][attributes][" + URI.urlEncode(strAttrName) + "]=" + URI.urlEncode(strAttrValue); } } } } } return bRes; }