From 08596e88b00966695244cc6e70f3467403f03c62 Mon Sep 17 00:00:00 2001
From: Mark Craig <mark.craig@forgerock.com>
Date: Fri, 03 Apr 2015 09:52:20 +0000
Subject: [PATCH] CR-6570 OPENDJ-1898 Move to single doc gen plugin

---
 opendj-doc-maven-plugin/src/main/resources/templates/log-message-reference.ftl                    |   66 +++
 opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateMessageFileMojo.java |  418 ++++++++++++++++++++
 opendj-doc-maven-plugin/src/main/resources/org/forgerock/opendj/maven/doc/docs.properties         |   76 +++
 opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/package-info.java            |    0 
 opendj-doc-maven-plugin/src/main/resources/templates/sec-locales-subtypes.ftl                     |    0 
 opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateSchemaDocMojo.java   |    0 
 opendj-server-legacy/src/main/docbkx/reference/index.xml                                          |    2 
 pom.xml                                                                                           |    2 
 opendj-doc-maven-plugin/pom.xml                                                                   |   28 +
 opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/CommandLineTool.java         |    2 
 /dev/null                                                                                         |  537 --------------------------
 opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateRefEntriesMojo.java  |    2 
 opendj-server-legacy/pom.xml                                                                      |   21 
 opendj-ldap-toolkit/pom.xml                                                                       |    2 
 14 files changed, 602 insertions(+), 554 deletions(-)

diff --git a/opendj-doc-plugin/pom.xml b/opendj-doc-maven-plugin/pom.xml
similarity index 75%
rename from opendj-doc-plugin/pom.xml
rename to opendj-doc-maven-plugin/pom.xml
index 899ac3a..5959acc 100644
--- a/opendj-doc-plugin/pom.xml
+++ b/opendj-doc-maven-plugin/pom.xml
@@ -36,7 +36,7 @@
     <version>3.0.0-SNAPSHOT</version>
   </parent>
 
-  <artifactId>opendj-doc-plugin</artifactId>
+  <artifactId>opendj-doc-maven-plugin</artifactId>
   <packaging>maven-plugin</packaging>
 
   <name>OpenDJ Doc Helper Maven Plugin</name>
@@ -55,6 +55,10 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.forgerock.commons</groupId>
+      <artifactId>i18n-core</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.freemarker</groupId>
       <artifactId>freemarker</artifactId>
       <version>2.3.21</version>
@@ -71,4 +75,26 @@
       <scope>provided</scope>
     </dependency>
   </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.forgerock.commons</groupId>
+        <artifactId>i18n-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>generate-messages</goal>
+            </goals>
+            <configuration>
+              <messageFiles>
+                <messageFile>org/forgerock/opendj/maven/doc/docs.properties</messageFile>
+              </messageFiles>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 </project>
diff --git a/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/CommandLineTool.java b/opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/CommandLineTool.java
similarity index 98%
rename from opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/CommandLineTool.java
rename to opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/CommandLineTool.java
index 3545f6e..e5cc512 100644
--- a/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/CommandLineTool.java
+++ b/opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/CommandLineTool.java
@@ -23,7 +23,7 @@
  *
  *      Copyright 2015 ForgeRock AS.
  */
-package org.forgerock.opendj.maven;
+package org.forgerock.opendj.maven.doc;
 
 import java.util.List;
 
