boolean adminActionRequired = false;
ArrayList<Message> messages = new ArrayList<Message>();
// Get the existing rule if it's already enabled.
VirtualAttributeRule existingRule = rules.get(configuration.dn());
// If the new configuration has the rule disabled, then disable it if it
// is enabled, or do nothing if it's already disabled.
if (! configuration.isEnabled())
{
if (existingRule != null)
{
rules.remove(configuration.dn());
DirectoryServer.deregisterVirtualAttribute(existingRule);
existingRule.getProvider().finalizeVirtualAttributeProvider();
}
return new ConfigChangeResult(resultCode, adminActionRequired, messages);
}
// Make sure that we can parse all of the search filters.
LinkedHashSet<SearchFilter> filters =
new LinkedHashSet<SearchFilter>();
for (String filterString : configuration.getFilter())
{
try
{
filters.add(SearchFilter.createFilterFromString(filterString));
}
catch (DirectoryException de)
{
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, de);
}
if (resultCode == ResultCode.SUCCESS)
{
resultCode = ResultCode.INVALID_ATTRIBUTE_SYNTAX;
}
Message message = ERR_CONFIG_VATTR_INVALID_SEARCH_FILTER.get(
filterString,
String.valueOf(configuration.dn()),
de.getMessageObject());
messages.add(message);
}
}
// Get the name of the class and make sure we can instantiate it as a
// certificate mapper.
VirtualAttributeProvider<? extends VirtualAttributeCfg> provider = null;
if (resultCode == ResultCode.SUCCESS)
{
String className = configuration.getJavaClass();
try
{
provider = loadProvider(className, configuration, true);
}
catch (InitializationException ie)
{
resultCode = DirectoryServer.getServerErrorResultCode();
messages.add(ie.getMessageObject());
}
}
if (resultCode == ResultCode.SUCCESS)
{
VirtualAttributeRule rule =
new VirtualAttributeRule(configuration.getAttributeType(), provider,
configuration.getBaseDN(),
configuration.getGroupDN(),
filters,
configuration.getConflictBehavior());