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();
}
}
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;
}
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;
}
Aggregations