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 2006-2008 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2016 ForgeRock AS. 016 */ 017package org.opends.server.util; 018 019import static org.forgerock.util.Reject.*; 020 021import org.forgerock.opendj.ldap.DN; 022import org.forgerock.opendj.ldap.RDN; 023 024 025 026/** 027 * This class defines a data structure for a change record entry for 028 * an modifyDN operation. It includes a DN and a set of attributes, as well as 029 * methods to decode the entry. 030 */ 031@org.opends.server.types.PublicAPI( 032 stability=org.opends.server.types.StabilityLevel.VOLATILE, 033 mayInstantiate=true, 034 mayExtend=false, 035 mayInvoke=true) 036public final class ModifyDNChangeRecordEntry extends ChangeRecordEntry 037{ 038 /** The new RDN. */ 039 private final RDN newRDN; 040 041 /** The new superior DN. */ 042 private final DN newSuperiorDN; 043 044 /** Delete the old RDN? */ 045 private final boolean deleteOldRDN; 046 047 048 /** 049 * Creates a new entry with the provided information. 050 * 051 * @param dn 052 * The distinguished name for this entry. It must not be 053 * <CODE>null</CODE>. 054 * @param newRDN 055 * The new RDN. It must not be <CODE>null</CODE>. 056 * @param deleteOldRDN 057 * Delete the old RDN? 058 * @param newSuperiorDN 059 * The new superior DN. It may be <CODE>null</CODE> if the entry is 060 * not to be moved below a new parent. 061 */ 062 public ModifyDNChangeRecordEntry(DN dn, RDN newRDN, boolean deleteOldRDN, 063 DN newSuperiorDN) 064 { 065 super(dn); 066 067 ifNull(newRDN); 068 069 this.newSuperiorDN = newSuperiorDN; 070 this.newRDN = newRDN; 071 this.deleteOldRDN = deleteOldRDN; 072 } 073 074 075 /** 076 * Get the new RDN for the requested modify DN operation. 077 * 078 * @return the new RDN. 079 * 080 */ 081 public RDN getNewRDN() 082 { 083 return newRDN; 084 } 085 086 087 /** 088 * Get the new superior DN for the requested modify DN operation. 089 * 090 * @return the new superior DN, or <CODE>null</CODE> if there is none. 091 * 092 */ 093 public DN getNewSuperiorDN() 094 { 095 return newSuperiorDN; 096 } 097 098 099 /** 100 * Get the new RDN for the requested modify DN operation. 101 * 102 * @return the new RDN. 103 * 104 */ 105 public boolean deleteOldRDN() 106 { 107 return deleteOldRDN; 108 } 109 110 111 /** 112 * Retrieves the name of the change operation type. 113 * 114 * @return The name of the change operation type. 115 */ 116 public ChangeOperationType getChangeOperationType() 117 { 118 return ChangeOperationType.MODIFY_DN; 119 } 120 121 122 123 /** {@inheritDoc} */ 124 @Override 125 public String toString() 126 { 127 StringBuilder buffer = new StringBuilder(); 128 buffer.append("ModifyDNChangeRecordEntry(dn=\""); 129 buffer.append(getDN()); 130 buffer.append("\", newRDN=\""); 131 buffer.append(newRDN); 132 buffer.append("\", deleteOldRDN="); 133 buffer.append(deleteOldRDN); 134 135 if (newSuperiorDN != null) 136 { 137 buffer.append(", newSuperior=\""); 138 buffer.append(newSuperiorDN); 139 buffer.append("\""); 140 } 141 142 buffer.append(")"); 143 144 return buffer.toString(); 145 } 146} 147