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
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2006-2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.util;
028
029 import static org.opends.server.util.Validator.*;
030
031 import org.opends.server.types.DN;
032 import 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)
046 public 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 ensureNotNull(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 /**
134 * {@inheritDoc}
135 */
136 @Override()
137 public String toString()
138 {
139 StringBuilder buffer = new StringBuilder();
140 buffer.append("ModifyDNChangeRecordEntry(dn=\"");
141 buffer.append(String.valueOf(getDN()));
142 buffer.append("\", newRDN=\"");
143 buffer.append(String.valueOf(newRDN));
144 buffer.append("\", deleteOldRDN=");
145 buffer.append(deleteOldRDN);
146
147 if (newSuperiorDN != null)
148 {
149 buffer.append(", newSuperior=\"");
150 newSuperiorDN.toString(buffer);
151 buffer.append("\"");
152 }
153
154 buffer.append(")");
155
156 return buffer.toString();
157 }
158 }
159