use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.
the class Index method delete.
public boolean delete(String bsn, Version v) throws Exception {
init();
Map<Version, Library.RevisionRef> map = cache.get(bsn);
if (map != null) {
try {
Library.RevisionRef removed = map.remove(v);
if (removed != null) {
for (Iterator<RevisionRef> i = repo.revisionRefs.iterator(); i.hasNext(); ) {
RevisionRef other = i.next();
if (Arrays.equals(other.revision, removed.revision)) {
i.remove();
}
}
repo.revisionRefs.remove(removed);
dirty = true;
return true;
}
} finally {
if (map.isEmpty())
cache.remove(bsn);
}
}
return false;
}
use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.
the class Index method getRevisionRef.
@SuppressWarnings("deprecation")
public Library.RevisionRef getRevisionRef(String bsn, Version version) throws Exception {
init();
Map<Version, Library.RevisionRef> map = cache.get(bsn);
if (map == null)
return null;
// Fixup the change from ref.url to ref.urls ...
boolean save = false;
RevisionRef ref = map.get(version);
if (ref == null) {
return null;
}
if (ref.urls.isEmpty() && ref.url != null) {
ref.urls.add(ref.url);
ref.url = null;
save = true;
}
if (Boolean.getBoolean("jpm4j.in.test") == false) {
for (Iterator<URI> i = ref.urls.iterator(); i.hasNext(); ) {
URI uri = i.next();
if (uri.getScheme().equalsIgnoreCase("file")) {
i.remove();
save = true;
}
}
}
if (save)
save();
return ref;
}
use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.
the class Repository method getUpdateAction.
/**
* Update a bsn
*
* @throws Exception
*/
Runnable getUpdateAction(Program program, String bsn) throws Exception {
final List<Runnable> update = new ArrayList<Runnable>();
for (Version v : index.getVersions(bsn)) {
RevisionRef resource = index.getRevisionRef(bsn, v);
Runnable updateAction = getUpdateAction(program, resource);
if (updateAction != null)
update.add(updateAction);
}
if (update.isEmpty())
return null;
return new Runnable() {
@Override
public void run() {
for (Runnable r : update) {
r.run();
}
}
@Override
public String toString() {
return update.toString();
}
};
}
use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.
the class Repository method add.
public void add(String bsn, Version version) throws Exception {
logger.debug("Add {} {}", bsn, version);
RevisionRef ref = getRevisionRef(bsn, version);
add(ref);
}
use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.
the class Repository method update.
/**
* Compare a list of versions against the available versions and return the
* desired list. This will remove all staged version that are 'below' a
* master.
*/
public SortedSet<Version> update(SortedSet<Version> input, Program p) throws Exception {
Map<Version, Version> mapped = new HashMap<Version, Version>();
for (RevisionRef ref : p.revisions) {
Version a = toVersion(ref.baseline, ref.qualifier);
Version mask = mask(a);
Version highest = mapped.get(mask);
if (highest == null || a.compareTo(highest) > 0 || ref.phase == Library.Phase.MASTER)
mapped.put(mask, a);
}
HashSet<Version> output = new HashSet<Version>();
for (Version i : input) {
Version mask = mask(i);
Version found = mapped.get(mask);
if (found != null)
output.add(found);
else
reporter.error("[update] Missing version %s for bsn %s", mask, p.last.bsn);
}
return new SortedList<Version>(output);
}
Aggregations