001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2009 Sun Microsystems, Inc.
015 * Portions copyright 2012-2016 ForgeRock AS.
016 */
017package org.opends.server.replication.plugin;
018
019import org.opends.server.replication.common.CSN;
020import org.opends.server.replication.protocol.DeleteMsg;
021import org.opends.server.replication.protocol.ReplicationMsg;
022import org.forgerock.opendj.ldap.DN;
023
024/**
025 * This class if used to build pseudo DEL Operation from the historical
026 * information that stay in the entry in the database.
027 *
028 * This is useful when a LDAP server can't find a LDAP server that
029 * has already seen all its changes and therefore need to retransmit them.
030 */
031public class FakeDelOperation extends FakeOperation
032{
033  private final DN dn;
034  private final String entryUUID;
035
036  /**
037   * Creates a new FakeDelOperation from the provided information.
038   *
039   * @param dn             The dn of the entry that was deleted.
040   * @param csn   The CSN of the operation.
041   * @param entryUUID      The Unique ID of the deleted entry.
042   */
043  public FakeDelOperation(DN dn, CSN csn, String entryUUID)
044  {
045    super(csn);
046    this.dn = dn;
047    this.entryUUID = entryUUID;
048  }
049
050
051  /** {@inheritDoc} */
052  @Override
053  public ReplicationMsg generateMessage()
054  {
055    return new DeleteMsg(dn, getCSN(), entryUUID);
056  }
057
058  /**
059   * Retrieves the Unique ID of the entry that was deleted with this operation.
060   *
061   * @return  The Unique ID of the entry that was deleted with this operation.
062   */
063  public String getEntryUUID()
064  {
065    return entryUUID;
066  }
067}