* limitations under the License.
*/
+import org.apache.maven.archiva.reporting.ReportGroup;
import org.apache.maven.archiva.reporting.ReportingDatabase;
import org.apache.maven.archiva.reporting.model.ArtifactResults;
import org.apache.maven.archiva.reporting.model.Result;
private ArtifactFactory artifactFactory;
- private ReportingDatabase reporter;
+ private ReportingDatabase reportingDatabase;
private static final int SLEEP_MILLIS = 100;
i18n = (I18N) lookup( I18N.ROLE );
- reporter = new ReportingDatabase();
+ ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
+ reportingDatabase = new ReportingDatabase( reportGroup );
}
private void copyDirectoryStructure( File sourceDirectory, File destinationDirectory )
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
artifactFile.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkSuccess();
assertTrue( "Check artifact created", artifactFile.exists() );
targetRepository.pathOfRemoteRepositoryMetadata( versionMetadata ) );
versionMetadataFile.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkSuccess();
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
targetRepository.pathOfRemoteRepositoryMetadata( versionMetadata ) );
versionMetadataFile.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
//checkSuccess(); --> commented until MNG-2100 is fixed
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
targetRepository.pathOfRemoteRepositoryMetadata( versionMetadata ) );
versionMetadataFile.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
- assertEquals( "check no errors", 0, reporter.getNumFailures() );
- assertEquals( "check number of warnings", 2, reporter.getNumWarnings() );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
+ assertEquals( "check no errors", 0, reportingDatabase.getNumFailures() );
+ assertEquals( "check number of warnings", 2, reportingDatabase.getNumWarnings() );
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
assertTrue( "Check artifact created", artifactFile.exists() );
targetRepository.pathOfRemoteRepositoryMetadata( snapshotMetadata ) );
snapshotMetadataFile.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkSuccess();
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
targetRepository.pathOfRemoteRepositoryMetadata( snapshotMetadata ) );
snapshotMetadataFile.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkSuccess();
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
targetRepository.pathOfRemoteRepositoryMetadata( snapshotMetadata ) );
snapshotMetadataFile.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkSuccess();
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
// test that a POM is not created when there was none at the source
Artifact artifact = createArtifact( "test", "noPomArtifact", "1.0.0" );
- repositoryConverter.convert( artifact, targetRepository, reporter );
- assertEquals( "check no errors", 0, reporter.getNumFailures() );
- assertEquals( "check no warnings", 1, reporter.getNumWarnings() );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
+ assertEquals( "check no errors", 0, reportingDatabase.getNumFailures() );
+ assertEquals( "check no warnings", 1, reportingDatabase.getNumWarnings() );
assertEquals( "check warning message", getI18nString( "warning.missing.pom" ), getWarning().getReason() );
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
file.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkFailure();
assertEquals( "check failure message", getI18nString( "failure.incorrect.md5" ), getFailure().getReason() );
File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
file.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkFailure();
assertEquals( "check failure message", getI18nString( "failure.incorrect.sha1" ), getFailure().getReason() );
// Need to guarantee last modified is not equal
Thread.sleep( SLEEP_MILLIS );
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkSuccess();
compareFiles( sourceFile, targetFile );
// Need to guarantee last modified is not equal
Thread.sleep( SLEEP_MILLIS );
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkFailure();
assertEquals( "Check failure message", getI18nString( "failure.target.already.exists" ),
getFailure().getReason() );
sourceFile.setLastModified( dateFormat.parse( "2006-01-01" ).getTime() );
sourcePomFile.setLastModified( dateFormat.parse( "2006-02-02" ).getTime() );
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkSuccess();
compareFiles( sourceFile, targetFile );
File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) );
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkSuccess();
assertTrue( "Check source file exists", sourceFile.exists() );
// Need to guarantee last modified is not equal
Thread.sleep( SLEEP_MILLIS );
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkFailure();
assertEquals( "Check failure message", getI18nString( "failure.target.already.exists" ),
getFailure().getReason() );
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkFailure();
String pattern = "^" + getI18nString( "failure.invalid.source.pom" ).replaceFirst( "\\{0\\}", ".*" ) + "$";
assertTrue( "Check failure message", getFailure().getReason().matches( pattern ) );
artifacts.add( createArtifact( "test", "artifact-one", "1.0.0" ) );
artifacts.add( createArtifact( "test", "artifact-two", "1.0.0" ) );
artifacts.add( createArtifact( "test", "artifact-three", "1.0.0" ) );
- repositoryConverter.convert( artifacts, targetRepository, reporter );
- assertEquals( "check no errors", 0, reporter.getNumFailures() );
- assertEquals( "check no warnings", 0, reporter.getNumWarnings() );
+ repositoryConverter.convert( artifacts, targetRepository, reportingDatabase );
+ assertEquals( "check no errors", 0, reportingDatabase.getNumFailures() );
+ assertEquals( "check no warnings", 0, reportingDatabase.getNumWarnings() );
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
{
File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
file.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkFailure();
assertEquals( "check failure message", getI18nString( "failure.incorrect.artifactMetadata.versions" ),
getFailure().getReason() );
File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
file.delete();
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkFailure();
assertEquals( "check failure message", getI18nString( "failure.incorrect.snapshotMetadata.snapshot" ),
getFailure().getReason() );
Artifact artifact = createArtifact( "test", "newversion-artifact", "1.0.1" );
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
checkSuccess();
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
try
{
- repositoryConverter.convert( artifact, targetRepository, reporter );
+ repositoryConverter.convert( artifact, targetRepository, reportingDatabase );
fail( "Should have failed trying to convert within the same repository" );
}
catch ( RepositoryConversionException e )
private void checkSuccess()
{
- assertEquals( "check no errors", 0, reporter.getNumFailures() );
- assertEquals( "check no warnings", 0, reporter.getNumWarnings() );
+ assertEquals( "check no errors", 0, reportingDatabase.getNumFailures() );
+ assertEquals( "check no warnings", 0, reportingDatabase.getNumWarnings() );
}
private void checkFailure()
{
- assertEquals( "check num errors", 1, reporter.getNumFailures() );
- assertEquals( "check no warnings", 0, reporter.getNumWarnings() );
+ assertEquals( "check num errors", 1, reportingDatabase.getNumFailures() );
+ assertEquals( "check no warnings", 0, reportingDatabase.getNumWarnings() );
}
private String getI18nString( String key )
private Result getFailure()
{
- ArtifactResults artifact = (ArtifactResults) reporter.getArtifactIterator().next();
+ ArtifactResults artifact = (ArtifactResults) reportingDatabase.getArtifactIterator().next();
return (Result) artifact.getFailures().get( 0 );
}
private Result getWarning()
{
- ArtifactResults artifact = (ArtifactResults) reporter.getArtifactIterator().next();
+ ArtifactResults artifact = (ArtifactResults) reportingDatabase.getArtifactIterator().next();
return (Result) artifact.getWarnings().get( 0 );
}
import org.apache.maven.archiva.discoverer.DiscovererException;
import org.apache.maven.archiva.discoverer.filter.AcceptAllArtifactFilter;
import org.apache.maven.archiva.discoverer.filter.SnapshotArtifactFilter;
+import org.apache.maven.archiva.reporting.ReportGroup;
import org.apache.maven.archiva.reporting.ReportingDatabase;
import org.apache.maven.archiva.reporting.ReportingStore;
import org.apache.maven.archiva.reporting.ReportingStoreException;
*/
private ReportingStore reportingStore;
+ /**
+ * @plexus.requirement role-hint="health"
+ */
+ private ReportGroup reportGroup;
+
public void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory,
boolean includeSnapshots )
throws RepositoryConversionException, DiscovererException
ReportingDatabase reporter;
try
{
- reporter = reportingStore.getReportsFromStore( repository );
+ reporter = reportingStore.getReportsFromStore( repository, reportGroup );
repositoryConverter.convert( legacyArtifacts, repository, reporter );
import org.apache.maven.archiva.indexer.record.IndexRecordExistsArtifactFilter;
import org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory;
import org.apache.maven.archiva.reporting.ReportExecutor;
+import org.apache.maven.archiva.reporting.ReportGroup;
import org.apache.maven.archiva.reporting.ReportingDatabase;
import org.apache.maven.archiva.reporting.ReportingMetadataFilter;
import org.apache.maven.archiva.reporting.ReportingStoreException;
*/
private ReportExecutor reportExecutor;
+ /**
+ * @plexus.requirement role-hint="health"
+ */
+ private ReportGroup reportGroup;
+
private static final int ARTIFACT_BUFFER_SIZE = 1000;
public void execute()
boolean includeSnapshots = repositoryConfiguration.isIncludeSnapshots();
ArtifactRepository repository = repoFactory.createRepository( repositoryConfiguration );
- ReportingDatabase reporter = reportExecutor.getReportDatabase( repository );
+ ReportingDatabase reporter = reportExecutor.getReportDatabase( repository, reportGroup );
// keep original value in case there is another process under way
long origStartTime = reporter.getStartTime();
// run the reports. Done intermittently to avoid losing track of what is indexed since
// that is what the filter is based on.
- reportExecutor.runArtifactReports( currentArtifacts, repository );
+ reportExecutor.runArtifactReports( reportGroup, currentArtifacts, repository );
index.indexArtifacts( currentArtifacts, recordFactory );
getLogger().info( "Discovered " + metadata.size() + " unprocessed metadata files" );
// run the reports
- reportExecutor.runMetadataReports( metadata, repository );
+ reportExecutor.runMetadataReports( reportGroup, metadata, repository );
}
reporter.setStartTime( origStartTime );
--- /dev/null
+package org.apache.maven.archiva.reporting;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
+import org.apache.maven.model.Model;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Basic functionality for all report groups.
+ */
+public abstract class AbstractReportGroup
+ implements ReportGroup
+{
+ /**
+ * @plexus.requirement role="org.apache.maven.archiva.reporting.ArtifactReportProcessor"
+ */
+ private Map artifactReports;
+
+ /**
+ * @plexus.requirement role="org.apache.maven.archiva.reporting.MetadataReportProcessor"
+ */
+ private Map metadataReports;
+
+ public void processArtifact( Artifact artifact, Model model, ReportingDatabase reportingDatabase )
+ {
+ for ( Iterator i = artifactReports.entrySet().iterator(); i.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+
+ if ( includeReport( (String) entry.getKey() ) )
+ {
+ ArtifactReportProcessor report = (ArtifactReportProcessor) entry.getValue();
+
+ report.processArtifact( artifact, model, reportingDatabase );
+ }
+ }
+ }
+
+ public void processMetadata( RepositoryMetadata repositoryMetadata, ArtifactRepository repository,
+ ReportingDatabase reportingDatabase )
+ {
+ for ( Iterator i = metadataReports.entrySet().iterator(); i.hasNext(); )
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+
+ if ( includeReport( (String) entry.getKey() ) )
+ {
+ MetadataReportProcessor report = (MetadataReportProcessor) entry.getValue();
+
+ report.processMetadata( repositoryMetadata, repository, reportingDatabase );
+ }
+ }
+ }
+
+ public String toString()
+ {
+ return getName();
+ }
+}
/**
* Report executor implementation.
*
+ * @todo should the report set be limitable by configuration?
* @plexus.component
*/
public class DefaultReportExecutor
*/
private ArtifactFactory artifactFactory;
- /**
- * @todo replace with a ReportGroup that is identified as "health" and has requirements on the specific health reports
- * @plexus.requirement role="org.apache.maven.archiva.reporting.ArtifactReportProcessor"
- */
- private List artifactReports;
-
- /**
- * @plexus.requirement role="org.apache.maven.archiva.reporting.MetadataReportProcessor"
- */
- private List metadataReports;
-
/**
* @plexus.requirement role="org.apache.maven.archiva.discoverer.ArtifactDiscoverer"
*/
private static final int ARTIFACT_BUFFER_SIZE = 1000;
- public void runMetadataReports( List metadata, ArtifactRepository repository )
+ public void runMetadataReports( ReportGroup reportGroup, List metadata, ArtifactRepository repository )
throws ReportingStoreException
{
- ReportingDatabase reporter = getReportDatabase( repository );
+ ReportingDatabase reporter = getReportDatabase( repository, reportGroup );
for ( Iterator i = metadata.iterator(); i.hasNext(); )
{
new File( repository.getBasedir(), repository.pathOfRemoteRepositoryMetadata( repositoryMetadata ) );
reporter.cleanMetadata( repositoryMetadata, file.lastModified() );
- // TODO: should the report set be limitable by configuration?
- runMetadataReports( repositoryMetadata, repository, reporter );
+ reportGroup.processMetadata( repositoryMetadata, repository, reporter );
}
reportingStore.storeReports( reporter, repository );
}
- private void runMetadataReports( RepositoryMetadata repositoryMetadata, ArtifactRepository repository,
- ReportingDatabase reporter )
- {
- for ( Iterator i = metadataReports.iterator(); i.hasNext(); )
- {
- MetadataReportProcessor report = (MetadataReportProcessor) i.next();
-
- report.processMetadata( repositoryMetadata, repository, reporter );
- }
- }
-
- public void runArtifactReports( List artifacts, ArtifactRepository repository )
+ public void runArtifactReports( ReportGroup reportGroup, List artifacts, ArtifactRepository repository )
throws ReportingStoreException
{
- ReportingDatabase reporter = getReportDatabase( repository );
+ ReportingDatabase reporter = getReportDatabase( repository, reportGroup );
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
{
reporter.removeArtifact( artifact );
- runArtifactReports( artifact, model, reporter );
+ reportGroup.processArtifact( artifact, model, reporter );
}
reportingStore.storeReports( reporter, repository );
}
- public ReportingDatabase getReportDatabase( ArtifactRepository repository )
+ public ReportingDatabase getReportDatabase( ArtifactRepository repository, ReportGroup reportGroup )
throws ReportingStoreException
{
- getLogger().debug( "Reading previous report database from repository " + repository.getId() );
- return reportingStore.getReportsFromStore( repository );
+ getLogger().debug(
+ "Reading previous report database " + reportGroup.getName() + " from repository " + repository.getId() );
+ return reportingStore.getReportsFromStore( repository, reportGroup );
}
- public void runReports( ArtifactRepository repository, List blacklistedPatterns, ArtifactFilter filter )
+ public void runReports( ReportGroup reportGroup, ArtifactRepository repository, List blacklistedPatterns,
+ ArtifactFilter filter )
throws DiscovererException, ReportingStoreException
{
// Flush (as in toilet, not store) the report database
- ReportingDatabase database = getReportDatabase( repository );
+ ReportingDatabase database = getReportDatabase( repository, reportGroup );
database.clear();
// Discovery process
// TODO: proper queueing of this in case it was triggered externally (not harmful to do so at present, but not optimal)
// run the reports.
- runArtifactReports( currentArtifacts, repository );
+ runArtifactReports( reportGroup, currentArtifacts, repository );
// MNG-142 - the project builder retains a lot of objects in its inflexible cache. This is a hack
// around that. TODO: remove when it is configurable
getLogger().info( "Discovered " + metadata.size() + " metadata files" );
// run the reports
- runMetadataReports( metadata, repository );
+ runMetadataReports( reportGroup, metadata, repository );
}
}
}
}
- private void runArtifactReports( Artifact artifact, Model model, ReportingDatabase reporter )
- {
- // TODO: should the report set be limitable by configuration?
- for ( Iterator i = artifactReports.iterator(); i.hasNext(); )
- {
- ArtifactReportProcessor report = (ArtifactReportProcessor) i.next();
-
- report.processArtifact( artifact, model, reporter );
- }
- }
-
private void flushProjectBuilderCacheHack()
{
try
--- /dev/null
+package org.apache.maven.archiva.reporting;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * The default report set, for repository health.
+ *
+ * @plexus.component role="org.apache.maven.archiva.reporting.ReportGroup" role-hint="health"
+ * @todo could these report groups be assembled dynamically by configuration rather than as explicit components? eg, reportGroup.addReport( ARP ), reportGroup.addReport( MRP )
+ */
+public class DefaultReportGroup
+ extends AbstractReportGroup
+{
+ /**
+ * Role hints of the reports to include in this set.
+ *
+ * @todo re-enable duplicate, once a way to populate the index is determined!
+ */
+ private static final Set reports = new LinkedHashSet( Arrays.asList( new String[]{"checksum", "dependency"
+/*, "duplicate"*/, "invalid-pom", "artifact-location", "bad-metadata", "checksum-metadata"} ) );
+
+ public boolean includeReport( String key )
+ {
+ return reports.contains( key );
+ }
+
+ public Collection getReportIds()
+ {
+ return reports;
+ }
+
+ public String getName()
+ {
+ return "Repository Health";
+ }
+
+ public String getFilename()
+ {
+ return "health-report.xml";
+ }
+}
* limitations under the License.
*/
+import org.apache.maven.archiva.reporting.model.Reporting;
import org.apache.maven.archiva.reporting.model.io.xpp3.ReportingXpp3Reader;
import org.apache.maven.archiva.reporting.model.io.xpp3.ReportingXpp3Writer;
import org.apache.maven.artifact.repository.ArtifactRepository;
/**
* The cached reports for given repositories.
*/
- private Map/*<ArtifactRepository,ReportingDatabase>*/ reports = new HashMap();
+ private Map/*<String,ReportingDatabase>*/ reports = new HashMap();
- public ReportingDatabase getReportsFromStore( ArtifactRepository repository )
+ public ReportingDatabase getReportsFromStore( ArtifactRepository repository, ReportGroup reportGroup )
throws ReportingStoreException
{
- ReportingDatabase database = (ReportingDatabase) reports.get( repository );
+ String key = getKey( repository, reportGroup );
+ ReportingDatabase database = (ReportingDatabase) reports.get( key );
if ( database == null )
{
ReportingXpp3Reader reader = new ReportingXpp3Reader();
- File file = getReportFilename( repository, "health" );
+ File file = getReportFilename( repository, reportGroup );
FileReader fileReader = null;
try
}
catch ( FileNotFoundException e )
{
- database = new ReportingDatabase( repository );
+ database = new ReportingDatabase( reportGroup, repository );
}
if ( database == null )
getLogger().info( "Reading report database from " + file );
try
{
- database = new ReportingDatabase( reader.read( fileReader, false ), repository );
+ Reporting reporting = reader.read( fileReader, false );
+ database = new ReportingDatabase( reportGroup, reporting, repository );
}
catch ( IOException e )
{
}
}
- reports.put( repository, database );
+ reports.put( key, database );
}
return database;
}
- private static File getReportFilename( ArtifactRepository repository, String s )
+ private static String getKey( ArtifactRepository repository, ReportGroup reportGroup )
{
- File file = new File( repository.getBasedir(), ".reports/" + s + ".xml" );
- return file;
+ return repository.getId() + "/" + reportGroup.getFilename();
+ }
+
+ private static File getReportFilename( ArtifactRepository repository, ReportGroup reportGroup )
+ {
+ return new File( repository.getBasedir(), ".reports/" + reportGroup.getFilename() );
}
public void storeReports( ReportingDatabase database, ArtifactRepository repository )
ReportingXpp3Writer writer = new ReportingXpp3Writer();
- File file = getReportFilename( repository, "health" );
+ File file = getReportFilename( repository, database.getReportGroup() );
getLogger().info( "Writing reports to " + file );
FileWriter fileWriter = null;
try
public void processArtifact( Artifact artifact, Model model, ReportingDatabase reporter )
{
ArtifactRepository repository = artifact.getRepository();
- // TODO! always null currently, need to configure this properly
- if ( indexDirectory != null )
+ if ( artifact.getFile() != null )
{
- if ( artifact.getFile() != null )
+ RepositoryArtifactIndex index = indexFactory.createStandardIndex( new File( indexDirectory ) );
+
+ String checksum = null;
+ try
+ {
+ checksum = digester.calc( artifact.getFile() );
+ }
+ catch ( DigesterException e )
{
- RepositoryArtifactIndex index = indexFactory.createStandardIndex( new File( indexDirectory ) );
+ reporter.addWarning( artifact, "Unable to generate checksum for " + artifact.getFile() + ": " + e );
+ }
- String checksum = null;
+ if ( checksum != null )
+ {
try
{
- checksum = digester.calc( artifact.getFile() );
- }
- catch ( DigesterException e )
- {
- reporter.addWarning( artifact, "Unable to generate checksum for " + artifact.getFile() + ": " + e );
- }
+ List results = index.search( new LuceneQuery(
+ new TermQuery( new Term( StandardIndexRecordFields.MD5, checksum.toLowerCase() ) ) ) );
- if ( checksum != null )
- {
- try
+ if ( !results.isEmpty() )
{
- List results = index.search( new LuceneQuery(
- new TermQuery( new Term( StandardIndexRecordFields.MD5, checksum.toLowerCase() ) ) ) );
-
- if ( !results.isEmpty() )
+ for ( Iterator i = results.iterator(); i.hasNext(); )
{
- for ( Iterator i = results.iterator(); i.hasNext(); )
- {
- StandardArtifactIndexRecord result = (StandardArtifactIndexRecord) i.next();
+ StandardArtifactIndexRecord result = (StandardArtifactIndexRecord) i.next();
- //make sure it is not the same artifact
- if ( !result.getFilename().equals( repository.pathOf( artifact ) ) )
+ //make sure it is not the same artifact
+ if ( !result.getFilename().equals( repository.pathOf( artifact ) ) )
+ {
+ //report only duplicates from the same groupId
+ String groupId = artifact.getGroupId();
+ if ( groupId.equals( result.getGroupId() ) )
{
- //report only duplicates from the same groupId
- String groupId = artifact.getGroupId();
- if ( groupId.equals( result.getGroupId() ) )
- {
- reporter.addFailure( artifact, "Found duplicate for " + artifact.getId() );
- }
+ reporter.addFailure( artifact, "Found duplicate for " + artifact.getId() );
}
}
}
}
- catch ( RepositoryIndexSearchException e )
- {
- reporter.addWarning( artifact, "Failed to search in index" + e );
- }
+ }
+ catch ( RepositoryIndexSearchException e )
+ {
+ reporter.addWarning( artifact, "Failed to search in index" + e );
}
}
- else
- {
- reporter.addWarning( artifact, "Artifact file is null" );
- }
+ }
+ else
+ {
+ reporter.addWarning( artifact, "Artifact file is null" );
}
}
}
--- /dev/null
+package org.apache.maven.archiva.reporting;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * The report set for finding old artifacts (both snapshot and release)
+ *
+ * @plexus.component role="org.apache.maven.archiva.reporting.ReportGroup" role-hint="old-artifact"
+ */
+public class OldArtifactReportGroup
+ extends AbstractReportGroup
+{
+ /**
+ * Role hints of the reports to include in this set.
+ *
+ * @todo implement these report processors!
+ */
+ private static final Set reports =
+ new LinkedHashSet( Arrays.asList( new String[]{"old-artifact", "old-snapshot-artifact"} ) );
+
+ public boolean includeReport( String key )
+ {
+ return reports.contains( key );
+ }
+
+ public Collection getReportIds()
+ {
+ return reports;
+ }
+
+ public String getFilename()
+ {
+ return "old-artifacts-report.xml";
+ }
+
+ public String getName()
+ {
+ return "Old Artifacts";
+ }
+}
/**
* Run reports on a set of metadata.
*
- * @param metadata the RepositoryMetadata objects to report on
- * @param repository the repository that they come from
+ * @param reportGroup the report set to run
+ * @param metadata the RepositoryMetadata objects to report on
+ * @param repository the repository that they come from
* @throws ReportingStoreException if there is a problem reading/writing the report database
*/
- public void runMetadataReports( List metadata, ArtifactRepository repository )
+ public void runMetadataReports( ReportGroup reportGroup, List metadata, ArtifactRepository repository )
throws ReportingStoreException;
/**
* Run reports on a set of artifacts.
*
- * @param artifacts the Artifact objects to report on
- * @param repository the repository that they come from
+ * @param reportGroup the report set to run
+ * @param artifacts the Artifact objects to report on
+ * @param repository the repository that they come from
* @throws ReportingStoreException if there is a problem reading/writing the report database
*/
- public void runArtifactReports( List artifacts, ArtifactRepository repository )
+ public void runArtifactReports( ReportGroup reportGroup, List artifacts, ArtifactRepository repository )
throws ReportingStoreException;
/**
* Get the report database in use for a given repository.
*
- * @param repository the repository
+ * @param repository the repository
+ * @param reportGroup the report set to run
* @return the report database
* @throws ReportingStoreException if there is a problem reading the report database
*/
- ReportingDatabase getReportDatabase( ArtifactRepository repository )
+ ReportingDatabase getReportDatabase( ArtifactRepository repository, ReportGroup reportGroup )
throws ReportingStoreException;
/**
* @param repository the repository to run from
* @param blacklistedPatterns the patterns to exclude during discovery
* @param filter the filter to use during discovery to get a consistent list of artifacts
+ * @param reportGroup the report set to run
* @throws ReportingStoreException if there is a problem reading/writing the report database
* @throws org.apache.maven.archiva.discoverer.DiscovererException
* if there is a problem finding the artifacts and metadata to report on
*/
- public void runReports( ArtifactRepository repository, List blacklistedPatterns, ArtifactFilter filter )
+ public void runReports( ReportGroup reportGroup, ArtifactRepository repository, List blacklistedPatterns,
+ ArtifactFilter filter )
throws DiscovererException, ReportingStoreException;
}
--- /dev/null
+package org.apache.maven.archiva.reporting;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
+import org.apache.maven.model.Model;
+
+import java.util.Collection;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A grouping or report processors for execution as a visible report from the web interface - eg, "health",
+ * "old artifacts", etc.
+ */
+public interface ReportGroup
+{
+ /**
+ * Plexus component role.
+ */
+ String ROLE = ReportGroup.class.getName();
+
+ /**
+ * Run any artifact related reports in the report set.
+ *
+ * @param artifact the artifact to process
+ * @param model the POM associated with the artifact to process
+ * @param reportingDatabase the report database to store results in
+ */
+ void processArtifact( Artifact artifact, Model model, ReportingDatabase reportingDatabase );
+
+ /**
+ * Run any metadata related reports in the report set.
+ *
+ * @param repositoryMetadata the metadata to process
+ * @param repository the repository the metadata is located in
+ * @param reportingDatabase the report database to store results in
+ */
+ void processMetadata( RepositoryMetadata repositoryMetadata, ArtifactRepository repository,
+ ReportingDatabase reportingDatabase );
+
+ /**
+ * Whether a report with the given role hint is included in this report set.
+ *
+ * @param key the report role hint.
+ * @return whether the report is included
+ */
+ boolean includeReport( String key );
+
+ /**
+ * Get a list of the report processors in this set.
+ *
+ * @return the report IDs
+ */
+ Collection getReportIds();
+
+ /**
+ * Get the user-friendly name of this report.
+ *
+ * @return the report name
+ */
+ String getName();
+
+ /**
+ * Get the filename of the reports within the repository's reports directory.
+ *
+ * @return the filename
+ */
+ String getFilename();
+}
private long startTime;
- public ReportingDatabase()
+ private final ReportGroup reportGroup;
+
+ public ReportingDatabase( ReportGroup reportGroup )
{
- this( new Reporting(), null );
+ this( reportGroup, new Reporting() );
}
- public ReportingDatabase( Reporting reporting )
+ public ReportingDatabase( ReportGroup reportGroup, Reporting reporting )
{
- this( reporting, null );
+ this( reportGroup, reporting, null );
}
- public ReportingDatabase( ArtifactRepository repository )
+ public ReportingDatabase( ReportGroup reportGroup, ArtifactRepository repository )
{
- this( new Reporting(), repository );
+ this( reportGroup, new Reporting(), repository );
}
- public ReportingDatabase( Reporting reporting, ArtifactRepository repository )
+ public ReportingDatabase( ReportGroup reportGroup, Reporting reporting, ArtifactRepository repository )
{
+ this.reportGroup = reportGroup;
+
this.reporting = reporting;
this.repository = repository;
}
getReporting().setLastModified( endTime );
}
+
+ public ReportGroup getReportGroup()
+ {
+ return reportGroup;
+ }
}
/**
* Get the reports from the store. A cached version may be used.
*
- * @param repository the repository to load the reports for
+ * @param repository the repository to load the reports for
+ * @param reportGroup the report group to get the report for
* @return the reporting database
* @throws ReportingStoreException if there was a problem reading the store
*/
- ReportingDatabase getReportsFromStore( ArtifactRepository repository )
+ ReportingDatabase getReportsFromStore( ArtifactRepository repository, ReportGroup reportGroup )
throws ReportingStoreException;
/**
public class ArtifactReporterTest
extends AbstractRepositoryReportsTestCase
{
- private ReportingDatabase reporter;
+ private ReportingDatabase reportingDatabase;
private Artifact artifact;
throws Exception
{
super.setUp();
- reporter = new ReportingDatabase();
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" );
Versioning versioning = new Versioning();
versioning.addVersion( "1.0-alpha-1" );
versioning.setLastUpdated( "20050611.202020" );
+
+ ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
+ reportingDatabase = new ReportingDatabase( reportGroup );
}
public void testArtifactReporterSingleFailure()
{
- reporter.addFailure( artifact, "failed once" );
+ reportingDatabase.addFailure( artifact, "failed once" );
- Iterator artifactIterator = reporter.getArtifactIterator();
+ Iterator artifactIterator = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) artifactIterator.next();
assertFalse( artifactIterator.hasNext() );
i.next();
}
assertEquals( 1, count );
- assertEquals( 1, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ assertEquals( 1, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
}
public void testArtifactReporterMultipleFailure()
{
- reporter.addFailure( artifact, "failed once" );
- reporter.addFailure( artifact, "failed twice" );
- reporter.addFailure( artifact, "failed thrice" );
+ reportingDatabase.addFailure( artifact, "failed once" );
+ reportingDatabase.addFailure( artifact, "failed twice" );
+ reportingDatabase.addFailure( artifact, "failed thrice" );
- Iterator artifactIterator = reporter.getArtifactIterator();
+ Iterator artifactIterator = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) artifactIterator.next();
assertFalse( artifactIterator.hasNext() );
i.next();
}
assertEquals( 3, count );
- assertEquals( 3, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ assertEquals( 3, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
}
public void testFailureMessages()
{
- reporter.addFailure( artifact, "failed once" );
- reporter.addFailure( artifact, "failed twice" );
- reporter.addFailure( artifact, "failed thrice" );
- Iterator artifactIterator = reporter.getArtifactIterator();
+ reportingDatabase.addFailure( artifact, "failed once" );
+ reportingDatabase.addFailure( artifact, "failed twice" );
+ reportingDatabase.addFailure( artifact, "failed thrice" );
+ Iterator artifactIterator = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) artifactIterator.next();
assertFalse( artifactIterator.hasNext() );
Iterator failure = results.getFailures().iterator();
public void testArtifactReporterSingleWarning()
{
- reporter.addWarning( artifact, "you've been warned" );
- Iterator artifactIterator = reporter.getArtifactIterator();
+ reportingDatabase.addWarning( artifact, "you've been warned" );
+ Iterator artifactIterator = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) artifactIterator.next();
assertFalse( artifactIterator.hasNext() );
i.next();
}
assertEquals( 1, count );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 1, reporter.getNumWarnings() );
+ assertEquals( 0, reportingDatabase.getNumFailures() );
+ assertEquals( 1, reportingDatabase.getNumWarnings() );
}
public void testArtifactReporterMultipleWarning()
{
- reporter.addWarning( artifact, "i'm warning you" );
- reporter.addWarning( artifact, "you have to stop now" );
- reporter.addWarning( artifact, "all right... that does it!" );
+ reportingDatabase.addWarning( artifact, "i'm warning you" );
+ reportingDatabase.addWarning( artifact, "you have to stop now" );
+ reportingDatabase.addWarning( artifact, "all right... that does it!" );
- Iterator artifactIterator = reporter.getArtifactIterator();
+ Iterator artifactIterator = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) artifactIterator.next();
assertFalse( artifactIterator.hasNext() );
i.next();
}
assertEquals( 3, count );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 3, reporter.getNumWarnings() );
+ assertEquals( 0, reportingDatabase.getNumFailures() );
+ assertEquals( 3, reportingDatabase.getNumWarnings() );
}
public void testWarningMessages()
{
- reporter.addWarning( artifact, "i'm warning you" );
- reporter.addWarning( artifact, "you have to stop now" );
- reporter.addWarning( artifact, "all right... that does it!" );
+ reportingDatabase.addWarning( artifact, "i'm warning you" );
+ reportingDatabase.addWarning( artifact, "you have to stop now" );
+ reportingDatabase.addWarning( artifact, "all right... that does it!" );
- Iterator artifactIterator = reporter.getArtifactIterator();
+ Iterator artifactIterator = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) artifactIterator.next();
assertFalse( artifactIterator.hasNext() );
Iterator warning = results.getWarnings().iterator();
private MetadataReportProcessor badMetadataReportProcessor;
- private ReportingDatabase reporter = new ReportingDatabase();
+ private ReportingDatabase reportingDatabase;
protected void setUp()
throws Exception
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
badMetadataReportProcessor = (MetadataReportProcessor) lookup( MetadataReportProcessor.ROLE );
+
+ ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
+ reportingDatabase = new ReportingDatabase( reportGroup );
}
public void testMetadataMissingLastUpdated()
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, null );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertFalse( "check there are no failures", failures.hasNext() );
}
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact, versioning );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) );
metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "default2" ) );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertFalse( "check there are no failures", failures.hasNext() );
}
metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "default2" ) );
metadata.getMetadata().addPlugin( createMetadataPlugin( "missing-plugin", "default3" ) );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
RepositoryMetadata metadata = new GroupRepositoryMetadata( "groupId" );
metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
metadata.getMetadata().addPlugin( createMetadataPlugin( null, "default3" ) );
metadata.getMetadata().addPlugin( createMetadataPlugin( "", "default4" ) );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", null ) );
metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "" ) );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
metadata.getMetadata().addPlugin( createMetadataPlugin( "artifactId", "default" ) );
metadata.getMetadata().addPlugin( createMetadataPlugin( "snapshot-artifact", "default" ) );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertFalse( "check there are no failures", failures.hasNext() );
}
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );
- badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+ badMetadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
{
private ArtifactReportProcessor artifactReportProcessor;
- private ReportingDatabase reporter = new ReportingDatabase();
+ private ReportingDatabase reportingDatabase;
private MetadataReportProcessor metadataReportProcessor;
super.setUp();
artifactReportProcessor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "checksum" );
metadataReportProcessor = (MetadataReportProcessor) lookup( MetadataReportProcessor.ROLE, "checksum-metadata" );
+
+ ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
+ reportingDatabase = new ReportingDatabase( reportGroup );
}
/**
Artifact artifact = createArtifact( "checksumTest", "validArtifact", "1.0" );
- artifactReportProcessor.processArtifact( artifact, null, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ artifactReportProcessor.processArtifact( artifact, null, reportingDatabase );
+ assertEquals( 0, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
}
/**
String s1 = "1.0";
Artifact artifact = createArtifact( "checksumTest", s, s1 );
- artifactReportProcessor.processArtifact( artifact, null, reporter );
- assertEquals( 1, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ artifactReportProcessor.processArtifact( artifact, null, reportingDatabase );
+ assertEquals( 1, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
}
/**
* Test the valid checksum of a metadata file.
- * The reporter should report 2 success validation.
+ * The reportingDatabase should report 2 success validation.
*/
public void testChecksumMetadataReporterSuccess()
throws DigesterException, IOException
//Version level metadata
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact );
- metadataReportProcessor.processMetadata( metadata, repository, reporter );
+ metadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
//Artifact level metadata
metadata = new ArtifactRepositoryMetadata( artifact );
- metadataReportProcessor.processMetadata( metadata, repository, reporter );
+ metadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
//Group level metadata
metadata = new GroupRepositoryMetadata( "checksumTest" );
- metadataReportProcessor.processMetadata( metadata, repository, reporter );
+ metadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
}
/**
* Test the corrupted checksum of a metadata file.
- * The reporter must report 2 failures.
+ * The reportingDatabase must report 2 failures.
*/
public void testChecksumMetadataReporterFailure()
{
Artifact artifact = createArtifact( "checksumTest", "invalidArtifact", "1.0" );
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact );
- metadataReportProcessor.processMetadata( metadata, repository, reporter );
+ metadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
Artifact artifact = createArtifact( "checksumTest", "validArtifact", "1.0" );
- artifactReportProcessor.processArtifact( artifact, null, reporter );
- assertEquals( 1, reporter.getNumFailures() );
+ artifactReportProcessor.processArtifact( artifact, null, reportingDatabase );
+ assertEquals( 1, reportingDatabase.getNumFailures() );
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact );
- metadataReportProcessor.processMetadata( metadata, repository, reporter );
+ metadataReportProcessor.processMetadata( metadata, repository, reportingDatabase );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
public class DefaultArtifactReporterTest
extends AbstractRepositoryReportsTestCase
{
- private ReportingDatabase reporter;
+ private ReportingDatabase reportingDatabase;
private RepositoryMetadata metadata;
public void testEmptyArtifactReporter()
{
- assertEquals( "No failures", 0, reporter.getNumFailures() );
- assertEquals( "No warnings", 0, reporter.getNumWarnings() );
- assertFalse( "No artifact failures", reporter.getArtifactIterator().hasNext() );
- assertFalse( "No metadata failures", reporter.getMetadataIterator().hasNext() );
+ assertEquals( "No failures", 0, reportingDatabase.getNumFailures() );
+ assertEquals( "No warnings", 0, reportingDatabase.getNumWarnings() );
+ assertFalse( "No artifact failures", reportingDatabase.getArtifactIterator().hasNext() );
+ assertFalse( "No metadata failures", reportingDatabase.getMetadataIterator().hasNext() );
}
public void testMetadataSingleFailure()
{
- reporter.addFailure( metadata, "Single Failure Reason" );
- assertEquals( "failures count", 1, reporter.getNumFailures() );
- assertEquals( "warnings count", 0, reporter.getNumWarnings() );
+ reportingDatabase.addFailure( metadata, "Single Failure Reason" );
+ assertEquals( "failures count", 1, reportingDatabase.getNumFailures() );
+ assertEquals( "warnings count", 0, reportingDatabase.getNumWarnings() );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
public void testMetadataMultipleFailures()
{
- reporter.addFailure( metadata, "First Failure Reason" );
- reporter.addFailure( metadata, "Second Failure Reason" );
- assertEquals( "failures count", 2, reporter.getNumFailures() );
- assertEquals( "warnings count", 0, reporter.getNumWarnings() );
+ reportingDatabase.addFailure( metadata, "First Failure Reason" );
+ reportingDatabase.addFailure( metadata, "Second Failure Reason" );
+ assertEquals( "failures count", 2, reportingDatabase.getNumFailures() );
+ assertEquals( "warnings count", 0, reportingDatabase.getNumWarnings() );
- Iterator failures = reporter.getMetadataIterator();
+ Iterator failures = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", failures.hasNext() );
MetadataResults results = (MetadataResults) failures.next();
failures = results.getFailures().iterator();
public void testMetadataSingleWarning()
{
- reporter.addWarning( metadata, "Single Warning Message" );
- assertEquals( "warnings count", 0, reporter.getNumFailures() );
- assertEquals( "warnings count", 1, reporter.getNumWarnings() );
+ reportingDatabase.addWarning( metadata, "Single Warning Message" );
+ assertEquals( "warnings count", 0, reportingDatabase.getNumFailures() );
+ assertEquals( "warnings count", 1, reportingDatabase.getNumWarnings() );
- Iterator warnings = reporter.getMetadataIterator();
+ Iterator warnings = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", warnings.hasNext() );
MetadataResults results = (MetadataResults) warnings.next();
warnings = results.getWarnings().iterator();
public void testMetadataMultipleWarnings()
{
- reporter.addWarning( metadata, "First Warning" );
- reporter.addWarning( metadata, "Second Warning" );
- assertEquals( "warnings count", 0, reporter.getNumFailures() );
- assertEquals( "warnings count", 2, reporter.getNumWarnings() );
+ reportingDatabase.addWarning( metadata, "First Warning" );
+ reportingDatabase.addWarning( metadata, "Second Warning" );
+ assertEquals( "warnings count", 0, reportingDatabase.getNumFailures() );
+ assertEquals( "warnings count", 2, reportingDatabase.getNumWarnings() );
- Iterator warnings = reporter.getMetadataIterator();
+ Iterator warnings = reportingDatabase.getMetadataIterator();
assertTrue( "check there is a failure", warnings.hasNext() );
MetadataResults results = (MetadataResults) warnings.next();
warnings = results.getWarnings().iterator();
{
super.setUp();
- reporter = new ReportingDatabase();
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" );
versioning.addVersion( "1.0-alpha-2" );
metadata = new ArtifactRepositoryMetadata( artifact, versioning );
+
+ ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
+ reportingDatabase = new ReportingDatabase( reportGroup );
}
}
private static final String VALID_VERSION = "1.0-alpha-1";
- private ReportingDatabase reporter;
+ private ReportingDatabase reportingDatabase;
private Model model;
throws Exception
{
super.setUp();
- reporter = new ReportingDatabase();
model = new Model();
processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "dependency" );
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
+
+ ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
+ reportingDatabase = new ReportingDatabase( reportGroup );
}
public void testArtifactFoundButNoDirectDependencies()
{
Artifact artifact = createValidArtifact();
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 0, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
}
private Artifact createValidArtifact()
{
Artifact artifact = artifactFactory.createProjectArtifact( INVALID, INVALID, INVALID );
artifact.setRepository( repository );
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 1, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
- Iterator failures = reporter.getArtifactIterator();
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 1, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
+ Iterator failures = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) failures.next();
assertFalse( failures.hasNext() );
failures = results.getFailures().iterator();
Dependency dependency = createValidDependency();
model.addDependency( dependency );
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 0, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
}
private Dependency createValidDependency()
Dependency dependency = createValidDependency();
model.addDependency( dependency );
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 0, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
}
public void testValidArtifactWithValidMultipleDependencies()
model.addDependency( dependency );
Artifact artifact = createValidArtifact();
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 0, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
}
public void testValidArtifactWithAnInvalidDependency()
model.addDependency( createDependency( INVALID, INVALID, INVALID ) );
Artifact artifact = createValidArtifact();
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 1, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 1, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
- Iterator failures = reporter.getArtifactIterator();
+ Iterator failures = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) failures.next();
assertFalse( failures.hasNext() );
failures = results.getFailures().iterator();
Dependency dependency = createDependency( INVALID, VALID_ARTIFACT_ID, VALID_VERSION );
model.addDependency( dependency );
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 1, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 1, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
- Iterator failures = reporter.getArtifactIterator();
+ Iterator failures = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) failures.next();
assertFalse( failures.hasNext() );
failures = results.getFailures().iterator();
Dependency dependency = createDependency( VALID_GROUP_ID, INVALID, VALID_VERSION );
model.addDependency( dependency );
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 1, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 1, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
- Iterator failures = reporter.getArtifactIterator();
+ Iterator failures = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) failures.next();
assertFalse( failures.hasNext() );
failures = results.getFailures().iterator();
Dependency dependency = createDependency( VALID_GROUP_ID, VALID_ARTIFACT_ID, INVALID );
model.addDependency( dependency );
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 1, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 1, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
- Iterator failures = reporter.getArtifactIterator();
+ Iterator failures = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) failures.next();
assertFalse( failures.hasNext() );
failures = results.getFailures().iterator();
Dependency dependency = createDependency( VALID_GROUP_ID, VALID_ARTIFACT_ID, "[" );
model.addDependency( dependency );
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 1, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 1, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
- Iterator failures = reporter.getArtifactIterator();
+ Iterator failures = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) failures.next();
assertFalse( failures.hasNext() );
failures = results.getFailures().iterator();
Dependency dependency = createDependency( VALID_GROUP_ID, VALID_ARTIFACT_ID, "[1.0,)" );
model.addDependency( dependency );
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 0, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
}
public void testValidArtifactWithMissingDependencyVersion()
Dependency dependency = createDependency( VALID_GROUP_ID, VALID_ARTIFACT_ID, null );
model.addDependency( dependency );
- processor.processArtifact( artifact, model, reporter );
- assertEquals( 1, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ processor.processArtifact( artifact, model, reportingDatabase );
+ assertEquals( 1, reportingDatabase.getNumFailures() );
+ assertEquals( 0, reportingDatabase.getNumWarnings() );
- Iterator failures = reporter.getArtifactIterator();
+ Iterator failures = reportingDatabase.getArtifactIterator();
ArtifactResults results = (ArtifactResults) failures.next();
assertFalse( failures.hasNext() );
failures = results.getFailures().iterator();
File indexDirectory;
- private ReportingDatabase reportDatabase = new ReportingDatabase();
+ private ReportingDatabase reportDatabase;
protected void setUp()
throws Exception
index.indexRecords( Collections.singletonList( recordFactory.createRecord( artifact ) ) );
processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "duplicate" );
+
+ ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
+ reportDatabase = new ReportingDatabase( reportGroup );
}
public void testNullArtifactFile()
{
private ArtifactReportProcessor artifactReportProcessor;
- private ReportingDatabase reporter = new ReportingDatabase();
+ private ReportingDatabase reportDatabase;
public void setUp()
throws Exception
{
super.setUp();
artifactReportProcessor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "invalid-pom" );
+
+ ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
+ reportDatabase = new ReportingDatabase( reportGroup );
}
/**
{
Artifact artifact = createArtifact( "org.apache.maven", "artifactId", "1.0-alpha-3", "pom" );
- artifactReportProcessor.processArtifact( artifact, null, reporter );
- assertEquals( 1, reporter.getNumFailures() );
+ artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
+ assertEquals( 1, reportDatabase.getNumFailures() );
}
{
Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-2", "pom" );
- artifactReportProcessor.processArtifact( artifact, null, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
+ assertEquals( 0, reportDatabase.getNumFailures() );
+ assertEquals( 0, reportDatabase.getNumWarnings() );
}
{
Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "jar" );
- artifactReportProcessor.processArtifact( artifact, null, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
+ assertEquals( 0, reportDatabase.getNumFailures() );
+ assertEquals( 0, reportDatabase.getNumWarnings() );
}
}
{
private ArtifactReportProcessor artifactReportProcessor;
- private ReportingDatabase reporter = new ReportingDatabase();
-
- private MavenXpp3Reader pomReader;
+ private ReportingDatabase reportDatabase;
public void setUp()
throws Exception
{
super.setUp();
artifactReportProcessor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "artifact-location" );
- pomReader = new MavenXpp3Reader();
+
+ ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
+ reportDatabase = new ReportingDatabase( reportGroup );
}
/**
{
Artifact artifact = createArtifact( "org.apache.maven", "maven-model", "2.0" );
- artifactReportProcessor.processArtifact( artifact, null, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
+ assertEquals( 0, reportDatabase.getNumFailures() );
+ assertEquals( 0, reportDatabase.getNumWarnings() );
}
/**
Artifact pomArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "pom" );
Model model = readPom( repository.pathOf( pomArtifact ) );
- artifactReportProcessor.processArtifact( artifact, model, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ artifactReportProcessor.processArtifact( artifact, model, reportDatabase );
+ assertEquals( 0, reportDatabase.getNumFailures() );
+ assertEquals( 0, reportDatabase.getNumWarnings() );
}
/**
Artifact pomArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "pom" );
Model model = readPom( repository.pathOf( pomArtifact ) );
- artifactReportProcessor.processArtifact( pomArtifact, model, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ artifactReportProcessor.processArtifact( pomArtifact, model, reportDatabase );
+ assertEquals( 0, reportDatabase.getNumFailures() );
+ assertEquals( 0, reportDatabase.getNumWarnings() );
}
/**
Artifact pomArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "pom" );
Model model = readPom( repository.pathOf( pomArtifact ) );
- artifactReportProcessor.processArtifact( artifact, model, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ artifactReportProcessor.processArtifact( artifact, model, reportDatabase );
+ assertEquals( 0, reportDatabase.getNumFailures() );
+ assertEquals( 0, reportDatabase.getNumWarnings() );
}
/**
Artifact pomArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "pom" );
Model model = readPom( repository.pathOf( pomArtifact ) );
- artifactReportProcessor.processArtifact( artifact, model, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ artifactReportProcessor.processArtifact( artifact, model, reportDatabase );
+ assertEquals( 0, reportDatabase.getNumFailures() );
+ assertEquals( 0, reportDatabase.getNumWarnings() );
}
/**
Artifact pomArtifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "pom" );
Model model = readPom( repository.pathOf( pomArtifact ) );
- artifactReportProcessor.processArtifact( artifact, model, reporter );
- assertEquals( 0, reporter.getNumFailures() );
- assertEquals( 0, reporter.getNumWarnings() );
+ artifactReportProcessor.processArtifact( artifact, model, reportDatabase );
+ assertEquals( 0, reportDatabase.getNumFailures() );
+ assertEquals( 0, reportDatabase.getNumWarnings() );
}
/**
try
{
Model model = readPom( repository.pathOf( pomArtifact ) );
- artifactReportProcessor.processArtifact( artifact, model, reporter );
+ artifactReportProcessor.processArtifact( artifact, model, reportDatabase );
fail( "Should not have passed the artifact" );
}
catch ( IllegalStateException e )
Artifact pomArtifact = createArtifact( "org.apache.maven", "maven-archiver", "2.0", "pom" );
Model model = readPom( repository.pathOf( pomArtifact ) );
- artifactReportProcessor.processArtifact( artifact, model, reporter );
- assertEquals( 1, reporter.getNumFailures() );
+ artifactReportProcessor.processArtifact( artifact, model, reportDatabase );
+ assertEquals( 1, reportDatabase.getNumFailures() );
}
private Model readPom( String path )
throws IOException, XmlPullParserException
{
Reader reader = new FileReader( new File( repository.getBasedir(), path ) );
- Model model = pomReader.read( reader );
+ Model model = new MavenXpp3Reader().read( reader );
// hokey inheritence to avoid some errors right now
if ( model.getGroupId() == null )
{
{
Artifact artifact = createArtifact( "org.apache.maven", "maven-monitor", "2.1" );
- artifactReportProcessor.processArtifact( artifact, null, reporter );
- assertEquals( 1, reporter.getNumFailures() );
+ artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
+ assertEquals( 1, reportDatabase.getNumFailures() );
}
/**
{
Artifact artifact = createArtifact( "org.apache.maven", "maven-project", "2.1" );
- artifactReportProcessor.processArtifact( artifact, null, reporter );
- assertEquals( 1, reporter.getNumFailures() );
+ artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
+ assertEquals( 1, reportDatabase.getNumFailures() );
}
}
import org.apache.maven.archiva.discoverer.filter.AcceptAllArtifactFilter;
import org.apache.maven.archiva.discoverer.filter.SnapshotArtifactFilter;
import org.apache.maven.archiva.reporting.ReportExecutor;
+import org.apache.maven.archiva.reporting.ReportGroup;
import org.apache.maven.archiva.reporting.ReportingDatabase;
import org.apache.maven.archiva.reporting.ReportingStore;
import org.apache.maven.archiva.reporting.ReportingStoreException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
/**
* Repository reporting.
private Configuration configuration;
+ /**
+ * @plexus.requirement role="org.apache.maven.archiva.reporting.ReportGroup"
+ */
+ private Map reports;
+
+ private String reportGroup = DEFAULT_REPORT_GROUP;
+
+ private static final String DEFAULT_REPORT_GROUP = "health";
+
public String execute()
throws Exception
{
+ ReportGroup reportGroup = (ReportGroup) reports.get( this.reportGroup );
+
databases = new ArrayList();
if ( repositoryId != null && !repositoryId.equals( "-" ) )
{
RepositoryConfiguration repositoryConfiguration = configuration.getRepositoryById( repositoryId );
- getReport( repositoryConfiguration );
+ getReport( repositoryConfiguration, reportGroup );
}
else
{
{
RepositoryConfiguration repositoryConfiguration = (RepositoryConfiguration) i.next();
- getReport( repositoryConfiguration );
+ getReport( repositoryConfiguration, reportGroup );
}
}
return SUCCESS;
}
- private void getReport( RepositoryConfiguration repositoryConfiguration )
+ private void getReport( RepositoryConfiguration repositoryConfiguration, ReportGroup reportGroup )
throws ReportingStoreException
{
ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
- ReportingDatabase database = reportingStore.getReportsFromStore( repository );
+ ReportingDatabase database = reportingStore.getReportsFromStore( repository, reportGroup );
databases.add( database );
}
public String runReport()
throws Exception
{
- // TODO: this should be one that runs in the background - see the showcase
+ ReportGroup reportGroup = (ReportGroup) reports.get( this.reportGroup );
RepositoryConfiguration repositoryConfiguration = configuration.getRepositoryById( repositoryId );
ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
- ReportingDatabase database = executor.getReportDatabase( repository );
+ ReportingDatabase database = executor.getReportDatabase( repository, reportGroup );
if ( database.isInProgress() )
{
return SUCCESS;
try
{
- executor.runReports( repository, blacklistedPatterns, filter );
+ executor.runReports( reportGroup, repository, blacklistedPatterns, filter );
}
finally
{
return SUCCESS;
}
+ public void setReportGroup( String reportGroup )
+ {
+ this.reportGroup = reportGroup;
+ }
+
+ public String getReportGroup()
+ {
+ return reportGroup;
+ }
+
public String getRepositoryId()
{
return repositoryId;
{
return configuration;
}
+
+ public Map getReports()
+ {
+ return reports;
+ }
}
<html>
<head>
- <%-- TODO! change the name --%>
- <title>Report: Repository Health</title>
+ <ww:set name="reports" value="reports"/>
+ <ww:set name="reportGroup" value="reportGroup"/>
+ <title>Report: ${reports[reportGroup].name}</title>
<ww:head/>
</head>
<div id="contentArea">
-<%-- TODO!: select report, filter --%>
+<%-- TODO!: select filter --%>
<ww:form action="reports" namespace="/admin">
+ <ww:select list="reports" label="Report" name="reportGroup"/>
<ww:select list="configuration.repositories" listKey="id" listValue="name" label="Repository" headerKey="-"
headerValue="(All repositories)" name="repositoryId"/>
<ww:submit value="Get Report"/>