Beispiel #1
0
  /**
   * Retourne un parcours comme représenté sur le réseau
   *
   * @param parcoursId : L'identifiant du parcours sur le serveur
   * @return : L'objet parcours trouvé. S'il n'est pas trouvé, une exception est lancé.
   * @throws Exception : Lancé en cas d'erreur de connexion ou de conversion d'objet json.
   */
  public static Parcours getParcours(String parcoursId) throws Exception {
    try {
      Parcours temp;
      HttpClient m_ClientHttp = new DefaultHttpClient();
      URI uri = new URI("https", WEB.URL, WEB.GET_PARCOURS(parcoursId), null, null);
      HttpGet requeteGet = new HttpGet(uri);
      requeteGet.addHeader("Content-Type", "application/json");

      String body = m_ClientHttp.execute(requeteGet, new BasicResponseHandler());

      temp = JsonParser.deserialiseParcours(new JSONObject(body));

      return temp;
    } catch (Exception e) {
      throw e;
    }
  }
Beispiel #2
0
  /**
   * Retourne un parcours comme représenté sur le réseau qui a le trajet avec l'identifiant spécifié
   *
   * @param trajetId : L'identifiant du trajet sur le serveur
   * @return : L'objet parcours trouvé. S'il n'est pas trouvé, une exception est lancé.
   * @throws Exception : Lancé en cas d'erreur de connexion ou de conversion d'objet json.
   */
  public static Parcours getTrajetParcours(String trajetId) throws Exception {
    try {
      Parcours temp;
      HttpClient m_ClientHttp = new DefaultHttpClient();
      URI uri = new URI("https", WEB.URL, WEB.GET_TRAJET_PARCOURS(trajetId), null, null);
      HttpGet requeteGet = new HttpGet(uri);
      requeteGet.addHeader("Content-Type", "application/json");

      String body = m_ClientHttp.execute(requeteGet, new BasicResponseHandler());

      temp = null;
      JSONArray res = new JSONArray(body);
      if (res.length() > 0) {
        temp = JsonParser.deserialiseParcours(((JSONObject) res.get(0)));
      }
      return temp;
    } catch (Exception e) {
      throw e;
    }
  }