Search in sources :

Example 6 with FeatureContainer

use of org.jboss.galleon.cli.model.FeatureContainer in project galleon by wildfly.

the class GetInfoCommand method displayOptionalPackages.

private boolean displayOptionalPackages(PmCommandInvocation commandInvocation, ProvisioningLayout<FeaturePackLayout> pLayout) throws ProvisioningException, IOException {
    try (ProvisioningRuntime rt = ProvisioningRuntimeBuilder.newInstance(commandInvocation.getPmSession().getMessageWriter(false)).initRtLayout(pLayout.transform(ProvisioningRuntimeBuilder.FP_RT_FACTORY)).build()) {
        FeatureContainer container = FeatureContainers.fromProvisioningRuntime(commandInvocation.getPmSession(), rt);
        String str = StateInfoUtil.buildOptionalPackages(commandInvocation.getPmSession(), container, pLayout);
        if (str != null) {
            commandInvocation.print(str);
        }
        return str != null;
    }
}
Also used : ProvisioningRuntime(org.jboss.galleon.runtime.ProvisioningRuntime) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer)

Example 7 with FeatureContainer

use of org.jboss.galleon.cli.model.FeatureContainer in project galleon by wildfly.

the class AbstractInstallationCommand method getFeatureContainer.

public FeatureContainer getFeatureContainer(PmSession session, ProvisioningLayout<FeaturePackLayout> layout) throws ProvisioningException, CommandExecutionException, IOException {
    FeatureContainer container;
    ProvisioningManager manager = getManager(session);
    if (manager.getProvisionedState() == null) {
        throw new CommandExecutionException("Specified directory doesn't contain an installation");
    }
    if (layout == null) {
        ProvisioningConfig config = manager.getProvisioningConfig();
        try (ProvisioningRuntime runtime = manager.getRuntime(config)) {
            container = FeatureContainers.fromProvisioningRuntime(session, runtime);
        }
    } else {
        try (ProvisioningRuntime runtime = manager.getRuntime(layout)) {
            container = FeatureContainers.fromProvisioningRuntime(session, runtime);
        }
    }
    return container;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningRuntime(org.jboss.galleon.runtime.ProvisioningRuntime) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException)

Example 8 with FeatureContainer

use of org.jboss.galleon.cli.model.FeatureContainer in project galleon by wildfly.

the class StateFullPathCompleter method getContainer.

@Override
protected FeatureContainer getContainer(PmCompleterInvocation completerInvocation) {
    PmSession session = completerInvocation.getPmSession();
    FeatureContainer container = session.getContainer();
    return container;
}
Also used : PmSession(org.jboss.galleon.cli.PmSession) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer)

Example 9 with FeatureContainer

use of org.jboss.galleon.cli.model.FeatureContainer in project galleon by wildfly.

the class StateInfoUtil method displayInfo.

