Search in sources :

Example 1 with ProvisioningOption

use of org.jboss.galleon.ProvisioningOption in project galleon by wildfly.

the class ProvisioningLayout method processOptions.

private void processOptions(Iterable<? extends ProvisioningOption> pluginOptions, Map<String, String> extraOptions, final Map<String, ProvisioningOption> recognizedOptions, final List<ProvisioningOption> overridenOptions) throws ProvisioningException {
    for (ProvisioningOption pluginOption : pluginOptions) {
        final String optionName = pluginOption.getName();
        if (!options.containsKey(optionName)) {
            if (pluginOption.isRequired()) {
                throw new ProvisioningException(Errors.pluginOptionRequired(optionName));
            }
            continue;
        }
        final ProvisioningOption existing = recognizedOptions.put(optionName, pluginOption);
        // doesn't override a persistent one
        if (existing != null && existing.isPersistent() && !pluginOption.isPersistent()) {
            recognizedOptions.put(existing.getName(), existing);
        } else if (pluginOption.isPersistent() || extraOptions.containsKey(optionName) && config.hasOption(optionName)) {
            overridenOptions.add(pluginOption);
        }
    }
}
Also used : ProvisioningException(org.jboss.galleon.ProvisioningException) ProvisioningOption(org.jboss.galleon.ProvisioningOption)

Example 2 with ProvisioningOption

use of org.jboss.galleon.ProvisioningOption in project galleon by wildfly.

the class StateProvisionCommand method getDynamicOptions.

@Override
protected List<AbstractDynamicCommand.DynamicOption> getDynamicOptions(State state) throws Exception {
    if (state == null) {
        return Collections.emptyList();
    }
    List<AbstractDynamicCommand.DynamicOption> options = new ArrayList<>();
    ProvisioningRuntime rt = state.getRuntime();
    Set<ProvisioningOption> opts = getPluginOptions(rt);
    for (ProvisioningOption opt : opts) {
        AbstractDynamicCommand.DynamicOption dynOption = new AbstractDynamicCommand.DynamicOption(opt.getName(), opt.isRequired());
        options.add(dynOption);
    }
    return options;
}
Also used : ProvisioningRuntime(org.jboss.galleon.runtime.ProvisioningRuntime) ArrayList(java.util.ArrayList) ProvisioningOption(org.jboss.galleon.ProvisioningOption) AbstractDynamicCommand(org.jboss.galleon.cli.cmd.AbstractDynamicCommand)

Example 3 with ProvisioningOption

use of org.jboss.galleon.ProvisioningOption in project galleon by wildfly.

the class AbstractPluginsCommand method getDynamicOptions.

@Override
protected List<DynamicOption> getDynamicOptions(State state) throws Exception {
    List<DynamicOption> options = new ArrayList<>();
    FeaturePackLocation fpl = pmSession.getResolvedLocation(getInstallationDirectory(pmSession.getAeshContext()), getId(pmSession));
    Set<ProvisioningOption> pluginOptions = getPluginOptions(fpl);
    for (ProvisioningOption opt : pluginOptions) {
        DynamicOption dynOption = new DynamicOption(opt.getName(), opt.isRequired());
        options.add(dynOption);
    }
    return options;
}
Also used : ArrayList(java.util.ArrayList) ProvisioningOption(org.jboss.galleon.ProvisioningOption) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 4 with ProvisioningOption

use of org.jboss.galleon.ProvisioningOption in project galleon by wildfly.

the class UpdateCommand method getDynamicOptions.

@Override
protected List<DynamicOption> getDynamicOptions(State state) throws Exception {
    String targetDirArg = (String) getValue(DIR_OPTION_NAME);
    if (targetDirArg == null) {
        // Check in argument or option, that is the option completion case.
        targetDirArg = getOptionValue(DIR_OPTION_NAME);
    }
    Path installation = getAbsolutePath(targetDirArg, pmSession.getAeshContext());
    ProvisioningConfig config = pmSession.newProvisioningManager(installation, false).getProvisioningConfig();
    Set<ProvisioningOption> opts = pmSession.getResolver().get(null, PluginResolver.newResolver(pmSession, config)).getDiff();
    List<DynamicOption> options = new ArrayList<>();
    for (ProvisioningOption opt : opts) {
        DynamicOption dynOption = new DynamicOption(opt.getName(), opt.isRequired());
        options.add(dynOption);
    }
    return options;
}
Also used : Path(java.nio.file.Path) ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ProvisioningOption(org.jboss.galleon.ProvisioningOption) ArrayList(java.util.ArrayList)

Example 5 with ProvisioningOption

use of org.jboss.galleon.ProvisioningOption in project galleon by wildfly.

the class ProvisionCommand method getDynamicOptions.

@Override
protected List<DynamicOption> getDynamicOptions(State state) throws Exception {
    List<DynamicOption> options = new ArrayList<>();
    Set<ProvisioningOption> opts;
    String file = getFile();
    if (file == null) {
        return Collections.emptyList();
    }
    ProvisioningConfig config = ProvisioningXmlParser.parse(getAbsolutePath(file, pmSession.getAeshContext()));
    opts = pmSession.getResolver().get(null, PluginResolver.newResolver(pmSession, config)).getInstall();
    for (ProvisioningOption opt : opts) {
        DynamicOption dynOption = new DynamicOption(opt.getName(), opt.isRequired());
        options.add(dynOption);
    }
    return options;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ArrayList(java.util.ArrayList) ProvisioningOption(org.jboss.galleon.ProvisioningOption)

Aggregations

ProvisioningOption (org.jboss.galleon.ProvisioningOption)8 ArrayList (java.util.ArrayList)5 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)4 Path (java.nio.file.Path)2 ProvisioningException (org.jboss.galleon.ProvisioningException)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 AbstractDynamicCommand (org.jboss.galleon.cli.cmd.AbstractDynamicCommand)1 Table (org.jboss.galleon.cli.cmd.Table)1 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)1 InstallPlugin (org.jboss.galleon.plugin.InstallPlugin)1 ProvisioningRuntime (org.jboss.galleon.runtime.ProvisioningRuntime)1 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)1