From: Olivier Lamy Date: Mon, 9 Dec 2013 11:22:02 +0000 (+0000) Subject: finally use a relocation for MRM-1761 X-Git-Tag: archiva-2.0.0-RC1~151 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3f90ad3744ae501d1786306529803e1e05aa0536;p=archiva.git finally use a relocation for MRM-1761 git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1549548 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/mock/MockBeanServices.java b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/mock/MockBeanServices.java index cb9d4ace9..ab414f5ca 100644 --- a/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/mock/MockBeanServices.java +++ b/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/mock/MockBeanServices.java @@ -154,7 +154,6 @@ public class MockBeanServices @Override public String getFilePathWithVersion( String requestPath, ManagedRepositoryContent managedRepositoryContent ) - throws LayoutException, XMLException { return null; } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index 6132dfe01..22966878c 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -39,6 +39,7 @@ import org.apache.archiva.indexer.merger.IndexMergerRequest; import org.apache.archiva.indexer.merger.TemporaryGroupIndex; import org.apache.archiva.indexer.search.RepositorySearch; import org.apache.archiva.maven2.metadata.MavenMetadataReader; +import org.apache.archiva.metadata.repository.storage.RelocationException; import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.model.ArchivaRepositoryMetadata; import org.apache.archiva.model.ArtifactReference; @@ -537,10 +538,10 @@ public class ArchivaDavResourceFactory { return repositoryStorage.getFilePathWithVersion( archivaLocator.getResourcePath(), managedRepositoryContent ); } - catch ( LayoutException e ) + catch ( RelocationException e ) { log.error( e.getMessage(), e ); - throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e ); + throw new BrowserRedirectException( e.getPath() ); } catch ( XMLException e ) { diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java index fee01b775..b8769ab4f 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java @@ -74,7 +74,7 @@ public interface RepositoryStorage String getFilePath( String requestPath, ManagedRepository managedRepository ); String getFilePathWithVersion( final String requestPath, ManagedRepositoryContent managedRepositoryContent ) - throws LayoutException, XMLException; + throws RelocationException, XMLException; } diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java index a5e69850b..94cfd4302 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java @@ -38,6 +38,7 @@ import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.RepositorySessionFactory; import org.apache.archiva.metadata.repository.filter.Filter; import org.apache.archiva.metadata.repository.storage.ReadMetadataRequest; +import org.apache.archiva.metadata.repository.storage.RelocationException; import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException; @@ -765,10 +766,10 @@ public class Maven2RepositoryStorage } public String getFilePathWithVersion( final String requestPath, ManagedRepositoryContent managedRepositoryContent ) - throws XMLException + throws XMLException, RelocationException { - if (StringUtils.endsWith( requestPath, METADATA_FILENAME )) + if ( StringUtils.endsWith( requestPath, METADATA_FILENAME ) ) { return getFilePath( requestPath, managedRepositoryContent.getRepository() ); } @@ -811,6 +812,10 @@ public class Maven2RepositoryStorage artifactReference.getVersion(), "-SNAPSHOT" ) + "-" + timestamp + "-" + buildNumber ); + throw new RelocationException( + "/repository/" + managedRepositoryContent.getRepository().getId() + + ( StringUtils.startsWith( filePath, "/" ) ? "" : "/" ) + filePath, RelocationException.RelocationType.TEMPORARY ); + } return filePath;