1057N/A/*
1057N/A * CDDL HEADER START
1057N/A *
1057N/A * The contents of this file are subject to the terms of the
1057N/A * Common Development and Distribution License, Version 1.0 only
1057N/A * (the "License"). You may not use this file except in compliance
1057N/A * with the License.
1057N/A *
1057N/A * You can obtain a copy of the license at
1057N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
1057N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
1057N/A * See the License for the specific language governing permissions
1057N/A * and limitations under the License.
1057N/A *
1057N/A * When distributing Covered Code, include this CDDL HEADER in each
1057N/A * file and include the License file at
1057N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
1057N/A * add the following below this CDDL HEADER, with the fields enclosed
1057N/A * by brackets "[]" replaced with your own identifying information:
1057N/A * Portions Copyright [yyyy] [name of copyright owner]
1057N/A *
1057N/A * CDDL HEADER END
1057N/A *
1057N/A *
5065N/A * Copyright 2006-2010 Sun Microsystems, Inc.
5886N/A * Portions Copyright 2012 ForgeRock AS
1057N/A */
1057N/Apackage org.opends.server.extensions;
1057N/A
1057N/A
1057N/A
4114N/Aimport java.util.Collections;
1057N/Aimport java.util.List;
4114N/Aimport java.util.Set;
1057N/A
2334N/Aimport org.opends.messages.Message;
2334N/Aimport org.opends.server.admin.std.server.SubschemaSubentryVirtualAttributeCfg;
1057N/Aimport org.opends.server.api.VirtualAttributeProvider;
1057N/Aimport org.opends.server.config.ConfigException;
1057N/Aimport org.opends.server.core.DirectoryServer;
1057N/Aimport org.opends.server.core.SearchOperation;
4134N/Aimport org.opends.server.types.*;
1057N/A
2086N/Aimport static org.opends.messages.ExtensionMessages.*;
1057N/A
1057N/A
1057N/A
1057N/A/**
1057N/A * This class implements a virtual attribute provider that is meant to serve the
1057N/A * subschemaSubentry operational attribute as described in RFC 4512.
1057N/A */
1057N/Apublic class SubschemaSubentryVirtualAttributeProvider
2334N/A extends VirtualAttributeProvider<SubschemaSubentryVirtualAttributeCfg>
1057N/A{
1057N/A /**
1057N/A * Creates a new instance of this subschemaSubentry virtual attribute
1057N/A * provider.
1057N/A */
1057N/A public SubschemaSubentryVirtualAttributeProvider()
1057N/A {
1057N/A super();
1057N/A
1057N/A // All initialization should be performed in the
1057N/A // initializeVirtualAttributeProvider method.
1057N/A }
1057N/A
1057N/A
1057N/A
1057N/A /**
1057N/A * {@inheritDoc}
1057N/A */
1057N/A @Override()
1057N/A public void initializeVirtualAttributeProvider(
2334N/A SubschemaSubentryVirtualAttributeCfg configuration)
1057N/A throws ConfigException, InitializationException
1057N/A {
1057N/A // No initialization is required.
1057N/A }
1057N/A
1057N/A
1057N/A
1057N/A /**
1057N/A * {@inheritDoc}
1057N/A */
1057N/A @Override()
1057N/A public boolean isMultiValued()
1057N/A {
1057N/A return false;
1057N/A }
1057N/A
1057N/A
1057N/A
1057N/A /**
1057N/A * {@inheritDoc}
1057N/A */
1057N/A @Override()
4114N/A public Set<AttributeValue> getValues(Entry entry,
4114N/A VirtualAttributeRule rule)
1057N/A {
5065N/A DN schemaDN = DirectoryServer.getSchemaDN();
5065N/A if (schemaDN == null)
5065N/A {
5065N/A return Collections.emptySet();
5065N/A }
4114N/A AttributeValue value =
5065N/A AttributeValues.create(rule.getAttributeType(),
5065N/A schemaDN.toString());
4114N/A return Collections.singleton(value);
1057N/A }
1057N/A
1057N/A
1057N/A
1057N/A /**
1057N/A * {@inheritDoc}
1057N/A */
1057N/A @Override()
1057N/A public ConditionResult matchesSubstring(Entry entry,
1057N/A VirtualAttributeRule rule,
1057N/A ByteString subInitial,
1057N/A List<ByteString> subAny,
1057N/A ByteString subFinal)
1057N/A {
1057N/A // DNs cannot be used in substring matching.
1057N/A return ConditionResult.UNDEFINED;
1057N/A }
1057N/A
1057N/A
1057N/A
1057N/A /**
1057N/A * {@inheritDoc}
1057N/A */
1057N/A @Override()
1057N/A public ConditionResult greaterThanOrEqualTo(Entry entry,
1057N/A VirtualAttributeRule rule,
1057N/A AttributeValue value)
1057N/A {
1057N/A // DNs cannot be used in ordering matching.
1057N/A return ConditionResult.UNDEFINED;
1057N/A }
1057N/A
1057N/A
1057N/A
1057N/A /**
1057N/A * {@inheritDoc}
1057N/A */
1057N/A @Override()
1057N/A public ConditionResult lessThanOrEqualTo(Entry entry,
1057N/A VirtualAttributeRule rule,
1057N/A AttributeValue value)
1057N/A {
1057N/A // DNs cannot be used in ordering matching.
1057N/A return ConditionResult.UNDEFINED;
1057N/A }
1057N/A
1057N/A
1057N/A
1057N/A /**
1057N/A * {@inheritDoc}
1057N/A */
1057N/A @Override()
1057N/A public ConditionResult approximatelyEqualTo(Entry entry,
1057N/A VirtualAttributeRule rule,
1057N/A AttributeValue value)
1057N/A {
1057N/A // DNs cannot be used in approximate matching.
1057N/A return ConditionResult.UNDEFINED;
1057N/A }
1057N/A
1057N/A
1057N/A
1057N/A /**
5886N/A * {@inheritDoc}
1057N/A */
1057N/A @Override()
1057N/A public boolean isSearchable(VirtualAttributeRule rule,
5886N/A SearchOperation searchOperation,
5886N/A boolean isPreIndexed)
1057N/A {
1057N/A // This attribute is not searchable, since it will have the same value in
1057N/A // tons of entries.
1057N/A return false;
1057N/A }
1057N/A
1057N/A
1057N/A
1057N/A /**
1057N/A * {@inheritDoc}
1057N/A */
1057N/A @Override()
1057N/A public void processSearch(VirtualAttributeRule rule,
1057N/A SearchOperation searchOperation)
1057N/A {
1057N/A searchOperation.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
1057N/A
4485N/A Message message = ERR_VATTR_NOT_SEARCHABLE.get(
2086N/A rule.getAttributeType().getNameOrOID());
1367N/A searchOperation.appendErrorMessage(message);
1057N/A }
1057N/A}
1057N/A