@Override protected void setUp() throws Exception { super.setUp(); LocalWaveletContainer.Factory localFactory = mock(LocalWaveletContainer.Factory.class); WaveletNotificationSubscriber notifiee = mock(WaveletNotificationSubscriber.class); SettableFuture<ImmutableSet<WaveletId>> lookedupWavelets = SettableFuture.create(); lookedupWavelets.set(ImmutableSet.of(WAVELET_NAME.waveletId)); Wave wave = new Wave(WAVELET_NAME.waveId, lookedupWavelets, notifiee, localFactory, null, WAVELET_NAME.waveId.getDomain()); Map<WaveId, Wave> waves = Maps.newHashMap(); waves.put(WAVELET_NAME.waveId, wave); when(waveMap.getWaves()).thenReturn(waves); ImmutableSet<WaveletId> wavelets = ImmutableSet.of(WAVELET_NAME.waveletId); when(waveMap.lookupWavelets(WAVELET_NAME.waveId)).thenReturn(wavelets); LocalWaveletContainer c = mock(LocalWaveletContainer.class); when(c.hasParticipant(PARTICIPANT)).thenReturn(true); when(waveMap.getLocalWavelet(WAVELET_NAME)).thenReturn(c); }
final AtomicInteger length = new AtomicInteger(0); try { wavelet.requestHistory( CoreWaveletOperationSerializer.deserialize(startVersion), CoreWaveletOperationSerializer.deserialize(endVersion),
if (!wavelet.checkAccessPermission(ParticipantId.of(delta.getAuthor()))) { resultListener.onFailure(FederationErrors.badRequest( delta.getAuthor() + " is not a participant of " + waveletName)); WaveletDeltaRecord submitResult = wavelet.submitRequest(waveletName, signedDelta); TransformedWaveletDelta transformedDelta = submitResult.getTransformedDelta(); LOG.info("Submit result for " + waveletName + " by "
private void submitDeltaToNewWavelet(WaveletName name, ParticipantId user, WaveletOperation... ops) throws Exception { HashedVersion version = V0_HASH_FACTORY.createVersionZero(name); WaveletDelta delta = new WaveletDelta(user, version, Arrays.asList(ops)); addWaveletToUserView(name, user); ProtocolWaveletDelta protoDelta = CoreWaveletOperationSerializer.serialize(delta); // Submitting the request will require the certificate manager to sign the delta. We'll just // leave it unsigned. ProtocolSignedDelta signedProtoDelta = ProtocolSignedDelta.newBuilder().setDelta(protoDelta.toByteString()).build(); LocalWaveletContainer wavelet = waveMap.getOrCreateLocalWavelet(name); wavelet.submitRequest(name, signedProtoDelta); }
@Override public void getDeltaSignerInfo(ByteString signerId, WaveletName waveletName, ProtocolHashedVersion deltaEndVersion, DeltaSignerInfoResponseListener listener) { LocalWaveletContainer wavelet = loadLocalWavelet(waveletName, listener); if (wavelet != null) { HashedVersion endVersion = CoreWaveletOperationSerializer.deserialize(deltaEndVersion); if (wavelet.isDeltaSigner(endVersion, signerId)) { ProtocolSignerInfo signerInfo = certificateManager.retrieveSignerInfo(signerId); if (signerInfo == null) { // Oh no! We are supposed to store it, and we already know they did sign this delta. LOG.severe("No stored signer info for valid getDeltaSignerInfo on " + waveletName); listener.onFailure(FederationErrors.badRequest("Unknown signer info")); } else { listener.onSuccess(signerInfo); } } else { LOG.info("getDeltaSignerInfo was not authrorised for wavelet " + waveletName + ", end version " + deltaEndVersion); listener.onFailure(FederationErrors.badRequest("Not authorised to get signer info")); } } }
private void submitDeltaToNewWavelet(WaveletName name, ParticipantId user, WaveletOperation... ops) throws Exception { HashedVersion version = V0_HASH_FACTORY.createVersionZero(name); WaveletDelta delta = new WaveletDelta(user, version, Arrays.asList(ops)); addWaveletToUserView(name, user); ProtocolWaveletDelta protoDelta = CoreWaveletOperationSerializer.serialize(delta); // Submitting the request will require the certificate manager to sign the delta. We'll just // leave it unsigned. ProtocolSignedDelta signedProtoDelta = ProtocolSignedDelta.newBuilder().setDelta(protoDelta.toByteString()).build(); LocalWaveletContainer wavelet = waveMap.getOrCreateLocalWavelet(name); wavelet.submitRequest(name, signedProtoDelta); }
@Override protected void setUp() throws Exception { super.setUp(); LocalWaveletContainer.Factory localFactory = mock(LocalWaveletContainer.Factory.class); WaveletNotificationSubscriber notifiee = mock(WaveletNotificationSubscriber.class); SettableFuture<ImmutableSet<WaveletId>> lookedupWavelets = SettableFuture.create(); lookedupWavelets.set(ImmutableSet.of(WAVELET_NAME.waveletId)); Wave wave = new Wave(WAVELET_NAME.waveId, lookedupWavelets, notifiee, localFactory, null, WAVELET_NAME.waveId.getDomain()); Map<WaveId, Wave> waves = Maps.newHashMap(); waves.put(WAVELET_NAME.waveId, wave); when(waveMap.getWaves()).thenReturn(waves); ImmutableSet<WaveletId> wavelets = ImmutableSet.of(WAVELET_NAME.waveletId); when(waveMap.lookupWavelets(WAVELET_NAME.waveId)).thenReturn(wavelets); LocalWaveletContainer c = mock(LocalWaveletContainer.class); when(c.hasParticipant(PARTICIPANT)).thenReturn(true); when(waveMap.getLocalWavelet(WAVELET_NAME)).thenReturn(c); }