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