Package org.waveprotocol.wave.model.wave

Examples of org.waveprotocol.wave.model.wave.ParticipantId


  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    OAuthMessage message = new HttpRequestMessage(req, req.getRequestURL().toString());
    // OAuth %-escapes the @ in the username so we need to decode it.
    String username = OAuth.decodePercent(message.getConsumerKey());

    ParticipantId participant;
    try {
      participant = ParticipantId.of(username);
    } catch (InvalidParticipantAddress e) {
      LOG.info("Participant id invalid", e);
      resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      return;
    }

    AccountData account;
    try {
      account = accountStore.getAccount(participant);
    } catch (PersistenceException e) {
      LOG.severe("Failed to retrieve account data for " + participant, e);
      resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          "An unexpected error occured while trying to retrieve account data for "
              + participant.getAddress());
      return;
    }
    if (account == null || !account.isRobot()) {
      LOG.info("The account for robot named " + participant + " does not exist");
      resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      return;
    }

    OAuthConsumer consumer =
        new OAuthConsumer(null, participant.getAddress(), account.asRobot().getConsumerSecret(),
            oauthServiceProvider);
    OAuthAccessor accessor = new OAuthAccessor(consumer);

    processOpsRequest(req, resp, message, accessor, participant);
  }
View Full Code Here


      // Have to set status here manually, cannot use e.getHttpStatusCode
      // because message.requireParameters doesn't set it in the exception.
      resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage());
      return;
    }
    ParticipantId participant =
        (ParticipantId) accessor.getProperty(DataApiTokenContainer.USER_PROPERTY_NAME);
   
    processOpsRequest(req, resp, message, accessor, participant);
  }
View Full Code Here

  public List<WaveletDelta> getDeltas() {
    List<WaveletDelta> deltas = Lists.newArrayList();

    for (Entry<ParticipantId, CapturingOperationSink<WaveletOperation>> entry :
        sinkMap.entrySet()) {
      ParticipantId author = entry.getKey();
      List<WaveletOperation> ops = entry.getValue().getOps();

      if (ops.isEmpty()) {
        // No ops to generate delta for
        continue;
View Full Code Here

  public static void executeOperation(OperationRequest operation,
      OperationServiceRegistry operationRegistry, OperationContext context, ParticipantId author) {
    try {
      OperationService service =
          operationRegistry.getServiceFor(OperationUtil.getOperationType(operation));
      ParticipantId proxyParticipant = OperationUtil.computeParticipant(operation, author);
      service.execute(operation, context, proxyParticipant);
    } catch (InvalidRequestException e) {
      LOG.warning("Operation " + operation + " failed to execute", e);
      context.constructErrorResponse(operation, e.getMessage());
    }
View Full Code Here

  //
  // Participants.
  //

  public void testAddedParticipantIsRetreived() {
    ParticipantId creator = target.getParticipantIds().iterator().next();
    ParticipantId fake = new ParticipantId("bill@foo.com");
    target.addParticipant(fake);

    assertEquals(Arrays.asList(creator, fake),
        CollectionUtils.newArrayList(target.getParticipantIds()));
  }
View Full Code Here

    assertEquals(Arrays.asList(creator, fake),
        CollectionUtils.newArrayList(target.getParticipantIds()));
  }

  public void testRemovedParticipantNoLongerRetrieved() {
    ParticipantId creator = target.getParticipantIds().iterator().next();
    ParticipantId fake = new ParticipantId("bill@foo.com");
    target.addParticipant(fake);
    target.removeParticipant(fake);

    assertEquals(Collections.singletonList(creator),
        CollectionUtils.newArrayList(target.getParticipantIds()));
View Full Code Here

    assertEquals(Collections.singletonList(creator),
        CollectionUtils.newArrayList(target.getParticipantIds()));
  }

  public void testParticipantsAreASet() {
    ParticipantId creator = target.getParticipantIds().iterator().next();
    ParticipantId fake1 = new ParticipantId("joe");
    ParticipantId fake2 = new ParticipantId("bill");
    List<ParticipantId> participants = CollectionUtils.newArrayList(creator, fake1, fake2);

    target.addParticipant(fake1);
    target.addParticipant(fake2);
    assertEquals(participants, CollectionUtils.newArrayList(target.getParticipantIds()));
View Full Code Here

  // These methods test that local modifications cause events via the
  // blip and thread listeners. They test that modifications to the underlying
  // data cause events via the conversation listener on a mirror conversation.

  public void testParticipantChangesFireEvents() {
    ParticipantId p1 = new ParticipantId("someone@example.com");
    ParticipantId p2 = new ParticipantId("else@example.com");
    ObservableConversation mirror = mirrorConversation(target);
    mirror.addListener(convListener);

    target.addParticipant(p1);
    target.addParticipant(p2);
View Full Code Here

   *         action of the given {@link CoreWaveletOperation}
   */
  public static WaveletOperation fromCoreWaveletOperation(
      WaveletOperationContext context, CoreWaveletOperation coreOp) {
    if (coreOp instanceof CoreRemoveParticipant) {
      ParticipantId participantId = ((CoreRemoveParticipant) coreOp).getParticipantId();
      return new RemoveParticipant(context, participantId);
    } else if (coreOp instanceof CoreAddParticipant) {
      ParticipantId participantId = ((CoreAddParticipant) coreOp).getParticipantId();
      return new AddParticipant(context, participantId);
    } else if (coreOp instanceof CoreWaveletDocumentOperation) {
      CoreWaveletDocumentOperation waveletDocOp = (CoreWaveletDocumentOperation) coreOp;
      return new WaveletBlipOperation(waveletDocOp.getDocumentId(),
          new BlipContentOperation(context, waveletDocOp.getOperation()));
View Full Code Here

   * @return a {@link CoreWaveletOperation} representing the action of the given
   *         {@link WaveletOperation}
   */
  public static CoreWaveletOperation toCoreWaveletOperation(WaveletOperation op) {
    if (op instanceof RemoveParticipant) {
      ParticipantId participantId = ((RemoveParticipant) op).getParticipantId();
      return new CoreRemoveParticipant(participantId);
    } else if (op instanceof AddParticipant) {
      ParticipantId participantId = ((AddParticipant) op).getParticipantId();
      return new CoreAddParticipant(participantId);
    } else if (op instanceof WaveletBlipOperation) {
      WaveletBlipOperation waveletBlipOp = (WaveletBlipOperation) op;
      BlipOperation blipOp = waveletBlipOp.getBlipOp();
      if (blipOp instanceof BlipContentOperation) {
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.wave.ParticipantId

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.