mirror of https://github.com/apache/archiva.git
fix use of applicationContext.getBeansOfType instead of the old lookupMap.
The key is now interface#hint whereas was only hint with plexus arghh ! git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1130140 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aaebb5d534
commit
ee78778213
|
@ -103,14 +103,14 @@ public class DefaultRepositoryProxyConnectors
|
||||||
* plexus.requirement
|
* plexus.requirement
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
@Named(value = "repositoryContentFactory#default")
|
@Named( value = "repositoryContentFactory#default" )
|
||||||
private RepositoryContentFactory repositoryFactory;
|
private RepositoryContentFactory repositoryFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plexus.requirement
|
* plexus.requirement
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
@Named(value="metadataTools#default")
|
@Named( value = "metadataTools#default" )
|
||||||
private MetadataTools metadataTools;
|
private MetadataTools metadataTools;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -890,9 +890,12 @@ public class DefaultRepositoryProxyConnectors
|
||||||
{
|
{
|
||||||
for ( Entry<String, ? extends DownloadPolicy> entry : policies.entrySet() )
|
for ( Entry<String, ? extends DownloadPolicy> entry : policies.entrySet() )
|
||||||
{
|
{
|
||||||
String key = entry.getKey();
|
// olamy with spring rolehint is now downloadPolicy#hint
|
||||||
|
// so substring after last # to get the hint as with plexus
|
||||||
|
String key = StringUtils.substringAfterLast( entry.getKey(), "#" );
|
||||||
DownloadPolicy policy = entry.getValue();
|
DownloadPolicy policy = entry.getValue();
|
||||||
String defaultSetting = policy.getDefaultOption();
|
String defaultSetting = policy.getDefaultOption();
|
||||||
|
|
||||||
String setting = StringUtils.defaultString( settings.get( key ), defaultSetting );
|
String setting = StringUtils.defaultString( settings.get( key ), defaultSetting );
|
||||||
|
|
||||||
log.debug( "Applying [{}] policy with [{}]", key, setting );
|
log.debug( "Applying [{}] policy with [{}]", key, setting );
|
||||||
|
|
|
@ -610,18 +610,33 @@ public abstract class AbstractProxyTestCase
|
||||||
|
|
||||||
protected void setManagedNewerThanRemote( File managedFile, File remoteFile )
|
protected void setManagedNewerThanRemote( File managedFile, File remoteFile )
|
||||||
{
|
{
|
||||||
assertTrue( "Managed File should exist: ", managedFile.exists() );
|
setManagedNewerThanRemote(managedFile, remoteFile, 55000);
|
||||||
assertTrue( "Remote File should exist: ", remoteFile.exists() );
|
|
||||||
|
|
||||||
managedFile.setLastModified( remoteFile.lastModified() + 55000 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setManagedOlderThanRemote( File managedFile, File remoteFile )
|
protected void setManagedNewerThanRemote( File managedFile, File remoteFile, long time )
|
||||||
{
|
{
|
||||||
assertTrue( "Managed File should exist: ", managedFile.exists() );
|
assertTrue( "Managed File should exist: ", managedFile.exists() );
|
||||||
assertTrue( "Remote File should exist: ", remoteFile.exists() );
|
assertTrue( "Remote File should exist: ", remoteFile.exists() );
|
||||||
|
|
||||||
managedFile.setLastModified( remoteFile.lastModified() - 55000 );
|
managedFile.setLastModified( remoteFile.lastModified() + time );
|
||||||
|
|
||||||
|
assertTrue( managedFile.lastModified() > remoteFile.lastModified() );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setManagedOlderThanRemote( File managedFile, File remoteFile )
|
||||||
|
{
|
||||||
|
setManagedOlderThanRemote(managedFile, remoteFile, 55000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setManagedOlderThanRemote( File managedFile, File remoteFile, long time )
|
||||||
|
{
|
||||||
|
assertTrue( "Managed File should exist: ", managedFile.exists() );
|
||||||
|
assertTrue( "Remote File should exist: ", remoteFile.exists() );
|
||||||
|
|
||||||
|
managedFile.setLastModified( remoteFile.lastModified() - time );
|
||||||
|
|
||||||
|
assertTrue( managedFile.lastModified() < remoteFile.lastModified() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertNotModified( File file, long expectedModificationTime )
|
protected void assertNotModified( File file, long expectedModificationTime )
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.Configuration;
|
import org.apache.maven.archiva.configuration.Configuration;
|
||||||
import org.apache.maven.archiva.configuration.ConfigurationListener;
|
import org.apache.maven.archiva.configuration.ConfigurationListener;
|
||||||
import org.apache.maven.archiva.configuration.FileType;
|
import org.apache.maven.archiva.configuration.FileType;
|
||||||
|
import org.apache.maven.archiva.configuration.FileTypes;
|
||||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
|
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
|
||||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||||
|
@ -75,12 +76,16 @@ public class MockConfiguration
|
||||||
public void initialize()
|
public void initialize()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
configuration.setRepositoryScanning( new RepositoryScanningConfiguration()
|
configuration.setRepositoryScanning( new RepositoryScanningConfiguration()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public List<FileType> getFileTypes()
|
public List<FileType> getFileTypes()
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
FileType fileType = new FileType();
|
||||||
|
fileType.setId( FileTypes.ARTIFACTS );
|
||||||
|
fileType.setPatterns( Collections.singletonList( "**/*" ) );
|
||||||
|
return Collections.singletonList( fileType );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ public class SnapshotTransferTest
|
||||||
File expectedFile = new File( managedDefaultDir, path );
|
File expectedFile = new File( managedDefaultDir, path );
|
||||||
File remoteFile = new File( REPOPATH_PROXIED1, path );
|
File remoteFile = new File( REPOPATH_PROXIED1, path );
|
||||||
|
|
||||||
setManagedNewerThanRemote( expectedFile, remoteFile );
|
setManagedNewerThanRemote( expectedFile, remoteFile, 12000000 );
|
||||||
long expectedTimestamp = expectedFile.lastModified();
|
long expectedTimestamp = expectedFile.lastModified();
|
||||||
|
|
||||||
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
|
||||||
|
|
|
@ -34,6 +34,10 @@
|
||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>metadata-repository-api</artifactId>
|
<artifactId>metadata-repository-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-lang</groupId>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>metadata-repository-api</artifactId>
|
<artifactId>metadata-repository-api</artifactId>
|
||||||
|
|
|
@ -39,17 +39,6 @@ import org.apache.jackrabbit.commons.JcrUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import javax.jcr.NamespaceRegistry;
|
import javax.jcr.NamespaceRegistry;
|
||||||
import javax.jcr.Node;
|
import javax.jcr.Node;
|
||||||
import javax.jcr.NodeIterator;
|
import javax.jcr.NodeIterator;
|
||||||
|
@ -65,6 +54,17 @@ import javax.jcr.nodetype.NodeTypeManager;
|
||||||
import javax.jcr.nodetype.NodeTypeTemplate;
|
import javax.jcr.nodetype.NodeTypeTemplate;
|
||||||
import javax.jcr.query.Query;
|
import javax.jcr.query.Query;
|
||||||
import javax.jcr.query.QueryResult;
|
import javax.jcr.query.QueryResult;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo below: revise storage format for project version metadata
|
* @todo below: revise storage format for project version metadata
|
||||||
|
@ -89,7 +89,7 @@ public class JcrMetadataRepository
|
||||||
|
|
||||||
private final Map<String, MetadataFacetFactory> metadataFacetFactories;
|
private final Map<String, MetadataFacetFactory> metadataFacetFactories;
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger( JcrMetadataRepository.class );
|
private Logger log = LoggerFactory.getLogger( JcrMetadataRepository.class );
|
||||||
|
|
||||||
private Repository repository;
|
private Repository repository;
|
||||||
|
|
||||||
|
@ -856,7 +856,7 @@ public class JcrMetadataRepository
|
||||||
MetadataFacetFactory factory = metadataFacetFactories.get( name );
|
MetadataFacetFactory factory = metadataFacetFactories.get( name );
|
||||||
if ( factory == null )
|
if ( factory == null )
|
||||||
{
|
{
|
||||||
log.error( "Attempted to load unknown project version metadata facet: " + name );
|
log.error( "Attempted to load unknown project version metadata facet: {}", name );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.archiva.metadata.repository.MetadataRepository;
|
||||||
import org.apache.archiva.metadata.repository.MetadataResolver;
|
import org.apache.archiva.metadata.repository.MetadataResolver;
|
||||||
import org.apache.archiva.metadata.repository.RepositorySession;
|
import org.apache.archiva.metadata.repository.RepositorySession;
|
||||||
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
|
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ import javax.annotation.PostConstruct;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.jcr.Repository;
|
import javax.jcr.Repository;
|
||||||
import javax.jcr.RepositoryException;
|
import javax.jcr.RepositoryException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,6 +87,18 @@ public class JcrRepositorySessionFactory
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
metadataFacetFactories = applicationContext.getBeansOfType( MetadataFacetFactory.class );
|
metadataFacetFactories = applicationContext.getBeansOfType( MetadataFacetFactory.class );
|
||||||
|
// olamy with spring the "id" is now "metadataFacetFactory#hint"
|
||||||
|
// whereas was only hint with plexus so let remove metadataFacetFactory#
|
||||||
|
Map<String, MetadataFacetFactory> cleanedMetadataFacetFactories =
|
||||||
|
new HashMap<String, MetadataFacetFactory>( metadataFacetFactories.size() );
|
||||||
|
|
||||||
|
for ( Map.Entry<String, MetadataFacetFactory> entry : metadataFacetFactories.entrySet() )
|
||||||
|
{
|
||||||
|
cleanedMetadataFacetFactories.put( StringUtils.substringAfterLast( entry.getKey(), "#" ),
|
||||||
|
entry.getValue() );
|
||||||
|
}
|
||||||
|
|
||||||
|
metadataFacetFactories = cleanedMetadataFacetFactories;
|
||||||
|
|
||||||
JcrMetadataRepository metadataRepository = null;
|
JcrMetadataRepository metadataRepository = null;
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue