Search in sources :

Example 16 with ProvisioningManager

use of org.jboss.galleon.ProvisioningManager 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 17 with ProvisioningManager

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

the class ClearHistoryCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
    try {
        ProvisioningManager mgr = getManager(invoc.getPmSession());
        mgr.clearStateHistory();
    } catch (ProvisioningException ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.clearHistoryFailed(), ex);
    }
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException)

Example 18 with ProvisioningManager

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

the class UniverseManager method getDefaultUniverseSpec.

public UniverseSpec getDefaultUniverseSpec(Path installation) {
    UniverseSpec defaultUniverse = null;
    if (pmSession.getState() != null) {
        defaultUniverse = pmSession.getState().getConfig().getDefaultUniverse();
    } else {
        try {
            ProvisioningManager mgr = getProvisioningManager(installation);
            defaultUniverse = mgr.getProvisioningConfig().getDefaultUniverse();
        } catch (ProvisioningException ex) {
        // OK, not an installation
        }
    }
    return defaultUniverse == null ? builtinUniverseSpec : defaultUniverse;
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningException(org.jboss.galleon.ProvisioningException) UniverseSpec(org.jboss.galleon.universe.UniverseSpec)

Example 19 with ProvisioningManager

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

the class UniverseManager method addUniverse.

public void addUniverse(Path installation, String name, String factory, String location) throws ProvisioningException, IOException {
    UniverseSpec u = new UniverseSpec(factory, location);
    ProvisioningManager mgr = getProvisioningManager(installation);
    if (name != null) {
        mgr.addUniverse(name, u);
    } else {
        mgr.setDefaultUniverse(u);
    }
    resolveUniverse(u);
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager) UniverseSpec(org.jboss.galleon.universe.UniverseSpec)

Example 20 with ProvisioningManager

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

the class UpdateCommand method doRunCommand.

@Override
protected void doRunCommand(PmCommandInvocation session, Map<String, String> options) throws CommandExecutionException {
    try {
        ProvisioningManager mgr = getManager(session);
        Updates updates = CheckUpdatesCommand.getUpdatesTable(mgr, session, allDependencies(), getFP());
        if (updates.plan.isEmpty()) {
            session.println(UP_TO_DATE);
        } else {
            session.println(UPDATES_AVAILABLE);
            session.println(updates.t.build());
            if (!noConfirm()) {
                try {
                    Key k = null;
                    while (k == null || (!Key.y.equals(k) && !Key.n.equals(k))) {
                        session.print("Proceed with latest updates [y/n]?");
                        KeyAction a = session.input();
                        k = Key.findStartKey(a.buffer().array());
                    }
                    if (Key.n.equals(k)) {
                        return;
                    }
                } finally {
                    session.println("");
                }
            }
            mgr.apply(updates.plan, options);
        }
    } catch (ProvisioningException | IOException ex) {
        throw new CommandExecutionException(session.getPmSession(), CliErrors.updateFailed(), ex);
    } catch (InterruptedException ignored) {
    // Just exit the command smoothly
    }
}
Also used : ProvisioningManager(org.jboss.galleon.ProvisioningManager) Updates(org.jboss.galleon.cli.cmd.maingrp.CheckUpdatesCommand.Updates) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException) KeyAction(org.aesh.readline.action.KeyAction) Key(org.aesh.readline.terminal.Key)

Aggregations

ProvisioningManager (org.jboss.galleon.ProvisioningManager)25 ProvisioningException (org.jboss.galleon.ProvisioningException)11 Path (java.nio.file.Path)8 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)8 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)7 IOException (java.io.IOException)6 Test (org.junit.Test)6 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)4 UniverseSpec (org.jboss.galleon.universe.UniverseSpec)4 MvnMessageWriter (org.jboss.galleon.maven.plugin.util.MvnMessageWriter)3 BufferedReader (java.io.BufferedReader)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 CommandException (org.aesh.command.CommandException)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 FeatureContainer (org.jboss.galleon.cli.model.FeatureContainer)2 ConfigModel (org.jboss.galleon.config.ConfigModel)2 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)2 MavenArtifactRepositoryManager (org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager)2 RepositoryArtifactResolver (org.jboss.galleon.repo.RepositoryArtifactResolver)2 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)2