Search in sources :

Example 1 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method setWriter.

/**
 * Sets an specific writer for an specific chain.
 *
 * @param chain
 *            Chain to apply the writer
 * @param type
 *            Writer type to set
 * @param path
 *            Writer path to set
 * @param recursive
 *            If to set the writer to all the submodules.
 * @param params
 *            Writer parameters
 * @throws Exception
 *             if the walkmod configuration file can't be read.
 */
public void setWriter(String chain, String type, String path, boolean recursive, Map<String, String> params) throws Exception {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if ((type != null && !"".equals(type.trim())) || (path != null && !"".equals(path.trim()))) {
        if (!cfg.exists()) {
            init();
        }
        userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
        System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
        try {
            ConfigurationManager manager = new ConfigurationManager(cfg, false);
            ProjectConfigurationProvider cfgProvider = manager.getProjectConfigurationProvider();
            cfgProvider.setWriter(chain, type, path, recursive, params);
        } catch (Exception e) {
            exception = e;
        } finally {
            System.setProperty("user.dir", userDir);
            updateMsg(startTime, exception);
        }
    }
}
Also used : ProjectConfigurationProvider(org.walkmod.conf.ProjectConfigurationProvider) File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Example 2 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method readConfig.

private Configuration readConfig(ConfigurationProvider... cp) throws InvalidConfigurationException {
    Configuration config = null;
    try {
        ConfigurationManager cfgManager = new ConfigurationManager(cfg, cp);
        config = cfgManager.getConfiguration();
        config.setParameters(options.getMutableCopyOfDynamicArgs());
    } catch (Exception e) {
        printConfigError(e);
    }
    return config;
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Example 3 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method removeChains.

/**
 * Removes the chains from the Walkmod config file.
 *
 * @param chains
 *            Chain names to remove
 * @param recursive
 *            If it necessary to remove the chains from all the submodules.
 * @throws Exception
 *             If the walkmod configuration file can't be read.
 */
public void removeChains(List<String> chains, boolean recursive) throws Exception {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if (cfg.exists()) {
        userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
        System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
        try {
            ConfigurationManager manager = new ConfigurationManager(cfg, false);
            manager.getProjectConfigurationProvider().removeChains(chains, recursive);
        } catch (Exception e) {
            exception = e;
        } finally {
            System.setProperty("user.dir", userDir);
            updateMsg(startTime, exception);
        }
    }
}
Also used : File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Example 4 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method removePluginConfig.

/**
 * Removes a plugin from the configuration file.
 *
 * @param pluginConfig
 *            Plugin configuration to remove.
 * @param recursive
 *            If it necessary to remove the plugin from all the submodules.
 * @throws Exception
 *             if the walkmod configuration file can't be read.
 */
public void removePluginConfig(PluginConfig pluginConfig, boolean recursive) throws Exception {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if (!cfg.exists()) {
        init();
    }
    userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
    System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
    try {
        ConfigurationManager manager = new ConfigurationManager(cfg, false);
        ProjectConfigurationProvider cfgProvider = manager.getProjectConfigurationProvider();
        cfgProvider.removePluginConfig(pluginConfig, recursive);
    } catch (Exception e) {
        exception = e;
    } finally {
        System.setProperty("user.dir", userDir);
        updateMsg(startTime, exception);
    }
}
Also used : ProjectConfigurationProvider(org.walkmod.conf.ProjectConfigurationProvider) File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Example 5 with ConfigurationManager

use of org.walkmod.conf.ConfigurationManager in project walkmod-core by walkmod.

the class WalkModFacade method addExcludesToChain.

/**
 * Adds a list of excludes rules into a chain
 *
 * @param chain
 *            Chain to apply the excludes list
 * @param excludes
 *            List of excludes
 * @param recursive
 *            If it necessary to set the parameter to all the submodules.
 * @param setToReader
 *            If it is added into the reader includes list
 * @param setToWriter
 *            If it is added into the writer includes list
 */
public void addExcludesToChain(String chain, List<String> excludes, boolean recursive, boolean setToReader, boolean setToWriter) {
    long startTime = System.currentTimeMillis();
    Exception exception = null;
    if (cfg.exists()) {
        userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
        System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
        try {
            ConfigurationManager manager = new ConfigurationManager(cfg, false);
            manager.getProjectConfigurationProvider().addExcludesToChain(chain, excludes, recursive, setToReader, setToWriter);
        } catch (Exception e) {
            exception = e;
        } finally {
            System.setProperty("user.dir", userDir);
            updateMsg(startTime, exception);
        }
    }
}
Also used : File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager) WalkModException(org.walkmod.exceptions.WalkModException) IOException(java.io.IOException) InvalidConfigurationException(org.walkmod.exceptions.InvalidConfigurationException)

Aggregations

ConfigurationManager (org.walkmod.conf.ConfigurationManager)23 IOException (java.io.IOException)21 File (java.io.File)20 InvalidConfigurationException (org.walkmod.exceptions.InvalidConfigurationException)20 WalkModException (org.walkmod.exceptions.WalkModException)20 ProjectConfigurationProvider (org.walkmod.conf.ProjectConfigurationProvider)12 Configuration (org.walkmod.conf.entities.Configuration)5 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)2 DynamicConfigurationProvider (org.walkmod.conf.providers.DynamicConfigurationProvider)2 DynamicModulesConfigurationProvider (org.walkmod.conf.providers.DynamicModulesConfigurationProvider)2 DateFormat (java.text.DateFormat)1 DecimalFormat (java.text.DecimalFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 ConfigurationProvider (org.walkmod.conf.ConfigurationProvider)1 PluginConfig (org.walkmod.conf.entities.PluginConfig)1 IvyConfigurationProvider (org.walkmod.conf.providers.IvyConfigurationProvider)1