Search in sources :

Example 21 with RevisionRef

use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.

the class Repository method dropTarget.

public boolean dropTarget(URI uri) throws Exception {
    try {
        init();
        //
        // On Linux we seem to get some spurious text. One case it added the
        // text of the version after the URI. So we remove anything after
        // the new line
        //
        String t = uri.toString().trim();
        int n = t.indexOf('\n');
        if (n > 0) {
            uri = new URI(t.substring(0, n));
            logger.debug("dropTarget cleaned up from {} to {}", t, uri);
        }
        RevisionRef ref;
        logger.debug("dropTarget {}", uri);
        String uriString = uri.toString();
        Matcher m = JPM_REVISION_URL_PATTERN.matcher(uriString);
        if (!m.matches()) {
            if (depositoryGroup != null || depositoryName != null)
                return false;
            if (!Boolean.getBoolean("jpm4j.in.test") && uri.getScheme().equalsIgnoreCase("file"))
                return false;
            //
            // See if it is a bundle
            //
            Download d = getCache().doDownload(uri);
            if (d == null) {
                return false;
            }
            ref = analyze(d.tmp, uri);
            if (ref == null) {
                logger.debug("not a proper url to drop {}", uri);
                IO.delete(d.tmp);
                return false;
            }
            getCache().makePermanent(ref, d);
        } else {
            Revision revision = getRevision(new Coordinate(m.group(1), m.group(2), m.group(3), m.group(4)));
            if (revision == null) {
                reporter.error("no revision found for %s", uri);
                return false;
            }
            ref = new RevisionRef(revision);
        }
        Library.RevisionRef resource = index.getRevisionRef(ref.revision);
        if (resource != null) {
            resource.urls.add(uri);
            // we know that we modified a resource so the index is dirty
            index.save(true);
            logger.debug("resource already loaded {}", uri);
            return true;
        }
        logger.debug("adding revision {}", ref);
        add(ref);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef) Revision(aQute.service.library.Library.Revision) RevisionRef(aQute.service.library.Library.RevisionRef) Matcher(java.util.regex.Matcher) Coordinate(aQute.service.library.Coordinate) Library(aQute.service.library.Library) URI(java.net.URI) Download(aQute.bnd.jpm.StoredRevisionCache.Download) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) SocketException(java.net.SocketException) IOException(java.io.IOException)

Example 22 with RevisionRef

use of aQute.service.library.Library.RevisionRef in project bnd by bndtools.

the class Index method getRevisions.

public Revisions getRevisions() throws Exception {
    init();
    Revisions revisions = new Revisions();
    for (RevisionRef ref : repo.revisionRefs) revisions.content.add(ref.revision);
    revisions._id = Revisions.checksum(revisions);
    return revisions;
}
Also used : RevisionRef(aQute.service.library.Library.RevisionRef) Revisions(aQute.service.library.Revisions)

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