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
private final ReportGroup reportGroup;
+ private Set metadataWithProblems;
+
public ReportingDatabase( ReportGroup reportGroup )
{
this( reportGroup, new Reporting() );
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();
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();
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 )
numWarnings -= results.getWarnings().size();
results.getWarnings().clear();
+
+ metadataWithProblems.remove( results );
}
private MetadataResults getMetadataResults( RepositoryMetadata metadata, long lastModified )
artifactMap.clear();
metadataMap.clear();
+ metadataWithProblems.clear();
reporting.getArtifacts().clear();
reporting.getMetadata().clear();
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;
extends ActionSupport
implements Preparable
{
- /**
- * @plexus.requirement
- */
- private ReportingStore reportingStore;
-
/**
* @plexus.requirement
*/
{
ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
- ReportingDatabase database = reportingStore.getReportsFromStore( repository, reportGroup );
+ ReportingDatabase database = executor.getReportDatabase( repository, reportGroup );
databases.add( database );
}
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();
{
database.setInProgress( false );
}
-
- return SUCCESS;
}
public void setReportGroup( String reportGroup )
<action name="runReport" class="reportsAction" method="runReport">
<interceptor-ref name="configuredStack"/>
<interceptor-ref name="execAndWait"/>
- <result name="wait" type="redirect-action">reports</result>
- <result name="success" type="redirect-action">reports</result>
+ <result name="wait" type="redirect">/admin/reports.action?reportGroup=${reportGroup}&repositoryId=${repositoryId}&filter=${filter}</result>
+ <result name="success" type="redirect">/admin/reports.action?reportGroup=${reportGroup}&repositoryId=${repositoryId}&filter=${filter}</result>
</action>
</package>
</xwork>
<c:set var="url">
<ww:url action="runReport" namespace="/admin">
<ww:param name="repositoryId" value="%{'${database.repository.id}'}"/>
+ <ww:param name="reportGroup" value="reportGroup"/>
</ww:url>
</c:set>
<a href="${url}">Regenerate Report</a>
<h2>Repository: ${database.repository.name}</h2>
<p>
- Status:
- <img src="<c:url value="/images/icon_error_sml.gif"/>" width="15" height="15" alt=""/>
- ${database.numFailures}
- <img src="<c:url value="/images/icon_warning_sml.gif"/>" width="15" height="15" alt=""/>
- ${database.numWarnings}
+ <c:choose>
+ <c:when test="${!empty(database.reporting.lastModified)}">
+ Status:
+ <img src="<c:url value="/images/icon_error_sml.gif"/>" width="15" height="15" alt=""/>
+ ${database.numFailures}
+ <img src="<c:url value="/images/icon_warning_sml.gif"/>" width="15" height="15" alt=""/>
+ ${database.numWarnings}
- <span style="font-size: x-small">
- <%-- TODO! use better formatting here --%>
- Last updated: ${database.reporting.lastModified},
- execution time: <fmt:formatNumber maxFractionDigits="0" value="${database.reporting.executionTime / 60000}"/> minutes
- <fmt:formatNumber maxFractionDigits="0" value="${(database.reporting.executionTime / 1000) % 60}"/> seconds
- </span>
+ <span style="font-size: x-small">
+ <%-- TODO! use better formatting here --%>
+ Last updated: ${database.reporting.lastModified},
+ execution time: <fmt:formatNumber maxFractionDigits="0" value="${database.reporting.executionTime / 60000}"/> minutes
+ <fmt:formatNumber maxFractionDigits="0" value="${(database.reporting.executionTime / 1000) % 60}"/> seconds
+ </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>
<%-- TODO need to protect iterations against concurrent modification exceptions by cloning the lists synchronously --%>
</p>
</c:if>
</c:if>
-<c:if test="${!empty(database.reporting.metadata)}">
+<c:if test="${!empty(database.metadataWithProblems)}">
<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>
<c:forEach items="${metadata.failures}" var="result">
<li class="errorBullet">${result.reason}</li>
</td>
--%>
</c:forEach>
- <c:if test="${fn:length(database.reporting.metadata) gt 3}">
+ <c:if test="${fn:length(database.metadataWithProblems) gt 3}">
<p>
<b>... more ...</b>
</p>