finally use a relocation for MRM-1761

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1549548 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-12-09 11:22:02 +00:00
parent 4b7ba850f4
commit 3f90ad3744
4 changed files with 11 additions and 6 deletions

View File

@ -154,7 +154,6 @@ public class MockBeanServices
@Override
public String getFilePathWithVersion( String requestPath, ManagedRepositoryContent managedRepositoryContent )
throws LayoutException, XMLException
{
return null;
}

View 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 )
{

View 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;
}

View 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;