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 2006-2008 Sun Microsystems, Inc. 025 * Portions copyright 2012-2015 ForgeRock AS 026 */ 027package org.opends.server.replication.plugin; 028 029import java.util.ArrayList; 030import java.util.List; 031 032import org.opends.server.replication.common.CSN; 033import org.opends.server.replication.protocol.ModifyMsg; 034import org.opends.server.replication.protocol.ReplicationMsg; 035import org.opends.server.types.DN; 036import org.opends.server.types.Modification; 037 038/** 039 * This class if used to build fake Modify Operation from the historical 040 * information that stay in the entry in the database. 041 * 042 * This is useful when a LDAP server can't find a LDAP server that 043 * has already seen all its changes and therefore need to retransmit them. 044 */ 045public class FakeModifyOperation extends FakeOperation 046{ 047 private List<Modification> mods = new ArrayList<>(); 048 private DN dn; 049 private String entryuuid; 050 051 /** 052 * Creates a new ModifyFakeOperation with the provided information. 053 * 054 * @param dn The DN on which the Operation was applied. 055 * @param csn The CSN of the operation. 056 * @param entryuuid The unique ID of the entry on which the Operation applies. 057 */ 058 public FakeModifyOperation(DN dn, CSN csn, String entryuuid) 059 { 060 super(csn); 061 this.dn = dn; 062 this.entryuuid = entryuuid; 063 } 064 065 /** 066 * Add a modification to the list of modification included 067 * in this fake operation. 068 * 069 * @param mod A modification that must be added to the list of modifications 070 * included in this fake operation. 071 */ 072 public void addModification(Modification mod) 073 { 074 mods.add(mod); 075 } 076 077 /** {@inheritDoc} */ 078 @Override 079 public ReplicationMsg generateMessage() 080 { 081 return new ModifyMsg(getCSN(), dn, mods, entryuuid); 082 } 083}