From f4330d5248c89f5902bf6a9e53ff6ee8e9278c64 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 2 Oct 2007 00:44:21 +0000 Subject: [PATCH] [MRM-448] validation for reports form. Creating validation. Changing "Show Reports" to "Pick Reports" to be more clear. Minor cleanup of jasper detection. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@581119 13f79535-47bb-0310-9956-ffa450edef68 --- .../action/reports/GenerateReportAction.java | 22 +++++---- ...portsAction.java => PickReportAction.java} | 31 ++++++++----- .../GenerateReportAction-validation.xml | 45 +++++++++++++++++++ .../src/main/resources/xwork.xml | 11 ++--- .../webapp/WEB-INF/jsp/decorators/default.jsp | 2 +- .../{showReports.jsp => pickReport.jsp} | 2 +- 6 files changed, 86 insertions(+), 27 deletions(-) rename archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/{ShowReportsAction.java => PickReportAction.java} (73%) create mode 100644 archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/reports/GenerateReportAction-validation.xml rename archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/{showReports.jsp => pickReport.jsp} (94%) diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java index b836ddc91..04a55adba 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java @@ -40,7 +40,7 @@ import java.util.ArrayList; import java.util.List; /** - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="generateReportAction" + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="generateReport" */ public class GenerateReportAction extends PlexusActionSupport @@ -55,7 +55,7 @@ public class GenerateReportAction protected HttpServletRequest request; - protected List reports = new ArrayList(); + protected List reports = new ArrayList(); protected String groupId; @@ -79,10 +79,10 @@ public class GenerateReportAction private static Boolean jasperPresent; - public String execute() + public String input() throws Exception { - List problemArtifacts = dao.getRepositoryProblemDAO().queryRepositoryProblems( configureConstraint() ); + List problemArtifacts = dao.getRepositoryProblemDAO().queryRepositoryProblems( configureConstraint() ); String contextPath = request.getRequestURL().substring( 0, request.getRequestURL().indexOf( request.getRequestURI() ) ); @@ -118,9 +118,9 @@ public class GenerateReportAction { return BLANK; } - else if ( !isJasperPresent() ) + else if ( isJasperPresent() ) { - return BASIC; + return "jasper"; } else { @@ -137,6 +137,10 @@ public class GenerateReportAction Class.forName( "net.sf.jasperreports.engine.JRExporterParameter" ); jasperPresent = Boolean.TRUE; } + catch ( NoClassDefFoundError e ) + { + jasperPresent = Boolean.FALSE; + } catch ( ClassNotFoundException e ) { jasperPresent = Boolean.FALSE; @@ -154,7 +158,7 @@ public class GenerateReportAction if ( groupId != null && ( !groupId.equals( "" ) ) ) { - if ( repositoryId != null && ( !repositoryId.equals( "" ) && !repositoryId.equals( ShowReportsAction.ALL_REPOSITORIES ) ) ) + if ( repositoryId != null && ( !repositoryId.equals( "" ) && !repositoryId.equals( PickReportAction.ALL_REPOSITORIES ) ) ) { constraint = new RepositoryProblemConstraint( range, groupId, repositoryId ); } @@ -163,7 +167,7 @@ public class GenerateReportAction constraint = new RepositoryProblemByGroupIdConstraint( range, groupId ); } } - else if ( repositoryId != null && ( !repositoryId.equals( "" ) && !repositoryId.equals( ShowReportsAction.ALL_REPOSITORIES ) ) ) + else if ( repositoryId != null && ( !repositoryId.equals( "" ) && !repositoryId.equals( PickReportAction.ALL_REPOSITORIES ) ) ) { constraint = new RepositoryProblemByRepositoryIdConstraint( range, repositoryId ); } @@ -180,7 +184,7 @@ public class GenerateReportAction this.request = request; } - public List getReports() + public List getReports() { return reports; } diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ShowReportsAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/PickReportAction.java similarity index 73% rename from archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ShowReportsAction.java rename to archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/PickReportAction.java index 2414d2f40..8ae78a2c7 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ShowReportsAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/PickReportAction.java @@ -19,6 +19,8 @@ package org.apache.maven.archiva.web.action.reports; * under the License. */ +import com.opensymphony.xwork.Preparable; + import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.constraints.UniqueFieldConstraint; import org.apache.maven.archiva.model.RepositoryProblem; @@ -28,33 +30,40 @@ import java.util.ArrayList; import java.util.Collection; /** - * Show reports. + * PickReportAction * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="showReportsAction" + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="pickReport" */ -public class ShowReportsAction +public class PickReportAction extends PlexusActionSupport + implements Preparable { /** * @plexus.requirement role-hint="jdo" */ protected ArchivaDAO dao; - private Collection repositoryIds = new ArrayList(); + private Collection repositoryIds = new ArrayList(); public static final String ALL_REPOSITORIES = "All Repositories"; - public String execute() - throws Exception + public void prepare() { repositoryIds.add( ALL_REPOSITORIES ); - repositoryIds.addAll( - dao.query( new UniqueFieldConstraint( RepositoryProblem.class.getName(), "repositoryId" ) ) ); - - return SUCCESS; + repositoryIds.addAll( dao + .query( new UniqueFieldConstraint( RepositoryProblem.class.getName(), "repositoryId" ) ) ); + } + + public String input() + throws Exception + { + return INPUT; } - public Collection getRepositoryIds() + public Collection getRepositoryIds() { return repositoryIds; } diff --git a/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/reports/GenerateReportAction-validation.xml b/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/reports/GenerateReportAction-validation.xml new file mode 100644 index 000000000..75e11aa55 --- /dev/null +++ b/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/reports/GenerateReportAction-validation.xml @@ -0,0 +1,45 @@ + + + + + + + + + 10 + 5000 + Row count must be between ${min} and ${max}. + + + + + + You must provide a repository id. + + + \ No newline at end of file diff --git a/archiva-web/archiva-webapp/src/main/resources/xwork.xml b/archiva-web/archiva-webapp/src/main/resources/xwork.xml index 1c9c05c92..9ad229f79 100644 --- a/archiva-web/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-web/archiva-webapp/src/main/resources/xwork.xml @@ -402,17 +402,18 @@ - - /WEB-INF/jsp/reports/showReports.jsp + + /WEB-INF/jsp/reports/pickReport.jsp - - + + /WEB-INF/jasperreports/report.jasper reports HTML - /WEB-INF/jsp/reports/basicReport.jsp + pickReport + /WEB-INF/jsp/reports/basicReport.jsp /WEB-INF/jsp/reports/blankReport.jsp diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp index af6593214..7396c3c7e 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp @@ -100,7 +100,7 @@
  • - Show Reports + Pick Report
  • <%-- POSTPONED to 1.1 series diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/showReports.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/pickReport.jsp similarity index 94% rename from archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/showReports.jsp rename to archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/pickReport.jsp index 589e40074..e1d039d97 100644 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/showReports.jsp +++ b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/pickReport.jsp @@ -30,7 +30,7 @@
    - +