mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
28.49.2016 7e87daab4e499538f69fcc44009e6f0e19ec95d6
Code cleanups
17 files modified
264 ■■■■■ changed files
opendj-config/src/main/java/org/forgerock/opendj/config/AggregationPropertyDefinition.java 2 ●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/ConfigurationFramework.java 76 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinitionVisitor.java 2 ●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/PropertyException.java 8 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/PropertyValueVisitor.java 2 ●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/CreateSubCommandHandler.java 10 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java 2 ●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DeleteSubCommandHandler.java 2 ●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/GetPropSubCommandHandler.java 2 ●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/LDAPManagementContextFactory.java 17 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/ListSubCommandHandler.java 2 ●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/SetPropSubCommandHandler.java 2 ●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/server/ConfigExceptionFactory.java 16 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagedObject.java 3 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagementContext.java 7 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/Matcher.java 87 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java 24 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/AggregationPropertyDefinition.java
@@ -258,7 +258,7 @@
                debugLogger.trace("Unable to perform post add", e);
                LocalizableMessage message =
                    ERR_REFINT_UNABLE_TO_EVALUATE_TARGET_CONDITION.get(mo.getManagedObjectDefinition()
                        .getUserFriendlyName(), String.valueOf(mo.getDN()), getExceptionMessage(e));
                        .getUserFriendlyName(), mo.getDN(), getExceptionMessage(e));
                LocalizedLogger logger =
                    LocalizedLogger.getLocalizedLogger(ERR_REFINT_UNABLE_TO_EVALUATE_TARGET_CONDITION.resourceName());
                logger.error(message);
opendj-config/src/main/java/org/forgerock/opendj/config/ConfigurationFramework.java
@@ -253,12 +253,12 @@
        if (loader != null) {
            throw new IllegalStateException("configuration framework already initialized.");
        }
        this.installPath = installPath == null ? System.getenv("INSTALL_ROOT") : installPath;
        this.installPath = installPath != null ? installPath : System.getenv("INSTALL_ROOT");
        if (instancePath != null) {
            this.instancePath = instancePath;
        } else {
            this.instancePath = System.getenv("INSTANCE_ROOT") != null ? System.getenv("INSTANCE_ROOT")
                    : this.installPath;
            String instanceRoot = System.getenv("INSTANCE_ROOT");
            this.instancePath = instanceRoot != null ? instanceRoot : this.installPath;
        }
        this.parent = parent;
        initialize0();
