Example #1
0
 public void reserveSeats(ReservationRequest request) {
   for (Carriage carriage : carriages) {
     if (carriage.hasSeatsAvailableWithin(percentReservedBarrier)) {
       request.reserveSeatsInCarriage(carriage);
       return;
     }
   }
   request.cannotFindSeats();
 }
 public RegistrationRequest merge(ReservationRequest reservation) {
   if (registrant == null) {
     registrant = reservation.getRegistrant();
   }
   // same for others, when it makes sense
   return this; // TODO: construct new instead of mutating
 }
  public Token getRequestToken(URI callback, ReservationRequest request) {
    try {
      // This is an optional step. Without requesting this extra scope
      // the client will not be able to update the user's calendar.
      // Note that the Social.com has documented the format of this scope
      // as updateCalendar-x where x is a specific hour.
      // Social.com has also documented that a "readCalendar" scoped will be
      // allocated by default
      Map<String, String> extraParams = new HashMap<String, String>();
      extraParams.put(
          org.apache.cxf.rs.security.oauth.utils.OAuthConstants.X_OAUTH_SCOPE,
          OAuthConstants.UPDATE_CALENDAR_SCOPE + request.getHour());

      return OAuthClientUtils.getRequestToken(requestTokenService, consumer, callback, extraParams);
    } catch (OAuthServiceException ex) {
      return null;
    }
  }