From: Brett Porter Date: Thu, 10 Dec 2009 13:42:22 +0000 (+0000) Subject: [MRM-1301] remove exception that is thrown and caught here only X-Git-Tag: archiva-1.4-M1~1017^2~74 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7da14962fa313809e961ffd1d248260b146b1045;p=archiva.git [MRM-1301] remove exception that is thrown and caught here only git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@889260 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java index 49724c86d..025e5a467 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java @@ -49,7 +49,6 @@ import org.apache.maven.archiva.database.constraints.RepositoryProblemConstraint import org.apache.maven.archiva.database.constraints.UniqueFieldConstraint; import org.apache.maven.archiva.model.RepositoryProblem; import org.apache.maven.archiva.model.RepositoryProblemReport; -import org.apache.maven.archiva.reporting.ArchivaReportException; import org.apache.maven.archiva.security.ArchivaRoleConstants; import org.apache.maven.archiva.web.action.PlexusActionSupport; import org.apache.struts2.interceptor.ServletRequestAware; @@ -171,113 +170,107 @@ public class GenerateReportAction addFieldError( "rowCount", "Row count must be larger than 10." ); return INPUT; } - try + Date startDateInDF; + Date endDateInDF; + + if ( selectedRepositories.size() > 1 ) { - Date startDateInDF; - Date endDateInDF; + numPages = 1; - if ( selectedRepositories.size() > 1 ) + try { - numPages = 1; + startDateInDF = getStartDateInDateFormat(); + endDateInDF = getEndDateInDateFormat(); + } + catch ( ParseException e ) + { + addActionError( "Error parsing date(s)." ); + return ERROR; + } - try - { - startDateInDF = getStartDateInDateFormat(); - endDateInDF = getEndDateInDateFormat(); - } - catch ( ParseException e ) + if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) ) + { + addFieldError( "startDate", "Start Date must be earlier than the End Date" ); + return INPUT; + } + + // multiple repos + for ( String repo : selectedRepositories ) + { + List stats = + repositoryStatisticsManager.getStatisticsInRange( repo, startDateInDF, endDateInDF ); + if ( stats.isEmpty() ) { - addActionError( "Error parsing date(s)." ); - return ERROR; + log.info( "No statistics available for repository '" + repo + "'." ); + // TODO set repo's stats to 0 + continue; } + repositoryStatistics.add( stats.get( 0 ) ); + } + } + else if ( selectedRepositories.size() == 1 ) + { + repositoryId = selectedRepositories.get( 0 ); + try + { + startDateInDF = getStartDateInDateFormat(); + endDateInDF = getEndDateInDateFormat(); + if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) ) { addFieldError( "startDate", "Start Date must be earlier than the End Date" ); return INPUT; } - // multiple repos - for ( String repo : selectedRepositories ) + List stats = + repositoryStatisticsManager.getStatisticsInRange( repositoryId, startDateInDF, endDateInDF ); + + if ( stats.isEmpty() ) { - List stats = - repositoryStatisticsManager.getStatisticsInRange( repo, startDateInDF, endDateInDF ); - if ( stats.isEmpty() ) - { - log.info( "No statistics available for repository '" + repo + "'." ); - // TODO set repo's stats to 0 - continue; - } - - repositoryStatistics.add( stats.get( 0 ) ); + addActionError( + "No statistics available for repository. Repository might not have been scanned." ); + return ERROR; } - } - else if ( selectedRepositories.size() == 1 ) - { - repositoryId = selectedRepositories.get( 0 ); - try + + int rowCount = getRowCount(); + int extraPage = ( stats.size() % rowCount ) != 0 ? 1 : 0; + int totalPages = ( stats.size() / rowCount ) + extraPage; + numPages = totalPages; + + int currentPage = getPage(); + if ( currentPage > totalPages ) { - startDateInDF = getStartDateInDateFormat(); - endDateInDF = getEndDateInDateFormat(); - - if ( startDateInDF != null && endDateInDF != null && startDateInDF.after( endDateInDF ) ) - { - addFieldError( "startDate", "Start Date must be earlier than the End Date" ); - return INPUT; - } - - List stats = - repositoryStatisticsManager.getStatisticsInRange( repositoryId, startDateInDF, endDateInDF ); - - if ( stats.isEmpty() ) - { - addActionError( - "No statistics available for repository. Repository might not have been scanned." ); - return ERROR; - } - - int rowCount = getRowCount(); - int extraPage = ( stats.size() % rowCount ) != 0 ? 1 : 0; - int totalPages = ( stats.size() / rowCount ) + extraPage; - numPages = totalPages; - - int currentPage = getPage(); - if ( currentPage > totalPages ) - { - throw new ArchivaReportException( "The requested page exceeds the total number of pages." ); - } - - int start = rowCount * ( currentPage - 1 ); - int end = ( start + rowCount ) - 1; - - if ( end > stats.size() ) - { - end = stats.size() - 1; - } - - repositoryStatistics = stats.subList( start, end + 1 ); + addActionError( + "Error encountered while generating report :: The requested page exceeds the total number of pages." ); + return ERROR; } - catch ( ParseException pe ) + + int start = rowCount * ( currentPage - 1 ); + int end = ( start + rowCount ) - 1; + + if ( end > stats.size() ) { - addActionError( pe.getMessage() ); - return ERROR; + end = stats.size() - 1; } - } - else - { - addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." ); - return INPUT; - } - if ( repositoryStatistics.isEmpty() ) + repositoryStatistics = stats.subList( start, end + 1 ); + } + catch ( ParseException pe ) { - return BLANK; + addActionError( pe.getMessage() ); + return ERROR; } } - catch ( ArchivaReportException e ) + else { - addActionError( "Error encountered while generating report :: " + e.getMessage() ); - return ERROR; + addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." ); + return INPUT; + } + + if ( repositoryStatistics.isEmpty() ) + { + return BLANK; } return SUCCESS;