@@ -327,8 +327,7 @@
    private void printExtensionDetails(PrintStream ps, File extension) {
        // retrieve MANIFEST entry and display name, build number and revision number
        try {
            JarFile jarFile = new JarFile(extension);
        try (JarFile jarFile = new JarFile(extension)) {
            JarEntry entry = jarFile.getJarEntry(MANIFEST_RELATIVE_PATH);
            if (entry == null) {
                return;
@@ -502,15 +501,13 @@
        try {
            if (!extensionsPath.exists()) {
                // The extensions directory does not exist. This is not a critical problem.
                adminLogger.warn(WARN_ADMIN_NO_EXTENSIONS_DIR, String.valueOf(extensionsPath));
                adminLogger.warn(WARN_ADMIN_NO_EXTENSIONS_DIR, extensionsPath);
                return;
            }
            if (!extensionsPath.isDirectory()) {
                // The extensions directory is not a directory. This is more critical.
                final LocalizableMessage message =
                        ERR_ADMIN_EXTENSIONS_DIR_NOT_DIRECTORY.get(String.valueOf(extensionsPath));
                throw new ConfigException(message);
                throw new ConfigException(ERR_ADMIN_EXTENSIONS_DIR_NOT_DIRECTORY.get(extensionsPath));
            }
            // Add and initialize the extensions.
@@ -520,9 +517,8 @@
            throw e;
        } catch (final Exception e) {
            debugLogger.trace("Unable to initialize all extensions", e);
            final LocalizableMessage message =
                    ERR_ADMIN_EXTENSIONS_CANNOT_LIST_FILES.get(String.valueOf(extensionsPath),
                            stackTraceToSingleLineString(e, true));
            final LocalizableMessage message = ERR_ADMIN_EXTENSIONS_CANNOT_LIST_FILES.get(
                extensionsPath, stackTraceToSingleLineString(e, true));
            throw new ConfigException(message, e);
        }
    }
@@ -551,17 +547,14 @@
    private void initializeCoreComponents() throws ConfigException {
        final InputStream is = RootCfgDefn.class.getResourceAsStream(MANIFEST_ABSOLUTE_PATH);
        if (is == null) {
            final LocalizableMessage message = ERR_ADMIN_CANNOT_FIND_CORE_MANIFEST.get(MANIFEST_ABSOLUTE_PATH);
            throw new ConfigException(message);
            throw new ConfigException(ERR_ADMIN_CANNOT_FIND_CORE_MANIFEST.get(MANIFEST_ABSOLUTE_PATH));
        }
        try {
            loadDefinitionClasses(is);
        } catch (final ConfigException e) {
            debugLogger.trace("Unable to initialize core components", e);
            final LocalizableMessage message =
                    ERR_CLASS_LOADER_CANNOT_LOAD_CORE.get(MANIFEST_ABSOLUTE_PATH, stackTraceToSingleLineString(e,
                            true));
            throw new ConfigException(message);
            throw new ConfigException(ERR_CLASS_LOADER_CANNOT_LOAD_CORE.get(
                MANIFEST_ABSOLUTE_PATH, stackTraceToSingleLineString(e, true)));
        }
    }
@@ -594,17 +587,15 @@
                loadDefinitionClasses(is);
            } catch (final ConfigException e) {
                debugLogger.trace("Unable to load classes from input stream", e);
                final LocalizableMessage message =
                        ERR_CLASS_LOADER_CANNOT_LOAD_EXTENSION.get(jarFile.getName(), MANIFEST_RELATIVE_PATH,
                                stackTraceToSingleLineString(e, true));
                final LocalizableMessage message = ERR_CLASS_LOADER_CANNOT_LOAD_EXTENSION.get(
                    jarFile.getName(), MANIFEST_RELATIVE_PATH, stackTraceToSingleLineString(e, true));
                throw new ConfigException(message);
            }
            try {
                // Log build information of extensions in the error log
                final String[] information = getBuildInformation(jarFile);
                final LocalizableMessage message =
                        NOTE_LOG_EXTENSION_INFORMATION.get(jarFile.getName(), information[1],
                                information[2]);
                final LocalizableMessage message = NOTE_LOG_EXTENSION_INFORMATION.get(
                    jarFile.getName(), information[1], information[2]);
                LocalizedLogger.getLocalizedLogger(message.resourceName()).info(message);
            } catch (final Exception e) {
                // Do not log information for that extension
@@ -613,16 +604,15 @@
    }
    /**
     * Forcefully load configuration definition classes named in a manifest
     * file.
     * Forcefully load configuration definition classes named in a manifest file.
     *
     * @param is
     *            The manifest file input stream.
     * @throws ConfigException
     *             If the definition classes could not be loaded and
     *             initialized.
     *             If the definition classes could not be loaded and initialized.
     */
    private void loadDefinitionClasses(final InputStream is) throws ConfigException {
        // Cannot use ServiceLoader because constructors are private
        final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        final List<AbstractManagedObjectDefinition<?, ?>> definitions = new LinkedList<>();
        while (true) {
@@ -631,8 +621,7 @@
                className = reader.readLine();
            } catch (final IOException e) {
                final LocalizableMessage msg =
                        ERR_CLASS_LOADER_CANNOT_READ_MANIFEST_FILE.get(String.valueOf(e
                                .getMessage()));
                        ERR_CLASS_LOADER_CANNOT_READ_MANIFEST_FILE.get(e.getMessage());
                throw new ConfigException(msg, e);
            }
@@ -641,14 +630,9 @@
                break;
            }
            // Skip blank lines.
            className = className.trim();
            if (className.length() == 0) {
                continue;
            }
            // Skip lines beginning with #.
            if (className.startsWith("#")) {
            // Skip blank lines or lines beginning with #.
            if (className.isEmpty() || className.startsWith("#")) {
                continue;
            }
@@ -660,20 +644,17 @@
                theClass = Class.forName(className, true, loader);
            } catch (final Exception e) {
                final LocalizableMessage msg =
                        ERR_CLASS_LOADER_CANNOT_LOAD_CLASS.get(className, String.valueOf(e
                                .getMessage()));
                        ERR_CLASS_LOADER_CANNOT_LOAD_CLASS.get(className, e.getMessage());
                throw new ConfigException(msg, e);
            }
            if (AbstractManagedObjectDefinition.class.isAssignableFrom(theClass)) {
                // We need to instantiate it using its getInstance() static
                // method.
                // We need to instantiate it using its getInstance() static method.
                Method method;
                try {
                    method = theClass.getMethod("getInstance");
                } catch (final Exception e) {
                    final LocalizableMessage msg =
                            ERR_CLASS_LOADER_CANNOT_FIND_GET_INSTANCE_METHOD.get(className, String
                                    .valueOf(e.getMessage()));
                            ERR_CLASS_LOADER_CANNOT_FIND_GET_INSTANCE_METHOD.get(className, e.getMessage());
                    throw new ConfigException(msg, e);
                }
@@ -683,8 +664,7 @@
                    d = (AbstractManagedObjectDefinition<?, ?>) method.invoke(null);
                } catch (final Exception e) {
                    final LocalizableMessage msg =
                            ERR_CLASS_LOADER_CANNOT_INVOKE_GET_INSTANCE_METHOD.get(className,
                                    String.valueOf(e.getMessage()));
                            ERR_CLASS_LOADER_CANNOT_INVOKE_GET_INSTANCE_METHOD.get(className, e.getMessage());
                    throw new ConfigException(msg, e);
                }
                definitions.add(d);
@@ -696,9 +676,8 @@
            try {
                d.initialize();
            } catch (final Exception e) {
                final LocalizableMessage msg =
                        ERR_CLASS_LOADER_CANNOT_INITIALIZE_DEFN.get(d.getName(), d.getClass()
                                .getName(), String.valueOf(e.getMessage()));
                final LocalizableMessage msg = ERR_CLASS_LOADER_CANNOT_INITIALIZE_DEFN.get(
                    d.getName(), d.getClass().getName(), e.getMessage());
                throw new ConfigException(msg, e);
            }
        }
@@ -735,5 +714,4 @@
    public String getInstancePath() {
        return instancePath;
    }
}
opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinitionVisitor.java
@@ -245,7 +245,7 @@
     *             Visitor implementations may optionally throw this exception.
     */
    public <T> R visitUnknown(PropertyDefinition<T> pd, P p) {
        throw PropertyException.unknownPropertyDefinitionException(pd, p);
        throw PropertyException.unknownPropertyDefinitionException(pd);
    }
}
opendj-config/src/main/java/org/forgerock/opendj/config/PropertyException.java
@@ -116,12 +116,9 @@
     *
     * @param pd
     *            The unknown property definition.
     * @param p
     *            The visitor parameter if there was one.
     * @return A new unknown property definition exception.
     */
    public static PropertyException unknownPropertyDefinitionException(
            final PropertyDefinition<?> pd, final Object p) {
    public static PropertyException unknownPropertyDefinitionException(final PropertyDefinition<?> pd) {
        return new PropertyException(pd, ERR_UNKNOWN_PROPERTY_DEFINITION_EXCEPTION.get(
                pd.getName(), pd.getClass().getName()));
    }
@@ -130,8 +127,7 @@
    private static LocalizableMessage createMessage(final PropertyDefinition<?> pd,
            final Object value) {
        final PropertyDefinitionUsageBuilder builder = new PropertyDefinitionUsageBuilder(true);
        return ERR_ILLEGAL_PROPERTY_VALUE_EXCEPTION.get(String.valueOf(value), pd.getName(),
                builder.getUsage(pd));
        return ERR_ILLEGAL_PROPERTY_VALUE_EXCEPTION.get(value, pd.getName(), builder.getUsage(pd));
    }
    /** LocalizableMessage that explains the problem. */
opendj-config/src/main/java/org/forgerock/opendj/config/PropertyValueVisitor.java
@@ -278,7 +278,7 @@
     *             Visitor implementations may optionally throw this exception.
     */
    public <T> R visitUnknown(PropertyDefinition<T> pd, T v, P p) {
        throw PropertyException.unknownPropertyDefinitionException(pd, p);
        throw PropertyException.unknownPropertyDefinitionException(pd);
    }
}
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/CreateSubCommandHandler.java
@@ -31,6 +31,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
@@ -963,7 +964,7 @@
        updateCommandBuilderWithSubCommand();
        // Add the child managed object.
        ManagementContext context = factory.getManagementContext(app);
        ManagementContext context = factory.getManagementContext();
        MenuResult<ManagedObject<?>> result;
        try {
            result = getManagedObject(app, context, path, names);
@@ -1288,10 +1289,9 @@
     * @return the type name for the provided ManagedObjectDefinition.
     */
    private String getTypeName(ManagedObjectDefinition<? extends C, ? extends S> d) {
        for (String key : types.keySet()) {
            ManagedObjectDefinition<? extends C, ? extends S> current = types.get(key);
            if (current.equals(d)) {
                return key;
        for (Entry<String, ManagedObjectDefinition<? extends C, ? extends S>> mapEntry : types.entrySet()) {
            if (d.equals(mapEntry.getValue())) {
                return mapEntry.getKey();
            }
        }
        return d.getName();
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DSConfig.java
@@ -1199,7 +1199,7 @@
        try {
            // Force retrieval of management context.
            factory.getManagementContext(app);
            factory.getManagementContext();
        } catch (ArgumentException e) {
            parser.displayMessageAndUsageReference(getErrStream(), e.getMessageObject());
            return ReturnCode.ERROR_USER_DATA.get();
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/DeleteSubCommandHandler.java
@@ -186,7 +186,7 @@
        setCommandBuilderUseful(false);
        // Delete the child managed object.
        ManagementContext context = factory.getManagementContext(app);
        ManagementContext context = factory.getManagementContext();
        MenuResult<ManagedObject<?>> result;
        LocalizableMessage ufn = relation.getUserFriendlyName();
        try {
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/GetPropSubCommandHandler.java
@@ -208,7 +208,7 @@
        // Get the targeted managed object.
        LocalizableMessage ufn = path.getRelationDefinition().getUserFriendlyName();
        ManagementContext context = factory.getManagementContext(app);
        ManagementContext context = factory.getManagementContext();
        MenuResult<ManagedObject<?>> result;
        try {
            result = getManagedObject(app, context, path, names);
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/LDAPManagementContextFactory.java
@@ -21,6 +21,7 @@
import javax.net.ssl.SSLException;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.LDAPProfile;
import org.forgerock.opendj.config.client.ManagementContext;
import org.forgerock.opendj.config.client.ldap.LDAPManagementContext;
@@ -33,7 +34,6 @@
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.CommandBuilder;
import com.forgerock.opendj.cli.ConnectionFactoryProvider;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ReturnCode;
/** An LDAP management context factory for the DSConfig tool. */
@@ -82,15 +82,13 @@
    /**
     * Gets the management context which sub-commands should use in order to manage the directory server.
     *
     * @param app
     *            The console application instance.
     * @return Returns the management context which sub-commands should use in order to manage the directory server.
     * @throws ArgumentException
     *             If a management context related argument could not be parsed successfully.
     * @throws ClientException
     *             If the management context could not be created.
     */
    public ManagementContext getManagementContext(ConsoleApplication app) throws ArgumentException, ClientException {
    public ManagementContext getManagementContext() throws ArgumentException, ClientException {
        // Lazily create the LDAP management context.
        if (context == null) {
            Connection connection;
@@ -100,13 +98,10 @@
                connection = factory.getConnection();
                BuildVersion.checkVersionMismatch(connection);
            } catch (LdapException e) {
                if (e.getCause() instanceof SSLException) {
                    throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR,
                            ERR_FAILED_TO_CONNECT_NOT_TRUSTED.get(hostName, String.valueOf(port)));
                } else {
                    throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR,
                            ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, String.valueOf(port)));
                }
                LocalizableMessage msg = e.getCause() instanceof SSLException
                    ? ERR_FAILED_TO_CONNECT_NOT_TRUSTED.get(hostName, port)
                    : ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, port);
                throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, msg);
            } catch (ConfigException e) {
                throw new ClientException(ReturnCode.ERROR_USER_DATA, e.getMessageObject());
            } catch (Exception ex) {
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/ListSubCommandHandler.java
@@ -203,7 +203,7 @@
        }
        // List the children.
        ManagementContext context = factory.getManagementContext(app);
        ManagementContext context = factory.getManagementContext();
        MenuResult<ManagedObject<?>> result;
        try {
            result = getManagedObject(app, context, path, names);
opendj-config/src/main/java/org/forgerock/opendj/config/dsconfig/SetPropSubCommandHandler.java
@@ -583,7 +583,7 @@
        // Get the targeted managed object.
        LocalizableMessage ufn = path.getRelationDefinition().getUserFriendlyName();
        ManagementContext context = factory.getManagementContext(app);
        ManagementContext context = factory.getManagementContext();
        MenuResult<ManagedObject<?>> result;
        try {
            result = getManagedObject(app, context, path, names);
opendj-config/src/main/java/org/forgerock/opendj/config/server/ConfigExceptionFactory.java
@@ -53,8 +53,8 @@
     * @return Returns the configuration exception.
     */
    public ConfigException createDecodingExceptionAdaptor(DN dn, DefinitionDecodingException e) {
        LocalizableMessage message = ERR_ADMIN_MANAGED_OBJECT_DECODING_PROBLEM.get(String.valueOf(dn),
                stackTraceToSingleLineString(e, true));
        LocalizableMessage message = ERR_ADMIN_MANAGED_OBJECT_DECODING_PROBLEM.get(
                dn, stackTraceToSingleLineString(e, true));
        return new ConfigException(message, e);
    }
@@ -69,8 +69,8 @@
    public ConfigException createDecodingExceptionAdaptor(ServerManagedObjectDecodingException e) {
        DN dn = e.getPartialManagedObject().getDN();
        LocalizableMessage message = ERR_ADMIN_MANAGED_OBJECT_DECODING_PROBLEM.get(String.valueOf(dn),
                stackTraceToSingleLineString(e, true));
        LocalizableMessage message = ERR_ADMIN_MANAGED_OBJECT_DECODING_PROBLEM.get(
                dn, stackTraceToSingleLineString(e, true));
        return new ConfigException(message, e);
    }
@@ -84,8 +84,8 @@
     */
    public ConfigException createDecodingExceptionAdaptor(ConstraintViolationException e) {
        DN dn = e.getManagedObject().getDN();
        LocalizableMessage message = ERR_ADMIN_MANAGED_OBJECT_DECODING_PROBLEM.get(String.valueOf(dn),
                stackTraceToSingleLineString(e, true));
        LocalizableMessage message = ERR_ADMIN_MANAGED_OBJECT_DECODING_PROBLEM.get(
                dn, stackTraceToSingleLineString(e, true));
        return new ConfigException(message, e);
    }
@@ -104,8 +104,8 @@
     */
    public ConfigException createClassLoadingExceptionAdaptor(DN dn, String className, Exception e) {
        LocalizableMessage message = ERR_ADMIN_CANNOT_INSTANTIATE_CLASS.get(String.valueOf(className),
                String.valueOf(dn), stackTraceToSingleLineString(e, true));
        LocalizableMessage message = ERR_ADMIN_CANNOT_INSTANTIATE_CLASS.get(
                className, dn, stackTraceToSingleLineString(e, true));
        return new ConfigException(message, e);
    }
}
opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagedObject.java
@@ -1196,8 +1196,7 @@
        }
        // No parent entry could be found.
        LocalizableMessage message = ERR_ADMIN_UNABLE_TO_REGISTER_LISTENER.get(String.valueOf(baseDN));
        throw new ConfigException(message);
        throw new ConfigException(ERR_ADMIN_UNABLE_TO_REGISTER_LISTENER.get(baseDN));
    }
    /**
opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagementContext.java
@@ -743,16 +743,15 @@
        } catch (ConfigException e) {
            debugLogger.trace("Unable to perform post add", e);
            LocalizableMessage message = ERR_ADMIN_CANNOT_GET_MANAGED_OBJECT.get(String.valueOf(dn),
                    stackTraceToSingleLineString(e, true));
            LocalizableMessage message = ERR_ADMIN_CANNOT_GET_MANAGED_OBJECT.get(
                    dn, stackTraceToSingleLineString(e, true));
            throw new ConfigException(message, e);
        }
        // The configuration handler is free to return null indicating
        // that the entry does not exist.
        if (configEntry == null) {
            LocalizableMessage message = ERR_ADMIN_MANAGED_OBJECT_DOES_NOT_EXIST.get(String.valueOf(dn));
            throw new ConfigException(message);
            throw new ConfigException(ERR_ADMIN_MANAGED_OBJECT_DOES_NOT_EXIST.get(dn));
        }
        return configEntry;
opendj-core/src/main/java/org/forgerock/opendj/ldap/Matcher.java
@@ -29,9 +29,7 @@
import com.forgerock.opendj.util.StaticUtils;
/**
 * An interface for determining whether entries match a {@code Filter}.
 */
/** An interface for determining whether entries match a {@code Filter}. */
public final class Matcher {
    private static final class AndMatcherImpl extends MatcherImpl {
        private final List<MatcherImpl> subMatchers;
@@ -52,17 +50,22 @@
            }
            return r;
        }
        @Override
        public void toString(StringBuilder sb) {
            sb.append("and(");
            for (MatcherImpl subMatcher : subMatchers) {
                subMatcher.toString(sb);
            }
            sb.append(")");
        }
    }
    private static final class AssertionMatcherImpl extends MatcherImpl {
        private final Assertion assertion;
        private final AttributeDescription attributeDescription;
        private final boolean dnAttributes;
        private final MatchingRule rule;
        private final MatchingRuleUse ruleUse;
        private AssertionMatcherImpl(final AttributeDescription attributeDescription,
@@ -130,6 +133,19 @@
            }
            return r;
        }
        @Override
        public void toString(StringBuilder sb) {
            // @Checkstyle:off
            sb.append("assertion(")
              .append("assertion=").append(assertion)
              .append(", attributeDescription=").append(attributeDescription)
              .append(", dnAttributes=").append(dnAttributes)
              .append(", rule=").append(rule)
              .append(", ruleUse=").append(ruleUse)
              .append(")");
            // @Checkstyle:on
        }
    }
    private static class FalseMatcherImpl extends MatcherImpl {
@@ -137,10 +153,24 @@
        public ConditionResult matches(final Entry entry) {
            return ConditionResult.FALSE;
        }
        @Override
        public void toString(StringBuilder sb) {
            sb.append("false");
        }
    }
    private static abstract class MatcherImpl {
        public abstract ConditionResult matches(Entry entry);
        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder();
            toString(sb);
            return sb.toString();
        }
        abstract void toString(StringBuilder sb);
    }
    private static final class NotMatcherImpl extends MatcherImpl {
@@ -154,6 +184,13 @@
        public ConditionResult matches(final Entry entry) {
            return ConditionResult.not(subFilter.matches(entry));
        }
        @Override
        public void toString(StringBuilder sb) {
            sb.append("not(");
            subFilter.toString(sb);
            sb.append(")");
        }
    }
    private static final class OrMatcherImpl extends MatcherImpl {
@@ -175,6 +212,15 @@
            }
            return r;
        }
        @Override
        public void toString(StringBuilder sb) {
            sb.append("or(");
            for (MatcherImpl subMatcher : subMatchers) {
                subMatcher.toString(sb);
            }
            sb.append(")");
        }
    }
    private static final class PresentMatcherImpl extends MatcherImpl {
@@ -186,8 +232,12 @@
        @Override
        public ConditionResult matches(final Entry entry) {
            return entry.getAttribute(attribute) == null ? ConditionResult.FALSE
                    : ConditionResult.TRUE;
            return ConditionResult.valueOf(entry.getAttribute(attribute) != null);
        }
        @Override
        public void toString(StringBuilder sb) {
            sb.append("present(").append(attribute).append(")");
        }
    }
