Examples of ObservableConversation


Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

   *        This wavelet is a copy.
   * @return the server representation of the digest for the query.
   */
  Digest generateDigest(ObservableConversationView conversations, SupplementedWave supplement,
      WaveletData rawWaveletData) {
    ObservableConversation rootConversation = conversations.getRoot();
    ObservableConversationBlip firstBlip = null;
    if (rootConversation != null && rootConversation.getRootThread() != null
        && rootConversation.getRootThread().getFirstBlip() != null) {
      firstBlip = rootConversation.getRootThread().getFirstBlip();
    }
    String title;
    if (firstBlip != null) {
      Document firstBlipContents = firstBlip.getContent();
      title = TitleHelper.extractTitle(firstBlipContents).trim();
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

      conversationId = WaveletBasedConversation.idFor(
          ApiIdSerializer.instance().deserialiseWaveletId(waveletId));
    } catch (InvalidIdException e) {
      throw new InvalidRequestException("Invalid conversation id", operation, e);
    }
    ObservableConversation conversation = conversationView.getConversation(conversationId);

    OperationType type = OperationUtil.getOperationType(operation);
    switch (type) {
      case BLIP_CONTINUE_THREAD:
        continueThread(operation, context, participant, conversation);
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

      OperationRequest operation, OperationContext context, ParticipantId participant)
      throws InvalidRequestException {
   
    String title =
        OperationUtil.getRequiredParameter(operation, ParamsProperty.WAVELET_TITLE);
    ObservableConversation conversation =
        context.openConversation(operation, participant).getRoot();
    String blipId = conversation.getRootThread().getFirstBlip().getId();
    Document doc = context.getBlip(conversation, blipId).getContent();
    TitleHelper.setExplicitTitle(doc, title);
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

    if (modifyHow.equals(ModifyHowType.MARK_AS_READ.getValue())) {
      if (blipId == null || blipId.isEmpty()) {
        supplement.markAsRead();
      } else {
        ObservableConversation conversation =
            context.openConversation(operation, participant).getRoot();
        ConversationBlip blip = conversation.getBlip(blipId);
        supplement.markAsRead(blip);
      }
    } else if (modifyHow.equals(ModifyHowType.MARK_AS_UNREAD.getValue())) {
      supplement.markAsUnread();
    } else {
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

    ui.setTitleLabelText((title == null) ? "" : URL.decodeComponent(title));
    updatePrefsFromAttribute(getAttribute(PREFS_ATTRIBUTE));
    refreshParticipantInformation();

    // HACK(anorth): This event routing should happen outside the widget.
    ObservableConversation conv = (ObservableConversation) blip.getConversation();
    conv.addListener(new WaveletListenerAdapter(blip, this));
    log("Requesting Gadget metadata: ", source);
    String cachedIframeUrl = getAttribute(IFRAME_URL_ATTRIBUTE);
    if (validIframeUrl(cachedIframeUrl)) {
      registerWithController(cleanUrl(cachedIframeUrl), 0, 0);
    }
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

    DocumentModifyAction modifyAction =
        OperationUtil.getRequiredParameter(operation, ParamsProperty.MODIFY_ACTION);

    OpBasedWavelet wavelet = context.openWavelet(operation, participant);
    ObservableConversation conversation =
        context.openConversation(operation, participant).getRoot();
    Document doc = context.getBlip(conversation, blipId).getContent();

    ApiView view = new ApiView(doc, wavelet);
    DocumentHitIterator hitIterator = getDocumentHitIterator(operation, view);
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

  @Override
  public void execute(
      OperationRequest operation, OperationContext context, ParticipantId participant)
      throws InvalidRequestException {
    OpBasedWavelet wavelet = context.openWavelet(operation, participant);
    ObservableConversation conversation =
        context.openConversation(operation, participant).getRoot();

    EventMessageBundle messages =
        mapWaveletToMessageBundle(context.getConverter(), participant, wavelet, conversation);
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

  public void execute(OperationRequest operation, OperationContext context,
      ParticipantId participant) throws InvalidRequestException {

    // Get the conversation wavelet. If participant performing operation is not
    // a member of wavelet, InvalidRequestException is thrown by this method.
    ObservableConversation conversation =
        context.openConversation(operation, participant).getRoot();

    // Get participant operation is being performed on.
    String paramParticipant =
        OperationUtil.getRequiredParameter(operation, ParamsProperty.PARTICIPANT_ID);

    ParticipantId targetParticipant;
    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());

        event =
            new WaveletParticipantsChangedEvent(null, null, participant.getAddress(),
                System.currentTimeMillis(), rootBlipId, participantsAdded, participantsRemoved);
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

  // Converters.
  //

  private ObservableConversationBlip getBlip(WaveletId wid, String bid) {
    String conversationId = WaveletBasedConversation.idFor(wid);
    ObservableConversation c = conversationView.getConversation(conversationId);
    return c != null ? c.getBlip(bid) : null;
  }
View Full Code Here

Examples of org.waveprotocol.wave.model.conversation.ObservableConversation

        new OpBasedWavelet(snapshot.getWaveId(), snapshot,
            // This doesn't thrown an exception, the sinks will
            new BasicWaveletOperationContextFactory(null),
            ParticipationHelper.DEFAULT, SilentOperationSink.VOID, SilentOperationSink.VOID);

    ObservableConversation conversation = getRootConversation(wavelet);

    if (conversation == null) {
      return messages;
    }

    // Start listening
    EventGeneratingConversationListener conversationListener =
        new EventGeneratingConversationListener(conversation, capabilities, messages, robotName);
    conversation.addListener(conversationListener);
    EventGeneratingWaveletListener waveletListener =
        new EventGeneratingWaveletListener(capabilities);
    wavelet.addListener(waveletListener);

    Map<String, EventGeneratingDocumentHandler> docHandlers = Maps.newHashMap();
    try {
      for (TransformedWaveletDelta delta : waveletAndDeltas.getDeltas()) {
        // TODO(ljvderijk): Set correct timestamp and hashed version once
        // wavebus sends them along
        long timestamp = 0L;
        conversationListener.deltaBegin(delta.getAuthor(), timestamp);

        for (WaveletOperation op : delta) {
          // Check if we need to attach a doc handler.
          if ((op instanceof WaveletBlipOperation)) {
            attachDocHandler(conversation, op, docHandlers, capabilities, messages,
                delta.getAuthor(), timestamp);
          }
          op.apply(snapshot);
        }
        conversationListener.deltaEnd();
      }
    } catch (OperationException e) {
      throw new IllegalStateException("Operation failed to apply when generating events", e);
    } finally {
      conversation.removeListener(conversationListener);
      wavelet.removeListener(waveletListener);
      for (EventGeneratingDocumentHandler docHandler : docHandlers.values()) {
        docHandler.doc.removeListener(docHandler);
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.