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 ForgeRock AS
026 */
027package org.opends.server.core;
028
029import java.util.List;
030import java.util.Map;
031
032import org.opends.server.types.*;
033import org.forgerock.opendj.ldap.ByteString;
034
035/**
036 * This interface defines an operation that may be used to add a new entry to
037 * the Directory Server.
038 */
039public interface AddOperation extends Operation
040{
041
042  /**
043   * Retrieves the DN of the entry to add in a raw, unparsed form as it was
044   * included in the request.  This may or may not actually contain a valid DN,
045   * since no validation will have been performed on it.
046   *
047   * @return  The DN of the entry in a raw, unparsed form.
048   */
049  ByteString getRawEntryDN();
050
051  /**
052   * Specifies the raw entry DN for the entry to add.  This should only be
053   * called by pre-parse plugins to alter the DN before it has been processed.
054   * If the entry DN needs to be altered later in the process, then it should
055   * be done using the <CODE>getEntryDN</CODE> and <CODE>setEntryDN</CODE>
056   * methods.
057   *
058   * @param  rawEntryDN  The raw entry DN for the entry to add.
059   */
060  void setRawEntryDN(ByteString rawEntryDN);
061
062  /**
063   * Retrieves the DN of the entry to add.  This method should not be called
064   * by pre-parse plugins because the parsed DN will not be available at that
065   * time.
066   *
067   * @return  The DN of the entry to add, or <CODE>null</CODE> if it has not yet
068   *          been parsed from the raw DN.
069   */
070  DN getEntryDN();
071
072  /**
073   * Retrieves the set of attributes in their raw, unparsed form as read from
074   * the client request.  Some of these attributes may be invalid as no
075   * validation will have been performed on them.  The returned list must not be
076   * altered by the caller.
077   *
078   * @return  The set of attributes in their raw, unparsed form as read from the
079   *          client request.
080   */
081  List<RawAttribute> getRawAttributes();
082
083  /**
084   * Adds the provided attribute to the set of raw attributes for this add
085   * operation.  This should only be called by pre-parse plugins.
086   *
087   * @param  rawAttribute  The attribute to add to the set of raw attributes for
088   *                       this add operation.
089   */
090  void addRawAttribute(RawAttribute rawAttribute);
091
092  /**
093   * Replaces the set of raw attributes for this add operation.  This should
094   * only be called by pre-parse plugins.
095   *
096   * @param  rawAttributes  The set of raw attributes for this add operation.
097   */
098  void setRawAttributes(List<RawAttribute> rawAttributes);
099
100  /**
101   * Retrieves the set of processed user attributes for the entry to add.  This
102   * should not be called by pre-parse plugins because this information will not
103   * yet be available.  The contents of the returned map may be altered by the
104   * caller.
105   *
106   * @return  The set of processed user attributes for the entry to add, or
107   *          <CODE>null</CODE> if that information is not yet available.
108   */
109  Map<AttributeType, List<Attribute>> getUserAttributes();
110
111  /**
112   * Sets the specified attribute in the entry to add, overwriting any existing
113   * attribute of the specified type if necessary.  This should only be called
114   * from pre-operation plugins.  Note that pre-operation plugin processing is
115   * invoked after access control and schema validation, so plugins should be
116   * careful to only make changes that will not violate either schema or access
117   * control rules.
118   *
119   * @param  attributeType  The attribute type for the attribute.
120   * @param  attributeList  The attribute list for the provided attribute type.
121   */
122  void setAttribute(AttributeType attributeType, List<Attribute> attributeList);
123
124  /**
125   * Removes the specified attribute from the entry to add. This should only be
126   * called from pre-operation plugins.  Note that pre-operation processing is
127   * invoked after access control and schema validation, so plugins should be
128   * careful to only make changes that will not violate either schema or access
129   * control rules.
130   *
131   * @param  attributeType  The attribute tyep for the attribute to remove.
132   */
133  void removeAttribute(AttributeType attributeType);
134
135  /**
136   * Retrieves the set of processed objectclasses for the entry to add.  This
137   * should not be called by pre-parse plugins because this information will not
138   * yet be available.  The contents of the returned map may not be altered by
139   * the caller.
140   *
141   * @return  The set of processed objectclasses for the entry to add, or
142   *          <CODE>null</CODE> if that information is not yet available.
143   */
144  Map<ObjectClass, String> getObjectClasses();
145
146  /**
147   * Adds the provided objectclass to the entry to add.  This should only be
148   * called from pre-operation plugins.  Note that pre-operation plugin
149   * processing is invoked after access control and schema validation, so
150   * plugins should be careful to only make changes that will not violate either
151   * schema or access control rules.
152   *
153   * @param  objectClass  The objectclass to add to the entry.
154   * @param  name         The name to use for the objectclass.
155   */
156  void addObjectClass(ObjectClass objectClass, String name);
157
158  /**
159   * Removes the provided objectclass from the entry to add.  This should only
160   * be called from pre-operation plugins.  Note that pre-operation plugin
161   * processing is invoked after access control and schema validation, so
162   * plugins should be careful to only make changes that will not violate either
163   * schema or access control rules.
164   *
165   * @param  objectClass  The objectclass to remove from the entry.
166   */
167  void removeObjectClass(ObjectClass objectClass);
168
169  /**
170   * Retrieves the set of processed operational attributes for the entry to add.
171   * This should not be called by pre-parse plugins because this information
172   * will not yet be available.  The contents of the returned map may be altered
173   * by the caller.
174   *
175   * @return  The set of processed operational attributes for the entry to add,
176   *          or <CODE>null</CODE> if that information is not yet available.
177   */
178  Map<AttributeType, List<Attribute>> getOperationalAttributes();
179
180  /**
181   * Retrieves the proxied authorization DN for this operation if proxied
182   * authorization has been requested.
183   *
184   * @return  The proxied authorization DN for this operation if proxied
185   *          authorization has been requested, or {@code null} if proxied
186   *          authorization has not been requested.
187   */
188  DN getProxiedAuthorizationDN();
189
190  /**
191   * Set the proxied authorization DN for this operation if proxied
192   * authorization has been requested.
193   *
194   * @param proxiedAuthorizationDN
195   *          The proxied authorization DN for this operation if proxied
196   *          authorization has been requested, or {@code null} if proxied
197   *          authorization has not been requested.
198   */
199  void setProxiedAuthorizationDN(DN proxiedAuthorizationDN);
200
201}