From: Brett Porter Date: Mon, 11 Sep 2006 00:01:48 +0000 (+0000) Subject: [MRM-166] better display of ungenerated reports, and only list metadata that has... X-Git-Tag: archiva-0.9-alpha-1~560 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=40b955d3878f11ed8485005e4358ff40b9cbfb1d;p=archiva.git [MRM-166] better display of ungenerated reports, and only list metadata that has had failures or warnings git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@442039 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ReportingDatabase.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ReportingDatabase.java index ca4a44c4b..a2f9bf74b 100644 --- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ReportingDatabase.java +++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/ReportingDatabase.java @@ -27,7 +27,9 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import java.util.Date; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.Map; +import java.util.Set; /** * @todo i18n, including message formatting and parameterisation @@ -52,6 +54,8 @@ public class ReportingDatabase private final ReportGroup reportGroup; + private Set metadataWithProblems; + public ReportingDatabase( ReportGroup reportGroup ) { this( reportGroup, new Reporting() ); @@ -152,6 +156,10 @@ public class ReportingDatabase public void addFailure( RepositoryMetadata metadata, String reason ) { MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() ); + if ( !metadataWithProblems.contains( results ) ) + { + metadataWithProblems.add( results ); + } results.addFailure( createResults( reason ) ); numFailures++; updateTimings(); @@ -160,14 +168,25 @@ public class ReportingDatabase public void addWarning( RepositoryMetadata metadata, String reason ) { MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() ); + if ( !metadataWithProblems.contains( results ) ) + { + metadataWithProblems.add( results ); + } results.addWarning( createResults( reason ) ); numWarnings++; updateTimings(); } + public Set getMetadataWithProblems() + { + return metadataWithProblems; + } + private void initMetadataMap() { Map map = new HashMap(); + Set problems = new LinkedHashSet(); + for ( Iterator i = reporting.getMetadata().iterator(); i.hasNext(); ) { MetadataResults result = (MetadataResults) i.next(); @@ -178,8 +197,14 @@ public class ReportingDatabase numFailures += result.getFailures().size(); numWarnings += result.getWarnings().size(); + + if ( !result.getFailures().isEmpty() || !result.getWarnings().isEmpty() ) + { + problems.add( result ); + } } metadataMap = map; + metadataWithProblems = problems; } private static String getMetadataKey( String groupId, String artifactId, String version ) @@ -237,6 +262,8 @@ public class ReportingDatabase numWarnings -= results.getWarnings().size(); results.getWarnings().clear(); + + metadataWithProblems.remove( results ); } private MetadataResults getMetadataResults( RepositoryMetadata metadata, long lastModified ) @@ -315,6 +342,7 @@ public class ReportingDatabase artifactMap.clear(); metadataMap.clear(); + metadataWithProblems.clear(); reporting.getArtifacts().clear(); reporting.getMetadata().clear(); diff --git a/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java b/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java index 0942a328b..86db54f3b 100644 --- a/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java +++ b/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java @@ -22,12 +22,12 @@ import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ConfigurationStore; import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory; import org.apache.maven.archiva.configuration.RepositoryConfiguration; +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.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 org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; @@ -46,11 +46,6 @@ public class ReportsAction extends ActionSupport implements Preparable { - /** - * @plexus.requirement - */ - private ReportingStore reportingStore; - /** * @plexus.requirement */ @@ -110,7 +105,7 @@ public class ReportsAction { ArtifactRepository repository = factory.createRepository( repositoryConfiguration ); - ReportingDatabase database = reportingStore.getReportsFromStore( repository, reportGroup ); + ReportingDatabase database = executor.getReportDatabase( repository, reportGroup ); databases.add( database ); } @@ -129,6 +124,15 @@ public class ReportsAction return SUCCESS; } + generateReport( database, repositoryConfiguration, reportGroup, repository ); + + return SUCCESS; + } + + private void generateReport( ReportingDatabase database, RepositoryConfiguration repositoryConfiguration, + ReportGroup reportGroup, ArtifactRepository repository ) + throws DiscovererException, ReportingStoreException + { database.setInProgress( true ); List blacklistedPatterns = new ArrayList(); @@ -159,8 +163,6 @@ public class ReportsAction { database.setInProgress( false ); } - - return SUCCESS; } public void setReportGroup( String reportGroup ) diff --git a/archiva-webapp/src/main/resources/xwork.xml b/archiva-webapp/src/main/resources/xwork.xml index 4bea0e165..b9d78897c 100644 --- a/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-webapp/src/main/resources/xwork.xml @@ -234,8 +234,8 @@ - reports - reports + /admin/reports.action?reportGroup=${reportGroup}&repositoryId=${repositoryId}&filter=${filter} + /admin/reports.action?reportGroup=${reportGroup}&repositoryId=${repositoryId}&filter=${filter} diff --git a/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp b/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp index ad043764d..4f91730a1 100644 --- a/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp +++ b/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp @@ -54,6 +54,7 @@ + Regenerate Report @@ -68,18 +69,27 @@

Repository: ${database.repository.name}

- Status: - " width="15" height="15" alt=""/> - ${database.numFailures} - " width="15" height="15" alt=""/> - ${database.numWarnings} + + + Status: + " width="15" height="15" alt=""/> + ${database.numFailures} + " width="15" height="15" alt=""/> + ${database.numWarnings} - - <%-- TODO! use better formatting here --%> - Last updated: ${database.reporting.lastModified}, - execution time: minutes - seconds - + + <%-- TODO! use better formatting here --%> + Last updated: ${database.reporting.lastModified}, + execution time: minutes + seconds + + + + + This report has not yet been generated. Generate Report + + +

<%-- TODO need to protect iterations against concurrent modification exceptions by cloning the lists synchronously --%> @@ -145,9 +155,9 @@

- +

Metadata

- +
  • ${result.reason}
  • @@ -206,7 +216,7 @@ --%>
    - +

    ... more ...