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

Nicolas Capponi
09.31.2016 86f898b050a24dac35c3a7c0e4276e25e888e09c
OPENDJ-2413 Add a new maven module opendj-embedded-server-examples that contains exemples for an embeddded directory server
11 files added
3 files modified
638 ■■■■■ changed files
opendj-embedded-server-examples/README 22 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/pom.xml 99 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/license/THIRD-PARTY.properties 20 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/main/assembly/examples.xml 39 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/ConfigureServer.java 104 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/SetupServer.java 103 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/StartStopServer.java 75 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/package-info.java 21 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/main/javadoc/overview.html 23 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/site/site.xml 33 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/site/xdoc/index.xml.vm 76 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/embedded/ConfigParameters.java 5 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/embedded/EmbeddedDirectoryServer.java 17 ●●●● patch | view | raw | blame | history
pom.xml 1 ●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/README
New file
@@ -0,0 +1,22 @@
To run the examples in this module:
# Build the whole opendj project
> maven clean install
# Go to the opendj-embedded-server-examples directory
> cd opendj-embedded-server-examples
# define the class patch to use
export CLASSPATH=target/opendj-embedded-server-examples-4.0.0-SNAPSHOT.jar:../opendj-server-legacy/target/package/opendj/lib/opendj-slf4j-adapter.jar
# Setup a server from the OpenDJ archive resulting from the build
# /path/to/opendj will be the root directory
java -cp $CLASSPATH org.forgerock.opendj.examples.SetupServer ../opendj-server-legacy/target/package/opendj-4.0.0-SNAPSHOT.zip /path/to/opendj
# Then you can run any of the example using the installed server
# Start and stop the server
java -cp $CLASSPATH /path/to/opendj
# Read and update the configuration of the server
java -cp $CLASSPATH /path/to/opendj "dc=example,dc=com"
opendj-embedded-server-examples/pom.xml
New file
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
  The contents of this file are subject to the terms of the Common Development and
  Distribution License (the License). You may not use this file except in compliance with the
  License.
  You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
  specific language governing permission and limitations under the License.
  When distributing Covered Software, include this CDDL Header Notice in each file and include
  the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
  Header, with the fields enclosed by brackets [] replaced by your own identifying
  information: "Portions Copyright [year] [name of copyright owner]".
  Copyright 2016 ForgeRock AS.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>opendj-parent</artifactId>
        <groupId>org.forgerock.opendj</groupId>
        <version>4.0.0-SNAPSHOT</version>
    </parent>
    <artifactId>opendj-embedded-server-examples</artifactId>
    <name>OpenDJ embedded server examples</name>
    <description>Examples illustrating usage of the OpenDJ embedded server API</description>
    <dependencies>
        <dependency>
            <groupId>org.forgerock.opendj</groupId>
            <artifactId>opendj-server-legacy</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
    <distributionManagement>
        <site>
            <id>forgerock.org</id>
            <name>OpenDJ Community</name>
            <url>scp://forgerock.org/var/www/vhosts/opendj.forgerock.org/httpdocs/opendj-embedded-server-examples</url>
        </site>
    </distributionManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <configuration>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <links>
                        <link>http://commons.forgerock.org/i18n-framework/i18n-core/apidocs</link>
                    </links>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jxr-plugin</artifactId>
                <version>2.2</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>jxr</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>
</project>
opendj-embedded-server-examples/src/license/THIRD-PARTY.properties
New file
@@ -0,0 +1,20 @@
# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
#-------------------------------------------------------------------------------
# Already used licenses in project :
# - Apache Software License, Version 2.0
# - BSD
# - Common Development and Distribution License 1.0
# - Common Development and Distribution License 1.1
# - Dual licensed (CDDL and GPL)
# - Dual licensed (CDDL and GPLv2+CE)
# - The GNU Lesser General Public License, version 2.0 with Classpath Exception
# - The GNU Lesser General Public License, version 2.1
# - The GNU Lesser General Public License, version 3.0
# - The MIT License
# - The Sleepycat License
#-------------------------------------------------------------------------------
# Please fill the missing licenses for dependencies :
#
#
#Mon Sep 12 13:43:47 CEST 2016
com.sleepycat--je--5.0.104=The Sleepycat License
opendj-embedded-server-examples/src/main/assembly/examples.xml
New file
@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<!--
  The contents of this file are subject to the terms of the Common Development and
  Distribution License (the License). You may not use this file except in compliance with the
  License.
  You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
  specific language governing permission and limitations under the License.
  When distributing Covered Software, include this CDDL Header Notice in each file and include
  the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
  Header, with the fields enclosed by brackets [] replaced by your own identifying
  information: "Portions Copyright [year] [name of copyright owner]".
  Copyright 2016 ForgeRock AS.
 -->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
                              http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  <id>examples</id>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
   <fileSet>
    <outputDirectory>resources</outputDirectory>
    <directory>src/main/java</directory>
   </fileSet>
   <fileSet>
    <outputDirectory>resources</outputDirectory>
    <directory>src/main/javadoc</directory>
   </fileSet>
  </fileSets>
  <formats>
    <format>jar</format>
  </formats>
