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