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