From 44dce100876f756c26945ce0e5295af448785bd8 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Fri, 8 Sep 2006 14:33:45 +0000 Subject: [PATCH] [MRM-77] preliminary reporting web interface git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@441516 13f79535-47bb-0310-9956-ffa450edef68 --- .../reporting/DefaultReportingStore.java | 4 +- .../archiva/reporting/ReportingDatabase.java | 104 ++++++---- .../archiva/web/action/ReportsAction.java | 81 ++++++++ archiva-webapp/src/main/resources/xwork.xml | 4 + .../webapp/WEB-INF/jsp/decorators/default.jsp | 22 ++- .../jsp/include/artifactDependencies.jspf | 2 +- .../webapp/WEB-INF/jsp/reports/reports.jsp | 181 ++++++++++++++++++ .../src/main/webapp/css/maven-theme.css | 1 + archiva-webapp/src/main/webapp/css/site.css | 8 + design/white-site/src/site/xdoc/reports.xml | 130 ++++++++----- 10 files changed, 438 insertions(+), 99 deletions(-) create mode 100644 archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java create mode 100644 archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultReportingStore.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultReportingStore.java index d9495308f..65d920506 100644 --- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultReportingStore.java +++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DefaultReportingStore.java @@ -67,7 +67,7 @@ public class DefaultReportingStore } catch ( FileNotFoundException e ) { - database = new ReportingDatabase(); + database = new ReportingDatabase( repository ); } if ( database == null ) @@ -75,7 +75,7 @@ public class DefaultReportingStore getLogger().info( "Reading report database from " + file ); try { - database = new ReportingDatabase( reader.read( fileReader, false ) ); + database = new ReportingDatabase( reader.read( fileReader, false ), repository ); } catch ( IOException e ) { 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 d50f16be4..823bbe7ef 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 @@ -21,6 +21,7 @@ import org.apache.maven.archiva.reporting.model.MetadataResults; import org.apache.maven.archiva.reporting.model.Reporting; import org.apache.maven.archiva.reporting.model.Result; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; import java.util.HashMap; @@ -38,37 +39,55 @@ public class ReportingDatabase private Map metadataMap; - private int totalFailures; + private int numFailures; - private int totalWarnings; + private int numWarnings; + + private ArtifactRepository repository; public ReportingDatabase() { - reporting = new Reporting(); + this( new Reporting(), null ); } public ReportingDatabase( Reporting reporting ) + { + this( reporting, null ); + } + + public ReportingDatabase( ArtifactRepository repository ) + { + this( new Reporting(), repository ); + } + + public ReportingDatabase( Reporting reporting, ArtifactRepository repository ) { this.reporting = reporting; + + this.repository = repository; + + initArtifactMap(); + + initMetadataMap(); } public void addFailure( Artifact artifact, String reason ) { ArtifactResults results = getArtifactResults( artifact ); results.addFailure( createResults( reason ) ); - totalFailures++; + numFailures++; } public void addWarning( Artifact artifact, String reason ) { ArtifactResults results = getArtifactResults( artifact ); results.addWarning( createResults( reason ) ); - totalWarnings++; + numWarnings++; } private ArtifactResults getArtifactResults( Artifact artifact ) { - Map artifactMap = getArtifactMap(); + Map artifactMap = this.artifactMap; String key = getArtifactKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier() ); @@ -89,25 +108,21 @@ public class ReportingDatabase return results; } - private Map getArtifactMap() + private void initArtifactMap() { - if ( artifactMap == null ) + Map map = new HashMap(); + for ( Iterator i = reporting.getArtifacts().iterator(); i.hasNext(); ) { - Map map = new HashMap(); - for ( Iterator i = reporting.getArtifacts().iterator(); i.hasNext(); ) - { - ArtifactResults result = (ArtifactResults) i.next(); + ArtifactResults result = (ArtifactResults) i.next(); - String key = getArtifactKey( result.getGroupId(), result.getArtifactId(), result.getVersion(), - result.getType(), result.getClassifier() ); - map.put( key, result ); + String key = getArtifactKey( result.getGroupId(), result.getArtifactId(), result.getVersion(), + result.getType(), result.getClassifier() ); + map.put( key, result ); - totalFailures += result.getFailures().size(); - totalWarnings += result.getWarnings().size(); - } - artifactMap = map; + numFailures += result.getFailures().size(); + numWarnings += result.getWarnings().size(); } - return artifactMap; + artifactMap = map; } private static String getArtifactKey( String groupId, String artifactId, String version, String type, @@ -127,35 +142,31 @@ public class ReportingDatabase { MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() ); results.addFailure( createResults( reason ) ); - totalFailures++; + numFailures++; } public void addWarning( RepositoryMetadata metadata, String reason ) { MetadataResults results = getMetadataResults( metadata, System.currentTimeMillis() ); results.addWarning( createResults( reason ) ); - totalWarnings++; + numWarnings++; } - private Map getMetadataMap() + private void initMetadataMap() { - if ( metadataMap == null ) + Map map = new HashMap(); + for ( Iterator i = reporting.getMetadata().iterator(); i.hasNext(); ) { - Map map = new HashMap(); - for ( Iterator i = reporting.getMetadata().iterator(); i.hasNext(); ) - { - MetadataResults result = (MetadataResults) i.next(); + MetadataResults result = (MetadataResults) i.next(); - String key = getMetadataKey( result.getGroupId(), result.getArtifactId(), result.getVersion() ); + String key = getMetadataKey( result.getGroupId(), result.getArtifactId(), result.getVersion() ); - map.put( key, result ); + map.put( key, result ); - totalFailures += result.getFailures().size(); - totalWarnings += result.getWarnings().size(); - } - metadataMap = map; + numFailures += result.getFailures().size(); + numWarnings += result.getWarnings().size(); } - return metadataMap; + metadataMap = map; } private static String getMetadataKey( String groupId, String artifactId, String version ) @@ -165,12 +176,12 @@ public class ReportingDatabase public int getNumFailures() { - return totalFailures; + return numFailures; } public int getNumWarnings() { - return totalWarnings; + return numWarnings; } public Reporting getReporting() @@ -191,7 +202,7 @@ public class ReportingDatabase public boolean isMetadataUpToDate( RepositoryMetadata metadata, long timestamp ) { String key = getMetadataKey( metadata ); - Map map = getMetadataMap(); + Map map = metadataMap; MetadataResults results = (MetadataResults) map.get( key ); return results != null && results.getLastModified() >= timestamp; } @@ -207,14 +218,18 @@ public class ReportingDatabase MetadataResults results = getMetadataResults( metadata, lastModified ); results.setLastModified( lastModified ); + + numFailures -= results.getFailures().size(); results.getFailures().clear(); + + numWarnings -= results.getWarnings().size(); results.getWarnings().clear(); } private MetadataResults getMetadataResults( RepositoryMetadata metadata, long lastModified ) { String key = getMetadataKey( metadata ); - Map metadataMap = getMetadataMap(); + Map metadataMap = this.metadataMap; MetadataResults results = (MetadataResults) metadataMap.get( key ); if ( results == null ) { @@ -237,7 +252,7 @@ public class ReportingDatabase public void removeArtifact( Artifact artifact ) { - Map map = getArtifactMap(); + Map map = artifactMap; String key = getArtifactKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier() ); @@ -251,7 +266,16 @@ public class ReportingDatabase i.remove(); } } + + numFailures -= results.getFailures().size(); + numWarnings -= results.getWarnings().size(); + map.remove( key ); } } + + public ArtifactRepository getRepository() + { + return repository; + } } 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 new file mode 100644 index 000000000..0e5efac7f --- /dev/null +++ b/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java @@ -0,0 +1,81 @@ +package org.apache.maven.archiva.web.action; + +/* + * 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 com.opensymphony.xwork.ActionSupport; +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.reporting.ReportingDatabase; +import org.apache.maven.archiva.reporting.ReportingStore; +import org.apache.maven.artifact.repository.ArtifactRepository; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Repository reporting. + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="reportsAction" + */ +public class ReportsAction + extends ActionSupport +{ + /** + * @plexus.requirement + */ + private ReportingStore reportingStore; + + /** + * @plexus.requirement + */ + private ConfigurationStore configurationStore; + + /** + * @plexus.requirement + */ + private ConfiguredRepositoryFactory factory; + + private List databases; + + public String execute() + throws Exception + { + databases = new ArrayList(); + + Configuration configuration = configurationStore.getConfigurationFromStore(); + + for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); ) + { + RepositoryConfiguration repositoryConfiguration = (RepositoryConfiguration) i.next(); + + ArtifactRepository repository = factory.createRepository( repositoryConfiguration ); + + ReportingDatabase database = reportingStore.getReportsFromStore( repository ); + + databases.add( database ); + } + return SUCCESS; + } + + public List getDatabases() + { + return databases; + } +} diff --git a/archiva-webapp/src/main/resources/xwork.xml b/archiva-webapp/src/main/resources/xwork.xml index 382b15631..61def7a32 100644 --- a/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-webapp/src/main/resources/xwork.xml @@ -107,6 +107,10 @@ /WEB-INF/jsp/showArtifact.jsp + + /WEB-INF/jsp/reports/reports.jsp + + /WEB-INF/jsp/showArtifact.jsp diff --git a/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp b/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp index 20476d744..4ee4b35f8 100644 --- a/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp +++ b/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp @@ -25,11 +25,11 @@ - + " type="text/css" media="print"/> @@ -62,10 +62,13 @@ - Login or Register + Login + or + Register - Welcome, ${sessionScope.user.username} - Logout + Welcome, ${sessionScope.user.username} - + Logout @@ -101,12 +104,11 @@
Manage
    +
  • + Reports +
  • <%-- TODO -
  • - Reports -
  • -
  • Synchronisation
  • diff --git a/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/artifactDependencies.jspf b/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/artifactDependencies.jspf index c9501cca5..32477f58a 100644 --- a/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/artifactDependencies.jspf +++ b/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/artifactDependencies.jspf @@ -1,7 +1,7 @@ <%@ taglib prefix="ww" uri="/webwork" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> -<%-- TODO: paginate --%> +<%-- TODO: paginate! --%>

    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 new file mode 100644 index 000000000..2905bea74 --- /dev/null +++ b/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/reports.jsp @@ -0,0 +1,181 @@ +<%-- + ~ 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. + --%> + +<%@ taglib prefix="ww" uri="/webwork" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> + + + + Repository Health + + + + + +

    Reports

    + +
    + + + +

    Repository: ${database.repository.name}

    + +

    + Status: + " width="15" height="15" alt=""/> + ${database.numFailures} + " width="15" height="15" alt=""/> + ${database.numWarnings} + <%-- TODO! + (Repair all) + --%> +

    + +<%-- TODO! factor out common parts, especially artifact rendering tag --%> +<%-- TODO! paginate --%> + +

    Artifacts

    + +
      + +
    • ${result.reason}
    • +
      + +
    • ${result.reason}
    • +
      +
    +

    + + <%-- TODO! share with browse as a tag --%> + + + + + + + + + + + + + + + + ${part} / + + ${artifact.artifactId} + | Version: + + + + + + + + + + ${artifact.version} + + | Classifier: ${artifact.classifier} + + +

    + <%-- TODO! + + Repair + + --%> +
    + +

    + ... more ... +

    +
    +
    + +

    Metadata

    + +
      + +
    • ${result.reason}
    • +
      + +
    • ${result.reason}
    • +
      +
    +

    + + <%-- TODO! share with browse as a tag --%> + + + + + + + + + + + + + + + + ${part} + + / + + + + + + + + + + / ${metadata.artifactId} + + | Version: + + + + + + + + ${metadata.version} + + +

    + <%-- TODO! + + Repair + + --%> +
    + +

    + ... more ... +

    +
    +
    +
    +
    + + + diff --git a/archiva-webapp/src/main/webapp/css/maven-theme.css b/archiva-webapp/src/main/webapp/css/maven-theme.css index b52a561b0..8f1d8fc4b 100644 --- a/archiva-webapp/src/main/webapp/css/maven-theme.css +++ b/archiva-webapp/src/main/webapp/css/maven-theme.css @@ -31,6 +31,7 @@ th { text-align: right; padding-right: 1em; font-size: x-small; + vertical-align: top; } .infoTable th { diff --git a/archiva-webapp/src/main/webapp/css/site.css b/archiva-webapp/src/main/webapp/css/site.css index dff21cc7b..bb03df783 100644 --- a/archiva-webapp/src/main/webapp/css/site.css +++ b/archiva-webapp/src/main/webapp/css/site.css @@ -96,3 +96,11 @@ .actionMessage { font-weight: bold; } + +.errorBullet { + list-style-image: url( "../images/icon_error_sml.gif" ); +} + +.warningBullet { + list-style-image: url( "../images/icon_warning_sml.gif" ); +} diff --git a/design/white-site/src/site/xdoc/reports.xml b/design/white-site/src/site/xdoc/reports.xml index ab7b8738a..7de7c34d4 100644 --- a/design/white-site/src/site/xdoc/reports.xml +++ b/design/white-site/src/site/xdoc/reports.xml @@ -10,75 +10,113 @@
    -

    Status

    +

    Repository 1

    + +

    + Status: + + 2 + + 0 + ( + Repair all + ) +

    + +

    Artifacts

    - - - - - - + + + - + +
    Last run1 February 13:01:04
    Next run1 February 17:00:00 + + + File is missing SHA1 checksum +

    + + Group ID: + org + / + apache + / + maven + Artifact ID: + maven-artifact + Version(s): + 2.0 + +

    +
    + Repair +
    Status - WARNING - : some warnings were found. + + File is missing SHA1 checksum +

    + + Group ID: + org + / + apache + / + maven + Artifact ID: + maven-artifact + Version(s): + 2.0.1 + +

    +
    + Repair
    -

    Errors

    -

    - No errors found. -

    -

    Warnings

    + +

    Repository 2

    +

    - 3 warnings found. ( + Status: + + 0 + + 1 + ( Repair all )

    + +

    Artifacts

    - - - - - - - - - - - - - - - - - - - - - - -
    Group IDArtifact IDVersionMessage
    org.apache.mavenmaven-model2.0.1File is missing SHA1 checksum - Repair +
    org.apache.mavenmaven-model2.0.2File is missing SHA1 checksum - Fixed - + File is missing a digital signature +

    + + Group ID: + org + / + apache + / + maven + Artifact ID: + maven-artifact + Version(s): + 2.0.1 + +

    org.apache.mavenmaven-model2.0.2File is missing a digital signature No fix available
    - - -
    -- 2.39.5