[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
This commit is contained in:
Brett Porter 2006-09-11 00:01:48 +00:00
parent b57273dff3
commit 40b955d387
4 changed files with 65 additions and 25 deletions
archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting
archiva-webapp/src/main
java/org/apache/maven/archiva/web/action
resources
webapp/WEB-INF/jsp/reports

View File

@ -27,7 +27,9 @@ import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* @todo i18n, including message formatting and parameterisation * @todo i18n, including message formatting and parameterisation
@ -52,6 +54,8 @@ public class ReportingDatabase
private final ReportGroup reportGroup; private final ReportGroup reportGroup;
private Set metadataWithProblems;
public ReportingDatabase( ReportGroup reportGroup ) public ReportingDatabase( ReportGroup reportGroup )
{ {
this( reportGroup, new Reporting() ); this( reportGroup, new Reporting() );
@ -152,6 +156,10 @@ public class ReportingDatabase
public void addFailure( RepositoryMetadata metadata, String reason ) public void addFailure( RepositoryMetadata metadata, String reason )
{ {
MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() ); MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() );
if ( !metadataWithProblems.contains( results ) )
{
metadataWithProblems.add( results );
}
results.addFailure( createResults( reason ) ); results.addFailure( createResults( reason ) );
numFailures++; numFailures++;
updateTimings(); updateTimings();
@ -160,14 +168,25 @@ public class ReportingDatabase
public void addWarning( RepositoryMetadata metadata, String reason ) public void addWarning( RepositoryMetadata metadata, String reason )
{ {
MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() ); MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() );
if ( !metadataWithProblems.contains( results ) )
{
metadataWithProblems.add( results );
}
results.addWarning( createResults( reason ) ); results.addWarning( createResults( reason ) );
numWarnings++; numWarnings++;
updateTimings(); updateTimings();
} }
public Set getMetadataWithProblems()
{
return metadataWithProblems;
}
private void initMetadataMap() private void initMetadataMap()
{ {
Map map = new HashMap(); Map map = new HashMap();
Set problems = new LinkedHashSet();
for ( Iterator i = reporting.getMetadata().iterator(); i.hasNext(); ) for ( Iterator i = reporting.getMetadata().iterator(); i.hasNext(); )
{ {
MetadataResults result = (MetadataResults) i.next(); MetadataResults result = (MetadataResults) i.next();
@ -178,8 +197,14 @@ public class ReportingDatabase
numFailures += result.getFailures().size(); numFailures += result.getFailures().size();
numWarnings += result.getWarnings().size(); numWarnings += result.getWarnings().size();
if ( !result.getFailures().isEmpty() || !result.getWarnings().isEmpty() )
{
problems.add( result );
}
} }
metadataMap = map; metadataMap = map;
metadataWithProblems = problems;
} }
private static String getMetadataKey( String groupId, String artifactId, String version ) private static String getMetadataKey( String groupId, String artifactId, String version )
@ -237,6 +262,8 @@ public class ReportingDatabase
numWarnings -= results.getWarnings().size(); numWarnings -= results.getWarnings().size();
results.getWarnings().clear(); results.getWarnings().clear();
metadataWithProblems.remove( results );
} }
private MetadataResults getMetadataResults( RepositoryMetadata metadata, long lastModified ) private MetadataResults getMetadataResults( RepositoryMetadata metadata, long lastModified )
@ -315,6 +342,7 @@ public class ReportingDatabase
artifactMap.clear(); artifactMap.clear();
metadataMap.clear(); metadataMap.clear();
metadataWithProblems.clear();
reporting.getArtifacts().clear(); reporting.getArtifacts().clear();
reporting.getMetadata().clear(); reporting.getMetadata().clear();

View File

@ -22,12 +22,12 @@ import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ConfigurationStore; import org.apache.maven.archiva.configuration.ConfigurationStore;
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory; import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory;
import org.apache.maven.archiva.configuration.RepositoryConfiguration; 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.AcceptAllArtifactFilter;
import org.apache.maven.archiva.discoverer.filter.SnapshotArtifactFilter; import org.apache.maven.archiva.discoverer.filter.SnapshotArtifactFilter;
import org.apache.maven.archiva.reporting.ReportExecutor; import org.apache.maven.archiva.reporting.ReportExecutor;
import org.apache.maven.archiva.reporting.ReportGroup; import org.apache.maven.archiva.reporting.ReportGroup;
import org.apache.maven.archiva.reporting.ReportingDatabase; 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.archiva.reporting.ReportingStoreException;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
@ -46,11 +46,6 @@ public class ReportsAction
extends ActionSupport extends ActionSupport
implements Preparable implements Preparable
{ {
/**
* @plexus.requirement
*/
private ReportingStore reportingStore;
/** /**
* @plexus.requirement * @plexus.requirement
*/ */
@ -110,7 +105,7 @@ public class ReportsAction
{ {
ArtifactRepository repository = factory.createRepository( repositoryConfiguration ); ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
ReportingDatabase database = reportingStore.getReportsFromStore( repository, reportGroup ); ReportingDatabase database = executor.getReportDatabase( repository, reportGroup );
databases.add( database ); databases.add( database );
} }
@ -129,6 +124,15 @@ public class ReportsAction
return SUCCESS; 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 ); database.setInProgress( true );
List blacklistedPatterns = new ArrayList(); List blacklistedPatterns = new ArrayList();
@ -159,8 +163,6 @@ public class ReportsAction
{ {
database.setInProgress( false ); database.setInProgress( false );
} }
return SUCCESS;
} }
public void setReportGroup( String reportGroup ) public void setReportGroup( String reportGroup )

