[MRM-1693] exposing index downloaded from remote repositories

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1398262 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-10-15 12:12:43 +00:00
parent c472f04353
commit 7f2fbd20e0
2 changed files with 57 additions and 5 deletions

View File

@ -52,7 +52,7 @@ import java.util.Map;
* @author Olivier Lamy
* @since 1.4-M1
*/
@Service( "remoteRepositoryAdmin#default" )
@Service ( "remoteRepositoryAdmin#default" )
public class DefaultRemoteRepositoryAdmin
extends AbstractRepositoryAdmin
implements RemoteRepositoryAdmin
@ -268,13 +268,34 @@ public class DefaultRemoteRepositoryAdmin
{
return indexingContext;
}
// create path
// create remote repository path
File repoDir = new File( appServerBase, "data/remotes/" + remoteRepository.getId() );
if ( !repoDir.exists() )
{
repoDir.mkdirs();
}
File indexDirectory = new File( repoDir, ".index" );
File indexDirectory = null;
// is there configured indexDirectory ?
String indexDirectoryPath = remoteRepository.getIndexDirectory();
if ( StringUtils.isNotBlank( indexDirectoryPath ) )
{
if ( new File( indexDirectoryPath ).isAbsolute() )
{
indexDirectory = new File( indexDirectoryPath );
}
else
{
indexDirectory = new File( repoDir, indexDirectoryPath );
}
}
// if not configured use a default value
if ( indexDirectory == null )
{
indexDirectory = new File( repoDir, ".index" );
}
if ( !indexDirectory.exists() )
{
indexDirectory.mkdirs();

View File

@ -20,6 +20,8 @@ package org.apache.archiva.webdav;
*/
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.RemoteRepository;
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener;
import org.apache.archiva.audit.Auditable;
@ -178,6 +180,9 @@ public class ArchivaDavResourceFactory
@Named ( value = "httpAuthenticator#basic" )
private HttpAuthenticator httpAuth;
@Inject
private RemoteRepositoryAdmin remoteRepositoryAdmin;
@Inject
private IndexMerger indexMerger;
@ -277,6 +282,32 @@ public class ArchivaDavResourceFactory
}
else
{
try
{
RemoteRepository remoteRepository =
remoteRepositoryAdmin.getRemoteRepository( archivaLocator.getRepositoryId() );
if ( remoteRepository != null )
{
String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
IndexingContext indexingContext = remoteRepositoryAdmin.createIndexContext( remoteRepository );
File resourceFile = StringUtils.equals( logicalResource, "/" )
? new File( indexingContext.getIndexDirectoryFile().getParent() )
: new File( indexingContext.getIndexDirectoryFile().getParent(), logicalResource );
resource = new ArchivaDavResource( resourceFile.getAbsolutePath(), locator.getResourcePath(), null,
request.getRemoteAddr(), activePrincipal,
request.getDavSession(), archivaLocator, this, mimeTypes,
auditListeners, scheduler );
return resource;
}
}
catch ( RepositoryAdminException e )
{
log.debug( "RepositoryException remote repository with d'{}' not found, msg: {}",
archivaLocator.getRepositoryId(), e.getMessage() );
}
ManagedRepositoryContent managedRepository = null;
try
@ -592,8 +623,8 @@ public class ArchivaDavResourceFactory
if ( managedRepository.hasContent( artifact )
&& managedRepository.getRepository().isBlockRedeployments() )
{
log.warn( "Overwriting released artifacts in repository '" + managedRepository.getId()
+ "' is not allowed." );
log.warn( "Overwriting released artifacts in repository '{}' is not allowed.",
managedRepository.getId() );
throw new DavException( HttpServletResponse.SC_CONFLICT,
"Overwriting released artifacts is not allowed." );
}