]> source.dussan.org Git - archiva.git/commitdiff
finally use a relocation for MRM-1761
authorOlivier Lamy <olamy@apache.org>
Mon, 9 Dec 2013 11:22:02 +0000 (11:22 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 9 Dec 2013 11:22:02 +0000 (11:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1549548 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/archiva/security/mock/MockBeanServices.java
archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java

index cb9d4ace999f657ca18e661f33f296d5dfae9fd7..ab414f5ca47ef4421261df9d2cbe1a532990b5b8 100644 (file)
@@ -154,7 +154,6 @@ public class MockBeanServices
 
     @Override
     public String getFilePathWithVersion( String requestPath, ManagedRepositoryContent managedRepositoryContent )
-        throws LayoutException, XMLException
     {
         return null;
     }
index 6132dfe01a782630677433835bcef0b1a97be79e..22966878cf5a7e72c8c17b01a3d4c829b4811c02 100644 (file)
@@ -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 )
         {
index fee01b7751a8028ff4ec67af8b75b1db8f92b65c..b8769ab4f9c3535fff70ddc0592f8df8558c1052 100644 (file)
@@ -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;
 
 
 }
index a5e69850b2c8e474eb71652d63346015c5c46408..94cfd43021b4458657191314db8d9701177b5e13 100644 (file)
@@ -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;