diff --git a/opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateMessageFileMojo.java b/opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateMessageFileMojo.java
new file mode 100644
index 0000000..c4e883a
--- /dev/null
+++ b/opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateMessageFileMojo.java
@@ -0,0 +1,418 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2008-2010 Sun Microsystems, Inc.
+ *      Portions Copyright 2011-2015 ForgeRock AS.
+ */
+package org.forgerock.opendj.maven.doc;
+
+import static org.apache.maven.plugins.annotations.LifecyclePhase.*;
+import static org.forgerock.opendj.maven.doc.DocsMessages.*;
+import static org.forgerock.util.Utils.*;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import freemarker.template.Configuration;
+import freemarker.template.TemplateException;
+import freemarker.template.TemplateExceptionHandler;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.forgerock.i18n.LocalizableMessage;
+
+/**
+ * Generates an XML file of log messages found in properties files.
+ */
+@Mojo(name = "generate-xml-messages-doc", defaultPhase = PRE_SITE)
+public class GenerateMessageFileMojo extends AbstractMojo {
+
+    /**
+     * The Maven Project.
+     */
+    @Parameter(property = "project", readonly = true, required = true)
+    private MavenProject project;
+
+    /**
+     * The tag of the locale for which to generate the documentation.
+     */
+    @Parameter(defaultValue = "en")
+    private String locale;
+
+    /**
+     * The path to the directory containing the message properties files.
+     */
+    @Parameter(required = true)
+    private String messagesDirectory;
+
+    /**
+     * The path to the directory where the XML file should be written.
+     * This path must be relative to ${project.build.directory}.
+     */
+    @Parameter(required = true)
+    private String outputDirectory;
+
+    /**
+     * A list which contains all file names, the extension is not needed.
+     */
+    @Parameter(required = true)
+    private List<String> messageFileNames;
+
+    /**
+     * One-line descriptions for log reference categories.
+     */
+    private static final HashMap<String, LocalizableMessage> CATEGORY_DESCRIPTIONS =
+            new HashMap<String, LocalizableMessage>();
+
+    static {
+        CATEGORY_DESCRIPTIONS.put("ACCESS_CONTROL", CATEGORY_ACCESS_CONTROL.get());
+        CATEGORY_DESCRIPTIONS.put("ADMIN", CATEGORY_ADMIN.get());
+        CATEGORY_DESCRIPTIONS.put("ADMIN_TOOL", CATEGORY_ADMIN_TOOL.get());
+        CATEGORY_DESCRIPTIONS.put("BACKEND", CATEGORY_BACKEND.get());
+        CATEGORY_DESCRIPTIONS.put("CONFIG", CATEGORY_CONFIG.get());
+        CATEGORY_DESCRIPTIONS.put("CORE", CATEGORY_CORE.get());
+        CATEGORY_DESCRIPTIONS.put("DSCONFIG", CATEGORY_DSCONFIG.get());
+        CATEGORY_DESCRIPTIONS.put("EXTENSIONS", CATEGORY_EXTENSIONS.get());
+        CATEGORY_DESCRIPTIONS.put("JEB", CATEGORY_JEB.get());
+        CATEGORY_DESCRIPTIONS.put("LOG", CATEGORY_LOG.get());
+        CATEGORY_DESCRIPTIONS.put("PLUGIN", CATEGORY_PLUGIN.get());
+        CATEGORY_DESCRIPTIONS.put("PROTOCOL", CATEGORY_PROTOCOL.get());
+        CATEGORY_DESCRIPTIONS.put("QUICKSETUP", CATEGORY_QUICKSETUP.get());
+        CATEGORY_DESCRIPTIONS.put("RUNTIME_INFORMATION", CATEGORY_RUNTIME_INFORMATION.get());
+        CATEGORY_DESCRIPTIONS.put("SCHEMA", CATEGORY_SCHEMA.get());
+        CATEGORY_DESCRIPTIONS.put("SYNC", CATEGORY_SYNC.get());
+        CATEGORY_DESCRIPTIONS.put("TASK", CATEGORY_TASK.get());
+        CATEGORY_DESCRIPTIONS.put("THIRD_PARTY", CATEGORY_THIRD_PARTY.get());
+        CATEGORY_DESCRIPTIONS.put("TOOLS", CATEGORY_TOOLS.get());
+        CATEGORY_DESCRIPTIONS.put("USER_DEFINED", CATEGORY_USER_DEFINED.get());
+        CATEGORY_DESCRIPTIONS.put("UTIL", CATEGORY_UTIL.get());
+        CATEGORY_DESCRIPTIONS.put("VERSION", CATEGORY_VERSION.get());
+    }
+
+    /** Message giving formatting rules for string keys. */
+    public static final String KEY_FORM_MSG = ".\n\nOpenDJ message property keys must be of the form\n\n"
+            + "\t\'[CATEGORY]_[SEVERITY]_[DESCRIPTION]_[ORDINAL]\'\n\n";
+
+    private static final String ERROR_SEVERITY_IDENTIFIER_STRING = "ERR_";
+
+    /** FreeMarker template configuration. */
+    private Configuration configuration;
+
+    private Configuration getConfiguration() {
+        if (configuration == null) {
+            configuration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
+            configuration.setClassForTemplateLoading(GenerateSchemaDocMojo.class, "/templates");
+            configuration.setDefaultEncoding("UTF-8");
+            configuration.setTemplateExceptionHandler(TemplateExceptionHandler.DEBUG_HANDLER);
+        }
+        return configuration;
+    }
+
+    /**
+     * Writes the result of applying the FreeMarker template to the data.
+     * @param file                  The file to write to.
+     * @param template              The name of a file in {@code resources/templates/}.
+     * @param map                   The data to use in the template.
+     * @throws IOException          Failed to write to the file.
+     * @throws TemplateException    Failed to load the template.
+     */
+    private void writeLogRef(final File file, final String template, final Map<String, Object> map)
+            throws IOException, TemplateException {
+        // FreeMarker requires a configuration to find the template.
+        configuration = getConfiguration();
+
+        // FreeMarker takes the data and a Writer to process the template.
+        Writer writer = null;
+        try {
+            writer = new PrintWriter(file);
+            configuration.getTemplate(template).process(map, writer);
+        } finally {
+            closeSilently(writer);
+        }
+    }
+
+    /**
+     * Represents a log reference entry for an individual message.
+     */
+    private static class MessageRefEntry implements Comparable<MessageRefEntry> {
+        private Integer ordinal;
+        private String xmlId;
+        private String formatString;
+
+        /**
+         * Build log reference entry for an log message.
+         */
+        public MessageRefEntry(final String msgPropKey, final Integer ordinal, final String formatString) {
+            this.formatString = formatString;
+            this.ordinal = ordinal;
+            xmlId = getXmlId(msgPropKey);
+        }
+
+        private String getXmlId(final String messagePropertyKey) {
+            // XML IDs must be unique, must begin with a letter ([A-Za-z]),
+            // and may be followed by any number of letters, digits ([0-9]),
+            // hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
+
+            final String invalidChars = "[^A-Za-z0-9\\-_:\\.]";
+            return messagePropertyKey.replaceAll(invalidChars, "-");
+        }
+
+        /**
+         * Returns a map of this log reference entry, suitable for use with FreeMarker.
+         * This implementation copies the message string verbatim.
+         * @return A map of this log reference entry, suitable for use with FreeMarker.
+         */
+        public Map<String, Object> toMap() {
+            Map<String, Object> map = new HashMap<String, Object>();
+            String id = (ordinal != null) ? ordinal.toString() : MESSAGE_NO_ORDINAL.get().toString();
+            map.put("xmlId", "log-ref-" + xmlId);
+            map.put("id", MESSAGE_ORDINAL_ID.get(id));
+            map.put("severity", MESSAGE_SEVERITY.get(ERROR_SEVERITY_PRINTABLE.get()));
+            map.put("message", MESSAGE_MESSAGE.get(formatString));
+            return map;
+        }
+
+        /**
+         * Compare message entries by unique identifier.
+         *
+         * @return See {@link java.lang.Comparable#compareTo(Object)}.
+         */
+        @Override
+        public int compareTo(MessageRefEntry mre) {
+            if (this.ordinal != null && mre.ordinal != null) {
+                return this.ordinal.compareTo(mre.ordinal);
+            }
+            return 0;
+        }
+    }
+
+    /** Represents a log reference list of messages for a category. */
+    private static class MessageRefCategory {
+        private String category;
+        private TreeSet<MessageRefEntry> messages;
+
+        MessageRefCategory(final String category, final TreeSet<MessageRefEntry> messages) {
+            this.category = category;
+            this.messages = messages;
+        }
+
+        /**
+         * Returns a map of this log reference category, suitable for use with FreeMarker.
+         * @return A map of this log reference category, suitable for use with FreeMarker.
+         */
+        public Map<String, Object> toMap() {
+            Map<String, Object> map = new HashMap<String, Object>();
+            map.put("id", category);
+            map.put("category", MESSAGE_CATEGORY.get(category));
+            List<Map<String, Object>> messageEntries = new LinkedList<Map<String, Object>>();
+            for (MessageRefEntry entry : messages) {
+                messageEntries.add(entry.toMap());
+            }
+            map.put("entries", messageEntries);
+            return map;
+        }
+    }
+
+    private static class MessagePropertyKey implements Comparable<MessagePropertyKey> {
+        private String description;
+        private Integer ordinal;
+
+        /**
+         * Creates a message property key from a string value.
+         *
+         * @param key
+         *            from properties file
+         * @return MessagePropertyKey created from string
+         */
+        public static MessagePropertyKey parseString(String key) {
+            int li = key.lastIndexOf("_");
+            if (li == -1) {
+                throw new IllegalArgumentException("Incorrectly formatted key " + key);
+            }
+
+            final String description = key.substring(0, li).toUpperCase();
+            Integer ordinal = null;
+            try {
+                String ordString = key.substring(li + 1);
+                ordinal = Integer.parseInt(ordString);
+            } catch (Exception nfe) {
+                // Ignore exception, the message has no ordinal.
+            }
+            return new MessagePropertyKey(description, ordinal);
+        }
+
+        /**
+         * Creates a parameterized instance.
+         *
+         * @param description
+         *            of this key
+         * @param ordinal
+         *            of this key
+         */
+        public MessagePropertyKey(String description, Integer ordinal) {
+            this.description = description;
+            this.ordinal = ordinal;
+        }
+
+        /**
+         * Gets the ordinal of this key.
+         *
+         * @return ordinal of this key
+         */
+        public Integer getOrdinal() {
+            return this.ordinal;
+        }
+
+        /** {@inheritDoc} */
+        @Override
+        public String toString() {
+            if (ordinal != null) {
+                return description + "_" + ordinal;
+            }
+            return description;
+        }
+
+        /** {@inheritDoc} */
+        @Override
+        public int compareTo(MessagePropertyKey k) {
+            if (ordinal == k.ordinal) {
+                return description.compareTo(k.description);
+            } else {
+                return ordinal.compareTo(k.ordinal);
+            }
+        }
+    }
+
+    /**
+     * For maven exec plugin execution. Generates for all included message files
+     * (sample.properties), a xml log ref file (log-ref-sample.xml)
+     *
+     * @throws MojoExecutionException
+     *          if a problem occurs
+     * @throws MojoFailureException
+     *          if a problem occurs
+     */
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        String projectBuildDir = project.getBuild().getDirectory();
+
+        if (!outputDirectory.contains(projectBuildDir)) {
+            String errorMsg = String.format("outputDirectory parameter (%s) must be included "
+                    + "in ${project.build.directory} (%s)", outputDirectory, projectBuildDir);
+            getLog().error(errorMsg);
+            throw new MojoExecutionException(errorMsg);
+        }
+
+        Map<String, Object> map = new HashMap<String, Object>();
+        map.put("year", new SimpleDateFormat("yyyy").format(new Date()));
+        map.put("lang", locale);
+        map.put("title", LOG_REF_TITLE.get());
+        map.put("indexterm", LOG_REF_INDEXTERM.get());
+        map.put("intro", LOG_REF_INTRO.get());
+        List<Map<String, Object>> categories = new LinkedList<Map<String, Object>>();
+        for (String category : messageFileNames) {
+            File source = new File(messagesDirectory, category + ".properties");
+            categories.add(getCategoryMap(source, category.toUpperCase()));
+        }
+        map.put("categories", categories);
+        File file = new File(outputDirectory, "log-message-reference.xml");
+        try {
+            createOutputDirectory();
+            writeLogRef(file, "log-message-reference.ftl", map);
+        } catch (Exception e) {
+            throw new MojoFailureException(e.getMessage(), e);
+        }
+    }
+
+    private void createOutputDirectory() throws IOException {
+        File outputDir = new File(outputDirectory);
+        if (outputDir != null && !outputDir.exists()) {
+            if (!outputDir.mkdirs()) {
+                throw new IOException("Failed to create output directory.");
+            }
+        }
+    }
+
+    private Map<String, Object> getCategoryMap(File source, String globalCategory) throws MojoExecutionException {
+        Properties properties = new Properties();
+        try {
+            properties.load(new FileInputStream(source));
+            Map<MessagePropertyKey, String> errorMessages = loadErrorProperties(properties);
+            TreeSet<MessageRefEntry> messageRefEntries = new TreeSet<MessageRefEntry>();
+            Set<Integer> usedOrdinals = new HashSet<Integer>();
+
+            for (MessagePropertyKey msgKey : errorMessages.keySet()) {
+                String formatString = errorMessages.get(msgKey).replaceAll("<", "&lt;");
+                Integer ordinal = msgKey.getOrdinal();
+                if (ordinal != null && usedOrdinals.contains(ordinal)) {
+                    throw new Exception("The ordinal value \'" + ordinal + "\' in key " + msgKey
+                            + " has been previously defined in " + source + KEY_FORM_MSG);
+                }
+                usedOrdinals.add(ordinal);
+                messageRefEntries.add(new MessageRefEntry(msgKey.toString(), ordinal, formatString));
+            }
+
+            return messageRefEntries.isEmpty()
+                    ? new HashMap<String, Object>()
+                    : new MessageRefCategory(globalCategory, messageRefEntries).toMap();
+        } catch (Exception e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+    }
+
+    private Map<MessagePropertyKey, String> loadErrorProperties(Properties properties) throws Exception {
+        Map<MessagePropertyKey, String> errorMessage = new TreeMap<MessagePropertyKey, String>();
+        for (Object propO : properties.keySet()) {
+            String propKey = propO.toString();
+            try {
+                // Document only ERROR messages.
+                if (propKey.startsWith(ERROR_SEVERITY_IDENTIFIER_STRING)) {
+                    MessagePropertyKey key = MessagePropertyKey.parseString(propKey);
+                    String formatString = properties.getProperty(propKey);
+                    errorMessage.put(key, formatString);
+                }
+            } catch (IllegalArgumentException iae) {
+                throw new Exception("invalid property key " + propKey + ": " + iae.getMessage() + KEY_FORM_MSG, iae);
+            }
+        }
+
+        return errorMessage;
+    }
+}
diff --git a/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateRefEntriesMojo.java b/opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateRefEntriesMojo.java
similarity index 99%
rename from opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateRefEntriesMojo.java
rename to opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateRefEntriesMojo.java
index 5901008..5323d0b 100644
--- a/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateRefEntriesMojo.java
+++ b/opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateRefEntriesMojo.java
@@ -23,7 +23,7 @@
  *
  *      Copyright 2015 ForgeRock AS.
  */
