Пример #1
0
  void callLoginCallback(SyncNotification oNotify, int nErrCode, String strMessage) {
    try {
      if (getSync().isStoppedByUser()) return;

      String strBody = "error_code=" + nErrCode;
      strBody += "&error_message=" + URI.urlEncode(strMessage != null ? strMessage : "");
      strBody += "&rho_callback=1";

      LOG.INFO("Login callback: " + oNotify.toString() + ". Body: " + strBody);

      callNotify(oNotify, strBody);
    } catch (Exception exc) {
      LOG.ERROR("Call Login callback failed.", exc);
    }
  }
Пример #2
0
  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;
      {
        synchronized (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);
    }
  }