Exemple #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);
    }
  }
Exemple #2
0
  /*
  void setSyncNotification(int source_id, String strUrl, String strParams )throws Exception
  {
  	LOG.INFO( "Set notification. Source ID: " + source_id + "; Url :" + strUrl + "; Params: " + strParams );
      String strFullUrl = getNet().resolveUrl(strUrl);

  	if ( source_id == -1 )
  	{
  		synchronized(m_mxSyncNotifications)
  		{
  			m_pAllNotification = new SyncNotification( strFullUrl, strParams, false );
  		}
  		LOG.INFO( " Done Set notification for all sources; Url :" + strFullUrl + "; Params: " + strParams );
  	}else
  	{
  	    if ( strFullUrl.length() > 0 )
  	    {
  	        synchronized(m_mxSyncNotifications){
  	        	m_mapSyncNotifications.put(new Integer(source_id),new SyncNotification( strFullUrl, strParams, true ) );
  	        }
  			LOG.INFO( " Done Set notification. Source ID: " + source_id + "; Url :" + strFullUrl + "; Params: " + strParams );
  	    }
  	}
  }*/
  void setSyncNotification(int source_id, SyncNotification pNotify) {
    LOG.INFO(
        "Set notification. Source ID: "
            + source_id
            + ";"
            + (pNotify != null ? pNotify.toString() : ""));

    if (source_id == -1) {
      synchronized (m_mxSyncNotifications) {
        m_pAllNotification = pNotify;
      }
    } else {
      synchronized (m_mxSyncNotifications) {
        m_mapSyncNotifications.put(new Integer(source_id), pNotify);
      }
    }
  }
Exemple #3
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);
    }
  }