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

Matthew Swift
16.34.2014 594c090e932966e1e41f70bd69d746556eaea99d
Removed some classes and methods:

* AciException: replace with LocalizedIllegalArgumentException
* IdentifiedException/OpenDsException: not needed since functionality is replaced with LocalizedException
* InitializationException: removed and replaced use with ConfigException (TODO: should consider renaming ConfigException to something more generic, like ServerException)
* DirectoryException/LDAPException: not used, so removed
* Removed unused ObjectClass methods in DirectoryServer.
6 files deleted
7 files modified
897 ■■■■■ changed files
opendj-config/src/main/java/org/forgerock/opendj/config/ACIPropertyDefinition.java 5 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/AdminException.java 15 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/ClassLoaderProvider.java 70 ●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/server/ConfigException.java 2 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/opends/server/authorization/dseecompat/Aci.java 5 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/opends/server/authorization/dseecompat/AciException.java 77 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/opends/server/core/DirectoryServer.java 31 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/opends/server/types/DirectoryException.java 252 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/opends/server/types/IdentifiedException.java 79 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/opends/server/types/InitializationException.java 67 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/opends/server/types/LDAPException.java 180 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/opends/server/types/OpenDsException.java 107 ●●●●● patch | view | raw | blame | history
opendj-config/src/test/java/org/forgerock/opendj/config/DNPropertyDefinitionTest.java 7 ●●●●● patch | view | raw | blame | history
opendj-config/src/main/java/org/forgerock/opendj/config/ACIPropertyDefinition.java
@@ -27,9 +27,8 @@
package org.forgerock.opendj.config;
import org.forgerock.util.Reject;
import org.opends.server.authorization.dseecompat.Aci;
import org.opends.server.authorization.dseecompat.AciException;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
@@ -101,7 +100,7 @@
        try {
            return Aci.decode(ByteString.valueOf(value), DN.rootDN());
        } catch (AciException e) {
        } catch (LocalizedIllegalArgumentException e) {
            // TODO: it would be nice to throw the cause.
            throw new IllegalPropertyValueStringException(this, value);
        }
opendj-config/src/main/java/org/forgerock/opendj/config/AdminException.java
@@ -26,13 +26,14 @@
package org.forgerock.opendj.config;
import org.forgerock.i18n.LocalizableException;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.types.OpenDsException;
/**
 * Exceptions thrown when interacting with administration framework.
 */
