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