use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class ProvisioningLayoutFactory method resolveFeaturePack.
public <F extends FeaturePackLayout> F resolveFeaturePack(FeaturePackLocation location, int type, FeaturePackLayoutFactory<F> factory) throws ProvisioningException {
final Path fpDir = resolveFeaturePackDir(location);
final Path fpXml = fpDir.resolve(Constants.FEATURE_PACK_XML);
if (!Files.exists(fpXml)) {
throw new ProvisioningDescriptionException(Errors.pathDoesNotExist(fpXml));
}
try (BufferedReader reader = Files.newBufferedReader(fpXml)) {
final FeaturePackSpec fpSpec = FeaturePackXmlParser.getInstance().parse(reader);
if (location.isMavenCoordinates()) {
final FPID specId = fpSpec.getFPID();
final FeaturePackLocation fpl = new FeaturePackLocation(specId.getUniverse(), specId.getProducer().getName(), specId.getChannel().getName(), location.getFrequency(), specId.getBuild());
synchronized (this) {
cachedPacks.put(fpl.getFPID(), cachedPacks.get(location.getFPID()));
}
location = fpl;
}
return factory.newFeaturePack(location, fpSpec, fpDir, type);
} catch (IOException | XMLStreamException e) {
throw new ProvisioningException(Errors.parseXml(fpXml), e);
}
}
use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class ProvisioningPlan method update.
public ProvisioningPlan update(FeaturePackUpdatePlan fpPlan) throws ProvisioningDescriptionException {
final ProducerSpec producer = fpPlan.getInstalledLocation().getProducer();
if (install.containsKey(producer) || uninstall.contains(producer)) {
throw new ProvisioningDescriptionException(producer + " has already been added to the plan");
}
updates = CollectionUtils.putLinked(updates, producer, fpPlan);
return this;
}
use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class FeaturePackDescriber method describeFeaturePack.
public static FeaturePackDescription describeFeaturePack(Path fpDir, String encoding) throws ProvisioningDescriptionException {
assertDirectory(fpDir);
final Path fpXml = fpDir.resolve(Constants.FEATURE_PACK_XML);
if (!Files.exists(fpXml)) {
throw new ProvisioningDescriptionException(Errors.pathDoesNotExist(fpXml));
}
final FeaturePackDescription.Builder layoutBuilder;
try (Reader is = Files.newBufferedReader(fpXml, Charset.forName(encoding))) {
final FeaturePackSpec.Builder specBuilder = FeaturePackSpec.builder();
XmlParsers.parse(is, specBuilder);
layoutBuilder = FeaturePackDescription.builder(specBuilder);
} catch (IOException e) {
throw new ProvisioningDescriptionException(Errors.openFile(fpXml));
} catch (XMLStreamException e) {
throw new ProvisioningDescriptionException(Errors.parseXml(fpXml), e);
}
final Path packagesDir = fpDir.resolve(Constants.PACKAGES);
if (Files.exists(packagesDir)) {
processPackages(layoutBuilder, packagesDir, encoding);
}
return layoutBuilder.build();
}
use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class ProvisioningLayout method loadPatch.
private void loadPatch(FPID patchId) throws ProvisioningException {
final F patchFp = layoutFactory.resolveFeaturePack(patchId.getLocation(), FeaturePackLayout.PATCH, fpFactory);
final FeaturePackSpec spec = patchFp.getSpec();
if (!spec.isPatch()) {
throw new ProvisioningDescriptionException(patchId + " is not a patch but listed as one");
}
allPatches = CollectionUtils.put(allPatches, patchId, patchFp);
if (spec.hasFeaturePackDeps()) {
for (FeaturePackConfig patchDep : spec.getFeaturePackDeps()) {
final FPID patchDepId = patchDep.getLocation().getFPID();
if (allPatches.containsKey(patchDepId)) {
continue;
}
loadPatch(patchDepId);
}
}
final FPID patchFor = spec.getPatchFor();
List<F> patchList = fpPatches.get(patchFor);
if (patchList == null) {
fpPatches = CollectionUtils.put(fpPatches, patchFor, Collections.singletonList(patchFp));
} else if (patchList.size() == 1) {
final List<F> tmp = new ArrayList<>(2);
tmp.add(patchList.get(0));
tmp.add(patchFp);
fpPatches = CollectionUtils.put(fpPatches, patchFor, tmp);
} else {
patchList.add(patchFp);
}
}
use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class ResolvedFeatureId method fromString.
public static ResolvedFeatureId fromString(String str) throws ProvisioningDescriptionException {
final int length = str.length();
if (length == 0) {
formatException(str);
}
if (str.charAt(0) != '{') {
formatException(str);
}
int i = str.indexOf('}', 1);
if (i < 0) {
formatException(str);
}
final int colon = str.indexOf(':', i + 1);
if (colon - i < 2) {
formatException(str);
}
ResolvedSpecId specId = null;
try {
specId = new ResolvedSpecId(FeaturePackLocation.fromString(str.substring(1, i)).getProducer(), str.substring(i + 1, colon));
} catch (IllegalArgumentException e) {
throw new ProvisioningDescriptionException("Failed to parse the channel part of feature id '" + str + "'", e);
}
int endIndex = str.indexOf(',', colon + 3);
if (endIndex < 0) {
final int equals = str.indexOf('=', colon + 1);
if (equals < 0 || equals == str.length() - 1) {
formatException(str);
}
return new ResolvedFeatureId(specId, Collections.singletonMap(str.substring(colon + 1, equals), str.substring(equals + 1)));
}
final Map<String, Object> params = new HashMap<>();
int lastComma = colon;
while (endIndex > 0) {
int equals = str.indexOf('=', lastComma + 1);
if (equals < 0 || equals == str.length() - 1) {
formatException(str);
}
params.put(str.substring(lastComma + 1, equals), str.substring(equals + 1, endIndex));
lastComma = endIndex;
endIndex = str.indexOf(',', endIndex + 1);
}
int equals = str.indexOf('=', lastComma + 2);
if (equals < 0 || equals == str.length() - 1) {
formatException(str);
}
params.put(str.substring(lastComma + 1, equals), str.substring(equals + 1));
return new ResolvedFeatureId(specId, params);
}
Aggregations