</assembly>
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/ConfigureServer.java
New file
@@ -0,0 +1,104 @@
/*
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2016 ForgeRock AS.
 */
package org.forgerock.opendj.examples;
import static java.util.Arrays.asList;
import static org.opends.server.util.embedded.ConfigParameters.configParams;
import static org.opends.server.util.embedded.ConnectionParameters.connectionParams;
import static org.opends.server.util.embedded.EmbeddedDirectoryServer.defineServer;
import java.io.File;
import java.util.SortedSet;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.server.config.client.BackendCfgClient;
import org.forgerock.opendj.server.config.client.RootCfgClient;
import org.opends.server.util.embedded.EmbeddedDirectoryServer;
import org.opends.server.util.embedded.EmbeddedDirectoryServer.DirectoryConfigReader;
import org.opends.server.util.embedded.EmbeddedDirectoryServer.DirectoryConfigUpdater;
import org.opends.server.util.embedded.EmbeddedDirectoryServerException;
/**
 * Provides an example of read and update of the configuration of a server that
 * is already installed.
 * <p>
 * The server may be running or not.
 */
public final class ConfigureServer {
    /**
     * Main method.
     * <p>
     * Read the current base Dn of user backend and then change it
     * to the one provided as argument.
     *
     * @param args
     *            The command line arguments: serverRootDir newBaseDn [ldapPort]
     * @throws EmbeddedDirectoryServerException
     *          If an error occurs
     */
    public static void main(final String[] args) throws EmbeddedDirectoryServerException {
        if (args.length != 2 && args.length != 3) {
            System.err.println("Usage: serverRootDir newBaseDn [ldapPort]");
            System.exit(1);
        }
        final String serverRootDir = args[0];
        final String newBaseDn = args[1];
        final int ldapPort = args.length > 2 ? Integer.parseInt(args[2]) : 1500;
        EmbeddedDirectoryServer server =
                defineServer(
                        configParams()
                            .serverRootDirectory(serverRootDir)
                            .configurationFile(serverRootDir + File.separator + "config/config.ldif")
                            .build(),
                        connectionParams()
                            .hostName("localhost")
                            .ldapPort(ldapPort)
                            .bindDn("cn=Directory Manager")
                            .bindPassword("password")
                            .build(),
                        System.out,
                        System.err);
        // read the current base DN(s) of user backend
        SortedSet<DN> baseDns = server.readConfiguration(new DirectoryConfigReader<SortedSet<DN>>() {
            @Override
            public SortedSet<DN> read(RootCfgClient rootConfig) throws Exception {
                BackendCfgClient userRoot = rootConfig.getBackend("userRoot");
                return userRoot.getBaseDN();
            }
        });
        System.out.println("The current base Dn(s) of the user backend are: " + baseDns);
        // modify the base DN of the user backend
        server.updateConfiguration(new DirectoryConfigUpdater() {
            @Override
            public void update(RootCfgClient rootConfig) throws Exception {
                BackendCfgClient userRoot = rootConfig.getBackend("userRoot");
                userRoot.setBaseDN(asList(DN.valueOf(newBaseDn)));
                userRoot.commit();
            }
        });
        System.out.println("The base Dn of the user backend has been set to: " + newBaseDn);
    }
    private ConfigureServer() {
        // Not used.
    }
}
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/SetupServer.java
New file
@@ -0,0 +1,103 @@
/*
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2016 ForgeRock AS.
 */
