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 2008-2010 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.AddMsg; 031import org.opends.server.types.Entry; 032 033/** 034 * This class if used to build fake ADD Operation from the historical 035 * information that stay in the entry in the database. 036 * 037 * This is useful when a LDAP server can't find a LDAP server that 038 * has already seen all its changes and therefore need to retransmit them. 039 * 040 */ 041public class FakeAddOperation extends FakeOperation 042{ 043 private Entry entry; 044 045 /** 046 * Creates a new AddFakeOperations. 047 * 048 * @param csn The CSN when the entry was created. 049 * @param entry The entry that the ADD operation will create. 050 */ 051 public FakeAddOperation(CSN csn, Entry entry) 052 { 053 super(csn); 054 this.entry = entry; 055 } 056 057 /** {@inheritDoc} */ 058 @Override 059 public AddMsg generateMessage() 060 { 061 return new AddMsg(getCSN(), entry.getName(), 062 EntryHistorical.getEntryUUID(entry), 063 LDAPReplicationDomain.findEntryUUID( 064 entry.getName().getParentDNInSuffix()), 065 entry.getObjectClasses(), 066 entry.getUserAttributes(), entry.getOperationalAttributes()); 067 } 068}