Package org.apache.ivy.plugins.repository

Examples of org.apache.ivy.plugins.repository.Resource


                for (Iterator iter = revs.iterator(); iter.hasNext();) {
                    String rev = (String) iter.next();
                    String resolvedPattern = IvyPatternHelper.substitute(
                        pattern, ModuleRevisionId.newInstance(mrid, rev), artifact);
                    try {
                        Resource res = repository.getResource(resolvedPattern);
                        if ((res != null) && res.exists()) {
                            rres.add(new ResolvedResource(res, rev));
                        }
                    } catch (IOException e) {
                        Message.warn(
                            "impossible to get resource from name listed by maven-metadata.xml:"
View Full Code Here


    private List listRevisionsWithMavenMetadata(Repository repository, String metadataLocation) {
        List revs = null;
        InputStream metadataStream = null;
        try {
            Resource metadata = repository.getResource(metadataLocation);
            if (metadata.exists()) {
                Message.verbose("\tlisting revisions from maven-metadata: " + metadata);
                final List metadataRevs = new ArrayList();
                metadataStream = metadata.openStream();
                XMLHelper.parse(metadataStream, null, new ContextualSAXHandler() {
                    public void endElement(String uri, String localName, String qName)
                            throws SAXException {
                        if ("metadata/versioning/versions/version".equals(getContext())) {
                            metadataRevs.add(getText().trim());
View Full Code Here

            List ret = new ArrayList(revs.length);
            for (int i = 0; i < revs.length; i++) {
                String rres = IvyPatternHelper.substituteToken(partiallyResolvedPattern,
                    IvyPatternHelper.REVISION_KEY, revs[i]);
                try {
                    Resource res = rep.getResource(rres);
                    if (res != null) {
                        // we do not test if the resource actually exist here, it would cause
                        // a lot of checks which are not always necessary depending on the usage
                        // which is done of the returned ResolvedResource array
                        ret.add(new ResolvedResource(res, revs[i]));
                    }
                } catch (IOException e) {
                    Message.warn("impossible to get resource from name listed by repository: "
                            + rres + ": " + e.getMessage());
                }
            }
            if (revs.length != ret.size()) {
                Message.debug("\tfound resolved res: " + ret);
            }
            return (ResolvedResource[]) ret.toArray(new ResolvedResource[ret.size()]);
        } else if (partiallyResolvedPattern.indexOf(
                "[" + IvyPatternHelper.REVISION_KEY + "]") == -1) {
            // the partially resolved pattern is completely resolved, check the resource
            try {
                Resource res = rep.getResource(partiallyResolvedPattern);
                if (res.exists()) {
                    Message.debug("\tonly one resource found without real listing: "
                                    + "using and defining it as working@"
                                    + rep.getName() + " revision: " + res.getName());
                    return new ResolvedResource[] {new ResolvedResource(res, "working@"
                            + rep.getName())};
                }
            } catch (IOException e) {
                Message.debug("\timpossible to get resource from name listed by repository: "
View Full Code Here

        try {
            if (!versionMatcher.isDynamic(mrid) || isAlwaysCheckExactRevision()) {
                String resourceName = IvyPatternHelper.substitute(pattern, mrid, artifact);
                Message.debug("\t trying " + resourceName);
                logAttempt(resourceName);
                Resource res = repository.getResource(resourceName);
                boolean reachable = res.exists();
                if (reachable) {
                    String revision;
                    if (pattern.indexOf(IvyPatternHelper.REVISION_KEY) == -1) {
                        if ("ivy".equals(artifact.getType()) || "pom".equals(artifact.getType())) {
                            // we can't determine the revision from the pattern, get it
                            // from the moduledescriptor itself
                            File temp = File.createTempFile("ivy", artifact.getExt());
                            temp.deleteOnExit();
                            repository.get(res.getName(), temp);
                            ModuleDescriptorParser parser =
                                ModuleDescriptorParserRegistry.getInstance().getParser(res);
                            ModuleDescriptor md =
                                parser.parseDescriptor(
                                    getParserSettings(), temp.toURI().toURL(), res, false);
View Full Code Here

        return ResolverHelper.listTokenValues(repository, pattern, token);
    }
   
    protected boolean exist(String path) {
        try {
            Resource resource = repository.getResource(path);
            return resource.exists();
        } catch (IOException e) {
            return false;
        }
    }
View Full Code Here

    private RepositoryCopyProgressListener progress = new RepositoryCopyProgressListener(this);

    private Map resourcesCache = new HashMap();

    public Resource getResource(String source) throws IOException {
        Resource res = (Resource) resourcesCache.get(source);
        if (res == null) {
            res = new URLResource(new URL(source));
            resourcesCache.put(source, res);
        }
        return res;
View Full Code Here

    }
   
    public void get(String source, File destination) throws IOException {
        fireTransferInitiated(getResource(source), TransferEvent.REQUEST_GET);
        try {
            Resource res = getResource(source);
            long totalLength = res.getContentLength();
            if (totalLength > 0) {
                progress.setTotalLength(new Long(totalLength));
            }
            FileUtil.copy(new URL(source), destination, progress);
        } catch (IOException ex) {
View Full Code Here

        try {
            if (!versionMatcher.isDynamic(mrid) || isAlwaysCheckExactRevision()) {
                String resourceName = IvyPatternHelper.substitute(pattern, mrid, artifact);
                Message.debug("\t trying " + resourceName);
                logAttempt(resourceName);
                Resource res = repository.getResource(resourceName);
                boolean reachable = res.exists();
                if (reachable) {
                    String revision;
                    if (pattern.indexOf(IvyPatternHelper.REVISION_KEY) == -1) {
                        if ("ivy".equals(artifact.getType()) || "pom".equals(artifact.getType())) {
                            // we can't determine the revision from the pattern, get it
                            // from the moduledescriptor itself
                            File temp = File.createTempFile("ivy", artifact.getExt());
                            temp.deleteOnExit();
                            repository.get(res.getName(), temp);
                            ModuleDescriptorParser parser =
                                ModuleDescriptorParserRegistry.getInstance().getParser(res);
                            ModuleDescriptor md =
                                parser.parseDescriptor(
                                    getParserSettings(), temp.toURI().toURL(), res, false);
View Full Code Here

        return ResolverHelper.listTokenValues(repository, pattern, token);
    }
   
    protected boolean exist(String path) {
        try {
            Resource resource = repository.getResource(path);
            return resource.exists();
        } catch (IOException e) {
            return false;
        }
    }
View Full Code Here

            EventManager eventManager = getEventManager();
            try {
                if (eventManager != null) {
                    getRepository().addTransferListener(eventManager);
                }
                Resource jarResource = new URLResource(url);
                CacheResourceOptions options = new CacheResourceOptions();
                report = getRepositoryCacheManager().downloadRepositoryResource(jarResource,
                    "jarrepository", "jar", "jar", options, new URLRepository());
            } finally {
                if (eventManager != null) {
View Full Code Here

TOP

Related Classes of org.apache.ivy.plugins.repository.Resource

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.