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-2010 Sun Microsystems, Inc.
025 *      Portions Copyright 2015 ForgeRock AS.
026 */
027package org.opends.server.api.plugin;
028
029import java.util.HashMap;
030import java.util.Map;
031import java.util.Set;
032
033/**
034 * This class defines an enumeration containing the types of plugins
035 * that are supported for use in the Directory Server.
036 */
037@org.opends.server.types.PublicAPI(
038     stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
039     mayInstantiate=false,
040     mayExtend=false,
041     mayInvoke=true)
042public enum PluginType
043{
044  /**
045   * The plugin type for plugins that are invoked when the Directory
046   * Server is starting up.
047   */
048  STARTUP("startup"),
049
050
051
052  /**
053   * The plugin type for plugins that are invoked when the Directory
054   * Server is performing a graceful shutdown.
055   */
056  SHUTDOWN("shutdown"),
057
058
059
060  /**
061   * The plugin type for plugins that are to be invoked whenever a new
062   * client connection is established.
063   */
064  POST_CONNECT("postconnect"),
065
066
067
068  /**
069   * The plugin type for plugins that are to be invoked whenever a
070   * client connection is closed.
071   */
072  POST_DISCONNECT("postdisconnect"),
073
074
075
076  /**
077   * The plugin type for plugins that are to be invoked for each entry
078   * read during an LDIF import.
079   */
080  LDIF_IMPORT("ldifimport"),
081
082
083
084  /**
085   * The plugin type for plugins that are to be invoked for each
086   * import session end.
087   */
088  LDIF_IMPORT_END("ldifimportend"),
089
090
091
092  /**
093   * The plugin type for plugins that are to be invoked for each
094   * import session beginning.
095   */
096  LDIF_IMPORT_BEGIN("ldifimportbegin"),
097
098
099
100  /**
101   * The plugin type for plugins that are to be invoked for each entry
102   * written during an LDIF export.
103   */
104  LDIF_EXPORT("ldifexport"),
105
106
107
108  /**
109   * The plugin type for plugins that are to be invoked before
110   * processing begins on an abandon operation.
111   */
112  PRE_PARSE_ABANDON("preparseabandon"),
113
114
115
116  /**
117   * The plugin type for plugins that are to be invoked before
118   * processing begins on an add operation.
119   */
120  PRE_PARSE_ADD("preparseadd"),
121
122
123
124  /**
125   * The plugin type for plugins that are to be invoked before
126   * processing begins on a bind operation.
127   */
128  PRE_PARSE_BIND("preparsebind"),
129
130
131
132  /**
133   * The plugin type for plugins that are to be invoked before
134   * processing begins on a compare operation.
135   */
136  PRE_PARSE_COMPARE("preparsecompare"),
137
138
139
140  /**
141   * The plugin type for plugins that are to be invoked before
142   * processing begins on a delete operation.
143   */
144  PRE_PARSE_DELETE("preparsedelete"),
145
146
147
148  /**
149   * The plugin type for plugins that are to be invoked before
150   * processing begins on an extended operation.
151   */
152  PRE_PARSE_EXTENDED("preparseextended"),
153
154
155
156  /**
157   * The plugin type for plugins that are to be invoked before
158   * processing begins on a modify operation.
159   */
160  PRE_PARSE_MODIFY("preparsemodify"),
161
162
163
164  /**
165   * The plugin type for plugins that are to be invoked before
166   * processing begins on a modify DN operation.
167   */
168  PRE_PARSE_MODIFY_DN("preparsemodifydn"),
169
170
171
172  /**
173   * The plugin type for plugins that are to be invoked before
174   * processing begins on a search operation.
175   */
176  PRE_PARSE_SEARCH("preparsesearch"),
177
178
179
180  /**
181   * The plugin type for plugins that are to be invoked before
182   * processing begins on an unbind operation.
183   */
184  PRE_PARSE_UNBIND("preparseunbind"),
185
186
187
188  /**
189   * The plugin type for plugins that are to be invoked just before
190   * the core processing for an add operation.
191   */
192  PRE_OPERATION_ADD("preoperationadd"),
193
194
195
196  /**
197   * The plugin type for plugins that are to be invoked just before
198   * the core processing for a bind operation.
199   */
200  PRE_OPERATION_BIND("preoperationbind"),
201
202
203
204  /**
205   * The plugin type for plugins that are to be invoked just before
206   * the core processing for a compare operation.
207   */
208  PRE_OPERATION_COMPARE("preoperationcompare"),
209
210
211
212  /**
213   * The plugin type for plugins that are to be invoked just before
214   * the core processing for a delete operation.
215   */
216  PRE_OPERATION_DELETE("preoperationdelete"),
217
218
219
220  /**
221   * The plugin type for plugins that are to be invoked just before
222   * the core processing for an extended operation.
223   */
224  PRE_OPERATION_EXTENDED("preoperationextended"),
225
226
227
228  /**
229   * The plugin type for plugins that are to be invoked just before
230   * the core processing for a modify operation.
231   */
232  PRE_OPERATION_MODIFY("preoperationmodify"),
233
234
235
236  /**
237   * The plugin type for plugins that are to be invoked just before
238   * the core processing for a modify DN operation.
239   */
240  PRE_OPERATION_MODIFY_DN("preoperationmodifydn"),
241
242
243
244  /**
245   * The plugin type for plugins that are to be invoked just before
246   * the core processing for a search operation.
247   */
248  PRE_OPERATION_SEARCH("preoperationsearch"),
249
250
251
252  /**
253   * The plugin type for plugins that are to be invoked just after the
254   * core processing for an abandon operation.
255   */
256  POST_OPERATION_ABANDON("postoperationabandon"),
257
258
259
260  /**
261   * The plugin type for plugins that are to be invoked just after the
262   * core processing for an add operation.
263   */
264  POST_OPERATION_ADD("postoperationadd"),
265
266
267
268  /**
269   * The plugin type for plugins that are to be invoked just after the
270   * core processing for a bind operation.
271   */
272  POST_OPERATION_BIND("postoperationbind"),
273
274
275
276  /**
277   * The plugin type for plugins that are to be invoked just after the
278   * core processing for a compare operation.
279   */
280  POST_OPERATION_COMPARE("postoperationcompare"),
281
282
283
284  /**
285   * The plugin type for plugins that are to be invoked just after the
286   * core processing for a delete operation.
287   */
288  POST_OPERATION_DELETE("postoperationdelete"),
289
290
291
292  /**
293   * The plugin type for plugins that are to be invoked just after the
294   * core processing for an extended operation.
295   */
296  POST_OPERATION_EXTENDED("postoperationextended"),
297
298
299
300  /**
301   * The plugin type for plugins that are to be invoked just after the
302   * core processing for a modify operation.
303   */
304  POST_OPERATION_MODIFY("postoperationmodify"),
305
306
307
308  /**
309   * The plugin type for plugins that are to be invoked just after the
310   * core processing for a modify DN operation.
311   */
312  POST_OPERATION_MODIFY_DN("postoperationmodifydn"),
313
314
315
316  /**
317   * The plugin type for plugins that are to be invoked just after the
318   * core processing for a search operation.
319   */
320  POST_OPERATION_SEARCH("postoperationsearch"),
321
322
323
324  /**
325   * The plugin type for plugins that are to be invoked just after the
326   * core processing for an unbind operation.
327   */
328  POST_OPERATION_UNBIND("postoperationunbind"),
329
330
331
332  /**
333   * The plugin type for plugins that are to be invoked just after the
334   * response is sent for an add operation.
335   */
336  POST_RESPONSE_ADD("postresponseadd"),
337
338
339
340  /**
341   * The plugin type for plugins that are to be invoked just after the
342   * response is sent for a bind operation.
343   */
344  POST_RESPONSE_BIND("postresponsebind"),
345
346
347
348  /**
349   * The plugin type for plugins that are to be invoked just after the
350   * response is sent for a compare operation.
351   */
352  POST_RESPONSE_COMPARE("postresponsecompare"),
353
354
355
356  /**
357   * The plugin type for plugins that are to be invoked just after the
358   * response is sent for a delete operation.
359   */
360  POST_RESPONSE_DELETE("postresponsedelete"),
361
362
363
364  /**
365   * The plugin type for plugins that are to be invoked just after the
366   * response is sent for an extended operation.
367   */
368  POST_RESPONSE_EXTENDED("postresponseextended"),
369
370
371
372  /**
373   * The plugin type for plugins that are to be invoked just after the
374   * response is sent for a modify operation.
375   */
376  POST_RESPONSE_MODIFY("postresponsemodify"),
377
378
379
380  /**
381   * The plugin type for plugins that are to be invoked just after the
382   * response is sent for a modify DN operation.
383   */
384  POST_RESPONSE_MODIFY_DN("postresponsemodifydn"),
385
386
387
388  /**
389   * The plugin type for plugins that are to be invoked just after the
390   * response is sent for a search operation.
391   */
392  POST_RESPONSE_SEARCH("postresponsesearch"),
393
394
395
396  /**
397   * The plugin type for plugins that are to be invoked just after an
398   * add operation has been completed via synchronization.
399   */
400  POST_SYNCHRONIZATION_ADD("postsynchronizationadd"),
401
402
403
404  /**
405   * The plugin type for plugins that are to be invoked just after a
406   * delete operation has been completed via synchronization.
407   */
408  POST_SYNCHRONIZATION_DELETE(
409       "postsynchronizationdelete"),
410
411
412
413  /**
414   * The plugin type for plugins that are to be invoked just after a
415   * modify operation has been completed via synchronization.
416   */
417  POST_SYNCHRONIZATION_MODIFY(
418       "postsynchronizationmodify"),
419
420
421
422  /**
423   * The plugin type for plugins that are to be invoked just after a
424   * modify DN operation has been completed via synchronization.
425   */
426  POST_SYNCHRONIZATION_MODIFY_DN(
427       "postsynchronizationmodifydn"),
428
429
430
431  /**
432   * The plugin type for plugins that are to be invoked before each
433   * search result entry is sent to a client.
434   */
435  SEARCH_RESULT_ENTRY("searchresultentry"),
436
437
438
439  /**
440   * The plugin type for plugins that are to be invoked before each
441   * search result reference is sent to a client.
442   */
443  SEARCH_RESULT_REFERENCE("searchresultreference"),
444
445
446
447  /**
448   * The plugin type for plugins that are to be invoked on each
449   * subordinate entry that is moved or renamed as part of a modify DN
450   * operation.
451   */
452  SUBORDINATE_MODIFY_DN("subordinatemodifydn"),
453
454
455
456  /**
457   * The plugin type for plugins that are to be invoked on each
458   * subordinate entry that is deleted as part of a subtree
459   * delete operation.
460   */
461  SUBORDINATE_DELETE("subordinatedelete"),
462
463
464
465  /**
466   * The plugin type for plugins that are to be invoked before each
467   * intermediate response message is sent to a client.
468   */
469  INTERMEDIATE_RESPONSE("intermediateresponse");
470
471
472
473  /**
474   * A hash map that relates the plugin type names to the
475   * corresponding plugin type.
476   */
477  private static final Map<String, PluginType> PLUGIN_TYPE_MAP = new HashMap<>(PluginType.values().length);
478  static
479  {
480    for (PluginType type : PluginType.values())
481    {
482      PLUGIN_TYPE_MAP.put(type.name, type);
483    }
484  }
485
486  /** The name for this plugin type. */
487  private String name;
488
489  /**
490   * Creates a new plugin type instance with the specified name.
491   *
492   * @param  name  The name to use for this plugin type.
493   */
494  private PluginType(String name)
495  {
496    this.name = name;
497  }
498
499  /**
500   * Retrieves the name for this plugin type.
501   *
502   * @return  The name for this plugin type.
503   */
504  public String getName()
505  {
506    return name;
507  }
508
509
510
511  /**
512   * Retrieves a string representation of this plugin type.
513   *
514   * @return  A string representation of this plugin type.
515   */
516  @Override
517  public String toString()
518  {
519    return name;
520  }
521
522
523
524  /**
525   * Retrieves a hash set containing the names of all the plugin
526   * types.
527   *
528   * @return  A hash set containing the names of all the plugin types.
529   */
530  public static Set<String> getPluginTypeNames()
531  {
532    return PLUGIN_TYPE_MAP.keySet();
533  }
534
535
536
537  /**
538   * Retrieves the plugin type for the plugin with the specified name.
539   *
540   * @param  lowerName  The name of the plugin type to retrieve,
541   *                    formatted in all lowercase characters.
542   *
543   * @return  The requested plugin type, or {@code null} if there is
544   *          no type for the provided name.
545   */
546  public static PluginType forName(String lowerName)
547  {
548    return PLUGIN_TYPE_MAP.get(lowerName);
549  }
550}
551