Search in sources :

Example 1 with PathConsumerException

use of org.jboss.galleon.cli.path.PathConsumerException 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 2 with PathConsumerException

use of org.jboss.galleon.cli.path.PathConsumerException in project galleon by wildfly.

the class ConfigurationUtil method getConfig.

private static ConfigInfo getConfig(PmSession session, FPID fpid, String configuration) throws ProvisioningException, IOException, PathParserException, PathConsumerException {
    String path = FeatureContainerPathConsumer.FINAL_CONFIGS_PATH + configuration + PathParser.PATH_SEPARATOR;
    FeatureContainer full = FeatureContainers.fromFeaturePackId(session, fpid, null);
    ConfigInfo ci = null;
    try {
        FeatureContainerPathConsumer consumer = new FeatureContainerPathConsumer(full, false);
        PathParser.parse(path, consumer);
        ci = consumer.getConfig();
    } catch (PathParserException | PathConsumerException ex) {
    // XXX OK, return null
    }
    return ci;
}
Also used : FeatureContainerPathConsumer(org.jboss.galleon.cli.path.FeatureContainerPathConsumer) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) PathParserException(org.jboss.galleon.cli.path.PathParserException) ConfigInfo(org.jboss.galleon.cli.model.ConfigInfo) PathConsumerException(org.jboss.galleon.cli.path.PathConsumerException)

Aggregations

FeatureContainerPathConsumer (org.jboss.galleon.cli.path.FeatureContainerPathConsumer)2 PathConsumerException (org.jboss.galleon.cli.path.PathConsumerException)2 PathParserException (org.jboss.galleon.cli.path.PathParserException)2 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)1 ConfigInfo (org.jboss.galleon.cli.model.ConfigInfo)1 FeatureContainer (org.jboss.galleon.cli.model.FeatureContainer)1 Group (org.jboss.galleon.cli.model.Group)1 PackageInfo (org.jboss.galleon.cli.model.PackageInfo)1