Package com.google.wave.api

Examples of com.google.wave.api.InvalidRequestException


    String parentBlipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID);
    ConversationBlip parentBlip = context.getBlip(conversation, parentBlipId);

    Integer index = OperationUtil.getRequiredParameter(operation, ParamsProperty.INDEX);
    if (index <= 0) {
      throw new InvalidRequestException(
          "Can't inline a blip on position <= 0, got " + index, operation);
    }

    ApiView view = new ApiView(parentBlip.getContent(), wavelet);
    int xmlLocation = view.transformToXmlOffset(index);
View Full Code Here


    // view.locateElement will tell where the element actually is.
    ApiView view = new ApiView(parentBlip.getContent(), wavelet);
    int elementApiLocation = view.locateElement(element);

    if (elementApiLocation == -1) {
      throw new InvalidRequestException("Requested element not found", operation);
    }

    // Insert just after the requested element
    int xmlLocation = view.transformToXmlOffset(elementApiLocation + 1);
View Full Code Here

      context.constructErrorResponse(operation, "Unable to retrieve account data");
      return;
    }

    if (account == null || !account.isRobot()) {
      throw new InvalidRequestException("Can't exectute robot.notify for unknown robot "
          + robotAccountId);
    }

    RobotAccountData robotAccountData = account.asRobot();
    RobotCapabilities capabilities = robotAccountData.getCapabilities();
View Full Code Here

    List<ParticipantId> participants = Lists.newArrayList(participant);
    for (String address : waveletData.getParticipants()) {
      try {
        participants.add(ParticipantId.of(address));
      } catch (InvalidParticipantAddress e) {
        throw new InvalidRequestException(
            address + " is not a valid participant address", operation);
      }
    }

    WaveletName waveletName = context.getConversationUtil().generateWaveletName();
    RobotWaveletData newWavelet = createEmptyRobotWavelet(participant, waveletName);
    OpBasedWavelet opBasedWavelet = newWavelet.getOpBasedWavelet(participant);

    WaveletBasedConversation.makeWaveletConversational(opBasedWavelet);

    ObservableConversationView conversation =
        context.getConversationUtil().buildConversation(opBasedWavelet);
    ObservableConversationBlip rootBlip = conversation.getRoot().getRootThread().appendBlip();

    for (ParticipantId newParticipant : participants) {
      opBasedWavelet.addParticipant(newParticipant);
    }

    // Store the temporary id of the wavelet and rootblip so that future
    // operations can reference it.
    try {
      WaveId waveId = ApiIdSerializer.instance().deserialiseWaveId(waveletData.getWaveId());
      WaveletId waveletId =
          ApiIdSerializer.instance().deserialiseWaveletId(waveletData.getWaveletId());
      context.putWavelet(waveId, waveletId, newWavelet);
    } catch (InvalidIdException e) {
      throw new InvalidRequestException("Invalid id", operation, e);
    }
    context.putBlip(waveletData.getRootBlipId(), rootBlip);

    String message = OperationUtil.getOptionalParameter(operation, ParamsProperty.MESSAGE);
    WaveletCreatedEvent event =
View Full Code Here

        OperationUtil.getOptionalParameter(operation, ParamsProperty.MODIFY_QUERY);

    DocumentHitIterator hitIterator;
    if (range != null) {
      if (index != null || query != null) {
        throw new InvalidRequestException(
            "At most one parameter out of RANGE, INDEX and MODIFY_QUERY must be specified",
            operation);
      }
      // Use the specified range
      hitIterator = new DocumentHitIterator.Singleshot(range);
    } else if (index != null) {
      if (query != null) { // range is null.
        throw new InvalidRequestException(
            "At most one parameter out of RANGE, INDEX and MODIFY_QUERY must be specified",
            operation);
      }
      // Use exactly the location of the index
      hitIterator = new DocumentHitIterator.Singleshot(new Range(index, index + 1));
View Full Code Here

      OperationRequest operation, Document doc, int start, int end, String key, String value)
      throws InvalidRequestException {
    try {
      doc.setAnnotation(start, end, key, value);
    } catch (IndexOutOfBoundsException e) {
      throw new InvalidRequestException(
          "Can't set annotation for out of bounds indices " + e.getMessage(), operation, e);
    }
  }
View Full Code Here

        // Can't delete the first new line.
        start = 1;
      }

      if (start >= end) {
        throw new InvalidRequestException(
            "Invalid range specified, " + start + ">=" + end, operation);
      }

      // Delete using the view.
      view.delete(start, end);
View Full Code Here

    try {
      targetParticipant = ParticipantId.of(paramParticipant);
    } catch (InvalidParticipantAddress e) {
      String message = "Target ParticipantId " + paramParticipant + " is not " + "valid";
      LOG.info(message);
      throw new InvalidRequestException(message);
    }

    String rootBlipId = ConversationUtil.getRootBlipId(conversation);

    // Create generic event (defined by operation type) that will be processed
    // by the context.
    Event event;

    // Set up participant containers.
    List<String> participantsAdded = Lists.newArrayList();
    List<String> participantsRemoved = Lists.newArrayList();

    OperationType type = OperationUtil.getOperationType(operation);
    switch (type) {
      case WAVELET_ADD_PARTICIPANT_NEWSYNTAX:
        // Make sure targetParticipant is not already member.
        if (conversation.getParticipantIds().contains(targetParticipant)) {
          String message = targetParticipant.getAddress() + " is already a " + "member of wavelet";
          LOG.info(message);
          throw new InvalidRequestException(message, operation);
        }

        // Add participant to conversation and send event.
        conversation.addParticipant(targetParticipant);
        participantsAdded.add(targetParticipant.getAddress());
        event =
            new WaveletParticipantsChangedEvent(null, null, participant.getAddress(),
                System.currentTimeMillis(), rootBlipId, participantsAdded, participantsRemoved);
        break;
      case WAVELET_REMOVE_PARTICIPANT_NEWSYNTAX:
        // Make sure targetParticipant is already member.
        if (!conversation.getParticipantIds().contains(targetParticipant)) {
          // Not a member, throw invalid request.
          String message = targetParticipant.getAddress() + " is not a " + "member of wavelet";
          LOG.info(message);
          throw new InvalidRequestException(message, operation);
        }

        // Remove participant and send event.
        conversation.removeParticipant(targetParticipant);
        participantsRemoved.add(targetParticipant.getAddress());
View Full Code Here

    // Create JSON-RPC success response.
    try {
      constructResponse(operation, EventSerializer.extractPropertiesToParamsPropertyMap(event));
    } catch (EventSerializationException e) {
      LOG.severe("Internal Error occurred, when serializing events", e);
      throw new InvalidRequestException("Unable to serialize events", operation);
    }
  }
View Full Code Here

          // opens a wavelet for the first time. However, if the wavelet is
          // fetched for the first time with Robot/Data API - user data should be
          // created here.
          wavelet = createEmptyRobotWavelet(participant, waveletName);
        } else {
          throw new InvalidRequestException("Wavelet " + waveletName + " couldn't be retrieved");
        }
       
      } else {
        ObservableWaveletData obsWavelet = FACTORY.create(snapshot.snapshot);
        wavelet = new RobotWaveletData(obsWavelet, snapshot.committedVersion);
View Full Code Here

TOP

Related Classes of com.google.wave.api.InvalidRequestException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.