Package org.waveprotocol.wave.federation

Examples of org.waveprotocol.wave.federation.ProtocolHashedVersion


    if (deltas == null) {
      return null;
    } else {
      List<TransformedWaveletDelta> parsed = new ArrayList<TransformedWaveletDelta>();
      for (int i = 0; i < deltas.size(); i++) {
        ProtocolHashedVersion thisEnd = //
            i < deltas.size() - 1 ? deltas.get(i + 1).getHashedVersion() : end;
        parsed.add(deserialize(deltas.get(i), thisEnd));
      }
      return parsed;
    }
View Full Code Here


  /**
   * Serializes a {@link HashedVersion} POJO to a {@link ProtocolHashedVersion}.
   */
  public static ProtocolHashedVersion serialize(HashedVersion hashedVersion) {
    Blob b64Hash = new Blob(Codec.encode(hashedVersion.getHistoryHash()));
    ProtocolHashedVersion version = ProtocolHashedVersionJsoImpl.create();
    version.setVersion(hashedVersion.getVersion());
    version.setHistoryHash(b64Hash);
    return version;
  }
View Full Code Here

    /**
     * Records a signed server version.
     */
    void updateHistory(WaveletName wavelet, ProtocolHashedVersion update) {
      ProtocolHashedVersion current = versions.get(wavelet);
      if (current != null && current.getVersion() > update.getVersion()) {
        LOG.info("Ignoring superceded hash update: " + update);
        return;
      }
      versions.put(wavelet, update);
    }
View Full Code Here

     */
    ProtocolHashedVersion getServerVersion(WaveletName wavelet, WaveletDelta delta) {
      if (delta.getTargetVersion().getVersion() == 0) {
        return serialize(HASHER.createVersionZero(wavelet));
      } else {
        ProtocolHashedVersion current = versions.get(wavelet);
        Preconditions.checkNotNull(current);
        double prevVersion = current.getVersion();
        double deltaVersion = delta.getTargetVersion().getVersion();
        if (deltaVersion != prevVersion) {
          throw new IllegalArgumentException(
              "Client delta expressed against non-server version.  Server version: " + prevVersion
                  + ", client delta: " + deltaVersion);
View Full Code Here

    /**
     * Records a signed server version.
     */
    void updateHistory(WaveletName wavelet, ProtocolHashedVersion update) {
      ProtocolHashedVersion current = versions.get(wavelet);
      if (current != null && current.getVersion() > update.getVersion()) {
        LOG.info("Ignoring superceded hash update: " + update);
        return;
      }
      versions.put(wavelet, update);
    }
View Full Code Here

     */
    ProtocolHashedVersion getServerVersion(WaveletName wavelet, WaveletDelta delta) {
      if (delta.getTargetVersion().getVersion() == 0) {
        return serialize(HASHER.createVersionZero(wavelet));
      } else {
        ProtocolHashedVersion current = versions.get(wavelet);
        Preconditions.checkNotNull(current);
        double prevVersion = current.getVersion();
        double deltaVersion = delta.getTargetVersion().getVersion();
        if (deltaVersion != prevVersion) {
          throw new IllegalArgumentException(
              "Client delta expressed against non-server version.  Server version: " + prevVersion
                  + ", client delta: " + deltaVersion);
View Full Code Here

  /**
   * Serializes a {@link HashedVersion} POJO to a {@link ProtocolHashedVersion}.
   */
  public static ProtocolHashedVersion serialize(HashedVersion hashedVersion) {
    Blob b64Hash = new Blob(Codec.encode(hashedVersion.getHistoryHash()));
    ProtocolHashedVersion version = ProtocolHashedVersionJsoImpl.create();
    version.setVersion(hashedVersion.getVersion());
    version.setHistoryHash(b64Hash);
    return version;
  }
View Full Code Here

    if (deltas == null) {
      return null;
    } else {
      List<TransformedWaveletDelta> parsed = new ArrayList<TransformedWaveletDelta>();
      for (int i = 0; i < deltas.size(); i++) {
        ProtocolHashedVersion thisEnd = //
            i < deltas.size() - 1 ? deltas.get(i + 1).getHashedVersion() : end;
        parsed.add(deserialize(deltas.get(i), thisEnd));
      }
      return parsed;
    }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.federation.ProtocolHashedVersion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.