summaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-06-01 13:07:26 +0000
committerOlivier Lamy <olamy@apache.org>2011-06-01 13:07:26 +0000
commitee78778213ac20a0ce8ea8ad66e3dc5b447c059f (patch)
tree9820ca4cc960359a3d4112efbe73d045946eee3f /archiva-modules
parentaaebb5d534e722c8e188848cce37683915ae5a38 (diff)
downloadarchiva-ee78778213ac20a0ce8ea8ad66e3dc5b447c059f.tar.gz
archiva-ee78778213ac20a0ce8ea8ad66e3dc5b447c059f.zip
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
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java9
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java19
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MockConfiguration.java7
-rw-r--r--archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java2
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/pom.xml4
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java26
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java14
7 files changed, 61 insertions, 20 deletions
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
index 6e9861dc5..094ec86a2 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/main/java/org/apache/maven/archiva/proxy/DefaultRepositoryProxyConnectors.java
@@ -103,14 +103,14 @@ public class DefaultRepositoryProxyConnectors
* plexus.requirement
*/
@Inject
- @Named(value = "repositoryContentFactory#default")
+ @Named( value = "repositoryContentFactory#default" )
private RepositoryContentFactory repositoryFactory;
/**
* plexus.requirement
*/
@Inject
- @Named(value="metadataTools#default")
+ @Named( value = "metadataTools#default" )
private MetadataTools metadataTools;
@Inject
@@ -890,9 +890,12 @@ public class DefaultRepositoryProxyConnectors
{
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();
String defaultSetting = policy.getDefaultOption();
+
String setting = StringUtils.defaultString( settings.get( key ), defaultSetting );
log.debug( "Applying [{}] policy with [{}]", key, setting );
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
index 09815b4c4..4ab400a34 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/AbstractProxyTestCase.java
@@ -610,18 +610,33 @@ public abstract class AbstractProxyTestCase
protected void setManagedNewerThanRemote( File managedFile, File remoteFile )
{
+ setManagedNewerThanRemote(managedFile, remoteFile, 55000);
+ }
+
+ protected void setManagedNewerThanRemote( File managedFile, File remoteFile, long time )
+ {
assertTrue( "Managed File should exist: ", managedFile.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() - 55000 );
+ managedFile.setLastModified( remoteFile.lastModified() - time );
+
+ assertTrue( managedFile.lastModified() < remoteFile.lastModified() );
+
}
protected void assertNotModified( File file, long expectedModificationTime )
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MockConfiguration.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MockConfiguration.java
index 9a6e78380..f116e14c5 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MockConfiguration.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MockConfiguration.java
@@ -23,6 +23,7 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ConfigurationListener;
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.RepositoryScanningConfiguration;
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
@@ -75,12 +76,16 @@ public class MockConfiguration
public void initialize()
throws Exception
{
+
configuration.setRepositoryScanning( new RepositoryScanningConfiguration()
{
@Override
public List<FileType> getFileTypes()
{
- return Collections.emptyList();
+ FileType fileType = new FileType();
+ fileType.setId( FileTypes.ARTIFACTS );
+ fileType.setPatterns( Collections.singletonList( "**/*" ) );
+ return Collections.singletonList( fileType );
}
} );
}
diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java
index 0e87f8fbd..f1998971d 100644
--- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java
+++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/SnapshotTransferTest.java
@@ -229,7 +229,7 @@ public class SnapshotTransferTest
File expectedFile = new File( managedDefaultDir, path );
File remoteFile = new File( REPOPATH_PROXIED1, path );
- setManagedNewerThanRemote( expectedFile, remoteFile );
+ setManagedNewerThanRemote( expectedFile, remoteFile, 12000000 );
long expectedTimestamp = expectedFile.lastModified();
ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path );
diff --git a/archiva-modules/plugins/metadata-store-jcr/pom.xml b/archiva-modules/plugins/metadata-store-jcr/pom.xml
index 60bb6752b..f501ca131 100644
--- a/archiva-modules/plugins/metadata-store-jcr/pom.xml
+++ b/archiva-modules/plugins/metadata-store-jcr/pom.xml
@@ -35,6 +35,10 @@
<artifactId>metadata-repository-api</artifactId>
</dependency>
<dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-repository-api</artifactId>
<classifier>tests</classifier>
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
index 449703437..11722351d 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
@@ -39,17 +39,6 @@ import org.apache.jackrabbit.commons.JcrUtils;
import org.slf4j.Logger;
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.Node;
import javax.jcr.NodeIterator;
@@ -65,6 +54,17 @@ import javax.jcr.nodetype.NodeTypeManager;
import javax.jcr.nodetype.NodeTypeTemplate;
import javax.jcr.query.Query;
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
@@ -89,7 +89,7 @@ public class JcrMetadataRepository
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;
@@ -856,7 +856,7 @@ public class JcrMetadataRepository
MetadataFacetFactory factory = metadataFacetFactories.get( name );
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
{
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java
index 2710ce2b2..cf12d0af6 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrRepositorySessionFactory.java
@@ -24,6 +24,7 @@ import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataResolver;
import org.apache.archiva.metadata.repository.RepositorySession;
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
+import org.apache.commons.lang.StringUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
@@ -31,6 +32,7 @@ import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
+import java.util.HashMap;
import java.util.Map;
/**
@@ -85,6 +87,18 @@ public class JcrRepositorySessionFactory
public void initialize()
{
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;
try