*
*/
public class ProxyConnectorSelectionPredicate
- implements Predicate
+ implements Predicate<ProxyConnectorConfiguration>
{
private String sourceId;
}
@Override
- public boolean evaluate( Object object )
+ public boolean evaluate( ProxyConnectorConfiguration object )
{
boolean satisfies = false;
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 );
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 )
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 );
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( ) );
- }
}
/*
if ( needsMetadataUpdate )
{
- updateMetadata( artifactRef );
+ updateMetadata( path );
}
}
catch ( LayoutException e )
}
}
- 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.
- }
}
}
return IndexingContext.class.equals(clazz);
}
+ @SuppressWarnings( "unchecked" )
@Override
public <T> T getBaseContext(Class<T> clazz) throws UnsupportedOperationException {
if (IndexingContext.class.equals(clazz)) {
/**
* @see RepositorySearch#search(String, SearchFields, SearchResultLimits)
*/
+ @SuppressWarnings( "deprecation" )
@Override
public SearchResults search( String principal, SearchFields searchFields, SearchResultLimits limits )
throws RepositorySearchException
FlatSearchResponse response = indexer.searchFlat( request );
- if ( response == null || response.getTotalHits() == 0 )
+ if ( response == null || response.getTotalHitsCount() == 0 )
{
SearchResults results = new SearchResults();
results.setLimits( limits );
@Inject
@Named(value = "archivaTaskScheduler#repository")
- private ArchivaTaskScheduler scheduler;
+ private ArchivaTaskScheduler<RepositoryTask> scheduler;
@Inject
private RepositoryRegistry repositoryRegistry;
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;
}
ProxyConnectorSelectionPredicate selectedProxy = new ProxyConnectorSelectionPredicate( sourceId, targetId );
- return (ProxyConnectorConfiguration) CollectionUtils.find( configuration.getProxyConnectors(), selectedProxy );
+ return IterableUtils.find( configuration.getProxyConnectors(), selectedProxy );
}
protected ProxyConnectorConfiguration getProxyConnectorConfiguration( ProxyConnector proxyConnector )
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;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.function.Function;
import static org.easymock.EasyMock.*;
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
{
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." );
}
@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." );
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*,
@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 );
}
+ @Deprecated
@Override
public void openConnection()
throws ConnectionException, AuthenticationException
return IndexingContext.class.equals(clazz);
}
+ @SuppressWarnings( "unchecked" )
@Override
public <T> T getBaseContext(Class<T> clazz) throws UnsupportedOperationException {
if (IndexingContext.class.equals(clazz)) {
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 );
/**
* MetadataToolsTest
*/
+@SuppressWarnings( "deprecation" )
@ContextConfiguration (
{ "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-metadata-tools-test.xml" } )
public class MetadataToolsTest