/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2012-2015 ForgeRock AS
*/
/**
* This class is a factory class for Collation matching rules. It
* creates different matching rules based on the configuration entries.
*/
public final class CollationMatchingRuleFactory extends
MatchingRuleFactory<CollationMatchingRuleCfg> implements
{
/** Stores the list of available locales on this JVM. */
private static final Set<Locale> supportedLocales = CollectionUtils.newHashSet(Locale.getAvailableLocales());
/** Current Configuration. */
/** Map of OID and the Matching Rule. */
/** Creates a new instance of CollationMatchingRuleFactory. */
public CollationMatchingRuleFactory()
{
super();
}
/** {@inheritDoc} */
{
}
/**
* Adds a new mapping of OID and MatchingRule.
*
* @param oid
* OID of the matching rule
* @param matchingRule
* instance of a MatchingRule.
*/
{
}
/**
* Clears the Map containing matching Rules.
*/
private void resetRules()
{
}
/** {@inheritDoc} */
{
{
{
continue;
}
{
try
{
for (int suffix : numericSuffixes)
{
}
// the default (equality) matching rule
}
catch (Exception e)
{
logger.error(LocalizableMessage.raw("Error when adding a collation matching rule with oid %s, tag %s: %s",
}
}
else
{
// This locale is not supported by JVM.
}
}
// Save this configuration.
// Register for change events.
}
/** {@inheritDoc} */
public void finalizeMatchingRule()
{
// De-register the listener.
}
/** {@inheritDoc} */
{
if (!configuration.isEnabled()
{
// Don't do anything if:
// 1. The configuration is disabled.
// 2. There is a change in the enable status
// i.e. (disable->enable or enable->disable). In this case, the
// ConfigManager will have already created the new Factory object.
return ccr;
}
// Since we have come here it means that this Factory is enabled and
// there is a change in the CollationMatchingRuleFactory's
// configuration.
// Deregister all the Matching Rule corresponding to this factory.
{
}
// Clear the associated matching rules.
resetRules();
{
// validation has already been performed in isConfigurationChangeAcceptable()
}
try
{
{
}
}
catch (DirectoryException de)
{
ccr.setAdminActionRequired(true);
}
return ccr;
}
/** {@inheritDoc} */
public boolean isConfigurationChangeAcceptable(
{
boolean configAcceptable = true;
// If the new configuration disables this factory, don't do
// anything.
if (!configuration.isEnabled())
{
return configAcceptable;
}
// If it comes here we don't need to verify MatchingRuleType; it
// should be okay as its syntax is verified by the admin framework.
// Iterate over the collations and verify if the format is okay.
// Also, verify if the locale is allowed by the JVM.
{
{
configAcceptable = false;
continue;
}
{
configAcceptable = false;
continue;
}
}
return configAcceptable;
}
/**
* Verifies if the locale is supported by the JVM.
*
* @param lTag
* The language tag specified in the configuration.
* @return Locale The locale corresponding to the languageTag.
*/
{
// Separates the language and the country from the locale.
if (countryIndex > 0)
{
if (variantIndex > countryIndex)
{
}
else
{
}
}
else
{
}
{
// This locale is not supported by this JVM.
}
return locale;
}
/**
* A utility class for extracting the OID and Language Tag from the
* configuration entry.
*/
private final class CollationMapper
{
/** OID of the collation rule. */
/** Language Tag. */
/**
* Creates a new instance of CollationMapper.
*
* @param collation
* The collation text in the LOCALE:OID format.
*/
{
if (index > 0)
{
}
}
/**
* Returns the OID part of the collation text.
*
* @return OID part of the collation text.
*/
{
return oid;
}
/**
* Returns the language Tag of collation text.
*
* @return Language Tag part of the collation text.
*/
{
return lTag;
}
}
}