-package org.forgerock.opendj.maven;
+package org.forgerock.opendj.maven.doc;
 
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.plugin.AbstractMojo;
diff --git a/opendj-doc-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateSchemaDocMojo.java b/opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateSchemaDocMojo.java
similarity index 100%
rename from opendj-doc-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateSchemaDocMojo.java
rename to opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateSchemaDocMojo.java
diff --git a/opendj-doc-plugin/src/main/java/org/forgerock/opendj/maven/doc/package-info.java b/opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/package-info.java
similarity index 100%
rename from opendj-doc-plugin/src/main/java/org/forgerock/opendj/maven/doc/package-info.java
rename to opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/package-info.java
diff --git a/opendj-doc-maven-plugin/src/main/resources/org/forgerock/opendj/maven/doc/docs.properties b/opendj-doc-maven-plugin/src/main/resources/org/forgerock/opendj/maven/doc/docs.properties
new file mode 100644
index 0000000..2a29855
--- /dev/null
+++ b/opendj-doc-maven-plugin/src/main/resources/org/forgerock/opendj/maven/doc/docs.properties
@@ -0,0 +1,76 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+# or http://forgerock.org/license/CDDLv1.0.html.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at legal-notices/CDDLv1_0.txt.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information:
+#      Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#      Copyright 2015 ForgeRock AS.
+#
+#
+# Documentation messages
+#
+CATEGORY_ACCESS_CONTROL=Access Control.
+CATEGORY_ADMIN=the administration framework.
+CATEGORY_ADMIN_TOOL=the tool like the offline installer and uninstaller.
+CATEGORY_BACKEND=generic backends.
+CATEGORY_CONFIG=configuration handling.
+CATEGORY_CORE=the core server.
+CATEGORY_DSCONFIG=the dsconfig administration tool.
+CATEGORY_EXTENSIONS=server extensions (for example, extended operations, \
+  SASL mechanisms, password storage schemes, password validators, and so on).
+CATEGORY_JEB=the JE backend.
+CATEGORY_LOG=the server loggers.
+CATEGORY_PLUGIN=plugin processing.
+CATEGORY_PROTOCOL=connection and protocol handling (for example, ASN.1 and LDAP).
+CATEGORY_QUICKSETUP=quicksetup tools.
+CATEGORY_RUNTIME_INFORMATION=the runtime information.
+CATEGORY_SCHEMA=the server schema elements.
+CATEGORY_SYNC=replication.
+CATEGORY_TASK=tasks.
+CATEGORY_THIRD_PARTY=third-party (including user-defined) modules.
+CATEGORY_TOOLS=tools.
+CATEGORY_USER_DEFINED=user-defined modules.
+CATEGORY_UTIL=the general server utilities.
+CATEGORY_VERSION=version information.
+
+MESSAGE_CATEGORY=Log Message Category: %s
+MESSAGE_ORDINAL_ID=ID: %s
+MESSAGE_NO_ORDINAL=N/A
+MESSAGE_SEVERITY=Severity: %s
+MESSAGE_MESSAGE=Message: %s
+
+ERROR_SEVERITY_PRINTABLE=ERROR
+
+LOG_REF_TITLE=Log Message Reference
+LOG_REF_INDEXTERM=Logs
+LOG_REF_INTRO=The section on                                    \
+  <link                                                         \
+   xlink:href="admin-guide#logging"                             \
+   xlink:role="http://docbook.org/xlink/role/olink"             \
+   xlink:show="new"                                             \
+  ><citetitle>Server Logs</citetitle></link> describes logs.    \
+  Access and audit logs concern client operations               \
+  rather than OpenDJ directory server and tools,                \
+  and so are not listed here.                                   \
+  Instead, this appendix covers severe and fatal error messages \
+  for the directory server and its tools,                       \
+  such as those logged in                                       \
+  <filename>/path/to/opendj/logs/errors</filename>, and         \
+  <filename>/path/to/opendj/logs/replication</filename>.
diff --git a/opendj-doc-maven-plugin/src/main/resources/templates/log-message-reference.ftl b/opendj-doc-maven-plugin/src/main/resources/templates/log-message-reference.ftl
new file mode 100644
index 0000000..e532a33
--- /dev/null
+++ b/opendj-doc-maven-plugin/src/main/resources/templates/log-message-reference.ftl
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ! CCPL HEADER START
+  !
+  ! This work is licensed under the Creative Commons
+  ! Attribution-NonCommercial-NoDerivs 3.0 Unported License.
+  ! To view a copy of this license, visit
+  ! http://creativecommons.org/licenses/by-nc-nd/3.0/
+  ! or send a letter to Creative Commons, 444 Castro Street,
+  ! Suite 900, Mountain View, California, 94041, USA.
+  !
+  ! You can also obtain a copy of the license at
+  ! trunk/opendj/legal-notices/CC-BY-NC-ND.txt.
+  ! See the License for the specific language governing permissions
+  ! and limitations under the License.
+  !
+  ! If applicable, add the following below this CCPL HEADER, with the fields
+  ! enclosed by brackets "[]" replaced with your own identifying information:
+  !      Portions Copyright [yyyy] [name of copyright owner]
+  !
+  ! CCPL HEADER END
+  !
+  !      Copyright 2012-${year} ForgeRock AS.
+  !
+-->
+<appendix xml:id="appendix-log-messages"
+          xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="${lang}"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://docbook.org/ns/docbook
+                              http://docbook.org/xml/5.0/xsd/docbook.xsd"
+          xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:xinclude="http://www.w3.org/2001/XInclude">
+
+ <title>${title}</title>
+
+ <indexterm>
+  <primary>${indexterm}</primary>
+ </indexterm>
+
+ <para>
+  ${intro}
+ </para>
+
+ <#list categories as section>
+ <section xml:id="${section.id}">
+  <title>${section.category}</title>
+
+  <variablelist>
+  <#list section.entries as entry>
+   <varlistentry xml:id="log-ref-${entry.xmlId}">
+    <term>${entry.id}</term>
+    <listitem>
+     <para>
+      ${entry.severity}
+     </para>
+
+     <para>
+      ${entry.message}
+     </para>
+    </listitem>
+   </varlistentry>
+  </#list>
+  </variablelist>
+ </section>
+ </#list>
+</appendix>
diff --git a/opendj-doc-plugin/src/main/resources/templates/sec-locales-subtypes.ftl b/opendj-doc-maven-plugin/src/main/resources/templates/sec-locales-subtypes.ftl
similarity index 100%
rename from opendj-doc-plugin/src/main/resources/templates/sec-locales-subtypes.ftl
rename to opendj-doc-maven-plugin/src/main/resources/templates/sec-locales-subtypes.ftl
diff --git a/opendj-ldap-toolkit/pom.xml b/opendj-ldap-toolkit/pom.xml
index 7d196b8..64f2512 100644
--- a/opendj-ldap-toolkit/pom.xml
+++ b/opendj-ldap-toolkit/pom.xml
@@ -100,7 +100,7 @@
       </plugin>
       <plugin>
         <groupId>org.forgerock.opendj</groupId>
