Search in sources :

Example 6 with FeaturePackLayout

use of org.jboss.galleon.layout.FeaturePackLayout in project galleon by wildfly.

the class LayersConfigBuilder method getAllLayers.

private static Map<String, Map<String, Set<String>>> getAllLayers(ProvisioningLayout<FeaturePackLayout> pLayout, boolean includeDependencies) throws ProvisioningException, IOException {
    Map<String, Map<String, Set<String>>> layersMap = new HashMap<>();
    for (FeaturePackLayout fp : pLayout.getOrderedFeaturePacks()) {
        for (ConfigId layer : fp.loadLayers()) {
            String model = layer.getModel();
            Map<String, Set<String>> names = layersMap.get(model);
            if (names == null) {
                names = new HashMap<>();
                layersMap.put(model, names);
            }
            Set<String> dependencies = new TreeSet<>();
            if (includeDependencies) {
                ConfigLayerSpec spec = fp.loadConfigLayerSpec(model, layer.getName());
                for (ConfigLayerDependency dep : spec.getLayerDeps()) {
                    dependencies.add(dep.getName());
                }
            }
            // Case where a layer is redefined in multiple FP. Add all deps.
            Set<String> existingDependencies = names.get(layer.getName());
            if (existingDependencies != null) {
                existingDependencies.addAll(dependencies);
                dependencies = existingDependencies;
            }
            names.put(layer.getName(), dependencies);
        }
    }
    return layersMap;
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ConfigLayerSpec(org.jboss.galleon.spec.ConfigLayerSpec) ConfigLayerDependency(org.jboss.galleon.spec.ConfigLayerDependency) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) TreeSet(java.util.TreeSet) ConfigId(org.jboss.galleon.config.ConfigId) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with FeaturePackLayout

use of org.jboss.galleon.layout.FeaturePackLayout in project galleon by wildfly.

the class StateInfoUtil method buildDependencies.

private static String buildDependencies(PmCommandInvocation invoc, ProvisioningLayout<FeaturePackLayout> layout) throws ProvisioningException {
    Map<FPID, FeaturePackConfig> configs = new HashMap<>();
    List<FeaturePackLocation> dependencies = new ArrayList<>();
    for (FeaturePackLayout fpLayout : layout.getOrderedFeaturePacks()) {
        boolean isProduct = true;
        for (FeaturePackLayout fpLayout2 : layout.getOrderedFeaturePacks()) {
            if (fpLayout2.getSpec().hasTransitiveDep(fpLayout.getFPID().getProducer()) || fpLayout2.getSpec().getFeaturePackDep(fpLayout.getFPID().getProducer()) != null) {
                isProduct = false;
                break;
            }
        }
        if (!isProduct) {
            FeaturePackLocation loc = invoc.getPmSession().getExposedLocation(null, fpLayout.getFPID().getLocation());
            dependencies.add(loc);
            FeaturePackConfig transitiveConfig = layout.getConfig().getTransitiveDep(fpLayout.getFPID().getProducer());
            configs.put(loc.getFPID(), transitiveConfig);
        }
    }
    return buildDependencies(dependencies, configs);
}
Also used : FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 8 with FeaturePackLayout

use of org.jboss.galleon.layout.FeaturePackLayout in project galleon by wildfly.

the class StateInfoUtil method displayInfo.

public static void displayInfo(PmCommandInvocation invoc, Path installation, ProvisioningConfig config, String type, Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer> supplier) throws CommandExecutionException {
    try {
        if (!config.hasFeaturePackDeps()) {
            return;
        }
        invoc.println("");
        displayFeaturePacks(invoc, installation, config);
        if (type != null) {
            invoc.println("");
            try (ProvisioningLayout<FeaturePackLayout> layout = invoc.getPmSession().getLayoutFactory().newConfigLayout(config)) {
                switch(type) {
                    case ALL:
                        {
                            FeatureContainer container = supplier.apply(layout);
                            if (displayDependencies(invoc, layout)) {
                                invoc.println("");
                            }
                            if (displayPatches(invoc, layout)) {
                                invoc.println("");
                            }
                            if (displayConfigs(invoc, container, layout)) {
                                invoc.println("");
                            }
                            if (displayLayers(invoc, layout)) {
                                invoc.println("");
                            }
                            if (displayOptionalPackages(invoc, container, layout)) {
                                invoc.println("");
                            }
                            if (displayOptions(invoc, layout)) {
                                invoc.println("");
                            }
                            displayUniverses(invoc, config);
                            break;
                        }
                    case CONFIGS:
                        {
                            FeatureContainer container = supplier.apply(layout);
                            String configs = buildConfigs(invoc, container, layout);
                            if (configs != null) {
                                invoc.print(configs);
                            } else {
                                invoc.println(NO_CONFIGURATIONS);
                            }
                            break;
                        }
                    case DEPENDENCIES:
                        {
                            String deps = buildDependencies(invoc, layout);
                            if (deps != null) {
                                invoc.print(deps);
                            } else {
                                invoc.println(NO_DEPENDENCIES);
                            }
                            break;
                        }
                    case LAYERS:
                        {
                            String layers = buildLayers(layout);
                            if (layers != null) {
                                invoc.print(layers);
                            } else {
                                invoc.println(NO_LAYERS);
                            }
                            break;
                        }
                    case OPTIONS:
                        {
                            String options = buildOptions(layout);
                            if (options != null) {
                                invoc.print(options);
                            } else {
                                invoc.println(NO_OPTIONS);
                            }
                            break;
                        }
                    case PATCHES:
                        {
                            String patches = buildPatches(invoc, layout);
                            if (patches != null) {
                                invoc.print(patches);
                            } else {
                                invoc.println(NO_PATCHES);
                            }
                            break;
                        }
                    case UNIVERSES:
                        {
                            String universes = buildUniverses(config);
                            if (universes != null) {
                                invoc.print(universes);
                            } else {
                                invoc.println(NO_UNIVERSES);
                            }
                            break;
                        }
                    case OPTIONAL_PACKAGES:
                        {
                            FeatureContainer container = supplier.apply(layout);
                            String packages = buildOptionalPackages(invoc.getPmSession(), container, layout);
                            invoc.print(packages);
                            break;
                        }
                    default:
                        {
                            throw new CommandExecutionException(CliErrors.invalidInfoType());
                        }
                }
            }
        }
    } catch (Exception ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.infoFailed(), ex);
    }
}
Also used : FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) PathParserException(org.jboss.galleon.cli.path.PathParserException) PathConsumerException(org.jboss.galleon.cli.path.PathConsumerException) IOException(java.io.IOException) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningException(org.jboss.galleon.ProvisioningException)