public abstract class AdminException extends OpenDsException {
public abstract class AdminException extends Exception implements LocalizableException {
    private final LocalizableMessage message;
    /**
     * Fake serialization ID.
@@ -48,7 +49,8 @@
     *            The cause.
     */
    protected AdminException(LocalizableMessage message, Throwable cause) {
        super(message, cause);
        super(cause);
        this.message = message;
    }
    /**
@@ -58,6 +60,11 @@
     *            The message.
     */
    protected AdminException(LocalizableMessage message) {
        super(message);
        this.message = message;
    }
    @Override
    public LocalizableMessage getMessageObject() {
        return message;
    }
}
opendj-config/src/main/java/org/forgerock/opendj/config/ClassLoaderProvider.java
@@ -56,9 +56,9 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.server.config.meta.RootCfgDefn;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.InitializationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -179,7 +179,7 @@
     *            The names of the extensions to be loaded. The names should not
     *            contain any path elements and must be located within the
     *            extensions folder.
     * @throws InitializationException
     * @throws ConfigException
     *             If one of the extensions could not be loaded and initialized.
     * @throws IllegalStateException
     *             If this class loader provider is disabled.
@@ -187,7 +187,7 @@
     *             If one of the extension names was not a single relative path
     *             name element or was an absolute path.
     */
    public synchronized void addExtension(String... extensions) throws InitializationException {
    public synchronized void addExtension(String... extensions) throws ConfigException {
        Reject.ifNull(extensions);
        if (loader == null) {
@@ -236,13 +236,13 @@
     * Enable this class loader provider using the application's class loader as
     * the parent class loader.
     *
     * @throws InitializationException
     * @throws ConfigException
     *             If the class loader provider could not initialize
     *             successfully.
     * @throws IllegalStateException
     *             If this class loader provider is already enabled.
     */
    public synchronized void enable() throws InitializationException {
    public synchronized void enable() throws ConfigException {
        enable(RootCfgDefn.class.getClassLoader());
    }
@@ -251,13 +251,13 @@
     *
     * @param parent
     *            The parent class loader.
     * @throws InitializationException
     * @throws ConfigException
     *             If the class loader provider could not initialize
     *             successfully.
     * @throws IllegalStateException
     *             If this class loader provider is already enabled.
     */
    public synchronized void enable(ClassLoader parent) throws InitializationException {
    public synchronized void enable(ClassLoader parent) throws ConfigException {
        if (loader != null) {
            throw new IllegalStateException("Class loader provider already enabled.");
        }
@@ -335,10 +335,10 @@
     *
     * @param extensions
     *            The names of the extensions to be loaded.
     * @throws InitializationException
     * @throws ConfigException
     *             If one of the extensions could not be loaded and initialized.
     */
    private synchronized void addExtension(File... extensions) throws InitializationException {
    private synchronized void addExtension(File... extensions) throws ConfigException {
        // First add the Jar files to the class loader.
        List<JarFile> jars = new LinkedList<JarFile>();
        for (File extension : extensions) {
@@ -358,7 +358,7 @@
                LocalizableMessage message =
                    ERR_ADMIN_CANNOT_OPEN_JAR_FILE.get(extension.getName(), extension.getParent(),
                        stackTraceToSingleLineString(e, true));
                throw new InitializationException(message);
                throw new ConfigException(message);
            }
            jarFiles.add(extension);
        }
@@ -477,12 +477,12 @@
     *
     * @param extensionsPath
     *            Indicates where extensions are located.
     * @throws InitializationException
     * @throws ConfigException
     *             If the extensions folder could not be accessed or if a
     *             extension jar file could not be accessed or if one of the
     *             configuration definition classes could not be initialized.
     */
    private void initializeAllExtensions(File extensionsPath) throws InitializationException {
    private void initializeAllExtensions(File extensionsPath) throws ConfigException {
        try {
            if (!extensionsPath.exists()) {
@@ -497,7 +497,7 @@
                // critical.
                LocalizableMessage message =
                    ERR_ADMIN_EXTENSIONS_DIR_NOT_DIRECTORY.get(String.valueOf(extensionsPath));
                throw new InitializationException(message);
                throw new ConfigException(message);
            }
            // Get each extension file name.
@@ -519,7 +519,7 @@
            // Add and initialize the extensions.
            addExtension(extensionsPath.listFiles(filter));
        } catch (InitializationException e) {
        } catch (ConfigException e) {
            debugLogger.trace("Unable to initialize all extensions", e);
            throw e;
        } catch (Exception e) {
@@ -527,31 +527,31 @@
            LocalizableMessage message =
                ERR_ADMIN_EXTENSIONS_CANNOT_LIST_FILES.get(String.valueOf(extensionsPath),
                    stackTraceToSingleLineString(e, true));
            throw new InitializationException(message, e);
            throw new ConfigException(message, e);
        }
    }
    /**
     * Make sure all core configuration definitions are loaded.
     *
     * @throws InitializationException
     * @throws ConfigException
     *             If the core manifest file could not be read or if one of the
     *             configuration definition classes could not be initialized.
     */
    private void initializeCoreComponents() throws InitializationException {
    private void initializeCoreComponents() throws ConfigException {
        InputStream is = RootCfgDefn.class.getResourceAsStream(MANIFEST);
        if (is == null) {
            LocalizableMessage message = ERR_ADMIN_CANNOT_FIND_CORE_MANIFEST.get(MANIFEST);
            throw new InitializationException(message);
            throw new ConfigException(message);
        }
        try {
            loadDefinitionClasses(is);
        } catch (InitializationException e) {
        } catch (ConfigException e) {
            debugLogger.trace("Unable to initialize core components", e);
            LocalizableMessage message =
                ERR_CLASS_LOADER_CANNOT_LOAD_CORE.get(MANIFEST,
                    stackTraceToSingleLineString(e, true));
            throw new InitializationException(message);
            throw new ConfigException(message);
        }
    }
@@ -561,12 +561,12 @@
     *
     * @param jarFile
     *            The extension's Jar file.
     * @throws InitializationException
     * @throws ConfigException
     *             If the extension jar file could not be accessed or if one of
     *             the configuration definition classes could not be
     *             initialized.
     */
    private void initializeExtension(JarFile jarFile) throws InitializationException {
    private void initializeExtension(JarFile jarFile) throws ConfigException {
        JarEntry entry = jarFile.getJarEntry(MANIFEST);
        if (entry != null) {
            InputStream is;
@@ -577,17 +577,17 @@
                LocalizableMessage message =
                    ERR_ADMIN_CANNOT_READ_EXTENSION_MANIFEST.get(MANIFEST, jarFile.getName(),
                        stackTraceToSingleLineString(e, true));
                throw new InitializationException(message);
                throw new ConfigException(message);
            }
            try {
                loadDefinitionClasses(is);
            } catch (InitializationException e) {
            } catch (ConfigException e) {
                debugLogger.trace("Unable to load classes from input stream", e);
                LocalizableMessage message =
                    ERR_CLASS_LOADER_CANNOT_LOAD_EXTENSION.get(jarFile.getName(), MANIFEST,
                        stackTraceToSingleLineString(e, true));
                throw new InitializationException(message);
                throw new ConfigException(message);
            }
            try {
                // Log build information of extensions in the error log
@@ -607,11 +607,11 @@
     *
     * @param is
     *            The manifest file input stream.
     * @throws InitializationException
     * @throws ConfigException
     *             If the definition classes could not be loaded and
     *             initialized.
     */
    private void loadDefinitionClasses(InputStream is) throws InitializationException {
    private void loadDefinitionClasses(InputStream is) throws ConfigException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        List<AbstractManagedObjectDefinition<?, ?>> definitions =
            new LinkedList<AbstractManagedObjectDefinition<?, ?>>();
@@ -622,7 +622,7 @@
            } catch (IOException e) {
                LocalizableMessage msg =
                    ERR_CLASS_LOADER_CANNOT_READ_MANIFEST_FILE.get(String.valueOf(e.getMessage()));
                throw new InitializationException(msg, e);
                throw new ConfigException(msg, e);
            }
            // Break out when the end of the manifest is reached.
@@ -650,7 +650,7 @@
            } catch (Exception e) {
                LocalizableMessage msg =
                    ERR_CLASS_LOADER_CANNOT_LOAD_CLASS.get(className, String.valueOf(e.getMessage()));
                throw new InitializationException(msg, e);
                throw new ConfigException(msg, e);
            }
            if (AbstractManagedObjectDefinition.class.isAssignableFrom(theClass)) {
                // We need to instantiate it using its getInstance() static
@@ -662,7 +662,7 @@
                    LocalizableMessage msg =
                        ERR_CLASS_LOADER_CANNOT_FIND_GET_INSTANCE_METHOD.get(className,
                            String.valueOf(e.getMessage()));
                    throw new InitializationException(msg, e);
                    throw new ConfigException(msg, e);
                }
                // Get the definition instance.
@@ -673,7 +673,7 @@
                    LocalizableMessage msg =
                        ERR_CLASS_LOADER_CANNOT_INVOKE_GET_INSTANCE_METHOD.get(className,
                            String.valueOf(e.getMessage()));
                    throw new InitializationException(msg, e);
                    throw new ConfigException(msg, e);
                }
                definitions.add(d);
            }
@@ -687,7 +687,7 @@
                LocalizableMessage msg =
                    ERR_CLASS_LOADER_CANNOT_INITIALIZE_DEFN.get(d.getName(), d.getClass().getName(),
                        String.valueOf(e.getMessage()));
                throw new InitializationException(msg, e);
                throw new ConfigException(msg, e);
            }
        }
    }
@@ -698,10 +698,10 @@
     * @param jar
     *            The name of the Jar file to load.
     * @return Returns the loaded Jar file.
     * @throws InitializationException
     * @throws ConfigException
     *             If the Jar file could not be loaded.
     */
    private JarFile loadJarFile(File jar) throws InitializationException {
    private JarFile loadJarFile(File jar) throws ConfigException {
        JarFile jarFile;
        try {
@@ -713,7 +713,7 @@
            LocalizableMessage message =
                ERR_ADMIN_CANNOT_OPEN_JAR_FILE.get(jar.getName(), jar.getParent(),
                    stackTraceToSingleLineString(e, true));
            throw new InitializationException(message);
            throw new ConfigException(message);
        }
        return jarFile;
    }
opendj-config/src/main/java/org/forgerock/opendj/config/server/ConfigException.java
@@ -33,9 +33,7 @@
 * configuration.
 */
public final class ConfigException extends Exception implements LocalizableException {
    private static final long serialVersionUID = -540463620272921157L;
    private final LocalizableMessage message;
    /**
opendj-config/src/main/java/org/opends/server/authorization/dseecompat/Aci.java
@@ -26,6 +26,7 @@
 */
package org.opends.server.authorization.dseecompat;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
@@ -48,10 +49,10 @@
     * @param dn
     *            DN of the ACI entry.
     * @return Returns a decoded ACI representing the string argument.
     * @throws AciException
     * @throws LocalizedIllegalArgumentException
     *             If the parsing of the ACI string fails.
     */
    public static Aci decode(ByteString byteString, DN dn) throws AciException {
    public static Aci decode(ByteString byteString, DN dn) {
        throw new RuntimeException("This class is not implemented");
    }
}
opendj-config/src/main/java/org/opends/server/authorization/dseecompat/AciException.java
File was deleted
opendj-config/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -26,7 +26,6 @@
package org.opends.server.core;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException;
@@ -97,34 +96,4 @@
        throw new RuntimeException("Not implemented");
    }
    /**
     * Retrieves the objectclass for the provided lowercase name or OID.
     *
     * @param lowerName
     *            The lowercase name or OID for the objectclass to retrieve.
     * @return The requested objectclass, or <CODE>null</CODE> if there is no
     *         such objectclass defined in the server schema.
     */
    public static ObjectClass getObjectClass(String lowerName) {
        try {
            return Schema.getDefaultSchema().getObjectClass(lowerName);
        } catch (UnknownSchemaElementException e) {
            return null;
        }
    }
    /**
     * Causes the Directory Server to construct a new objectclass definition
     * with the provided name and with no required or allowed attributes. This
     * should only be used if there is no objectclass for the specified name. It
     * will not register the created objectclass with the Directory Server.
     *
     * @param name
     *            The name to use for the objectclass, as provided by the user.
     * @return The constructed objectclass definition.
     */
    public static ObjectClass getDefaultObjectClass(String name) {
        return getObjectClass(name);
    }
}
opendj-config/src/main/java/org/opends/server/types/DirectoryException.java
File was deleted
opendj-config/src/main/java/org/opends/server/types/IdentifiedException.java
File was deleted
opendj-config/src/main/java/org/opends/server/types/InitializationException.java
File was deleted
opendj-config/src/main/java/org/opends/server/types/LDAPException.java
File was deleted
opendj-config/src/main/java/org/opends/server/types/OpenDsException.java
File was deleted
opendj-config/src/test/java/org/forgerock/opendj/config/DNPropertyDefinitionTest.java
@@ -30,7 +30,6 @@
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.server.config.meta.RootCfgDefn;
import org.opends.server.types.DirectoryException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -46,7 +45,7 @@
    @Test(dataProvider = "baseDN")
    public void testBuilderSetBaseDN(String baseDN) throws DirectoryException {
    public void testBuilderSetBaseDN(String baseDN) {
        DNPropertyDefinition.Builder localBuilder = DNPropertyDefinition.createBuilder(RootCfgDefn.getInstance(),
                "test-property");
        localBuilder.setBaseDN(baseDN);
@@ -90,7 +89,7 @@
    }
    @Test(dataProvider = "legalValues")
    public void testValidateLegalValues(String baseDN, String valueToValidate) throws DirectoryException {
    public void testValidateLegalValues(String baseDN, String valueToValidate) {
        DNPropertyDefinition.Builder localBuilder = DNPropertyDefinition.createBuilder(RootCfgDefn.getInstance(),
                "test-property");
        localBuilder.setBaseDN(baseDN);
@@ -99,7 +98,7 @@
    }
    @Test(dataProvider = "illegalValues", expectedExceptions = IllegalPropertyValueException.class)
    public void testValidateIllegalValues(String baseDN, String valueToValidate) throws DirectoryException {
    public void testValidateIllegalValues(String baseDN, String valueToValidate) {
        DNPropertyDefinition.Builder localBuilder = DNPropertyDefinition.createBuilder(RootCfgDefn.getInstance(),
                "test-property");
        localBuilder.setBaseDN(baseDN);