use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.
the class AbstractPluginsCommand method getDynamicOptions.
@Override
protected List<DynamicOption> getDynamicOptions(State state) throws Exception {
List<DynamicOption> options = new ArrayList<>();
FeaturePackLocation fpl = pmSession.getResolvedLocation(getInstallationDirectory(pmSession.getAeshContext()), getId(pmSession));
Set<ProvisioningOption> pluginOptions = getPluginOptions(fpl);
for (ProvisioningOption opt : pluginOptions) {
DynamicOption dynOption = new DynamicOption(opt.getName(), opt.isRequired());
options.add(dynOption);
}
return options;
}
use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.
the class AbstractFPProvisioningCommand method runCommand.
@Override
protected void runCommand(PmCommandInvocation invoc, State session) throws IOException, ProvisioningException, CommandExecutionException {
FeaturePackLocation fpl = invoc.getPmSession().getResolvedLocation(null, this.fpl);
runCommand(invoc, session, fpl);
}
use of org.jboss.galleon.universe.FeaturePackLocation 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.universe.FeaturePackLocation in project galleon by wildfly.
the class ProvisionedConfigXmlParser30 method parseSource.
private static FeaturePackLocation parseSource(XMLExtendedStreamReader reader) throws XMLStreamException {
final int count = reader.getAttributeCount();
FeaturePackLocation fps = null;
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i));
switch(attribute) {
case LOCATION:
try {
fps = FeaturePackLocation.fromString(reader.getAttributeValue(i));
} catch (IllegalArgumentException e) {
throw new XMLStreamException("Failed to parse feature-pack location", e);
}
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
}
if (fps == null) {
throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.LOCATION));
}
return fps;
}
use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.
the class ProvisioningXmlParser30 method doReadFeaturePackDep.
private static void doReadFeaturePackDep(XMLExtendedStreamReader reader, FeaturePackDepsConfigBuilder<?> builder, boolean transitive) throws XMLStreamException {
FeaturePackLocation location = null;
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
final Attribute attribute = Attribute.of(reader.getAttributeName(i).getLocalPart());
switch(attribute) {
case LOCATION:
location = parseFpl(reader, i);
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
}
if (location == null) {
throw ParsingUtils.missingAttributes(reader.getLocation(), Collections.singleton(Attribute.LOCATION));
}
location = resolveUniverse(builder, location);
String origin = null;
final FeaturePackConfig.Builder depBuilder = transitive ? FeaturePackConfig.transitiveBuilder(location) : FeaturePackConfig.builder(location);
while (reader.hasNext()) {
switch(reader.nextTag()) {
case XMLStreamConstants.END_ELEMENT:
{
try {
builder.addFeaturePackDep(origin, depBuilder.build());
} catch (ProvisioningDescriptionException e) {
final StringBuilder buf = new StringBuilder();
buf.append("Failed to add ").append(location).append(" as a ");
if (transitive) {
buf.append("transitive ");
}
buf.append(" feature-pack dependency");
throw new XMLStreamException(ParsingUtils.error(buf.toString(), reader.getLocation()), e);
}
return;
}
case XMLStreamConstants.START_ELEMENT:
{
final Element element = Element.of(reader.getName().getLocalPart());
switch(element) {
case PACKAGES:
try {
FeaturePackPackagesConfigParser10.readPackages(reader, depBuilder);
} catch (ProvisioningDescriptionException e) {
throw new XMLStreamException("Failed to parse " + Element.PACKAGES.getLocalName() + ": " + e.getLocalizedMessage(), reader.getLocation(), e);
}
break;
case ORIGIN:
origin = reader.getElementText();
break;
case DEFAULT_CONFIGS:
ProvisioningXmlParser30.parseDefaultConfigs(reader, depBuilder);
break;
case CONFIG:
final ConfigModel.Builder config = ConfigModel.builder();
ConfigXml.readConfig(reader, config);
try {
depBuilder.addConfig(config.build());
} catch (ProvisioningDescriptionException e) {
throw new XMLStreamException("Failed to parse config element", reader.getLocation(), e);
}
break;
case PATCHES:
readPatches(reader, depBuilder, builder);
break;
default:
throw ParsingUtils.unexpectedContent(reader);
}
break;
}
default:
{
throw ParsingUtils.unexpectedContent(reader);
}
}
}
}
Aggregations