http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/common/DeltaSequence.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/common/DeltaSequence.java 
b/wave/src/main/java/org/waveprotocol/box/common/DeltaSequence.java
deleted file mode 100644
index df0523f..0000000
--- a/wave/src/main/java/org/waveprotocol/box/common/DeltaSequence.java
+++ /dev/null
@@ -1,134 +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.common;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ForwardingList;
-import com.google.common.collect.ImmutableList;
-
-import org.waveprotocol.wave.model.operation.wave.TransformedWaveletDelta;
-import org.waveprotocol.wave.model.version.HashedVersion;
-
-import java.util.List;
-import java.util.RandomAccess;
-
-/**
- * An immutable sequence of transformed deltas.
- *
- * This class enforces that the deltas are contiguous.
- */
-public final class DeltaSequence extends 
ForwardingList<TransformedWaveletDelta>
-    implements RandomAccess {
-  private final ImmutableList<TransformedWaveletDelta> deltas;
-
-  /**
-   * Creates an empty delta sequence. This sequence will not have an end 
version.
-   */
-  public static DeltaSequence empty() {
-    return new DeltaSequence(ImmutableList.<TransformedWaveletDelta>of(), 
false);
-  }
-
-  /** Creates a delta sequence from contiguous deltas. */
-  public static DeltaSequence of(Iterable<TransformedWaveletDelta> deltas) {
-    return new DeltaSequence(ImmutableList.copyOf(deltas), true);
-  }
-
-  /** Creates a delta sequence from contiguous deltas. */
-  public static DeltaSequence of(TransformedWaveletDelta... deltas) {
-    return new DeltaSequence(ImmutableList.copyOf(deltas), true);
-  }
-
-  /** Creates a delta sequence by concatenating contiguous sequences. */
-  public static DeltaSequence join(DeltaSequence first, DeltaSequence... rest) 
{
-    ImmutableList.Builder<TransformedWaveletDelta> builder = 
ImmutableList.builder();
-    builder.addAll(first);
-    long expectedBeginVersion = first.getEndVersion().getVersion();
-    for (DeltaSequence s : rest) {
-      Preconditions.checkArgument(s.getStartVersion() == expectedBeginVersion,
-          "Sequences are not contiguous, expected start version %s for 
sequence %s",
-          expectedBeginVersion, s);
-      builder.addAll(s);
-      expectedBeginVersion = s.getEndVersion().getVersion();
-    }
-    return new DeltaSequence(builder.build(), false);
-  }
-
-  private DeltaSequence(ImmutableList<TransformedWaveletDelta> deltas, boolean 
checkVersions) {
-    this.deltas = deltas;
-    if (checkVersions) {
-      checkDeltaVersions();
-    }
-  }
-
-  /**
-   * @throws IllegalArgumentException if any of the deltas' end version 
disagrees
-   *         with the next delta's version.
-   */
-  private void checkDeltaVersions() {
-    for (int i = 0; i < deltas.size(); i++) {
-      TransformedWaveletDelta delta = deltas.get(i);
-      long deltaEndVersion = delta.getResultingVersion().getVersion();
-      if (i + 1 < deltas.size()) {
-        long nextVersion = deltas.get(i + 1).getAppliedAtVersion();
-        Preconditions.checkArgument(deltaEndVersion == nextVersion,
-            "Delta %s / %s ends at version %s, next begins at %s",
-            i + 1, deltas.size(), deltaEndVersion, nextVersion);
-      }
-    }
-  }
-
-  @Override
-  protected List<TransformedWaveletDelta> delegate() {
-    return deltas;
-  }
-
-  @Override
-  public DeltaSequence subList(int start, int end) {
-    return new DeltaSequence(deltas.subList(start, end), false);
-  }
-
-  /**
-   * Gets the version at which the first delta applied.
-   *
-   * @precondition the sequence is non-empty
-   */
-  public long getStartVersion() {
-    Preconditions.checkState(!deltas.isEmpty(), "Empty delta sequence has no 
start version");
-    return deltas.get(0).getAppliedAtVersion();
-  }
-
-  /**
-   * Gets the resulting version of this sequence.
-   *
-   * @precondition the sequence is non-empty
-   */
-  public HashedVersion getEndVersion() {
-    Preconditions.checkState(!deltas.isEmpty(), "Empty delta sequence has no 
end version");
-    return deltas.get(deltas.size() - 1).getResultingVersion();
-  }
-
-  @Override
-  public String toString() {
-    if (isEmpty()) {
-      return "[DeltaSequence empty]";
-    }
-    return "[DeltaSequence " + deltas.size() + " deltas, v " + 
getStartVersion() + " -> "
-        + getEndVersion() + ": " + deltas + "]";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/common/DocumentConstants.java
----------------------------------------------------------------------
diff --git 
a/wave/src/main/java/org/waveprotocol/box/common/DocumentConstants.java 
b/wave/src/main/java/org/waveprotocol/box/common/DocumentConstants.java
deleted file mode 100644
index a3d6b01..0000000
--- a/wave/src/main/java/org/waveprotocol/box/common/DocumentConstants.java
+++ /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.
- */
-
-package org.waveprotocol.box.common;
-
-/**
- * Constants relating to the document model.
- *
- * TODO: put in org.waveprotocol.wave.document or similar
- */
-public class DocumentConstants {
-
-  public static final String BLIP = "blip";
-
-  public static final String BLIP_ID = "id";
-
-  public static final String BODY = "body";
-
-  public static final String CONTRIBUTOR = "contributor";
-
-  public static final String CONTRIBUTOR_NAME = "name";
-
-  public static final String CONVERSATION = "conversation";
-
-  public static final String LINE = "line";
-
-  public static final String MANIFEST_DOCUMENT_ID = "conversation";
-
-  public static final String THREAD = "thread";
-
-  private DocumentConstants() {
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/common/ExceptionalIterator.java
----------------------------------------------------------------------
diff --git 
a/wave/src/main/java/org/waveprotocol/box/common/ExceptionalIterator.java 
b/wave/src/main/java/org/waveprotocol/box/common/ExceptionalIterator.java
deleted file mode 100644
index 773361f..0000000
--- a/wave/src/main/java/org/waveprotocol/box/common/ExceptionalIterator.java
+++ /dev/null
@@ -1,146 +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.common;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * A iterator which may throw a checked exception from query methods.
- *
- * If an exception is thrown the iterator becomes invalid.
- *
- * @author [email protected] (Alex North)
- * @param <T> type iterated over
- * @param <E> type of the exception thrown on failure
- */
-public interface ExceptionalIterator<T, E extends Exception> {
-  /**
-   * An empty iterator.
-   */
-  final static class Empty {
-    /** Creates an empty iterator. */
-    public static <T, E extends Exception> ExceptionalIterator<T, E> create() {
-      return new ExceptionalIterator<T, E>() {
-        @Override
-        public boolean hasNext() {
-          return false;
-        }
-
-        @Override
-        public T next() {
-          throw new NoSuchElementException();
-        }
-      };
-    }
-    private Empty() {}
-  }
-
-  /**
-   * An exceptional iterator which wraps an ordinary iterator.
-   */
-  final static class FromIterator {
-    /**
-     * Creates an iterator which adapts an ordinary iterator. It never throws
-     * {@code E}.
-     *
-     * @param it iterator to adapt
-     */
-    public static <T, E extends Exception> ExceptionalIterator<T, E> 
create(final Iterator<T> it) {
-      return new ExceptionalIterator<T, E>() {
-        @Override
-        public boolean hasNext() {
-          return it.hasNext();
-        }
-
-        @Override
-        public T next() {
-          return it.next();
-        }
-      };
-    }
-
-    /**
-     * Creates an iterator which adapts an ordinary iterator but throws an
-     * exception when the adapted iterator finishes, when hasNext() returns
-     * false.
-     *
-     * @param it iterator to adapt
-     * @param exception exception to throw when the iterator is finished
-     */
-    public static <T, E extends Exception> ExceptionalIterator<T, E> 
create(final Iterator<T> it,
-        final E exception) {
-      return new ExceptionalIterator<T, E>() {
-        @Override
-        public boolean hasNext() throws E {
-          if (it.hasNext()) {
-            return true;
-          }
-          throw exception;
-        }
-
-        @Override
-        public T next() {
-          return it.next();
-        }
-      };
-    }
-
-    private FromIterator() {}
-  }
-
-  /**
-   * An exceptional iterator which always throws an exception.
-   */
-  final static class Failing {
-    /**
-     * Creates an iterator which just throws an exception.
-     *
-     * @param exception exception to throw
-     */
-    public static <T, E extends Exception> ExceptionalIterator<T, E> 
create(final E exception) {
-      return new ExceptionalIterator<T, E>() {
-        @Override
-        public boolean hasNext() throws E {
-          throw exception;
-        }
-
-        @Override
-        public T next() throws E {
-          throw exception;
-        }
-      };
-    }
-  }
-
-  /**
-   * Returns true if the iteration has more elements.
-   *
-   * @throws E if an underlying query fails
-   */
-  boolean hasNext() throws E;
-
-  /**
-   * Returns the next element in the iteration.
-   *
-   * @throws E if an underlying query fails
-   */
-  T next() throws E;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/common/ListReceiver.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/common/ListReceiver.java 
b/wave/src/main/java/org/waveprotocol/box/common/ListReceiver.java
deleted file mode 100644
index 347fbe5..0000000
--- a/wave/src/main/java/org/waveprotocol/box/common/ListReceiver.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.waveprotocol.box.common;
-/*
- *
- * 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.
- *
-*/
-
-
-import java.util.ArrayList;
-
-/**
- * Callback interface to sequential reception objects to list.
- *
- * @author [email protected] (Andrew Kaplanov)
- */
-public class ListReceiver<T> extends ArrayList<T> implements Receiver<T> {
-
-  @Override
-  public boolean put(T obj) {
-    add(obj);
-    return true;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/common/Receiver.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/common/Receiver.java 
b/wave/src/main/java/org/waveprotocol/box/common/Receiver.java
deleted file mode 100644
index a90c48f..0000000
--- a/wave/src/main/java/org/waveprotocol/box/common/Receiver.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.waveprotocol.box.common;
-/*
- *
- * 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.
- *
-*/
-
-
-/**
- * Callback interface to sequential reception objects.
- *
- * @author [email protected] (Andrew Kaplanov)
- */
-public interface Receiver<T> {
-  /**
-   * Receives objects.
-   *
-   * @param the object.
-   * @return true to continue, false to cancel transmission.
-   */
-  public boolean put(T obj);
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/common/SessionConstants.java
----------------------------------------------------------------------
diff --git 
a/wave/src/main/java/org/waveprotocol/box/common/SessionConstants.java 
b/wave/src/main/java/org/waveprotocol/box/common/SessionConstants.java
deleted file mode 100644
index 9fab195..0000000
--- a/wave/src/main/java/org/waveprotocol/box/common/SessionConstants.java
+++ /dev/null
@@ -1,45 +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.common;
-
-/**
- * Session constants for FedOne clients.
- *
- * @author [email protected] (Benjamin Kalman)
- */
-public interface SessionConstants {
-
-  /**
-   * The domain the wave server serves waves for.
-   */
-  public final static String DOMAIN = "domain";
-
-  /**
-   * The user's logged in address.
-   */
-  public final static String ADDRESS = "address";
-
-  /**
-   * A globally unique id that the client can use to seed unique ids of the 
session.
-   * It has no relationship with the application session or http session or 
authentication, and
-   * is not guaranteed to be cryptographically strong.
-   */
-  public final static String ID_SEED = "id";
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/common/Snippets.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/common/Snippets.java 
b/wave/src/main/java/org/waveprotocol/box/common/Snippets.java
deleted file mode 100644
index 52a9323..0000000
--- a/wave/src/main/java/org/waveprotocol/box/common/Snippets.java
+++ /dev/null
@@ -1,226 +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.common;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Lists;
-
-import org.waveprotocol.wave.model.document.operation.AnnotationBoundaryMap;
-import org.waveprotocol.wave.model.document.operation.Attributes;
-import org.waveprotocol.wave.model.document.operation.AttributesUpdate;
-import org.waveprotocol.wave.model.document.operation.DocInitializationCursor;
-import org.waveprotocol.wave.model.document.operation.DocOp;
-import org.waveprotocol.wave.model.document.operation.DocOpCursor;
-import 
org.waveprotocol.wave.model.document.operation.impl.InitializationCursorAdapter;
-import org.waveprotocol.wave.model.wave.data.ReadableBlipData;
-import org.waveprotocol.wave.model.wave.data.ReadableWaveletData;
-import org.waveprotocol.wave.model.wave.data.WaveletData;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Utility methods for rendering snippets.
- *
- * @author [email protected] (Alex North)
- */
-public final class Snippets {
-
-  private final static Function<StringBuilder, Void> DEFAULT_LINE_MODIFIER =
-      new Function<StringBuilder, Void>() {
-
-    @Override
-    public Void apply(StringBuilder resultBuilder) {
-      resultBuilder.append(" ");
-      return null;
-    }
-  };
-  public static final int DIGEST_SNIPPET_LENGTH = 140;
-
-  /**
-   * Concatenates all of the text for the given documents in
-   * {@link WaveletData}.
-   *
-   * @param wavelet the wavelet for which to concatenate the documents.
-   * @return A String containing the characters from all documents.
-   */
-  public static String collateTextForWavelet(ReadableWaveletData wavelet) {
-    List<ReadableBlipData> documents = new ArrayList<ReadableBlipData>();
-    for (String documentId : wavelet.getDocumentIds()) {
-      documents.add(wavelet.getDocument(documentId));
-    }
-    return collateTextForDocuments(documents);
-  }
-
-  /**
-   * Concatenates all of the text of the specified blips into a single String.
-   *
-   * @param documents the documents to concatenate.
-   * @return A String containing the characters from all documents.
-   */
-  public static String collateTextForDocuments(Iterable<? extends 
ReadableBlipData> documents) {
-    ArrayList<DocOp> docOps = new ArrayList<DocOp>();
-    for (ReadableBlipData blipData : documents) {
-      docOps.add(blipData.getContent().asOperation());
-    }
-    return collateTextForOps(docOps);
-  }
-
-  /**
-   * Concatenates all of the text of the specified docops into a single String.
-   *
-   * @param documentops the document operations to concatenate.
-   * @param func the function that will be applied on result when
-   *        DocumentConstants.LINE event is be encountered during parsing.
-   * @return A String containing the characters from the operations.
-   */
-  public static String collateTextForOps(Iterable<? extends DocOp> documentops,
-      final Function<StringBuilder, Void> func) {
-    final StringBuilder resultBuilder = new StringBuilder();
-    for (DocOp docOp : documentops) {
-      docOp.apply(InitializationCursorAdapter.adapt(new DocOpCursor() {
-        @Override
-        public void characters(String s) {
-          resultBuilder.append(s);
-        }
-
-        @Override
-        public void annotationBoundary(AnnotationBoundaryMap map) {
-        }
-
-        @Override
-        public void elementStart(String type, Attributes attrs) {
-          if (type.equals(DocumentConstants.LINE)) {
-            func.apply(resultBuilder);
-          }
-        }
-
-        @Override
-        public void elementEnd() {
-        }
-
-        @Override
-        public void retain(int itemCount) {
-        }
-
-        @Override
-        public void deleteCharacters(String chars) {
-        }
-
-        @Override
-        public void deleteElementStart(String type, Attributes attrs) {
-        }
-
-        @Override
-        public void deleteElementEnd() {
-        }
-
-        @Override
-        public void replaceAttributes(Attributes oldAttrs, Attributes 
newAttrs) {
-        }
-
-        @Override
-        public void updateAttributes(AttributesUpdate attrUpdate) {
-        }
-      }));
-    }
-    return resultBuilder.toString().trim();
-  }
-
-  /**
-   * Concatenates all of the text of the specified docops into a single String.
-   *
-   * @param documentops the document operations to concatenate.
-   * @return A String containing the characters from the operations.
-   */
-  public static String collateTextForOps(Iterable<? extends DocOp> 
documentops) {
-    return collateTextForOps(documentops, DEFAULT_LINE_MODIFIER);
-  }
-
-  /**
-   * Returns a snippet or null.
-   */
-  public static String renderSnippet(final ReadableWaveletData wavelet,
-      final int maxSnippetLength) {
-    final StringBuilder sb = new StringBuilder();
-    Set<String> docsIds = wavelet.getDocumentIds();
-    long newestLmt = -1;
-    ReadableBlipData newestBlip = null;
-    for (String docId : docsIds) {
-      ReadableBlipData blip = wavelet.getDocument(docId);
-      long currentLmt = blip.getLastModifiedTime();
-      if (currentLmt > newestLmt) {
-        newestLmt = currentLmt;
-        newestBlip = blip;
-      }
-    }
-    if (newestBlip == null) {
-      // Render whatever data we have and hope its good enough
-      sb.append(collateTextForWavelet(wavelet));
-    } else {
-      DocOp docOp = newestBlip.getContent().asOperation();
-      sb.append(collateTextForOps(Lists.newArrayList(docOp)));
-      sb.append(" ");
-      docOp.apply(InitializationCursorAdapter.adapt(new 
DocInitializationCursor() {
-        @Override
-        public void annotationBoundary(AnnotationBoundaryMap map) {
-        }
-
-        @Override
-        public void characters(String chars) {
-          // No chars in the conversation manifest
-        }
-
-        @Override
-        public void elementEnd() {
-        }
-
-        @Override
-        public void elementStart(String type, Attributes attrs) {
-          if (sb.length() >= maxSnippetLength) {
-            return;
-          }
-
-          if (DocumentConstants.BLIP.equals(type)) {
-            String blipId = attrs.get(DocumentConstants.BLIP_ID);
-            if (blipId != null) {
-              ReadableBlipData document = wavelet.getDocument(blipId);
-              if (document == null) {
-                // We see this when a blip has been deleted
-                return;
-              }
-              sb.append(collateTextForDocuments(Arrays.asList(document)));
-              sb.append(" ");
-            }
-          }
-        }
-      }));
-    }
-    if (sb.length() > maxSnippetLength) {
-      return sb.substring(0, maxSnippetLength);
-    }
-    return sb.toString();
-  }
-
-  private Snippets() {
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/expimp/Console.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/expimp/Console.java 
b/wave/src/main/java/org/waveprotocol/box/expimp/Console.java
deleted file mode 100644
index 381a41b..0000000
--- a/wave/src/main/java/org/waveprotocol/box/expimp/Console.java
+++ /dev/null
@@ -1,64 +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.expimp;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Input/output for Export/Import utilities.
- *
- * @author [email protected] (Andrew Kaplanov)
- */
-public class Console {
-
-  private static final Logger log = Logger.getLogger("ExportImport");
-
-  public static void print(String line) {
-    System.out.print(line);
-  }
-
-  public static void println(String line) {
-    System.out.println(line);
-  }
-
-  public static void println() {
-    System.out.println();
-  }
-
-  public static void error(String error) {
-    System.err.println();
-    System.err.println(error);
-  }
-
-  public static void error(String error, Exception ex) {
-    log.log(Level.SEVERE, error, ex);
-    System.err.println();
-    System.err.println(error);
-    System.err.println(ex.toString());
-  }
-
-  public static String readLine() throws IOException {
-    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
-    return in.readLine();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/expimp/DeltaParser.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/expimp/DeltaParser.java 
b/wave/src/main/java/org/waveprotocol/box/expimp/DeltaParser.java
deleted file mode 100644
index b9db5aa..0000000
--- a/wave/src/main/java/org/waveprotocol/box/expimp/DeltaParser.java
+++ /dev/null
@@ -1,84 +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.expimp;
-
-import com.google.protobuf.InvalidProtocolBufferException;
-import 
org.waveprotocol.wave.federation.Proto.ProtocolDocumentOperation.Component;
-import 
org.waveprotocol.wave.federation.Proto.ProtocolDocumentOperation.Component.ElementStart;
-import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta;
-import org.waveprotocol.wave.federation.Proto.ProtocolWaveletOperation;
-import 
org.waveprotocol.wave.federation.Proto.ProtocolWaveletOperation.MutateDocument;
-import org.waveprotocol.wave.media.model.AttachmentId;
-import org.waveprotocol.wave.model.id.InvalidIdException;
-import org.waveprotocol.wave.model.image.ImageConstants;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Raw deltas parser.
- *
- * @author [email protected] (Andrew Kaplanov)
- */
-public class DeltaParser {
-
-  private DeltaParser() {
-  }
-
-  public static List<ProtocolWaveletDelta> parseDeltas(List<byte[]> rawDeltas)
-      throws InvalidProtocolBufferException {
-    List<ProtocolWaveletDelta> deltas = new ArrayList<ProtocolWaveletDelta>();
-    for (byte[] delta : rawDeltas) {
-      deltas.add(ProtocolWaveletDelta.parseFrom(delta));
-    }
-    return deltas;
-  }
-
-  /**
-   * Extract attachment ids from operations.
-   */
-  public static Set<AttachmentId> getAttachemntIds(ProtocolWaveletDelta delta) 
{
-    Set<AttachmentId> ids = new HashSet<AttachmentId>();
-    for (int i=0; i < delta.getOperationCount(); i++) {
-      ProtocolWaveletOperation op = delta.getOperation(i);
-      if (op.hasMutateDocument()) {
-        MutateDocument doc = op.getMutateDocument();
-        for (int c = 0; c < doc.getDocumentOperation().getComponentCount(); 
c++) {
-          Component comp = doc.getDocumentOperation().getComponent(c);
-          ElementStart start = comp.getElementStart();
-          if (ImageConstants.TAGNAME.equals(start.getType())) {
-            for (int a=0; a < start.getAttributeCount(); a++) {
-              Component.KeyValuePair attr = start.getAttribute(a);
-              if (ImageConstants.ATTACHMENT_ATTRIBUTE.equals(attr.getKey())) {
-                try {
-                  ids.add(AttachmentId.deserialise(attr.getValue()));
-                } catch (InvalidIdException ex) {
-                  Console.error("Invalid attachment Id " + attr.getValue(), 
ex);
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-    return ids;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/expimp/DomainConverter.java
----------------------------------------------------------------------
diff --git 
a/wave/src/main/java/org/waveprotocol/box/expimp/DomainConverter.java 
b/wave/src/main/java/org/waveprotocol/box/expimp/DomainConverter.java
deleted file mode 100644
index 76a6911..0000000
--- a/wave/src/main/java/org/waveprotocol/box/expimp/DomainConverter.java
+++ /dev/null
@@ -1,150 +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.expimp;
-
-import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta;
-import org.waveprotocol.wave.model.wave.InvalidParticipantAddress;
-import org.waveprotocol.wave.model.wave.ParticipantId;
-import org.waveprotocol.wave.federation.Proto.ProtocolWaveletOperation;
-import org.waveprotocol.wave.model.id.IdUtil;
-import org.waveprotocol.wave.model.id.WaveId;
-import org.waveprotocol.wave.model.id.WaveletId;
-
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Converts domain names in exported data.
- *
- * @author [email protected] (Andrew Kaplanov)
- */
-public class DomainConverter {
-
-  /**
-   * Replaces domain of WaveId.
-   *
-   * @param waveId source waveId
-   * @param waveDomain target wave domain
-   * @return wave id with waveDomain if waveDomain is not null, otherwise 
source wave id.
-   */
-  public static WaveId convertWaveId(WaveId waveId, String waveDomain) {
-    if (waveDomain != null) {
-      return WaveId.of(waveDomain, waveId.getId());
-    }
-    return waveId;
-  }
-
-  /**
-   * Replaces domain of WaveletId.
-   *
-   * @param waveletId source waveletId
-   * @param waveDomain target wave domain
-   * @return wavelet id with waveDomain if waveDomain is not null, otherwise 
source wavelet id.
-   */
-  public static WaveletId convertWaveletId(WaveletId waveletId, String 
waveDomain) throws InvalidParticipantAddress {
-    if (waveDomain != null) {
-      if (IdUtil.isUserDataWavelet(waveletId)) {
-        String sourceParticipant = IdUtil.getUserDataWaveletAddress(waveletId);
-        String targetParticipant = convertParticipantId(sourceParticipant, 
waveDomain).toString();
-        String targetWaveletId = IdUtil.join(IdUtil.USER_DATA_WAVELET_PREFIX, 
targetParticipant);
-        return WaveletId.of(waveDomain, targetWaveletId);
-      }
-      return WaveletId.of(waveDomain, waveletId.getId());
-    }
-    return waveletId;
-  }
-
-  /**
-   * Replaces domain in deltas for Add/Remove participant operations.
-   *
-   * @param delta source delta
-   * @param waveDomain target wave domain
-   * @return delta for waveDomain if WaveDoamin is not null, otherwise source 
delta.
-   * @throws InvalidParticipantAddress if there is a problem with 
deserialization of participant id.
-   */
-  public static ProtocolWaveletDelta convertDelta(ProtocolWaveletDelta delta,
-      String waveDomain) throws InvalidParticipantAddress {
-    if (waveDomain != null) {
-      ProtocolWaveletDelta.Builder newDelta = 
ProtocolWaveletDelta.newBuilder(delta);
-      ParticipantId author = convertParticipantId(delta.getAuthor(), 
waveDomain);
-      newDelta.setAuthor(author.getAddress());
-      for (int i = 0; i < delta.getOperationCount(); i++) {
-        ProtocolWaveletOperation op = delta.getOperation(i);
-        ProtocolWaveletOperation.Builder newOp = 
ProtocolWaveletOperation.newBuilder(op);
-        if (op.hasAddParticipant()) {
-          convertAddParticipantOperation(newOp, op, waveDomain);
-        } else if (op.hasRemoveParticipant()) {
-          convertRemoveParticipantOperation(newOp, op, waveDomain);
-        }
-        // TODO(user) release convert for other operations.
-        newDelta.setOperation(i, newOp);
-      }
-      return newDelta.build();
-    } else {
-      return delta;
-    }
-  }
-
-  /**
-   * Converts all history deltas.
-   *
-   * @param deltas source deltas
-   * @param waveDomain target wave domain
-   * @return deltas for waveDomain if WaveDoamin is not null, otherwise source 
deltas.
-   * @throws InvalidParticipantAddress if there is a problem with 
deserialization of participant id.
-   */
-  public static List<ProtocolWaveletDelta> 
convertDeltas(List<ProtocolWaveletDelta> deltas,
-      String waveDomain) throws InvalidParticipantAddress {
-    if (waveDomain != null) {
-      List<ProtocolWaveletDelta> targetDeltas = new 
LinkedList<ProtocolWaveletDelta>();
-      for (ProtocolWaveletDelta delta : deltas) {
-        targetDeltas.add(DomainConverter.convertDelta(delta, waveDomain));
-      }
-      return targetDeltas;
-    } else {
-      return deltas;
-    }
-  }
-
-  /**
-   * Converts adding participant operation.
-   */
-  private static void 
convertAddParticipantOperation(ProtocolWaveletOperation.Builder newOperation,
-      ProtocolWaveletOperation operation, String domain) throws 
InvalidParticipantAddress {
-    ParticipantId participant = 
convertParticipantId(operation.getAddParticipant(), domain);
-    newOperation.setAddParticipant(participant.getAddress());
-  }
-
-  /**
-   * Converts removal participant operation.
-   */
-  private static void 
convertRemoveParticipantOperation(ProtocolWaveletOperation.Builder newOperation,
-      ProtocolWaveletOperation operation, String domain) throws 
InvalidParticipantAddress {
-    ParticipantId participant = 
convertParticipantId(operation.getRemoveParticipant(), domain);
-    newOperation.setRemoveParticipant(participant.getAddress());
-  }
-
-  /**
-   * Replaces participant domain.
-   */
-  private static ParticipantId convertParticipantId(String participant, String 
domain)
-      throws InvalidParticipantAddress {
-    return ParticipantId.of(ParticipantId.of(participant).getName(), domain);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/expimp/FileNames.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/expimp/FileNames.java 
b/wave/src/main/java/org/waveprotocol/box/expimp/FileNames.java
deleted file mode 100644
index a2740f7..0000000
--- a/wave/src/main/java/org/waveprotocol/box/expimp/FileNames.java
+++ /dev/null
@@ -1,106 +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.expimp;
-
-import org.waveprotocol.box.server.persistence.file.FileUtils;
-import org.waveprotocol.wave.media.model.AttachmentId;
-import org.waveprotocol.wave.model.id.WaveId;
-import org.waveprotocol.wave.model.id.WaveletId;
-import org.waveprotocol.wave.model.id.InvalidIdException;
-
-import java.text.DecimalFormat;
-
-/**
- * File and directory names for Export/Import utilities.
- *
- * @author [email protected] (Andrew Kaplanov)
- */
-public class FileNames {
-  private static final String FILE_NUMBER_PATTERN="000000";
-
-  private final String exportDir;
-
-  public FileNames(String exportDir) {
-    this.exportDir = exportDir;
-  }
-
-  public static String getWaveDirName(WaveId waveId) {
-    return FileUtils.waveIdToPathSegment(waveId);
-  }
-
-  public static String getWaveletDirName(WaveletId waveletId) {
-    return FileUtils.waveletIdToPathSegment(waveletId);
-  }
-
-  public static String getSnapshotFileName() {
-    return "snapshot.json";
-  }
-
-  public static String getDeltasFileName(int part) {
-    return "deltas." + new DecimalFormat(FILE_NUMBER_PATTERN).format(part) + 
".json";
-  }
-
-  public static String getAttachmentsDirName() {
-    return "attachments";
-  }
-
-  public static String getAttachmentFileName(AttachmentId attachmentId) {
-    return attachmentId.serialise() + ".json";
-  }
-
-  public String getExportDir() {
-    return exportDir;
-  }
-
-  public String getWaveDirPath(WaveId waveId) {
-    return exportDir + "/" + getWaveDirName(waveId);
-  }
-
-  public String getWaveletDirPath(WaveId waveId, WaveletId waveletId) {
-    return getWaveDirPath(waveId) + "/" + getWaveletDirName(waveletId);
-  }
-
-  public String getSnapshotFilePath(WaveId waveId, WaveletId waveletId) {
-    return getWaveletDirPath(waveId, waveletId) + "/" + getSnapshotFileName();
-  }
-
-  public String getDeltasFilePath(WaveId waveId, WaveletId waveletId, int 
part) {
-    return getWaveletDirPath(waveId, waveletId) + "/" + 
getDeltasFileName(part);
-  }
-
-  public String getAttachmentsDirPath(WaveId waveId, WaveletId waveletId) {
-    return getWaveletDirPath(waveId, waveletId) + "/" + 
getAttachmentsDirName();
-  }
-
-  public String getAttachmentFilePath(WaveId waveId, WaveletId waveletId, 
AttachmentId attachmentId) {
-    return getAttachmentsDirPath(waveId, waveletId) + "/" + 
getAttachmentFileName(attachmentId);
-  }
-
-  public static WaveId getWaveIdFromFileName(String name) {
-     return FileUtils.waveIdFromPathSegment(name);
-  }
-
-  public static WaveletId getWaveletIdFromFileName(String name) {
-     return FileUtils.waveletIdFromPathSegment(name);
-  }
-
-  public static AttachmentId getAttachmentIdFromFileName(String name) throws 
InvalidIdException {
-     return AttachmentId.deserialise(name.substring(0, name.length()-5));
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/expimp/OAuth.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/expimp/OAuth.java 
b/wave/src/main/java/org/waveprotocol/box/expimp/OAuth.java
deleted file mode 100644
index 0e6fd22..0000000
--- a/wave/src/main/java/org/waveprotocol/box/expimp/OAuth.java
+++ /dev/null
@@ -1,102 +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.expimp;
-
-import java.io.IOException;
-import java.net.URLEncoder;
-import java.util.StringTokenizer;
-
-import net.oauth.OAuthAccessor;
-import net.oauth.OAuthConsumer;
-import net.oauth.OAuthServiceProvider;
-
-import org.apache.commons.codec.binary.Base64;
-import com.google.wave.api.WaveService;
-
-/**
- * OAuth authorization through Robot and Data API.
- *
- * @author [email protected] (Andrew Kaplanov)
- */
-public class OAuth {
-  private static final String REQUEST_URL_POSTFIX = 
"/robot/dataapi/oauth/OAuthGetRequestToken";
-  private static final String AUTH_URL_POSTFIX = 
"/robot/dataapi/oauth/OAuthAuthorizeToken";
-  private static final String ACCESS_URL_POSTFIX = 
"/robot/dataapi/oauth/OAuthGetAccessToken";
-  private static final String GET_ALL_TOKENS_URL_POSTFIX = 
"/robot/dataapi/oauth/OAuthGetAllTokens";
-
-  private static final String DATA_API_RPC_URL_POSTFIX = "/robot/dataapi/rpc";
-  private static final String ROBOT_RPC_URL_POSTFIX = "/robot/rpc";
-
-  private static final String THREE_LEGGED_API_CONSUMER_KEY = "anonymous";
-  private static final String THREE_LEGGED_API_CONSUMER_SECRET = "anonymous";
-
-  private final String serverUrl;
-
-  public OAuth(String serverUrl) {
-    this.serverUrl = serverUrl;
-  }
-
-  /**
-   * Performs 2-legged OAuth authorization through Robot API.
-   *
-   * @param service wave service.
-   * @param consumerKey robot consumer key.
-   * @param consumerSecret robot consumer secret.
-   */
-  public String twoLeggedOAuth(WaveService service, String consumerKey, String 
consumerSecret) {
-    String rpcServerUrl = serverUrl + ROBOT_RPC_URL_POSTFIX;
-    service.setupOAuth(consumerKey, consumerSecret, rpcServerUrl);
-    return rpcServerUrl;
-  }
-
-  /**
-   * Performs 3-legged OAuth authorization through Data API.
-   *
-   * @param service wave service.
-   */
-  public String threeLeggedOAuth(WaveService service) throws IOException {
-    Console.println("Paste this URL in your browser:\n" + serverUrl + 
GET_ALL_TOKENS_URL_POSTFIX);
-    Console.println("Type the code you received here: ");
-    String authorizationCode = new String(
-        Base64.decodeBase64(Console.readLine().getBytes("UTF-8")), "UTF-8");
-
-    StringTokenizer st = new StringTokenizer(authorizationCode);
-
-    String requestToken = st.nextToken();
-    String accessToken = st.nextToken();
-    String tokenSecret = st.nextToken();
-
-    String requestUrl = serverUrl + REQUEST_URL_POSTFIX;
-    String authUrl = serverUrl + AUTH_URL_POSTFIX;
-    String accessUrl = serverUrl + ACCESS_URL_POSTFIX;
-
-    OAuthServiceProvider provider = new OAuthServiceProvider(requestUrl
-        + "?scope=" + URLEncoder.encode("", "utf-8"), authUrl, accessUrl);
-    OAuthConsumer consumer = new OAuthConsumer("", 
THREE_LEGGED_API_CONSUMER_KEY,
-        THREE_LEGGED_API_CONSUMER_SECRET, provider);
-    OAuthAccessor accessor = new OAuthAccessor(consumer);
-    accessor.requestToken = requestToken;
-    accessor.accessToken = accessToken;
-    accessor.tokenSecret = tokenSecret;
-
-    String rpcServerUrl = serverUrl + DATA_API_RPC_URL_POSTFIX;
-    service.setupOAuth(accessor, rpcServerUrl);
-    return rpcServerUrl;
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/expimp/WaveExport.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/expimp/WaveExport.java 
b/wave/src/main/java/org/waveprotocol/box/expimp/WaveExport.java
deleted file mode 100644
index 2108c1c..0000000
--- a/wave/src/main/java/org/waveprotocol/box/expimp/WaveExport.java
+++ /dev/null
@@ -1,332 +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.expimp;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import org.waveprotocol.wave.communication.gson.GsonException;
-import org.waveprotocol.wave.model.util.Base64DecoderException;
-import com.google.wave.api.SearchResult;
-import com.google.wave.api.SearchResult.Digest;
-import org.waveprotocol.wave.model.id.WaveId;
-import org.waveprotocol.wave.model.id.WaveletId;
-import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta;
-import org.waveprotocol.wave.media.model.AttachmentId;
-import org.waveprotocol.box.common.comms.proto.WaveletSnapshotProtoImpl;
-
-import com.google.wave.api.WaveService;
-import com.google.wave.api.impl.GsonFactory;
-import com.google.wave.api.impl.RawAttachmentData;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonParser;
-import com.google.wave.api.impl.RawDeltasListener;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.util.LinkedList;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.waveprotocol.box.server.common.CoreWaveletOperationSerializer;
-import org.waveprotocol.wave.federation.Proto.ProtocolHashedVersion;
-import org.waveprotocol.wave.model.id.IdURIEncoderDecoder;
-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.version.HashedVersionFactoryImpl;
-import org.waveprotocol.wave.util.escapers.jvm.JavaUrlCodec;
-
-/**
- * Export waves from Wiab to files.
- *
- * @author [email protected] (Andrew Kaplanov)
- */
-public class WaveExport {
-  private static final IdURIEncoderDecoder URI_CODEC = new 
IdURIEncoderDecoder(new JavaUrlCodec());
-  private static final HashedVersionFactory HASH_FACTORY = new 
HashedVersionFactoryImpl(URI_CODEC);
-
-  private static final Gson gson = new GsonFactory().create();
-  private static final JsonParser jsonParser = new JsonParser();
-
-  private final String serverUrl;
-  private final WaveService api;
-  private final FileNames fileNames;
-  private String search = "";
-  private String consumerKey;
-  private String consumerSecret;
-  private List<WaveId> includeList;
-  private List<WaveId> excludeList;
-  private String rpcServerUrl;
-
-  public WaveExport(String serverUrl, String exportDir) {
-    this.serverUrl = serverUrl;
-    fileNames = new FileNames(exportDir);
-    api = new WaveService();
-    api.setFetchFimeout(WaveService.FETCH_INFINITE_TIMEOUT);
-  }
-
-  public static void usageError() {
-    Console.println("Use: WaveExport <server URL> <export directory>\n"
-        + "   [-consumer_key     Robot consumer key]\n"
-        + "   [-consumer_secret  Robot consumer secret]\n"
-        + "   [-search           Search query]\n"
-        + "   [-include          Include waves list]\n"
-        + "   [-include_file     Include waves list file]\n"
-        + "   [-exclude          Exclude waves list]");
-    System.exit(1);
-  }
-
-  public static void main(String[] args) throws IOException, 
Base64DecoderException {
-    if (args.length < 2) {
-      usageError();
-    }
-    WaveExport export = new WaveExport(args[0], args[1]);
-    List<WaveId> includeList = new LinkedList<WaveId>();
-    List<WaveId> excludeList = new LinkedList<WaveId>();
-    for (int i = 2; i < args.length;) {
-      if (args[i].equals("-search")) {
-        export.setSearch(args[++i]);
-        i++;
-      } else if (args[i].equals("-consumer_key")) {
-        export.setConsumerKey(args[++i]);
-        i++;
-      } else if (args[i].equals("-consumer_secret")) {
-        export.setConsumerSecret(args[++i]);
-        i++;
-      } else if (args[i].equals("-include")) {
-        for (i = i + 1; i < args.length && args[i].charAt(0) != '-'; i++) {
-          includeList.add(WaveId.deserialise(args[i]));
-        }
-      } else if (args[i].equals("-include_file")) {
-        BufferedReader in = new BufferedReader(new FileReader(args[++i]));
-        for (;;) {
-          String line = in.readLine();
-          if (line == null)
-            break;
-          includeList.add(WaveId.deserialise(line));
-        }
-        in.close();
-        i++;
-      } else if (args[i].equals("-exclude")) {
-        for (i = i + 1; i < args.length && args[i].charAt(0) != '-'; i++) {
-          excludeList.add(WaveId.deserialise(args[i]));
-        }
-      } else {
-        usageError();
-      }
-    }
-    if (!includeList.isEmpty()) {
-      export.setIncludeList(includeList);
-    }
-    if (!excludeList.isEmpty()) {
-      export.setExcludeList(excludeList);
-    }
-
-    export.authorization();
-    export.exportWavesToFiles();
-  }
-
-  public void setSearch(String search) {
-    this.search = search;
-  }
-
-  public void setConsumerKey(String consumerKey) {
-    this.consumerKey = consumerKey;
-  }
-
-  public void setConsumerSecret(String consumerSecret) {
-    this.consumerSecret = consumerSecret;
-  }
-
-  public void setExcludeList(List<WaveId> excludeList) {
-    this.excludeList = excludeList;
-  }
-
-  public void setIncludeList(List<WaveId> includeList) {
-    this.includeList = includeList;
-  }
-
-  /**
-   * Performs authorization.
-   */
-  public void authorization() throws IOException, Base64DecoderException {
-    OAuth oauth = new OAuth(serverUrl);
-    if (consumerKey != null && consumerSecret != null) {
-      rpcServerUrl = oauth.twoLeggedOAuth(api, consumerKey, consumerSecret);
-    } else {
-      rpcServerUrl = oauth.threeLeggedOAuth(api);
-    }
-  }
-
-  /**
-   * Exports waves to files.
-   */
-  private void exportWavesToFiles() throws IOException {
-    Console.println();
-    List<WaveId> waves = includeList;
-    if (waves == null || waves.isEmpty()) {
-      waves = getAllWavesList();
-    }
-    int exportedCount = 0;
-    int failedCount = 0;
-    for (int i = 0; i < waves.size(); i++) {
-      boolean errorOccured = false;
-      WaveId waveId = waves.get(i);
-      try {
-        if (excludeList != null && excludeList.contains(waveId)) {
-          Console.println("Skipping wave " + waveId.serialise() + "...");
-          continue;
-        }
-        Console.println("Exporting wave " + waveId.serialise()
-            + " (" + (i + 1) + " of " + waves.size() + ") ...");
-        new File(fileNames.getWaveDirPath(waveId)).mkdir();
-        for (WaveletId waveletId : api.retrieveWaveletIds(waveId, 
rpcServerUrl)) {
-          WaveletSnapshotProtoImpl snapshot = exportSnapshot(waveId, 
waveletId);
-          Set<AttachmentId> attachmentIds = new HashSet<AttachmentId>();
-          try {
-            exportDeltas(waveId, waveletId, snapshot.getVersion().getPB(), 
attachmentIds);
-          } catch (IOException ex) {
-            errorOccured = true;
-            Console.error("Export of deltas error.", ex);
-          }
-          if (!attachmentIds.isEmpty()) {
-            new File(fileNames.getAttachmentsDirPath(waveId, 
waveletId)).mkdir();
-            for (AttachmentId attachmentId : attachmentIds) {
-              try {
-                exportAttachment(waveId, waveletId, attachmentId);
-              } catch (IOException ex) {
-                errorOccured = true;
-                Console.error("Uploading of attachment error.", ex);
-              }
-            }
-          }
-        }
-      } catch (Exception ex) {
-        errorOccured = true;
-        Console.error("Exporting of " + waveId.serialise() + " error.", ex);
-      }
-      if (errorOccured) {
-        failedCount++;
-      } else {
-        exportedCount++;
-      }
-    }
-    Console.println();
-    Console.println("Successfully exported " + exportedCount + " waves.");
-    Console.println("Failed for " + failedCount + " waves.");
-  }
-
-  private WaveletSnapshotProtoImpl exportSnapshot(WaveId waveId, WaveletId 
waveletId)
-      throws IOException {
-    new File(fileNames.getWaveletDirPath(waveId, waveletId)).mkdir();
-    Console.println("  wavelet " + waveletId.serialise());
-    Console.print("    getting snapshot ...");
-    String snapshotJSon = api.exportRawSnapshot(waveId, waveletId, 
rpcServerUrl);
-    writeSnapshotToFile(waveId, waveletId, snapshotJSon);
-    WaveletSnapshotProtoImpl snapshot = new WaveletSnapshotProtoImpl();
-    try {
-      snapshot.fromGson(jsonParser.parse(snapshotJSon), gson, null);
-    } catch (GsonException ex) {
-      throw new IOException(ex);
-    }
-    Console.println(" Ok, version " + 
(long)snapshot.getVersion().getVersion());
-    return snapshot;
-  }
-
-  private void exportDeltas(WaveId waveId, WaveletId waveletId, 
ProtocolHashedVersion lastVersion,
-      Set<AttachmentId> attachmentIds) throws IOException {
-    HashedVersion zeroVersion = 
HASH_FACTORY.createVersionZero(WaveletName.of(waveId, waveletId));
-    ProtocolHashedVersion version = 
CoreWaveletOperationSerializer.serialize(zeroVersion);
-    for (int fetchNum = 0; version.getVersion() != lastVersion.getVersion(); 
fetchNum++) {
-      Console.print("    getting deltas from version " + version.getVersion() 
+ " ...");
-      final List<byte[]> deltas = Lists.newArrayList();
-      final AtomicReference<byte[]> targetVersion = new 
AtomicReference<byte[]>();
-      api.exportRawDeltas(waveId, waveletId,
-          version.toByteArray(), lastVersion.toByteArray(), rpcServerUrl, new 
RawDeltasListener() {
-        @Override
-        public void onSuccess(List<byte[]> rawDeltas, byte[] rawTargetVersion) 
{
-          deltas.addAll(rawDeltas);
-          targetVersion.set(rawTargetVersion);
-        }
-
-        @Override
-        public void onFailire(String message) {
-          Console.error(search);
-        }
-      });
-      if (deltas.isEmpty()) {
-        Console.println(" empty response");
-        continue;
-      }
-      version = ProtocolHashedVersion.parseFrom(targetVersion.get());
-      Console.println(" Ok, got to version " + version.getVersion());
-      writeDeltasToFile(waveId, waveletId, deltas, fetchNum);
-      for (byte[] delta : deltas) {
-        
attachmentIds.addAll(DeltaParser.getAttachemntIds(ProtocolWaveletDelta.parseFrom(delta)));
-      }
-    }
-  }
-
-  private void exportAttachment(WaveId waveId, WaveletId waveletId, 
AttachmentId attachmentId) throws IOException {
-    Console.print("    getting attachment " + attachmentId.getId() + " ...");
-    RawAttachmentData attachment = api.exportAttachment(attachmentId, 
rpcServerUrl);
-    writeAttachmentToFile(waveId, waveletId, attachmentId, attachment);
-    Console.println(" Ok");
-  }
-
-  private List<WaveId> getAllWavesList() throws IOException {
-    List<WaveId> allList = new LinkedList<WaveId>();
-    SearchResult result = api.search(search, 0, Integer.MAX_VALUE, 
rpcServerUrl);
-    for (Digest digest : result.getDigests()) {
-      allList.add(WaveId.deserialise(digest.getWaveId()));
-    }
-    return allList;
-  }
-
-  private void writeSnapshotToFile(WaveId waveId, WaveletId waveletId, String 
snapshot) throws IOException {
-    String fileName = fileNames.getSnapshotFilePath(waveId, waveletId);
-    writeFile(fileName, snapshot);
-  }
-
-  private void writeDeltasToFile(WaveId waveId, WaveletId waveletId, 
List<byte[]> deltas,
-      int fetchNum) throws IOException {
-    String fileName = fileNames.getDeltasFilePath(waveId, waveletId, fetchNum);
-    String gsonStr = gson.toJson(deltas);
-    writeFile(fileName, gsonStr);
-  }
-
-  private void writeAttachmentToFile(WaveId waveId, WaveletId waveletId, 
AttachmentId attachmentId,
-      RawAttachmentData attachment) throws IOException {
-    String fileName = fileNames.getAttachmentFilePath(waveId, waveletId, 
attachmentId);
-    String gsonStr = gson.toJson(attachment);
-    writeFile(fileName, gsonStr);
-  }
-
-  static private void writeFile(String name, String data) throws IOException {
-    FileWriter w = new FileWriter(new File(name));
-    w.write(data);
-    w.close();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/expimp/WaveImport.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/expimp/WaveImport.java 
b/wave/src/main/java/org/waveprotocol/box/expimp/WaveImport.java
deleted file mode 100644
index 430082b..0000000
--- a/wave/src/main/java/org/waveprotocol/box/expimp/WaveImport.java
+++ /dev/null
@@ -1,294 +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.expimp;
-
-import com.google.gson.Gson;
-import com.google.protobuf.ByteString;
-import com.google.wave.api.WaveService;
-import com.google.wave.api.impl.RawAttachmentData;
-import com.google.wave.api.impl.GsonFactory;
-
-import org.waveprotocol.wave.media.model.AttachmentId;
-import org.waveprotocol.wave.model.id.WaveId;
-import org.waveprotocol.wave.model.id.WaveletId;
-import org.waveprotocol.wave.model.id.IdUtil;
-import org.waveprotocol.wave.federation.Proto.ProtocolWaveletDelta;
-import org.waveprotocol.wave.model.wave.InvalidParticipantAddress;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Import waves from files to Wiab.
- *
- * @author ([email protected]) (Andrew Kaplanov)
- */
-public final class WaveImport {
-
-  private enum ImportWaveletState { NOTHING_DONE, WAVELET_CREATED, 
WAVELET_UPDATED };
-
-  private static final Gson gson = new GsonFactory().create();
-
-  private final String serverUrl;
-  private final WaveService api;
-  private final FileNames fileNames;
-
-  private String consumerKey;
-  private String consumerSecret;
-  private String rpcServerUrl;
-  private String waveDomain;
-
-  static public void usageError() {
-    Console.println("Use: WaveImport <server URL> <export directory>\n"
-      + "   [-consumer_key    Robot consumer key]\n"
-      + "   [-consumer_secret Robot consumer secret]\n"
-      + "   [-wave_domain     Target wave domain]");
-    System.exit(1);
-  }
-
-  public static void main(String[] args) throws IOException {
-    if (args.length < 2) {
-      usageError();
-    }
-    WaveImport imp = new WaveImport(args[0], args[1]);
-    for (int i = 2; i < args.length;) {
-      if (args[i].equals("-consumer_key")) {
-        imp.setConsumerKey(args[++i]);
-        i++;
-      } else if (args[i].equals("-consumer_secret")) {
-        imp.setConsumerSecret(args[++i]);
-        i++;
-      } else if (args[i].equals("-wave_domain")) {
-        imp.setWaveDomain(args[++i]);
-        i++;
-      } else {
-        usageError();
-      }
-    }
-    imp.authorization();
-    imp.importWavesFromFiles();
-  }
-
-  private WaveImport(String serverUrl, String exportDir) {
-    this.serverUrl = serverUrl;
-    fileNames = new FileNames(exportDir);
-    api = new WaveService();
-    api.setFetchFimeout(WaveService.FETCH_INFINITE_TIMEOUT);
-  }
-
-  public void setConsumerKey(String consumerKey) {
-    this.consumerKey = consumerKey;
-  }
-
-  public void setConsumerSecret(String consumerSecret) {
-    this.consumerSecret = consumerSecret;
-  }
-
-  public void setWaveDomain(String waveDomain) {
-    this.waveDomain = waveDomain;
-  }
-
-  /**
-   * Performs authorization.
-   */
-  public void authorization() throws IOException {
-    OAuth oauth = new OAuth(serverUrl);
-    if (consumerKey != null && consumerSecret != null) {
-      rpcServerUrl = oauth.twoLeggedOAuth(api, consumerKey, consumerSecret);
-    } else {
-      rpcServerUrl = oauth.threeLeggedOAuth(api);
-    }
-  }
-
-  /**
-   * Imports waves from files.
-   */
-  public void importWavesFromFiles() {
-    Console.println();
-    File expDir = new File(fileNames.getExportDir());
-    if (!expDir.exists()) {
-      Console.println("Directory " + fileNames.getExportDir() + " is not 
exists.");
-      System.exit(1);
-    }
-    File[] waveDirs = expDir.listFiles();
-    Arrays.sort(waveDirs, new Comparator<File>() {
-
-      @Override
-      public int compare(File f1, File f2) {
-        return f1.getName().compareTo(f2.getName());
-      }
-    });
-    int createdCount = 0;
-    int updatedCount = 0;
-    int skippedCount = 0;
-    int failedCount = 0;
-    for (int i = 0; i < waveDirs.length; i++) {
-      File waveDir = waveDirs[i];
-      WaveId sourceWaveId = FileNames.getWaveIdFromFileName(waveDir.getName());
-      WaveId targetWaveId = DomainConverter.convertWaveId(sourceWaveId, 
waveDomain);
-      Console.println("Importing wave " + targetWaveId.serialise()
-          + " (" + (i + 1) + " of " + waveDirs.length + ") ...");
-      boolean waveCreated = false;
-      boolean waveUpdated = false;
-      File[] waveletDirs = waveDir.listFiles();
-      for (File waveletDir : waveletDirs) {
-        WaveletId sourceWaveletId = 
FileNames.getWaveletIdFromFileName(waveletDir.getName());
-        try {
-          ImportWaveletState state = importWavelet(sourceWaveId, 
sourceWaveletId);
-          if (state == ImportWaveletState.WAVELET_CREATED && 
!IdUtil.isUserDataWavelet(sourceWaveletId)) {
-            waveCreated = true;
-          } else if (state != ImportWaveletState.NOTHING_DONE) {
-            waveUpdated = true;
-          }
-        } catch (IOException ex) {
-          failedCount++;
-          Console.error("Importing wavelet error", ex);
-        }
-      }
-      if (waveCreated) {
-        createdCount++;
-      } else if (waveUpdated) {
-        updatedCount++;
-      } else {
-        skippedCount++;
-      }
-    }
-    Console.println();
-    Console.println("Created " + createdCount + " waves.");
-    Console.println("Updated " + updatedCount + " waves.");
-    Console.println("Skipped " + skippedCount + " waves.");
-    Console.println("Failed for " + failedCount + " waves.");
-  }
-
-  private ImportWaveletState importWavelet(WaveId sourceWaveId, WaveletId 
sourceWaveletId)
-      throws IOException {
-    ImportWaveletState state = ImportWaveletState.NOTHING_DONE;
-    WaveId targetWaveId = DomainConverter.convertWaveId(sourceWaveId, 
waveDomain);
-    WaveletId targetWaveletId;
-    try {
-      targetWaveletId = DomainConverter.convertWaveletId(sourceWaveletId, 
waveDomain);
-    } catch (InvalidParticipantAddress ex) {
-      throw new IOException(ex);
-    }
-    Set<AttachmentId> attachmentIds = new HashSet<AttachmentId>();
-    Console.println("  wavelet " + targetWaveletId.serialise());
-    for (int part=0 ; ; part++) {
-      File deltasFile = new File(fileNames.getDeltasFilePath(sourceWaveId, 
sourceWaveletId, part));
-      if (!deltasFile.exists()) {
-        break;
-      }
-      ImportWaveletState st = importDeltas(deltasFile, targetWaveId, 
targetWaveletId, attachmentIds);
-      if (state == ImportWaveletState.NOTHING_DONE) {
-        state = st;
-      }
-    }
-    importAttachments(sourceWaveId, sourceWaveletId, targetWaveId, 
targetWaveletId, attachmentIds);
-    return state;
-  }
-
-  private ImportWaveletState importDeltas(File deltasFile, WaveId 
targetWaveId, WaveletId targetWaveletId,
-      Set<AttachmentId> attachmentIds) throws IOException {
-    ImportWaveletState state = ImportWaveletState.NOTHING_DONE;
-    @SuppressWarnings("unchecked")
-    List<byte[]> sourceHistory = gson.fromJson(readFile(deltasFile), 
GsonFactory.RAW_DELTAS_TYPE);
-    List<byte[]> targetHistory;
-    List<ProtocolWaveletDelta> deltas = DeltaParser.parseDeltas(sourceHistory);
-    List<ProtocolWaveletDelta> targetDeltas;
-    if (waveDomain != null) {
-      try {
-        targetDeltas = DomainConverter.convertDeltas(deltas, waveDomain);
-      } catch (InvalidParticipantAddress ex) {
-        throw new IOException(ex);
-      }
-      targetHistory = new LinkedList<byte[]>();
-      for (ProtocolWaveletDelta delta : targetDeltas) {
-        targetHistory.add(delta.toByteArray());
-      }
-    } else {
-      targetDeltas = deltas;
-      targetHistory = sourceHistory;
-    }
-    if (!targetDeltas.isEmpty()) {
-      long fromVersion = targetDeltas.get(0).getHashedVersion().getVersion();
-      ProtocolWaveletDelta lastDelta = targetDeltas.get(targetDeltas.size()-1);
-      long toVersion = 
lastDelta.getHashedVersion().getVersion()+lastDelta.getOperationCount();
-      Console.print("    send deltas " + fromVersion + "-" + toVersion + " 
...");
-      long importedFromVersion = api.importRawDeltas(targetWaveId, 
targetWaveletId, targetHistory, rpcServerUrl);
-      if (fromVersion == importedFromVersion) {
-        Console.println(" imported");
-      } else if (importedFromVersion == -1) {
-        Console.println(" skipped");
-      } else {
-        Console.println(" imported from version " + importedFromVersion);
-      }
-      if (fromVersion == importedFromVersion) {
-        if (fromVersion == 0) {
-          state = ImportWaveletState.WAVELET_CREATED;
-        } else {
-          state = ImportWaveletState.WAVELET_UPDATED;
-        }
-      } else if (importedFromVersion != -1) {
-        state = ImportWaveletState.WAVELET_UPDATED;
-      }
-      if (importedFromVersion != -1) {
-        for (ProtocolWaveletDelta delta : targetDeltas) {
-          if (delta.getHashedVersion().getVersion() >= importedFromVersion) {
-            attachmentIds.addAll(DeltaParser.getAttachemntIds(delta));
-          }
-        }
-      }
-    }
-    return state;
-  }
-
-  private void importAttachments(WaveId sourceWaveId, WaveletId 
sourceWaveletId,
-      WaveId targetWaveId, WaveletId targetWaveletId, Set<AttachmentId> 
attachmentIds)
-      throws FileNotFoundException, IOException {
-    for (AttachmentId attachmentId : attachmentIds) {
-      String attachmentFile = fileNames.getAttachmentFilePath(sourceWaveId, 
sourceWaveletId, attachmentId);
-      RawAttachmentData attachmentData = gson.fromJson(readFile(new 
File(attachmentFile)), RawAttachmentData.class);
-      Console.print("    importing attachment " + attachmentId.serialise() + " 
...");
-      api.importAttachment(targetWaveId, targetWaveletId, attachmentId, 
attachmentData, rpcServerUrl);
-      Console.println(" Ok");
-    }
-  }
-
-  private static String readFile(File file) throws FileNotFoundException, 
IOException {
-    Reader reader = new FileReader(file);
-    StringBuilder sb = new StringBuilder();
-    char buf[] = new char[1024];
-    for (;;) {
-      int ret = reader.read(buf, 0, buf.length);
-      if (ret == -1) {
-        break;
-      }
-      sb.append(buf, 0, ret);
-    }
-    return sb.toString();
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/server/CoreSettingsNames.java
----------------------------------------------------------------------
diff --git 
a/wave/src/main/java/org/waveprotocol/box/server/CoreSettingsNames.java 
b/wave/src/main/java/org/waveprotocol/box/server/CoreSettingsNames.java
deleted file mode 100644
index 9179951..0000000
--- a/wave/src/main/java/org/waveprotocol/box/server/CoreSettingsNames.java
+++ /dev/null
@@ -1,27 +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.
- */
-
- /**
- * @author [email protected](Yuri Zelikov)
- */
-package org.waveprotocol.box.server;
-
-public interface CoreSettingsNames {
-    String WAVE_SERVER_DOMAIN = "wave_server_domain";
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/server/DataMigrationTool.java
----------------------------------------------------------------------
diff --git 
a/wave/src/main/java/org/waveprotocol/box/server/DataMigrationTool.java 
b/wave/src/main/java/org/waveprotocol/box/server/DataMigrationTool.java
deleted file mode 100644
index 0ec107b..0000000
--- a/wave/src/main/java/org/waveprotocol/box/server/DataMigrationTool.java
+++ /dev/null
@@ -1,141 +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;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import org.waveprotocol.box.server.persistence.PersistenceModule;
-import org.waveprotocol.box.server.persistence.migration.DeltaMigrator;
-import org.waveprotocol.box.server.waveserver.DeltaStore;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A cmd line utility to perform data migration from a store type to another
- * one. Initially developed to replicate deltas from a file store to a mongodb
- * store.
- *
- *
- * @author [email protected] (Pablo Ojanguren)
- *
- */
-public class DataMigrationTool {
-
-  private static void runDeltasMigration(Injector sourceInjector, Injector 
targetInjector) {
-
-    // We can migrate data from-to any store type,
-    // but it is not allowed migrate from-to the same type
-    String sourceDeltaStoreType =
-        sourceInjector
-            .getInstance(Config.class).getString("core.delta_store_type");
-
-    String targetDeltaStoreType =
-        targetInjector
-                .getInstance(Config.class).getString("core.delta_store_type");
-
-    if (sourceDeltaStoreType.equalsIgnoreCase(targetDeltaStoreType))
-      usageError("Source and Target Delta store types must be different");
-
-
-    DeltaMigrator dm =
-        new DeltaMigrator(sourceInjector.getInstance(DeltaStore.class),
-            targetInjector.getInstance(DeltaStore.class));
-
-    dm.run();
-
-  }
-
-  private static Module bindCmdLineSettings(String cmdLineProperties) {
-
-    // Get settings from cmd line, e.g.
-    // Key = delta_store_type
-    // Value = mongodb
-    final Map<String, String> propertyMap = new HashMap<>();
-
-    for (String arg : cmdLineProperties.split(",")) {
-      String[] argTokens = arg.split("=");
-      propertyMap.put(argTokens[0], argTokens[1]);
-    }
-
-    return new AbstractModule() {
-
-      @Override
-      protected void configure() {
-        Config config = ConfigFactory.load().withFallback(
-          ConfigFactory.parseFile(new File("application.conf")).withFallback(
-            ConfigFactory.parseFile(new File("reference.conf"))));
-        
bind(Config.class).toInstance(ConfigFactory.parseMap(propertyMap).withFallback(config));
-      }
-    };
-
-  }
-
-  public static void usageError() {
-    usageError("");
-  }
-
-  public static void usageError(String msg) {
-    System.out.println(msg + "\n");
-    System.out.println("Use: DataMigrationTool <data type> <source options> 
<target options>\n");
-    System.out.println("supported data types : deltas");
-    System.out
-        .println("source options example : core.delta_store_type=file," +
-                   "core.delta_store_directory=_deltas");
-    System.out
-        .println("target options example : core.delta_store_type=mongodb," +
-                   
"core.mongodb_host=127.0.0.1,core.mongodb_port=27017,core.mongodb_database=wiab");
-    System.exit(1);
-  }
-
-  public static void main(String... args) {
-
-    if (args.length != 3) usageError();
-
-    String dataType = args[0];
-
-    Module sourceSettings = bindCmdLineSettings(args[1]);
-    Injector sourceSettingsInjector = Guice.createInjector(sourceSettings);
-    Module sourcePersistenceModule = 
sourceSettingsInjector.getInstance(PersistenceModule.class);
-    Injector sourceInjector = 
sourceSettingsInjector.createChildInjector(sourcePersistenceModule);
-
-
-    Module targetSettings = bindCmdLineSettings(args[2]);
-    Injector targetSettingsInjector = Guice.createInjector(targetSettings);
-    Module targetPersistenceModule = 
targetSettingsInjector.getInstance(PersistenceModule.class);
-    Injector targetInjector = 
targetSettingsInjector.createChildInjector(targetPersistenceModule);
-
-
-    if (dataType.equals("deltas")) {
-      runDeltasMigration(sourceInjector, targetInjector);
-
-    } else {
-      usageError("Wrong data type");
-    }
-
-
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/051db092/wave/src/main/java/org/waveprotocol/box/server/SearchModule.java
----------------------------------------------------------------------
diff --git a/wave/src/main/java/org/waveprotocol/box/server/SearchModule.java 
b/wave/src/main/java/org/waveprotocol/box/server/SearchModule.java
deleted file mode 100644
index 4422155..0000000
--- a/wave/src/main/java/org/waveprotocol/box/server/SearchModule.java
+++ /dev/null
@@ -1,82 +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;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.typesafe.config.Config;
-import org.waveprotocol.box.server.persistence.file.FileUtils;
-import org.waveprotocol.box.server.persistence.lucene.FSIndexDirectory;
-import org.waveprotocol.box.server.persistence.lucene.IndexDirectory;
-import org.waveprotocol.box.server.waveserver.*;
-
-/**
- * @author [email protected] (Yuri Zelikov)
- */
-public class SearchModule extends AbstractModule {
-
-  private final String searchType;
-  private final String indexDirectory;
-
-  @Inject
-  public SearchModule(Config config) {
-    this.searchType = config.getString("core.search_type");
-    this.indexDirectory = config.getString("core.index_directory");
-  }
-
-  @Override
-  public void configure() {
-    if ("lucene".equals(searchType)) {
-      
bind(SearchProvider.class).to(SimpleSearchProviderImpl.class).in(Singleton.class);
-      
bind(PerUserWaveViewProvider.class).to(LucenePerUserWaveViewHandlerImpl.class).in(
-          Singleton.class);
-      
bind(PerUserWaveViewBus.Listener.class).to(LucenePerUserWaveViewHandlerImpl.class).in(
-          Singleton.class);
-      
bind(PerUserWaveViewHandler.class).to(LucenePerUserWaveViewHandlerImpl.class).in(
-          Singleton.class);
-      bind(IndexDirectory.class).to(FSIndexDirectory.class);
-      if (!FileUtils.isDirExistsAndNonEmpty(indexDirectory)) {
-        bind(WaveIndexer.class).to(LuceneWaveIndexerImpl.class);
-      } else {
-        bind(WaveIndexer.class).to(NoOpWaveIndexerImpl.class);
-      }
-    } else if ("solr".equals(searchType)) {
-      
bind(SearchProvider.class).to(SolrSearchProviderImpl.class).in(Singleton.class);
-      /*-
-       * (Frank R.) binds to class with dummy methods just because it's 
required by
-       * org.waveprotocol.box.server.ServerMain.initializeSearch(Injector, 
WaveBus)
-       */
-      
bind(PerUserWaveViewBus.Listener.class).to(SolrWaveIndexerImpl.class).in(Singleton.class);
-      
bind(WaveIndexer.class).to(SolrWaveIndexerImpl.class).in(Singleton.class);
-    } else if ("memory".equals(searchType)) {
-      
bind(SearchProvider.class).to(SimpleSearchProviderImpl.class).in(Singleton.class);
-      
bind(PerUserWaveViewProvider.class).to(MemoryPerUserWaveViewHandlerImpl.class).in(
-          Singleton.class);
-      
bind(PerUserWaveViewBus.Listener.class).to(MemoryPerUserWaveViewHandlerImpl.class).in(
-          Singleton.class);
-      
bind(PerUserWaveViewHandler.class).to(MemoryPerUserWaveViewHandlerImpl.class).in(
-          Singleton.class);
-      
bind(WaveIndexer.class).to(MemoryWaveIndexerImpl.class).in(Singleton.class);
-    } else {
-      throw new RuntimeException("Unknown search type: " + searchType);
-    }
-  }
-}

Reply via email to