当前位置: 首页>>代码示例>>Java>>正文


Java AddParticipant类代码示例

本文整理汇总了Java中org.waveprotocol.wave.model.operation.wave.AddParticipant的典型用法代码示例。如果您正苦于以下问题:Java AddParticipant类的具体用法?Java AddParticipant怎么用?Java AddParticipant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AddParticipant类属于org.waveprotocol.wave.model.operation.wave包,在下文中一共展示了AddParticipant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createWaveletOperation

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
/**
 * Deserializes a wavelet-operation message.
 *
 * @param context  operation context for the operation
 * @param message  operation message
 * @param checkWellFormed If we should check for wellformness of deserialised DocOp
 * @return an operation described by {@code message}
 */
public static WaveletOperation createWaveletOperation(WaveletOperationContext context,
    ProtocolWaveletOperation message, boolean checkWellFormed)
    throws InvalidInputException {

  try {
    if (message.hasNoOp() && message.getNoOp()) {
      return new NoOp(context);
    } else if (message.getAddParticipant() != null && !message.getAddParticipant().isEmpty()) {
      return new AddParticipant(context, ParticipantId.of(message.getAddParticipant()));
    } else if (message.getRemoveParticipant() != null
        && !message.getRemoveParticipant().isEmpty()) {
      return new RemoveParticipant(context, ParticipantId.of(message.getRemoveParticipant()));
    } else if (message.getMutateDocument() != null) {
      return createBlipOperation(context, message, checkWellFormed);
    }
    throw new IllegalArgumentException("Unsupported operation: " + message);
  } catch (InvalidParticipantAddress e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:29,代码来源:OperationFactory.java

示例2: deserialize

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
/**
 * Deserialize a {@link ProtocolWaveletOperation} as a {@link WaveletOperation}.
 *
 * @param protobufOp protocol buffer wavelet operation to deserialize
 * @return deserialized wavelet operation
 */
public static WaveletOperation deserialize(ProtocolWaveletOperation protobufOp,
    WaveletOperationContext context) {
  if (protobufOp.hasNoOp()) {
    return new NoOp(context);
  } else if (protobufOp.hasAddParticipant()) {
    return new AddParticipant(context, new ParticipantId(protobufOp.getAddParticipant()));
  } else if (protobufOp.hasRemoveParticipant()) {
    return new RemoveParticipant(context, new ParticipantId(protobufOp.getRemoveParticipant()));
  } else if (protobufOp.hasMutateDocument()) {
    return new WaveletBlipOperation(protobufOp.getMutateDocument().getDocumentId(),
        new BlipContentOperation(context,
            deserialize(protobufOp.getMutateDocument().getDocumentOperation())));
  } else {
    throw new IllegalArgumentException("Unsupported operation: " + protobufOp);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:23,代码来源:OperationSerializer.java

示例3: deserializeWaveletOperation

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
public static WaveletOperation deserializeWaveletOperation(DBObject dbObject,
    WaveletOperationContext context) throws PersistenceException {
  String type = (String) dbObject.get(FIELD_TYPE);
  if (type.equals(WAVELET_OP_NOOP)) {
    return new NoOp(context);
  } else if (type.equals(WAVELET_OP_ADD_PARTICIPANT)) {
    return new AddParticipant(context,
        deserializeParicipantId((DBObject) dbObject.get(FIELD_PARTICIPANT)));
  } else if (type.equals(WAVELET_OP_REMOVE_PARTICIPANT)) {
    return new RemoveParticipant(context,
        deserializeParicipantId((DBObject) dbObject.get(FIELD_PARTICIPANT)));
  } else if (type.equals(WAVELET_OP_WAVELET_BLIP_OPERATION)) {
    return new WaveletBlipOperation((String) dbObject.get(FIELD_BLIPID),
        deserializeBlipContentOperation((DBObject) dbObject.get(FIELD_BLIPOP), context));
  } else {
    throw new IllegalArgumentException("Unsupported operation: " + type);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:19,代码来源:MongoDbStoreUtil.java

示例4: serialize

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
/**
 * Serialize a {@link WaveletOperation} as a {@link ProtocolWaveletOperation}.
 *
 * @param waveletOp wavelet operation to serialize
 * @return serialized protocol buffer wavelet operation
 */
public ProtocolWaveletOperation serialize(WaveletOperation waveletOp) {
  ProtocolWaveletOperation protobufOp = adaptor.createProtocolWaveletOperation();

  if (waveletOp instanceof NoOp) {
    protobufOp.setNoOp(true);
  } else if (waveletOp instanceof AddParticipant) {
    protobufOp.setAddParticipant(((AddParticipant) waveletOp).getParticipantId().getAddress());
  } else if (waveletOp instanceof RemoveParticipant) {
    protobufOp.setRemoveParticipant(((RemoveParticipant) waveletOp).getParticipantId()
        .getAddress());
  } else if (waveletOp instanceof WaveletBlipOperation) {
    ProtocolWaveletOperation.MutateDocument mutation = adaptor.createProtocolWaveletDocumentOperation();
    mutation.setDocumentId(((WaveletBlipOperation) waveletOp).getBlipId());
    mutation.setDocumentOperation(serialize(((WaveletBlipOperation) waveletOp).getBlipOp()));
    protobufOp.setMutateDocument(mutation);
  } else {
    throw new IllegalArgumentException("Unsupported operation type: " + waveletOp);
  }

  return protobufOp;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:28,代码来源:WaveletOperationSerializer.java

示例5: deserialize

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
/**
 * Deserialize a {@link ProtocolWaveletOperation} as a
 * {@link WaveletOperation}.
 *
 * @param protobufOp protocol buffer wavelet operation to deserialize
 * @return deserialized wavelet operation
 */
public static WaveletOperation deserialize(ProtocolWaveletOperation protobufOp,
    WaveletOperationContext ctx) {
  if (protobufOp.hasNoOp()) {
    return new NoOp(ctx);
  } else if (protobufOp.hasAddParticipant()) {
    return new AddParticipant(ctx, new ParticipantId(protobufOp.getAddParticipant()));
  } else if (protobufOp.hasRemoveParticipant()) {
    return new RemoveParticipant(ctx, new ParticipantId(protobufOp.getRemoveParticipant()));
  } else if (protobufOp.hasMutateDocument()) {
    return new WaveletBlipOperation(protobufOp.getMutateDocument().getDocumentId(),
        new BlipContentOperation(ctx, deserialize(protobufOp.getMutateDocument()
            .getDocumentOperation())));
  } else {
    throw new IllegalArgumentException("Unsupported operation: " + protobufOp);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:24,代码来源:WaveletOperationSerializer.java

示例6: authorise

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
/**
 * Gains access for the author of an operation to perform changes if they are
 * not already able to. This should generally be called before the given
 * operation has been applied locally, and must be called before it is sent to
 * the output sink. It acceptable, however, for the given operation to have
 * been applied locally already if it does not make any changes to the
 * participant list.
 *
 * @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) {
  if (op.getContext() == null) {
    return null;
  }

  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);
      return authorisation;
    }
  }
  return null;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:37,代码来源:OpBasedWavelet.java

示例7: testParticipantSnapshotSerialization

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
public void testParticipantSnapshotSerialization() throws Exception {
  ParticipantsSnapshot s = new ParticipantsSnapshot();
  s.applyAndReturnReverse(new AddParticipant(CONTEXT1, USER1));
  s.applyAndReturnReverse(new AddParticipant(CONTEXT2, USER2));
  s.applyAndReturnReverse(new AddParticipant(CONTEXT3, USER3));

  ProtoBlockStore.SegmentSnapshotRecord serialized = s.serialize();
  ParticipantsSnapshot s1 = (ParticipantsSnapshot)ParticipantsSnapshot.deserialize(serialized,
    SegmentId.PARTICIPANTS_ID);

  assertEquals(USER1, s1.getCreator());
  assertEquals(3, s1.getParticipants().size());
  assertTrue(s1.getParticipants().contains(USER1));
  assertTrue(s1.getParticipants().contains(USER2));
  assertTrue(s1.getParticipants().contains(USER3));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:17,代码来源:SerializationTest.java

示例8: writeBlock

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
private static Block writeBlock(BlockAccess wavelet, String blockId,
    HashedVersion startVersion, HashedVersion endVersion, boolean finish) throws PersistenceException {
  Block block = BlockImpl.create(blockId);
  WaveletOperationContext context = new WaveletOperationContext(USER, 1234, endVersion.getVersion(), endVersion);
  block.writeSegmentOperation(new SegmentOperationImpl(new AddParticipant(context, USER)));
  Fragment fragment = block.createFragment(SegmentId.PARTICIPANTS_ID, false);
  Segment segment = mock(Segment.class);
  when(segment.getSegmentId()).thenReturn(SegmentId.PARTICIPANTS_ID);
  fragment.setSegment(segment);
  VersionNode node = new VersionNodeImpl();
  node.setVersionInfo(new VersionInfoImpl(startVersion.getVersion(), USER, 0));
  fragment.writeVersionNode(node);
  node = new VersionNodeImpl();
  node.setVersionInfo(new VersionInfoImpl(endVersion.getVersion(), USER, 0));
  fragment.writeVersionNode(node);
  if (finish) {
    fragment.finish(node.getVersion());
  }
  wavelet.writeBlock(block);
  return block;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:22,代码来源:BlockStoreTestBase.java

示例9: testGetDeltas

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
public void testGetDeltas() {
  // Alex adds a participant to the wavelet
  OpBasedWavelet waveletAlex = wavelet.getOpBasedWavelet(ALEX);
  waveletAlex.addParticipant(TRIXIE);

  // Bob doesn't perform any operations but we do retrieve his wavelet
  wavelet.getOpBasedWavelet(BOB);

  List<WaveletDelta> deltas = wavelet.getDeltas();
  assertTrue("Only one participant has performed operations", deltas.size() == 1);

  WaveletDelta delta = deltas.get(0);

  HashedVersion version = delta.getTargetVersion();
  assertEquals(
      "Delta should apply to the version given on construction", hashedVersionZero, version);

  assertEquals(ALEX, delta.getAuthor());

  assertTrue(delta.size() == 1);

  AddParticipant addParticipantOp = new AddParticipant(null, TRIXIE);
  assertEquals("Expected operation that adds Trixie to the wavelet", addParticipantOp,
      delta.iterator().next());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:26,代码来源:RobotWaveletTest.java

示例10: setUp

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  waveletData = WaveletDataUtil.createEmptyWavelet(WAVELET_NAME, ALEX, HashedVersion.unsigned(0),
      0L);
  waveletData.addParticipant(ALEX, null);

  AddParticipant addBobOp = new AddParticipant(new WaveletOperationContext(ALEX, 0L, 1, V1), BOB);

  addBobOp.apply(waveletData);
  TransformedWaveletDelta delta =
      new TransformedWaveletDelta(ALEX, V1, 0L, Arrays.asList(addBobOp));

  wavelet = WaveletAndDeltas.create(waveletData, DeltaSequence.of(delta));
  addCarolOp = new AddParticipant(new WaveletOperationContext(ALEX, 0L, 2, V2), CAROL);
  removeAlexOp = new RemoveParticipant(new WaveletOperationContext(ALEX, 0L, 3, V3), ALEX);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:17,代码来源:WaveletAndDeltasTest.java

示例11: testAddingParticipantIdSetProducesManyOperations

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
public void testAddingParticipantIdSetProducesManyOperations() {
  target.addParticipant(target.getCreatorId());
  Set<ParticipantId> participants = new HashSet<ParticipantId>();
  for (int i = 0; i < 20; i++) {
    ParticipantId participant = new ParticipantId("foo" + i + "@bar.com");
    participants.add(participant);
  }
  target.addParticipantIds(participants);
  List<WaveletOperation> operations = sink.getOps();
  for (WaveletOperation op : operations) {
    assertTrue("The operation was not an AddParticipant operator",
        op instanceof AddParticipant);
    participants.remove(((AddParticipant)op).getParticipantId());
  }
  assertEquals("Not all participants resulted in an operation",0, participants.size());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:17,代码来源:OpBasedWaveletTestBase.java

示例12: testNonParticipantAutoAddedByAuthoriser

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
/**
 * Tests the situation where someone not on a wavelet's participant list
 * attempts to perform some operation. Ensures that the model adds them as a
 * participant before the attempted operations go through.
 */
public void testNonParticipantAutoAddedByAuthoriser() {
  final ParticipantId creator = target.getCreatorId();
  final ParticipantId bob = new ParticipantId("[email protected]");

  target.addParticipant(target.getCreatorId());

  sink.clear();
  factory.getLastContextFactory().setParticipantId(bob);
  factory.getLastAuthoriser().program(new MockParticipationHelper.Frame(creator, bob, creator));
  target.addParticipant(ParticipantId.ofUnsafe("[email protected]"));

  List<WaveletOperation> ops = sink.getOps();
  assertEquals(2, ops.size());
  assertAddParticipant(creator, bob, ops.get(0));

  assertTrue(ops.get(1) instanceof AddParticipant);
  assertEquals(bob, ops.get(1).getContext().getCreator());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:24,代码来源:OpBasedWaveletTestBase.java

示例13: serialize

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
/**
 * Serialize a {@link WaveletOperation} as a {@link ProtocolWaveletOperation}.
 *
 * @param waveletOp wavelet operation to serialize
 * @return serialized protocol buffer wavelet operation
 */
public static ProtocolWaveletOperation serialize(WaveletOperation waveletOp) {
  ProtocolWaveletOperation protobufOp = ProtocolWaveletOperationJsoImpl.create();

  if (waveletOp instanceof NoOp) {
    protobufOp.setNoOp(true);
  } else if (waveletOp instanceof AddParticipant) {
    protobufOp.setAddParticipant(((AddParticipant) waveletOp).getParticipantId().getAddress());
  } else if (waveletOp instanceof RemoveParticipant) {
    protobufOp.setRemoveParticipant(((RemoveParticipant) waveletOp).getParticipantId()
        .getAddress());
  } else if (waveletOp instanceof WaveletBlipOperation) {
    ProtocolWaveletOperation.MutateDocument mutation =
        ProtocolWaveletOperationJsoImpl.MutateDocumentJsoImpl.create();
    mutation.setDocumentId(((WaveletBlipOperation) waveletOp).getBlipId());
    mutation.setDocumentOperation(serialize(((WaveletBlipOperation) waveletOp).getBlipOp()));
    protobufOp.setMutateDocument(mutation);
  } else {
    throw new IllegalArgumentException("Unsupported operation type: " + waveletOp);
  }

  return protobufOp;
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:29,代码来源:WaveletOperationSerializer.java

示例14: authorise

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
/**
 * Gains access for the author of an operation to perform changes if they are
 * not already able to. This should generally be called before the given
 * operation has been applied locally, and must be called before it is sent to
 * the output sink. It acceptable, however, for the given operation to have
 * been applied locally already if it does not make any changes to the
 * participant list.
 *
 * @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);
      return authorisation;
    }
  }
  return null;
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:33,代码来源:OpBasedWavelet.java

示例15: setUp

import org.waveprotocol.wave.model.operation.wave.AddParticipant; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  waveletData = WaveletDataUtil.createEmptyWavelet(WAVELET_NAME, ALEX, HashedVersion.unsigned(0),
      0L);
  waveletData.addParticipant(ALEX);

  AddParticipant addBobOp = new AddParticipant(new WaveletOperationContext(ALEX, 0L, 1, V1), BOB);

  addBobOp.apply(waveletData);
  TransformedWaveletDelta delta =
      new TransformedWaveletDelta(ALEX, V1, 0L, Arrays.asList(addBobOp));

  wavelet = WaveletAndDeltas.create(waveletData, DeltaSequence.of(delta));
  addCarolOp = new AddParticipant(new WaveletOperationContext(ALEX, 0L, 1, V2), CAROL);
  removeAlexOp = new RemoveParticipant(new WaveletOperationContext(ALEX, 0L, 1, V3), ALEX);
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:17,代码来源:WaveletAndDeltasTest.java


注:本文中的org.waveprotocol.wave.model.operation.wave.AddParticipant类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。