Search in sources :

Example 1 with UpdateSite

use of org.apache.ivy.osgi.updatesite.xml.UpdateSite in project ant-ivy by apache.

the class UpdateSiteLoader method load.

public RepoDescriptor load(URI repoUri) throws IOException, ParseException, SAXException {
    if (!repoUri.toString().endsWith("/")) {
        try {
            repoUri = new URI(repoUri.toString() + "/");
        } catch (URISyntaxException e) {
            throw new RuntimeException("Cannot make an uri for the repo");
        }
    }
    Message.info("Loading the update site " + repoUri);
    // first look for a p2 repository
    RepoDescriptor repo = loadP2(repoUri);
    if (repo != null) {
        return repo;
    }
    Message.verbose("\tNo P2 artifacts, falling back on the old fashioned updatesite");
    // then try the old update site
    UpdateSite site = loadSite(repoUri);
    if (site == null) {
        return null;
    }
    repo = loadFromDigest(site);
    if (repo != null) {
        return repo;
    }
    return loadFromSite(site);
}
Also used : RepoDescriptor(org.apache.ivy.osgi.repo.RepoDescriptor) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) UpdateSite(org.apache.ivy.osgi.updatesite.xml.UpdateSite)

Example 2 with UpdateSite

use of org.apache.ivy.osgi.updatesite.xml.UpdateSite in project ant-ivy by apache.

the class UpdateSiteLoader method loadSite.

private UpdateSite loadSite(URI repoUri) throws IOException, SAXException {
    URI siteUri = normalizeSiteUri(repoUri, null);
    URL u = siteUri.resolve("site.xml").toURL();
    final URLResource res = new URLResource(u, this.timeoutConstraint);
    ArtifactDownloadReport report = repositoryCacheManager.downloadRepositoryResource(res, "site", "updatesite", "xml", options, urlRepository);
    if (report.getDownloadStatus() == DownloadStatus.FAILED) {
        return null;
    }
    try (InputStream in = new FileInputStream(report.getLocalFile())) {
        UpdateSite site = EclipseUpdateSiteParser.parse(in);
        site.setUri(normalizeSiteUri(site.getUri(), siteUri));
        return site;
    }
}
Also used : URLResource(org.apache.ivy.plugins.repository.url.URLResource) ZipInputStream(java.util.zip.ZipInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) URI(java.net.URI) UpdateSite(org.apache.ivy.osgi.updatesite.xml.UpdateSite) URL(java.net.URL) FileInputStream(java.io.FileInputStream)

Aggregations

URI (java.net.URI)2 UpdateSite (org.apache.ivy.osgi.updatesite.xml.UpdateSite)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 ZipInputStream (java.util.zip.ZipInputStream)1 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)1 RepoDescriptor (org.apache.ivy.osgi.repo.RepoDescriptor)1 URLResource (org.apache.ivy.plugins.repository.url.URLResource)1