private void patchConfiguration() throws IOException { message("Patching configuration config/config.ldif..."); InputStream defaultCurrentConfig = null; InputStream defaultNewConfig = null; InputStream currentConfig = null; OutputStream newCurrentConfig = null; try { defaultCurrentConfig = new FileInputStream(installRoot + "/" + "config/upgrade/config.ldif." + currentVersion); defaultNewConfig = new FileInputStream(installRoot + "/" + "config/upgrade/config.ldif." + newVersion); currentConfig = new FileInputStream(getBackupFileName("config/config.ldif")); 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; } finally { closeIfNotNull(newCurrentConfig); closeIfNotNull(currentConfig); closeIfNotNull(defaultNewConfig); closeIfNotNull(defaultCurrentConfig); } }