mirror of https://github.com/apache/archiva.git
remove duplicate code with using exposed method
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1443220 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a331e649ca
commit
9b1ba50b0a
|
@ -60,7 +60,7 @@ import java.util.Set;
|
||||||
/**
|
/**
|
||||||
* RepositorySearch implementation which uses the Maven Indexer for searching.
|
* RepositorySearch implementation which uses the Maven Indexer for searching.
|
||||||
*/
|
*/
|
||||||
@Service ("repositorySearch#maven")
|
@Service("repositorySearch#maven")
|
||||||
public class MavenRepositorySearch
|
public class MavenRepositorySearch
|
||||||
implements RepositorySearch
|
implements RepositorySearch
|
||||||
{
|
{
|
||||||
|
@ -338,37 +338,8 @@ public class MavenRepositorySearch
|
||||||
|
|
||||||
if ( repoConfig != null )
|
if ( repoConfig != null )
|
||||||
{
|
{
|
||||||
String indexDir = repoConfig.getIndexDirectory();
|
|
||||||
File indexDirectory = null;
|
|
||||||
if ( indexDir != null && !"".equals( indexDir ) )
|
|
||||||
{
|
|
||||||
indexDirectory = new File( repoConfig.getIndexDirectory() );
|
|
||||||
if ( !indexDirectory.isAbsolute() )
|
|
||||||
{
|
|
||||||
indexDirectory = new File( repoConfig.getLocation(), repoConfig.getIndexDirectory() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
indexDirectory = new File( repoConfig.getLocation(), ".indexer" );
|
|
||||||
}
|
|
||||||
|
|
||||||
IndexingContext context = indexer.getIndexingContexts().get( repoConfig.getId() );
|
IndexingContext context = managedRepositoryAdmin.createIndexContext( repoConfig );
|
||||||
if ( context != null )
|
|
||||||
{
|
|
||||||
// alreday here so no need to record it again
|
|
||||||
log.debug( "index with id {} already exists skip adding it", repoConfig.getId() );
|
|
||||||
// set searchable flag
|
|
||||||
context.setSearchable( repoConfig.isScanned() );
|
|
||||||
indexingContextIds.add( context.getId() );
|
|
||||||
indexingContextIds.addAll( getRemoteIndexingContextIds( repo ) );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
context = indexer.addIndexingContext( repoConfig.getId(), repoConfig.getId(),
|
|
||||||
new File( repoConfig.getLocation() ), indexDirectory, null,
|
|
||||||
null, getAllIndexCreators() );
|
|
||||||
context.setSearchable( repoConfig.isScanned() );
|
|
||||||
if ( context.isSearchable() )
|
if ( context.isSearchable() )
|
||||||
{
|
{
|
||||||
indexingContextIds.addAll( getRemoteIndexingContextIds( repo ) );
|
indexingContextIds.addAll( getRemoteIndexingContextIds( repo ) );
|
||||||
|
@ -382,23 +353,23 @@ public class MavenRepositorySearch
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.warn( "Repository '" + repo + "' not found in configuration." );
|
log.warn( "Repository '{}' not found in configuration.", repo );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( UnsupportedExistingLuceneIndexException e )
|
catch ( UnsupportedExistingLuceneIndexException e )
|
||||||
{
|
{
|
||||||
log.warn( "Error accessing index of repository '" + repo + "' : " + e.getMessage() );
|
log.warn( "Error accessing index of repository '{}' : {}", repo, e.getMessage() );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
log.warn( "IO error occured while accessing index of repository '" + repo + "' : " + e.getMessage() );
|
log.warn( "IO error occured while accessing index of repository '{}' : {}", repo, e.getMessage() );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
catch ( RepositoryAdminException e )
|
catch ( RepositoryAdminException e )
|
||||||
{
|
{
|
||||||
log.warn( "RepositoryAdminException occured while accessing index of repository '" + repo + "' : "
|
log.warn( "RepositoryAdminException occured while accessing index of repository '{}' : {}", repo,
|
||||||
+ e.getMessage() );
|
e.getMessage() );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue