Examples of Wavelet


Examples of com.google.wave.api.Wavelet

  @Override
  public void onWaveletSelfAdded(WaveletSelfAddedEvent e) {
    // Invoked when any participants have been added/removed from the wavelet.
    LOG.info("onWaveletSelfAdded");
    Blip blip = e.getBlip();
    Wavelet wavelet = e.getWavelet();

    // Test setting wavelet title.
    wavelet.setTitle("A wavelet title");

    // Test inserting image.
    blip.append(new Image("http://www.google.com/logos/clickortreat1.gif", 320, 118,
        "Click or treat"));

    // Test inserting list.
    Line line = new Line();
    line.setLineType("li");
    line.setIndent("2");
    blip.append(line);
    blip.append("bulleted!");

    // Test inserting extension installer.
    String installerUrl = "http://wave-skynet.appspot.com/public/extensions/areyouin/manifest.xml";
    blip.append(new Installer(installerUrl));

    // Test adding a proxied reply. The reply will be posted by
    // jkitchensinky+proxy@appspot.com. Note that as a side effect this will
    // also add this participant to the wave.
    wavelet.proxyFor("proxy").reply("\n").append("Douwe says Java rocks!");

    // Test inserting inline blip.
    Blip inlineBlip = blip.insertInlineBlip(5);
    inlineBlip.append("Hello again!");

    // Test creating a new wave. The new wave will have its own operation queue.
    // {@link AbstractRobot#newWave(String, Set, String, String)} takes a
    // {@code message} parameter which can be set to an arbitrary string. By
    // setting it to the serialized version of the current wave, we can
    // reconstruct the current wave when the other wave is constructed and
    // update the current wave.
    JsonElement waveletJson = SERIALIZER.toJsonTree(wavelet.serialize());
    JsonElement blipJson = SERIALIZER.toJsonTree(blip.serialize());
    JsonObject json = new JsonObject();
    json.add("wavelet", waveletJson);
    json.add("blip", blipJson);
    Wavelet newWave = this.newWave(wavelet.getDomain(), wavelet.getParticipants(),
        SERIALIZER.toJson(json), null);
    newWave.getParticipants().setParticipantRole(wavelet.getCreator(), Participants.Role.READ_ONLY);
   
    newWave.getRootBlip().append("A new day and a new wave");
    newWave.getRootBlip().appendMarkup("<p>Some stuff!</p><p>Not the <b>beautiful</b></p>");

    // Since the new wave has its own operation queue, we need to submit it
    // explicitly through the active gateway, or, as in this case, submit it
    // together with wavelet, which will handle the submit automatically.
    newWave.submitWith(wavelet);

    // Test inserting a form element.
    blip.append(new FormElement(ElementType.CHECK, "My Label", "true", "false"));

    // Test inserting replies with image.
View Full Code Here

Examples of com.google.wave.api.Wavelet

    WaveletData waveletData = SERIALIZER.fromJson(json.get("wavelet"), WaveletData.class);
    BlipData blipData = SERIALIZER.fromJson(json.get("blip"), BlipData.class);
    OperationQueue operationQueue = new OperationQueue();

    Map<String, Blip> blips = new HashMap<String, Blip>();
    Wavelet originalWavelet = Wavelet.deserialize(operationQueue, blips, waveletData);

    Blip rootBlip = Blip.deserialize(operationQueue, originalWavelet, blipData);
    blips.put(rootBlip.getBlipId(), rootBlip);

    // Add a gadget that embeds the newly created wave to the original wavelet.
    Gadget gadget = new Gadget("http://jkitchensinky.appspot.com/public/embed.xml");
    gadget.setProperty("waveid", e.getWavelet().getWaveId().serialise());
    originalWavelet.getRootBlip().append(gadget);

    // Insert some non-standard characters.
    String unicodeString = "\u0430\u0431\u0432";
    originalWavelet.getRootBlip().append("\nInserted a gadget: " + unicodeString);

    // Again, we have to explicitly submit the operations to the other wavelet.
    originalWavelet.submitWith(e.getWavelet());
  }
View Full Code Here

