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 2009 Sun Microsystems, Inc.
015 * Portions copyright 2012 ForgeRock AS.
016 */
017
018package org.forgerock.opendj.ldap.requests;
019
020import java.util.List;
021
022import org.forgerock.i18n.LocalizedIllegalArgumentException;
023import org.forgerock.opendj.ldap.DN;
024import org.forgerock.opendj.ldap.DecodeException;
025import org.forgerock.opendj.ldap.DecodeOptions;
026import org.forgerock.opendj.ldap.RDN;
027import org.forgerock.opendj.ldap.controls.Control;
028import org.forgerock.opendj.ldap.controls.ControlDecoder;
029import org.forgerock.opendj.ldif.ChangeRecord;
030import org.forgerock.opendj.ldif.ChangeRecordVisitor;
031
032/**
033 * The Modify DN operation allows a client to change the Relative Distinguished
034 * Name (RDN) of an entry in the Directory and/or to move a subtree of entries
035 * to a new location in the Directory.
036 */
037public interface ModifyDNRequest extends Request, ChangeRecord {
038
039    @Override
040    <R, P> R accept(ChangeRecordVisitor<R, P> v, P p);
041
042    @Override
043    ModifyDNRequest addControl(Control control);
044
045    @Override
046    <C extends Control> C getControl(ControlDecoder<C> decoder, DecodeOptions options)
047            throws DecodeException;
048
049    @Override
050    List<Control> getControls();
051
052    /**
053     * Returns the distinguished name of the entry to be renamed. This entry may
054     * or may not have subordinate entries. The server shall not dereference any
055     * aliases in locating the entry to be renamed.
056     *
057     * @return The distinguished name of the entry.
058     */
059    @Override
060    DN getName();
061
062    /**
063     * Returns the new RDN of the entry to be renamed. The value of the old RDN
064     * is supplied when moving the entry to a new superior without changing its
065     * RDN. Attribute values of the new RDN not matching any attribute value of
066     * the entry are added to the entry, and an appropriate error is returned if
067     * this fails.
068     *
069     * @return The new RDN of the entry.
070     */
071    RDN getNewRDN();
072
073    /**
074     * Returns the distinguished name of an existing entry that will become the
075     * immediate superior (parent) of the entry to be renamed. The server shall
076     * not dereference any aliases in locating the new superior entry. The
077     * default value is {@code null}, indicating that the entry is to remain
078     * under the same parent entry.
079     *
080     * @return The distinguished name of the new superior entry, or {@code null}
081     *         if the entry is to remain under the same parent entry.
082     */
083    DN getNewSuperior();
084
085    /**
086     * Indicates whether the old RDN attribute values are to be retained as
087     * attributes of the entry or deleted from the entry. The default value is
088     * {@code false}.
089     *
090     * @return {@code true} if the old RDN attribute values are to be deleted
091     *         from the entry, or {@code false} if they are to be retained.
092     */
093    boolean isDeleteOldRDN();
094
095    /**
096     * Specifies whether the old RDN attribute values are to be retained as
097     * attributes of the entry or deleted from the entry. The default value is
098     * {@code false}.
099     *
100     * @param deleteOldRDN
101     *            {@code true} if the old RDN attribute values are to be deleted
102     *            from the entry, or {@code false} if they are to be retained.
103     * @return This modify DN request.
104     * @throws UnsupportedOperationException
105     *             If this modify DN request does not permit the delete old RDN
106     *             parameter to be set.
107     */
108    ModifyDNRequest setDeleteOldRDN(boolean deleteOldRDN);
109
110    /**
111     * Sets the distinguished name of the entry to be renamed. This entry may or
112     * may not have subordinate entries. The server shall not dereference any
113     * aliases in locating the entry to be renamed.
114     *
115     * @param dn
116     *            The distinguished name of the entry to be renamed.
117     * @return This modify DN request.
118     * @throws UnsupportedOperationException
119     *             If this modify DN request does not permit the distinguished
120     *             name to be set.
121     * @throws NullPointerException
122     *             If {@code dn} was {@code null}.
123     */
124    ModifyDNRequest setName(DN dn);
125
126    /**
127     * Sets the distinguished name of the entry to be renamed. This entry may or
128     * may not have subordinate entries. The server shall not dereference any
129     * aliases in locating the entry to be renamed.
130     *
131     * @param dn
132     *            The distinguished name of the entry to be renamed.
133     * @return This modify DN request.
134     * @throws LocalizedIllegalArgumentException
135     *             If {@code dn} could not be decoded using the default schema.
136     * @throws UnsupportedOperationException
137     *             If this modify DN request does not permit the distinguished
138     *             name to be set.
139     * @throws NullPointerException
140     *             If {@code dn} was {@code null}.
141     */
142    ModifyDNRequest setName(String dn);
143
144    /**
145     * Sets the new RDN of the entry to be renamed. The value of the old RDN is
146     * supplied when moving the entry to a new superior without changing its
147     * RDN. Attribute values of the new RDN not matching any attribute value of
148     * the entry are added to the entry, and an appropriate error is returned if
149     * this fails.
150     *
151     * @param rdn
152     *            The new RDN of the entry to be renamed.
153     * @return This modify DN request.
154     * @throws UnsupportedOperationException
155     *             If this modify DN request does not permit the new RDN to be
156     *             set.
157     * @throws NullPointerException
158     *             If {@code rdn} was {@code null}.
159     */
160    ModifyDNRequest setNewRDN(RDN rdn);
161
162    /**
163     * Sets the new RDN of the entry to be renamed. The value of the old RDN is
164     * supplied when moving the entry to a new superior without changing its
165     * RDN. Attribute values of the new RDN not matching any attribute value of
166     * the entry are added to the entry, and an appropriate error is returned if
167     * this fails.
168     *
169     * @param rdn
170     *            The new RDN of the entry to be renamed.
171     * @return This modify DN request.
172     * @throws LocalizedIllegalArgumentException
173     *             If {@code rdn} could not be decoded using the default schema.
174     * @throws UnsupportedOperationException
175     *             If this modify DN request does not permit the new RDN to be
176     *             set.
177     * @throws NullPointerException
178     *             If {@code rdn} was {@code null}.
179     */
180    ModifyDNRequest setNewRDN(String rdn);
181
182    /**
183     * Sets the distinguished name of an existing entry that will become the
184     * immediate superior (parent) of the entry to be renamed. The server shall
185     * not dereference any aliases in locating the new superior entry. The
186     * default value is {@code null}, indicating that the entry is to remain
187     * under the same parent entry.
188     *
189     * @param dn
190     *            The distinguished name of an existing entry that will become
191     *            the immediate superior (parent) of the entry to be renamed,
192     *            may be {@code null}.
193     * @return This modify DN request.
194     * @throws UnsupportedOperationException
195     *             If this modify DN request does not permit the new superior to
196     *             be set.
197     */
198    ModifyDNRequest setNewSuperior(DN dn);
199
200    /**
201     * Sets the distinguished name of an existing entry that will become the
202     * immediate superior (parent) of the entry to be renamed. The server shall
203     * not dereference any aliases in locating the new superior entry. The
204     * default value is {@code null}, indicating that the entry is to remain
205     * under the same parent entry.
206     *
207     * @param dn
208     *            The distinguished name of an existing entry that will become
209     *            the immediate superior (parent) of the entry to be renamed,
210     *            may be {@code null}.
211     * @return This modify DN request.
212     * @throws LocalizedIllegalArgumentException
213     *             If {@code dn} could not be decoded using the default schema.
214     * @throws UnsupportedOperationException
215     *             If this modify DN request does not permit the new superior to
216     *             be set.
217     */
218    ModifyDNRequest setNewSuperior(String dn);
219
220}