Search in sources :

Example 1 with RevisionRef

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;
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef) RevisionRef(aQute.service.library.Library.RevisionRef) Version(aQute.bnd.version.Version) Library(aQute.service.library.Library)

Example 2 with RevisionRef

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;
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef) Version(aQute.bnd.version.Version) URI(java.net.URI)

Example 3 with RevisionRef

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();
        }
    };
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef) Version(aQute.bnd.version.Version) ArrayList(java.util.ArrayList)

Example 4 with RevisionRef

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);
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef)

Example 5 with RevisionRef

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);
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Version(aQute.bnd.version.Version) SortedList(aQute.lib.collections.SortedList) HashSet(java.util.HashSet)

Aggregations

RevisionRef (aQute.service.library.Library.RevisionRef)22 Version (aQute.bnd.version.Version)11 Revision (aQute.service.library.Library.Revision)5 FileNotFoundException (java.io.FileNotFoundException)5 IOException (java.io.IOException)5 SocketException (java.net.SocketException)5 URISyntaxException (java.net.URISyntaxException)5 HashSet (java.util.HashSet)5 Matcher (java.util.regex.Matcher)5 Coordinate (aQute.service.library.Coordinate)4 Library (aQute.service.library.Library)4 ArrayList (java.util.ArrayList)4 Program (aQute.service.library.Library.Program)3 File (java.io.File)3 URI (java.net.URI)3 Formatter (java.util.Formatter)2 LinkedHashMap (java.util.LinkedHashMap)2 Container (aQute.bnd.build.Container)1 Project (aQute.bnd.build.Project)1 Workspace (aQute.bnd.build.Workspace)1