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;
}
}
Aggregations