Added:
/src/org/waveprotocol/box/server/frontend/WaveletInfo.java
Modified:
/src/org/waveprotocol/box/server/ServerMain.java
/src/org/waveprotocol/box/server/frontend/ClientFrontendImpl.java
/test/org/waveprotocol/box/server/frontend/ClientFrontendImplTest.java
=======================================
--- /dev/null
+++ /src/org/waveprotocol/box/server/frontend/WaveletInfo.java Tue Sep 6
11:45:34 2011
@@ -0,0 +1,258 @@
+/**
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.waveprotocol.box.server.frontend;
+
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.MapMaker;
+import com.google.common.collect.Sets;
+
+import org.waveprotocol.box.common.DeltaSequence;
+import org.waveprotocol.box.server.waveserver.WaveServerException;
+import org.waveprotocol.box.server.waveserver.WaveletProvider;
+import org.waveprotocol.wave.model.id.WaveId;
+import org.waveprotocol.wave.model.id.WaveletId;
+import org.waveprotocol.wave.model.id.WaveletName;
+import org.waveprotocol.wave.model.version.HashedVersion;
+import org.waveprotocol.wave.model.version.HashedVersionFactory;
+import org.waveprotocol.wave.model.wave.ParticipantId;
+import org.waveprotocol.wave.model.wave.data.ReadableWaveletData;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * Provides services to manage and track wavelet participants and wavelet
+ * subscriptions.
+ *
+ * @author yur...@apache.org (Yuri Zelikov)
+ * @see ClientFrontendImpl
+ */
+public class WaveletInfo {
+
+ /** Information we hold in memory for each wavelet. */
+ private static class PerWavelet {
+ private final HashedVersion version0;
+ private final Set<ParticipantId> explicitParticipants;
+ private final Set<ParticipantId> implicitParticipants;
+ private HashedVersion currentVersion;
+
+ PerWavelet(WaveletName waveletName, HashedVersion hashedVersionZero) {
+ this.explicitParticipants = Sets.newHashSet();
+ this.implicitParticipants = Sets.newHashSet();
+ this.version0 = hashedVersionZero;
+ this.currentVersion = version0;
+ }
+
+ synchronized HashedVersion getCurrentVersion() {
+ return currentVersion;
+ }
+
+ synchronized void setCurrentVersion(HashedVersion version) {
+ this.currentVersion = version;
+ }
+ }
+
+ private final Map<ParticipantId, UserManager> perUser;
+ private final Map<WaveId, Map<WaveletId, PerWavelet>> perWavelet;
+ private final WaveletProvider waveletProvider;
+
+ /**
+ * Creates new instance of {@link WaveletInfo}.
+ *
+ * @param hashFactory the factory for hashed versions.
+ * @param provider the {@link WaveletProvider}.
+ * @return new {@link WaveletInfo} instance.
+ */
+ public static WaveletInfo create(HashedVersionFactory hashFactory,
WaveletProvider provider) {
+ return new WaveletInfo(hashFactory, provider);
+ }
+
+ WaveletInfo(final HashedVersionFactory hashedVersionFactory,
WaveletProvider waveletProvider) {
+ this.waveletProvider = waveletProvider;
+ perWavelet =
+ new MapMaker().makeComputingMap(new Function<WaveId,
Map<WaveletId, PerWavelet>>() {
+ @Override
+ public Map<WaveletId, PerWavelet> apply(final WaveId waveId) {
+ return new MapMaker().makeComputingMap(new Function<WaveletId,
PerWavelet>() {
+ @Override
+ public PerWavelet apply(WaveletId waveletId) {
+ WaveletName waveletName = WaveletName.of(waveId,
waveletId);
+ return new PerWavelet(waveletName, hashedVersionFactory
+ .createVersionZero(waveletName));
+ }
+ });
+ }
+ });
+
+ perUser = new MapMaker().makeComputingMap(new Function<ParticipantId,
UserManager>() {
+ @Override
+ public UserManager apply(ParticipantId from) {
+ return new UserManager();
+ }
+ });
+ }
+
+ /**
+ * Returns all visible wavelets in the wave specified by subscription
which
+ * are also comply with the subscription filter.
+ */
+ public Set<WaveletId> visibleWaveletsFor(WaveViewSubscription
subscription,
+ ParticipantId loggedInUser) throws WaveServerException {
+ Set<WaveletId> visible = Sets.newHashSet();
+ Set<Entry<WaveletId, PerWavelet>> entrySet =
+ perWavelet.get(subscription.getWaveId()).entrySet();
+ for (Entry<WaveletId, PerWavelet> entry : entrySet) {
+ WaveletName waveletName = WaveletName.of(subscription.getWaveId(),
entry.getKey());
+ if (subscription.includes(entry.getKey())
+ && waveletProvider.checkAccessPermission(waveletName,
loggedInUser)) {
+ visible.add(entry.getKey());
+ }
+ }
+ return visible;
+ }
+
+ /**
+ * Initializes front-end information from the wave store, if necessary.
+ */
+ public void initialiseWave(WaveId waveId) throws WaveServerException {
+ if (!perWavelet.containsKey(waveId)) {
+ Map<WaveletId, PerWavelet> wavelets = perWavelet.get(waveId);
+ for (WaveletId waveletId : waveletProvider.getWaveletIds(waveId)) {
+ ReadableWaveletData wavelet =
+ waveletProvider.getSnapshot(WaveletName.of(waveId,
waveletId)).snapshot;
+ // Wavelets is a computing map, so get() initializes the entry.
+ PerWavelet waveletInfo = wavelets.get(waveletId);
+ synchronized (waveletInfo) {
+ waveletInfo.currentVersion = wavelet.getHashedVersion();
+
waveletInfo.explicitParticipants.addAll(wavelet.getParticipants());
+ }
+ }
+ }
+ }
+
+ /**
+ * Synchronizes the wavelet version and ensures that the deltas are
+ * contiguous.
+ *
+ * @param waveletName the wavelet name.
+ * @param newDeltas the new deltas.
+ */
+ public void syncWaveletVersion(WaveletName waveletName, DeltaSequence
newDeltas) {
+ HashedVersion expectedVersion;
+ PerWavelet waveletInfo = getWavelet(waveletName);
+ synchronized (waveletInfo) {
+ expectedVersion = waveletInfo.getCurrentVersion();
+ Preconditions.checkState(expectedVersion.getVersion() ==
newDeltas.getStartVersion(),
+ "Expected deltas starting at version %s, got %s",
expectedVersion,
+ newDeltas.getStartVersion());
+ waveletInfo.setCurrentVersion(newDeltas.getEndVersion());
+ }
+ }
+
+ /**
+ * Returns {@link UserManager} for the participant.
+ */
+ public UserManager getUserManager(ParticipantId participantId) {
+ return perUser.get(participantId);
+ }
+
+ /**
+ * Returns the current wavelet version.
+ */
+ public HashedVersion getCurrentWaveletVersion(WaveletName waveletName) {
+ PerWavelet waveletInfo = getWavelet(waveletName);
+ synchronized (waveletInfo) {
+ return waveletInfo.getCurrentVersion();
+ }
+ }
+
+ /**
+ * @param waveletName the waveletName.
+ * @return the wavelet participants.
+ */
+ public Set<ParticipantId> getWaveletParticipants(WaveletName
waveletName) {
+ PerWavelet waveletInfo = getWavelet(waveletName);
+ synchronized (waveletInfo) {
+ return ImmutableSet.copyOf(waveletInfo.explicitParticipants);
+ }
+ }
+
+ /**
+ * @param waveletName the waveletName.
+ * @return the implicit wavelet participants. An implicit participant is
not a
+ * "strict" participant on the wavelet, but rather only opened
the
+ * wave and listens on updates. For example, anyone can open a
shared
+ * wave without becoming explicit participant.
+ */
+ public Set<ParticipantId> getImplicitWaveletParticipants(WaveletName
waveletName) {
+ PerWavelet waveletInfo = getWavelet(waveletName);
+ synchronized (waveletInfo) {
+ return ImmutableSet.copyOf(waveletInfo.explicitParticipants);
+ }
+ }
+
+ /**
+ * Notifies that the participant was added from the wavelet.
+ *
+ * @param waveletName the wavelet name.
+ * @param participant the participant.
+ */
+ public void notifyAddedExplicitWaveletParticipant(WaveletName
waveletName,
+ ParticipantId participant) {
+ PerWavelet waveletInfo = getWavelet(waveletName);
+ synchronized (waveletInfo) {
+ waveletInfo.explicitParticipants.add(participant);
+ }
+ }
+
+ /**
+ * Notifies that the participant was removed from the wavelet.
+ *
+ * @param waveletName the wavelet name.
+ * @param participant the participant.
+ */
+ public void notifyRemovedExplicitWaveletParticipant(WaveletName
waveletName,
+ ParticipantId participant) {
+ PerWavelet waveletInfo = getWavelet(waveletName);
+ synchronized (waveletInfo) {
+ waveletInfo.explicitParticipants.remove(participant);
+ }
+ }
+
+ /**
+ * Notifies that an implicit participant opened the wave.
+ *
+ * @param waveletName the wavelet name.
+ * @param participant the participant.
+ */
+ public void notifyAddedImplcitParticipant(WaveletName waveletName,
ParticipantId participant) {
+ PerWavelet waveletInfo = getWavelet(waveletName);
+ synchronized (waveletInfo) {
+ if (!waveletInfo.explicitParticipants.contains(participant)) {
+ waveletInfo.implicitParticipants.add(participant);
+ }
+ }
+ }
+
+ private PerWavelet getWavelet(WaveletName name) {
+ return perWavelet.get(name.waveId).get(name.waveletId);
+ }
+}
=======================================
--- /src/org/waveprotocol/box/server/ServerMain.java Thu Aug 4 11:50:54
2011
+++ /src/org/waveprotocol/box/server/ServerMain.java Tue Sep 6 11:45:34
2011
@@ -35,6 +35,7 @@
import org.waveprotocol.box.server.frontend.ClientFrontend;
import org.waveprotocol.box.server.frontend.ClientFrontendImpl;
import org.waveprotocol.box.server.frontend.WaveClientRpcImpl;
+import org.waveprotocol.box.server.frontend.WaveletInfo;
import org.waveprotocol.box.server.persistence.AccountStore;
import org.waveprotocol.box.server.persistence.PersistenceException;
import org.waveprotocol.box.server.persistence.PersistenceModule;
@@ -246,8 +247,9 @@
HashedVersionFactory hashFactory =
injector.getInstance(HashedVersionFactory.class);
WaveletProvider provider = injector.getInstance(WaveletProvider.class);
+ WaveletInfo waveletInfo = WaveletInfo.create(hashFactory, provider);
ClientFrontend frontend =
- ClientFrontendImpl.create(hashFactory, provider, waveBus);
+ ClientFrontendImpl.create(provider, waveBus, waveletInfo);
ProtocolWaveClientRpc.Interface rpcImpl =
WaveClientRpcImpl.create(frontend, false);
server.registerService(ProtocolWaveClientRpc.newReflectiveService(rpcImpl));
=======================================
--- /src/org/waveprotocol/box/server/frontend/ClientFrontendImpl.java Sun
Aug 28 10:51:26 2011
+++ /src/org/waveprotocol/box/server/frontend/ClientFrontendImpl.java Tue
Sep 6 11:45:34 2011
@@ -18,9 +18,6 @@
package org.waveprotocol.box.server.frontend;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.MapMaker;
import com.google.common.collect.Sets;
import org.waveprotocol.box.common.DeltaSequence;
@@ -40,15 +37,11 @@
import org.waveprotocol.wave.model.operation.wave.TransformedWaveletDelta;
import org.waveprotocol.wave.model.operation.wave.WaveletOperation;
import org.waveprotocol.wave.model.version.HashedVersion;
-import org.waveprotocol.wave.model.version.HashedVersionFactory;
import org.waveprotocol.wave.model.wave.ParticipantId;
import org.waveprotocol.wave.model.wave.data.ReadableWaveletData;
import org.waveprotocol.wave.util.logging.Log;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -64,42 +57,19 @@
private final static AtomicInteger channel_counter = new
AtomicInteger(0);
- /** Information we hold in memory for each wavelet. */
- private static class PerWavelet {
- private final HashedVersion version0;
- private final Set<ParticipantId> participants;
- private HashedVersion currentVersion;
-
- PerWavelet(WaveletName waveletName, HashedVersion hashedVersionZero) {
- this.participants =
Collections.synchronizedSet(Sets.<ParticipantId>newHashSet());
- this.version0 = hashedVersionZero;
- this.currentVersion = version0;
- }
-
- synchronized HashedVersion getCurrentVersion() {
- return currentVersion;
- }
-
- synchronized void setCurrentVersion(HashedVersion version) {
- this.currentVersion = version;
- }
- }
-
- @VisibleForTesting final Map<ParticipantId, UserManager> perUser;
- private final Map<WaveId, Map< WaveletId, PerWavelet>> perWavelet;
private final WaveletProvider waveletProvider;
+ private final WaveletInfo waveletInfo;
/**
* Creates a client frontend and subscribes it to the wave bus.
*
* @throws WaveServerException if the server fails during initialization.
*/
- public static ClientFrontendImpl create(HashedVersionFactory
hashedVersionFactory,
- WaveletProvider waveletProvider, WaveBus wavebus)
- throws WaveServerException {
+ public static ClientFrontendImpl create(WaveletProvider waveletProvider,
WaveBus wavebus,
+ WaveletInfo waveletInfo) throws WaveServerException {
ClientFrontendImpl impl =
- new ClientFrontendImpl(hashedVersionFactory, waveletProvider);
+ new ClientFrontendImpl(waveletProvider, waveletInfo);
// Initialize all waves here until a separate index system exists.
impl.initialiseAllWaves();
@@ -110,34 +80,14 @@
/**
* Constructor.
*
- * @param hashedVersionFactory
* @param waveletProvider
* @param waveDomain the server wave domain. It is assumed that the wave
domain is valid.
*/
@VisibleForTesting
- ClientFrontendImpl(final HashedVersionFactory hashedVersionFactory,
- WaveletProvider waveletProvider) {
+ ClientFrontendImpl(
+ WaveletProvider waveletProvider, WaveletInfo waveletInfo) {
this.waveletProvider = waveletProvider;
- final MapMaker mapMaker = new MapMaker();
- perWavelet = mapMaker.makeComputingMap(new Function<WaveId,
Map<WaveletId, PerWavelet>>() {
- @Override
- public Map<WaveletId, PerWavelet> apply(final WaveId waveId) {
- return mapMaker.makeComputingMap(new Function<WaveletId,
PerWavelet>() {
- @Override
- public PerWavelet apply(WaveletId waveletId) {
- WaveletName waveletName = WaveletName.of(waveId, waveletId);
- return new PerWavelet(waveletName,
hashedVersionFactory.createVersionZero(waveletName));
- }
- });
- }
- });
-
- perUser = mapMaker.makeComputingMap(new Function<ParticipantId,
UserManager>() {
- @Override
- public UserManager apply(ParticipantId from) {
- return new UserManager();
- }
- });
+ this.waveletInfo = waveletInfo;
}
@Override
@@ -158,7 +108,7 @@
}
try {
- initialiseWave(waveId);
+ waveletInfo.initialiseWave(waveId);
} catch (WaveServerException e) {
LOG.severe("Wave server failed lookup for " + waveId, e);
openListener.onFailure("Wave server failed to look up wave");
@@ -166,7 +116,7 @@
}
String channelId = generateChannelID();
- UserManager userManager = perUser.get(loggedInUser);
+ UserManager userManager = waveletInfo.getUserManager(loggedInUser);
synchronized (userManager) {
WaveViewSubscription subscription =
userManager.subscribe(waveId, waveletIdFilter, channelId,
openListener);
@@ -174,7 +124,7 @@
Set<WaveletId> waveletIds;
try {
- waveletIds = visibleWaveletsFor(subscription, loggedInUser);
+ waveletIds = waveletInfo.visibleWaveletsFor(subscription,
loggedInUser);
} catch (WaveServerException e1) {
waveletIds = Sets.newHashSet();
LOG.warning("Failed to retrieve visible wavelets for " +
loggedInUser, e1);
@@ -182,7 +132,10 @@
for (WaveletId waveletId : waveletIds) {
WaveletName waveletName = WaveletName.of(waveId, waveletId);
// Ensure that implicit participants will also receive updates.
- participantAddedToWavelet(waveletName, loggedInUser);
+ // TODO (Yuri Z.) If authorizing participant was removed from the
wave
+ // (the shared domain participant), then all implicit participant
that
+ // were authorized should be unsubsrcibed.
+ waveletInfo.notifyAddedImplcitParticipant(waveletName,
loggedInUser);
// The WaveletName by which the waveletProvider knows the relevant
deltas
// TODO(anorth): if the client provides known wavelets, calculate
@@ -243,28 +196,9 @@
ExceptionalIterator<WaveId, WaveServerException> witr =
waveletProvider.getWaveIds();
while (witr.hasNext()) {
WaveId waveId = witr.next();
- initialiseWave(waveId);
+ waveletInfo.initialiseWave(waveId);
}
}
-
- /**
- * Initialises front-end information from the wave store, if necessary.
- */
- private void initialiseWave(WaveId waveId) throws WaveServerException {
- if (!perWavelet.containsKey(waveId)) {
- Map<WaveletId, PerWavelet> wavelets = perWavelet.get(waveId);
- for (WaveletId waveletId : waveletProvider.getWaveletIds(waveId)) {
- ReadableWaveletData wavelet =
- waveletProvider.getSnapshot(WaveletName.of(waveId,
waveletId)).snapshot;
- // Wavelets is a computing map, so get() initialises the entry.
- PerWavelet waveletInfo = wavelets.get(waveletId);
- synchronized (waveletInfo) {
- waveletInfo.currentVersion = wavelet.getHashedVersion();
- waveletInfo.participants.addAll(wavelet.getParticipants());
- }
- }
- }
- }
@Override
public void submitRequest(ParticipantId loggedInUser, final WaveletName
waveletName,
@@ -277,45 +211,38 @@
return;
}
- perUser.get(author).submitRequest(channelId, waveletName);
+ waveletInfo.getUserManager(author).submitRequest(channelId,
waveletName);
waveletProvider.submitRequest(waveletName, delta, new
SubmitRequestListener() {
@Override
public void onSuccess(int operationsApplied,
HashedVersion hashedVersionAfterApplication, long
applicationTimestamp) {
listener.onSuccess(operationsApplied,
hashedVersionAfterApplication,
applicationTimestamp);
- perUser.get(author).submitResponse(channelId, waveletName,
hashedVersionAfterApplication);
+ waveletInfo.getUserManager(author).submitResponse(channelId,
waveletName,
+ hashedVersionAfterApplication);
}
@Override
public void onFailure(String error) {
listener.onFailure(error);
- perUser.get(author).submitResponse(channelId, waveletName, null);
+ waveletInfo.getUserManager(author).submitResponse(channelId,
waveletName, null);
}
});
}
@Override
public void waveletCommitted(WaveletName waveletName, HashedVersion
version) {
- for (ParticipantId participant : getWavelet(waveletName).participants)
{
- perUser.get(participant).onCommit(waveletName, version);
+ for (ParticipantId participant :
waveletInfo.getWaveletParticipants(waveletName)) {
+ waveletInfo.getUserManager(participant).onCommit(waveletName,
version);
}
}
-
- private void participantAddedToWavelet(WaveletName waveletName,
ParticipantId participant) {
- getWavelet(waveletName).participants.add(participant);
- }
-
- private void participantRemovedFromWavelet(WaveletName waveletName,
ParticipantId participant) {
- getWavelet(waveletName).participants.remove(participant);
- }
/**
* Sends new deltas to a particular user on a particular wavelet.
* Updates the participants of the specified wavelet if the participant
was added or removed.
*
- * @param waveletName which the deltas belong to
- * @param participant on the wavelet
+ * @param waveletName the waveletName which the deltas belong to.
+ * @param participant on the wavelet.
* @param newDeltas newly arrived deltas of relevance for participant.
Must
* not be empty.
* @param add whether the participant is added by the first delta.
@@ -324,16 +251,17 @@
private void participantUpdate(WaveletName waveletName, ParticipantId
participant,
DeltaSequence newDeltas, boolean add, boolean remove) {
if (add) {
- participantAddedToWavelet(waveletName, participant);
- }
- perUser.get(participant).onUpdate(waveletName, newDeltas);
+ waveletInfo.notifyAddedExplicitWaveletParticipant(waveletName,
participant);
+ }
+ waveletInfo.getUserManager(participant).onUpdate(waveletName,
newDeltas);
if (remove) {
- participantRemovedFromWavelet(waveletName, participant);
+ waveletInfo.notifyRemovedExplicitWaveletParticipant(waveletName,
participant);
}
}
/**
- * Tracks wavelet versions and ensures that the deltas are contiguous.
+ * Tracks wavelet versions and ensures that the deltas are contiguous.
Updates
+ * wavelet subscribers with new new deltas.
*/
@Override
public void waveletUpdate(ReadableWaveletData wavelet, DeltaSequence
newDeltas) {
@@ -342,71 +270,37 @@
}
WaveletName waveletName = WaveletName.of(wavelet.getWaveId(),
wavelet.getWaveletId());
- PerWavelet waveletInfo = getWavelet(waveletName);
- HashedVersion expectedVersion;
-
- // Reflects the wave participants after applying the new deltas.
- Set<ParticipantId> remainingParticipants;
-
- synchronized (waveletInfo) {
- expectedVersion = waveletInfo.getCurrentVersion();
- Preconditions.checkState(expectedVersion.getVersion() ==
newDeltas.getStartVersion(),
- "Expected deltas starting at version %s, got %s",
- expectedVersion, newDeltas.getStartVersion());
- remainingParticipants = Sets.newHashSet(waveletInfo.participants);
- waveletInfo.setCurrentVersion(newDeltas.getEndVersion());
- }
-
- // Participants added during the course of newDeltas
+ waveletInfo.syncWaveletVersion(waveletName, newDeltas);
+
+ Set<ParticipantId> remainingparticipants =
+ Sets.newHashSet(waveletInfo.getWaveletParticipants(waveletName));
+ // Participants added during the course of newDeltas.
Set<ParticipantId> newParticipants = Sets.newHashSet();
for (int i = 0; i < newDeltas.size(); i++) {
TransformedWaveletDelta delta = newDeltas.get(i);
- // Participants added or removed in this delta get the whole delta
+ // Participants added or removed in this delta get the whole delta.
for (WaveletOperation op : delta) {
if (op instanceof AddParticipant) {
ParticipantId p = ((AddParticipant) op).getParticipantId();
- remainingParticipants.add(p);
+ remainingparticipants.add(p);
newParticipants.add(p);
}
if (op instanceof RemoveParticipant) {
ParticipantId p = ((RemoveParticipant) op).getParticipantId();
- remainingParticipants.remove(p);
- participantUpdate(waveletName, p,
- newDeltas.subList(0, i + 1), newParticipants.remove(p),
true);
+ remainingparticipants.remove(p);
+ participantUpdate(waveletName, p, newDeltas.subList(0, i + 1),
newParticipants.remove(p),
+ true);
}
}
}
// Send out deltas to those who end up being participants at the end
// (either because they already were, or because they were added).
- for (ParticipantId p : remainingParticipants) {
+ for (ParticipantId p : remainingparticipants) {
boolean isNew = newParticipants.contains(p);
participantUpdate(waveletName, p, newDeltas, isNew, false);
}
}
-
- private PerWavelet getWavelet(WaveletName name) {
- return perWavelet.get(name.waveId).get(name.waveletId);
- }
-
- /**
- * Returns all visible wavelets in the wave specified by subscription
which
- * also comply with the subscription filter.
- */
- private Set<WaveletId> visibleWaveletsFor(WaveViewSubscription
subscription,
- ParticipantId loggedInUser) throws WaveServerException {
- Set<WaveletId> visible = Sets.newHashSet();
- Set<Entry<WaveletId, PerWavelet>> entrySet =
- perWavelet.get(subscription.getWaveId()).entrySet();
- for (Entry<WaveletId, PerWavelet> entry : entrySet) {
- WaveletName waveletName = WaveletName.of(subscription.getWaveId(),
entry.getKey());
- if (subscription.includes(entry.getKey())
- && waveletProvider.checkAccessPermission(waveletName,
loggedInUser)) {
- visible.add(entry.getKey());
- }
- }
- return visible;
- }
@VisibleForTesting
static WaveletName createDummyWaveletName(WaveId waveId) {
=======================================
--- /test/org/waveprotocol/box/server/frontend/ClientFrontendImplTest.java
Sun Aug 28 10:51:26 2011
+++ /test/org/waveprotocol/box/server/frontend/ClientFrontendImplTest.java
Tue Sep 6 11:45:34 2011
@@ -112,7 +112,8 @@
waveletProvider = mock(WaveletProvider.class);
when(waveletProvider.getWaveletIds(any(WaveId.class))).thenReturn(ImmutableSet.<WaveletId>of());
- clientFrontend = new ClientFrontendImpl(HASH_FACTORY, waveletProvider);
+ WaveletInfo waveletInfo = WaveletInfo.create(HASH_FACTORY,
waveletProvider);
+ clientFrontend = new ClientFrontendImpl(waveletProvider, waveletInfo);
}
public void testCannotOpenWavesWhenNotLoggedIn() throws Exception {