use of org.apache.aries.application.resolver.obr.ext.BundleResourceTransformer in project aries by apache.
the class RepositoryGeneratorImpl method generateRepository.
public static void generateRepository(RepositoryAdmin repositoryAdmin, String repositoryName, Collection<? extends ModelledResource> byValueBundles, OutputStream os) throws ResolverException, IOException {
logger.debug(LOG_ENTRY, "generateRepository", new Object[] { repositoryAdmin, repositoryName, byValueBundles, os });
Document doc;
try {
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
} catch (ParserConfigurationException pce) {
throw new ResolverException(pce);
}
Element root = doc.createElement("repository");
root.setAttribute("name", repositoryName);
doc.appendChild(root);
for (ModelledResource mr : byValueBundles) {
BundleResource bundleResource = new BundleResource(mr, repositoryAdmin);
if (bundleResourceTransformers.size() > 0) {
for (BundleResourceTransformer brt : bundleResourceTransformers) {
bundleResource = brt.transform(bundleResource);
}
}
writeResource(bundleResource, mr.getLocation(), doc, root);
}
try {
Transformer trans = TransformerFactory.newInstance().newTransformer();
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.transform(new DOMSource(doc), new StreamResult(os));
} catch (TransformerException te) {
logger.debug(LOG_EXIT, "generateRepository", te);
throw new ResolverException(te);
}
logger.debug(LOG_EXIT, "generateRepository");
}
Aggregations