use of aQute.bnd.repository.maven.provider.IndexFile.BundleDescriptor in project bnd by bndtools.
the class MavenBndRepository method getBundleDescriptor.
BundleDescriptor getBundleDescriptor(Object... target) throws Exception {
String bsn = (String) target[0];
Version version = (Version) target[1];
BundleDescriptor bd = getDescriptor(bsn, version);
return bd;
}
use of aQute.bnd.repository.maven.provider.IndexFile.BundleDescriptor in project bnd by bndtools.
the class MavenBndRepository method title.
@Override
public String title(Object... target) throws Exception {
switch(target.length) {
case 0:
String name = getName();
int n = index.getErrors(null);
if (n > 0)
return name += " [" + n + "!]";
return name;
case 1:
name = (String) target[0];
n = index.getErrors(name);
if (n > 0)
name += " [!]";
return name;
case 2:
BundleDescriptor bd = getBundleDescriptor(target);
if (bd.error != null)
return bd.version + " [" + bd.error + "]";
else if (isLocal(bd.archive)) {
return bd.version.toString();
} else
return bd.version.toString() + " [?]";
default:
}
return null;
}
use of aQute.bnd.repository.maven.provider.IndexFile.BundleDescriptor in project bnd by bndtools.
the class RepoActions method addDependency.
private void addDependency(Archive archive, MavenScope scope) throws Exception {
IPom pom = repo.storage.getPom(archive.revision);
Map<Program, Dependency> dependencies = pom.getDependencies(scope, false);
for (Dependency d : dependencies.values()) {
BundleDescriptor add = repo.index.add(d.program.version(d.version).archive("jar", null));
if (d.error != null)
add.error = d.error;
}
}
use of aQute.bnd.repository.maven.provider.IndexFile.BundleDescriptor in project bnd by bndtools.
the class MavenBndRepository method tooltip.
@Override
public String tooltip(Object... target) throws Exception {
switch(target.length) {
case 0:
try (Formatter f = new Formatter()) {
f.format("%s\n", getName());
f.format("Revisions %s\n", index.descriptors.size());
for (MavenBackingRepository mbr : storage.getReleaseRepositories()) f.format("Release %s (%s)\n", mbr, getUser(mbr));
for (MavenBackingRepository mbr : storage.getSnapshotRepositories()) f.format("Snapshot %s (%s)\n", mbr, getUser(mbr));
f.format("Storage %s\n", localRepo);
f.format("Index %s\n", index.indexFile);
f.format("Index Cache %s\n", index.cacheDir);
return f.toString();
}
case 1:
try (Formatter f = new Formatter()) {
String name = (String) target[0];
Set<aQute.maven.api.Program> programs = index.getProgramsForBsn(name);
return programs.toString();
}
case 2:
BundleDescriptor bd = getBundleDescriptor(target);
try (Formatter f = new Formatter()) {
f.format("%s\n", bd.archive);
f.format("Bundle-Version %s\n", bd.version);
f.format("Last Modified %s\n", new Date(bd.lastModified));
f.format("URL %s\n", bd.url);
f.format("SHA-1 %s\n", Hex.toHexString(bd.id).toLowerCase());
f.format("SHA-256 %s\n", Hex.toHexString(bd.sha256).toLowerCase());
File localFile = storage.toLocalFile(bd.archive);
f.format("Local %s%s\n", localFile, localFile.isFile() ? "" : " ?");
if (bd.description != null)
f.format("Description\n%s", bd.description);
return f.toString();
}
default:
}
return null;
}
use of aQute.bnd.repository.maven.provider.IndexFile.BundleDescriptor in project bnd by bndtools.
the class MavenBndRepository method get.
@Override
public File get(String bsn, Version version, Map<String, String> properties, final DownloadListener... listeners) throws Exception {
init();
BundleDescriptor descriptor = index.getDescriptor(bsn, version);
if (descriptor == null)
return null;
Archive archive = descriptor.archive;
if (archive != null) {
final File file = storage.toLocalFile(archive);
final File withSources = new File(file.getParentFile(), "+" + file.getName());
if (withSources.isFile() && withSources.lastModified() > file.lastModified()) {
if (listeners.length == 0)
return withSources;
for (DownloadListener dl : listeners) dl.success(withSources);
return withSources;
}
Promise<File> promise = index.updateAsync(descriptor, storage.get(archive));
if (listeners.length == 0)
return promise.getValue();
promise.then(new Success<File, Void>() {
@Override
public Promise<Void> call(Promise<File> resolved) throws Exception {
File value = resolved.getValue();
if (value == null) {
throw new FileNotFoundException("Download failed");
}
for (DownloadListener dl : listeners) {
try {
dl.success(value);
} catch (Exception e) {
reporter.exception(e, "Download listener failed in success callback %s", dl);
}
}
return null;
}
}).then(null, new Failure() {
@Override
public void fail(Promise<?> resolved) throws Exception {
String reason = Exceptions.toString(resolved.getFailure());
for (DownloadListener dl : listeners) {
try {
dl.failure(file, reason);
} catch (Exception e) {
reporter.exception(e, "Download listener failed in failure callback %s", dl);
}
}
}
});
return file;
}
return null;
}
Aggregations