| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.client.ldap; |
| | |
| | | * @param profile |
| | | * The LDAP profile |
| | | * @param exceptions |
| | | * Contains {@code IOException} that may occurred during |
| | | * management context close. Could be {@code null} |
| | | * Contains {@code IOException} that may occurred during management context close. |
| | | * Could be {@code null} |
| | | * @return A LDIF file management context |
| | | * @throws IOException |
| | | * If problems occurs while reading the file. |
| | | */ |
| | | public static ManagementContext newLDIFManagementContext( |
| | | final File ldifFile, final LDAPProfile profile, final List<IOException> exceptions) throws IOException { |
| | | public static ManagementContext newLDIFManagementContext(final File ldifFile, final LDAPProfile profile, |
| | | final List<IOException> exceptions) throws IOException { |
| | | final BufferedReader configReader = new BufferedReader(new FileReader(ldifFile)); |
| | | try { |
| | | final MemoryBackend memoryBackend = new MemoryBackend(new LDIFEntryReader(configReader)); |
| | |
| | | exceptions.add(e); |
| | | } else { |
| | | logger.error(LocalizableMessage.raw( |
| | | "IOException occured during LDIF context management close:" + e)); |
| | | "IOException occured during LDIF context management close:", e)); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | }; |
| | | |
| | | // We need to add the root dse entry to make the configuration |
| | | // framework work. |
| | | // We need to add the root dse entry to make the configuration framework work. |
| | | co.add(LDIFEntryReader.valueOfLDIFEntry("dn:", "objectClass:top", "objectClass:ds-root-dse")); |
| | | return LDAPManagementContext.newManagementContext(co, LDAPProfile.getInstance()); |
| | | } finally { |
| | |
| | | * @throws IOException |
| | | * If problems occurs while reading the file. |
| | | */ |
| | | public static ManagementContext newLDIFManagementContext( |
| | | final File ldifFile, final LDAPProfile profile) throws IOException { |
| | | public static ManagementContext newLDIFManagementContext(final File ldifFile, final LDAPProfile profile) |
| | | throws IOException { |
| | | return newLDIFManagementContext(ldifFile, profile, null); |
| | | } |
| | | |