示例#1
0
 /**
  * Transform a wavelet delta if it has been submitted against a different head (currentVersion).
  * Must be called with write lock held.
  *
  * @param delta to possibly transform
  * @param appliedVersion that the delta is applied to
  * @return the transformed delta and the version it was applied at (the version is the current
  *     version of the wavelet, unless the delta is a duplicate in which case it is the version at
  *     which it was originally applied)
  * @throws InvalidHashException if submitting against same version but different hash
  * @throws OperationException if transformation fails
  */
 protected VersionedWaveletDelta maybeTransformSubmittedDelta(
     WaveletDelta delta, HashedVersion appliedVersion)
     throws InvalidHashException, OperationException {
   if (appliedVersion.equals(currentVersion)) {
     // Applied version is the same, we're submitting against head, don't need to do OT
     return new VersionedWaveletDelta(delta, appliedVersion);
   } else {
     // Not submitting against head, we need to do OT, but check the versions really are different
     if (appliedVersion.getVersion() == currentVersion.getVersion()) {
       LOG.warning(
           "Same version ("
               + currentVersion.getVersion()
               + ") but different hashes ("
               + appliedVersion
               + "/"
               + currentVersion
               + ")");
       throw new InvalidHashException(
           "Different hash, same version: " + currentVersion.getVersion());
     } else {
       return transformSubmittedDelta(delta, appliedVersion);
     }
   }
 }