| | |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | |
| | | |
| | | /** |
| | | * This class creates an output stream that can be used to export entries |
| | | * to a synchonization 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; |
| | | |
| | | // The current number of entries exported |
| | | long numExportedEntries; |
| | | |
| | | String entryBuffer = ""; |
| | | |
| | | /** |
| | |
| | | * domain. |
| | | * |
| | | * @param domain The replication domain |
| | | * @param numEntries The max number of entry to process. |
| | | */ |
| | | public ReplLDIFOutputStream(ReplicationDomain domain) |
| | | public ReplLDIFOutputStream(ReplicationDomain domain, long numEntries) |
| | | { |
| | | this.domain = domain; |
| | | this.numEntries = numEntries; |
| | | } |
| | | |
| | | /** |
| | |
| | | endOfEntryIndex = ebytes.indexOf("\n\n"); |
| | | if ( endOfEntryIndex >= 0 ) |
| | | { |
| | | |
| | | endOfEntryIndex += 2; |
| | | entryBuffer = entryBuffer + ebytes.substring(0, endOfEntryIndex); |
| | | |
| | | // Send the entry |
| | | domain.sendEntryLines(entryBuffer); |
| | | if ((numEntries>0) && (numExportedEntries > numEntries)) |
| | | { |
| | | // This outputstream has reached the total number |
| | | // of entries to export. |
| | | return; |
| | | } |
| | | domain.exportLDIFEntry(entryBuffer); |
| | | numExportedEntries++; |
| | | |
| | | startOfEntryIndex = startOfEntryIndex + endOfEntryIndex; |
| | | entryBuffer = ""; |