-        <artifactId>opendj-maven-plugin</artifactId>
+        <artifactId>opendj-doc-maven-plugin</artifactId>
         <version>${project.version}</version>
         <executions>
           <execution>
diff --git a/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateMessageFileMojo.java b/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateMessageFileMojo.java
deleted file mode 100644
index bb4a30c..0000000
--- a/opendj-maven-plugin/src/main/java/org/forgerock/opendj/maven/GenerateMessageFileMojo.java
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2015 ForgeRock AS
- */
-package org.forgerock.opendj.maven;
-
-import static org.apache.maven.plugins.annotations.LifecyclePhase.*;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-import org.forgerock.util.Utils;
-
-/**
- * Generates xml files containing representations of messages found in
- * properties files.
- * <p>
- * There is a single goal that generates xml files.
- * <p>
- */
-@Mojo(name = "generate-xml-messages-doc", defaultPhase = PRE_SITE)
-public class GenerateMessageFileMojo extends AbstractMojo {
-
-    /**
-     * The Maven Project.
-     */
-    @Parameter(property = "project", readonly = true, required = true)
-    private MavenProject project;
-
-    /**
-     * The path to the directory containing the message properties files.
-     */
-    @Parameter(required = true)
-    private String messagesDirectory;
-
-    /**
-     * The path to the directory where xml reference files should be written.
-     * This path must be relative to ${project.build.directory}.
-     */
-    @Parameter(required = true)
-    private String outputDirectory;
-
-    /**
-     * A list which contains all file names, the extension is not needed.
-     */
-    @Parameter(required = true)
-    private List<String> messageFileNames;
-
-    /**
-     * The path and file name of the log message reference file path which will
-     * be copied in the output directory with generated log reference files.
-     */
-    @Parameter(required = true)
-    private String logMessageReferenceFilePath;
-
-    /**
-     * If the plugin is supposed to overwrite existing generated xml files.
-     */
-    @Parameter(required = true, defaultValue = "false")
-    private boolean overwrite;
-
-    /** The end-of-line character for this platform. */
-    public static final String EOL = System.getProperty("line.separator");
-
-    /**
-     * The registry filename is the result of the concatenation of the location
-     * of where the source are generated, the package name and the
-     * DESCRIPTORS_REG value.
-     */
-    private static String registryFileName;
-
-    /**
-     * One-line descriptions for log reference categories.
-     */
-    private static final HashMap<String, String> CATEGORY_DESCRIPTIONS = new HashMap<String, String>();
-
-    static {
-        CATEGORY_DESCRIPTIONS.put("ACCESS_CONTROL", "Access Control.");
-        CATEGORY_DESCRIPTIONS.put("ADMIN", "the administration framework.");
-        CATEGORY_DESCRIPTIONS.put("ADMIN_TOOL", "the tool like the offline" + " installer and uninstaller.");
-        CATEGORY_DESCRIPTIONS.put("BACKEND", "generic backends.");
-        CATEGORY_DESCRIPTIONS.put("CONFIG", "configuration handling.");
-        CATEGORY_DESCRIPTIONS.put("CORE", "the core server.");
-        CATEGORY_DESCRIPTIONS.put("DSCONFIG", "the dsconfig administration tool.");
-        CATEGORY_DESCRIPTIONS.put("EXTENSIONS", "server extensions for example,"
-                + " extended operations, SASL mechanisms, password storage"
-                + " schemes, password validators, and so on).");
-        CATEGORY_DESCRIPTIONS.put("JEB", "the JE backend.");
-        CATEGORY_DESCRIPTIONS.put("LOG", "the server loggers.");
-        CATEGORY_DESCRIPTIONS.put("PLUGIN", "plugin processing.");
-        CATEGORY_DESCRIPTIONS.put("PROTOCOL", "connection and protocol handling" + " (for example, ASN.1 and LDAP).");
-        CATEGORY_DESCRIPTIONS.put("QUICKSETUP", "quicksetup tools.");
-        CATEGORY_DESCRIPTIONS.put("RUNTIME_INFORMATION", "the runtime" + " information.");
-        CATEGORY_DESCRIPTIONS.put("SCHEMA", "the server schema elements.");
-        CATEGORY_DESCRIPTIONS.put("SYNC", "replication.");
-        CATEGORY_DESCRIPTIONS.put("TASK", "tasks.");
-        CATEGORY_DESCRIPTIONS.put("THIRD_PARTY", "third-party (including" + " user-defined) modules.");
-        CATEGORY_DESCRIPTIONS.put("TOOLS", "tools.");
-        CATEGORY_DESCRIPTIONS.put("USER_DEFINED", "user-defined modules.");
-        CATEGORY_DESCRIPTIONS.put("UTIL", "the general server utilities.");
-        CATEGORY_DESCRIPTIONS.put("VERSION", "version information.");
-    }
-
-    private static final String DESCRIPTORS_REG = "descriptors.reg";
-
-    /** Message giving formatting rules for string keys. */
-    public static final String KEY_FORM_MSG = ".\n\nOpenDJ message property keys must be of the form\n\n"
-            + "\t\'[CATEGORY]_[SEVERITY]_[DESCRIPTION]_[ORDINAL]\'\n\n";
-
-    private static final String ERROR_SEVERITY_IDENTIFIER_STRING = "ERR_";
-    private static final String ERROR_SEVERITY_PRINTABLE = "ERROR";
-
-    /**
-     * Represents a log reference entry for an individual message.
-     */
-    private static class MessageRefEntry implements Comparable<MessageRefEntry> {
-        private Integer ordinal;
-        private String xmlId;
-        private String formatString;
-
-        /**
-         * Build log reference entry for an log message.
-         */
-        public MessageRefEntry(final String msgPropKey, final Integer ordinal, final String formatString) {
-            this.formatString = formatString;
-            this.ordinal = ordinal;
-            xmlId = getXmlId(msgPropKey);
-        }
-
-        private String getXmlId(final String messagePropertyKey) {
-            // XML IDs must be unique, and must begin with a letter ([A-Za-z])
-            // and may be followed by any number of letters, digits ([0-9]),
-            // hyphens ("-"), underscores ("_"), colons (":"), and periods
-            // (".").
-
-            final String invalidChars = "[^A-Za-z0-9\\-_:\\.]";
-            return messagePropertyKey.replaceAll(invalidChars, "-");
-        }
-
-        /**
-         * Return a DocBook XML &lt;varlistentry&gt; of this log reference
-         * entry. This implementation copies the message string verbatim, and
-         * does not interpret format specifiers.
-         *
-         * @return DocBook XML &lt;varlistentry&gt;.
-         */
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append("  <varlistentry xml:id=\"log-ref-").append(xmlId).append("\">").append(EOL);
-            if (ordinal != null) {
-                builder.append("   <term>ID: ").append(ordinal).append("</term>").append(EOL);
-            }
-            builder.append("   <listitem>").append(EOL);
-            builder.append("    <para>Severity: ").append(ERROR_SEVERITY_PRINTABLE).append("</para>").append(EOL);
-            builder.append("    <para>Message: ").append(formatString).append("</para>").append(EOL);
-            builder.append("   </listitem>").append(EOL);
-            builder.append("  </varlistentry>").append(EOL);
-
-            return builder.toString();
-        }
-
-        /**
-         * Calls {@link #toString()}.
-         */
-        public String toXML() {
-            return toString();
-        }
-
-        /**
-         * Compare message entries by unique identifier.
-         *
-         * @return See {@link java.lang.Comparable#compareTo(Object)}.
-         */
-        @Override
-        public int compareTo(MessageRefEntry mre) {
-            if (this.ordinal != null && mre.ordinal != null) {
-                return this.ordinal.compareTo(mre.ordinal);
-            }
-            return 0;
-        }
-    }
-
-    /** Represents a log reference list of messages for a category. */
-    private static class MessageRefCategory {
-        private String category;
-        private TreeSet<MessageRefEntry> messages;
-
-        MessageRefCategory(final String category, final TreeSet<MessageRefEntry> messages) {
-            this.category = category;
-            this.messages = messages;
-        }
-
-        /**
-         * Return a DocBook XML &lt;variablelist&gt; of this log reference
-         * category.
-         *
-         * @return DocBook XML &lt;variablelist&gt;
-         */
-        @Override
-        public String toString() {
-            StringBuilder entries = new StringBuilder();
-            for (MessageRefEntry entry : messages) {
-                entries.append(entry.toXML());
-            }
-            return getVariablelistHead() + entries + getVariablelistTail();
-        }
-
-        /**
-         * Calls {@link #toString()}.
-         */
-        public String toXML() {
-            return toString();
-        }
-
-        private String getXMLPreamble() {
-            DateFormat df = new SimpleDateFormat("yyyy");
-            Date now = new Date();
-            String year = df.format(now);
-
-            return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + EOL + "<!--" + EOL + "  ! CCPL HEADER START" + EOL
-                    + "  !" + EOL + "  ! This work is licensed under the Creative Commons" + EOL
-                    + "  ! Attribution-NonCommercial-NoDerivs 3.0 Unported License." + EOL
-                    + "  ! To view a copy of this license, visit" + EOL
-                    + "  ! http://creativecommons.org/licenses/by-nc-nd/3.0/" + EOL
-                    + "  ! or send a letter to Creative Commons, 444 Castro Street," + EOL
-                    + "  ! Suite 900, Mountain View, California, 94041, USA." + EOL + "  !" + EOL
-                    + "  ! See the License for the specific language governing permissions" + EOL
-                    + "  ! and limitations under the License." + EOL + "  !" + EOL
-                    + "  ! If applicable, add the following below this CCPL HEADER, with the fields" + EOL
-                    + "  ! enclosed by brackets \"[]\" replaced with your own identifying information:" + EOL
-                    + "  !      Portions Copyright [yyyy] [name of copyright owner]" + EOL + "  !" + EOL
-                    + "  ! CCPL HEADER END" + EOL + "  !" + EOL + "  !      Copyright " + year + " ForgeRock AS"
-                    + EOL + "  !" + EOL + "-->" + EOL;
-        }
-
-        private String getBaseElementAttrs() {
-            return "xmlns='http://docbook.org/ns/docbook'" + " version='5.0' xml:lang='en'"
-                    + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
-                    + " xsi:schemaLocation='http://docbook.org/ns/docbook"
-                    + " http://docbook.org/xml/5.0/xsd/docbook.xsd'" + " xmlns:xlink='http://www.w3.org/1999/xlink'"
-                    + " xmlns:xinclude='http://www.w3.org/2001/XInclude'";
-        }
-
-        private String getVariablelistHead() {
-            return getXMLPreamble()
-                + " <variablelist xml:id=\"log-ref-" + this.category + "\" " + getBaseElementAttrs() + ">" + EOL
-                + "  <title>Log Message Category: " + category + "</title>" + EOL;
-        }
-
-        private String getVariablelistTail() {
-            return " </variablelist>" + EOL;
-        }
-
-    }
-
-    private static class MessagePropertyKey implements Comparable<MessagePropertyKey> {
-        private String description;
-        private Integer ordinal;
-
-        /**
-         * Creates a message property key from a string value.
-         *
-         * @param key
-         *            from properties file
-         * @return MessagePropertyKey created from string
-         */
-        public static MessagePropertyKey parseString(String key) {
-            int li = key.lastIndexOf("_");
-            if (li == -1) {
-                throw new IllegalArgumentException("Incorrectly formatted key " + key);
-            }
-
-            final String description = key.substring(0, li).toUpperCase();
-            Integer ordinal = null;
-            try {
-                String ordString = key.substring(li + 1);
-                ordinal = Integer.parseInt(ordString);
-            } catch (Exception nfe) {
-                // Ignore exception, the message has no ordinal.
-            }
-            return new MessagePropertyKey(description, ordinal);
-        }
-
-        /**
-         * Creates a parameterized instance.
-         *
-         * @param description
-         *            of this key
-         * @param ordinal
-         *            of this key
-         */
-        public MessagePropertyKey(String description, Integer ordinal) {
-            this.description = description;
-            this.ordinal = ordinal;
-        }
-
-        /**
-         * Gets the ordinal of this key.
-         *
-         * @return ordinal of this key
-         */
-        public Integer getOrdinal() {
-            return this.ordinal;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public String toString() {
-            if (ordinal != null) {
-                return description + "_" + ordinal;
-            }
-            return description;
-        }
-
-        /** {@inheritDoc} */
-        @Override
-        public int compareTo(MessagePropertyKey k) {
-            if (ordinal == k.ordinal) {
-                return description.compareTo(k.description);
-            } else {
-                return ordinal.compareTo(k.ordinal);
-            }
-        }
-    }
-
-    /**
-     * For maven exec plugin execution. Generates for all included message files
-     * (sample.properties), a xml log ref file (log-ref-sample.xml)
-     *
-     * @throws MojoExecutionException
-     *          if a problem occurs
-     * @throws MojoFailureException
-     *          if a problem occurs
-     */
-    @Override
-    public void execute() throws MojoExecutionException, MojoFailureException {
-        String projectBuildDir = project.getBuild().getDirectory();
-
-        if (!outputDirectory.contains(projectBuildDir)) {
-            String errorMsg = String.format("outputDirectory parameter (%s) must be included "
-                    + "in ${project.build.directory} (%s)", outputDirectory, projectBuildDir);
-            getLog().error(errorMsg);
-            throw new MojoExecutionException(errorMsg);
-        }
-
-        for (String messageFileName : messageFileNames) {
-            File source = new File(messagesDirectory, messageFileName + ".properties");
-            File dest = new File(outputDirectory, "log-ref-" + messageFileName.replace("_", "-") + ".xml");
-            try {
-                generateLogReferenceFile(source, dest, messageFileName.toUpperCase());
-            } catch (MojoExecutionException e) {
-                getLog().error("Impossible to generate " + dest.getAbsolutePath() + ": " + e.getMessage());
-                throw e;
-            }
-        }
-        copyLogMessageReferenceFile();
-    }
-
-    private void generateLogReferenceFile(File source, File dest, String globalCategory)
-            throws MojoExecutionException {
-        PrintWriter destWriter = null;
-        try {
-            // Decide whether to generate messages based on modification times
-            // and print status messages.
-            if (!source.exists()) {
-                throw new Exception("file " + source.getName() + " does not exist");
-            }
-            if (!isOverwriteNeeded(source, dest)) {
-                return;
-            }
-
-            destWriter = new PrintWriter(dest, "UTF-8");
-            Properties properties = new Properties();
-            properties.load(new FileInputStream(source));
-            Map<MessagePropertyKey, String> errorMessages = loadErrorProperties(properties);
-            TreeSet<MessageRefEntry> messageRefEntries = new TreeSet<MessageRefEntry>();
-            Set<Integer> usedOrdinals = new HashSet<Integer>();
-
-            for (MessagePropertyKey msgKey : errorMessages.keySet()) {
-                String formatString = errorMessages.get(msgKey).replaceAll("<", "&lt;");
-                Integer ordinal = msgKey.getOrdinal();
-                if (ordinal != null && usedOrdinals.contains(ordinal)) {
-                    throw new Exception("The ordinal value \'" + ordinal + "\' in key " + msgKey
-                            + " has been previously defined in " + source + KEY_FORM_MSG);
-                }
-                usedOrdinals.add(ordinal);
-                messageRefEntries.add(new MessageRefEntry(msgKey.toString(), ordinal, formatString));
-            }
-
-            destWriter.println(messageRefEntries.isEmpty() ? "<!-- No message for this category -->"
-                    : new MessageRefCategory(globalCategory, messageRefEntries).toXML());
-            getLog().info(dest.getPath() + " has been successfully generated");
-            getLog().debug("Message Generated: " + errorMessages.size());
-        } catch (Exception e) {
-            // Delete malformed file.
-            if (dest.exists()) {
-                dest.deleteOnExit();
-            }
-            throw new MojoExecutionException(e.getMessage(), e);
-        } finally {
-            Utils.closeSilently(destWriter);
-        }
-    }
-
-    private Map<MessagePropertyKey, String> loadErrorProperties(Properties properties) throws Exception {
-        Map<MessagePropertyKey, String> errorMessage = new TreeMap<MessagePropertyKey, String>();
-        for (Object propO : properties.keySet()) {
-            String propKey = propO.toString();
-            try {
-                // Document only ERROR messages.
-                if (propKey.startsWith(ERROR_SEVERITY_IDENTIFIER_STRING)) {
-                    MessagePropertyKey key = MessagePropertyKey.parseString(propKey);
-                    String formatString = properties.getProperty(propKey);
-                    errorMessage.put(key, formatString);
-                }
-            } catch (IllegalArgumentException iae) {
-                throw new Exception("invalid property key " + propKey + ": " + iae.getMessage() + KEY_FORM_MSG, iae);
-            }
-        }
-
-        return errorMessage;
-    }
-
-    private boolean isOverwriteNeeded(File source, File dest) {
-        boolean needsOverwrite = this.overwrite || source.lastModified() > dest.lastModified();
-        if (dest.exists() && needsOverwrite) {
-            dest.delete();
-            getLog().info("Regenerating " + dest.getName() + " from " + source.getName());
-        } else if (dest.exists() && !needsOverwrite) {
-            // Fail fast - nothing to do.
-            getLog().info(dest.getName() + " is up to date");
-            return false;
-        } else {
-            File javaGenDir = dest.getParentFile();
-            if (!javaGenDir.exists()) {
-                javaGenDir.mkdirs();
-            }
-        }
-
-        return true;
-    }
-
-    private void copyLogMessageReferenceFile() throws MojoExecutionException {
-        File msgReferenceSourceFile = new File(logMessageReferenceFilePath);
-        File msgReferenceDestFile = new File(outputDirectory, msgReferenceSourceFile.getName());
-        if (!isOverwriteNeeded(msgReferenceSourceFile, msgReferenceDestFile)) {
-            return;
-        }
-        InputStream input = null;
-        OutputStream output = null;
-        try {
-            input = new FileInputStream(msgReferenceSourceFile);
-            output = new FileOutputStream(msgReferenceDestFile);
-            byte[] buf = new byte[1024];
-            int bytesRead;
-            while ((bytesRead = input.read(buf)) > 0) {
-                output.write(buf, 0, bytesRead);
-            }
-            getLog().info("log message reference file has been successfully generated");
-        } catch (Exception e) {
-            throw new MojoExecutionException("Impossible to copy log reference message file into output directory: "
-                    + e.getMessage(), e);
-        } finally {
-            Utils.closeSilently(input, output);
-        }
-    }
-
-    /**
-     * Sets the file that will be generated containing declarations of messages
-     * from <code>source</code>.
-     *
-     * @param dest
-     *            File destination
-     * @throws Exception
-     *          If a problem occurs
-     */
-    public void checkDestJava(File dest) throws Exception {
-        File descriptorsRegFile = new File(dest.getParentFile(), DESCRIPTORS_REG);
-        if (registryFileName != null) {
-            // if REGISTRY_FILE_NAME is already set, ensure that we computed the
-            // same one
-            File prevDescriptorsRegFile = new File(registryFileName);
-            if (!prevDescriptorsRegFile.equals(descriptorsRegFile)) {
-                throw new Exception("Error processing " + dest
-                        + ": all messages must be located in the same package thus "
-                        + "name of the source file should be "
-                        + new File(prevDescriptorsRegFile.getParent(), dest.getName()));
-            }
-        } else {
-            registryFileName = descriptorsRegFile.getCanonicalPath();
-        }
-    }
-}
diff --git a/opendj-server-legacy/pom.xml b/opendj-server-legacy/pom.xml
index 32b1147..ea2f5ca 100644
--- a/opendj-server-legacy/pom.xml
+++ b/opendj-server-legacy/pom.xml
@@ -526,8 +526,15 @@
               <outputFile>schema.ldif.${buildRevision}</outputFile>
             </configuration>
           </execution>
