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

Nicolas Capponi
06.32.2013 d8572e224caa6f3a9c9799491b63f4098483edba
Checkpoint commit for OPENDJ-1075 Port server make-ldif tool to the SDK
CR-2539

* Use existing DecodeException class instead of MakeLDIFException class
** Simplify try catch clauses in MakeLDIFEntryReader as DecodeException extends IOException
** Delete MakeLDIFException class

* Remove useless throwing of exceptions in methods of MakeLDIFEntryReader
1 files deleted
4 files modified
461 ■■■■■ changed files
opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/MakeLDIFEntryReader.java 30 ●●●●● patch | view | raw | blame | history
opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/MakeLDIFException.java 73 ●●●●● patch | view | raw | blame | history
opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateFile.java 123 ●●●● patch | view | raw | blame | history
opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java 225 ●●●● patch | view | raw | blame | history
opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/MakeLDIFEntryReaderTestCase.java 10 ●●●●● patch | view | raw | blame | history
opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/MakeLDIFEntryReader.java
@@ -40,6 +40,7 @@
import java.util.concurrent.TimeUnit;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaValidationPolicy;
@@ -268,10 +269,12 @@
         * Return an instance of reader.
         *
         * @return a new instance of reader
         * @throws MakeLDIFException
         *             if a problem occurs during initialization of reader.
         * @throws IOException
         *             If an error occurs while reading template file.
         * @throws DecodeException
         *             If some other problem occurs during initialization
         */
        public MakeLDIFEntryReader build() throws MakeLDIFException {
        public MakeLDIFEntryReader build() throws IOException, DecodeException {
            if (schema == null) {
                schema = Schema.getDefaultSchema();
            }
@@ -290,12 +293,12 @@
                    templateFile.parse(templateStream, warnings);
                } else {
                    // this should never happen
                    throw new MakeLDIFException(ERR_MAKELDIF_MISSING_TEMPLATE_FILE.get());
                    throw DecodeException.fatalError(ERR_MAKELDIF_MISSING_TEMPLATE_FILE.get());
                }
            } catch (IOException e) {
                throw new MakeLDIFException(ERR_MAKELDIF_IOEXCEPTION_DURING_PARSE.get(e.getMessage()), e);
                throw e;
            } catch (Exception e) {
                throw new MakeLDIFException(ERR_MAKELDIF_EXCEPTION_DURING_PARSE.get(e.getMessage()), e);
                throw DecodeException.fatalError(ERR_MAKELDIF_EXCEPTION_DURING_PARSE.get(e.getMessage()), e);
            }
            MakeLDIFEntryReader reader = new MakeLDIFEntryReader(templateFile,
                    warnings, new LinkedBlockingQueue<TemplateEntry>(maxNumberOfEntriesInQueue));
