Search in sources :

Example 1 with ProgramMetadata

use of aQute.maven.provider.MetadataParser.ProgramMetadata in project bnd by bndtools.

the class MavenBackingRepository method getMetadata.

ProgramMetadata getMetadata(Program program) throws Exception {
    File metafile = IO.getFile(local, program.metadata(id));
    ProgramMetadata metadata = programs.get(program);
    TaggedData tag = fetch(program.metadata(), metafile);
    switch(tag.getState()) {
        case NOT_FOUND:
            return null;
        case OTHER:
            throw new IOException("Failed " + tag.getResponseCode());
        case UNMODIFIED:
            if (metadata != null)
                return metadata;
        case UPDATED:
        default:
            metadata = MetadataParser.parseProgramMetadata(metafile);
            programs.put(program, metadata);
            return metadata;
    }
}
Also used : ProgramMetadata(aQute.maven.provider.MetadataParser.ProgramMetadata) TaggedData(aQute.bnd.service.url.TaggedData) IOException(java.io.IOException) File(java.io.File)

Example 2 with ProgramMetadata

use of aQute.maven.provider.MetadataParser.ProgramMetadata in project bnd by bndtools.

the class MetadataTest method testProgramParsing.

public void testProgramParsing() throws Exception {
    try (InputStream in = new FileInputStream(IO.getFile("testresources/parser/commons-dbcp.xml"))) {
        ProgramMetadata parse = MetadataParser.parseProgramMetadata(in);
        assertNotNull(parse);
        assertEquals("commons.dbcp", parse.group);
        assertEquals("commons-dbcp", parse.artifact);
        assertEquals(2, parse.versions.size());
        assertTrue(parse.versions.contains(new MavenVersion("1.4.1-SNAPSHOT")));
        assertTrue(parse.versions.contains(new MavenVersion("1.5-SNAPSHOT")));
    }
}
Also used : MavenVersion(aQute.bnd.version.MavenVersion) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ProgramMetadata(aQute.maven.provider.MetadataParser.ProgramMetadata) FileInputStream(java.io.FileInputStream)

Aggregations

ProgramMetadata (aQute.maven.provider.MetadataParser.ProgramMetadata)2 TaggedData (aQute.bnd.service.url.TaggedData)1 MavenVersion (aQute.bnd.version.MavenVersion)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1