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-2016 ForgeRock AS.
016 */
017package org.forgerock.opendj.ldif;
018
019import org.forgerock.opendj.ldap.DN;
020import org.forgerock.opendj.ldap.requests.Request;
021
022/**
023 * A request to modify the content of the Directory in some way. A change record
024 * represents one of the following operations:
025 * <ul>
026 * <li>An {@code Add} operation.
027 * <li>An {@code Delete} operation.
028 * <li>An {@code Modify} operation.
029 * <li>An {@code ModifyDN} operation.
030 * </ul>
031 */
032public interface ChangeRecord extends Request {
033    /**
034     * Applies a {@code ChangeRecordVisitor} to this {@code ChangeRecord}.
035     *
036     * @param <R>
037     *            The return type of the visitor's methods.
038     * @param <P>
039     *            The type of the additional parameters to the visitor's
040     *            methods.
041     * @param v
042     *            The change record visitor.
043     * @param p
044     *            Optional additional visitor parameter.
045     * @return A result as specified by the visitor.
046     */
047    <R, P> R accept(ChangeRecordVisitor<R, P> v, P p);
048
049    /**
050     * Returns the distinguished name of the entry being modified by this
051     * {@code ChangeRecord}.
052     *
053     * @return The distinguished name of the entry being modified.
054     */
055    DN getName();
056
057
058    /*
059     * Uncomment both setName methods when we require JDK7 since JDK6 fails
060     * cannot deal with multiple inheritance of covariant return types
061     * (AddRequest inherits from both ChangeRecord and Entry).
062     *
063     * See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6970851
064     */
065
066    /**
067     * Sets the distinguished name of the entry to be updated. The server shall
068     * not perform any alias dereferencing in determining the object to be
069     * updated.
070     *
071     * @param dn
072     *            The the distinguished name of the entry to be updated.
073     * @return This change record.
074     * @throws UnsupportedOperationException
075     *             If this change record does not permit the distinguished name
076     *             to be set.
077     * @throws NullPointerException
078     *             If {@code dn} was {@code null}.
079     */
080    // ChangeRecord setName(DN dn);
081
082    /**
083     * Sets the distinguished name of the entry to be updated. The server shall
084     * not perform any alias dereferencing in determining the object to be
085     * updated.
086     *
087     * @param dn
088     *            The the distinguished name of the entry to be updated.
089     * @return This change record.
090     * @throws LocalizedIllegalArgumentException
091     *             If {@code dn} could not be decoded using the default schema.
092     * @throws UnsupportedOperationException
093     *             If this change record does not permit the distinguished name
094     *             to be set.
095     * @throws NullPointerException
096     *             If {@code dn} was {@code null}.
097     */
098    // ChangeRecord setName(String dn);
099}