mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

ludovicp
25.47.2010 65cf071e6e7a15eb81c7d8f9fa2984c9de74b10e
opends/src/server/org/opends/server/replication/plugin/ReplLDIFOutputStream.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 */
package org.opends.server.replication.plugin;
@@ -30,19 +30,15 @@
import java.io.IOException;
import java.io.OutputStream;
import org.opends.server.replication.service.ReplicationDomain;
import org.opends.server.util.ServerConstants;
/**
 * This class creates an output stream that can be used to export entries
 * to a synchonization domain.
 * to a synchronization domain.
 */
public class ReplLDIFOutputStream
       extends OutputStream
{
  // The synchronization domain on which the export is done
  ReplicationDomain domain;
  // The number of entries to be exported
  long numEntries;
@@ -50,16 +46,17 @@
  private long numExportedEntries;
  String entryBuffer = "";
  // The checksum for computing the generation id
  private GenerationIdChecksum checkSum = new GenerationIdChecksum();
  /**
   * Creates a new ReplLDIFOutputStream related to a replication
   * domain.
   *
   * @param domain The replication domain
   * @param numEntries The max number of entry to process.
   */
  public ReplLDIFOutputStream(ReplicationDomain domain, long numEntries)
  public ReplLDIFOutputStream(long numEntries)
  {
    this.domain = domain;
    this.numEntries = numEntries;
  }
@@ -72,6 +69,15 @@
  }
  /**
   * Get the value of the underlying checksum.
   * @return The value of the underlying checksum
   */
  public long getChecksumValue()
  {
    return checkSum.getValue();
  }
  /**
   * {@inheritDoc}
   */
  public void write(byte b[], int off, int len) throws IOException
@@ -105,6 +111,10 @@
          throw(new IOException());
        }
        // Add the entry bytes to the checksum
        byte[] entryBytes = entryBuffer.getBytes();
        checkSum.update(entryBytes, 0, entryBytes.length);
        numExportedEntries++;
        entryBuffer = "";