Search in sources :

Example 1 with ReplacerAdapter

use of aQute.libg.sed.ReplacerAdapter in project bnd by bndtools.

the class ArtifactRepository method parse.

void parse() throws Exception {
    final Map<String, String> properties = getProperties("repository/properties/property");
    properties.put("repoUrl", base.resolve("").toString());
    final Domain parent = new Domain() {

        @Override
        public Map<String, String> getMap() {
            return properties;
        }

        @Override
        public Domain getParent() {
            return null;
        }
    };
    rules = getRules();
    NodeList artifactNodes = getNodes("repository/artifacts/artifact");
    for (int i = 0; i < artifactNodes.getLength(); i++) {
        final Node artifactNode = artifactNodes.item(i).cloneNode(true);
        final XMLArtifact xmlArtifact = getFromType(artifactNode, XMLArtifact.class);
        final Map<String, String> map = Converter.cnv(new TypeReference<Map<String, String>>() {
        }, xmlArtifact);
        if ("osgi.bundle".equals(xmlArtifact.classifier)) {
            Domain domain = new Domain() {

                @Override
                public Map<String, String> getMap() {
                    return map;
                }

                @Override
                public Domain getParent() {
                    return parent;
                }
            };
            ReplacerAdapter ra = new ReplacerAdapter(domain);
            for (Rule r : rules) {
                if (r.matches(map)) {
                    String s = ra.process(r.output);
                    URI uri = new URI(s).normalize();
                    Artifact artifact = new Artifact();
                    artifact.uri = uri;
                    artifact.id = xmlArtifact.id;
                    artifact.version = new Version(xmlArtifact.version);
                    artifact.md5 = getProperties(artifactNode, "properties/property").get("download.md5");
                    artifacts.add(artifact);
                    break;
                }
            }
        }
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) URI(java.net.URI) Artifact(aQute.p2.api.Artifact) Version(org.osgi.framework.Version) ReplacerAdapter(aQute.libg.sed.ReplacerAdapter) Domain(aQute.libg.sed.Domain) Map(java.util.Map)

Aggregations

Domain (aQute.libg.sed.Domain)1 ReplacerAdapter (aQute.libg.sed.ReplacerAdapter)1 Artifact (aQute.p2.api.Artifact)1 URI (java.net.URI)1 Map (java.util.Map)1 Version (org.osgi.framework.Version)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1