Search in sources :

Example 1 with Group

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

the class FeatureContainerPathConsumer method enterPackagesContent.

private void enterPackagesContent(PathParser.Node node) throws PathConsumerException {
    Group next = null;
    if (current == null) {
        current = info.getPackages().get(packagesGav);
        if (current == null) {
            throw new PathConsumerException("no package in " + packagesGav);
        }
    }
    for (Group info : current.getGroups()) {
        if (info.getIdentity().getName().equals(node.getName())) {
            next = info;
            break;
        }
    }
    if (next == null) {
        if (completion) {
            if (inError) {
                throw new PathConsumerException("no node for name " + node.getName());
            } else {
                inError = true;
            }
        } else {
            throw new PathConsumerException("no node for name " + node.getName());
        }
    } else {
        current = next;
    }
    packagesGav = null;
}
Also used : Group(org.jboss.galleon.cli.model.Group)

Example 2 with Group

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

the class StateInfoUtil method displayPackage.

private static void displayPackage(PmCommandInvocation session, Group grp) throws IOException {
    PackageInfo pkg = grp.getPackage();
    session.println("");
    session.println("Package name : " + pkg.getIdentity().getName());
    session.println("Package origin : " + pkg.getIdentity().getOrigin());
    session.println(Config.getLineSeparator() + "Package providers (features that depend on this package)");
    if (pkg.getProviders().isEmpty()) {
        session.println("default provider");
    } else {
        for (Identity id : pkg.getProviders()) {
            session.println(id.toString());
        }
    }
    session.println(Config.getLineSeparator() + "Package dependencies");
    if (grp.getGroups().isEmpty()) {
        session.println("NONE");
    } else {
        for (Group dep : grp.getGroups()) {
            session.println(dep.getIdentity().toString());
        }
    }
    session.println(Config.getLineSeparator() + "Package content");
    String customContent = pkg.getCustomContent();
    if (customContent != null) {
        session.println(customContent);
    } else if (pkg.getContent().isEmpty()) {
        session.println("NONE");
    } else {
        StringBuilder contentBuilder = new StringBuilder();
        for (String name : pkg.getContent()) {
            contentBuilder.append("  " + name + Config.getLineSeparator());
        }
        session.println(contentBuilder.toString());
    }
}
Also used : Group(org.jboss.galleon.cli.model.Group) PackageInfo(org.jboss.galleon.cli.model.PackageInfo) Identity(org.jboss.galleon.cli.model.Identity)

Example 3 with Group

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

the class StateAddFeatureCommand method getSpec.

private FeatureSpecInfo getSpec(State state, String id) throws PathParserException, PathConsumerException, ProvisioningException {
    String path = FeatureContainerPathConsumer.FEATURES_PATH + id;
    FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(new AllFeaturesContainer(state.getContainer()), false);
    PathParser.parse(path, consumer);
    Group grp = consumer.getCurrentNode(path);
    if (grp == null) {
        throw new ProvisioningException("Invalid path");
    }
    if (grp.getSpec() == null) {
        throw new ProvisioningException("Path is not a feature-spec");
    }
    return grp.getSpec();
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) Group(org.jboss.galleon.cli.model.Group) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 4 with Group

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

the class StateRemoveFeatureCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc, State session) throws IOException, ProvisioningException, CommandExecutionException {
    try {
        String path = FeatureContainerPathConsumer.FINAL_CONFIGS_PATH + (feature.endsWith("" + PathParser.PATH_SEPARATOR) ? feature : feature + PathParser.PATH_SEPARATOR);
        FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(session.getContainer(), false);
        PathParser.parse(path, consumer);
        ConfigInfo ci = consumer.getConfig();
        if (ci == null) {
            throw new ProvisioningException("Not a valid configuration " + feature);
        }
        Group grp = consumer.getCurrentNode(path);
        if (grp == null) {
            throw new ProvisioningException("Not a valid feature " + feature);
        }
        FeatureInfo fi = grp.getFeature();
        if (fi == null) {
            throw new ProvisioningException("Not a valid feature " + feature);
        }
        session.removeFeature(invoc.getPmSession(), ci, fi);
    } catch (Exception ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.removeFeatureFailed(), ex);
    }
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) Group(org.jboss.galleon.cli.model.Group) ProvisioningException(org.jboss.galleon.ProvisioningException) FeatureInfo(org.jboss.galleon.cli.model.FeatureInfo) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ConfigInfo(org.jboss.galleon.cli.model.ConfigInfo) IOException(java.io.IOException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 5 with Group

use of org.jboss.galleon.cli.model.Group 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)

Aggregations

Group (org.jboss.galleon.cli.model.Group)12 FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)7 ProvisioningException (org.jboss.galleon.ProvisioningException)4 PackageInfo (org.jboss.galleon.cli.model.PackageInfo)4 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)3 FeatureInfo (org.jboss.galleon.cli.model.FeatureInfo)2 Identity (org.jboss.galleon.cli.model.Identity)2 ResolvedSpecId (org.jboss.galleon.runtime.ResolvedSpecId)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 List (java.util.List)1 PmSession (org.jboss.galleon.cli.PmSession)1 ConfigInfo (org.jboss.galleon.cli.model.ConfigInfo)1 FeatureContainer (org.jboss.galleon.cli.model.FeatureContainer)1 FeatureSpecInfo (org.jboss.galleon.cli.model.FeatureSpecInfo)1 PathConsumerException (org.jboss.galleon.cli.path.PathConsumerException)1 PathParserException (org.jboss.galleon.cli.path.PathParserException)1