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 2009 Sun Microsystems, Inc.
025 *      Portions copyright 2012 ForgeRock AS
026 */
027
028package org.forgerock.opendj.ldif;
029
030import java.util.List;
031
032import org.forgerock.opendj.ldap.DN;
033import org.forgerock.opendj.ldap.DecodeException;
034import org.forgerock.opendj.ldap.DecodeOptions;
035import org.forgerock.opendj.ldap.controls.Control;
036import org.forgerock.opendj.ldap.controls.ControlDecoder;
037import org.forgerock.opendj.ldap.requests.Request;
038
039/**
040 * A request to modify the content of the Directory in some way. A change record
041 * represents one of the following operations:
042 * <ul>
043 * <li>An {@code Add} operation.
044 * <li>An {@code Delete} operation.
045 * <li>An {@code Modify} operation.
046 * <li>An {@code ModifyDN} operation.
047 * </ul>
048 */
049public interface ChangeRecord extends Request {
050    /**
051     * Applies a {@code ChangeRecordVisitor} to this {@code ChangeRecord}.
052     *
053     * @param <R>
054     *            The return type of the visitor's methods.
055     * @param <P>
056     *            The type of the additional parameters to the visitor's
057     *            methods.
058     * @param v
059     *            The change record visitor.
060     * @param p
061     *            Optional additional visitor parameter.
062     * @return A result as specified by the visitor.
063     */
064    <R, P> R accept(ChangeRecordVisitor<R, P> v, P p);
065
066    /**
067     * Returns the distinguished name of the entry being modified by this
068     * {@code ChangeRecord}.
069     *
070     * @return The distinguished name of the entry being modified.
071     */
072    DN getName();
073
074
075    /*
076     * Uncomment both setName methods when we require JDK7 since JDK6 fails
077     * cannot deal with multiple inheritance of covariant return types
078     * (AddRequest inherits from both ChangeRecord and Entry).
079     *
080     * See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6970851
081     */
082
083    /**
084     * Sets the distinguished name of the entry to be updated. The server shall
085     * not perform any alias dereferencing in determining the object to be
086     * updated.
087     *
088     * @param dn
089     *            The the distinguished name of the entry to be updated.
090     * @return This change record.
091     * @throws UnsupportedOperationException
092     *             If this change record does not permit the distinguished name
093     *             to be set.
094     * @throws NullPointerException
095     *             If {@code dn} was {@code null}.
096     */
097    // ChangeRecord setName(DN dn);
098
099    /**
100     * Sets the distinguished name of the entry to be updated. The server shall
101     * not perform any alias dereferencing in determining the object to be
102     * updated.
103     *
104     * @param dn
105     *            The the distinguished name of the entry to be updated.
106     * @return This change record.
107     * @throws LocalizedIllegalArgumentException
108     *             If {@code dn} could not be decoded using the default schema.
109     * @throws UnsupportedOperationException
110     *             If this change record does not permit the distinguished name
111     *             to be set.
112     * @throws NullPointerException
113     *             If {@code dn} was {@code null}.
114     */
115    // ChangeRecord setName(String dn);
116
117    /** {@inheritDoc} */
118    Request addControl(Control control);
119
120    /** {@inheritDoc} */
121    <C extends Control> C getControl(ControlDecoder<C> decoder, DecodeOptions options)
122            throws DecodeException;
123
124    /** {@inheritDoc} */
125    List<Control> getControls();
126}