Search in sources :

Example 1 with FeatureContainer

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

the class State method buildNewConfig.

private ProvisioningConfig buildNewConfig(PmSession pmSession) throws ProvisioningException, IOException {
    ProvisioningConfig tmp = builder.build();
    if (runtime != null) {
        runtime.close();
    }
    runtime = ProvisioningRuntimeBuilder.newInstance(pmSession.getMessageWriter(false)).initLayout(pmSession.getLayoutFactory(), tmp).build();
    try {
        Set<FeaturePackLocation.FPID> dependencies = new HashSet<>();
        for (FeaturePackRuntime rt : runtime.getFeaturePacks()) {
            dependencies.add(rt.getFPID());
        }
        FeatureContainer tmpContainer = FeatureContainers.fromProvisioningRuntime(pmSession, runtime);
        // Need to have in sync the current with the full.
        // If fullConainer creation is a failure, the container will be not updated.
        Map<String, FeatureContainer> tmpDeps = new HashMap<>();
        if (container != null) {
            tmpDeps.putAll(container.getFullDependencies());
        }
        buildDependencies(pmSession, dependencies, tmpDeps);
        container = tmpContainer;
        container.setEdit(true);
        container.setFullDependencies(tmpDeps);
    } catch (ProvisioningException ex) {
        runtime.close();
        throw ex;
    }
    return tmp;
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) HashMap(java.util.HashMap) ProvisioningException(org.jboss.galleon.ProvisioningException) FeaturePackRuntime(org.jboss.galleon.runtime.FeaturePackRuntime) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) HashSet(java.util.HashSet)

Example 2 with FeatureContainer

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

the class GetInfoCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
    try {
        Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer> supplier = new Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer>() {

            public FeatureContainer apply(ProvisioningLayout<FeaturePackLayout> layout) {
                try {
                    return getFeatureContainer(invoc.getPmSession(), layout);
                } catch (CommandExecutionException | ProvisioningException | IOException ex) {
                    throw new RuntimeException(ex);
                }
            }
        };
        ProvisioningManager mgr = getManager(invoc.getPmSession());
        StateInfoUtil.displayInfo(invoc, mgr.getInstallationHome(), mgr.getProvisioningConfig(), type, supplier);
    } catch (ProvisioningException | CommandExecutionException ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.infoFailed(), ex);
    }
}
Also used : Function(java.util.function.Function) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) ProvisioningManager(org.jboss.galleon.ProvisioningManager) ProvisioningException(org.jboss.galleon.ProvisioningException) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) IOException(java.io.IOException) ProvisioningLayout(org.jboss.galleon.layout.ProvisioningLayout)

Example 3 with FeatureContainer

use of org.jboss.galleon.cli.model.FeatureContainer 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 4 with FeatureContainer

use of org.jboss.galleon.cli.model.FeatureContainer 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 5 with FeatureContainer

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

the class AbstractPathCompleter method getItems.

List<String> getItems(PmCompleterInvocation completerInvocation) {
    PmSession session = completerInvocation.getPmSession();
    try {
        FeatureContainer container = getContainer(completerInvocation);
        if (container == null) {
            return Collections.emptyList();
        }
        if (session.getCurrentPath() == null && completerInvocation.getGivenCompleteValue().isEmpty()) {
            return Arrays.asList("" + PathParser.PATH_SEPARATOR);
        }
        String buffer = completerInvocation.getGivenCompleteValue();
        if (!buffer.startsWith("" + PathParser.PATH_SEPARATOR)) {
            String currentPath = getCurrentPath(completerInvocation);
            if (currentPath != null) {
                boolean completePath = currentPath.endsWith("" + PathParser.PATH_SEPARATOR);
                buffer = currentPath + (completePath ? "" : "" + PathParser.PATH_SEPARATOR) + buffer;
            }
        }
        FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(container, true);
        PathParser.parse(buffer, consumer);
        List<String> candidates = consumer.getCandidates(buffer);
        filterCandidates(consumer, candidates);
        return candidates;
    } catch (Exception ex) {
        CliLogging.log.errorf("Exception while completing: {0}", ex.getLocalizedMessage());
    }
    return Collections.emptyList();
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) PmSession(org.jboss.galleon.cli.PmSession) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer)

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