active = activeContexts.add( ctxPath );
try
{
- Thread.currentThread( ).sleep( WAIT_TIME );
+ Thread.currentThread().sleep(WAIT_TIME);
}
catch ( InterruptedException e )
{
DefaultScannerListener listener = new DefaultScannerListener( indexingContext, indexerEngine, true, null );
ScanningRequest request = new ScanningRequest( indexingContext, listener );
ScanningResult result = scanner.scan( request );
- if ( result.hasExceptions( ) )
+ if (result.hasExceptions() && log.isErrorEnabled())
{
log.error( "Exceptions occured during index scan of " + context.getId( ) );
- result.getExceptions( ).stream( ).map( e -> e.getMessage( ) ).distinct( ).limit( 5 ).forEach(
- s -> log.error( "Message: " + s )
+ result.getExceptions().stream().map(Throwable::getMessage)
+ .distinct().limit(5)
+ .forEach(s -> log.error("Message: {}", s)
);
}
httpMethodConfiguration.setUsePreemptive( true );
httpMethodConfiguration.setReadTimeout( readTimeout );
httpConfiguration.setGet( httpMethodConfiguration );
- AbstractHttpClientWagon.class.cast( wagon ).setHttpConfiguration( httpConfiguration );
+ ((AbstractHttpClientWagon)wagon).setHttpConfiguration(httpConfiguration );
}
wagon.addTransferListener( new DownloadListener( ) );
private static final class DownloadListener
implements TransferListener
{
- private Logger log = LoggerFactory.getLogger( getClass( ) );
+ private final Logger log = LoggerFactory.getLogger( getClass( ) );
private String resourceName;
@Override
public InputStream retrieve(String name )
- throws IOException, FileNotFoundException
+ throws IOException
{
try
{
}
catch ( ResourceDoesNotExistException e )
{
- FileNotFoundException fnfe = new FileNotFoundException( e.getMessage( ) );
- fnfe.initCause( e );
+ FileNotFoundException fnfe = new FileNotFoundException(e.getMessage( ));
+ fnfe.initCause(e);
throw fnfe;
}
}
import org.apache.archiva.indexer.UnsupportedBaseContextException;
import org.apache.archiva.indexer.search.ArtifactInfoFilter;
-import org.apache.archiva.maven.indexer.search.NoClassifierArtifactInfoFilter;
import org.apache.archiva.indexer.search.RepositorySearch;
import org.apache.archiva.indexer.search.RepositorySearchException;
import org.apache.archiva.indexer.search.SearchFields;
public class MavenRepositorySearch
implements RepositorySearch
{
- private Logger log = LoggerFactory.getLogger( getClass() );
+ private final Logger log = LoggerFactory.getLogger( getClass() );
private Indexer indexer;
throw new RepositorySearchException( "No search fields set." );
}
if (qu.clauses()!=null) {
- log.debug("CLAUSES ", qu.clauses());
+ log.debug("CLAUSES {}", qu.clauses());
for (BooleanClause cl : qu.clauses()) {
- log.debug("Clause ",cl);
+ log.debug("Clause {}",cl);
}
}
- return search( limits, qu, indexingContextIds, Collections.<ArtifactInfoFilter>emptyList(),
+ return search( limits, qu, indexingContextIds, Collections.emptyList(),
searchFields.getRepositories(), searchFields.isIncludePomArtifacts() );
}
{
log.warn( "RepositorySearchException occured while accessing index of repository '{}' : {}", repo,
e.getMessage() );
- continue;
} catch (UnsupportedBaseContextException e) {
log.error("Fatal situation: Maven repository without IndexingContext found.");
- continue;
}
}
import org.apache.archiva.repository.base.RepositoryHandlerDependencies;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.index.ArtifactContext;
import org.apache.maven.index.ArtifactContextProducer;
import org.apache.maven.index.ArtifactScanningListener;
StringBuilder sb = new StringBuilder();
for ( SearchResultHit hit : searchResults.getHits() )
{
- sb.append( hit.toString() ).append( SystemUtils.LINE_SEPARATOR );
+ sb.append( hit.toString() ).append( System.lineSeparator() );
}
return sb.toString();
}
{
createSimpleIndex( false );
- List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+ List<String> selectedRepos = Collections.singletonList(TEST_REPO_1);
// search artifactId
when( archivaConfig.getDefaultLocale() ).thenReturn( Locale.getDefault( ) );
{
createIndexContainingMoreArtifacts( true );
- List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+ List<String> selectedRepos = Collections.singletonList(TEST_REPO_1);
SearchFields searchFields = new SearchFields();
searchFields.setClassName( "com.classname.search.App" );
{
createIndexContainingMoreArtifacts( true );
- List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+ List<String> selectedRepos = Collections.singletonList(TEST_REPO_1);
SearchFields searchFields = new SearchFields();
searchFields.setClassName( "SomeClass" );
{
createIndexContainingMoreArtifacts( true );
- List<String> selectedRepos = Arrays.asList( TEST_REPO_1 );
+ List<String> selectedRepos = Collections.singletonList(TEST_REPO_1);
when( archivaConfig.getConfiguration() ).thenReturn( config );
{
createIndexContainingMoreArtifacts( true );
- List<String> selectedRepos = Arrays.asList( "foo" );
+ List<String> selectedRepos = Collections.singletonList("foo");
SearchFields searchFields = new SearchFields();
searchFields.setClassName( "SomeClass" );
SearchFields searchFields = new SearchFields();
searchFields.setGroupId("org.example");
- searchFields.setRepositories(Arrays.asList(REPO_RELEASE));
+ searchFields.setRepositories(Collections.singletonList(REPO_RELEASE));
searchResults = search.search(null, searchFields, limits);
*/
private void executeUpdateFunction( ArchivaIndexingContext context, IndexUpdateConsumer function ) throws IndexUpdateFailedException
{
- IndexingContext indexingContext = null;
+ IndexingContext indexingContext;
try
{
indexingContext = getMvnContext( context );
DefaultScannerListener listener = new DefaultScannerListener( indexingContext, indexerEngine, true, null );
ScanningRequest request = new ScanningRequest( indexingContext, listener );
ScanningResult result = scanner.scan( request );
- if ( result.hasExceptions( ) )
+ if (result.hasExceptions() && log.isErrorEnabled())
{
- log.error( "Exceptions occured during index scan of " + context.getId( ) );
- result.getExceptions( ).stream( ).map( e -> e.getMessage( ) ).distinct( ).limit( 5 ).forEach(
- s -> log.error( "Message: " + s )
+ log.error("Exceptions occured during index scan of {}", context.getId());
+ result.getExceptions().stream()
+ .map(Throwable::getMessage).distinct()
+ .limit(5).forEach(s -> log.error( "Message: {}", s )
);
}
private static final class DownloadListener
implements TransferListener
{
- private Logger log = LoggerFactory.getLogger( getClass( ) );
+ private final Logger log = LoggerFactory.getLogger( getClass( ) );
private String resourceName;