+        </executions>
+      </plugin>
 
-          <!-- Generates man page sources -->
+      <!-- Generates man page sources -->
+      <plugin>
+        <groupId>org.forgerock.opendj</groupId>
+        <artifactId>opendj-doc-maven-plugin</artifactId>
+        <version>${project.version}</version>
+        <executions>
           <execution>
              <id>generate-doc</id>
              <goals>
@@ -1834,7 +1841,7 @@
         <plugins>
           <plugin>
             <groupId>org.forgerock.opendj</groupId>
-            <artifactId>opendj-doc-plugin</artifactId>
+            <artifactId>opendj-doc-maven-plugin</artifactId>
             <version>${project.version}</version>
             <executions>
               <execution>
@@ -1844,14 +1851,7 @@
                   <goal>generate-schema-ref</goal>
                 </goals>
               </execution>
-            </executions>
-          </plugin>
 
-          <plugin>
-            <groupId>org.forgerock.opendj</groupId>
-            <artifactId>opendj-maven-plugin</artifactId>
-            <version>${project.version}</version>
-            <executions>
               <execution>
                 <goals>
                   <goal>generate-xml-messages-doc</goal>
@@ -1859,8 +1859,7 @@
                 <phase>prepare-package</phase>
                 <configuration>
                   <messagesDirectory>${basedir}/src/messages/org/opends/messages</messagesDirectory>