public static void displayInfo(PmCommandInvocation invoc, Path installation, ProvisioningConfig config, String type, Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer> supplier) throws CommandExecutionException {
    try {
        if (!config.hasFeaturePackDeps()) {
            return;
        }
        invoc.println("");
        displayFeaturePacks(invoc, installation, config);
        if (type != null) {
            invoc.println("");
            try (ProvisioningLayout<FeaturePackLayout> layout = invoc.getPmSession().getLayoutFactory().newConfigLayout(config)) {
                switch(type) {
                    case ALL:
                        {
                            FeatureContainer container = supplier.apply(layout);
                            if (displayDependencies(invoc, layout)) {
                                invoc.println("");
                            }
                            if (displayPatches(invoc, layout)) {
                                invoc.println("");
                            }
                            if (displayConfigs(invoc, container, layout)) {
                                invoc.println("");
                            }
                            if (displayLayers(invoc, layout)) {
                                invoc.println("");
                            }
                            if (displayOptionalPackages(invoc, container, layout)) {
                                invoc.println("");
                            }
                            if (displayOptions(invoc, layout)) {
                                invoc.println("");
                            }
                            displayUniverses(invoc, config);
                            break;
                        }
                    case CONFIGS:
                        {
                            FeatureContainer container = supplier.apply(layout);
                            String configs = buildConfigs(invoc, container, layout);
                            if (configs != null) {
                                invoc.print(configs);
                            } else {
                                invoc.println(NO_CONFIGURATIONS);
                            }
                            break;
                        }
                    case DEPENDENCIES:
                        {
                            String deps = buildDependencies(invoc, layout);
                            if (deps != null) {
                                invoc.print(deps);
                            } else {
                                invoc.println(NO_DEPENDENCIES);
                            }
                            break;
                        }
                    case LAYERS:
                        {
                            String layers = buildLayers(layout);
                            if (layers != null) {
                                invoc.print(layers);
                            } else {
                                invoc.println(NO_LAYERS);
                            }
                            break;
                        }
                    case OPTIONS:
                        {
                            String options = buildOptions(layout);
                            if (options != null) {
                                invoc.print(options);
                            } else {
                                invoc.println(NO_OPTIONS);
                            }
                            break;
                        }
                    case PATCHES:
                        {
                            String patches = buildPatches(invoc, layout);
                            if (patches != null) {
                                invoc.print(patches);
                            } else {
                                invoc.println(NO_PATCHES);
                            }
                            break;
                        }
                    case UNIVERSES:
                        {
                            String universes = buildUniverses(config);
                            if (universes != null) {
                                invoc.print(universes);
                            } else {
                                invoc.println(NO_UNIVERSES);
                            }
                            break;
                        }
                    case OPTIONAL_PACKAGES:
                        {
                            FeatureContainer container = supplier.apply(layout);
                            String packages = buildOptionalPackages(invoc.getPmSession(), container, layout);
                            invoc.print(packages);
                            break;
                        }
                    default:
                        {
                            throw new CommandExecutionException(CliErrors.invalidInfoType());
                        }
                }
            }
        }
    } catch (Exception ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.infoFailed(), ex);
    }
}
Also used : FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) PathParserException(org.jboss.galleon.cli.path.PathParserException) PathConsumerException(org.jboss.galleon.cli.path.PathConsumerException) IOException(java.io.IOException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 10 with FeatureContainer

use of org.jboss.galleon.cli.model.FeatureContainer in project galleon by wildfly.

the class StateGetInfoCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
    try {
        ProvisioningConfig config = invoc.getPmSession().getContainer().getProvisioningConfig();
        Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer> supplier = new Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer>() {

            public FeatureContainer apply(ProvisioningLayout<FeaturePackLayout> layout) {
                return invoc.getPmSession().getState().getContainer();
            }
        };
        StateInfoUtil.displayInfo(invoc, null, config, type, supplier);
    } catch (Exception ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.infoFailed(), ex);
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) Function(java.util.function.Function) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningLayout(org.jboss.galleon.layout.ProvisioningLayout) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException)

Aggregations

FeatureContainer (org.jboss.galleon.cli.model.FeatureContainer)12 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)6 ProvisioningException (org.jboss.galleon.ProvisioningException)5 FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)3 PathConsumerException (org.jboss.galleon.cli.path.PathConsumerException)3 PathParserException (org.jboss.galleon.cli.path.PathParserException)3 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)3 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)3 IOException (java.io.IOException)2 Function (java.util.function.Function)2 ProvisioningManager (org.jboss.galleon.ProvisioningManager)2 PmSession (org.jboss.galleon.cli.PmSession)2 ProvisioningLayout (org.jboss.galleon.layout.ProvisioningLayout)2 ProvisioningRuntime (org.jboss.galleon.runtime.ProvisioningRuntime)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ConfigInfo (org.jboss.galleon.cli.model.ConfigInfo)1 Group (org.jboss.galleon.cli.model.Group)1 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)1 FeaturePackRuntime (org.jboss.galleon.runtime.FeaturePackRuntime)1