void doFireSyncNotification( SyncSource src, boolean bFinish, int nErrCode, String strError, String strParams, String strServerError ) { if ( getSync().isStoppedByUser() ) return; try{ SyncNotification pSN = null; String strBody = ""; boolean bRemoveAfterFire = bFinish; { lock(m_mxSyncNotifications){ pSN = getSyncNotifyBySrc(src); if ( pSN == null ) return; strBody = ""; if ( src != null ) { strBody += "total_count=" + src.getTotalCount(); strBody += "&processed_count=" + src.getCurPageCount(); strBody += "&processed_objects_count=" + getLastSyncObjectCount(src.getID()); strBody += "&cumulative_count=" + src.getServerObjectsCount(); strBody += "&source_id=" + src.getID(); strBody += "&source_name=" + src.getName(); } if ( strParams.length() > 0 ) strBody += (strBody.length() > 0 ? "&" : "") + strParams; else strBody += (strBody.length() > 0 ? "&" : "") + "sync_type=incremental"; strBody += "&status="; if ( bFinish ) { if ( nErrCode == RhoAppAdapter.ERR_NONE ) { if ( getSync().isSchemaChanged() ) strBody += "schema_changed"; else strBody += (src == null && strParams.length() == 0) ? "complete" : "ok"; } else { if ( getSync().isStoppedByUser() ) nErrCode = RhoAppAdapter.ERR_CANCELBYUSER; strBody += "error"; strBody += "&error_code=" + nErrCode; if (strError != null && strError.length() > 0) { if (strError.length() > MAX_SERVER_ERROR_LEN) strError = strError.substring(0, MAX_SERVER_ERROR_LEN); strBody += "&error_message=" + URI.urlEncode(strError); } else if (src != null && src.m_strError != null) { if (src.m_strError.length() > MAX_SERVER_ERROR_LEN) src.m_strError = src.m_strError.substring(0, MAX_SERVER_ERROR_LEN); strBody += "&error_message=" + URI.urlEncode(src.m_strError); } if (strServerError != null && strServerError.length() > 0) { if (strServerError.length() > MAX_SERVER_ERROR_LEN) strServerError = strServerError.substring(0, MAX_SERVER_ERROR_LEN); strBody += "&" + strServerError; } else if (src != null && src.m_strServerError != null && src.m_strServerError.length() > 0) { if ( src.m_strServerError.length() > MAX_SERVER_ERROR_LEN ) src.m_strServerError = src.m_strServerError.substring(0, MAX_SERVER_ERROR_LEN); strBody += "&" + src.m_strServerError; } } if ( src != null ) strBody += makeCreateObjectErrorBody( src.getID()); } else strBody += "in_progress"; strBody += "&rho_callback=1"; if ( pSN.m_strParams != null && pSN.m_strParams.length() > 0 ) { if ( !pSN.m_strParams.startsWith("&") ) strBody += "&"; strBody += pSN.m_strParams; } bRemoveAfterFire = bRemoveAfterFire && pSN.m_bRemoveAfterFire; } } if ( bRemoveAfterFire ) clearNotification(src); LOG.INFO("Fire notification. Source : " + (src != null ? (src).getName():"") + "; " + pSN.ToString()); if ( callNotify(pSN, strBody) ) clearNotification(src); }catch(Exception exc) { LOG.ERROR("Fire notification failed.", exc); } }
void doFireSyncNotification(SyncSource src, boolean bFinish, int nErrCode, String strError, String strParams, String strServerError) { if (getSync().isStoppedByUser()) { return; } try{ SyncNotification pSN = null; String strBody = ""; boolean bRemoveAfterFire = bFinish; { lock (m_mxSyncNotifications){ pSN = getSyncNotifyBySrc(src); if (pSN == null) { return; } strBody = ""; if (src != null) { strBody += "total_count=" + src.getTotalCount(); strBody += "&processed_count=" + src.getCurPageCount(); strBody += "&processed_objects_count=" + getLastSyncObjectCount(src.getID()); strBody += "&cumulative_count=" + src.getServerObjectsCount(); strBody += "&source_id=" + src.getID(); strBody += "&source_name=" + src.getName(); } if (strParams.length() > 0) { strBody += (strBody.length() > 0 ? "&" : "") + strParams; } else { strBody += (strBody.length() > 0 ? "&" : "") + "sync_type=incremental"; } strBody += "&status="; if (bFinish) { if (nErrCode == RhoAppAdapter.ERR_NONE) { if (getSync().isSchemaChanged()) { strBody += "schema_changed"; } else { strBody += (src == null && strParams.length() == 0) ? "complete" : "ok"; } } else { if (getSync().isStoppedByUser()) { nErrCode = RhoAppAdapter.ERR_CANCELBYUSER; } strBody += "error"; strBody += "&error_code=" + nErrCode; if (strError != null && strError.length() > 0) { strBody += "&error_message=" + URI.urlEncode(strError); } else if (src != null) { strBody += "&error_message=" + URI.urlEncode(src.m_strError); } if (strServerError != null && strServerError.length() > 0) { strBody += "&" + strServerError; } else if (src != null && src.m_strServerError != null && src.m_strServerError.length() > 0) { strBody += "&" + src.m_strServerError; } } if (src != null) { strBody += makeCreateObjectErrorBody(src.getID()); } } else { strBody += "in_progress"; } strBody += "&rho_callback=1"; if (pSN.m_strParams != null && pSN.m_strParams.length() > 0) { if (!pSN.m_strParams.startsWith("&")) { strBody += "&"; } strBody += pSN.m_strParams; } bRemoveAfterFire = bRemoveAfterFire && pSN.m_bRemoveAfterFire; } } if (bRemoveAfterFire) { clearNotification(src); } LOG.INFO("Fire notification. Source : " + (src != null ? (src).getName():"") + "; " + pSN.ToString()); if (callNotify(pSN, strBody)) { clearNotification(src); } }catch (Exception exc) { LOG.ERROR("Fire notification failed.", exc); } }