Package org.apache.ivy.plugins.resolver.util

Examples of org.apache.ivy.plugins.resolver.util.ResolvedResource


            ret = findBundle(dd, data, mds);
        } else {
            ret = findCapability(dd, data, mds);
        }

        ResolvedResource found = findResource(ret, getDefaultRMDParser(dd.getDependencyId()), mrid,
            data.getDate());
        if (found == null) {
            Message.debug("\t" + getName() + ": no resource found for " + mrid);
        }
        return found;
View Full Code Here


        return new MDResolvedResource(null, capabilityMd.getRevision(), rmr);
    }

    public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
            ModuleRevisionId mrid, Date date) {
        ResolvedResource found = super.findResource(rress, rmdparser, mrid, date);

        String osgiType = mrid.getOrganisation();
        // for non bundle requirement : log the selected bundle
        if (!BundleInfo.BUNDLE_TYPE.equals(osgiType)) {
            // several candidates with different symbolic name : make an warning about the ambiguity
            if (rress.length != 1) {
                // several candidates with different symbolic name ?
                Map/* <String, List<MDResolvedResource>> */matching = new HashMap();
                for (int i = 0; i < rress.length; i++) {
                    String name = ((MDResolvedResource) rress[i]).getResolvedModuleRevision()
                            .getDescriptor().getExtraAttribute(CAPABILITY_EXTRA_ATTR);
                    List/* <MDResolvedResource> */list = (List) matching.get(name);
                    if (list == null) {
                        list = new ArrayList/* <MDResolvedResource> */();
                        matching.put(name, list);
                    }
                    list.add(rress[i]);
                }
                if (matching.keySet().size() != 1) {
                    if (requirementStrategy == RequirementStrategy.first) {
                        Message.warn("Ambiguity for the '" + osgiType + "' requirement "
                                + mrid.getName() + ";version=" + mrid.getRevision());
                        Iterator itMatching = matching.entrySet().iterator();
                        while (itMatching.hasNext()) {
                            Entry/* <String, List<MDResolvedResource>> */entry = (Entry) itMatching
                                    .next();
                            Message.warn("\t" + entry.getKey());
                            Iterator itB = ((List) entry.getValue()).iterator();
                            while (itB.hasNext()) {
                                MDResolvedResource c = (MDResolvedResource) itB.next();
                                Message.warn("\t\t" + c.getRevision()
                                        + (found == c ? " (selected)" : ""));
                            }
                        }
                    } else if (requirementStrategy == RequirementStrategy.noambiguity) {
                        Message.error("Ambiguity for the '" + osgiType + "' requirement "
                                + mrid.getName() + ";version=" + mrid.getRevision());
                        Iterator itMatching = matching.entrySet().iterator();
                        while (itMatching.hasNext()) {
                            Entry/* <String, List<MDResolvedResource>> */entry = (Entry) itMatching
                                    .next();
                            Message.error("\t" + entry.getKey());
                            Iterator itB = ((List) entry.getValue()).iterator();
                            while (itB.hasNext()) {
                                MDResolvedResource c = (MDResolvedResource) itB.next();
                                Message.error("\t\t" + c.getRevision()
                                        + (found == c ? " (best match)" : ""));
                            }
                        }
                        return null;
                    }
                }
            }
            Message.info("'" + osgiType + "' requirement " + mrid.getName() + ";version="
                    + mrid.getRevision() + " satisfied by "
                    + ((MDResolvedResource) found).getResolvedModuleRevision().getId().getName()
                    + ";" + found.getRevision());
        }

        return found;
    }
View Full Code Here

    public ResolvedResource findArtifactRef(Artifact artifact, Date date) {
        URL url = artifact.getUrl();
        Message.verbose("\tusing url for " + artifact + ": " + url);
        logArtifactAttempt(artifact, url.toExternalForm());
        Resource resource = new URLResource(url);
        return new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision());
    }
