Exemple #1
0
  /** {@inheritDoc} */
  public synchronized Result createConference(String creator, String mucRoomName) {
    Conference conference = conferenceMap.get(mucRoomName);
    if (conference == null) {
      // Create new conference
      try {
        ApiResult result = api.createNewConference(creator, mucRoomName);

        if (result.getError() == null) {
          conference = result.getConference();
          conferenceMap.put(mucRoomName, conference);
        } else if (result.getStatusCode() == 409 && result.getError().getConflictId() != null) {
          Number conflictId = result.getError().getConflictId();

          // Conference already exists(check if we have it locally)
          conference = findConferenceForId(conflictId);

          logger.info("Conference '" + mucRoomName + "' already " + "allocated, id: " + conflictId);

          // do GET conflict conference
          if (conference == null) {
            ApiResult getResult = api.getConference(conflictId);
            if (getResult.getConference() != null) {
              conference = getResult.getConference();
              // Fill full room name as it is not transferred
              // over REST API
              conference.setMucRoomName(mucRoomName);

              conferenceMap.put(mucRoomName, conference);
            } else {
              logger.error("API error: " + result);
              return new Result(RESULT_INTERNAL_ERROR, result.getError().getMessage());
            }
          }
        } else {
          // Other error
          logger.error("API error: " + result);
          return new Result(RESULT_INTERNAL_ERROR, result.getError().getMessage());
        }
      } catch (FaultTolerantRESTRequest.RetryExhaustedException e) {
        logger.error(e, e);
        return new Result(RESULT_INTERNAL_ERROR, e.getMessage());
      } catch (UnsupportedEncodingException e) {
        logger.error(e, e);
        return new Result(RESULT_INTERNAL_ERROR, e.getMessage());
      }
    }

    // Verify owner == creator
    if (creator.equals(conference.getOwner())) {
      return new Result(RESULT_OK);
    } else {
      logger.error(
          "Room " + mucRoomName + ", conflict : " + creator + " != " + conference.getOwner());

      return new Result(RESULT_CONFLICT);
    }
  }
Exemple #2
0
 /**
  * Deletes conference from the reservation system.
  *
  * @param id identifier of the conference which has to be removed.
  * @return one of {@link ReservationSystem} "result" constants.
  */
 private int deleteConference(Number id) {
   // Delete conference
   try {
     logger.info("Deleting conference: " + id);
     ApiResult result = api.deleteConference(id);
     if (result.getStatusCode() == 200) {
       logger.info("Conference " + id + " deleted - OK");
       return RESULT_OK;
     } else {
       logger.error("DELETE API ERROR: " + result);
     }
   } catch (FaultTolerantRESTRequest.RetryExhaustedException e) {
     logger.error(e, e);
   }
   return RESULT_INTERNAL_ERROR;
 }