Examples of com.google.wave.api.Wavelet

  }

  @Override
  public void processEvents(RobotMessageBundle robotMessageBundle) {

    final Wavelet wavelet = robotMessageBundle.getWavelet();
    final Blip rootBlip = wavelet.getRootBlip();
    // Construct an oauthService with the user key and Twitter OAuth info.
    final String authUserId = wavelet.getCreator() + "@" + wavelet.getWaveId();
    final TwitterService twitterService = new TwitterService(authUserId, getRobotAddress());
    final PopupLoginFormHandler loginForm = new PopupLoginFormHandler(getRobotAddress());
       
    // Handle the flow when Tweety was just added to a new wave.
    if (robotMessageBundle.wasSelfAdded()) {
      rootBlip.getDocument().setAuthor(TWEETY_ID);
      wavelet.setTitle("Sign into Twitter");

      // Checks if the user is authorized with the service provider.
      // If not, fetches the request token and authorizes it.
      if (!twitterService.checkAuthorization(wavelet, loginForm)) {
        LOG.info("Request token fetched and authorized");
        return;
      }
    }
   
    PersistenceManager pm = SingletonPersistenceManagerFactory.get().getPersistenceManager();
    TwitterWave twitterWave =
        TwitterWave.getTwitterWave(pm, wavelet.getWaveId(), wavelet.getWaveletId(), wavelet
            .getCreator());

    try {
      // When user logs in via the popup, finish OAuth by exchanging
      // request token for an access token.
      for (Event event : robotMessageBundle.getEvents()) {
        if (event.getType() == EventType.DOCUMENT_CHANGED) {
          // Get all the gadgets in the wave (typically only be one).
          TextView document = wavelet.getRootBlip().getDocument();
          GadgetView gadgetView = document.getGadgetView();
          for (Gadget gadget : gadgetView.getGadgets()) {
            if ((gadget != null) && ("true".equals(gadget.getField(GADGET_STATE)))) {
              if (twitterService.checkAuthorization(wavelet, loginForm)) {
                FetchController controller =
View Full Code Here

Examples of com.google.wave.api.Wavelet

   * Receives and handles Wave events.
   * @param bundle contains all incoming wave events.
   */
  @Override
  public void processEvents(RobotMessageBundle bundle) {
    Wavelet wavelet = bundle.getWavelet();

    if (bundle.wasSelfAdded() && bundle.isNewWave() && !wavelet.hasDataDocument(TOC_FLAG)) {
      TableOfContents contents = new TableOfContents(wavelet);
      wavelet.appendDataDocument(TOC_FLAG, "true");
      wavelet.appendDataDocument(WAVE_ID, contents.getWaveId());
      wavelet.appendDataDocument(WAVELET_ID, contents.getWaveletId());
      wavelet.appendDataDocument(BLIP_ID, contents.getBlipId());
    }
   
    // Handle various events.
    for (Event e : bundle.getEvents()) {
      switch (e.getType()) {
        case FORM_BUTTON_CLICKED:
          // New post button pressed in TOC wave.
          newPost(bundle, wavelet);
          break;
        case BLIP_SUBMITTED:
          // Post title changed.
          if ("false".equals(wavelet.getDataDocument(TOC_FLAG))) {
            if (!wavelet.getDataDocument(TITLE).equals(wavelet.getTitle())) {
              updateTableOfContents(bundle, wavelet);
            }
          }
          break;
        case DOCUMENT_CHANGED:
          // Receives and parses the Table of Contents BlipID from Rusty.
          String newIds = wavelet.getDataDocument("_new_ids_");
          if (newIds != null && !newIds.isEmpty()) {
            for (String line : newIds.split(LINE_SEP_REGEX)) {
              if (line.startsWith("<p>" + wavelet.getDataDocument(BLIP_ID))) {
                String[] pollBlip = line.split(FIELD_SEP_REGEX);
                String participantPollBlipId = pollBlip[1];
                pollBlip = participantPollBlipId.split(" ");
                participantPollBlipId = pollBlip[2];
                wavelet.setDataDocument(BLIP_ID, participantPollBlipId);
              }
            }
            wavelet.setDataDocument("_new_ids_", "");
          }
          break;
      }
    }
  }
View Full Code Here

Examples of com.google.wave.api.Wavelet

    // Adds the blog owner, robot, and all participants of TOC
    // as participants on the new blog wave.
    participants.add(ROBOT);
    participants.add(wavelet.getCreator());
    participants.addAll(wavelet.getParticipants());
    Wavelet newWavelet = bundle.createWavelet(participants, annotationWriteBack);
   
    // Sets initial wave information.
    newWavelet.setTitle(BLOG_TITLE);
    newWavelet.appendDataDocument(TITLE, BLOG_TITLE);
   
    // Give the new wave the Table Of Contents data.
    passTableOfContentsData(newWavelet, waveId, waveletId, blipId)
  }
View Full Code Here

Examples of com.google.wave.api.Wavelet

    String postTitle = postWavelet.getTitle();
   
    // Get access to table of contents blip by using the stored information.
    Blip blip = bundle.getBlip(waveId, waveletId, blipId);
    TextView contentsDocument = blip.getDocument();
    Wavelet contentsWavelet = blip.getWavelet();
       
    // Add and linkify the title of the new blog post.
    String postWaveId = postWavelet.getWaveId();
    contentsDocument.insert(0, "\n" + postTitle);
    int upperIndex = postTitle.length() + 1;
View Full Code Here

Examples of com.google.wave.api.Wavelet

    } catch (PersistenceException e) {
      LOG.log(Level.WARNING, "Cannot fetch account data for robot id: " + getRobotId(), e);
    }
    if (account != null) {
      setupOAuth(account.getId().getAddress(), account.getConsumerSecret(), rpcUrl);
      Wavelet newWelcomeWavelet = newWave(getWaveDomain(), Sets.newHashSet(id.getAddress()));
      if (welcomeWaveId != null) {
        Wavelet templateWelcomeWavelet =
          fetchWavelet(welcomeWaveId, WaveletId.of(getWaveDomain(), "conv+root"), rpcUrl);
        RobotsUtil.copyBlipContents(templateWelcomeWavelet.getRootBlip(),
            newWelcomeWavelet.getRootBlip());
      } else {
        appendLine(newWelcomeWavelet.getRootBlip(), "Welcome to " + getWaveDomain() + "!");
      }
      submit(newWelcomeWavelet, rpcUrl);
View Full Code Here

Examples of com.google.wave.api.Wavelet

    // Deserialize wavelet.
    WaveletData waveletData = context.deserialize(jsonObj.get(WAVELET_TAG), WaveletData.class);
    result.setWaveletData(waveletData);
    Map<String, Blip> blips = new HashMap<String, Blip>();
    Map<String, BlipThread> threads = new HashMap<String, BlipThread>();
    Wavelet wavelet = Wavelet.deserialize(operationQueue, blips, threads, waveletData);
    wavelet.setRobotAddress(robotAddress);
    result.setWavelet(wavelet);

    // Deserialize threads.
    Map<String, BlipThread> tempThreads = context.deserialize(jsonObj.get(THREADS_TAG),
        GsonFactory.THREAD_MAP_TYPE);
View Full Code Here

Examples of org.waveprotocol.wave.concurrencycontrol.FetchWaveViewResponse.Wavelet

      return this;
    }

    /** Builds a {@link Wavelet} using this builder and a factory. */
    public Wavelet build(Factory factory) {
      Wavelet message = factory.create();
      message.setWaveletId(waveletId);
      message.setSnapshot(snapshot);
      return message;
    }
View Full Code Here

Examples of org.waveprotocol.wave.model.wave.Wavelet

      return WaveBasedConversationView.create(getWave(), getIdGenerator());
    }

    /** @return the user supplement of the wave. Subclasses may override. */
    protected LocalSupplementedWave createSupplement() {
      Wavelet udw = getWave().getUserData();
      if (udw == null) {
         udw = getWave().createUserData();
      }
      ObservablePrimitiveSupplement state = WaveletBasedSupplement.create(udw);
      ObservableSupplementedWave live = new LiveSupplementedWaveImpl(
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.