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;
}
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);
}
}
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;
}
Aggregations