Search in sources :

Example 26 with ResolverException

use of org.apache.aries.application.management.ResolverException 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");
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) ResolverException(org.apache.aries.application.management.ResolverException) Transformer(javax.xml.transform.Transformer) BundleResourceTransformer(org.apache.aries.application.resolver.obr.ext.BundleResourceTransformer) StreamResult(javax.xml.transform.stream.StreamResult) BundleResourceTransformer(org.apache.aries.application.resolver.obr.ext.BundleResourceTransformer) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Document(org.w3c.dom.Document) BundleResource(org.apache.aries.application.resolver.obr.ext.BundleResource) TransformerException(javax.xml.transform.TransformerException) ModelledResource(org.apache.aries.application.modelling.ModelledResource)

Aggregations

ResolverException (org.apache.aries.application.management.ResolverException)26 ArrayList (java.util.ArrayList)20 DeployedBundles (org.apache.aries.application.modelling.DeployedBundles)17 Test (org.junit.Test)15 ModelledResource (org.apache.aries.application.modelling.ModelledResource)11 Content (org.apache.aries.application.Content)8 InvalidAttributeException (org.apache.aries.application.InvalidAttributeException)6 ApplicationMetadata (org.apache.aries.application.ApplicationMetadata)5 HashSet (java.util.HashSet)4 ExportedPackage (org.apache.aries.application.modelling.ExportedPackage)4 List (java.util.List)3 ImportedBundle (org.apache.aries.application.modelling.ImportedBundle)3 ImportedPackage (org.apache.aries.application.modelling.ImportedPackage)3 MethodCall (org.apache.aries.unittest.mocks.MethodCall)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Set (java.util.Set)2 Manifest (java.util.jar.Manifest)2 AriesApplication (org.apache.aries.application.management.AriesApplication)2 ResolveConstraint (org.apache.aries.application.management.ResolveConstraint)2