Example 9 with FeaturePackLayout

use of org.jboss.galleon.layout.FeaturePackLayout in project galleon by wildfly.

the class StateInfoUtil method buildPatches.

public static String buildPatches(PmCommandInvocation invoc, ProvisioningLayout<FeaturePackLayout> layout) throws ProvisioningException {
    if (!layout.hasPatches()) {
        return null;
    }
    Table table = new Table(Headers.PATCH, Headers.PATCH_FOR, Headers.UPDATE_CHANNEL);
    for (FeaturePackLayout fpLayout : layout.getOrderedFeaturePacks()) {
        List<FeaturePackLayout> patches = layout.getPatches(fpLayout.getFPID());
        for (FeaturePackLayout patch : patches) {
            FeaturePackLocation loc = invoc.getPmSession().getExposedLocation(null, patch.getFPID().getLocation());
            FPID patchFor = patch.getSpec().getPatchFor();
            table.addLine(patch.getFPID().getBuild(), patchFor.getProducer().getName() + FeaturePackLocation.BUILD_START + patchFor.getBuild(), formatChannel(loc));
        }
    }
    if (!table.isEmpty()) {
        table.sort(Table.SortType.ASCENDANT);
        return table.build();
    }
    return null;
}
Also used : Table(org.jboss.galleon.cli.cmd.Table) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 10 with FeaturePackLayout

use of org.jboss.galleon.layout.FeaturePackLayout in project galleon by wildfly.

the class StateGetInfoCommand method runCommand.

@Override
protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException {
    try {
        ProvisioningConfig config = invoc.getPmSession().getContainer().getProvisioningConfig();
        Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer> supplier = new Function<ProvisioningLayout<FeaturePackLayout>, FeatureContainer>() {

            public FeatureContainer apply(ProvisioningLayout<FeaturePackLayout> layout) {
                return invoc.getPmSession().getState().getContainer();
            }
        };
        StateInfoUtil.displayInfo(invoc, null, config, type, supplier);
    } catch (Exception ex) {
        throw new CommandExecutionException(invoc.getPmSession(), CliErrors.infoFailed(), ex);
    }
}
Also used : ProvisioningConfig(org.jboss.galleon.config.ProvisioningConfig) Function(java.util.function.Function) FeaturePackLayout(org.jboss.galleon.layout.FeaturePackLayout) FeatureContainer(org.jboss.galleon.cli.model.FeatureContainer) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException) ProvisioningLayout(org.jboss.galleon.layout.ProvisioningLayout) CommandExecutionException(org.jboss.galleon.cli.CommandExecutionException)

Aggregations

FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)12 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)6 ArrayList (java.util.ArrayList)5 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)5 IOException (java.io.IOException)4 ProvisioningException (org.jboss.galleon.ProvisioningException)4 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)4 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)4 HashMap (java.util.HashMap)3 FeatureContainer (org.jboss.galleon.cli.model.FeatureContainer)3 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)3 Path (java.nio.file.Path)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 TreeSet (java.util.TreeSet)2 Function (java.util.function.Function)2 ProvisioningManager (org.jboss.galleon.ProvisioningManager)2 ConfigId (org.jboss.galleon.config.ConfigId)2 ProvisioningLayout (org.jboss.galleon.layout.ProvisioningLayout)2 Comparator (java.util.Comparator)1