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