Search in sources :

Example 1 with RepositoryStorage

use of org.apache.archiva.metadata.repository.storage.RepositoryStorage in project archiva by apache.

the class ArchivaDavResourceFactory method fetchContentFromProxies.

private boolean fetchContentFromProxies(ManagedRepositoryContent managedRepository, DavServletRequest request, LogicalResource resource) throws DavException {
    String path = resource.getPath();
    if (repositoryRequest.isSupportFile(path)) {
        Path proxiedFile = connectors.fetchFromProxies(managedRepository, path);
        return (proxiedFile != null);
    }
    // Is it a Metadata resource?
    if (repositoryRequest.isDefault(path) && repositoryRequest.isMetadata(path)) {
        return connectors.fetchMetadataFromProxies(managedRepository, path).isModified();
    }
    // Is it an Archetype Catalog?
    if (repositoryRequest.isArchetypeCatalog(path)) {
        // FIXME we must implement a merge of remote archetype catalog from remote servers.
        Path proxiedFile = connectors.fetchFromProxies(managedRepository, path);
        return (proxiedFile != null);
    }
    // Not any of the above? Then it's gotta be an artifact reference.
    try {
        // Get the artifact reference in a layout neutral way.
        ArtifactReference artifact = repositoryRequest.toArtifactReference(path);
        if (artifact != null) {
            String repositoryLayout = managedRepository.getRepository().getLayout();
            RepositoryStorage repositoryStorage = this.applicationContext.getBean("repositoryStorage#" + repositoryLayout, RepositoryStorage.class);
            repositoryStorage.applyServerSideRelocation(managedRepository, artifact);
            Path proxiedFile = connectors.fetchFromProxies(managedRepository, artifact);
            resource.setPath(managedRepository.toPath(artifact));
            log.debug("Proxied artifact '{}:{}:{}'", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
            return (proxiedFile != null);
        }
    } catch (LayoutException e) {
    /* eat it */
    } catch (ProxyDownloadException e) {
        log.error(e.getMessage(), e);
        throw new DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to fetch artifact resource.");
    }
    return false;
}
Also used : Path(java.nio.file.Path) RepositoryStorage(org.apache.archiva.metadata.repository.storage.RepositoryStorage) LayoutException(org.apache.archiva.repository.LayoutException) DavException(org.apache.jackrabbit.webdav.DavException) ProxyDownloadException(org.apache.archiva.policies.ProxyDownloadException) ArtifactReference(org.apache.archiva.model.ArtifactReference)

Example 2 with RepositoryStorage

use of org.apache.archiva.metadata.repository.storage.RepositoryStorage in project archiva by apache.

the class ArchivaDavResourceFactory method evaluatePathWithVersion.

private // 
String evaluatePathWithVersion(// 
ArchivaDavResourceLocator archivaLocator, // 
ManagedRepositoryContent managedRepositoryContent, String contextPath) throws DavException {
    String layout = managedRepositoryContent.getRepository() == null ? "default" : managedRepositoryContent.getRepository().getLayout();
    RepositoryStorage repositoryStorage = this.applicationContext.getBean("repositoryStorage#" + layout, RepositoryStorage.class);
    try {
        return // 
        repositoryStorage.getFilePathWithVersion(// 
        archivaLocator.getResourcePath(), managedRepositoryContent);
    } catch (RelocationException e) {
        String path = e.getPath();
        log.debug("Relocation to {}", path);
        throw new BrowserRedirectException(addHrefPrefix(contextPath, path), e.getRelocationType());
    } catch (XMLException e) {
        log.error(e.getMessage(), e);
        throw new DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e);
    }
}
Also used : RepositoryStorage(org.apache.archiva.metadata.repository.storage.RepositoryStorage) XMLException(org.apache.archiva.xml.XMLException) RelocationException(org.apache.archiva.metadata.repository.storage.RelocationException) DavException(org.apache.jackrabbit.webdav.DavException)

Example 3 with RepositoryStorage

use of org.apache.archiva.metadata.repository.storage.RepositoryStorage in project archiva by apache.

the class ArchivaDavResourceFactory method getLogicalResource.

private String getLogicalResource(ArchivaDavResourceLocator archivaLocator, org.apache.archiva.repository.ManagedRepository managedRepository, boolean useOrigResourcePath) {
    // FIXME remove this hack
    // but currently managedRepository can be null in case of group
    String layout = managedRepository == null ? "default" : managedRepository.getLayout();
    RepositoryStorage repositoryStorage = this.applicationContext.getBean("repositoryStorage#" + layout, RepositoryStorage.class);
    String path = repositoryStorage.getFilePath(useOrigResourcePath ? archivaLocator.getOrigResourcePath() : archivaLocator.getResourcePath(), managedRepository);
    log.debug("found path {} for resourcePath: '{}' with managedRepo '{}' and layout '{}'", path, archivaLocator.getResourcePath(), managedRepository == null ? "null" : managedRepository.getId(), layout);
    return path;
}
Also used : RepositoryStorage(org.apache.archiva.metadata.repository.storage.RepositoryStorage)

Aggregations

RepositoryStorage (org.apache.archiva.metadata.repository.storage.RepositoryStorage)3 DavException (org.apache.jackrabbit.webdav.DavException)2 Path (java.nio.file.Path)1 RelocationException (org.apache.archiva.metadata.repository.storage.RelocationException)1 ArtifactReference (org.apache.archiva.model.ArtifactReference)1 ProxyDownloadException (org.apache.archiva.policies.ProxyDownloadException)1 LayoutException (org.apache.archiva.repository.LayoutException)1 XMLException (org.apache.archiva.xml.XMLException)1