@@ -332,7 +335,7 @@
    }
    @Override
    public void close() throws IOException {
    public void close() {
        isClosed = true;
        ioException = null;
        try {
@@ -384,7 +387,7 @@
    private final class MakeEntryWriter implements EntryWriter {
        @Override
        public boolean writeEntry(final TemplateEntry entry) throws IOException, MakeLDIFException {
        public boolean writeEntry(final TemplateEntry entry) {
            while (!isClosed) {
                try {
                    if (entryQueue.offer(entry, 500, TimeUnit.MILLISECONDS)) {
@@ -400,13 +403,7 @@
        @Override
        public void closeEntryWriter() {
            generationIsFinished = true;
            try {
                writeEntry(POISON_ENTRY);
            } catch (IOException e) {
                // should never happen
            } catch (MakeLDIFException e) {
                // should never happen
            }
            writeEntry(POISON_ENTRY);
        }
        public void setIOException(final IOException ioe) {
@@ -450,9 +447,6 @@
        void generate() {
            try {
                templateFile.generateEntries(entryWriter);
            } catch (MakeLDIFException e) {
                entryWriter.setIOException(new IOException(e));
                entryWriter.closeEntryWriter();
            } catch (IOException e) {
                entryWriter.setIOException(e);
                entryWriter.closeEntryWriter();
opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/MakeLDIFException.java
File was deleted
opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateFile.java
@@ -50,6 +50,7 @@
import org.forgerock.opendj.ldap.AttributeDescription;
import org.forgerock.opendj.ldap.AttributeFactory;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.Entries;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldap.LinkedAttribute;
@@ -237,17 +238,17 @@
     *
     * @param tagClass
     *            The fully-qualified name of the class to register as a tag.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             If a problem occurs while attempting to register the
     *             specified tag.
     */
    public void registerTag(String tagClass) throws MakeLDIFException {
    public void registerTag(String tagClass) throws DecodeException {
        Class<?> c;
        try {
            c = Class.forName(tagClass);
        } catch (Exception e) {
            final LocalizableMessage message = ERR_MAKELDIF_CANNOT_LOAD_TAG_CLASS.get(tagClass);
            throw new MakeLDIFException(message, e);
            throw DecodeException.fatalError(message, e);
        }
        TemplateTag t;
@@ -255,13 +256,13 @@
            t = (TemplateTag) c.newInstance();
        } catch (Exception e) {
            final LocalizableMessage message = ERR_MAKELDIF_CANNOT_INSTANTIATE_TAG.get(tagClass);
            throw new MakeLDIFException(message, e);
            throw DecodeException.fatalError(message, e);
        }
        String lowerName = t.getName().toLowerCase();
        if (registeredTags.containsKey(lowerName)) {
            final LocalizableMessage message = ERR_MAKELDIF_CONFLICTING_TAG_NAME.get(tagClass, t.getName());
            throw new MakeLDIFException(message);
            throw DecodeException.fatalError(message);
        } else {
            registeredTags.put(lowerName, t);
        }
@@ -534,10 +535,10 @@
     * @throws IOException
     *             If a problem occurs while attempting to read data from the
     *             specified file.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             If any other problem occurs while parsing the template file.
     */
    public void parse(String filename, List<LocalizableMessage> warnings) throws IOException, MakeLDIFException {
    public void parse(String filename, List<LocalizableMessage> warnings) throws IOException, DecodeException {
        ArrayList<String> fileLines = new ArrayList<String>();
        templatePath = null;
@@ -577,11 +578,11 @@
     * @throws IOException
     *             If a problem occurs while attempting to read data from the
     *             provided input stream.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             If any other problem occurs while parsing the template.
     */
    public void parse(InputStream inputStream, List<LocalizableMessage> warnings)
            throws IOException, MakeLDIFException {
            throws IOException, DecodeException {
        ArrayList<String> fileLines = new ArrayList<String>();
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
@@ -608,10 +609,10 @@
     *            The lines that make up the template file.
     * @param warnings
     *            A list into which any warnings identified may be placed.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             If any other problem occurs while parsing the template lines.
     */
    public void parse(String[] lines, List<LocalizableMessage> warnings) throws MakeLDIFException {
    public void parse(String[] lines, List<LocalizableMessage> warnings) throws DecodeException {
        // Create temporary variables that will be used to hold the data read.
        LinkedHashMap<String, TemplateTag> templateFileIncludeTags = new LinkedHashMap<String, TemplateTag>();
        LinkedHashMap<String, String> templateFileConstants = new LinkedHashMap<String, String>();
@@ -640,7 +641,7 @@
                    tagClass = Class.forName(className);
                } catch (Exception e) {
                    LocalizableMessage message = ERR_MAKELDIF_CANNOT_LOAD_TAG_CLASS.get(className);
                    throw new MakeLDIFException(message, e);
                    throw DecodeException.fatalError(message, e);
                }
                TemplateTag tag;
@@ -648,13 +649,13 @@
                    tag = (TemplateTag) tagClass.newInstance();
                } catch (Exception e) {
                    LocalizableMessage message = ERR_MAKELDIF_CANNOT_INSTANTIATE_TAG.get(className);
                    throw new MakeLDIFException(message, e);
                    throw DecodeException.fatalError(message, e);
                }
                String lowerName = tag.getName().toLowerCase();
                if (registeredTags.containsKey(lowerName) || templateFileIncludeTags.containsKey(lowerName)) {
                    LocalizableMessage message = ERR_MAKELDIF_CONFLICTING_TAG_NAME.get(className, tag.getName());
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
                templateFileIncludeTags.put(lowerName, tag);
@@ -666,19 +667,19 @@
                int equalPos = line.indexOf('=', 7);
                if (equalPos < 0) {
                    LocalizableMessage message = ERR_MAKELDIF_DEFINE_MISSING_EQUALS.get(lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
                String name = line.substring(7, equalPos).trim();
                if (name.length() == 0) {
                    LocalizableMessage message = ERR_MAKELDIF_DEFINE_NAME_EMPTY.get(lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
                String lowerName = name.toLowerCase();
                if (templateFileConstants.containsKey(lowerName)) {
                    LocalizableMessage message = ERR_MAKELDIF_CONFLICTING_CONSTANT_NAME.get(name, lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
                String value = line.substring(equalPos + 1);
@@ -715,7 +716,7 @@
                if (templateFileBranches.containsKey(branchDN)) {
                    LocalizableMessage message = ERR_MAKELDIF_CONFLICTING_BRANCH_DN.get(String.valueOf(branchDN),
                            startLineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                } else {
                    templateFileBranches.put(branchDN, b);
                }
@@ -747,13 +748,13 @@
                if (templateFileTemplates.containsKey(lowerName)) {
                    LocalizableMessage message = ERR_MAKELDIF_CONFLICTING_TEMPLATE_NAME.get(
                            String.valueOf(t.getName()), startLineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                } else {
                    templateFileTemplates.put(lowerName, t);
                }
            } else {
                LocalizableMessage message = ERR_MAKELDIF_UNEXPECTED_TEMPLATE_FILE_LINE.get(line, lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -840,12 +841,12 @@
     * @param warnings
     *            A list into which any warnings identified may be placed.
     * @return The decoded branch definition.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             If a problem occurs during initializing any of the branch
     *             elements or during processing.
     */
    private Branch parseBranchDefinition(String[] branchLines, int startLineNumber, Map<String, TemplateTag> tags,
            List<LocalizableMessage> warnings) throws MakeLDIFException {
            List<LocalizableMessage> warnings) throws DecodeException {
        // The first line must be "branch: " followed by the branch DN.
        String dnString = branchLines[0].substring(8).trim();
        DN branchDN;
@@ -853,7 +854,7 @@
            branchDN = DN.valueOf(dnString, schema);
        } catch (Exception e) {
            LocalizableMessage message = ERR_MAKELDIF_CANNOT_DECODE_BRANCH_DN.get(dnString, startLineNumber);
            throw new MakeLDIFException(message);
            throw DecodeException.fatalError(message);
        }
        // Create a new branch that will be used for the verification process.
@@ -875,7 +876,7 @@
                if (colonPos <= 21) {
                    LocalizableMessage message = ERR_MAKELDIF_BRANCH_SUBORDINATE_TEMPLATE_NO_COLON.get(lineNumber,
                            dnString);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
                String templateName = line.substring(21, colonPos).trim();
@@ -886,7 +887,7 @@
                    if (numEntries < 0) {
                        LocalizableMessage message = ERR_MAKELDIF_BRANCH_SUBORDINATE_INVALID_NUM_ENTRIES.get(
                                lineNumber, dnString, numEntries, templateName);
                        throw new MakeLDIFException(message);
                        throw DecodeException.fatalError(message);
                    } else if (numEntries == 0) {
                        LocalizableMessage message = WARN_MAKELDIF_BRANCH_SUBORDINATE_ZERO_ENTRIES.get(lineNumber,
                                dnString, templateName);
@@ -897,7 +898,7 @@
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_BRANCH_SUBORDINATE_CANT_PARSE_NUMENTRIES.get(
                            templateName, lineNumber, dnString);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } else {
                TemplateLine templateLine =
@@ -927,13 +928,13 @@
     * @param warnings
     *            A list into which any warnings identified may be placed.
     * @return The decoded template definition.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             If a problem occurs during initializing any of the template
     *             elements or during processing.
     */
    private Template parseTemplateDefinition(String[] templateLines, int startLineNumber,
            Map<String, TemplateTag> tags, Map<String, Template> definedTemplates, List<LocalizableMessage> warnings)
            throws MakeLDIFException {
            throws DecodeException {
        // The first line must be "template: " followed by the template name.
        String templateName = templateLines[0].substring(10).trim();
@@ -959,7 +960,7 @@
                if (parentTemplate == null) {
                    LocalizableMessage message = ERR_MAKELDIF_TEMPLATE_INVALID_PARENT_TEMPLATE.get(parentTemplateName,
                            lineNumber, templateName);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } else if (lowerLine.startsWith("rdnattr: ")) {
                // This is the set of RDN attributes. If there are multiple,
@@ -982,7 +983,7 @@
                if (colonPos <= 21) {
                    LocalizableMessage message = ERR_MAKELDIF_TEMPLATE_SUBORDINATE_TEMPLATE_NO_COLON.get(lineNumber,
                            templateName);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
                String subTemplateName = line.substring(21, colonPos).trim();
@@ -993,7 +994,7 @@
                    if (numEntries < 0) {
                        LocalizableMessage message = ERR_MAKELDIF_TEMPLATE_SUBORDINATE_INVALID_NUM_ENTRIES.get(
                                lineNumber, templateName, numEntries, subTemplateName);
                        throw new MakeLDIFException(message);
                        throw DecodeException.fatalError(message);
                    } else if (numEntries == 0) {
                        LocalizableMessage message = WARN_MAKELDIF_TEMPLATE_SUBORDINATE_ZERO_ENTRIES.get(lineNumber,
                                templateName, subTemplateName);
@@ -1005,7 +1006,7 @@
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_TEMPLATE_SUBORDINATE_CANT_PARSE_NUMENTRIES.get(
                            subTemplateName, lineNumber, templateName);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } else {
                // It's something we don't recognize, so it must be a template
@@ -1079,32 +1080,32 @@
     * @param warnings
     *            A list into which any warnings identified may be placed.
     * @return The template line that has been parsed.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             If a problem occurs during initializing any of the template
     *             elements or during processing.
     */
    private TemplateLine parseTemplateLine(String line, String lowerLine, int lineNumber, Branch branch,
            Template template, Map<String, TemplateTag> tags, List<LocalizableMessage> warnings)
            throws MakeLDIFException {
            throws DecodeException {
        // The first component must be the attribute type, followed by a colon.
        int colonPos = lowerLine.indexOf(':');
        if (colonPos < 0) {
            if (branch == null) {
                LocalizableMessage message = ERR_MAKELDIF_NO_COLON_IN_TEMPLATE_LINE.get(lineNumber, template.getName());
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            } else {
                LocalizableMessage message = ERR_MAKELDIF_NO_COLON_IN_BRANCH_EXTRA_LINE.get(lineNumber,
                        String.valueOf(branch.getBranchDN()));
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        } else if (colonPos == 0) {
            if (branch == null) {
                LocalizableMessage message = ERR_MAKELDIF_NO_ATTR_IN_TEMPLATE_LINE.get(lineNumber, template.getName());
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            } else {
                LocalizableMessage message = ERR_MAKELDIF_NO_ATTR_IN_BRANCH_EXTRA_LINE.get(lineNumber,
                        String.valueOf(branch.getBranchDN()));
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -1241,7 +1242,7 @@
            }
        } else {
            LocalizableMessage message = ERR_MAKELDIF_INCOMPLETE_TAG.get(lineNumber);
            throw new MakeLDIFException(message);
            throw DecodeException.fatalError(message);
        }
        TemplateTag[] tagArray = new TemplateTag[tagList.size()];
@@ -1269,11 +1270,11 @@
     * @param warnings
     *            A list into which any warnings identified may be placed.
     * @return The replacement tag parsed from the provided string.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             If some problem occurs during processing.
     */
    private TemplateTag parseReplacementTag(String tagString, Branch branch, Template template, int lineNumber,
            Map<String, TemplateTag> tags, List<LocalizableMessage> warnings) throws MakeLDIFException {
            Map<String, TemplateTag> tags, List<LocalizableMessage> warnings) throws DecodeException {
        // The components of the replacement tag will be separated by colons,
        // with
        // the first being the tag name and the remainder being arguments.
@@ -1286,7 +1287,7 @@
            t = tags.get(lowerTagName);
            if (t == null) {
                LocalizableMessage message = ERR_MAKELDIF_NO_SUCH_TAG.get(tagName, lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -1304,7 +1305,7 @@
        } catch (Exception e) {
            LocalizableMessage message = ERR_MAKELDIF_CANNOT_INSTANTIATE_NEW_TAG.get(tagName, lineNumber,
                    String.valueOf(e));
            throw new MakeLDIFException(message, e);
            throw DecodeException.fatalError(message, e);
        }
        if (branch == null) {
@@ -1314,7 +1315,7 @@
                newTag.initializeForBranch(schema, this, branch, args, lineNumber, warnings);
            } else {
                LocalizableMessage message = ERR_MAKELDIF_TAG_NOT_ALLOWED_IN_BRANCH.get(newTag.getName(), lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -1337,11 +1338,11 @@
     * @param warnings
     *            A list into which any warnings identified may be placed.
     * @return The attribute tag parsed from the provided string.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             If some other problem occurs during processing.
     */
    private TemplateTag parseAttributeTag(String tagString, Branch branch, Template template, int lineNumber,
            List<LocalizableMessage> warnings) throws MakeLDIFException {
            List<LocalizableMessage> warnings) throws DecodeException {
        // The attribute tag must have at least one argument, which is the name
        // of
        // the attribute to reference. It may have a second argument, which is
@@ -1462,10 +1463,10 @@
     * @return The result that indicates whether processing should continue.
     * @throws IOException
     *             If an error occurs while writing the entry.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             If some other problem occurs.
     */
    public TagResult generateEntries(EntryWriter entryWriter) throws IOException, MakeLDIFException {
    public TagResult generateEntries(EntryWriter entryWriter) throws IOException, DecodeException {
        for (Branch b : branches.values()) {
            TagResult result = b.writeEntries(entryWriter);
            if (!(result.keepProcessingTemplateFile())) {
@@ -1492,10 +1493,10 @@
         * @throws IOException
         *             If a problem occurs while writing the entry to its
         *             intended destination.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If some other problem occurs.
         */
        public boolean writeEntry(TemplateEntry entry) throws IOException, MakeLDIFException;
        public boolean writeEntry(TemplateEntry entry) throws IOException, DecodeException;
        /**
         * Notifies the entry writer that no more entries will be provided and
@@ -1623,11 +1624,11 @@
         *
         * @param templates
         *            The set of templates defined in the template file.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If any of the subordinate templates are not defined in
         *             the template file.
         */
        public void completeBranchInitialization(Map<String, Template> templates) throws MakeLDIFException {
        public void completeBranchInitialization(Map<String, Template> templates) throws DecodeException {
            if (subordinateTemplateNames == null) {
                subordinateTemplateNames = new String[0];
                subordinateTemplates = new Template[0];
@@ -1638,7 +1639,7 @@
                    if (subordinateTemplates[i] == null) {
                        LocalizableMessage message = ERR_MAKELDIF_UNDEFINED_BRANCH_SUBORDINATE.get(branchDN.toString(),
                                subordinateTemplateNames[i]);
                        throw new MakeLDIFException(message);
                        throw DecodeException.fatalError(message);
                    }
                }
            }
@@ -1770,10 +1771,10 @@
         * @throws IOException
         *             If a problem occurs while attempting to write to the LDIF
         *             writer.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If some other problem occurs.
         */
        public TagResult writeEntries(EntryWriter entryWriter) throws IOException, MakeLDIFException {
        public TagResult writeEntries(EntryWriter entryWriter) throws IOException, DecodeException {
            // Create a new template entry and populate it based on the RDN
            // attributes and extra lines.
            TemplateEntry entry = new TemplateEntry(this);
@@ -1912,11 +1913,11 @@
         *
         * @param templates
         *            The set of templates defined in the template file.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If any of the subordinate templates are not defined in
         *             the template file.
         */
        public void completeTemplateInitialization(Map<String, Template> templates) throws MakeLDIFException {
        public void completeTemplateInitialization(Map<String, Template> templates) throws DecodeException {
            // Make sure that all of the specified subordinate templates exist.
            if (subordinateTemplateNames == null) {
                subordinateTemplateNames = new String[0];
@@ -1928,7 +1929,7 @@
                    if (subordinateTemplates[i] == null) {
                        LocalizableMessage message = ERR_MAKELDIF_UNDEFINED_TEMPLATE_SUBORDINATE.get(
                                subordinateTemplateNames[i], name);
                        throw new MakeLDIFException(message);
                        throw DecodeException.fatalError(message);
                    }
                }
            }
@@ -1950,7 +1951,7 @@
            if (!rdnAttrs.isEmpty()) {
                AttributeType t = rdnAttrs.iterator().next();
                LocalizableMessage message = ERR_MAKELDIF_TEMPLATE_MISSING_RDN_ATTR.get(name, t.getNameOrOID());
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -2064,11 +2065,11 @@
         * @throws IOException
         *             If a problem occurs while attempting to write to the LDIF
         *             writer.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If some other problem occurs.
         */
        public TagResult writeEntries(EntryWriter entryWriter, DN parentDN, int count) throws IOException,
                MakeLDIFException {
                DecodeException {
            for (int i = 0; i < count; i++) {
                templateFile.nextFirstAndLastNames();
                TemplateEntry templateEntry = new TemplateEntry(this, parentDN);
opendj3/opendj-core/src/main/java/org/forgerock/opendj/ldif/TemplateTag.java
@@ -37,6 +37,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldif.TemplateFile.Branch;
@@ -87,11 +88,11 @@
     * @param warnings
     *            A list into which any appropriate warning messages may be
     *            placed.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             if a problem occurs
     */
    public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
            int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
            int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
        // No implementation required by default.
    }
@@ -113,11 +114,11 @@
     * @param warnings
     *            A list into which any appropriate warning messages may be
     *            placed.
     * @throws MakeLDIFException
     * @throws DecodeException
     *             if a problem occurs
     */
    public abstract void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
            String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException;
            String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException;
    /**
     * Performs any initialization for this tag that may be needed when starting
@@ -315,18 +316,18 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if ((arguments.length < 1) || (arguments.length > 2)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        1, 2, arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            String lowerName = arguments[0].toLowerCase();
            attributeType = schema.getAttributeType(lowerName);
            if (!branch.hasAttribute(attributeType)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            if (arguments.length == 2) {
@@ -335,12 +336,12 @@
                    if (numCharacters < 0) {
                        LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(numCharacters, 0,
                                getName(), lineNumber);
                        throw new MakeLDIFException(message);
                        throw DecodeException.fatalError(message);
                    }
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], getName(),
                            lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } else {
                numCharacters = 0;
@@ -366,18 +367,18 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if ((arguments.length < 1) || (arguments.length > 2)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        1, 2, arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            String lowerName = arguments[0].toLowerCase();
            attributeType = schema.getAttributeType(lowerName);
            if (!template.hasAttribute(attributeType)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            if (arguments.length == 2) {
@@ -386,12 +387,12 @@
                    if (numCharacters < 0) {
                        LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(numCharacters, 0,
                                getName(), lineNumber);
                        throw new MakeLDIFException(message);
                        throw DecodeException.fatalError(message);
                    }
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1], getName(),
                            lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } else {
                numCharacters = 0;
@@ -485,7 +486,7 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber);
        }
@@ -508,7 +509,7 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber);
        }
@@ -523,11 +524,11 @@
         * @param lineNumber
         *            The line number on which this tag appears in the template
         *            file.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If a problem occurs while initializing this tag.
         */
        private void initializeInternal(TemplateFile templateFile, String[] arguments, int lineNumber)
                throws MakeLDIFException {
                throws DecodeException {
            if (arguments.length == 0) {
                numComponents = 0;
            } else if (arguments.length == 1) {
@@ -536,12 +537,12 @@
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(),
                            lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } else {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        0, 1, arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -660,7 +661,7 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber, warnings);
        }
@@ -683,7 +684,7 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber, warnings);
        }
@@ -700,25 +701,25 @@
         * @param warnings
         *            A list into which any appropriate warning messages may be
         *            placed.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If a problem occurs while initializing this tag.
         */
        private void initializeInternal(TemplateFile templateFile, String[] arguments, int lineNumber,
                List<LocalizableMessage> warnings) throws MakeLDIFException {
                List<LocalizableMessage> warnings) throws DecodeException {
            random = templateFile.getRandom();
            // There must be at least one argument, and possibly two.
            if ((arguments.length < 1) || (arguments.length > 2)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        1, 2, arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            // The first argument should be the path to the file.
            dataFile = templateFile.getFile(arguments[0]);
            if ((dataFile == null) || (!dataFile.exists())) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_FIND_FILE.get(arguments[0], getName(), lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            // If there is a second argument, then it should be either
@@ -732,7 +733,7 @@
                } else {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_FILE_ACCESS_MODE.get(arguments[1], getName(),
                            lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } else {
                sequential = false;
@@ -745,7 +746,7 @@
            } catch (IOException ioe) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_READ_FILE.get(arguments[0], getName(), lineNumber,
                        String.valueOf(ioe));
                throw new MakeLDIFException(message, ioe);
                throw DecodeException.fatalError(message, ioe);
            }
        }
@@ -828,13 +829,13 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            this.templateFile = templateFile;
            if (arguments.length != 0) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -906,11 +907,11 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if (arguments.length != 0) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -933,11 +934,11 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if (arguments.length != 0) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -1016,18 +1017,18 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if ((arguments.length < 1) || (arguments.length > 2)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        1, 2, arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            String lowerName = arguments[0].toLowerCase();
            AttributeType t = schema.getAttributeType(lowerName);
            if (!branch.hasAttribute(t)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            if (arguments.length == 2) {
@@ -1056,18 +1057,18 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if ((arguments.length < 1) || (arguments.length > 2)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        1, 2, arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            String lowerName = arguments[0].toLowerCase();
            attributeType = schema.getAttributeType(lowerName);
            if (!template.hasAttribute(attributeType)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            if (arguments.length == 2) {
@@ -1166,18 +1167,18 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if ((arguments.length < 1) || (arguments.length > 2)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        1, 2, arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            String lowerName = arguments[0].toLowerCase();
            AttributeType t = schema.getAttributeType(lowerName);
            if (!branch.hasAttribute(t)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            if (arguments.length == 2) {
@@ -1206,18 +1207,18 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if ((arguments.length < 1) || (arguments.length > 2)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        1, 2, arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            String lowerName = arguments[0].toLowerCase();
            attributeType = schema.getAttributeType(lowerName);
            if (!template.hasAttribute(attributeType)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get(arguments[0], lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            if (arguments.length == 2) {
@@ -1312,13 +1313,13 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            this.templateFile = templateFile;
            if (arguments.length != 0) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -1408,7 +1409,7 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber, warnings);
        }
@@ -1431,7 +1432,7 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber, warnings);
        }
@@ -1449,13 +1450,13 @@
         * @param warnings
         *            A list into which any appropriate warning messages may be
         *            placed.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If a problem occurs while initializing this tag.
         */
        private void initializeInternal(TemplateFile templateFile, String[] arguments, int lineNumber,
                List<LocalizableMessage> warnings) throws MakeLDIFException {
                List<LocalizableMessage> warnings) throws DecodeException {
            if (arguments.length == 0) {
                throw new MakeLDIFException(ERR_MAKELDIF_TAG_LIST_NO_ARGUMENTS.get(lineNumber));
                throw DecodeException.fatalError(ERR_MAKELDIF_TAG_LIST_NO_ARGUMENTS.get(lineNumber));
            }
            valueStrings = new String[arguments.length];
@@ -1558,11 +1559,11 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if (arguments.length != 0) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -1646,7 +1647,7 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber);
        }
@@ -1669,7 +1670,7 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber);
        }
@@ -1684,17 +1685,17 @@
         * @param lineNumber
         *            The line number on which this tag appears in the template
         *            file.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If a problem occurs while initializing this tag.
         */
        private void initializeInternal(TemplateFile templateFile, String[] arguments, int lineNumber)
                throws MakeLDIFException {
                throws DecodeException {
            random = templateFile.getRandom();
            if (arguments.length != 1) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 1,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            try {
@@ -1703,16 +1704,16 @@
                if (percentage < 0) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(percentage, 0,
                            getName(), lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                } else if (percentage > 100) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_ABOVE_UPPER_BOUND.get(percentage, 100,
                            getName(), lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } catch (NumberFormatException nfe) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(),
                        lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -1908,7 +1909,7 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber, warnings);
        }
@@ -1931,7 +1932,7 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber, warnings);
        }
@@ -1949,18 +1950,18 @@
         * @param warnings
         *            A list into which any appropriate warning messages may be
         *            placed.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If a problem occurs while initializing this tag.
         */
        private void initializeInternal(TemplateFile templateFile, String[] arguments, int lineNumber,
                List<LocalizableMessage> warnings) throws MakeLDIFException {
                List<LocalizableMessage> warnings) throws DecodeException {
            random = templateFile.getRandom();
            // There must be at least one argument, to specify the type of
            // random value to generate.
            if ((arguments == null) || (arguments.length == 0)) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_NO_RANDOM_TYPE_ARGUMENT.get(lineNumber);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            int numArgs = arguments.length;
@@ -1980,7 +1981,7 @@
                        if (minLength < 0) {
                            LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(minLength, 0,
                                    getName(), lineNumber);
                            throw new MakeLDIFException(message);
                            throw DecodeException.fatalError(message);
                        } else if (minLength == 0) {
                            LocalizableMessage message = WARN_MAKELDIF_TAG_WARNING_EMPTY_VALUE.get(lineNumber);
                            warnings.add(message);
@@ -1988,7 +1989,7 @@
                    } catch (NumberFormatException nfe) {
                        LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1],
                                getName(), lineNumber);
                        throw new MakeLDIFException(message, nfe);
                        throw DecodeException.fatalError(message, nfe);
                    }
                } else if ((numArgs == 3) || (numArgs == 4)) {
                    randomType = RANDOM_TYPE_NUMERIC;
@@ -1999,7 +2000,7 @@
                        } catch (Exception e) {
                            LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_FORMAT_STRING.get(arguments[3],
                                    getName(), lineNumber);
                            throw new MakeLDIFException(message, e);
                            throw DecodeException.fatalError(message, e);
                        }
                    } else {
                        decimalFormat = null;
@@ -2010,7 +2011,7 @@
                    } catch (NumberFormatException nfe) {
                        LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1],
                                getName(), lineNumber);
                        throw new MakeLDIFException(message, nfe);
                        throw DecodeException.fatalError(message, nfe);
                    }
                    try {
@@ -2018,19 +2019,19 @@
                        if (maxValue < minValue) {
                            LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(maxValue,
                                    minValue, getName(), lineNumber);
                            throw new MakeLDIFException(message);
                            throw DecodeException.fatalError(message);
                        }
                        valueRange = maxValue - minValue + 1;
                    } catch (NumberFormatException nfe) {
                        LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[2],
                                getName(), lineNumber);
                        throw new MakeLDIFException(message, nfe);
                        throw DecodeException.fatalError(message, nfe);
                    }
                } else {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(),
                            lineNumber, 2, 4, numArgs);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } else if (randomTypeString.equals("alphanumeric")) {
                characterSet = ALPHANUMERIC_CHARS;
@@ -2039,7 +2040,7 @@
                if ((numArgs < 3) || (numArgs > 4)) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(),
                            lineNumber, 3, 4, numArgs);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
                characterSet = arguments[1].toCharArray();
@@ -2061,23 +2062,23 @@
                        if (maxLength <= 0) {
                            LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(maxLength, 1,
                                    getName(), lineNumber);
                            throw new MakeLDIFException(message);
                            throw DecodeException.fatalError(message);
                        }
                    } catch (NumberFormatException nfe) {
                        LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[1],
                                getName(), lineNumber);
                        throw new MakeLDIFException(message, nfe);
                        throw DecodeException.fatalError(message, nfe);
                    }
                } else {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(),
                            lineNumber, 1, 2, numArgs);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } else if (randomTypeString.equals("telephone")) {
                randomType = RANDOM_TYPE_TELEPHONE;
            } else {
                LocalizableMessage message = ERR_MAKELDIF_TAG_UNKNOWN_RANDOM_TYPE.get(lineNumber, randomTypeString);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -2099,7 +2100,7 @@
         *            placed.
         */
        private void decodeLength(String[] arguments, int startPos, int lineNumber, List<LocalizableMessage> warnings)
                throws MakeLDIFException {
                throws DecodeException {
            int numArgs = arguments.length - startPos + 1;
            if (numArgs == 2) {
@@ -2112,7 +2113,7 @@
                    if (minLength < 0) {
                        LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(minLength, 0,
                                getName(), lineNumber);
                        throw new MakeLDIFException(message);
                        throw DecodeException.fatalError(message);
                    } else if (minLength == 0) {
                        LocalizableMessage message = WARN_MAKELDIF_TAG_WARNING_EMPTY_VALUE.get(lineNumber);
                        warnings.add(message);
@@ -2120,7 +2121,7 @@
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[startPos],
                            getName(), lineNumber);
                    throw new MakeLDIFException(message, nfe);
                    throw DecodeException.fatalError(message, nfe);
                }
            } else if (numArgs == 3) {
                // There are minimum and maximum lengths.
@@ -2132,12 +2133,12 @@
                    if (minLength < 0) {
                        LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(minLength, 0,
                                getName(), lineNumber);
                        throw new MakeLDIFException(message);
                        throw DecodeException.fatalError(message);
                    }
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[startPos],
                            getName(), lineNumber);
                    throw new MakeLDIFException(message, nfe);
                    throw DecodeException.fatalError(message, nfe);
                }
                try {
@@ -2147,7 +2148,7 @@
                    if (maxLength < minLength) {
                        LocalizableMessage message = ERR_MAKELDIF_TAG_INTEGER_BELOW_LOWER_BOUND.get(maxLength,
                                minLength, getName(), lineNumber);
                        throw new MakeLDIFException(message);
                        throw DecodeException.fatalError(message);
                    } else if (maxLength == 0) {
                        LocalizableMessage message = WARN_MAKELDIF_TAG_WARNING_EMPTY_VALUE.get(lineNumber);
                        warnings.add(message);
@@ -2155,12 +2156,12 @@
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[startPos + 1],
                            getName(), lineNumber);
                    throw new MakeLDIFException(message, nfe);
                    throw DecodeException.fatalError(message, nfe);
                }
            } else {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        startPos + 1, startPos + 2, numArgs);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -2279,11 +2280,11 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if (arguments.length != 0) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -2306,11 +2307,11 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if (arguments.length != 0) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -2396,7 +2397,7 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber);
        }
@@ -2419,7 +2420,7 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber);
        }
@@ -2434,11 +2435,11 @@
         * @param lineNumber
         *            The line number on which this tag appears in the template
         *            file.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             If a problem occurs while initializing this tag.
         */
        private void initializeInternal(TemplateFile templateFile, String[] arguments, int lineNumber)
                throws MakeLDIFException {
                throws DecodeException {
            switch (arguments.length) {
            case 0:
                initialValue = 0;
@@ -2451,7 +2452,7 @@
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(),
                            lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
                nextValue = initialValue;
@@ -2463,7 +2464,7 @@
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(),
                            lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
                if (arguments[1].equalsIgnoreCase("true")) {
@@ -2473,7 +2474,7 @@
                } else {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_BOOLEAN.get(arguments[1], getName(),
                            lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
                nextValue = initialValue;
@@ -2481,7 +2482,7 @@
            default:
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        0, 2, arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -2570,11 +2571,11 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if (arguments.length != 1) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 1,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            text = arguments[0];
@@ -2599,11 +2600,11 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if (arguments.length != 1) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 1,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
            text = arguments[0];
@@ -2680,7 +2681,7 @@
         */
        @Override
        public void initializeForBranch(Schema schema, TemplateFile templateFile, Branch branch, String[] arguments,
                int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber);
        }
@@ -2703,7 +2704,7 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            initializeInternal(templateFile, arguments, lineNumber);
        }
@@ -2718,11 +2719,11 @@
         * @param lineNumber
         *            The line number on which this tag appears in the template
         *            file.
         * @throws MakeLDIFException
         * @throws DecodeException
         *             TODO
         */
        private void initializeInternal(TemplateFile templateFile, String[] arguments, int lineNumber)
                throws MakeLDIFException {
                throws DecodeException {
            if (arguments.length == 0) {
                numComponents = 0;
            } else if (arguments.length == 1) {
@@ -2731,12 +2732,12 @@
                } catch (NumberFormatException nfe) {
                    LocalizableMessage message = ERR_MAKELDIF_TAG_CANNOT_PARSE_AS_INTEGER.get(arguments[0], getName(),
                            lineNumber);
                    throw new MakeLDIFException(message);
                    throw DecodeException.fatalError(message);
                }
            } else {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_RANGE_COUNT.get(getName(), lineNumber,
                        0, 1, arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
@@ -2836,11 +2837,11 @@
         */
        @Override
        public void initializeForTemplate(Schema schema, TemplateFile templateFile, Template template,
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws MakeLDIFException {
                String[] arguments, int lineNumber, List<LocalizableMessage> warnings) throws DecodeException {
            if (arguments.length != 0) {
                LocalizableMessage message = ERR_MAKELDIF_TAG_INVALID_ARGUMENT_COUNT.get(getName(), lineNumber, 0,
                        arguments.length);
                throw new MakeLDIFException(message);
                throw DecodeException.fatalError(message);
            }
        }
opendj3/opendj-core/src/test/java/org/forgerock/opendj/ldif/MakeLDIFEntryReaderTestCase.java
@@ -33,11 +33,13 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldap.SdkTestCase;
import org.forgerock.opendj.ldap.schema.Schema;
@@ -136,13 +138,13 @@
        assertThat(reader.hasNext()).as("should have no more entries").isFalse();
    }
    @Test(expectedExceptions = MakeLDIFException.class,
    @Test(expectedExceptions = IOException.class,
            expectedExceptionsMessageRegExp = ".*Could not find template file unknown.*")
    public void testMissingTemplateFile() throws Exception {
        newReader("unknown").setResourcePath(resourcePath).build();
    }
    @Test(expectedExceptions = MakeLDIFException.class,
    @Test(expectedExceptions = DecodeException.class,
            expectedExceptionsMessageRegExp = ".*Cannot find file streets.*")
    public void testMissingResourceFile() throws Exception {
        // fail to find first resource file which is 'streets'
@@ -171,8 +173,8 @@
        try {
            templateFile.parse(lines, warns);
            failWasExpected(MakeLDIFException.class);
        } catch (MakeLDIFException e) {
            failWasExpected(DecodeException.class);
        } catch (DecodeException e) {
            LocalizableMessage expected = ERR_MAKELDIF_TAG_UNDEFINED_ATTRIBUTE.get("missingVar", 1);
            assertThat(e.getMessage()).isEqualTo(expected.toString());
        }