http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/frontend/WaveViewSubscription.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/frontend/WaveViewSubscription.java b/src/org/waveprotocol/box/server/frontend/WaveViewSubscription.java deleted file mode 100644 index 6281edd..0000000 --- a/src/org/waveprotocol/box/server/frontend/WaveViewSubscription.java +++ /dev/null @@ -1,247 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.Preconditions; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -import org.waveprotocol.box.common.DeltaSequence; -import org.waveprotocol.wave.model.id.IdFilter; -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.operation.wave.TransformedWaveletDelta; -import org.waveprotocol.wave.model.version.HashedVersion; -import org.waveprotocol.wave.util.logging.Log; - -import java.util.Collection; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * A client's subscription to a wave view. - * - * @author [email protected] (Alex North) - */ -final class WaveViewSubscription { - - /** - * State of a wavelet endpoint. - */ - private static final class WaveletChannelState { - /** - * Resulting versions of deltas submitted on this wavelet for which - * the outbound delta has not yet been seen. - */ - public final Collection<Long> submittedEndVersions = Sets.newHashSet(); - /** - * Resulting version of the most recent outbound delta. - */ - public HashedVersion lastVersion = null; - /** - * Whether a submit request is awaiting a response. - */ - public boolean hasOutstandingSubmit = false; - /** - * Outbound deltas held back while a submit is in-flight. - */ - public List<TransformedWaveletDelta> heldBackDeltas = Lists.newLinkedList(); - } - - private static final Log LOG = Log.get(WaveViewSubscription.class); - - private final WaveId waveId; - private final IdFilter waveletIdFilter; - private final ClientFrontend.OpenListener openListener; - private final String channelId; - private final LoadingCache<WaveletId, WaveletChannelState> channels = - CacheBuilder.newBuilder().build(new CacheLoader<WaveletId, WaveletChannelState>() { - @Override - public WaveletChannelState load(WaveletId id) { - return new WaveletChannelState(); - } - }); - - public WaveViewSubscription(WaveId waveId, IdFilter waveletIdFilter, String channelId, - ClientFrontend.OpenListener openListener) { - Preconditions.checkNotNull(waveId, "null wave id"); - Preconditions.checkNotNull(waveletIdFilter, "null filter"); - Preconditions.checkNotNull(openListener, "null listener"); - Preconditions.checkNotNull(channelId, "null channel id"); - - this.waveId = waveId; - this.waveletIdFilter = waveletIdFilter; - this.channelId = channelId; - this.openListener = openListener; - } - - public WaveId getWaveId() { - return waveId; - } - - public ClientFrontend.OpenListener getOpenListener() { - return openListener; - } - - public String getChannelId() { - return channelId; - } - - /** - * Checks whether the subscription includes a wavelet. - */ - public boolean includes(WaveletId waveletId) { - return IdFilter.accepts(waveletIdFilter, waveletId); - } - - /** This client sent a submit request */ - public synchronized void submitRequest(WaveletName waveletName) { - // A given client can only have one outstanding submit per wavelet. - WaveletChannelState state; - try { - state = channels.get(waveletName.waveletId); - } catch (ExecutionException ex) { - throw new RuntimeException(ex); - } - Preconditions.checkState(!state.hasOutstandingSubmit, - "Received overlapping submit requests to subscription %s", this); - LOG.info("Submit oustandinding on channel " + channelId); - state.hasOutstandingSubmit = true; - } - - /** - * A submit response for the given wavelet and version has been sent to this - * client. - */ - public synchronized void submitResponse(WaveletName waveletName, HashedVersion version) { - Preconditions.checkNotNull(version, "Null delta application version"); - WaveletId waveletId = waveletName.waveletId; - WaveletChannelState state; - try { - state = channels.get(waveletId); - } catch (ExecutionException ex) { - throw new RuntimeException(ex); - } - Preconditions.checkState(state.hasOutstandingSubmit); - state.submittedEndVersions.add(version.getVersion()); - state.hasOutstandingSubmit = false; - LOG.info("Submit resolved on channel " + channelId); - - // Forward any queued deltas. - List<TransformedWaveletDelta> filteredDeltas = filterOwnDeltas(state.heldBackDeltas, state); - if (!filteredDeltas.isEmpty()) { - sendUpdate(waveletName, filteredDeltas, null); - } - state.heldBackDeltas.clear(); - } - - /** - * Sends deltas for this subscription (if appropriate). - * - * If the update contains a delta for a wavelet where the delta is actually - * from this client, the delta is dropped. If there's an outstanding submit - * request the delta is queued until the submit finishes. - */ - public synchronized void onUpdate(WaveletName waveletName, DeltaSequence deltas) { - Preconditions.checkArgument(!deltas.isEmpty()); - WaveletChannelState state; - try { - state = channels.get(waveletName.waveletId); - } catch (ExecutionException ex) { - throw new RuntimeException(ex); - } - checkUpdateVersion(waveletName, deltas, state); - state.lastVersion = deltas.getEndVersion(); - if (state.hasOutstandingSubmit) { - state.heldBackDeltas.addAll(deltas); - } else { - List<TransformedWaveletDelta> filteredDeltas = filterOwnDeltas(deltas, state); - if (!filteredDeltas.isEmpty()) { - sendUpdate(waveletName, filteredDeltas, null); - } - } - } - - /** - * Filters any deltas sent by this client from a list of received deltas. - * - * @param deltas received deltas - * @param state channel state - * @return deltas, if none are from this client, or a copy with own client's - * deltas removed - */ - private List<TransformedWaveletDelta> filterOwnDeltas(List<TransformedWaveletDelta> deltas, - WaveletChannelState state) { - List<TransformedWaveletDelta> filteredDeltas = deltas; - if (!state.submittedEndVersions.isEmpty()) { - filteredDeltas = Lists.newArrayList(); - for (TransformedWaveletDelta delta : deltas) { - long deltaEndVersion = delta.getResultingVersion().getVersion(); - if (!state.submittedEndVersions.remove(deltaEndVersion)) { - filteredDeltas.add(delta); - } - } - } - return filteredDeltas; - } - - /** - * Sends a commit notice for this subscription. - */ - public synchronized void onCommit(WaveletName waveletName, HashedVersion committedVersion) { - sendUpdate(waveletName, ImmutableList.<TransformedWaveletDelta>of(), committedVersion); - } - - /** - * Sends an update to the client. - */ - private void sendUpdate(WaveletName waveletName, List<TransformedWaveletDelta> deltas, - HashedVersion committedVersion) { - // Channel id needs to be sent with every message until views can be - // closed, see bug 128. - openListener.onUpdate(waveletName, null, deltas, committedVersion, null, channelId); - } - - /** - * Checks the update targets the next expected version. - */ - private void checkUpdateVersion(WaveletName waveletName, DeltaSequence deltas, - WaveletChannelState state) { - if (state.lastVersion != null) { - long expectedVersion = state.lastVersion.getVersion(); - long targetVersion = deltas.getStartVersion(); - Preconditions.checkState(targetVersion == expectedVersion, - "Subscription expected delta for %s targeting %s, was %s", waveletName, expectedVersion, - targetVersion); - } - } - - @Override - public String toString() { - return "[WaveViewSubscription wave: " + waveId + ", channel: " + channelId + "]"; - } -}
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/frontend/WaveletInfo.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/frontend/WaveletInfo.java b/src/org/waveprotocol/box/server/frontend/WaveletInfo.java deleted file mode 100644 index 79950db..0000000 --- a/src/org/waveprotocol/box/server/frontend/WaveletInfo.java +++ /dev/null @@ -1,286 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.Preconditions; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; -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 org.waveprotocol.wave.util.logging.Log; - -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.ExecutionException; - -/** - * Provides services to manage and track wavelet participants and wavelet - * subscriptions. - * - * @author [email protected] (Yuri Zelikov) - * @see ClientFrontendImpl - */ -public class WaveletInfo { - private static final Log LOG = Log.get(WaveletInfo.class); - - /** 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 LoadingCache<ParticipantId, UserManager> perUser; - private final LoadingCache<WaveId, LoadingCache<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 = - CacheBuilder.newBuilder().build(new CacheLoader<WaveId, LoadingCache<WaveletId, PerWavelet>>() { - @Override - public LoadingCache<WaveletId, PerWavelet> load(final WaveId waveId) { - return CacheBuilder.newBuilder().build(new CacheLoader<WaveletId, PerWavelet>() { - @Override - public PerWavelet load(WaveletId waveletId) { - WaveletName waveletName = WaveletName.of(waveId, waveletId); - return new PerWavelet(waveletName, hashedVersionFactory - .createVersionZero(waveletName)); - } - }); - } - }); - - perUser = CacheBuilder.newBuilder().build(new CacheLoader<ParticipantId, UserManager>() { - @Override - public UserManager load(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; - try { - entrySet = perWavelet.get(subscription.getWaveId()).asMap().entrySet(); - } catch (ExecutionException ex) { - throw new RuntimeException(ex); - } - 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(LOG.isFineLoggable()) { - LOG.fine("frontend initialiseWave(" + waveId +")"); - } - - try { - if (perWavelet.getIfPresent(waveId) == null) { - LoadingCache<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(); - if(LOG.isFineLoggable()) { - LOG.fine("frontend wavelet " + waveletId + " @" + wavelet.getHashedVersion().getVersion()); - } - waveletInfo.explicitParticipants.addAll(wavelet.getParticipants()); - } - } - } - } catch (ExecutionException ex) { - throw new RuntimeException(ex); - } - } - - /** - * 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) { - try { - return perUser.get(participantId); - } catch (ExecutionException ex) { - throw new RuntimeException(ex); - } - } - - /** - * 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) { - try { - return perWavelet.get(name.waveId).get(name.waveletId); - } catch (ExecutionException ex) { - throw new RuntimeException(ex); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/frontend/testing/FakeClientFrontend.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/frontend/testing/FakeClientFrontend.java b/src/org/waveprotocol/box/server/frontend/testing/FakeClientFrontend.java deleted file mode 100644 index d1ac76b..0000000 --- a/src/org/waveprotocol/box/server/frontend/testing/FakeClientFrontend.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.testing; - -import org.waveprotocol.box.common.DeltaSequence; -import org.waveprotocol.box.common.comms.WaveClientRpc; -import org.waveprotocol.box.server.frontend.ClientFrontend; -import org.waveprotocol.box.server.waveserver.WaveBus; -import org.waveprotocol.box.server.waveserver.WaveletProvider.SubmitRequestListener; -import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; -import org.waveprotocol.wave.model.id.IdFilter; -import org.waveprotocol.wave.model.id.WaveId; -import org.waveprotocol.wave.model.id.WaveletName; -import org.waveprotocol.wave.model.version.HashedVersion; -import org.waveprotocol.wave.model.wave.ParticipantId; -import org.waveprotocol.wave.model.wave.data.ReadableWaveletData; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/** - * Implementation of a ClientFrontend which only records requests and will make callbacks when it - * receives wavelet listener events. - */ -public class FakeClientFrontend implements ClientFrontend, WaveBus.Subscriber { - private static class SubmitRecord { - final SubmitRequestListener listener; - final int operations; - SubmitRecord(int operations, SubmitRequestListener listener) { - this.operations = operations; - this.listener = listener; - } - } - - private final Map<WaveId, OpenListener> openListeners = new HashMap<WaveId, OpenListener>(); - - private final Map<WaveletName, SubmitRecord> submitRecords = - new HashMap<WaveletName, SubmitRecord>(); - - public void doSubmitFailed(WaveletName waveletName, String errorMessage) { - SubmitRecord record = submitRecords.remove(waveletName); - if (record != null) { - record.listener.onFailure(errorMessage); - } - } - - /** Reports a submit success with resulting version 0 application timestamp 0 */ - public void doSubmitSuccess(WaveletName waveletName) { - HashedVersion fakeHashedVersion = HashedVersion.of(0, new byte[0]); - doSubmitSuccess(waveletName, fakeHashedVersion, 0); - } - - /** Reports a submit success with the specified resulting version and application timestamp */ - public void doSubmitSuccess(WaveletName waveletName, HashedVersion resultingVersion, - long applicationTimestamp) { - SubmitRecord record = submitRecords.remove(waveletName); - if (record != null) { - record.listener.onSuccess(record.operations, resultingVersion, applicationTimestamp); - } - } - - public void doUpdateFailure(WaveId waveId, String errorMessage) { - OpenListener listener = openListeners.get(waveId); - if (listener != null) { - listener.onFailure(errorMessage); - } - } - - @Override - public void openRequest(ParticipantId participant, WaveId waveId, IdFilter waveletIdFilter, - Collection<WaveClientRpc.WaveletVersion> knownWavelets, OpenListener openListener) { - openListeners.put(waveId, openListener); - } - - @Override - public void submitRequest(ParticipantId loggedInUser, WaveletName waveletName, - ProtocolWaveletDelta delta, String channelId, SubmitRequestListener listener) { - submitRecords.put(waveletName, new SubmitRecord(delta.getOperationCount(), listener)); - } - - @Override - public void waveletCommitted(WaveletName waveletName, HashedVersion version) { - OpenListener listener = openListeners.get(waveletName.waveId); - if (listener != null) { - listener.onUpdate(waveletName, null, DeltaSequence.empty(), version, null, null); - } - } - - @Override - public void waveletUpdate(ReadableWaveletData wavelet, DeltaSequence newDeltas) { - OpenListener listener = openListeners.get(wavelet.getWaveId()); - if (listener != null) { - WaveletName waveletName = WaveletName.of(wavelet.getWaveId(), wavelet.getWaveletId()); - listener.onUpdate(waveletName, null, newDeltas, null, null, null); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/frontend/testing/FakeWaveServer.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/frontend/testing/FakeWaveServer.java b/src/org/waveprotocol/box/server/frontend/testing/FakeWaveServer.java deleted file mode 100644 index 712306d..0000000 --- a/src/org/waveprotocol/box/server/frontend/testing/FakeWaveServer.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.testing; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Maps; - -import org.waveprotocol.box.common.DeltaSequence; -import org.waveprotocol.box.common.comms.WaveClientRpc; -import org.waveprotocol.box.server.common.CoreWaveletOperationSerializer; -import org.waveprotocol.box.server.util.WaveletDataUtil; -import org.waveprotocol.box.server.waveserver.WaveletProvider.SubmitRequestListener; -import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta; -import org.waveprotocol.wave.model.id.IdFilter; -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.operation.wave.TransformedWaveletDelta; -import org.waveprotocol.wave.model.version.HashedVersion; -import org.waveprotocol.wave.model.wave.ParticipantId; -import org.waveprotocol.wave.model.wave.data.WaveletData; - -import java.util.Collection; -import java.util.Map; - -import javax.annotation.Nullable; - -/** - * A fake single-user wave server which only echoes back submitted deltas and - * corresponding index wave deltas. - * - * @author [email protected] (Michael Kuntzman) - */ -public class FakeWaveServer extends FakeClientFrontend { - /** Fake application timestamp for confirming a successful submit. */ - private static final long APP_TIMESTAMP = 0; - - /** Known wavelet states, excluding index wavelets. */ - private final Map<WaveId, Map<WaveletId, WaveletData>> waves = Maps.newHashMap(); - - /** A history of submitted deltas, per wavelet. Does not store generated index deltas. */ - private final ListMultimap<WaveletName, TransformedWaveletDelta> deltas = - ArrayListMultimap.create(); - - /** The current versions of the user's wavelets, including index wavelets */ - private final Map<WaveletName, HashedVersion> versions = Maps.newHashMap(); - - /** The user that is connected to this server */ - private ParticipantId user = null; - - - @Override - public void openRequest(ParticipantId participant, WaveId waveId, IdFilter waveletIdFilter, - Collection<WaveClientRpc.WaveletVersion> knownWavelets, OpenListener openListener) { - if (user == null) { - user = participant; - } else { - Preconditions.checkArgument(participant.equals(user), "Unexpected user"); - } - - super.openRequest(participant, waveId, waveletIdFilter, knownWavelets, openListener); - - Map<WaveletId, WaveletData> wavelets = waves.get(waveId); - if (wavelets != null) { - // Send any deltas we have in this wave to the client, in the order we got - // them. - for (WaveletData wavelet : wavelets.values()) { - WaveletName name = WaveletName.of(wavelet.getWaveId(), wavelet.getWaveletId()); - waveletUpdate(wavelet, DeltaSequence.of(deltas.get(name))); - } - } - } - - @Override - public void submitRequest(ParticipantId loggedInUser, WaveletName waveletName, - ProtocolWaveletDelta delta, @Nullable String channelId, SubmitRequestListener listener) { - super.submitRequest(loggedInUser, waveletName, delta, channelId, listener); - - Map<WaveletId, WaveletData> wavelets = waves.get(waveletName.waveId); - if (wavelets == null) { - wavelets = Maps.newHashMap(); - waves.put(waveletName.waveId, wavelets); - } - - WaveletData wavelet = wavelets.get(waveletName.waveletId); - if (wavelet == null) { - long dummyCreationTime = System.currentTimeMillis(); - wavelet = WaveletDataUtil.createEmptyWavelet( - waveletName, ParticipantId.ofUnsafe(delta.getAuthor()), - HashedVersion.unsigned(0), dummyCreationTime); - wavelets.put(waveletName.waveletId, wavelet); - } - - // Add the delta to the history and update the wavelet's version. - HashedVersion resultingVersion = updateAndGetVersion(waveletName, delta.getOperationCount()); - TransformedWaveletDelta versionedDelta = CoreWaveletOperationSerializer.deserialize(delta, - resultingVersion, APP_TIMESTAMP); - deltas.put(waveletName, versionedDelta); - - // Confirm submit success. - doSubmitSuccess(waveletName, resultingVersion, APP_TIMESTAMP); - // Send an update echoing the submitted delta. Note: the document state is - // ignored. - waveletUpdate(wavelet, DeltaSequence.of(versionedDelta)); - // Send a corresponding update of the index wave. - } - - /** - * Updates and returns the version of a given wavelet. - * - * @param waveletName of the wavelet whose version to update. - * @param operationsCount applied to the wavelet. - * @return the new hashed version of the wavelet. - */ - private HashedVersion updateAndGetVersion(WaveletName waveletName, int operationsCount) { - // Get the current version. - HashedVersion version = versions.get(waveletName); - - // Calculate the new version. - if (version != null) { - version = HashedVersion.unsigned(version.getVersion() + operationsCount); - } else { - version = HashedVersion.unsigned(operationsCount); - } - - // Store and return the new version. - versions.put(waveletName, version); - return version; - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/gxp/AnalyticsFragment.gxp ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/gxp/AnalyticsFragment.gxp b/src/org/waveprotocol/box/server/gxp/AnalyticsFragment.gxp deleted file mode 100644 index 57c40a3..0000000 --- a/src/org/waveprotocol/box/server/gxp/AnalyticsFragment.gxp +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" ?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - - Author: [email protected] (Christian Ohler) - - Analytics page view tracking code. Call in other pages immediately before </head>. ---> -<!DOCTYPE gxp:template SYSTEM - 'http://gxp.googlecode.com/svn/trunk/resources/xhtml.ent'> -<gxp:template name='org.waveprotocol.box.server.gxp.AnalyticsFragment' - xmlns='http://www.w3.org/1999/xhtml' - xmlns:expr='http://google.com/2001/gxp/expressions' - xmlns:call='http://google.com/2001/gxp/call' - xmlns:gxp='http://google.com/2001/gxp'> - - <gxp:param name='account' type='String'/> - <gxp:param name='error' type='String' default='null'/> - - <gxp:if cond='account != null && !account.isEmpty()'> - <script type="text/javascript"> - var _gaq = _gaq || []; - _gaq.push(['_setAccount', <gxp:eval expr='account'/>]); - <gxp:if cond='error != null && !error.isEmpty()'> - _gaq.push(['_setCustomVar', 1, 'error', <gxp:eval expr='error'/>, 3]); - </gxp:if> - _gaq.push(['_trackPageview']); - - (function() { - var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; - var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); - })(); - </script> - </gxp:if> -</gxp:template> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/gxp/AuthenticationPage.gxp ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/gxp/AuthenticationPage.gxp b/src/org/waveprotocol/box/server/gxp/AuthenticationPage.gxp deleted file mode 100644 index d8791d4..0000000 --- a/src/org/waveprotocol/box/server/gxp/AuthenticationPage.gxp +++ /dev/null @@ -1,246 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - - GXP template for the user authentication (login) page. - Generate "ant gen_gxp". - Author: [email protected] (Joseph Gentle) ---> - -<gxp:template name='org.waveprotocol.box.server.gxp.AuthenticationPage' - xmlns='http://www.w3.org/1999/xhtml' - xmlns:expr='http://google.com/2001/gxp/expressions' - xmlns:call='http://google.com/2001/gxp/call' - xmlns:gxp='http://google.com/2001/gxp'> - - <gxp:param name='domain' type='String' /> - <gxp:param name='message' type='String' /> - <gxp:param name='responseType' type='String' /> - <gxp:param name='disableLoginPage' type='Boolean' /> - <gxp:param name='analyticsAccount' type='String'/> - - <html dir="ltr"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <link type="text/css" rel="stylesheet" href="/static/auth.css" /> - <link rel="shortcut icon" href="/static/favicon.ico" /> - <title>Wave in a Box login</title> - <call:AnalyticsFragment expr:account='analyticsAccount'/> - </head> - <body onload="init()"> - <table width="100%" border="0" align="center" cellpadding="0" - cellspacing="0" style="margin-top: 15px"> - <tr> - <td valign="top" style="padding-left: 20px; padding-right: 10px"> - <img src="/static/logo.png" border="0" width="45px" height="30" - align="left" vspace="10" alt='Wave in a Box logo' /></td> - <td width="95%" bgcolor="#ffffff"> - <table width="100%" align="right" cellspacing="0" dir="ltr"> - <tr> - <td class="bubble" - style='font-family: arial; text-align: left; font-weight: bold; padding-right: 10px;' - dir="ltr"><b>Welcome to Wave in a Box </b> @<gxp:eval - expr='domain' /></td> - </tr> - </table> - </td> - </tr> - </table> - <table border="0" width="100%" cellpadding="1" cellspacing="1" - style="margin-top: 10px;"> - <tr> - <td valign="top"> - <table> - <td> - <div style="margin: 0 75px 0 25px;"> - <span style="font-weight: bold; font-size: larger"> - Apache Wave lets you communicate and collaborate in real time - </span> - <p> - <b>Wave is equal parts conversation and document.</b> - People can communicate and work together with richly formatted text, - gadgets, robots and more. - </p> - <p> - <b>Wave is shared.</b> Any participant can reply anywhere in the message, - edit the content and add participants at any point in the process. - </p> - <p> - <b>Wave is live.</b> - With live transmission as you type, participants on a wave can have faster - conversations, see edits and interact with extensions in real-time. - </p> - <div> - <br /> - <a href="/static/wiab_screenshot.jpg" target="_blank" title="Click to enlarge"> - <img src="/static/wiab_screenshot_small.jpg" - style="float: right; align: right; margin: 0 25px 0 35px;" alt="WIAB client."/> - </a> - <p style="width: 60%;"> - <ul> - <li> - Apache Wave is a rich, distributed, real-time collaboration platform, - which allows users to work together in new and exciting ways. - </li> - <li> - <a href="http://incubator.apache.org/wave/" target="_blank"> - "Wave in a Box" (WIAB) - </a> - project is a stand alone wave server and rich web client that can - serve as an Apache Wave reference implementation. - </li> - <li> - This project lets developers and - enterprise users run wave servers and host waves on their own hardware. - And then share those waves with other wave servers. - </li> - </ul> - </p> - </div> - </div> - </td> - </table> - </td> - <td valign="top" align="center" style="padding-right: 30px"> - <gxp:if cond='disableLoginPage == true'> - HTTP Authentication disabled by Administrator. Install and use your certificate instead. - </gxp:if> - <gxp:if cond='disableLoginPage == false'> - <form id="wiab_loginform" action="" method="post"> - <table class="form-noindent" style="padding: 1;" border="0" - align="right"> - <tr> - <td valign="top" style="text-align: center" class="loginBox" - width="260px"> - <table align="center" border="0" cellpadding="1" - cellspacing="0" style="margin: auto;"> - <tr> - <td class="smallfont" colspan="2" align="center">Sign - in - <h2>Wave in a Box</h2> - </td> - </tr> - <tr> - <td colspan="2" align="center"></td> - </tr> - <tr> - <td> - <div align="right"><span class="wiab le lbl"> - Username: </span></div> - </td> - <td><input type="text" name="address" id="address" - size="22" value="" class='wiab le val' /></td> - </tr> - <tr> - <td></td> - <td align="right" - style="color: #444444; font-size: 75%; overflow: hidden; padding-top: 0px" - dir="ltr">@<gxp:eval expr='domain' /></td> - </tr> - <tr> - <td></td> - <td align="right"></td> - </tr> - <tr class="enabled"> - <td align="right"><span class="wiab le lbl"> - Password: </span></td> - <td><input type="password" name="password" - id="password" size="22" class="wiab le val" /></td> - </tr> - <tr> - <td></td> - <td align="center" - style="font-size: 75%; overflow: hidden;" width="40px"><label - id="messageLbl" style="display: none;"></label></td> - </tr> - <tr> - <td></td> - <td align="left"><input type="submit" - class="wiab le button" name="signIn" id="signIn" - value="Sign in" /></td> - </tr> - </table> - <table align="center" border="0" cellpadding="0" - cellspacing="0"> - <tr> - <td colspan="2" height="20" align="center" valign="bottom"> - <div - style="font-size: 12px; margin-left: 15px; margin-top: 5px; background-color: d3d4d6; text-align: center;"> - Don't have a Wave in a Box @<gxp:eval expr='domain' /> - account?</div> - <div><span> <a - style="color: #0066cc; margin-left: 15px;" - href="/auth/register">Register a new account</a> </span></div> - </td> - </tr> - </table> - </td> - </tr> - </table> - </form> - </gxp:if> - </td> - </tr> - </table> - <table width="100%" border="0" align="center" cellpadding="0" - cellspacing="0" style="margin-top: 10px"> - <tr> - <td width="95%" bgcolor="#ffffff"> - <table width="100%" align="right" cellspacing="0" - bgcolor="#C3D9FF" dir="ltr"> - <tr> - <td class="bubble" - style='font-family: arial; text-align: left; font-weight: bold; padding-right: 10px;' - dir="ltr"></td> - </tr> - </table> - </td> - </tr> - </table> - <br /> - <br /> - <script type="text/javascript"> - var RESPONSE_STATUS_NONE = "NONE"; - var RESPONSE_STATUS_FAILED = "FAILED"; - var RESPONSE_STATUS_SUCCESS = "SUCCESS"; - - var message = <gxp:eval expr='message'/>; - var responseType = <gxp:eval expr='responseType'/>; - - function init() { - setFocus(); - handleResponse(responseType, message); - } - - function setFocus() { - document.getElementById("address").focus(); - } - - function handleResponse(responseType, message) { - var messageLbl = document.getElementById("messageLbl"); - if (responseType == RESPONSE_STATUS_NONE) { - messageLbl.style.display = "none"; - } else if (responseType == RESPONSE_STATUS_FAILED) { - messageLbl.style.display = "inline"; - messageLbl.style.color = "red"; - messageLbl.innerHTML = message; - } - } - </script> - </body> - </html> -</gxp:template> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/gxp/OAuthAuthorizationCodePage.gxp ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/gxp/OAuthAuthorizationCodePage.gxp b/src/org/waveprotocol/box/server/gxp/OAuthAuthorizationCodePage.gxp deleted file mode 100644 index 823db91..0000000 --- a/src/org/waveprotocol/box/server/gxp/OAuthAuthorizationCodePage.gxp +++ /dev/null @@ -1,49 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - - GXP template for the OAuth authorization page. - Generate "ant gen_gxp". - Author: [email protected] (A. Kaplanov) ---> - -<gxp:template - name='org.waveprotocol.box.server.gxp.OAuthAuthorizationCodePage' - xmlns='http://www.w3.org/1999/xhtml' xmlns:gxp='http://google.com/2001/gxp'> - - <gxp:param name='code' type='String' /> - - <html> - - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> - <title>Authorization code</title> - <link rel="shortcut icon" href="/static/favicon.ico" /> - </head> - - <body> - <div> - <div>Please copy this code, switch to your application and paste it there:</div> - <input id="code" type="text" readonly="readonly" style="width:500px" onclick="this.focus();this.select();"> - <gxp:attr name='value'> - <gxp:eval expr='code'/> - </gxp:attr> - </input> - </div> - </body> - </html> -</gxp:template> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/gxp/OAuthAuthorizeTokenPage.gxp ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/gxp/OAuthAuthorizeTokenPage.gxp b/src/org/waveprotocol/box/server/gxp/OAuthAuthorizeTokenPage.gxp deleted file mode 100644 index 0dc0950..0000000 --- a/src/org/waveprotocol/box/server/gxp/OAuthAuthorizeTokenPage.gxp +++ /dev/null @@ -1,58 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - - GXP template for the OAuth authorization page. - Generate "ant gen_gxp". - Author: [email protected] (Lennard de Rijk) ---> - -<gxp:template - name='org.waveprotocol.box.server.gxp.OAuthAuthorizeTokenPage' - xmlns='http://www.w3.org/1999/xhtml' xmlns:gxp='http://google.com/2001/gxp'> - - <gxp:param name='user' type='String' /> - <gxp:param name='xsrfToken' type='String' /> - - <html> - - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> - <title>Authorization Required</title> - <link rel="shortcut icon" href="/static/favicon.ico" /> - </head> - - <body> - <div>You logged as <gxp:eval expr='user' />.</div> - A program would like to access your waves and perform operations on your - behalf. - - <form method="post" action=""><input type="hidden" name="token"> - <gxp:attr name='value'> - <gxp:eval expr='xsrfToken' /> - </gxp:attr></input> - <table> - <tr> - <input type="submit" value="Agree" name="agree" /> - <input type="submit" value="Cancel" name="cancel" /> - </tr> - </table> - - </form> - </body> - </html> -</gxp:template> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/gxp/RobotRegistrationPage.gxp ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/gxp/RobotRegistrationPage.gxp b/src/org/waveprotocol/box/server/gxp/RobotRegistrationPage.gxp deleted file mode 100644 index 55dc707..0000000 --- a/src/org/waveprotocol/box/server/gxp/RobotRegistrationPage.gxp +++ /dev/null @@ -1,57 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - - GXP template for the Robot registration page. - Generate with "ant gen_gxp". - Author: [email protected] (Lennard de Rijk) ---> - -<gxp:template - name='org.waveprotocol.box.server.gxp.RobotRegistrationPage' - xmlns='http://www.w3.org/1999/xhtml' - xmlns:expr='http://google.com/2001/gxp/expressions' - xmlns:call='http://google.com/2001/gxp/call' - xmlns:gxp='http://google.com/2001/gxp'> - - <gxp:param name='domain' type='String' /> - <gxp:param name='message' type='String' /> - <gxp:param name='analyticsAccount' type='String'/> - - <html> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> - <title>Robot Registration</title> - <link rel="shortcut icon" href="/static/favicon.ico" /> - <call:AnalyticsFragment expr:account='analyticsAccount'/> - </head> - - <body> - - <gxp:if cond='!message.isEmpty()'> - <b><gxp:eval expr='message'/></b> - </gxp:if> - - <form method="post" action=""> - Robot Username: <input name="username" type="text"/>@<gxp:eval expr='domain'/><br/> - Robot URL: <input name="location" type="text"/><br/> - <input type="submit"/> - </form> - - </body> - </html> -</gxp:template> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/gxp/RobotRegistrationSuccessPage.gxp ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/gxp/RobotRegistrationSuccessPage.gxp b/src/org/waveprotocol/box/server/gxp/RobotRegistrationSuccessPage.gxp deleted file mode 100644 index 295b14f..0000000 --- a/src/org/waveprotocol/box/server/gxp/RobotRegistrationSuccessPage.gxp +++ /dev/null @@ -1,60 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - - GXP template after registration of a robot to show the user the token and token secret to use. - Generate with "ant gen_gxp". - Author: [email protected] (Lennard de Rijk) ---> - -<gxp:template - name='org.waveprotocol.box.server.gxp.RobotRegistrationSuccessPage' - xmlns='http://www.w3.org/1999/xhtml' - xmlns:expr='http://google.com/2001/gxp/expressions' - xmlns:call='http://google.com/2001/gxp/call' - xmlns:gxp='http://google.com/2001/gxp'> - - <gxp:param name='token' type='String' /> - <gxp:param name='tokenSecret' type='String' /> - <gxp:param name='analyticsAccount' type='String'/> - - <html> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> - <title>Robot Successfully Registered</title> - <link rel="shortcut icon" href="/static/favicon.ico" /> - <call:AnalyticsFragment expr:account='analyticsAccount'/> - </head> - - <body> - Your Robot has been successfully registered. Please take note of the consumer - token and token secret to use for the Active API. - - <table> - <tr> - <td><b>Consumer Token</b></td> - <td><gxp:eval expr='token' /></td> - </tr> - <tr> - <td><b>Consumer Token Secret</b></td> - <td><gxp:eval expr='tokenSecret' /></td> - </tr> - </table> - - </body> - </html> -</gxp:template> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/gxp/TopBar.gxp ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/gxp/TopBar.gxp b/src/org/waveprotocol/box/server/gxp/TopBar.gxp deleted file mode 100644 index 0135709..0000000 --- a/src/org/waveprotocol/box/server/gxp/TopBar.gxp +++ /dev/null @@ -1,50 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - - GXP template for the bar up the top of the page showing who you're logged in as. - Author: [email protected] (Joseph Gentle) ---> - -<gxp:template - name='org.waveprotocol.box.server.gxp.TopBar' - xmlns='http://www.w3.org/1999/xhtml' - xmlns:gxp='http://google.com/2001/gxp'> - - <gxp:param name='username' type='String' /> - <gxp:param name='domain' type='String' /> - - <div class="topbar"> - <a href="/"><img src="/static/logo.png" alt="logo" class="logo" /></a> - <div class="title">Wave in a box</div> - <div class="banner" id="banner"></div> - <div class="info"> - <gxp:if cond='username == null'> - Not logged in | - <a href="/auth/register">Register</a> | - <a href="/auth/signin?r=/">Sign In</a> - </gxp:if> - <gxp:if cond='username != null'> - <select id="lang" class="lang" size="1"/> | - <gxp:eval expr='username' /><span class="domain">@<gxp:eval expr='domain' /></span> | - <span id='unsavedStateContainer' style="width: 60px">Saved</span> | - <span id="netstatus" class="offline">Offline</span> | - <a id="signout" href="/auth/signout?r=/">Sign out</a> - </gxp:if> - </div> - </div> -</gxp:template> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/gxp/UserRegistrationPage.gxp ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/gxp/UserRegistrationPage.gxp b/src/org/waveprotocol/box/server/gxp/UserRegistrationPage.gxp deleted file mode 100644 index 90914c7..0000000 --- a/src/org/waveprotocol/box/server/gxp/UserRegistrationPage.gxp +++ /dev/null @@ -1,217 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - - GXP template for the user registration page. - Generate "ant gen_gxp". - Author: [email protected] (Joseph Gentle) ---> - -<gxp:template - name='org.waveprotocol.box.server.gxp.UserRegistrationPage' - xmlns='http://www.w3.org/1999/xhtml' - xmlns:expr='http://google.com/2001/gxp/expressions' - xmlns:call='http://google.com/2001/gxp/call' - xmlns:gxp='http://google.com/2001/gxp'> - - <gxp:param name='domain' type='String' /> - <gxp:param name='message' type='String' /> - <gxp:param name='responseType' type='String' /> - <gxp:param name='disableRegistration' type='Boolean' /> - <gxp:param name='analyticsAccount' type='String'/> - - <html dir="ltr"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <link type="text/css" rel="stylesheet" href="/static/auth.css" /> - <title>Register a New Account - Wave in a Box</title> - <link rel="shortcut icon" href="/static/favicon.ico" /> - <call:AnalyticsFragment expr:account='analyticsAccount'/> - </head> - <body onload="init()"> - <table width="100%" border="0" align="center" cellpadding="0" - cellspacing="0" style="margin-top: 15px"> - <tr> - <td valign="top" style="padding-left: 20px; padding-right: 10px"><img - src="/static/logo.png" border="0" width="45px" height="30" - align="left" vspace="10" alt='Wave in a Box logo' /></td> - <td width="95%"> - <table width="100%" align="right" cellspacing="0" - bgcolor="#C3D9FF" dir="ltr"> - <tr> - <td class="bubble" - style='font-family: arial; text-align: left; font-weight: bold; padding-right: 10px;' - dir="ltr"><span><b>Wave in a Box - Register a New Account - </b> @<gxp:eval expr='domain' /></span></td> - </tr> - </table> - </td> - </tr> - </table> - <table border="0" width="100%" cellpadding="1" cellspacing="1" - style="margin-top: 10px; padding-left: 20px;"> - <tr> - <td align="left" style="height: 20px; padding-right: 10;"><label - id="messageLbl" style="display: none;"></label><span - id="loginLink" style="display: none;"> Please <a - href="/auth/signin">sign in</a>.</span></td> - </tr> - <tr> - <td id="wiab_loginbox_td" valign="top" align="center"> - <gxp:if cond='disableRegistration == true'> - Registration disabled by administrator. - </gxp:if> - <gxp:if cond='disableRegistration == false'> - <form id="regForm" name="regForm" method="post" action=""> - <table align="left"> - <tr> - <td> - <table class="form-noindent" align="center" cellspacing="5" - cellpadding="5" width="100%" border="0"> - <tbody> - <tr> - <td>Username:</td> - <td><input id="address" name="address" - class='wiab le val' tabindex="1" value="" type="text" - style="padding-bottom: 0px;" /></td> - </tr> - <tr> - <td style="padding: 0px; margin: 0px"></td> - <td align="right" - style="color: #444444; font-size: 75%; overflow: hidden; padding-top: 0px; margin-top: 0px; vertical-align: top;" - dir="ltr">@<gxp:eval expr='domain' /></td> - </tr> - <tr> - <td><label for="password">Password:</label></td> - <td><input id="password" name="password" - tabindex="2" autocomplete="OFF" type="password" - class='wiab le val' /></td> - </tr> - <tr> - <td><label for="verifypass">Re-enter - Password: </label></td> - <td><input id="verifypass" name="verifypass" - tabindex="3" autocomplete="OFF" type="password" - class='wiab le val' /></td> - </tr> - </tbody> - </table> - <table> - <tbody> - <tr> - <td align="center"><input class="wiab le button" - value="Cancel" id="buttonStyle" - onclick="history.go(-1)" tabindex="4" type="button" /></td> - <td align="center"><input class="wiab le button" - value="Register" id="buttonStyle" tabindex="5" - type="button" onclick="validate()" /></td> - </tr> - </tbody> - </table> - </td> - </tr> - </table> - </form> - </gxp:if> - </td> - </tr> - </table> - <table width="100%" border="0" align="center" cellpadding="0" - cellspacing="0" style="margin-top: 10px"> - <tr> - <td width="95%"> - <table width="100%" align="right" cellspacing="0" dir="ltr"> - <tr> - <td class="bubble" - style='font-family: arial; text-align: left; font-weight: bold; padding-right: 10px;' - dir="ltr"></td> - </tr> - </table> - </td> - </tr> - </table> - <script type="text/javascript"> - var RESPONSE_STATUS_NONE = "NONE"; - var RESPONSE_STATUS_FAILED = "FAILED"; - var RESPONSE_STATUS_SUCCESS = "SUCCESS"; - - var message = <gxp:eval expr='message'/>; - var responseType = <gxp:eval expr='responseType'/>; - var domain = <gxp:eval expr='domain'/>; - - function init() { - setFocus(); - handleResponse(responseType, message); - } - - function setFocus() { - document.getElementById("address").focus(); - } - - function handleResponse(responseType,message) { - var messageLbl = document.getElementById("messageLbl"); - if(responseType == RESPONSE_STATUS_SUCCESS) { - messageLbl.style.display = "inline"; - messageLbl.style.color = "green"; - messageLbl.innerHTML = message; - document.getElementById("loginLink").style.display = "inline"; - } else if(responseType == RESPONSE_STATUS_FAILED) { - messageLbl.style.display = "inline"; - messageLbl.style.color = "red"; - messageLbl.innerHTML = message; - } - } - - function validate() { - var address = document.getElementById("address").value; - if (address.length < 1) { - message = "Username portion of address cannot be empty"; - responseType = RESPONSE_STATUS_FAILED; - handleResponse(responseType,message); - return; - } - if (!isAlphaNumeric(address)) { - message = "Only letters (a-z), numbers (0-9), and periods (.) are allowed in Username"; - responseType = RESPONSE_STATUS_FAILED; - handleResponse(responseType,message); - return; - } - var password = document.getElementById("password").value; - var verifypass = document.getElementById("verifypass").value; - if((password != null && verifypass != null) && (password != verifypass)) { - message = "Password and password verification do not match!"; - responseType = RESPONSE_STATUS_FAILED; - handleResponse(responseType,message); - return; - } - document.getElementById("address").value = address + "@" + domain; - document.getElementById("regForm").submit(); - } - - function isAlphaNumeric(alphanumericChar) { - if(alphanumericChar.length == 0 || alphanumericChar.search(/[^a-zA-Z0-9\.]/g) != -1 ) - { - return false; - } - else - return true; - } - </script> - </body> - </html> - -</gxp:template> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/gxp/WaveClientPage.gxp ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/gxp/WaveClientPage.gxp b/src/org/waveprotocol/box/server/gxp/WaveClientPage.gxp deleted file mode 100644 index 1ac118c..0000000 --- a/src/org/waveprotocol/box/server/gxp/WaveClientPage.gxp +++ /dev/null @@ -1,153 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - - GXP template for the wave client's landing page. - Generate WaveClientPage.java file in gen/org/... with "ant gen_gxp". - Author: [email protected] (Benjamin Kalman) ---> - -<gxp:template - name='org.waveprotocol.box.server.gxp.WaveClientPage' - xmlns='http://www.w3.org/1999/xhtml' - xmlns:expr='http://google.com/2001/gxp/expressions' - xmlns:call='http://google.com/2001/gxp/call' - xmlns:gxp='http://google.com/2001/gxp'> - - <gxp:import class="org.json.JSONObject" /> - <gxp:import class="org.waveprotocol.box.server.gxp.TopBar" /> - <gxp:param name='sessionJson' type='JSONObject' /> - <gxp:param name='clientFlags' type='JSONObject' /> - <gxp:param name='websocketAddress' type='String' /> - <gxp:param name='topBar' type='HtmlClosure' /> - <gxp:param name='analyticsAccount' type='String'/> - - <!-- Generate doctype to trigger standards mode --> - <html gxp:doctype='transitional'> - <head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> - <title>Wave in a Box</title> - <link rel="shortcut icon" href="/static/favicon.ico" /> - - <!-- Session variables. --> - <script type="text/javascript" language="javascript"> - var __session = <gxp:eval expr='sessionJson' />; - var __websocket_address = <gxp:eval expr='websocketAddress' />; - var __client_flags = <gxp:eval expr='clientFlags' />; - </script> - <style type="text/css"> - /* TODO: Minimize this. */ - body { - /* Override UA defaults. */ - margin: 0; - } - - .topbar { - height: 32px; - /* Line-height set to full height, in order to get vertical text alignment. */ - line-height: 32px; - border-bottom: solid 1px black; - overflow: visible; /* Let banner detail flow over. */ - font-family: "Gill Sans", "Lucida Grande", Verdana, Arial, sans-serif; - font-size: 16px; - - /* Left/right padding to keep content off the screen edges. */ - padding: 0 0.5em; - - /* Z-index to ensure topbar sits on top of the app body. */ - position: relative; - z-index: 1; - } - - .logo { - /* Logo image is 30px high. 1px padding brings it to 32px, which is the topbar height. */ - padding: 1px; - float: left; - } - - .title { - float: left; - margin-left: 0.5em; - } - - .banner { - float: left; - margin-left: 0.5em; - } - - .earth { - /* Earth image is 24px high. 4px padding brings it to 32px, which is the topbar height. */ - padding: 4px; - float: left; - } - - .lang { - height: 19px; - } - - .domain { - color: #606060; - } - - .info { - float: right; - } - - .online { - color: green; - } - - .connecting { - color: #ff7f00; - font-weight: bold; - } - - .offline { - color: red; - font-weight: bold; - } - - </style> - <!-- GWT-compiled JS. --> - <script type="text/javascript" language="javascript"> - var stats = window.__stats = []; - window.__gwtStatsEvent = function(evt) { - stats[stats.length] = evt; - var listener = window.__stats_listener; - listener && listener(evt); - return true; - } - </script> - <script type="text/javascript" language="javascript" src="webclient/webclient.nocache.js" /> - <call:AnalyticsFragment expr:account='analyticsAccount'/> - </head> - - <body> - <!-- GWT history support. --> - <iframe src="javascript:''" id="__gwt_historyFrame" style="position:absolute;width:0;height:0;border:0" /> - <gxp:eval expr='topBar'/> - <div id="app" style="position:absolute; top:33px; right:0px; bottom:0px; left:0px;" /> - <noscript> - <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> - Your web browser must have JavaScript enabled - in order for this application to display correctly. - </div> - </noscript> - </body> - </html> - -</gxp:template> http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/persistence/AccountStore.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/persistence/AccountStore.java b/src/org/waveprotocol/box/server/persistence/AccountStore.java deleted file mode 100644 index 877368d..0000000 --- a/src/org/waveprotocol/box/server/persistence/AccountStore.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.persistence; - -import org.waveprotocol.box.server.account.AccountData; -import org.waveprotocol.wave.model.wave.ParticipantId; - -/** - * Interface for the storage and retrieval of {@link AccountData}s. - * - * @author [email protected] (Lennard de Rijk) - */ -public interface AccountStore { - /** - * Initialize the account store. - * Implementations are expected to validate any configuration values, validate the state of the - * store, and perform an start-up action needed (e.g. load list of accounts into memory, - * establish connection to database, etc...). - * - * @throws PersistenceException - */ - void initializeAccountStore() throws PersistenceException; - - /** - * Returns an {@link AccountData} for the given username or null if not - * exists. - * - * @param id participant id of the requested account. - */ - AccountData getAccount(ParticipantId id) throws PersistenceException; - - /** - * Puts the given {@link AccountData} in the storage, overrides an existing - * account if the username is already in use. - * - * @param account to store. - */ - void putAccount(AccountData account) throws PersistenceException; - - /** - * Removes an account from storage. - * - * @param id the participant id of the account to remove. - */ - void removeAccount(ParticipantId id) throws PersistenceException; -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/persistence/AttachmentStore.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/persistence/AttachmentStore.java b/src/org/waveprotocol/box/server/persistence/AttachmentStore.java deleted file mode 100644 index 3452476..0000000 --- a/src/org/waveprotocol/box/server/persistence/AttachmentStore.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.persistence; - -import org.waveprotocol.box.attachment.AttachmentMetadata; -import org.waveprotocol.wave.media.model.AttachmentId; - -import java.io.IOException; -import java.io.InputStream; - -/** - * An attachment store is a place for storing attachment data. - * - * @author [email protected] (Joseph Gentle) - * @author [email protected] (A. Kaplanov) - */ -public interface AttachmentStore { - - interface AttachmentData { - - public InputStream getInputStream() throws IOException; - - public long getSize(); - } - - /** - * Fetch an attachment metadata. - * - * @param attachmentId - * @return the attachment metadata, or null if the metadata - * does not exist - */ - AttachmentMetadata getMetadata(AttachmentId attachmentId) throws IOException; - - /** - * Fetch an attachment with the specified id. - * - * @param attachmentId - * @return the attachment with the specified id, or null if the attachment - * does not exist - */ - AttachmentData getAttachment(AttachmentId attachmentId) throws IOException; - - /** - * Fetch an attachment thumbnail. - * - * @param attachmentId - * @return the attachment thumbnail - */ - AttachmentData getThumbnail(AttachmentId attachmentId) throws IOException; - - /** - * Store a new attachment with the specified id and data. - * - * @param attachmentId - * @param metaData attachment metadata - * @throws IOException - */ - void storeMetadata(AttachmentId attachmentId, AttachmentMetadata metaData) throws IOException; - - /** - * Store a new attachment with the specified id and data. - * - * @param attachmentId - * @param data A stream which contains the data to be stored - * @throws IOException - */ - void storeAttachment(AttachmentId attachmentId, InputStream data) throws IOException; - - /** - * Store a new attachment with the specified id and data. - * - * @param attachmentId - * @param metaData attachment metadata - * @throws IOException - */ - void storeThumbnail(AttachmentId attachmentId, InputStream dataData) throws IOException; - - /** - * Delete the specified attachment from the store. If the attachment does - * not exist, this has no effect. - * - * The behavior of calling any methods on an open AttachmentData object is - * undefined (implementation-specific). - * - * @param attachmentId - */ - void deleteAttachment(AttachmentId attachmentId); -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/persistence/AttachmentUtil.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/persistence/AttachmentUtil.java b/src/org/waveprotocol/box/server/persistence/AttachmentUtil.java deleted file mode 100644 index c61af57..0000000 --- a/src/org/waveprotocol/box/server/persistence/AttachmentUtil.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.persistence; - -import org.waveprotocol.box.server.persistence.AttachmentStore.AttachmentData; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import org.waveprotocol.wave.model.id.IdConstants; -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.waveref.InvalidWaveRefException; -import org.waveprotocol.wave.model.waveref.WaveRef; -import org.waveprotocol.wave.util.escapers.jvm.JavaWaverefEncoder; -import org.waveprotocol.wave.util.logging.Log; - -/** - * Some utility methods for managing attachment data objects - * - * @author [email protected] (Joseph Gentle) - */ -public class AttachmentUtil { - private static final Log LOG = Log.get(AttachmentUtil.class); - - private AttachmentUtil() {} - - /** - * Write an input stream to an output stream. This will often be useful for - * implementors of AttachmentData.writeDataTo(). - * - * @param source The InputStream to read from - * @param dest The OutputStream to write to - * @throws IOException - */ - public static void writeTo(InputStream source, OutputStream dest) throws IOException { - byte[] buffer = new byte[256]; - int length; - while ((length = source.read(buffer)) != -1) { - dest.write(buffer, 0, length); - } - } - - /** - * Write the attachment out to a string. - * - * @param encoding The string encoding format of the data. Eg, "UTF-8". - * @return A string representation of the attachment data. - * @throws IOException - */ - public static String writeAttachmentDataToString( - AttachmentData data, String encoding) throws IOException { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - writeTo(data.getInputStream(), stream); - return stream.toString(encoding); - } - - /** - * Decode wavelet name. - * - * @param waveRefStr encoded name. - * @return WaveletName object. - */ - public static WaveletName waveRef2WaveletName(String waveRefStr) { - WaveRef waveRef = null; - try { - waveRef = JavaWaverefEncoder.decodeWaveRefFromPath(waveRefStr); - } catch (InvalidWaveRefException e) { - LOG.warning("Cannot decode: " + waveRefStr, e); - return null; - } - - WaveId waveId = waveRef.getWaveId(); - WaveletId waveletId = - waveRef.getWaveletId() != null ? waveRef.getWaveletId() : WaveletId.of(waveId.getDomain(), - IdConstants.CONVERSATION_ROOT_WAVELET); - - WaveletName waveletName = WaveletName.of(waveId, waveletId); - return waveletName; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/persistence/FakePermissiveAccountStore.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/persistence/FakePermissiveAccountStore.java b/src/org/waveprotocol/box/server/persistence/FakePermissiveAccountStore.java deleted file mode 100644 index fcefc18..0000000 --- a/src/org/waveprotocol/box/server/persistence/FakePermissiveAccountStore.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.persistence; - -import org.waveprotocol.box.server.account.AccountData; -import org.waveprotocol.box.server.account.HumanAccountDataImpl; -import org.waveprotocol.box.server.authentication.PasswordDigest; -import org.waveprotocol.wave.model.util.CollectionUtils; -import org.waveprotocol.wave.model.wave.ParticipantId; - -import java.util.Map; - -/** - * An account store which on-the-fly creates a userdata object for any account - * requested. The created user has an empty password. - * - * This class exists to ease development until persistence is in. It will be - * removed once persistence works. - * - * @author [email protected] (Joseph Gentle) - */ -public class FakePermissiveAccountStore implements AccountStore { - Map<ParticipantId, AccountData> accounts = CollectionUtils.newHashMap(); - - @Override - public AccountData getAccount(ParticipantId id) { - AccountData account = accounts.get(id); - - if (account == null && !id.getAddress().startsWith("xxx")) { - account = new HumanAccountDataImpl(id, new PasswordDigest("".toCharArray())); - accounts.put(id, account); - } - - return account; - } - - @Override - public void initializeAccountStore() { - // Nothing to initialize. - } - - @Override - public void putAccount(AccountData account) { - accounts.put(account.getId(), account); - } - - @Override - public void removeAccount(ParticipantId id) { - accounts.remove(id); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/persistence/FileNotFoundPersistenceException.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/persistence/FileNotFoundPersistenceException.java b/src/org/waveprotocol/box/server/persistence/FileNotFoundPersistenceException.java deleted file mode 100644 index c12b8a8..0000000 --- a/src/org/waveprotocol/box/server/persistence/FileNotFoundPersistenceException.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.persistence; - -/** - * {@link Exception} thrown when a persistence operation can not locate a file. - * - * @author [email protected] (Lennard de Rijk) - */ -public class FileNotFoundPersistenceException extends PersistenceException { - - public FileNotFoundPersistenceException() { - super(); - } - - public FileNotFoundPersistenceException(String message, Throwable cause) { - super(message, cause); - } - - public FileNotFoundPersistenceException(String message) { - super(message); - } - - public FileNotFoundPersistenceException(Throwable cause) { - super(cause); - } -} http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/7d8609e7/src/org/waveprotocol/box/server/persistence/PersistenceException.java ---------------------------------------------------------------------- diff --git a/src/org/waveprotocol/box/server/persistence/PersistenceException.java b/src/org/waveprotocol/box/server/persistence/PersistenceException.java deleted file mode 100644 index 57c417e..0000000 --- a/src/org/waveprotocol/box/server/persistence/PersistenceException.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.persistence; - -/** - * {@link Exception} thrown when a persistence operation has failed. - * - * @author [email protected] (Tad Glines) - */ -public class PersistenceException extends Exception { - - public PersistenceException() { - super(); - } - - public PersistenceException(String message, Throwable cause) { - super(message, cause); - } - - public PersistenceException(String message) { - super(message); - } - - public PersistenceException(Throwable cause) { - super(cause); - } -}