-                  <outputDirectory>${project.build.directory}/docgen/logref</outputDirectory>
-                  <logMessageReferenceFilePath>${basedir}/resource/log-message-reference.xml</logMessageReferenceFilePath>
+                  <outputDirectory>${project.build.directory}/docbkx-sources/reference</outputDirectory>
                   <messageFileNames>
                     <!-- for xxx_yyy.properties generates a log-ref-xxx-yyy.xml file -->
                     <messageFileName>admin</messageFileName>
diff --git a/opendj-server-legacy/src/main/docbkx/reference/index.xml b/opendj-server-legacy/src/main/docbkx/reference/index.xml
index 2e3dac2..8ddb519 100644
--- a/opendj-server-legacy/src/main/docbkx/reference/index.xml
+++ b/opendj-server-legacy/src/main/docbkx/reference/index.xml
@@ -201,7 +201,7 @@
  <xinclude:include href='appendix-extended-ops.xml' />
  <xinclude:include href='appendix-l10n.xml' />
  <xinclude:include href='appendix-interface-stability.xml' />
- <xinclude:include href='${project.build.directory}/docgen/logref/log-message-reference.xml'>
+ <xinclude:include href='log-message-reference.xml'>
   <xinclude:fallback>
    <appendix>
     <title>Log Message Reference Missing</title>
diff --git a/pom.xml b/pom.xml
index 366e28e..579b98f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,7 +93,7 @@
     <module>opendj-maven-plugin</module>
     <module>opendj-copyright-maven-plugin</module>
     <module>opendj-svn-property-check-maven-plugin</module>
-    <module>opendj-doc-plugin</module>
+    <module>opendj-doc-maven-plugin</module>
     <module>opendj-core</module>
     <module>opendj-grizzly</module>
     <module>opendj-config</module>

--
Gitblit v1.10.0