Search in sources :

Example 16 with CommandExecutionException

use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.

the class StateExcludePackageCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc, State session, FeaturePackConfig config) throws IOException, ProvisioningException, CommandExecutionException {
    try {
        int i = getPackage().indexOf("/");
        String name = getPackage().substring(i + 1);
        // but no transitive dependency has been created yet.
        if (config == null) {
            session.excludePackageFromNewTransitive(invoc.getPmSession(), getProducer(invoc.getPmSession()), name);
        } else {
            session.excludePackage(invoc.getPmSession(), name, config);
        }
    } catch (Exception ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.excludeFailed(), ex);
    }
}
Also used : CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 17 with CommandExecutionException

use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.

the class AbstractPackageCommand method getProvisionedFP.

@Override
public FeaturePackConfig getProvisionedFP(PmSession session) throws CommandExecutionException {
    FeaturePackConfig config = super.getProvisionedFP(session);
    if (config == null) {
        // Problem, the package is not directly part of the added FP. Must retrieve it in the packages of
        // its internal dependencies.
        int i = getPackage().indexOf("/");
        String orig = getPackage().substring(0, i);
        String name = getPackage().substring(i + 1);
        FeaturePackLocation.FPID fpid = null;
        FeatureContainer container = session.getContainer().getFullDependencies().get(orig);
        if (container != null) {
            if (container.getAllPackages().containsKey(Identity.fromString(orig, name))) {
                fpid = container.getFPID();
            }
        }
        if (fpid == null) {
            throw new CommandExecutionException("No package found for " + getPackage());
        }
        for (FeaturePackConfig c : session.getState().getConfig().getFeaturePackDeps()) {
            if (c.getLocation().getFPID().equals(fpid)) {
                config = c;
                break;
            }
        }
        if (config == null) {
            // reset buildID
            FeaturePackLocation noBuildLocation = new FeaturePackLocation(fpid.getUniverse(), fpid.getProducer().getName(), null, null, null);
            for (FeaturePackConfig c : session.getState().getConfig().getTransitiveDeps()) {
                if (c.getLocation().equals(c.getLocation().hasBuild() ? fpid.getLocation() : noBuildLocation)) {
                    config = c;
                    break;
                }
            }
        }
    }
    return config;
}
Also used : FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 18 with CommandExecutionException

use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.

the class AbstractPackageCommand method getProducer.

@Override
public ProducerSpec getProducer(PmSession session) throws CommandExecutionException {
    if (pkg == null) {
        throw new CommandExecutionException("No package set.");
    }
    String fullpath = FeatureContainerPathConsumer.PACKAGES_PATH + pkg;
    FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(new AllPackagesContainer(session.getState().getContainer()), false);
    try {
        PathParser.parse(fullpath, consumer);
        Group grp = consumer.getCurrentNode(fullpath);
        if (grp == null) {
            throw new CommandExecutionException("Invalid package " + pkg);
        }
        PackageInfo info = grp.getPackage();
        if (info == null) {
            throw new CommandExecutionException("Invalid package " + pkg);
        }
        return info.getFPID().getProducer();
    } catch (PathParserException | PathConsumerException ex) {
        throw new CommandExecutionException(session, CliErrors.retrieveProducerFailed(), ex);
    }
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) Group(org.jboss.galleon.cli.model.Group) PackageInfo(org.jboss.galleon.cli.model.PackageInfo) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) PathParserException(org.jboss.galleon.cli.path.PathParserException) PathConsumerException(org.jboss.galleon.cli.path.PathConsumerException)

Example 19 with CommandExecutionException

use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.

the class StateSearchCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
    try {
        if (query == null && pkg == null) {
            throw new CommandExecutionException("One of --query or --package must be set");
        }
        FeatureContainer container = invoc.getPmSession().getContainer();
        run(invoc.getPmSession().getContainer(), invoc, false);
        if (inDependencies) {
            if (!container.getFullDependencies().isEmpty()) {
                invoc.println("");
                invoc.println("Search in dependencies");
                for (FeatureContainer c : container.getFullDependencies().values()) {
                    invoc.println("dependency: " + c.getFPID());
                    run(c, invoc, true);
                }
            }
        }
    } catch (Exception ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.searchFailed(), ex);
    }
}
Also used : CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) PathConsumerException(org.jboss.galleon.cli.path.PathConsumerException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException) PathParserException(org.jboss.galleon.cli.path.PathParserException)

Example 20 with CommandExecutionException

use of org.jboss.galleon.cli.CommandExecutionException in project galleon by wildfly.

the class StateEditCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
    State state;
    try {
        state = new State(invoc.getPmSession(), getInstallationHome(invoc.getConfiguration().getAeshContext()));
    } catch (ProvisioningException | IOException ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.readContentFailed(), ex);
    }
    invoc.getPmSession().setState(state);
    invoc.setPrompt(invoc.getPmSession().buildPrompt(state.getPath()));
    invoc.println(WELCOME_STATE_MSG);
}
Also used : State(org.jboss.galleon.cli.model.state.State) ProvisioningException(org.jboss.galleon.ProvisioningException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException)

Aggregations

CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)37 ProvisioningException (org.jboss.galleon.ProvisioningException)25 IOException (java.io.IOException)18 Path (java.nio.file.Path)11 ProvisioningManager (org.jboss.galleon.ProvisioningManager)8 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)7 FeatureContainer (org.jboss.galleon.cli.model.FeatureContainer)6 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)6 State (org.jboss.galleon.cli.model.state.State)5 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)5 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)4 ArrayList (java.util.ArrayList)3 Group (org.jboss.galleon.cli.model.Group)3 FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)3 PathConsumerException (org.jboss.galleon.cli.path.PathConsumerException)3 PathParserException (org.jboss.galleon.cli.path.PathParserException)3 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 PrintWriter (java.io.PrintWriter)2