List of usage examples for org.apache.commons.configuration PropertiesConfigurationLayout PropertiesConfigurationLayout
public PropertiesConfigurationLayout(PropertiesConfiguration config)
PropertiesConfigurationLayout and initializes it with the associated configuration object. From source file:com.dcsquare.fileauthplugin.utility.properties.CredentialProperties.java
/** * Initialize properties file/*www . ja va2 s. co m*/ * * @param filename credential file name * @throws ConfigurationException is thrown if an error is encountered during loading of the file */ public CredentialProperties(String filename) throws ConfigurationException { propertiesConfiguration = new PropertiesConfiguration(); PropertiesConfigurationLayout propertiesConfigurationLayout = new PropertiesConfigurationLayout( propertiesConfiguration); propertiesConfigurationLayout.setGlobalSeparator(":"); propertiesConfiguration.setFile(new File(filename)); propertiesConfiguration.load(); }
From source file:com.thoughtworks.go.agent.service.AgentAutoRegistrationProperties.java
public void scrubRegistrationProperties() { if (!exist()) { return;/*w w w. j av a 2s . co m*/ } try { PropertiesConfiguration config = new PropertiesConfiguration(); config.setIOFactory(new FilteringOutputWriterFactory()); PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout(config); layout.setLineSeparator("\n"); layout.load(reader()); layout.save(new FileWriter(this.configFile)); } catch (ConfigurationException | IOException e) { LOG.warn("[Agent Auto Registration] Unable to scrub registration key.", e); } }
From source file:bioLockJ.module.agent.MailAgent.java
/** * Used to obtain a new encrypted password hash when the admin email password is set. * @param password//from w ww . j a v a 2s . c om * @throws Exception */ public static void encryptAndStoreEmailPassword(final String propFile, final String password) throws Exception { final String encryptedPassword = encrypt(password); final PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout( new PropertiesConfiguration()); layout.load(new InputStreamReader(new FileInputStream(propFile))); final PropertyFileContainer props = Config.readProps(new File(propFile), null); props.setProperty(EMAIL_ENCRYPTED_PASSWORD, encryptedPassword); layout.save(new FileWriter(propFile, false)); System.out.println("CONFIG FILE UPDATED WITH ENCRYPTED PASSWORD: " + encryptedPassword); }
From source file:org.sonar.plugins.l10n.L10nHackyPropertiesUpdater.java
public static void main(String[] args) throws ConfigurationException, IOException { URL l10nRoot = FrenchPackPlugin.class.getResource(BundleSynchronizedMatcher.L10N_PATH); Collection<File> bundles = FileUtils.listFiles(FileUtils.toFile(l10nRoot), new String[] { "properties" }, false);/*from ww w . jav a 2 s.c o m*/ for (File localizedBundle : bundles) { String originalVersion = localizedBundle.getName().replaceFirst("_fr\\.", "."); System.out.println("Processing " + localizedBundle + " looking for " + originalVersion); URL originalBundle = FrenchPackPlugin.class .getResource(BundleSynchronizedMatcher.L10N_PATH + originalVersion); if (originalBundle == null) { System.out.println("\tOriginal bundle not found"); } else { System.out.println("\tOriginal bundle found, let's try to update the localized version"); Properties localizedProps = new Properties(); localizedProps.load(new FileInputStream(localizedBundle)); PropertiesConfiguration config = new PropertiesConfiguration(); PropertiesConfigurationLayout layout = new PropertiesConfigurationLayout(config); layout.load(new InputStreamReader(FrenchPackPlugin.class .getResourceAsStream(BundleSynchronizedMatcher.L10N_PATH + originalVersion))); for (@SuppressWarnings("unchecked") Iterator<String> it = config.getKeys(); it.hasNext();) { String key = it.next(); Object localizedValue = localizedProps.get(key); if (localizedValue != null) { config.setProperty(key, localizedValue); } else { System.out.println("Nothing found for " + key); String currentValue = config.getString(key); config.setProperty(key, currentValue + " <== TODO"); } } layout.save(new FileWriter(localizedBundle)); System.out.println("\tFixing spaces"); fixSpacesAroundEqualsAndScrewUpEncoding(localizedBundle); System.out.println("OK: file " + localizedBundle + " contains ready-to-translate updated file."); } } }