Message.warn("problem while downloading ivy file: "+ivyRef.getResource()+": "+ex.getMessage());
Message.warn("problem while downloading ivy file: "+ivyRef.getResource()+" to "+ivyTempFile+": "+ex.getMessage());
    public ResolvedModuleRevision parse(    		ResolvedResource ivyRef,     		DependencyDescriptor dd,     		ResolveData data    		) throws ParseException {    	    	ModuleRevisionId mrid = dd.getDependencyRevisionId();    	ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(ivyRef.getResource());        if (parser == null) {            Message.warn("no module descriptor parser available for "+ivyRef.getResource());            return null;        }        Message.verbose("\t"+getName()+": found md file for "+mrid);        Message.verbose("\t\t=> "+ivyRef);        Message.debug("\tparser = "+parser);        boolean isChangingRevision = getChangingMatcher().matches(mrid.getRevision());                boolean isChangingDependency = isChangingRevision || dd.isChanging();    	Date cachedPublicationDate = null;        ModuleRevisionId resolvedMrid = mrid;                // first check if this dependency has not yet been resolved        if (getIvy().getVersionMatcher().isDynamic(mrid)) {            resolvedMrid = new ModuleRevisionId(mrid.getModuleId(), ivyRef.getRevision());            IvyNode node = getSystemNode(data, resolvedMrid);            if (node != null && node.getModuleRevision() != null) {                // this revision has already be resolved : return it                if (node.getDescriptor() != null && node.getDescriptor().isDefault()) {                    Message.verbose("\t"+getName()+": found already resolved revision: "+resolvedMrid+": but it's a default one, maybe we can find a better one");                } else {                    Message.verbose("\t"+getName()+": revision already resolved: "+resolvedMrid);                    return searchedRmr(node.getModuleRevision());                }            }        }                // now let's see if we can find it in cache and if it is up to date        ResolvedModuleRevision rmr = findModuleInCache(data, resolvedMrid);        if (rmr != null) {            if (rmr.getDescriptor().isDefault() && rmr.getResolver() != this) {                Message.verbose("\t"+getName()+": found revision in cache: "+mrid+" (resolved by "+rmr.getResolver().getName()+"): but it's a default one, maybe we can find a better one");            } else {                if (!isCheckmodified() && !isChangingDependency) {                    Message.verbose("\t"+getName()+": revision in cache: "+mrid);                    return searchedRmr(rmr);                }                long repLastModified = ivyRef.getLastModified();                long cacheLastModified = rmr.getDescriptor().getLastModified();                 if (!rmr.getDescriptor().isDefault() && repLastModified <= cacheLastModified) {                    Message.verbose("\t"+getName()+": revision in cache (not updated): "+resolvedMrid);                    return searchedRmr(rmr);                } else {                    Message.verbose("\t"+getName()+": revision in cache is not up to date: "+resolvedMrid);                    if (isChangingDependency) {                        // ivy file has been updated, we should see if it has a new publication date                        // to see if a new download is required (in case the dependency is a changing one)                        cachedPublicationDate = rmr.getDescriptor().getResolvedPublicationDate();                    }                }            }        }                // now download ivy file and parse it        URL cachedIvyURL = null;        try {            // first check if source file is not cache file itself            if (ResourceHelper.equals(ivyRef.getResource(),                     data.getIvy().getIvyFileInCache(data.getCache(), toSystem(resolvedMrid)))) {                Message.error("invalid configuration for resolver '"+getName()+"': pointing ivy files to ivy cache is forbidden !");                return null;            }                        // temp file is used to prevent downloading twice            File ivyTempFile = File.createTempFile("ivy", "xml");             ivyTempFile.deleteOnExit();            Message.debug("\t"+getName()+": downloading "+ivyRef.getResource());            get(ivyRef.getResource(), ivyTempFile);            try {                cachedIvyURL = ivyTempFile.toURL();            } catch (MalformedURLException ex) {                Message.warn("malformed url exception for temp file: "+ivyTempFile+": "+ex.getMessage());                return null;            }        } catch (IOException ex) {            Message.warn("problem while downloading ivy file: "+ivyRef.getResource()+": "+ex.getMessage());            return null;        }        try {            ModuleDescriptor md = parser.parseDescriptor(data.getIvy(), cachedIvyURL, ivyRef.getResource(), doValidate(data));            Message.debug("\t"+getName()+": parsed downloaded md file for "+mrid+" parsed="+md.getModuleRevisionId());                                    // check if we should delete old artifacts            boolean deleteOldArtifacts = false;            if (cachedPublicationDate != null && !cachedPublicationDate.equals(md.getResolvedPublicationDate())) {                // artifacts have changed, they should be downloaded again                Message.verbose(dd+" has changed: deleting old artifacts");                deleteOldArtifacts = true;            }            if (deleteOldArtifacts) {                String[] confs = rmr.getDescriptor().getConfigurationsNames();                for (int i = 0; i < confs.length; i++) {                    Artifact[] arts = rmr.getDescriptor().getArtifacts(confs[i]);                    for (int j = 0; j < arts.length; j++) {                        Artifact transformedArtifact = toSystem(arts[j]);						File artFile = data.getIvy().getArchiveFileInCache(data.getCache(), transformedArtifact);                        if (artFile.exists()) {                            Message.debug("deleting "+artFile);                            artFile.delete();                        }                        data.getIvy().removeSavedArtifactOrigin(data.getCache(), transformedArtifact);                    }                }            } else if (isChangingDependency){                Message.verbose(dd+" is changing, but has not changed: will trust cached artifacts if any");            }             return new DefaultModuleRevision(this, this, md, true, true, cachedIvyURL);        } catch (IOException ex) {            Message.warn("io problem while parsing ivy file: "+ivyRef.getResource()+": "+ex.getMessage());            return null;        }    	    }