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;
}
}
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;
}
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;
}
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);
}
}
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);
}
}
Aggregations