Search in sources :

Example 1 with Program

use of aQute.service.library.Library.Program in project bnd by bndtools.

the class Repository method programTooltip.

private String programTooltip(String bsn) throws Exception {
    Program p = getProgram(bsn, false);
    if (p != null) {
        try (Formatter sb = new Formatter()) {
            if (p.wiki != null && p.wiki.text != null)
                sb.format("%s\n", p.wiki.text.replaceAll("#\\s?", ""));
            else if (p.last.description != null)
                sb.format("%s\n", p.last.description);
            else
                sb.format("No description\n");
            if (bsn.indexOf("__") >= 0) {
                sb.format("\nThis artifact has no OSGi metadata. Its coordinates are %s:%s\n", p.groupId, p.artifactId);
            }
            j.wrap((StringBuilder) sb.out());
            return sb.toString().trim();
        }
    }
    return null;
}
Also used : Program(aQute.service.library.Library.Program) Formatter(java.util.Formatter)

Example 2 with Program

use of aQute.service.library.Library.Program in project bnd by bndtools.

the class Repository method update.

/**
	 * Update all baselines for a bsn
	 * 
	 * @param bsn
	 * @throws Exception
	 */
void update(String bsn) throws Exception {
    Program program = getProgram(bsn, false);
    Runnable updateAction = getUpdateAction(program, bsn);
    if (updateAction == null)
        return;
    logger.debug("update bsn {}", updateAction);
    updateAction.run();
}
Also used : Program(aQute.service.library.Library.Program)

Example 3 with Program

use of aQute.service.library.Library.Program in project bnd by bndtools.

the class Main method printPrograms.

// void print(Iterable<RevisionRef> revisions) {
// for (RevisionRef r : revisions) {
// out.printf("%-40s %s %s\n", jpm.getCoordinates(r),
// Hex.toHexString(r._id), (r.description == null ? ""
// : r.description));
// }
// }
void printPrograms(Iterable<? extends Program> programs) {
    Justif j = new Justif(120, 40, 42, 100);
    StringBuilder sb = new StringBuilder();
    try (Formatter f = new Formatter(sb)) {
        for (Program p : programs) {
            if (p.groupId.equals(Library.OSGI_GROUP) || p.groupId.equals(Library.SHA_GROUP))
                f.format("%s", p.artifactId);
            else
                f.format("%s:%s", p.groupId, p.artifactId);
            f.format("\t0-\t1");
            if (p.wiki != null && p.wiki.text != null)
                sb.append(p.wiki.text.replace('\n', '\f'));
            else if (p.last != null) {
                if (p.last.description != null)
                    sb.append(p.last.description.replace('\n', '\f'));
            }
            f.format("%n");
        }
        j.wrap(sb);
        out.println(sb);
    }
}
Also used : Program(aQute.service.library.Library.Program) Justif(aQute.lib.justif.Justif) Formatter(java.util.Formatter)

Example 4 with Program

use of aQute.service.library.Library.Program in project bnd by bndtools.

the class StoredRevisionCache method getProgram.

public Program getProgram(String bsn) {
    Program p = programs.get(bsn);
    if (p != null)
        return p;
    File pf = IO.getFile(programdir, bsn + ".json");
    if (pf != null && pf.isFile() && pf.lastModified() >= refresh.lastModified()) {
        try {
            p = codec.dec().from(pf).get(Program.class);
            programs.put(bsn, p);
            return p;
        } catch (Exception e) {
            //
            return null;
        }
    } else
        return null;
}
Also used : Program(aQute.service.library.Library.Program) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 5 with Program

use of aQute.service.library.Library.Program in project bnd by bndtools.

the class Repository method getRevisionRefs.

private List<RevisionRef> getRevisionRefs(String bsn) throws Exception {
    String classifier = null;
    String[] parts = bsn.split("__");
    if (parts.length == 3) {
        bsn = parts[0] + "__" + parts[1];
        classifier = parts[2];
    }
    Program program = getProgram(bsn, false);
    if (program != null) {
        List<RevisionRef> refs = new ArrayList<Library.RevisionRef>();
        for (RevisionRef r : program.revisions) {
            if (eq(classifier, r.classifier))
                refs.add(r);
        }
        return refs;
    }
    return Collections.emptyList();
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef) Program(aQute.service.library.Library.Program) ArrayList(java.util.ArrayList) Library(aQute.service.library.Library)

Aggregations

Program (aQute.service.library.Library.Program)8 RevisionRef (aQute.service.library.Library.RevisionRef)3 Formatter (java.util.Formatter)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Version (aQute.bnd.version.Version)1 Justif (aQute.lib.justif.Justif)1 Library (aQute.service.library.Library)1 SocketException (java.net.SocketException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1