package org.forgerock.opendj.examples;
import static org.opends.server.util.embedded.ConfigParameters.configParams;
import static org.opends.server.util.embedded.ConnectionParameters.connectionParams;
import static org.opends.server.util.embedded.EmbeddedDirectoryServer.defineServer;
import static org.opends.server.util.embedded.SetupParameters.setupParams;
import java.io.File;
import org.opends.server.util.embedded.EmbeddedDirectoryServer;
import org.opends.server.util.embedded.EmbeddedDirectoryServerException;
/**
 * Setup a server from a OpenDJ archive using the EmbeddedDirectoryServer class.
 */
public final class SetupServer {
    /**
     * Main method.
     * <p>
     * The OpenDJ archive is the zip archive that is resulting from a maven build.
     *
     * The server root directory is the directory where OpenDJ will be installed. Because
     * the archive contains the "opendj" directory, it is mandatory to provide a server root
     * directory that is named "opendj" (the archive will be automatically extracted in the
     * parent directory of the provided server root directory).
     *
     * Other parameters are usual parameters to setup a server.
     *
     * @param args
     *            The command line arguments: openDJArchive, serverRootDir
     *            and optionally: baseDn, backendType, ldapPort, adminPort, jmxPort
     * @throws EmbeddedDirectoryServerException
     *          If an error occurs
     */
    public static void main(final String[] args) throws EmbeddedDirectoryServerException {
        if (args.length != 2 && args.length != 4 && args.length != 7) {
            System.err.println("Usage: openDJArchive serverRootDir "
                    + "[baseDn backendType [ldapPort adminPort jmxPort]]");
            System.exit(1);
        }
        int i = 0;
        final String openDJArchive = args[i++];
        final String serverRootDir = args[i++];
        final String baseDn = (args.length > i) ? args[i++] : "o=example";
        final String backendType = (args.length > i) ? args[i++] : "pdb";
        final int ldapPort = (args.length > i) ? Integer.parseInt(args[i++]) : 1500;
        final int adminPort = (args.length > i) ? Integer.parseInt(args[i++]) : 4500;
        final int jmxPort = (args.length > i) ? Integer.parseInt(args[i++]) : 1600;
        performSetup(openDJArchive, serverRootDir, baseDn, backendType, ldapPort, adminPort, jmxPort);
    }
    /** Performs the setup with provided parameters. */
    static void performSetup(final String openDJArchive, final String serverRootDir, final String baseDn,
            final String backendType, final int ldapPort, final int adminPort, final int jmxPort)
            throws EmbeddedDirectoryServerException {
        EmbeddedDirectoryServer server =
                defineServer(
                        configParams()
                            .serverRootDirectory(serverRootDir)
                            .configurationFile(serverRootDir + File.separator + "config/config.ldif")
                            .build(),
                        connectionParams()
                            .hostName("localhost")
                            .ldapPort(ldapPort)
                            .bindDn("cn=Directory Manager")
                            .bindPassword("password")
                            .adminPort(adminPort)
                            .build(),
                        System.out,
                        System.err);
        server.setupFromArchive(
                new File(openDJArchive),
                setupParams()
                    .baseDn(baseDn)
                    .backendType(backendType)
                    .jmxPort(jmxPort)
                    .build());
    }
    private SetupServer() {
        // Not used.
    }
}
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/StartStopServer.java
New file
@@ -0,0 +1,75 @@
/*
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2016 ForgeRock AS.
 */
package org.forgerock.opendj.examples;
import static org.opends.server.util.embedded.ConfigParameters.configParams;
import static org.opends.server.util.embedded.EmbeddedDirectoryServer.defineServerForStartStopOperations;
import java.io.File;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.util.embedded.EmbeddedDirectoryServer;
import org.opends.server.util.embedded.EmbeddedDirectoryServerException;
/**
 * Start and stop a server that is already installed.
 */
public final class StartStopServer {
    /**
     * Main method.
     * <p>
     * The server is started, and this program waits for a Control-C on the terminal to stop the server.
     *
     * @param args
     *            The command line arguments: serverRootDir
     * @throws EmbeddedDirectoryServerException
     *          If an error occurs
     */
    public static void main(final String[] args) throws EmbeddedDirectoryServerException {
        if (args.length != 1) {
            System.err.println("Usage: serverRootDir");
            System.exit(1);
        }
        final String serverRootDir = args[0];
        final EmbeddedDirectoryServer server =
                defineServerForStartStopOperations(
                        configParams()
                            .serverRootDirectory(serverRootDir)
                            .configurationFile(serverRootDir + File.separator + "config/config.ldif")
                            .build(),
                            System.out,
                            System.err);
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                System.out.println("Shutting down ...");
                server.stop(StartStopServer.class.getName(),
                        LocalizableMessage.raw("Stopped after receiving Control-C"));
            }
        });
        System.out.println("Starting the server...");
        server.start();
        System.out.println("Type Ctrl-C to stop the server");
    }
    private StartStopServer() {
        // Not used.
    }
}
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/package-info.java
New file
@@ -0,0 +1,21 @@
/*
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2016 ForgeRock AS.
 */
