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;
}
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);
}
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);
}
}
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;
}
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);
}
}
Aggregations