001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2006-2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.replication.plugin;
028    
029    import java.util.ArrayList;
030    
031    import org.opends.server.replication.common.ChangeNumber;
032    import org.opends.server.replication.protocol.ModifyMsg;
033    import org.opends.server.replication.protocol.ReplicationMessage;
034    import org.opends.server.types.DN;
035    import org.opends.server.types.Modification;
036    
037    /**
038     * This class if used to build fake Modify Operation from the historical
039     * information that stay in the entry in the database.
040     *
041     * This is usefull when a LDAP server can't find a LDAP server that
042     * has already seen all its changes and therefore need to retransmit them
043     *
044     * @author Gilles Bellaton
045     */
046    public class ModifyFakeOperation extends FakeOperation
047    {
048      private ArrayList<Modification> mods = new ArrayList<Modification>();
049      private DN dn;
050      private String entryuuid;
051    
052      /**
053       * Creates a new ModifyFakeOperation with the provided information.
054       *
055       * @param dn The dn on which the Operation was applied.
056       * @param changenumber The ChangeNumber of the operation.
057       * @param entryuuid The unique ID of the entry on which the Operation applies.
058       */
059      public ModifyFakeOperation(DN dn, ChangeNumber changenumber, String entryuuid)
060      {
061        super(changenumber);
062        this.dn = dn;
063        this.entryuuid = entryuuid;
064      }
065    
066      /**
067       * Add a modification to the list of modification included
068       * in this fake operation.
069       *
070       * @param mod A modification that must be adde to the list of modifications
071       *            included in this fake operation.
072       */
073      public void addModification(Modification mod)
074      {
075        mods.add(mod);
076      }
077    
078      /**
079       * {@inheritDoc}
080       */
081      @Override
082      public ReplicationMessage generateMessage()
083      {
084        return new ModifyMsg(super.getChangeNumber(), dn, mods, entryuuid);
085      }
086    }