List of usage examples for org.apache.commons.configuration PropertiesConfiguration setHeader
public void setHeader(String header)
From source file:com.carmatech.maven.utils.MergeUtils.java
public static void savePropertiesTo(final File targetFile, final PropertiesConfiguration properties, final String comment) throws IOException { properties.setHeader(comment); try {/*from ww w . j av a 2s.co m*/ Files.createParentDirs(targetFile); properties.save(targetFile); } catch (ConfigurationException e) { throw new IOException("Unable to save properties file " + targetFile); } }
From source file:com.liferay.ide.project.core.tests.ProjectCoreBase.java
private void persistAppServerProperties() throws FileNotFoundException, IOException, ConfigurationException { Properties initProps = new Properties(); initProps.put("app.server.type", "tomcat"); initProps.put("app.server.tomcat.dir", getLiferayRuntimeDir().toPortableString()); initProps.put("app.server.tomcat.deploy.dir", getLiferayRuntimeDir().append("webapps").toPortableString()); initProps.put("app.server.tomcat.lib.global.dir", getLiferayRuntimeDir().append("lib/ext").toPortableString()); initProps.put("app.server.parent.dir", getLiferayRuntimeDir().removeLastSegments(1).toPortableString()); initProps.put("app.server.tomcat.portal.dir", getLiferayRuntimeDir().append("webapps/ROOT").toPortableString()); IPath loc = getLiferayPluginsSdkDir(); String userName = System.getProperty("user.name"); //$NON-NLS-1$ File userBuildFile = loc.append("build." + userName + ".properties").toFile(); //$NON-NLS-1$ //$NON-NLS-2$ try (FileOutputStream fileOutput = new FileOutputStream(userBuildFile)) { if (userBuildFile.exists()) { PropertiesConfiguration propsConfig = new PropertiesConfiguration(userBuildFile); for (Object key : initProps.keySet()) { propsConfig.setProperty((String) key, initProps.get(key)); }/*w w w . j av a2 s . co m*/ propsConfig.setHeader(""); propsConfig.save(fileOutput); } else { Properties props = new Properties(); props.putAll(initProps); props.store(fileOutput, StringPool.EMPTY); } } }
From source file:com.liferay.ide.sdk.core.SDK.java
protected void persistAppServerProperties(Map<String, String> properties) throws FileNotFoundException, IOException, ConfigurationException { IPath loc = getLocation();// ww w.j a v a 2 s .c o m // check for build.<username>.properties String userName = System.getProperty("user.name"); //$NON-NLS-1$ File userBuildFile = loc.append("build." + userName + ".properties").toFile(); //$NON-NLS-1$ //$NON-NLS-2$ if (userBuildFile.exists()) { /* * the build file exists so we need to check the following conditions 1. if the header in the comment * contains the text written by a previous SDK operation then we can write it again 2. if the file was not * previously written by us we will need to prompt the user with permission yes/no to update the * build.<username>.properties file */ PropertiesConfiguration propsConfig = new PropertiesConfiguration(userBuildFile); String header = propsConfig.getHeader(); boolean shouldUpdateBuildFile = false; if (header != null && header.contains(MSG_MANAGED_BY_LIFERAY_IDE)) { shouldUpdateBuildFile = true; } else { String overwrite = getPrefStore().get(SDKCorePlugin.PREF_KEY_OVERWRITE_USER_BUILD_FILE, ALWAYS); if (ALWAYS.equals(overwrite)) { shouldUpdateBuildFile = true; } else { shouldUpdateBuildFile = false; } } if (shouldUpdateBuildFile) { for (String key : properties.keySet()) { propsConfig.setProperty(key, properties.get(key)); } propsConfig.setHeader(MSG_MANAGED_BY_LIFERAY_IDE); propsConfig.save(userBuildFile); } } else { Properties props = new Properties(); props.putAll(properties); props.store(new FileOutputStream(userBuildFile), MSG_MANAGED_BY_LIFERAY_IDE); } }