aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-reporting
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2007-09-12 09:33:41 +0000
committerBrett Porter <brett@apache.org>2007-09-12 09:33:41 +0000
commit17f229020f24ab34c553ef619f11834ae6882b21 (patch)
tree1867c4e8f537fe2f7cb05c129aa75b728ae035e5 /archiva-reporting
parentb8cca284caff8744badd9db482f6db163b6e0a18 (diff)
downloadarchiva-17f229020f24ab34c553ef619f11834ae6882b21.tar.gz
archiva-17f229020f24ab34c553ef619f11834ae6882b21.zip
[MRM-462] separate configuration of managed and remote repositories
Merged from branches/MRM-462 git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@574859 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-reporting')
-rw-r--r--archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java64
-rw-r--r--archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReportTest.java30
2 files changed, 41 insertions, 53 deletions
diff --git a/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java b/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java
index 5a17dc2ff..f461baf46 100644
--- a/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java
+++ b/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java
@@ -23,7 +23,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
import org.apache.maven.archiva.configuration.FileTypes;
-import org.apache.maven.archiva.configuration.RepositoryConfiguration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
import org.apache.maven.archiva.consumers.ArchivaArtifactConsumer;
import org.apache.maven.archiva.consumers.ConsumerException;
@@ -48,10 +48,8 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -62,9 +60,8 @@ import java.util.jar.JarFile;
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
- *
* @plexus.component role="org.apache.maven.archiva.consumers.ArchivaArtifactConsumer"
- * role-hint="validate-artifacts-location"
+ * role-hint="validate-artifacts-location"
*/
public class LocationArtifactsConsumer
extends AbstractMonitoredConsumer
@@ -84,7 +81,7 @@ public class LocationArtifactsConsumer
* @plexus.requirement
*/
private ArchivaConfiguration configuration;
-
+
/**
* @plexus.requirement
*/
@@ -146,11 +143,6 @@ public class LocationArtifactsConsumer
throws ConsumerException
{
ArchivaRepository repository = findRepository( artifact );
- if ( !repository.isManaged() )
- {
- getLogger().warn( "Artifact Location Validation Cannot operate against a non-managed Repository." );
- return;
- }
File artifactFile = new File( repository.getUrl().toString(), toPath( artifact ) );
ArchivaProjectModel fsModel = readFilesystemModel( artifactFile );
@@ -167,23 +159,23 @@ public class LocationArtifactsConsumer
{
if ( !StringUtils.equals( model.getGroupId(), artifact.getGroupId() ) )
{
- addProblem( artifact, "The groupId of the " + location
- + " project model doesn't match with the artifact, expected <" + artifact.getGroupId()
- + ">, but was actually <" + model.getGroupId() + ">" );
+ addProblem( artifact, "The groupId of the " + location +
+ " project model doesn't match with the artifact, expected <" + artifact.getGroupId() +
+ ">, but was actually <" + model.getGroupId() + ">" );
}
-
+
if ( !StringUtils.equals( model.getArtifactId(), artifact.getArtifactId() ) )
{
- addProblem( artifact, "The artifactId of the " + location
- + " project model doesn't match with the artifact, expected <" + artifact.getArtifactId()
- + ">, but was actually <" + model.getArtifactId() + ">" );
+ addProblem( artifact, "The artifactId of the " + location +
+ " project model doesn't match with the artifact, expected <" + artifact.getArtifactId() +
+ ">, but was actually <" + model.getArtifactId() + ">" );
}
-
+
if ( !StringUtils.equals( model.getVersion(), artifact.getVersion() ) )
{
- addProblem( artifact, "The version of the " + location
- + " project model doesn't match with the artifact, expected <" + artifact.getVersion()
- + ">, but was actually <" + model.getVersion() + ">" );
+ addProblem( artifact, "The version of the " + location +
+ " project model doesn't match with the artifact, expected <" + artifact.getVersion() +
+ ">, but was actually <" + model.getVersion() + ">" );
}
}
}
@@ -196,18 +188,18 @@ public class LocationArtifactsConsumer
JarFile jar = new JarFile( artifactFile );
// Get the entry and its input stream.
- JarEntry expectedEntry = jar.getJarEntry( "META-INF/maven/" + artifact.getGroupId() + "/"
- + artifact.getArtifactId() + "/pom.xml" );
+ JarEntry expectedEntry = jar.getJarEntry(
+ "META-INF/maven/" + artifact.getGroupId() + "/" + artifact.getArtifactId() + "/pom.xml" );
if ( expectedEntry != null )
{
// TODO: read and resolve model here.
return null;
}
-
+
/* Expected Entry not found, look for alternate that might
- * indicate that the artifact is, indeed located in the wrong place.
- */
+ * indicate that the artifact is, indeed located in the wrong place.
+ */
List actualPomXmls = findJarEntryPattern( jar, "META-INF/maven/**/pom.xml" );
if ( actualPomXmls.isEmpty() )
@@ -215,7 +207,7 @@ public class LocationArtifactsConsumer
// No check needed.
}
-
+
// TODO: test for invalid actual pom.xml
// TODO: test
}
@@ -276,7 +268,7 @@ public class LocationArtifactsConsumer
File pomFile = createPomFileReference( artifactFile );
// TODO: read and resolve model here.
-
+
return null;
}
@@ -316,7 +308,7 @@ public class LocationArtifactsConsumer
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
{
- if ( ConfigurationNames.isRepositories( propertyName ) )
+ if ( ConfigurationNames.isManagedRepositories( propertyName ) )
{
initRepositoryMap();
}
@@ -345,14 +337,12 @@ public class LocationArtifactsConsumer
{
this.repositoryMap.clear();
- Iterator it = configuration.getConfiguration().createRepositoryMap().entrySet().iterator();
- while ( it.hasNext() )
+ Map<String, ManagedRepositoryConfiguration> map =
+ configuration.getConfiguration().getManagedRepositoriesAsMap();
+ for ( Map.Entry<String, ManagedRepositoryConfiguration> entry : map.entrySet() )
{
- Map.Entry entry = (Entry) it.next();
- String key = (String) entry.getKey();
- RepositoryConfiguration repoConfig = (RepositoryConfiguration) entry.getValue();
- ArchivaRepository repository = ArchivaConfigurationAdaptor.toArchivaRepository( repoConfig );
- this.repositoryMap.put( key, repository );
+ ArchivaRepository repository = ArchivaConfigurationAdaptor.toArchivaRepository( entry.getValue() );
+ this.repositoryMap.put( entry.getKey(), repository );
}
}
}
diff --git a/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReportTest.java b/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReportTest.java
index d899de562..4d0f244c2 100644
--- a/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReportTest.java
+++ b/archiva-reporting/archiva-artifact-reports/src/test/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReportTest.java
@@ -20,9 +20,8 @@ package org.apache.maven.archiva.reporting.artifact;
*/
import org.apache.commons.io.FileUtils;
-import org.apache.maven.archiva.common.utils.PathUtil;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.RepositoryConfiguration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.consumers.ArchivaArtifactConsumer;
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.model.ArchivaArtifact;
@@ -35,7 +34,7 @@ import java.util.Iterator;
import java.util.List;
/**
- * DuplicateArtifactReportTest
+ * DuplicateArtifactReportTest
*
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
* @version $Id$
@@ -62,19 +61,19 @@ public class DuplicateArtifactReportTest
ArchivaConfiguration config = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "default" );
- RepositoryConfiguration repoConfig = new RepositoryConfiguration();
+ ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
repoConfig.setId( TESTABLE_REPO );
repoConfig.setLayout( "default" );
File testRepoDir = new File( getBasedir(), "target/test-repository" );
FileUtils.forceMkdir( testRepoDir );
- repoConfig.setUrl( PathUtil.toUrl( testRepoDir ) );
- config.getConfiguration().addRepository( repoConfig );
+ repoConfig.setLocation( testRepoDir.getAbsolutePath() );
+ config.getConfiguration().addManagedRepository( repoConfig );
}
public ArchivaArtifact createArtifact( String artifactId, String version )
{
- ArchivaArtifact artifact = artifactDao.createArtifact( "org.apache.maven.archiva.test", artifactId, version,
- "", "jar" );
+ ArchivaArtifact artifact =
+ artifactDao.createArtifact( "org.apache.maven.archiva.test", artifactId, version, "", "jar" );
artifact.getModel().setLastModified( new Date() );
artifact.getModel().setRepositoryId( TESTABLE_REPO );
return artifact;
@@ -120,8 +119,8 @@ public class DuplicateArtifactReportTest
List allArtifacts = artifactDao.queryArtifacts( null );
assertEquals( "Total Artifact Count", 7, allArtifacts.size() );
- DuplicateArtifactReport report = (DuplicateArtifactReport) lookup( DynamicReportSource.class.getName(),
- "duplicate-artifacts" );
+ DuplicateArtifactReport report =
+ (DuplicateArtifactReport) lookup( DynamicReportSource.class.getName(), "duplicate-artifacts" );
List results = report.getData();
@@ -137,10 +136,9 @@ public class DuplicateArtifactReportTest
int hash1Count = 4;
int hash2Count = 2;
int hash3Count = 1;
-
- int totals = ( ( hash1Count * hash1Count ) - hash1Count ) +
- ( ( hash2Count * hash2Count ) - hash2Count ) +
- ( ( hash3Count * hash3Count ) - hash3Count );
+
+ int totals = ( ( hash1Count * hash1Count ) - hash1Count ) + ( ( hash2Count * hash2Count ) - hash2Count ) +
+ ( ( hash3Count * hash3Count ) - hash3Count );
assertEquals( "Total report hits.", totals, results.size() );
}
@@ -148,8 +146,8 @@ public class DuplicateArtifactReportTest
throws Exception
{
List artifacts = dao.getArtifactDAO().queryArtifacts( null );
- ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) lookup( ArchivaArtifactConsumer.class.getName(),
- "duplicate-artifacts" );
+ ArchivaArtifactConsumer consumer =
+ (ArchivaArtifactConsumer) lookup( ArchivaArtifactConsumer.class.getName(), "duplicate-artifacts" );
consumer.beginScan();
try
{