Package org.waveprotocol.wave.model.wave.opbased

Examples of org.waveprotocol.wave.model.wave.opbased.OpBasedWavelet


    BasicWaveletOperationContextFactory CONTEXT_FACTORY =
        new BasicWaveletOperationContextFactory(participant);

    SilentOperationSink<WaveletOperation> executor =
        SilentOperationSink.Executor.<WaveletOperation, WaveletData>build(waveletData);
    OpBasedWavelet wavelet =
        new OpBasedWavelet(waveletData.getWaveId(), waveletData, CONTEXT_FACTORY,
            ParticipationHelper.DEFAULT, executor, SilentOperationSink.VOID);

    // Make a conversation with an empty root blip
    WaveletBasedConversation.makeWaveletConversational(wavelet);
    ConversationUtil conversationUtil = new ConversationUtil(FakeIdGenerator.create());
View Full Code Here


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

    String waveletId = OperationUtil.getRequiredParameter(operation, ParamsProperty.WAVELET_ID);
    String conversationId;
View Full Code Here

      // This robot is proxying so set the proxy field.
      messages.setProxyingFor(robotName.getProxyFor());
    }

    // Sending any operations will cause an exception.
    OpBasedWavelet wavelet =
        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

      }
    }

    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 {
View Full Code Here

    // Create operation adapter, which translates semantic methods into
    // operations, applying them to the target as well as sending them down
    // the operation channel. Local operation failure fails this wavelet
    // permanently.
    wavelet = new OpBasedWavelet(waveId, target, contextFactory, participationHelper,
        opTap.incoming(), opTap.outgoing());

    // Create operation sucker, which sucks operations out of the channel and
    // applies them to the CC target.
    driver = new OperationSucker(channel, opTap.incoming());
View Full Code Here

    Map<ParticipantId, ObservableConversationView> conversations =
        openedConversations.get(waveletName);

    if (!conversations.containsKey(participant)) {
      OpBasedWavelet wavelet = openWavelet(waveId, waveletId, participant);
      conversations.put(participant, conversationUtil.buildConversation(wavelet));
    }
    return conversations.get(participant);
  }
View Full Code Here

    CapturingOperationSink<WaveletOperation> output =
        new CapturingOperationSink<WaveletOperation>();

    BasicWaveletOperationContextFactory contextFactory =
        new BasicWaveletOperationContextFactory(opAuthor);
    OpBasedWavelet w =
        new OpBasedWavelet(perAuthorWavelet.getWaveId(), perAuthorWavelet, contextFactory,
            ParticipationHelper.DEFAULT, executor, output);

    // Store the new sink and wavelet
    sinkMap.put(opAuthor, output);
    waveletMap.put(opAuthor, w);
View Full Code Here

    String blipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID);

    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);
View Full Code Here

      ImmutableSet<WaveletId> waveletIds = context.getVisibleWaveletIds(operation, participant);
      Map<ParamsProperty, Object> data =
          ImmutableMap.<ParamsProperty, Object>of(ParamsProperty.WAVELET_IDS, waveletIds);
      context.constructResponse(operation, data);
    } else {
      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

   * @throws InvalidRequestException if the wave id provided in the operation is
   *         invalid.
   */
  public static SupplementedWave buildSupplement(OperationRequest operation,
      OperationContext context, ParticipantId participant) throws InvalidRequestException {
    OpBasedWavelet wavelet = context.openWavelet(operation, participant);
    ConversationView conversationView = context.getConversationUtil().buildConversation(wavelet);

    // TODO (Yuri Z.) Find a way to obtain an instance of IdGenerator and use it
    // to create udwId.
    WaveletId udwId = IdUtil.buildUserDataWaveletId(participant);
    String waveIdStr = OperationUtil.getRequiredParameter(operation, ParamsProperty.WAVE_ID);
    WaveId waveId = null;
    try {
      waveId = ApiIdSerializer.instance().deserialiseWaveId(waveIdStr);
    } catch (InvalidIdException e) {
      throw new InvalidRequestException("Invalid WAVE_ID parameter: " + waveIdStr, operation, e);
    }
    OpBasedWavelet udw = context.openWavelet(waveId, udwId, participant);

    PrimitiveSupplement udwState = WaveletBasedSupplement.create(udw);

    SupplementedWave supplement =
        SupplementedWaveImpl.create(udwState, conversationView, participant, DefaultFollow.ALWAYS);
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.wave.opbased.OpBasedWavelet

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.