@@ -176,7 +176,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { | |||
active = activeContexts.add( ctxPath ); | |||
try | |||
{ | |||
Thread.currentThread( ).sleep( WAIT_TIME ); | |||
Thread.currentThread().sleep(WAIT_TIME); | |||
} | |||
catch ( InterruptedException e ) | |||
{ | |||
@@ -229,11 +229,12 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { | |||
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) | |||
); | |||
} | |||
@@ -302,7 +303,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { | |||
httpMethodConfiguration.setUsePreemptive( true ); | |||
httpMethodConfiguration.setReadTimeout( readTimeout ); | |||
httpConfiguration.setGet( httpMethodConfiguration ); | |||
AbstractHttpClientWagon.class.cast( wagon ).setHttpConfiguration( httpConfiguration ); | |||
((AbstractHttpClientWagon)wagon).setHttpConfiguration(httpConfiguration ); | |||
} | |||
wagon.addTransferListener( new DownloadListener( ) ); | |||
@@ -672,7 +673,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { | |||
private static final class DownloadListener | |||
implements TransferListener | |||
{ | |||
private Logger log = LoggerFactory.getLogger( getClass( ) ); | |||
private final Logger log = LoggerFactory.getLogger( getClass( ) ); | |||
private String resourceName; | |||
@@ -763,7 +764,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { | |||
@Override | |||
public InputStream retrieve(String name ) | |||
throws IOException, FileNotFoundException | |||
throws IOException | |||
{ | |||
try | |||
{ | |||
@@ -780,8 +781,8 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { | |||
} | |||
catch ( ResourceDoesNotExistException e ) | |||
{ | |||
FileNotFoundException fnfe = new FileNotFoundException( e.getMessage( ) ); | |||
fnfe.initCause( e ); | |||
FileNotFoundException fnfe = new FileNotFoundException(e.getMessage( )); | |||
fnfe.initCause(e); | |||
throw fnfe; | |||
} | |||
} |
@@ -20,7 +20,6 @@ package org.apache.archiva.maven.indexer.search; | |||
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; | |||
@@ -73,7 +72,7 @@ import java.util.Set; | |||
public class MavenRepositorySearch | |||
implements RepositorySearch | |||
{ | |||
private Logger log = LoggerFactory.getLogger( getClass() ); | |||
private final Logger log = LoggerFactory.getLogger( getClass() ); | |||
private Indexer indexer; | |||
@@ -273,13 +272,13 @@ public class MavenRepositorySearch | |||
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() ); | |||
} | |||
@@ -435,10 +434,8 @@ public class MavenRepositorySearch | |||
{ | |||
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; | |||
} | |||
} | |||
@@ -32,7 +32,6 @@ import org.apache.archiva.repository.base.ArchivaRepositoryRegistry; | |||
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; | |||
@@ -346,7 +345,7 @@ public abstract class AbstractMavenRepositorySearch | |||
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(); | |||
} |
@@ -109,7 +109,7 @@ public class MavenRepositorySearchTest | |||
{ | |||
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( ) ); | |||
@@ -685,7 +685,7 @@ public class MavenRepositorySearchTest | |||
{ | |||
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" ); | |||
@@ -733,7 +733,7 @@ public class MavenRepositorySearchTest | |||
{ | |||
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" ); | |||
@@ -755,7 +755,7 @@ public class MavenRepositorySearchTest | |||
{ | |||
createIndexContainingMoreArtifacts( true ); | |||
List<String> selectedRepos = Arrays.asList( TEST_REPO_1 ); | |||
List<String> selectedRepos = Collections.singletonList(TEST_REPO_1); | |||
when( archivaConfig.getConfiguration() ).thenReturn( config ); | |||
@@ -775,7 +775,7 @@ public class MavenRepositorySearchTest | |||
{ | |||
createIndexContainingMoreArtifacts( true ); | |||
List<String> selectedRepos = Arrays.asList( "foo" ); | |||
List<String> selectedRepos = Collections.singletonList("foo"); | |||
SearchFields searchFields = new SearchFields(); | |||
searchFields.setClassName( "SomeClass" ); | |||
@@ -821,7 +821,7 @@ public class MavenRepositorySearchTest | |||
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); | |||
@@ -156,7 +156,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { | |||
*/ | |||
private void executeUpdateFunction( ArchivaIndexingContext context, IndexUpdateConsumer function ) throws IndexUpdateFailedException | |||
{ | |||
IndexingContext indexingContext = null; | |||
IndexingContext indexingContext; | |||
try | |||
{ | |||
indexingContext = getMvnContext( context ); | |||
@@ -226,11 +226,12 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { | |||
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 ) | |||
); | |||
} | |||
@@ -659,7 +660,7 @@ public class ArchivaIndexManagerMock implements ArchivaIndexManager { | |||
private static final class DownloadListener | |||
implements TransferListener | |||
{ | |||
private Logger log = LoggerFactory.getLogger( getClass( ) ); | |||
private final Logger log = LoggerFactory.getLogger( getClass( ) ); | |||
private String resourceName; | |||