@@ -196,6 +246,11 @@
        public ConditionResult matches(final Entry entry) {
            return ConditionResult.TRUE;
        }
        @Override
        public void toString(StringBuilder sb) {
            sb.append("true");
        }
    }
    private static class UndefinedMatcherImpl extends MatcherImpl {
@@ -203,11 +258,14 @@
        public ConditionResult matches(final Entry entry) {
            return ConditionResult.UNDEFINED;
        }
        @Override
        public void toString(StringBuilder sb) {
            sb.append("undefined");
        }
    }
    /**
     * A visitor which is used to transform a filter into a matcher.
     */
    /** A visitor which is used to transform a filter into a matcher. */
    private static final class Visitor implements FilterVisitor<MatcherImpl, Schema> {
        @Override
        public MatcherImpl visitAndFilter(final Schema schema, final List<Filter> subFilters) {
@@ -564,4 +622,9 @@
    public ConditionResult matches(final Entry entry) {
        return impl.matches(entry);
    }
    @Override
    public String toString() {
        return impl.toString();
    }
}
opendj-core/src/main/java/org/forgerock/opendj/ldap/MemoryBackend.java
@@ -230,7 +230,7 @@
                if (entries.containsKey(dn)) {
                    throw newLdapException(ResultCode.ENTRY_ALREADY_EXISTS, "The entry '" + dn + "' already exists");
                } else if (parent != null && !entries.containsKey(parent)) {
                    noSuchObject(parent);
                    throw noSuchObject(parent);
                } else {
                    entries.put(dn, request);
                }
@@ -585,14 +585,9 @@
    private Entry getRequiredEntry(final Request request, final DN dn) throws LdapException {
        final Entry entry = entries.get(dn);
        if (entry == null) {
            noSuchObject(dn);
        } else if (request != null) {
            AssertionRequestControl control;
            try {
                control = request.getControl(AssertionRequestControl.DECODER, decodeOptions);
            } catch (final DecodeException e) {
                throw newLdapException(ResultCode.PROTOCOL_ERROR, e);
            throw noSuchObject(dn);
            }
        AssertionRequestControl control = decodeAssertionRequestControl(request);
            if (control != null) {
                final Filter filter = control.getFilter();
                final Matcher matcher = filter.matcher(schema);
@@ -601,16 +596,23 @@
                            "The filter '" + filter + "' did not match the entry '" + entry.getName() + "'");
                }
            }
        }
        return entry;
    }
    private AssertionRequestControl decodeAssertionRequestControl(final Request request) throws LdapException {
        try {
            return request != null ? request.getControl(AssertionRequestControl.DECODER, decodeOptions) : null;
        } catch (final DecodeException e) {
            throw newLdapException(ResultCode.PROTOCOL_ERROR, e);
        }
    }
    private Result getResult(final Request request, final Entry before, final Entry after) throws LdapException {
        return addResultControls(request, before, after, newResult(ResultCode.SUCCESS));
    }
    private void noSuchObject(final DN dn) throws LdapException {
        throw newLdapException(ResultCode.NO_SUCH_OBJECT, "The entry '" + dn + "' does not exist");
    private LdapException noSuchObject(final DN dn) {
        return newLdapException(ResultCode.NO_SUCH_OBJECT, "The entry '" + dn + "' does not exist");
    }
    private boolean sendEntry(final AttributeFilter filter,