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 2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.admin.std.meta;
028
029
030
031 import java.util.Collection;
032 import java.util.SortedSet;
033 import org.opends.server.admin.AdministratorAction;
034 import org.opends.server.admin.BooleanPropertyDefinition;
035 import org.opends.server.admin.ClassPropertyDefinition;
036 import org.opends.server.admin.client.AuthorizationException;
037 import org.opends.server.admin.client.CommunicationException;
038 import org.opends.server.admin.client.ConcurrentModificationException;
039 import org.opends.server.admin.client.ManagedObject;
040 import org.opends.server.admin.client.MissingMandatoryPropertiesException;
041 import org.opends.server.admin.client.OperationRejectedException;
042 import org.opends.server.admin.DefaultBehaviorProvider;
043 import org.opends.server.admin.DefinedDefaultBehaviorProvider;
044 import org.opends.server.admin.EnumPropertyDefinition;
045 import org.opends.server.admin.ManagedObjectAlreadyExistsException;
046 import org.opends.server.admin.ManagedObjectDefinition;
047 import org.opends.server.admin.PropertyOption;
048 import org.opends.server.admin.PropertyProvider;
049 import org.opends.server.admin.server.ConfigurationChangeListener;
050 import org.opends.server.admin.server.ServerManagedObject;
051 import org.opends.server.admin.std.client.LDAPAttributeDescriptionListPluginCfgClient;
052 import org.opends.server.admin.std.meta.PluginCfgDefn.PluginType;
053 import org.opends.server.admin.std.server.LDAPAttributeDescriptionListPluginCfg;
054 import org.opends.server.admin.std.server.PluginCfg;
055 import org.opends.server.admin.Tag;
056 import org.opends.server.types.DN;
057
058
059
060 /**
061 * An interface for querying the LDAP Attribute Description List
062 * Plugin managed object definition meta information.
063 * <p>
064 * The LDAP Attribute Description List Plugin provides the ability for
065 * clients to include an attribute list in a search request that names
066 * object classes instead of (or in addition to) attributes.
067 */
068 public final class LDAPAttributeDescriptionListPluginCfgDefn extends ManagedObjectDefinition<LDAPAttributeDescriptionListPluginCfgClient, LDAPAttributeDescriptionListPluginCfg> {
069
070 // The singleton configuration definition instance.
071 private static final LDAPAttributeDescriptionListPluginCfgDefn INSTANCE = new LDAPAttributeDescriptionListPluginCfgDefn();
072
073
074
075 // The "java-class" property definition.
076 private static final ClassPropertyDefinition PD_JAVA_CLASS;
077
078
079
080 // The "plugin-type" property definition.
081 private static final EnumPropertyDefinition<PluginType> PD_PLUGIN_TYPE;
082
083
084
085 // Build the "java-class" property definition.
086 static {
087 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
088 builder.setOption(PropertyOption.MANDATORY);
089 builder.setOption(PropertyOption.ADVANCED);
090 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class"));
091 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.plugins.LDAPADListPlugin");
092 builder.setDefaultBehaviorProvider(provider);
093 builder.addInstanceOf("org.opends.server.api.plugin.DirectoryServerPlugin");
094 PD_JAVA_CLASS = builder.getInstance();
095 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
096 }
097
098
099
100 // Build the "plugin-type" property definition.
101 static {
102 EnumPropertyDefinition.Builder<PluginType> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "plugin-type");
103 builder.setOption(PropertyOption.MULTI_VALUED);
104 builder.setOption(PropertyOption.MANDATORY);
105 builder.setOption(PropertyOption.ADVANCED);
106 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "plugin-type"));
107 DefaultBehaviorProvider<PluginType> provider = new DefinedDefaultBehaviorProvider<PluginType>("preparsesearch");
108 builder.setDefaultBehaviorProvider(provider);
109 builder.setEnumClass(PluginType.class);
110 PD_PLUGIN_TYPE = builder.getInstance();
111 INSTANCE.registerPropertyDefinition(PD_PLUGIN_TYPE);
112 }
113
114
115
116 // Register the tags associated with this managed object definition.
117 static {
118 INSTANCE.registerTag(Tag.valueOf("core-server"));
119 }
120
121
122
123 /**
124 * Get the LDAP Attribute Description List Plugin configuration
125 * definition singleton.
126 *
127 * @return Returns the LDAP Attribute Description List Plugin
128 * configuration definition singleton.
129 */
130 public static LDAPAttributeDescriptionListPluginCfgDefn getInstance() {
131 return INSTANCE;
132 }
133
134
135
136 /**
137 * Private constructor.
138 */
139 private LDAPAttributeDescriptionListPluginCfgDefn() {
140 super("ldap-attribute-description-list-plugin", PluginCfgDefn.getInstance());
141 }
142
143
144
145 /**
146 * {@inheritDoc}
147 */
148 public LDAPAttributeDescriptionListPluginCfgClient createClientConfiguration(
149 ManagedObject<? extends LDAPAttributeDescriptionListPluginCfgClient> impl) {
150 return new LDAPAttributeDescriptionListPluginCfgClientImpl(impl);
151 }
152
153
154
155 /**
156 * {@inheritDoc}
157 */
158 public LDAPAttributeDescriptionListPluginCfg createServerConfiguration(
159 ServerManagedObject<? extends LDAPAttributeDescriptionListPluginCfg> impl) {
160 return new LDAPAttributeDescriptionListPluginCfgServerImpl(impl);
161 }
162
163
164
165 /**
166 * {@inheritDoc}
167 */
168 public Class<LDAPAttributeDescriptionListPluginCfg> getServerConfigurationClass() {
169 return LDAPAttributeDescriptionListPluginCfg.class;
170 }
171
172
173
174 /**
175 * Get the "enabled" property definition.
176 * <p>
177 * Indicates whether the plug-in is enabled for use.
178 *
179 * @return Returns the "enabled" property definition.
180 */
181 public BooleanPropertyDefinition getEnabledPropertyDefinition() {
182 return PluginCfgDefn.getInstance().getEnabledPropertyDefinition();
183 }
184
185
186
187 /**
188 * Get the "invoke-for-internal-operations" property definition.
189 * <p>
190 * Indicates whether the plug-in should be invoked for internal
191 * operations.
192 * <p>
193 * Any plug-in that can be invoked for internal operations must
194 * ensure that it does not create any new internal operatons that can
195 * cause the same plug-in to be re-invoked.
196 *
197 * @return Returns the "invoke-for-internal-operations" property definition.
198 */
199 public BooleanPropertyDefinition getInvokeForInternalOperationsPropertyDefinition() {
200 return PluginCfgDefn.getInstance().getInvokeForInternalOperationsPropertyDefinition();
201 }
202
203
204
205 /**
206 * Get the "java-class" property definition.
207 * <p>
208 * Specifies the fully-qualified name of the Java class that
209 * provides the plug-in implementation.
210 *
211 * @return Returns the "java-class" property definition.
212 */
213 public ClassPropertyDefinition getJavaClassPropertyDefinition() {
214 return PD_JAVA_CLASS;
215 }
216
217
218
219 /**
220 * Get the "plugin-type" property definition.
221 * <p>
222 * Specifies the set of plug-in types for the plug-in, which
223 * specifies the times at which the plug-in is invoked.
224 *
225 * @return Returns the "plugin-type" property definition.
226 */
227 public EnumPropertyDefinition<PluginType> getPluginTypePropertyDefinition() {
228 return PD_PLUGIN_TYPE;
229 }
230
231
232
233 /**
234 * Managed object client implementation.
235 */
236 private static class LDAPAttributeDescriptionListPluginCfgClientImpl implements
237 LDAPAttributeDescriptionListPluginCfgClient {
238
239 // Private implementation.
240 private ManagedObject<? extends LDAPAttributeDescriptionListPluginCfgClient> impl;
241
242
243
244 // Private constructor.
245 private LDAPAttributeDescriptionListPluginCfgClientImpl(
246 ManagedObject<? extends LDAPAttributeDescriptionListPluginCfgClient> impl) {
247 this.impl = impl;
248 }
249
250
251
252 /**
253 * {@inheritDoc}
254 */
255 public Boolean isEnabled() {
256 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
257 }
258
259
260
261 /**
262 * {@inheritDoc}
263 */
264 public void setEnabled(boolean value) {
265 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
266 }
267
268
269
270 /**
271 * {@inheritDoc}
272 */
273 public boolean isInvokeForInternalOperations() {
274 return impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition());
275 }
276
277
278
279 /**
280 * {@inheritDoc}
281 */
282 public void setInvokeForInternalOperations(Boolean value) {
283 impl.setPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition(), value);
284 }
285
286
287
288 /**
289 * {@inheritDoc}
290 */
291 public String getJavaClass() {
292 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
293 }
294
295
296
297 /**
298 * {@inheritDoc}
299 */
300 public void setJavaClass(String value) {
301 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
302 }
303
304
305
306 /**
307 * {@inheritDoc}
308 */
309 public SortedSet<PluginType> getPluginType() {
310 return impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition());
311 }
312
313
314
315 /**
316 * {@inheritDoc}
317 */
318 public void setPluginType(Collection<PluginType> values) {
319 impl.setPropertyValues(INSTANCE.getPluginTypePropertyDefinition(), values);
320 }
321
322
323
324 /**
325 * {@inheritDoc}
326 */
327 public ManagedObjectDefinition<? extends LDAPAttributeDescriptionListPluginCfgClient, ? extends LDAPAttributeDescriptionListPluginCfg> definition() {
328 return INSTANCE;
329 }
330
331
332
333 /**
334 * {@inheritDoc}
335 */
336 public PropertyProvider properties() {
337 return impl;
338 }
339
340
341
342 /**
343 * {@inheritDoc}
344 */
345 public void commit() throws ManagedObjectAlreadyExistsException,
346 MissingMandatoryPropertiesException, ConcurrentModificationException,
347 OperationRejectedException, AuthorizationException,
348 CommunicationException {
349 impl.commit();
350 }
351
352 }
353
354
355
356 /**
357 * Managed object server implementation.
358 */
359 private static class LDAPAttributeDescriptionListPluginCfgServerImpl implements
360 LDAPAttributeDescriptionListPluginCfg {
361
362 // Private implementation.
363 private ServerManagedObject<? extends LDAPAttributeDescriptionListPluginCfg> impl;
364
365 // The value of the "enabled" property.
366 private final boolean pEnabled;
367
368 // The value of the "invoke-for-internal-operations" property.
369 private final boolean pInvokeForInternalOperations;
370
371 // The value of the "java-class" property.
372 private final String pJavaClass;
373
374 // The value of the "plugin-type" property.
375 private final SortedSet<PluginType> pPluginType;
376
377
378
379 // Private constructor.
380 private LDAPAttributeDescriptionListPluginCfgServerImpl(ServerManagedObject<? extends LDAPAttributeDescriptionListPluginCfg> impl) {
381 this.impl = impl;
382 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
383 this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition());
384 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
385 this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition());
386 }
387
388
389
390 /**
391 * {@inheritDoc}
392 */
393 public void addLDAPAttributeDescriptionListChangeListener(
394 ConfigurationChangeListener<LDAPAttributeDescriptionListPluginCfg> listener) {
395 impl.registerChangeListener(listener);
396 }
397
398
399
400 /**
401 * {@inheritDoc}
402 */
403 public void removeLDAPAttributeDescriptionListChangeListener(
404 ConfigurationChangeListener<LDAPAttributeDescriptionListPluginCfg> listener) {
405 impl.deregisterChangeListener(listener);
406 }
407 /**
408 * {@inheritDoc}
409 */
410 public void addChangeListener(
411 ConfigurationChangeListener<PluginCfg> listener) {
412 impl.registerChangeListener(listener);
413 }
414
415
416
417 /**
418 * {@inheritDoc}
419 */
420 public void removeChangeListener(
421 ConfigurationChangeListener<PluginCfg> listener) {
422 impl.deregisterChangeListener(listener);
423 }
424
425
426
427 /**
428 * {@inheritDoc}
429 */
430 public boolean isEnabled() {
431 return pEnabled;
432 }
433
434
435
436 /**
437 * {@inheritDoc}
438 */
439 public boolean isInvokeForInternalOperations() {
440 return pInvokeForInternalOperations;
441 }
442
443
444
445 /**
446 * {@inheritDoc}
447 */
448 public String getJavaClass() {
449 return pJavaClass;
450 }
451
452
453
454 /**
455 * {@inheritDoc}
456 */
457 public SortedSet<PluginType> getPluginType() {
458 return pPluginType;
459 }
460
461
462
463 /**
464 * {@inheritDoc}
465 */
466 public Class<? extends LDAPAttributeDescriptionListPluginCfg> configurationClass() {
467 return LDAPAttributeDescriptionListPluginCfg.class;
468 }
469
470
471
472 /**
473 * {@inheritDoc}
474 */
475 public DN dn() {
476 return impl.getDN();
477 }
478
479 }
480 }