Search in sources :

Example 1 with LDIFEntryWriter

use of org.forgerock.opendj.ldif.LDIFEntryWriter in project OpenAM by OpenRock.

the class OpenDJUpgrader method patchConfiguration.

private void patchConfiguration() throws IOException {
    message("Patching configuration config/config.ldif...");
    try (InputStream defaultCurrentConfig = new FileInputStream(installRoot + "/config/upgrade/config.ldif." + currentVersion);
        InputStream defaultNewConfig = new FileInputStream(installRoot + "/config/upgrade/config.ldif." + newVersion);
        InputStream currentConfig = new FileInputStream(getBackupFileName("config/config.ldif"));
        OutputStream newCurrentConfig = new FileOutputStream(installRoot + "/config/config.ldif")) {
        final LDIFEntryReader defaultCurrentConfigReader = new LDIFEntryReader(defaultCurrentConfig);
        final LDIFEntryReader defaultNewConfigReader = new LDIFEntryReader(defaultNewConfig);
        final LDIFEntryReader currentConfigReader = new LDIFEntryReader(currentConfig);
        final LDIFEntryWriter newConfigWriter = new LDIFEntryWriter(newCurrentConfig);
        LDIF.copyTo(LDIF.patch(currentConfigReader, LDIF.diff(defaultCurrentConfigReader, defaultNewConfigReader)), newConfigWriter);
        newConfigWriter.flush();
        message("done");
    } catch (final IOException ioe) {
        message("failed: " + ioe.getMessage());
        throw ioe;
    }
}
Also used : LDIFEntryReader(org.forgerock.opendj.ldif.LDIFEntryReader) ZipInputStream(java.util.zip.ZipInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) LDIFEntryWriter(org.forgerock.opendj.ldif.LDIFEntryWriter) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 ZipInputStream (java.util.zip.ZipInputStream)1 LDIFEntryReader (org.forgerock.opendj.ldif.LDIFEntryReader)1 LDIFEntryWriter (org.forgerock.opendj.ldif.LDIFEntryWriter)1