Example #1
0
  /**
   * Retourne un utilisateur comme représenté sur le serveur
   *
   * @param userId : Login de l'utilisateur
   * @return : Utilisateur s'il est trouvé. si non une exception est lancé.
   * @throws Exception
   */
  public static User getUser(String userId) throws Exception {
    HttpClient m_ClientHttp = new DefaultHttpClient();
    try {
      User temp;
      URI uri = new URI("https", WEB.URL, WEB.GET_USER(userId), null, null);
      HttpGet requeteGet = new HttpGet(uri);
      requeteGet.addHeader("Content-Type", "application/json");

      String body = m_ClientHttp.execute(requeteGet, new BasicResponseHandler());
      temp = JsonParser.deseriliserUser(new JSONObject(body));
      return temp;
    } catch (Exception e) {
      throw e;
    }
  }
Example #2
0
  public static User signIn(Connection con) throws Exception {
    HttpClient m_ClientHttp = new DefaultHttpClient();
    try {
      User temp;
      URI uri = new URI("https", WEB.URL, WEB.CON, null, null);
      HttpPost requetePost = new HttpPost(uri);

      // String body = m_ClientHttp.execute(requeteGet, new BasicResponseHandler());
      // Log.i(TAG, "Reçu (PUT) : " + body);

      JSONObject obj = JsonParser.serialiseCon(con);
      requetePost.setEntity(new StringEntity(obj.toString(), HTTP.UTF_8));
      requetePost.addHeader("Content-Type", "application/json");

      String body = m_ClientHttp.execute(requetePost, new BasicResponseHandler());
      temp = JsonParser.deseriliserUser(new JSONObject(body));
      return temp;
    } catch (Exception e) {
      throw e;
    }
  }