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 legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2009 Sun Microsystems, Inc.
025 *      Portions copyright 2012-2015 ForgeRock AS
026 */
027package org.opends.server.replication.plugin;
028
029import org.opends.server.replication.common.CSN;
030import org.opends.server.replication.protocol.DeleteMsg;
031import org.opends.server.replication.protocol.ReplicationMsg;
032import org.opends.server.types.DN;
033
034/**
035 * This class if used to build pseudo DEL Operation from the historical
036 * information that stay in the entry in the database.
037 *
038 * This is useful when a LDAP server can't find a LDAP server that
039 * has already seen all its changes and therefore need to retransmit them.
040 */
041public class FakeDelOperation extends FakeOperation
042{
043  private final DN dn;
044  private final String entryUUID;
045
046  /**
047   * Creates a new FakeDelOperation from the provided information.
048   *
049   * @param dn             The dn of the entry that was deleted.
050   * @param csn   The CSN of the operation.
051   * @param entryUUID      The Unique ID of the deleted entry.
052   */
053  public FakeDelOperation(DN dn, CSN csn, String entryUUID)
054  {
055    super(csn);
056    this.dn = dn;
057    this.entryUUID = entryUUID;
058  }
059
060
061  /** {@inheritDoc} */
062  @Override
063  public ReplicationMsg generateMessage()
064  {
065    return new DeleteMsg(dn, getCSN(), entryUUID);
066  }
067
068  /**
069   * Retrieves the Unique ID of the entry that was deleted with this operation.
070   *
071   * @return  The Unique ID of the entry that was deleted with this operation.
072   */
073  public String getEntryUUID()
074  {
075    return entryUUID;
076  }
077}