Package org.opends.server.extensions
Class UserTemplateVirtualAttributeProvider
- java.lang.Object
-
- org.opends.server.api.VirtualAttributeProvider<UserTemplateVirtualAttributeCfg>
-
- org.opends.server.extensions.UserTemplateVirtualAttributeProvider
-
- All Implemented Interfaces:
ConfigurationChangeListener<UserTemplateVirtualAttributeCfg>
public final class UserTemplateVirtualAttributeProvider extends VirtualAttributeProvider<UserTemplateVirtualAttributeCfg> implements ConfigurationChangeListener<UserTemplateVirtualAttributeCfg>
This class implements a virtual attribute provider that allows administrators to define their own virtual attribute with template that will be evaluated by taking the data from the attributes only for the entry that matches the criteria defined in the virtual attribute rule.Note: We will not allow searches based only on user template virtual attributes.
Valid templates:
- With no placeholders:
"No placeholders in template!"
- With placeholders pointing to other entry attributes:
"{uid}@{domain}" : "bjensen@example.com"
- With expression defining default value: "{uid}@{domain|domain.com}"
(if {domain}="example.com") : "bjensen@example.com"
(if no {domain} attribute) : "bjensen@domain.com"
- With reference pointing to a multi-valued attribute :
"This is {cn}" :
cn = 1 : "This is 1"
cn = 2 : "This is 2"
cn = 3 : "This is 3"
- With escaping brace:
"This is \{uid}" : "This is {uid}"
"This is \{uid\}" : "This is {uid\}"
-
-
Constructor Summary
Constructors Constructor Description UserTemplateVirtualAttributeProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigChangeResult
applyConfigurationChange(UserTemplateVirtualAttributeCfg configuration)
Applies the configuration changes to this change listener.void
finalizeVirtualAttributeProvider()
Performs any finalization that may be necessary whenever this virtual attribute provider is taken out of service.Attribute
getAttribute(Entry entry, AttributeDescription attributeDescription)
Generates an unmodifiable attribute with the values for the provided entry.void
initializeVirtualAttributeProvider(UserTemplateVirtualAttributeCfg configuration)
Initializes this virtual attribute based on the information in the provided configuration entry.boolean
isConfigurationAcceptable(UserTemplateVirtualAttributeCfg configuration, List<LocalizableMessage> unacceptableReasons)
Indicates whether the provided configuration is acceptable for this virtual attribute provider.boolean
isConfigurationChangeAcceptable(UserTemplateVirtualAttributeCfg configuration, List<LocalizableMessage> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.boolean
isMultiValued()
Indicates whether this virtual attribute provider may generate multiple values.-
Methods inherited from class org.opends.server.api.VirtualAttributeProvider
getServerContext, initializeVirtualAttributeProvider, isSearchable, processSearch
-
-
-
-
Method Detail
-
initializeVirtualAttributeProvider
public void initializeVirtualAttributeProvider(UserTemplateVirtualAttributeCfg configuration) throws ConfigException
Description copied from class:VirtualAttributeProvider
Initializes this virtual attribute based on the information in the provided configuration entry.- Overrides:
initializeVirtualAttributeProvider
in classVirtualAttributeProvider<UserTemplateVirtualAttributeCfg>
- Parameters:
configuration
- The configuration to use to initialize this virtual attribute provider.- Throws:
ConfigException
- If an unrecoverable problem arises in the process of performing the initialization.
-
isConfigurationAcceptable
public boolean isConfigurationAcceptable(UserTemplateVirtualAttributeCfg configuration, List<LocalizableMessage> unacceptableReasons)
Description copied from class:VirtualAttributeProvider
Indicates whether the provided configuration is acceptable for this virtual attribute provider. It should be possible to call this method on an uninitialized virtual attribute provider instance in order to determine whether the virtual attribute provider would be able to use the provided configuration.- Overrides:
isConfigurationAcceptable
in classVirtualAttributeProvider<UserTemplateVirtualAttributeCfg>
- Parameters:
configuration
- The virtual attribute provider configuration for which to make the determination.unacceptableReasons
- A list that may be used to hold the reasons that the provided configuration is not acceptable.- Returns:
true
if the provided configuration is acceptable for this virtual attribute provider, orfalse
if not.
-
finalizeVirtualAttributeProvider
public void finalizeVirtualAttributeProvider()
Description copied from class:VirtualAttributeProvider
Performs any finalization that may be necessary whenever this virtual attribute provider is taken out of service.- Overrides:
finalizeVirtualAttributeProvider
in classVirtualAttributeProvider<UserTemplateVirtualAttributeCfg>
-
getAttribute
public Attribute getAttribute(Entry entry, AttributeDescription attributeDescription)
Description copied from class:VirtualAttributeProvider
Generates an unmodifiable attribute with the values for the provided entry.- Specified by:
getAttribute
in classVirtualAttributeProvider<UserTemplateVirtualAttributeCfg>
- Parameters:
entry
- The entry for which the values are to be generated.attributeDescription
- the attribute description corresponding to this virtual attribute- Returns:
- The unmodifiable attribute with the values generated for the provided entry. It may be empty, but it must
not be
null
.
-
isMultiValued
public boolean isMultiValued()
Description copied from class:VirtualAttributeProvider
Indicates whether this virtual attribute provider may generate multiple values.- Specified by:
isMultiValued
in classVirtualAttributeProvider<UserTemplateVirtualAttributeCfg>
- Returns:
true
if this virtual attribute provider may generate multiple values, orfalse
if not.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(UserTemplateVirtualAttributeCfg configuration, List<LocalizableMessage> unacceptableReasons)
Description copied from interface:ConfigurationChangeListener
Indicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptable
in interfaceConfigurationChangeListener<UserTemplateVirtualAttributeCfg>
- Parameters:
configuration
- The new configuration containing the changes.unacceptableReasons
- A list that can be used to hold messages about why the provided configuration is not acceptable.- Returns:
- Returns
true
if the proposed change is acceptable, orfalse
if it is not.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(UserTemplateVirtualAttributeCfg configuration)
Description copied from interface:ConfigurationChangeListener
Applies the configuration changes to this change listener.- Specified by:
applyConfigurationChange
in interfaceConfigurationChangeListener<UserTemplateVirtualAttributeCfg>
- Parameters:
configuration
- The new configuration containing the changes.- Returns:
- Returns information about the result of changing the configuration.
-
-