Search in sources :

Example 6 with Program

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

the class Repository method revisionTooltip.

private String revisionTooltip(String bsn, Version version) throws Exception {
    RevisionRef r = getRevisionRef(bsn, version);
    if (r == null)
        return null;
    try (Formatter sb = new Formatter()) {
        sb.format("[%s:%s", r.groupId, r.artifactId);
        if (r.classifier != null) {
            sb.format(":%s", r.classifier);
        }
        sb.format("@%s] %s\n\n", r.version, r.phase);
        if (r.releaseSummary != null)
            sb.format("%s\n\n", r.releaseSummary);
        if (r.description != null)
            sb.format("%s\n\n", r.description.replaceAll("#\\s*", ""));
        sb.format("Size: %s\n", size(r.size, 0));
        sb.format("SHA-1: %s\n", Hex.toHexString(r.revision));
        sb.format("Age: %s\n", age(r.created));
        sb.format("URL: %s\n", r.urls);
        File f = getCache().getPath(bsn, version.toString(), r.revision);
        if (f.isFile() && f.length() == r.size)
            sb.format("Cached %s\n", f);
        else
            sb.format("Not downloaded\n");
        if (bsn.indexOf("__") >= 0) {
            sb.format("\nThis artifact has no OSGi metadata. Its coordinates are %s:%s@%s\n", r.groupId, r.artifactId, r.version);
        }
        Program p = getProgram(bsn, false);
        if (p != null) {
            Runnable update = getUpdateAction(p, r);
            if (update != null) {
                sb.format("%c This version can be updated to %s\n", DOWN_ARROW, update);
            }
        }
        File sources = getCache().getPath(bsn, version.toString(), r.revision, true);
        if (sources.isFile())
            sb.format("Has sources: %s\n", sources.getAbsolutePath());
        else
            sb.format("No sources\n");
        j.wrap((StringBuilder) sb.out());
        return sb.toString().trim();
    }
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef) Program(aQute.service.library.Library.Program) Formatter(java.util.Formatter) File(java.io.File)

Example 7 with Program

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

the class Repository method query.

// @Override
public Set<ResourceDescriptor> query(String query) throws Exception {
    Set<ResourceDescriptor> resources = new HashSet<ResourceDescriptor>();
    RevisionRef master = null;
    RevisionRef staging = null;
    for (Program p : getLibrary().getQueryPrograms(query, 0, 100)) {
        for (RevisionRef ref : p.revisions) {
            if (master == null && ref.phase == Library.Phase.MASTER) {
                master = ref;
            } else if (staging != null && ref.phase == Library.Phase.STAGING) {
                staging = ref;
            }
        }
        if (master != null)
            resources.add(createResourceDescriptor(master));
        if (staging != null)
            resources.add(createResourceDescriptor(staging));
    }
    return resources;
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef) Program(aQute.service.library.Library.Program) HashSet(java.util.HashSet)

Example 8 with Program

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

the class Repository method actions.

/**
	 * Return the actions for this repository
	 */
@Override
public Map<String, Runnable> actions(Object... target) throws Exception {
    init();
    boolean connected = isConnected();
    if (target == null)
        return null;
    if (target.length == 0)
        return getRepositoryActions();
    final String bsn = (String) target[0];
    Program careful = null;
    if (connected)
        try {
            careful = getProgram(bsn, true);
        } catch (Exception e) {
            reporter.error("Offline? %s", e);
        }
    final Program p = careful;
    if (target.length == 1)
        return getProgramActions(bsn, p);
    if (target.length >= 2) {
        final Version version = (Version) target[1];
        return getRevisionActions(p, bsn, version);
    }
    return null;
}
Also used : Program(aQute.service.library.Library.Program) Version(aQute.bnd.version.Version) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) SocketException(java.net.SocketException) IOException(java.io.IOException)

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