Package org.apache.ivy.plugins.repository

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


    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

        if (shouldUseMavenMetadata(getWholePattern())) {
            InputStream metadataStream = null;
            try {
                String metadataLocation = IvyPatternHelper.substitute(root
                        + "[organisation]/[module]/[revision]/maven-metadata.xml", mrid);
                Resource metadata = getRepository().getResource(metadataLocation);
                if (metadata.exists()) {
                    metadataStream = metadata.openStream();
                    final StringBuffer timestamp = new StringBuffer();
                    final StringBuffer buildNumer = new StringBuffer();
                    XMLHelper.parse(metadataStream, null, new ContextualSAXHandler() {
                        public void endElement(String uri, String localName, String qName)
                                throws SAXException {
View Full Code Here

                        }
                    }
                    String resolvedPattern = IvyPatternHelper.substitute(patternForRev,
                        historicalMrid, artifact);
                    try {
                        Resource res = repository.getResource(resolvedPattern);
                        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
                            rres.add(new ResolvedResource(res, rev));
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

        Checks.checkNotNull(origin, "origin");
        return getRepositoryCacheManager().download(origin.getArtifact(),
            new ArtifactResourceResolver() {
                public ResolvedResource resolve(Artifact artifact) {
                    try {
                        Resource resource = getResource(origin.getLocation());
                        if (resource == null) {
                            return null;
                        }
                        String revision = origin.getArtifact().getModuleRevisionId().getRevision();
                        return new ResolvedResource(resource, revision);
View Full Code Here

    private boolean check(Resource resource, File dest, String algorithm) throws IOException {
        if (!ChecksumHelper.isKnownAlgorithm(algorithm)) {
            throw new IllegalArgumentException("Unknown checksum algorithm: " + algorithm);
        }

        Resource csRes = resource.clone(resource.getName() + "." + algorithm);
        if (csRes.exists()) {
            Message.debug(algorithm + " file found for " + resource + ": checking...");
            File csFile = File.createTempFile("ivytmp", algorithm);
            try {
                get(csRes, csFile);
                try {
View Full Code Here

            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());
                Resource resource;
                if ("file".equals(url.getProtocol())) {
                    File f;
                    try {
                        f = new File(new URI(url.toExternalForm()));
                    } catch (URISyntaxException e) {
View Full Code Here

                    .setConfsToExclude(
                        (String[]) confsToRemove.toArray(new String[confsToRemove.size()]));
            if (!resolvedBranches.isEmpty()) {
                opts = opts.setResolvedBranches(resolvedBranches);
            }
            Resource res = md.getResource();
            XmlModuleDescriptorUpdater.update(res.openStream(), res, publishedIvy, opts);
        } catch (SAXException ex) {
            throw new RuntimeException("bad ivy file in cache for " + mrid, ex);
        }

        Message.verbose("\tdeliver done (" + (System.currentTimeMillis() - start) + "ms)");
View Full Code Here

            } else {
                long start = System.currentTimeMillis();
                try {
                    ResolvedResource artifactRef = resourceResolver.resolve(artifact);
                    if (artifactRef != null) {
                        Resource artifactRes = artifactRef.getResource();
                        origin = new ArtifactOrigin(artifact, artifactRes.isLocal(),
                                artifactRes.getName());
                        if (useOrigin && artifactRes.isLocal()) {
                            if (artifactRes instanceof LocalizableResource) {
                                origin.setLocation(((LocalizableResource) artifactRes).getFile()
                                        .getAbsolutePath());
                            }
                            saveArtifactOrigin(artifact, origin);
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.