Search in sources :

Example 16 with ConfigurationManager

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

the class WalkModFacade method inspectPlugin.

/**
 * Retrieves the bean definitions that contains an specific plugin.
 *
 * @param plugin
 *            Plugin container of bean definitions.
 * @return List of bean definitions.
 */
public List<BeanDefinition> inspectPlugin(PluginConfig plugin) {
    Configuration conf = new ConfigurationImpl();
    Collection<PluginConfig> plugins = new LinkedList<PluginConfig>();
    plugins.add(plugin);
    conf.setPlugins(plugins);
    ConfigurationManager manager = new ConfigurationManager(conf, false, locateConfigurationProvider());
    manager.executeConfigurationProviders();
    return conf.getAvailableBeans(plugin);
}
Also used : PluginConfig(org.walkmod.conf.entities.PluginConfig) Configuration(org.walkmod.conf.entities.Configuration) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) ConfigurationManager(org.walkmod.conf.ConfigurationManager) LinkedList(java.util.LinkedList)

Example 17 with ConfigurationManager

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

the class WalkModFacade method init.

/**
 * Initializes an empty walkmod configuration file
 *
 * @throws Exception
 *             in case that the walkmod configuration file can't be created.
 */
public void init() throws Exception {
    userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
    System.setProperty("user.dir", options.getExecutionDirectory().getAbsolutePath());
    if (!cfg.exists()) {
        ConfigurationManager manager = new ConfigurationManager(cfg, false, locateConfigurationProvider());
        try {
            manager.runProjectConfigurationInitializers();
            if (options.isVerbose()) {
                log.info("CONFIGURATION FILE [" + cfg.getAbsolutePath() + "] CREATION COMPLETE");
            }
        } catch (IOException aux) {
            if (options.isVerbose()) {
                log.error("The system can't create the file [ " + cfg.getAbsolutePath() + "]");
            }
            if (options.isThrowException()) {
                System.setProperty("user.dir", userDir);
                throw aux;
            }
        }
    } else {
        if (options.isVerbose()) {
            log.error("The configuration file [" + cfg.getAbsolutePath() + "] already exists");
        }
    }
    System.setProperty("user.dir", userDir);
}
Also used : IOException(java.io.IOException) File(java.io.File) ConfigurationManager(org.walkmod.conf.ConfigurationManager)

Example 18 with ConfigurationManager

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

the class WalkModFacade method setReader.

/**
 * Sets an specific reader for an specific chain.
 *
 * @param chain
 *            Chain to apply the writer
 * @param type
 *            Reader type to set
 * @param path
 *            Reader path to set
 * @param recursive
 *            If to set the reader to all the submodules.
 * @param params
 *            Reader parameters
 * @throws Exception
 *             if the walkmod configuration file can't be read.
 */
public void setReader(String chain, String type, String path, boolean recursive, Map<String, String> params) throws Exception {
    if ((type != null && !"".equals(type.trim())) || (path != null && !"".equals(path.trim()))) {
        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.setReader(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 19 with ConfigurationManager

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

the class WalkModFacade method addPluginConfig.

/**
 * Adds a new plugin into the configuration file
 *
 * @param pluginConfig
 *            the plugin to add
 * @param recursive
 *            if the plugin config is added recursively to all the submodules.
 * @throws Exception
 *             in case that the walkmod configuration file can't be read.
 */
public void addPluginConfig(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.addPluginConfig(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 20 with ConfigurationManager

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

the class WalkModFacade method addIncludesToChain.

/**
 * Adds a list of includes rules into a chain
 *
 * @param chain
 *            Chain to apply the includes list
 * @param includes
 *            List of includes
 * @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 addIncludesToChain(String chain, List<String> includes, 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().addIncludesToChain(chain, includes, 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