private void saveNewProperties(String path, Properties oldProps) throws Exception { File newPropsFile = new File(path + FileSystemPage.propertiesFilename); WikiPageProperties newProps = new WikiPageProperties(); for (Iterator iterator = oldProps.keySet().iterator(); iterator.hasNext(); ) { String key = (String) iterator.next(); String value = (String) oldProps.get(key); if (!"false".equals(value)) newProps.set(key, value); } FileOutputStream os = new FileOutputStream(newPropsFile); newProps.save(os); os.close(); }
protected synchronized void saveAttributes(final WikiPageProperties attributes) throws Exception { OutputStream output = null; String propertiesFilePath = "<unknown>"; try { propertiesFilePath = getFileSystemPath() + propertiesFilename; File propertiesFile = new File(propertiesFilePath); if (propertiesFile.exists()) cmSystem.edit(propertiesFilePath); output = new FileOutputStream(propertiesFile); WikiPageProperties propertiesToSave = new WikiPageProperties(attributes); removeAlwaysChangingProperties(propertiesToSave); propertiesToSave.save(output); } catch (final Exception e) { System.err.println( "Failed to save properties file: \"" + propertiesFilePath + "\" (exception: " + e + ")."); e.printStackTrace(); throw e; } finally { if (output != null) { output.close(); cmSystem.update(propertiesFilePath); } } }