Package org.waveprotocol.wave.model.wave

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


        any(SubmitRequestListener.class));
    verifyZeroInteractions(submitListener);
  }

  public void testCannotSubmitAsDifferentUser() {
    ParticipantId otherParticipant = new ParticipantId("another@example.com");
    OpenListener openListener = openWave(IdFilters.ALL_IDS);
    String channelId = verifyChannelId(openListener);

    SubmitRequestListener submitListener = mock(SubmitRequestListener.class);
    clientFrontend.submitRequest(otherParticipant, WN1, SERIALIZED_DELTA, channelId,
View Full Code Here


   */
  private ObservableWaveletData buildSnapshot(final long version, final byte[] signature) {
    HashedVersion hv = HashedVersion.of(version, signature);
    return DATA_FACTORY.create(
        new EmptyWaveletSnapshot(WAVE_ID, WAVELET_ID,
            new ParticipantId("creator@gwave.com"), hv, 0L));
  }
View Full Code Here

  public void testMultipleVaildAddresses()  throws Exception {
    String stringOne = "test1@test.com";
    String stringTwo = "test2@example.com";
    String stringThree = "test3@example.com";
    ParticipantId idOne = ParticipantId.ofUnsafe(stringOne);
    ParticipantId idTwo = ParticipantId.ofUnsafe(stringTwo);
    ParticipantId idThree = ParticipantId.ofUnsafe(stringThree);

    ParticipantId[] participants = ParticipantController.buildParticipantList(
        null, stringOne + "," + stringTwo + "," + stringThree);

    assertEquals("Wrong number of participants created", 3, participants.length);
View Full Code Here

  public void testMultipleLocalVaildAddresses() throws Exception {
    String stringOne = "test1";
    String stringTwo = "test2";
    String stringThree = "test3";
    ParticipantId idOne = ParticipantId.ofUnsafe(stringOne + "@localhost");
    ParticipantId idTwo = ParticipantId.ofUnsafe(stringTwo + "@localhost");
    ParticipantId idThree = ParticipantId.ofUnsafe(stringThree + "@localhost");

    ParticipantId[] participants = ParticipantController.buildParticipantList(
        "localhost", stringOne + "," + stringTwo + "," + stringThree);

    assertEquals("Wrong number of participants created", 3, participants.length);
View Full Code Here

      resp.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
      return;
    }

    // Check if the user is logged in, else redirect to login.
    ParticipantId user = sessionManager.getLoggedInUser(req.getSession(false));
    if (user == null) {
      resp.sendRedirect(sessionManager.getLoginUrl(
          DATA_API_OAUTH_PATH + authorizeTokenPath + "?" + req.getQueryString()));
      return;
    }
View Full Code Here

   *
   * @return the add-participant operation injected as a side-effect to
   *         to authorisation, or null if no operation was injected.
   */
  private AddParticipant authorise(WaveletOperation op) {
    ParticipantId author = op.getContext().getCreator();
    Set<ParticipantId> participantIds = getParticipantIds();
    if (participantIds.contains(author)) {
      // Users on the participant list may submit ops directly.
    } else if (participantIds.isEmpty()) {
      // Model is unaware of how participants are allowed to join a wave when
      // there is no one to authorise them. Assume the op is authorised, leaving
      // it to another part of the system to reject it if necessary.
    } else {
      ParticipantId authoriser = null;
      authoriser = participationHelper.getAuthoriser(author, participantIds);
      if (authoriser != null) {
        AddParticipant authorisation =
            new AddParticipant(contextFactory.createContext(authoriser), author);
        applyAndSend(authorisation);
View Full Code Here

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

    Set<ParticipantId> currentAndNewParticipants = Sets.newHashSet(wavelet.getParticipants());
    for (TransformedWaveletDelta delta : deltas) {
      // Participants added or removed in this delta get the whole delta.
      for (WaveletOperation op : delta) {
        if (op instanceof AddParticipant) {
          ParticipantId p = ((AddParticipant) op).getParticipantId();
          currentAndNewParticipants.add(p);
        }
      }
    }
    // Robot should receive also deltas that contain AddParticipant ops.
    // EventGenerator will take care to filter out events before the add.
    for (ParticipantId participant : currentAndNewParticipants) {
      RobotName robotName = RobotName.fromAddress(participant.getAddress());
      if (robotName == null) {
        // Not a valid robot name, next.
        continue;
      }

      ParticipantId robotId = ParticipantId.ofUnsafe(robotName.toEmailAddress());
      AccountData account;
      try {
        account = accountStore.getAccount(robotId);
      } catch (PersistenceException e) {
        LOG.severe("Failed to retrieve the account data for " + robotId.getAddress(), e);
        continue;
      }

      if (account != null && account.isRobot()) {
        RobotAccountData robotAccount = account.asRobot();
View Full Code Here

    if (Strings.isNullOrEmpty(username) || Strings.isNullOrEmpty(location)) {
      doRegisterGet(req, resp, "Please complete all fields.");
      return;
    }

    ParticipantId id;
    try {
      id = ParticipantId.of(username + "@" + domain);
    } catch (InvalidParticipantAddress e) {
      doRegisterGet(req, resp, "Invalid username specified, use alphanumeric characters only.");
      return;
    }

    RobotAccountData robotAccount = null;
    try{
      robotAccount = robotRegistrar.registerNew(id, location);
    } catch (RobotRegistrationException e) {
      doRegisterGet(req, resp, e.getMessage());
      return;
    } catch (PersistenceException e) {
      LOG.severe("Failed to retrieve account data for " + id, e);
      doRegisterGet(req, resp, "Failed to retrieve account data for " + id.getAddress());
      return;
    }
    onRegisterSuccess(req, resp, robotAccount);
  }
View Full Code Here

  /**
   * Ensures that the robot agent is registered in the {@link AccountStore}.
   */
  private void ensureRegistered(TokenGenerator tokenGenerator, String serverFrontendAddress) {
    ParticipantId robotId = null;
    try {
      robotId = ParticipantId.of(getRobotId() + "@" + waveDomain);
    } catch (InvalidParticipantAddress e) {
      LOG.log(Level.SEVERE, "Failed to register the agent:" + getRobotId(), e);
      return;
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.