/**
 * Classes providing examples of usage of Embedded Server API.
 */
package org.forgerock.opendj.examples;
opendj-embedded-server-examples/src/main/javadoc/overview.html
New file
@@ -0,0 +1,23 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
  The contents of this file are subject to the terms of the Common Development and
  Distribution License (the License). You may not use this file except in compliance with the
  License.
  You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
  specific language governing permission and limitations under the License.
  When distributing Covered Software, include this CDDL Header Notice in each file and include
  the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
  Header, with the fields enclosed by brackets [] replaced by your own identifying
  information: "Portions Copyright [year] [name of copyright owner]".
  Copyright 2016 ForgeRock AS.
 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
    The OpenDJ Embedded Server Examples contains various examples illustrating
    usage of the Embedded Server API.
</body>
</html>
opendj-embedded-server-examples/src/site/site.xml
New file
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
  The contents of this file are subject to the terms of the Common Development and
  Distribution License (the License). You may not use this file except in compliance with the
  License.
  You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
  specific language governing permission and limitations under the License.
  When distributing Covered Software, include this CDDL Header Notice in each file and include
  the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
  Header, with the fields enclosed by brackets [] replaced by your own identifying
  information: "Portions Copyright [year] [name of copyright owner]".
  Copyright 2016 ForgeRock AS.
-->
<project name="${project.name}"
         xmlns="http://maven.apache.org/DECORATION/1.0.1"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.1
                             http://maven.apache.org/xsd/decoration-1.0.1.xsd">
    <!--
        Use https://github.com/andriusvelykis/blank-maven-skin, which is Apache 2.0.
        Pages are rendered in vanilla HTML referencing an empty ./css/site.css stylesheet.
    -->
    <skin>
        <groupId>lt.velykis.maven.skins</groupId>
        <artifactId>blank-maven-skin</artifactId>
        <version>1.0.0</version>
    </skin>
    <body />
</project>
opendj-embedded-server-examples/src/site/xdoc/index.xml.vm
New file
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
  The contents of this file are subject to the terms of the Common Development and
  Distribution License (the License). You may not use this file except in compliance with the
  License.
  You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
  specific language governing permission and limitations under the License.
  When distributing Covered Software, include this CDDL Header Notice in each file and include
  the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
  Header, with the fields enclosed by brackets [] replaced by your own identifying
  information: "Portions Copyright [year] [name of copyright owner]".
  Copyright 2016 ForgeRock AS.
-->
<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
  <properties>
    <title>About ${project.name}</title>
    <author email="opendj-dev@forgerock.org">${project.organization.name}</author>
  </properties>
  <body>
    <section name="About ${project.name}">
      <p>
        The following examples use the OpenDJ Embedded Server API:
      </p>
      <ul>
        <li>
          <a href="xref/org/forgerock/opendj/examples/SetupServer.html">Server Setup</a>
          - illustrates how to setup a server from the OpenDJ archive using the Embedded Server API
        </li>
        <li>
          <a href="xref/org/forgerock/opendj/examples/StartStop.html">Server Start and Stop</a>
          - illustrates how to start and stop an installed server using the Embedded Server API
        </li>
        <li>
          <a href="xref/org/forgerock/opendj/examples/ConfigureServer.html">Server Configuration</a>
          - illustrates how to read and update configuration of an installed server using the Embedded Server API
        </li>
      </ul>
    </section>