View File

@ -234,8 +234,8 @@
<action name="runReport" class="reportsAction" method="runReport"> <action name="runReport" class="reportsAction" method="runReport">
<interceptor-ref name="configuredStack"/> <interceptor-ref name="configuredStack"/>
<interceptor-ref name="execAndWait"/> <interceptor-ref name="execAndWait"/>
<result name="wait" type="redirect-action">reports</result> <result name="wait" type="redirect">/admin/reports.action?reportGroup=${reportGroup}&amp;repositoryId=${repositoryId}&amp;filter=${filter}</result>
<result name="success" type="redirect-action">reports</result> <result name="success" type="redirect">/admin/reports.action?reportGroup=${reportGroup}&amp;repositoryId=${repositoryId}&amp;filter=${filter}</result>
</action> </action>
</package> </package>
</xwork> </xwork>

View File

@ -54,6 +54,7 @@
<c:set var="url"> <c:set var="url">
<ww:url action="runReport" namespace="/admin"> <ww:url action="runReport" namespace="/admin">
<ww:param name="repositoryId" value="%{'${database.repository.id}'}"/> <ww:param name="repositoryId" value="%{'${database.repository.id}'}"/>
<ww:param name="reportGroup" value="reportGroup"/>
</ww:url> </ww:url>
</c:set> </c:set>
<a href="${url}">Regenerate Report</a> <a href="${url}">Regenerate Report</a>
@ -68,6 +69,8 @@
<h2>Repository: ${database.repository.name}</h2> <h2>Repository: ${database.repository.name}</h2>
<p> <p>
<c:choose>
<c:when test="${!empty(database.reporting.lastModified)}">
Status: Status:
<img src="<c:url value="/images/icon_error_sml.gif"/>" width="15" height="15" alt=""/> <img src="<c:url value="/images/icon_error_sml.gif"/>" width="15" height="15" alt=""/>
${database.numFailures} ${database.numFailures}
@ -80,6 +83,13 @@
execution time: <fmt:formatNumber maxFractionDigits="0" value="${database.reporting.executionTime / 60000}"/> minutes execution time: <fmt:formatNumber maxFractionDigits="0" value="${database.reporting.executionTime / 60000}"/> minutes
<fmt:formatNumber maxFractionDigits="0" value="${(database.reporting.executionTime / 1000) % 60}"/> seconds <fmt:formatNumber maxFractionDigits="0" value="${(database.reporting.executionTime / 1000) % 60}"/> seconds
</span> </span>
</c:when>
<c:otherwise>
<b>
This report has not yet been generated. <a href="${url}">Generate Report</a>
</b>
</c:otherwise>
</c:choose>
</p> </p>
<%-- TODO need to protect iterations against concurrent modification exceptions by cloning the lists synchronously --%> <%-- TODO need to protect iterations against concurrent modification exceptions by cloning the lists synchronously --%>
@ -145,9 +155,9 @@
</p> </p>
</c:if> </c:if>
</c:if> </c:if>
<c:if test="${!empty(database.reporting.metadata)}"> <c:if test="${!empty(database.metadataWithProblems)}">
<h3>Metadata</h3> <h3>Metadata</h3>
<c:forEach items="${database.reporting.metadata}" var="metadata" begin="0" end="2"> <c:forEach items="${database.metadataWithProblems}" var="metadata" begin="0" end="2">
<ul> <ul>
<c:forEach items="${metadata.failures}" var="result"> <c:forEach items="${metadata.failures}" var="result">
<li class="errorBullet">${result.reason}</li> <li class="errorBullet">${result.reason}</li>
@ -206,7 +216,7 @@
</td> </td>
--%> --%>
</c:forEach> </c:forEach>
<c:if test="${fn:length(database.reporting.metadata) gt 3}"> <c:if test="${fn:length(database.metadataWithProblems) gt 3}">
<p> <p>
<b>... more ...</b> <b>... more ...</b>
</p> </p>