Ejemplo n.º 1
0
  /**
   * Send Conference POST request to API endpoint which is used for allocating new conferences in
   * reservation system.
   *
   * @param ownerEmail email of new conference owner
   * @param mucRoomName full name of MUC room that is hosting the conference.
   *     {room_name}@{muc.server.net}
   * @return <tt>ApiResult</tt> that contains system response. It will contain <tt>Conference</tt>
   *     instance filled with data from the reservation system if everything goes OK.
   * @throws FaultTolerantRESTRequest.RetryExhaustedException When the number of retries to submit
   *     the request for the conference data is reached
   * @throws UnsupportedEncodingException When the room data have the encoding that does not play
   *     with UTF8 standard
   */
  public ApiResult createNewConference(String ownerEmail, String mucRoomName)
      throws FaultTolerantRESTRequest.RetryExhaustedException, UnsupportedEncodingException {
    Conference conference = new Conference(mucRoomName, ownerEmail, new Date());

    HttpPost post = new HttpPost(baseUrl + "/conference");

    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
    Map<String, Object> jsonMap = conference.createJSonMap();

    for (Map.Entry<String, Object> entry : jsonMap.entrySet()) {
      nameValuePairs.add(new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue())));
    }

    post.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF8"));

    logger.info("Sending post: " + jsonMap);

    CreateConferenceResponseParser conferenceResponseParser =
        new CreateConferenceResponseParser(conference);

    FaultTolerantRESTRequest faultTolerantRESTRequest =
        new FaultTolerantRESTRequest(post, conferenceResponseParser, retriesCreate, httpClient);

    return faultTolerantRESTRequest.submit();
  }
Ejemplo n.º 2
0
  /**
   * Sends conference DELETE request to the REST API endpoint.
   *
   * @param conferenceId the identifier of the conference to be destroyed.
   * @return <tt>ApiResult</tt> that describes the response. Check <tt>ApiResult#statusCode</tt> to
   *     see if it went OK.
   * @throws FaultTolerantRESTRequest.RetryExhaustedException When the number of retries to submit
   *     the request for the conference data is reached
   */
  public ApiResult deleteConference(Number conferenceId)
      throws FaultTolerantRESTRequest.RetryExhaustedException {
    HttpDelete delete = new HttpDelete(baseUrl + "/conference/" + conferenceId);

    DeleteConferenceResponseParser conferenceResponseParser = new DeleteConferenceResponseParser();

    FaultTolerantRESTRequest faultTolerantRESTRequest =
        new FaultTolerantRESTRequest(delete, conferenceResponseParser, retriesDelete, httpClient);

    return faultTolerantRESTRequest.submit();
  }
Ejemplo n.º 3
0
  /**
   * Sends Conference GET request to the REST API endpoint. Is used to read info about the
   * conference from the reservation system.
   *
   * @param conferenceId the identifier of the conference for which we want to read the data.
   * @return <tt>ApiResult</tt> which describes the response. It will contain <tt>Conference</tt> if
   *     data has been read successfully.
   * @throws FaultTolerantRESTRequest.RetryExhaustedException when the number of retries to submit
   *     the request for the conference data is reached
   */
  public ApiResult getConference(Number conferenceId)
      throws FaultTolerantRESTRequest.RetryExhaustedException {
    HttpGet get = new HttpGet(baseUrl + "/conference/" + conferenceId);

    GetConferenceResponseParser conferenceResponseParser = new GetConferenceResponseParser();

    FaultTolerantRESTRequest faultTolerantRESTRequest =
        new FaultTolerantRESTRequest(
            get, conferenceResponseParser, retriesResolveConflict, httpClient);

    return faultTolerantRESTRequest.submit();
  }