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
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2006-2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.core;
028    
029    import java.util.List;
030    import java.util.Map;
031    
032    import org.opends.server.types.Attribute;
033    import org.opends.server.types.AttributeType;
034    import org.opends.server.types.ByteString;
035    import org.opends.server.types.DN;
036    import org.opends.server.types.ObjectClass;
037    import org.opends.server.types.Operation;
038    import org.opends.server.types.RawAttribute;
039    
040    /**
041     * This interface defines an operation that may be used to add a new entry to
042     * the Directory Server.
043     */
044    public interface AddOperation extends Operation
045    {
046    
047      /**
048       * Retrieves the DN of the entry to add in a raw, unparsed form as it was
049       * included in the request.  This may or may not actually contain a valid DN,
050       * since no validation will have been performed on it.
051       *
052       * @return  The DN of the entry in a raw, unparsed form.
053       */
054      public abstract ByteString getRawEntryDN();
055    
056      /**
057       * Specifies the raw entry DN for the entry to add.  This should only be
058       * called by pre-parse plugins to alter the DN before it has been processed.
059       * If the entry DN needs to be altered later in the process, then it should
060       * be done using the <CODE>getEntryDN</CODE> and <CODE>setEntryDN</CODE>
061       * methods.
062       *
063       * @param  rawEntryDN  The raw entry DN for the entry to add.
064       */
065      public abstract void setRawEntryDN(ByteString rawEntryDN);
066    
067      /**
068       * Retrieves the DN of the entry to add.  This method should not be called
069       * by pre-parse plugins because the parsed DN will not be available at that
070       * time.
071       *
072       * @return  The DN of the entry to add, or <CODE>null</CODE> if it has not yet
073       *          been parsed from the raw DN.
074       */
075      public abstract DN getEntryDN();
076    
077      /**
078       * Retrieves the set of attributes in their raw, unparsed form as read from
079       * the client request.  Some of these attributes may be invalid as no
080       * validation will have been performed on them.  The returned list must not be
081       * altered by the caller.
082       *
083       * @return  The set of attributes in their raw, unparsed form as read from the
084       *          client request.
085       */
086      public abstract List<RawAttribute> getRawAttributes();
087    
088      /**
089       * Adds the provided attribute to the set of raw attributes for this add
090       * operation.  This should only be called by pre-parse plugins.
091       *
092       * @param  rawAttribute  The attribute to add to the set of raw attributes for
093       *                       this add operation.
094       */
095      public abstract void addRawAttribute(RawAttribute rawAttribute);
096    
097      /**
098       * Replaces the set of raw attributes for this add operation.  This should
099       * only be called by pre-parse plugins.
100       *
101       * @param  rawAttributes  The set of raw attributes for this add operation.
102       */
103      public abstract void setRawAttributes(List<RawAttribute> rawAttributes);
104    
105      /**
106       * Retrieves the set of processed user attributes for the entry to add.  This
107       * should not be called by pre-parse plugins because this information will not
108       * yet be available.  The contents of the returned map may be altered by the
109       * caller.
110       *
111       * @return  The set of processed user attributes for the entry to add, or
112       *          <CODE>null</CODE> if that information is not yet available.
113       */
114      public abstract Map<AttributeType, List<Attribute>> getUserAttributes();
115    
116      /**
117       * Sets the specified attribute in the entry to add, overwriting any existing
118       * attribute of the specified type if necessary.  This should only be called
119       * from pre-operation plugins.  Note that pre-operation plugin processing is
120       * invoked after access control and schema validation, so plugins should be
121       * careful to only make changes that will not violate either schema or access
122       * control rules.
123       *
124       * @param  attributeType  The attribute type for the attribute.
125       * @param  attributeList  The attribute list for the provided attribute type.
126       */
127      public abstract void setAttribute(AttributeType attributeType,
128          List<Attribute> attributeList);
129    
130      /**
131       * Removes the specified attribute from the entry to add. This should only be
132       * called from pre-operation plugins.  Note that pre-operation processing is
133       * invoked after access control and schema validation, so plugins should be
134       * careful to only make changes that will not violate either schema or access
135       * control rules.
136       *
137       * @param  attributeType  The attribute tyep for the attribute to remove.
138       */
139      public abstract void removeAttribute(AttributeType attributeType);
140    
141      /**
142       * Retrieves the change number that has been assigned to this operation.
143       *
144       * @return  The change number that has been assigned to this operation, or -1
145       *          if none has been assigned yet or if there is no applicable
146       *          synchronization mechanism in place that uses change numbers.
147       */
148      public abstract long getChangeNumber();
149    
150      /**
151       * Specifies the change number that has been assigned to this operation by the
152       * synchronization mechanism.
153       *
154       * @param  changeNumber  The change number that has been assigned to this
155       *                       operation by the synchronization mechanism.
156       */
157      public abstract void setChangeNumber(long changeNumber);
158    
159      /**
160       * Retrieves the set of processed objectclasses for the entry to add.  This
161       * should not be called by pre-parse plugins because this information will not
162       * yet be available.  The contents of the returned map may not be altered by
163       * the caller.
164       *
165       * @return  The set of processed objectclasses for the entry to add, or
166       *          <CODE>null</CODE> if that information is not yet available.
167       */
168      public abstract Map<ObjectClass,String> getObjectClasses();
169    
170      /**
171       * Adds the provided objectclass to the entry to add.  This should only be
172       * called from pre-operation plugins.  Note that pre-operation plugin
173       * processing is invoked after access control and schema validation, so
174       * plugins should be careful to only make changes that will not violate either
175       * schema or access control rules.
176       *
177       * @param  objectClass  The objectclass to add to the entry.
178       * @param  name         The name to use for the objectclass.
179       */
180      public abstract void addObjectClass(ObjectClass objectClass, String name);
181    
182      /**
183       * Removes the provided objectclass from the entry to add.  This should only
184       * be called from pre-operation plugins.  Note that pre-operation plugin
185       * processing is invoked after access control and schema validation, so
186       * plugins should be careful to only make changes that will not violate either
187       * schema or access control rules.
188       *
189       * @param  objectClass  The objectclass to remove from the entry.
190       */
191      public abstract void removeObjectClass(ObjectClass objectClass);
192    
193      /**
194       * Retrieves the set of processed operational attributes for the entry to add.
195       * This should not be called by pre-parse plugins because this information
196       * will not yet be available.  The contents of the returned map may be altered
197       * by the caller.
198       *
199       * @return  The set of processed operational attributes for the entry to add,
200       *          or <CODE>null</CODE> if that information is not yet available.
201       */
202      public abstract Map<AttributeType,List<Attribute>> getOperationalAttributes();
203    
204      /**
205       * Retrieves the proxied authorization DN for this operation if proxied
206       * authorization has been requested.
207       *
208       * @return  The proxied authorization DN for this operation if proxied
209       *          authorization has been requested, or {@code null} if proxied
210       *          authorization has not been requested.
211       */
212      public abstract DN getProxiedAuthorizationDN();
213    
214      /**
215       * Set the proxied authorization DN for this operation if proxied
216       * authorization has been requested.
217       *
218       * @param proxiedAuthorizationDN
219       *          The proxied authorization DN for this operation if proxied
220       *          authorization has been requested, or {@code null} if proxied
221       *          authorization has not been requested.
222       */
223      public abstract void setProxiedAuthorizationDN(DN proxiedAuthorizationDN);
224    
225    }