| | |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.plugins; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.meta.PluginCfgDefn; |
| | | import org.opends.server.admin.std.server.LastModPluginCfg; |
| | | import org.opends.server.admin.std.server.PluginCfg; |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.api.plugin.PreOperationPluginResult; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.ByteStringFactory; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | |
| | | import org.opends.server.types.operation.PreOperationModifyOperation; |
| | | import org.opends.server.types.operation.PreOperationModifyDNOperation; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.messages.PluginMessages.*; |
| | | |
| | | import static org.opends.server.util.TimeThread.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import static org.opends.server.util.TimeThread.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class implements a Directory Server plugin that will add the |
| | |
| | | * whenever the entry is modified or renamed. |
| | | */ |
| | | public final class LastModPlugin |
| | | extends DirectoryServerPlugin<PluginCfg> |
| | | implements ConfigurationChangeListener<PluginCfg> |
| | | extends DirectoryServerPlugin<LastModPluginCfg> |
| | | implements ConfigurationChangeListener<LastModPluginCfg> |
| | | { |
| | | /** |
| | | * The tracer object for the debug logger. |
| | |
| | | // The attribute type for the "modifyTimestamp" attribute. |
| | | private final AttributeType modifyTimestampType; |
| | | |
| | | // The current configuration for this plugin. |
| | | private LastModPluginCfg currentConfig; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | super(); |
| | | |
| | | |
| | | |
| | | // Get the attribute types for the attributes that we will use. This needs |
| | | // to be done in the constructor in order to make the associated variables |
| | | // "final". |
| | |
| | | */ |
| | | @Override() |
| | | public final void initializePlugin(Set<PluginType> pluginTypes, |
| | | PluginCfg configuration) |
| | | LastModPluginCfg configuration) |
| | | throws ConfigException |
| | | { |
| | | configuration.addChangeListener(this); |
| | | currentConfig = configuration; |
| | | configuration.addLastModChangeListener(this); |
| | | |
| | | // Make sure that the plugin has been enabled for the appropriate types. |
| | | for (PluginType t : pluginTypes) |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public final void finalizePlugin() |
| | | { |
| | | currentConfig.removeLastModChangeListener(this); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override() |
| | | public final PreOperationPluginResult |
| | | doPreOperation(PreOperationAddOperation addOperation) |
| | | { |
| | |
| | | public boolean isConfigurationAcceptable(PluginCfg configuration, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | return isConfigurationChangeAcceptable(configuration, unacceptableReasons); |
| | | LastModPluginCfg cfg = (LastModPluginCfg) configuration; |
| | | return isConfigurationChangeAcceptable(cfg, unacceptableReasons); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable(PluginCfg configuration, |
| | | public boolean isConfigurationChangeAcceptable(LastModPluginCfg configuration, |
| | | List<Message> unacceptableReasons) |
| | | { |
| | | boolean configAcceptable = true; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange(PluginCfg configuration) |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | LastModPluginCfg configuration) |
| | | { |
| | | // No implementation is required. |
| | | currentConfig = configuration; |
| | | return new ConfigChangeResult(ResultCode.SUCCESS, false); |
| | | } |
| | | } |