mirror of https://github.com/apache/archiva.git
[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
This commit is contained in:
parent
2ddcb71f37
commit
f4330d5248
|
@ -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<RepositoryProblemReport> reports = new ArrayList<RepositoryProblemReport>();
|
||||
|
||||
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<RepositoryProblem> 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<RepositoryProblemReport> getReports()
|
||||
{
|
||||
return reports;
|
||||
}
|
||||
|
|
|
@ -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 <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
|
||||
* @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<String> repositoryIds = new ArrayList<String>();
|
||||
|
||||
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 Collection getRepositoryIds()
|
||||
public String input()
|
||||
throws Exception
|
||||
{
|
||||
return INPUT;
|
||||
}
|
||||
|
||||
public Collection<String> getRepositoryIds()
|
||||
{
|
||||
return repositoryIds;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one
|
||||
~ or more contributor license agreements. See the NOTICE file
|
||||
~ distributed with this work for additional information
|
||||
~ regarding copyright ownership. The ASF licenses this file
|
||||
~ to you 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.
|
||||
-->
|
||||
|
||||
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
|
||||
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
|
||||
|
||||
<validators>
|
||||
<field name="rowCount">
|
||||
<field-validator type="int">
|
||||
<param name="min">10</param>
|
||||
<param name="max">5000</param>
|
||||
<message>Row count must be between ${min} and ${max}.</message>
|
||||
</field-validator>
|
||||
</field>
|
||||
<!--
|
||||
<field name="groupId">
|
||||
<field-validator type="regex">
|
||||
<param name="expression"><![CDATA[([a-zA-Z0-9]+[a-zA-Z0-9.]*)]]></param>
|
||||
<message>You must provide a valid group id.</message>
|
||||
</field-validator>
|
||||
</field>
|
||||
-->
|
||||
<field name="repositoryId">
|
||||
<field-validator type="requiredstring">
|
||||
<message>You must provide a repository id.</message>
|
||||
</field-validator>
|
||||
</field>
|
||||
</validators>
|
|
@ -402,17 +402,18 @@
|
|||
</package>
|
||||
|
||||
<package name="report" namespace="/report" extends="base">
|
||||
<action name="showReports" class="showReportsAction">
|
||||
<result>/WEB-INF/jsp/reports/showReports.jsp</result>
|
||||
<action name="pickReport" class="pickReport">
|
||||
<result>/WEB-INF/jsp/reports/pickReport.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="generateReportAction" class="generateReportAction">
|
||||
<result name="success" type="jasper">
|
||||
<action name="generateReport" class="generateReport">
|
||||
<result name="jasper" type="jasper">
|
||||
<param name="location">/WEB-INF/jasperreports/report.jasper</param>
|
||||
<param name="dataSource">reports</param>
|
||||
<param name="format">HTML</param>
|
||||
</result>
|
||||
<result name="basic">/WEB-INF/jsp/reports/basicReport.jsp</result>
|
||||
<result name="input" type="redirect-action">pickReport</result>
|
||||
<result name="success">/WEB-INF/jsp/reports/basicReport.jsp</result>
|
||||
<result name="blank">/WEB-INF/jsp/reports/blankReport.jsp</result>
|
||||
</action>
|
||||
</package>
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
<ul>
|
||||
<redback:ifAuthorized permission="archiva-access-reports">
|
||||
<li class="none">
|
||||
<my:currentWWUrl action="showReports" namespace="/report">Show Reports</my:currentWWUrl>
|
||||
<my:currentWWUrl action="pickReport" namespace="/report">Pick Report</my:currentWWUrl>
|
||||
</li>
|
||||
</redback:ifAuthorized>
|
||||
<%-- POSTPONED to 1.1 series
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
<div id="contentArea">
|
||||
|
||||
<ww:form action="generateReportAction" namespace="/report">
|
||||
<ww:form action="generateReport" namespace="/report" validate="true">
|
||||
<ww:textfield label="Row Count" name="rowCount" value="100"/>
|
||||
<ww:textfield label="Group ID" name="groupId"/>
|
||||
<ww:select label="Repository ID" name="repositoryId" list="repositoryIds"/>
|
Loading…
Reference in New Issue