| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.UUID; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.AttributeValues; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public Set<AttributeValue> getValues(Entry entry, |
| | | VirtualAttributeRule rule) |
| | | public Attribute getValues(Entry entry, VirtualAttributeRule rule) |
| | | { |
| | | String normDNString = entry.getName().toNormalizedString(); |
| | | String uuidString = |
| | | UUID.nameUUIDFromBytes(getBytes(normDNString)).toString(); |
| | | AttributeValue value = AttributeValues.create( |
| | | ByteString.valueOf(uuidString), |
| | | ByteString.valueOf(uuidString)); |
| | | return Collections.singleton(value); |
| | | return Attributes.create(rule.getAttributeType(), uuidString); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | public boolean hasValue(Entry entry, VirtualAttributeRule rule, ByteString value) |
| | | { |
| | | MatchingRule matchingRule = |
| | | rule.getAttributeType().getEqualityMatchingRule(); |
| | |
| | | String uuidString = |
| | | UUID.nameUUIDFromBytes(getBytes(normalizedDN)).toString(); |
| | | |
| | | ByteString normValue = matchingRule.normalizeAttributeValue(value.getValue()); |
| | | ByteString normValue = matchingRule.normalizeAttributeValue(value); |
| | | return uuidString.equals(normValue.toString()); |
| | | } |
| | | catch (Exception e) |
| | |
| | | @Override() |
| | | public ConditionResult greaterThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult lessThanOrEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in ordering matching. |
| | | return ConditionResult.UNDEFINED; |
| | |
| | | @Override() |
| | | public ConditionResult approximatelyEqualTo(Entry entry, |
| | | VirtualAttributeRule rule, |
| | | AttributeValue value) |
| | | ByteString value) |
| | | { |
| | | // DNs cannot be used in approximate matching. |
| | | return ConditionResult.UNDEFINED; |