<!--
    <section name="Documentation for ${project.name}">
      <p>
        Javadoc for this module can be found <a href="apidocs/index.html">here</a>.
      </p>
    </section>
    <section name="Get ${project.name}">
      <p>
        You can get ${project.name} using any of the following methods:
      </p>
      <subsection name="Download">
        <p>
          Pre-built binaries can be downloaded directly from the ForgeRock Maven
          repository:
        </p>
        <ul>
          <li><a href="${mavenRepoReleases}/org/forgerock/opendj/${project.artifactId}">Stable releases</a></li>
          <li><a href="${mavenRepoSnapshots}/org/forgerock/opendj/${project.artifactId}/${project.version}">Latest development snapshot</a></li>
        </ul>
      </subsection>
      <subsection name="Build">
        <p>
          For the DIY enthusiasts you can build it yourself by checking out the
          latest code using <a href="source-repository.html">Subversion</a> and
          building it with Maven 3.
        </p>
      </subsection>
    </section>
-->
  </body>
</document>
opendj-server-legacy/src/main/java/org/opends/server/util/embedded/ConfigParameters.java
@@ -15,6 +15,8 @@
 */
package org.opends.server.util.embedded;
import org.forgerock.util.Reject;
/**
 * Parameters to configure a directory server.
 */
@@ -45,9 +47,9 @@
    return serverRootDirectory;
  }
  /** This value may be {@code null}, it must always  be checked. */
  String getServerInstanceDirectory()
  {
    // provides the expected default value if not set
    return serverInstanceDirectory;
  }
@@ -83,6 +85,7 @@
    public ConfigParameters toParams()
    {
      ConfigParameters p = params;
      Reject.ifNull(p.serverRootDirectory, p.configurationFile);
      this.params = new ConfigParameters();
      return p;
    }
opendj-server-legacy/src/main/java/org/opends/server/util/embedded/EmbeddedDirectoryServer.java
@@ -15,6 +15,7 @@
 */
package org.opends.server.util.embedded;
import static org.opends.server.util.ServerConstants.*;
import static org.forgerock.opendj.config.client.ldap.LDAPManagementContext.newManagementContext;
import static org.forgerock.opendj.config.client.ldap.LDAPManagementContext.newLDIFManagementContext;
import static org.opends.messages.UtilityMessages.*;
@@ -36,7 +37,6 @@
import org.forgerock.opendj.server.config.client.RootCfgClient;
import org.forgerock.util.Options;
import org.forgerock.util.Pair;
import org.forgerock.util.Reject;
import org.opends.quicksetup.TempLogFile;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
@@ -48,7 +48,6 @@
import org.opends.server.types.DirectoryEnvironmentConfig;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
/**
@@ -357,6 +356,9 @@
  /**
   * Setups this server from the root directory.
   * <p>
   * As a pre-requisite, the OpenDJ archive must have been previously extracted to some
   * directory. To perform a setup directly from an archive, see {@code setupFromArchive()}.
   *
   * @param parameters
   *            The setup parameters.
@@ -366,8 +368,15 @@
  public void setup(SetupParameters parameters) throws EmbeddedDirectoryServerException
  {
    checkConnectionParameters();
    System.setProperty(PROPERTY_SERVER_ROOT, configParams.getServerRootDirectory());
    System.setProperty(QUICKSETUP_ROOT_PROPERTY, configParams.getServerRootDirectory());
    System.setProperty(QUICKSETUP_INSTANCE_PROPERTY, configParams.getServerInstanceDirectory());
    String instanceDir = configParams.getServerInstanceDirectory() != null ?
        configParams.getServerInstanceDirectory() :
        configParams.getServerRootDirectory();
    System.setProperty(QUICKSETUP_INSTANCE_PROPERTY, instanceDir);
    System.setProperty(PROPERTY_INSTANCE_ROOT, instanceDir);
    int returnCode = InstallDS.mainCLI(parameters.toCommandLineArguments(connectionParams), outStream, errStream,
        TempLogFile.newTempLogFile(EMBEDDED_OPEN_DJ_PREFIX));
@@ -382,7 +391,7 @@
   * Setups this server from the provided archive.
   * <p>
   * As the DJ archive includes the "opendj" directory, it is mandatory to have
   * the root directory named "opendj".
   * the root directory named "opendj" when using this method.
   *
   * @param openDJZipFile
   *            The OpenDJ server archive.
pom.xml
@@ -230,6 +230,7 @@
        <module>opendj-legacy</module>
        <module>opendj-server-legacy</module>
        <module>opendj-dsml-servlet</module>
        <module>opendj-embedded-server-examples</module>
        <module>opendj-openidm-account-change-notification-handler</module>
        <module>opendj-doc-generated-ref</module>
    </modules>