View Full Code Here

            }
          }
        }
        checkInterrupted();
        URL cachedIvyURL = null;
        ResolvedResource ivyRef = findIvyFileRef(dd, data);
        checkInterrupted();
        searched = true;

        // get module descriptor
        ModuleDescriptorParser parser;
        ModuleDescriptor md;
        ModuleDescriptor systemMd = null;
        if (ivyRef == null) {
          if (!isAllownomd()) {
            Message.verbose("\t"+getName()+": no ivy file found for "+mrid);
            return null;
          }
          parser = XmlModuleDescriptorParser.getInstance();
          md = DefaultModuleDescriptor.newDefaultInstance(mrid, dd.getAllDependencyArtifacts());
          ResolvedResource artifactRef = findFirstArtifactRef(md, dd, data);
          checkInterrupted();
          if (artifactRef == null) {
            Message.verbose("\t"+getName()+": no ivy file nor artifact found for "+mrid);
            String[] conf = md.getConfigurationsNames();
            for (int i = 0; i < conf.length; i++) {
              Artifact[] artifacts = md.getArtifacts(conf[i]);
              for (int j = 0; j < artifacts.length; j++) {
              }
            }
            if (!checkedCache) {
              cachedRmr = findModuleInCache(data, mrid);
            }
            if (cachedRmr != null) {
              Message.verbose("\t"+getName()+": revision in cache: "+mrid);
              return toSystem(cachedRmr);                   
            }
            return null;
          } else {
            long lastModified = artifactRef.getLastModified();
            if (lastModified != 0 && md instanceof DefaultModuleDescriptor) {
              ((DefaultModuleDescriptor) md).setLastModified(lastModified);
            }
            Message.verbose("\t"+getName()+": no ivy file found for "+mrid+": using default data");           
            if (isDynamic) {
              md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(mrid, artifactRef.getRevision()));
            }
          }
        } else {
          ResolvedModuleRevision rmr = null;
          if (ivyRef instanceof MDResolvedResource) {
View Full Code Here

    protected ResourceMDParser getRMDParser(final DependencyDescriptor dd, final ResolveData data) {
    return new ResourceMDParser() {
      public MDResolvedResource parse(Resource resource, String rev) {
        try {
          ResolvedModuleRevision rmr = BasicResolver.this.parse(new ResolvedResource(resource, rev), dd, data);
          if (rmr == null) {
            return null;
          } else {
            return new MDResolvedResource(resource, rev, rmr);
          }
View Full Code Here

            if (!artifact.equals(artifacts[i])) {
              Message.verbose("\t"+getName()+"looking for artifact "+artifact+ " (is "+artifacts[i]+" in system namespace)");
            }
            long start = System.currentTimeMillis();
            try {
              ResolvedResource artifactRef = getArtifactRef(artifact, null);
              if (artifactRef != null) {
                origin = new ArtifactOrigin(artifactRef.getResource().isLocal(), artifactRef.getResource().getName());
                if (useOrigin && artifactRef.getResource().isLocal()) {
                  Message.verbose("\t[NOT REQUIRED] "+artifacts[i]);
                  cacheManager.saveArtifactOrigin(artifacts[i], origin);
                  archiveFile = cacheManager.getArchiveFileInCache(artifacts[i], origin);
                  adr.setDownloadStatus(DownloadStatus.NO)
                  adr.setSize(archiveFile.length());
                  adr.setArtifactOrigin(origin);
                } else {
                  // refresh archive file now that we better now its origin
                  archiveFile = cacheManager.getArchiveFileInCache(artifacts[i], origin, useOrigin);
                  if (ResourceHelper.equals(artifactRef.getResource(),
                      archiveFile)) {
                    Message.error("invalid configuration for resolver '"+getName()+"': pointing artifacts to ivy cache is forbidden !");
                    return null;
                  }
                  Message.info("downloading "+artifactRef.getResource()+" ...");
                  if (eventManager != null) {
                    eventManager.fireIvyEvent(new StartArtifactDownloadEvent(this, artifacts[i], origin));
                  }

                  File tmp = cacheManager.getArchiveFileInCache(
                      new DefaultArtifact(
                          artifacts[i].getModuleRevisionId(),
                          artifacts[i].getPublicationDate(),
                          artifacts[i].getName(),
                          artifacts[i].getType(),
                          artifacts[i].getExt()+".part",
                          artifacts[i].getExtraAttributes()),
                          origin, useOrigin);

                  // deal with artifact with url special case
                  if (artifactRef.getResource().getName().equals(String.valueOf(artifacts[i].getUrl()))) {
                    Message.verbose("\t"+getName()+": downloading "+artifactRef.getResource().getName());
                    Message.debug("\t\tto "+tmp);
                    if (tmp.getParentFile() != null) {
                      tmp.getParentFile().mkdirs();
                    }
                    _extartifactrep.get(artifactRef.getResource().getName(), tmp);
                    adr.setSize(tmp.length());
                  } else {
                    adr.setSize(getAndCheck(artifactRef.getResource(), tmp));
                  }
                  if (!tmp.renameTo(archiveFile)) {
                    Message.warn("\t[FAILED     ] "+artifacts[i]+" impossible to move temp file to definitive one ("+(System.currentTimeMillis()-start)+"ms)");
                    adr.setDownloadStatus(DownloadStatus.FAILED);
                  } else {
View Full Code Here

  protected void clearArtifactAttempts() {
      _artattempts.clear();
    }
   
    public boolean exists(Artifact artifact) {
        ResolvedResource artifactRef = getArtifactRef(artifact, null);
        if (artifactRef != null) {
            return artifactRef.getResource().exists();
        }
        return false;
    }
View Full Code Here

    protected long getPublicationDate(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data) {
        if (md.getPublicationDate() != null) {
            return md.getPublicationDate().getTime();
        }
        ResolvedResource artifactRef = findFirstArtifactRef(md, dd, data);
        if (artifactRef != null) {
            return artifactRef.getLastModified();
        }
        return -1;
    }
View Full Code Here

    protected abstract Collection findNames(Map tokenValues, String token);

    protected abstract ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data);

    protected ResolvedResource findFirstArtifactRef(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data) {
        ResolvedResource ret = null;
        String[] conf = md.getConfigurationsNames();
        for (int i = 0; i < conf.length; i++) {
            Artifact[] artifacts = md.getArtifacts(conf[i]);
            for (int j = 0; j < artifacts.length; j++) {
                ret = getArtifactRef(artifacts[j], data.getDate());
View Full Code Here


    protected ResolvedResource getArtifactRef(Artifact artifact, Date date) {
      IvyContext.getContext().set(getName()+".artifact", artifact);
      try {
        ResolvedResource ret = findArtifactRef(artifact, date);
        if (ret == null && artifact.getUrl() != null) {
          URL url = artifact.getUrl();
          Message.verbose("\tusing url for "+artifact+": "+url);
          logArtifactAttempt(artifact, url.toExternalForm());
          ret =  new ResolvedResource(new URLResource(url), artifact.getModuleRevisionId().getRevision());
        }
        return ret;
      } finally {
          IvyContext.getContext().set(getName()+".artifact", null);
      }
View Full Code Here

TOP

Related Classes of org.apache.ivy.plugins.resolver.util.ResolvedResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.