use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.
the class FileRepoTest method testBundleNotModifiedOnPut.
public void testBundleNotModifiedOnPut() throws Exception {
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
File dstBundle = null;
try {
File srcBundle = IO.getFile("testresources/test.jar");
byte[] srcSha = calculateHash(sha1, srcBundle);
PutOptions options = new RepositoryPlugin.PutOptions();
options.digest = srcSha;
PutResult r = testRepo.put(new BufferedInputStream(new FileInputStream(srcBundle)), options);
dstBundle = new File(r.artifact);
assertEquals(hashToString(srcSha), hashToString(r.digest));
assertTrue(MessageDigest.isEqual(srcSha, r.digest));
} finally {
if (dstBundle != null) {
delete(dstBundle.getParentFile());
}
}
}
use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.
the class Project method releaseRepo.
private URI releaseRepo(RepositoryPlugin releaseRepo, String jarName, InputStream jarStream) throws Exception {
logger.debug("release to {}", releaseRepo.getName());
try {
PutOptions putOptions = new RepositoryPlugin.PutOptions();
// TODO find sub bnd that is associated with this thing
putOptions.context = this;
PutResult r = releaseRepo.put(jarStream, putOptions);
logger.debug("Released {} to {} in repository {}", jarName, r.artifact, releaseRepo);
return r.artifact;
} catch (Exception e) {
msgs.Release_Into_Exception_(jarName, releaseRepo, e);
return null;
}
}
use of aQute.bnd.service.RepositoryPlugin.PutResult in project bnd by bndtools.
the class Project method copy.
public void copy(RepositoryPlugin source, Instructions filter, RepositoryPlugin destination) throws Exception {
assert source != null;
assert destination != null;
logger.info("copy from repo {} to {} with filter {}", source, destination, filter);
for (String bsn : source.list(null)) {
for (Version version : source.versions(bsn)) {
if (filter == null || filter.matches(bsn)) {
logger.info("copy {}:{}", bsn, version);
File file = source.get(bsn, version, null);
if (file.getName().endsWith(".jar")) {
try (InputStream in = IO.stream(file)) {
PutOptions po = new PutOptions();
po.bsn = bsn;
po.context = null;
po.type = "bundle";
po.version = version;
PutResult put = destination.put(in, po);
} catch (Exception e) {
logger.error("Failed to copy {}-{}", e, bsn, version);
error("Failed to copy %s:%s from %s to %s, error: %s", bsn, version, source, destination, e);
}
}
}
}
}
}
Aggregations