@@ -29,7 +29,7 @@ import org.apache.commons.lang.StringUtils; | |||
* | |||
*/ | |||
public class ProxyConnectorSelectionPredicate | |||
implements Predicate | |||
implements Predicate<ProxyConnectorConfiguration> | |||
{ | |||
private String sourceId; | |||
@@ -42,7 +42,7 @@ public class ProxyConnectorSelectionPredicate | |||
} | |||
@Override | |||
public boolean evaluate( Object object ) | |||
public boolean evaluate( ProxyConnectorConfiguration object ) | |||
{ | |||
boolean satisfies = false; | |||
@@ -213,17 +213,9 @@ public class MetadataUpdaterConsumer | |||
log.debug( "Skipping uptodate metadata: {}", this.metadataTools.toPath( projectRef ) ); | |||
return; | |||
} | |||
metadataTools.updateMetadata( this.repository, projectRef ); | |||
metadataTools.updateMetadata( this.repository, metadataPath ); | |||
log.debug( "Updated metadata: {}", this.metadataTools.toPath( projectRef ) ); | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
log.warn( "Unable to convert path [{}] to an internal project reference: ", path, e ); | |||
triggerConsumerWarning( TYPE_METADATA_BAD_INTERNAL_REF, | |||
"Unable to convert path [" + path + "] to an internal project reference: " | |||
+ e.getMessage( ) ); | |||
} | |||
catch ( RepositoryMetadataException e ) | |||
{ | |||
log.error( "Unable to write project metadat for artifact [{}]:", path, e ); | |||
@@ -236,13 +228,6 @@ public class MetadataUpdaterConsumer | |||
triggerConsumerWarning( TYPE_METADATA_IO, | |||
"Project metadata not written due to IO warning: " + e.getMessage( ) ); | |||
} | |||
catch ( ContentNotFoundException e ) | |||
{ | |||
log.warn( "Project metadata not written because no versions were found to update: ", e ); | |||
triggerConsumerWarning( TYPE_METADATA_IO, | |||
"Project metadata not written because no versions were found to update: " | |||
+ e.getMessage( ) ); | |||
} | |||
} | |||
private void updateVersionMetadata( ArtifactReference artifact, String path ) | |||
@@ -265,16 +250,9 @@ public class MetadataUpdaterConsumer | |||
return; | |||
} | |||
metadataTools.updateMetadata( this.repository, versionRef ); | |||
metadataTools.updateMetadata( this.repository, metadataPath ); | |||
log.debug( "Updated metadata: {}", this.metadataTools.toPath( versionRef ) ); | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
log.warn( "Unable to convert path [{}] to an internal version reference: ", path, e ); | |||
triggerConsumerWarning( TYPE_METADATA_BAD_INTERNAL_REF, | |||
"Unable to convert path [" + path + "] to an internal version reference: " | |||
+ e.getMessage( ) ); | |||
} | |||
catch ( RepositoryMetadataException e ) | |||
{ | |||
log.error( "Unable to write version metadata for artifact [{}]: ", path, e ); | |||
@@ -287,13 +265,6 @@ public class MetadataUpdaterConsumer | |||
triggerConsumerWarning( TYPE_METADATA_IO, | |||
"Version metadata not written due to IO warning: " + e.getMessage( ) ); | |||
} | |||
catch ( ContentNotFoundException e ) | |||
{ | |||
log.warn( "Version metadata not written because no versions were found to update: ", e ); | |||
triggerConsumerWarning( TYPE_METADATA_IO, | |||
"Version metadata not written because no versions were found to update: " | |||
+ e.getMessage( ) ); | |||
} | |||
} | |||
/* |
@@ -166,7 +166,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge | |||
if ( needsMetadataUpdate ) | |||
{ | |||
updateMetadata( artifactRef ); | |||
updateMetadata( path ); | |||
} | |||
} | |||
catch ( LayoutException e ) | |||
@@ -183,57 +183,17 @@ public class CleanupReleasedSnapshotsRepositoryPurge | |||
} | |||
} | |||
private void updateMetadata( ArtifactReference artifact ) | |||
private void updateMetadata( String path ) | |||
{ | |||
VersionedReference versionRef = new VersionedReference( ); | |||
versionRef.setGroupId( artifact.getGroupId( ) ); | |||
versionRef.setArtifactId( artifact.getArtifactId( ) ); | |||
versionRef.setVersion( artifact.getVersion( ) ); | |||
ProjectReference projectRef = new ProjectReference( ); | |||
projectRef.setGroupId( artifact.getGroupId( ) ); | |||
projectRef.setArtifactId( artifact.getArtifactId( ) ); | |||
try | |||
{ | |||
metadataTools.updateMetadata( repository, versionRef ); | |||
} | |||
catch ( ContentNotFoundException e ) | |||
{ | |||
// Ignore. (Just means we have no snapshot versions left to reference). | |||
metadataTools.updateMetadata( repository, path ); | |||
} | |||
catch ( RepositoryMetadataException e ) | |||
{ | |||
// Ignore. | |||
} | |||
catch ( IOException e ) | |||
{ | |||
// Ignore. | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
// Ignore. | |||
} | |||
try | |||
{ | |||
metadataTools.updateMetadata( repository, projectRef ); | |||
} | |||
catch ( ContentNotFoundException e ) | |||
{ | |||
// Ignore. (Just means we have no snapshot versions left to reference). | |||
} | |||
catch ( RepositoryMetadataException e ) | |||
{ | |||
// Ignore. | |||
} | |||
catch ( IOException e ) | |||
{ | |||
// Ignore. | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
// Ignore. | |||
} | |||
} | |||
} |
@@ -108,6 +108,7 @@ public class MavenIndexContext implements ArchivaIndexingContext { | |||
return IndexingContext.class.equals(clazz); | |||
} | |||
@SuppressWarnings( "unchecked" ) | |||
@Override | |||
public <T> T getBaseContext(Class<T> clazz) throws UnsupportedOperationException { | |||
if (IndexingContext.class.equals(clazz)) { |
@@ -145,6 +145,7 @@ public class MavenRepositorySearch | |||
/** | |||
* @see RepositorySearch#search(String, SearchFields, SearchResultLimits) | |||
*/ | |||
@SuppressWarnings( "deprecation" ) | |||
@Override | |||
public SearchResults search( String principal, SearchFields searchFields, SearchResultLimits limits ) | |||
throws RepositorySearchException | |||
@@ -325,7 +326,7 @@ public class MavenRepositorySearch | |||
FlatSearchResponse response = indexer.searchFlat( request ); | |||
if ( response == null || response.getTotalHits() == 0 ) | |||
if ( response == null || response.getTotalHitsCount() == 0 ) | |||
{ | |||
SearchResults results = new SearchResults(); | |||
results.setLimits( limits ); |
@@ -144,7 +144,7 @@ public class DefaultRepositoryProxyConnectors | |||
@Inject | |||
@Named(value = "archivaTaskScheduler#repository") | |||
private ArchivaTaskScheduler scheduler; | |||
private ArchivaTaskScheduler<RepositoryTask> scheduler; | |||
@Inject | |||
private RepositoryRegistry repositoryRegistry; |
@@ -29,7 +29,7 @@ import org.apache.archiva.configuration.ProxyConnectorConfiguration; | |||
import org.apache.archiva.configuration.functors.ProxyConnectorSelectionPredicate; | |||
import org.apache.archiva.metadata.model.facets.AuditEvent; | |||
import org.apache.archiva.repository.RepositoryRegistry; | |||
import org.apache.commons.collections4.CollectionUtils; | |||
import org.apache.commons.collections4.IterableUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.springframework.stereotype.Service; | |||
@@ -205,7 +205,7 @@ public class DefaultProxyConnectorAdmin | |||
} | |||
ProxyConnectorSelectionPredicate selectedProxy = new ProxyConnectorSelectionPredicate( sourceId, targetId ); | |||
return (ProxyConnectorConfiguration) CollectionUtils.find( configuration.getProxyConnectors(), selectedProxy ); | |||
return IterableUtils.find( configuration.getProxyConnectors(), selectedProxy ); | |||
} | |||
protected ProxyConnectorConfiguration getProxyConnectorConfiguration( ProxyConnector proxyConnector ) |
@@ -23,6 +23,7 @@ import junit.framework.TestCase; | |||
import org.apache.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.archiva.consumers.InvalidRepositoryContentConsumer; | |||
import org.apache.archiva.consumers.KnownRepositoryContentConsumer; | |||
import org.apache.archiva.consumers.RepositoryContentConsumer; | |||
import org.apache.archiva.repository.BasicManagedRepository; | |||
import org.apache.archiva.repository.BasicRemoteRepository; | |||
import org.apache.archiva.repository.ManagedRepository; | |||
@@ -59,6 +60,7 @@ import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
import java.util.function.Function; | |||
import static org.easymock.EasyMock.*; | |||
@@ -347,16 +349,20 @@ public class RepositoryContentConsumersTest | |||
return path; | |||
} | |||
private static Map convertToMap( List objects ) | |||
private static <T> Map<String, T> convertToMap( List<T> objects) | |||
{ | |||
HashMap map = new HashMap(); | |||
for ( Object o : objects ) | |||
HashMap<String,T> map = new HashMap<>(); | |||
for ( T o : objects ) | |||
{ | |||
map.put( o, o ); | |||
map.put( o.toString(), o ); | |||
} | |||
return map; | |||
} | |||
private static <T> Function<List<T>,Map<String,T>> getConversionFunction(Class<T> type) { | |||
return ts -> convertToMap( ts ); | |||
} | |||
public class MockApplicationContext | |||
implements ApplicationContext | |||
{ | |||
@@ -445,23 +451,25 @@ public class RepositoryContentConsumersTest | |||
throw new UnsupportedOperationException( "Not supported yet." ); | |||
} | |||
@SuppressWarnings( "unchecked" ) | |||
@Override | |||
public Map getBeansOfType( Class type ) | |||
public <T> Map<String, T> getBeansOfType( Class<T> type ) | |||
throws BeansException | |||
{ | |||
if ( type == KnownRepositoryContentConsumer.class ) | |||
{ | |||
return convertToMap( knownRepositoryContentConsumer ); | |||
List<T> list = null; | |||
if (type == KnownRepositoryContentConsumer.class) { | |||
list = (List<T>) knownRepositoryContentConsumer; | |||
} else if (type == InvalidRepositoryContentConsumer.class) { | |||
list = (List<T>) invalidRepositoryContentConsumers; | |||
} | |||
if ( type == InvalidRepositoryContentConsumer.class ) | |||
{ | |||
return convertToMap( invalidRepositoryContentConsumers ); | |||
if (list!=null) { | |||
return getConversionFunction( type ).apply( list ); | |||
} | |||
throw new UnsupportedOperationException( "Should not have been called" ); | |||
} | |||
@Override | |||
public Map getBeansOfType( Class type, boolean includeNonSingletons, boolean allowEagerInit ) | |||
public <T> Map<String, T> getBeansOfType( Class<T> type, boolean includeNonSingletons, boolean allowEagerInit ) | |||
throws BeansException | |||
{ | |||
throw new UnsupportedOperationException( "Not supported yet." ); | |||
@@ -487,7 +495,7 @@ public class RepositoryContentConsumersTest | |||
} | |||
@Override | |||
public Object getBean( String name, Class requiredType ) | |||
public <T> T getBean( String name, Class<T> requiredType ) | |||
throws BeansException | |||
{ | |||
throw new UnsupportedOperationException( "Not supported yet." ); |
@@ -227,7 +227,6 @@ | |||
org.apache.archiva.scheduler;version=${project.version}, | |||
org.apache.commons.io;version="[1.4,2)", | |||
org.apache.commons.lang*;version="[2.4,3)", | |||
org.apache.lucene*;version="[3,4)", | |||
org.springframework*;version="[3,4)", | |||
org.apache.archiva.redback.components.taskqueue*, | |||
org.apache.maven.index*, |
@@ -68,7 +68,7 @@ public class TemporaryGroupIndexSessionCleaner | |||
@Override | |||
public void sessionDestroyed( HttpSessionEvent httpSessionEvent ) | |||
{ | |||
Map<String, TemporaryGroupIndex> tempFilesPerKey = | |||
@SuppressWarnings( "unchecked" ) Map<String, TemporaryGroupIndex> tempFilesPerKey = | |||
(Map<String, TemporaryGroupIndex>) httpSessionEvent.getSession().getAttribute( | |||
TEMPORARY_INDEX_SESSION_KEY ); | |||
@@ -147,6 +147,7 @@ public class MockWagon | |||
} | |||
@Deprecated | |||
@Override | |||
public void openConnection() | |||
throws ConnectionException, AuthenticationException |
@@ -108,6 +108,7 @@ public class MavenIndexContextMock implements ArchivaIndexingContext { | |||
return IndexingContext.class.equals(clazz); | |||
} | |||
@SuppressWarnings( "unchecked" ) | |||
@Override | |||
public <T> T getBaseContext(Class<T> clazz) throws UnsupportedOperationException { | |||
if (IndexingContext.class.equals(clazz)) { |
@@ -154,11 +154,11 @@ public class MavenRepositoryProviderTest | |||
repo.setUrl( "https://repo.maven.apache.org/maven2/test" ); | |||
repo.setDownloadRemoteIndex( true ); | |||
repo.setDownloadRemoteIndexOnStartup( true ); | |||
Map header = new HashMap( ); | |||
Map<String,String> header = new HashMap<>( ); | |||
header.put("header1","value1"); | |||
header.put("header2","value2"); | |||
repo.setExtraHeaders( header ); | |||
Map params = new HashMap( ); | |||
Map<String,String> params = new HashMap<>( ); | |||
params.put("param1","pval1"); | |||
params.put("param2","pval2"); | |||
repo.setExtraParameters( params ); |
@@ -60,6 +60,7 @@ import static org.junit.Assert.*; | |||
/** | |||
* MetadataToolsTest | |||
*/ | |||
@SuppressWarnings( "deprecation" ) | |||
@ContextConfiguration ( | |||
{ "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-metadata-tools-test.xml" } ) | |||
public class MetadataToolsTest |