]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1301] remove exception that is thrown and caught here only
authorBrett Porter <brett@apache.org>
Thu, 10 Dec 2009 13:42:22 +0000 (13:42 +0000)
committerBrett Porter <brett@apache.org>
Thu, 10 Dec 2009 13:42:22 +0000 (13:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@889260 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java

index 49724c86d53234972a31d5e05ee1fad4d6a16687..025e5a467a6794c874008c2fe5e8d5560a0d03e1 100644 (file)
@@ -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<RepositoryStatistics> 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<RepositoryStatistics> stats =
+                    repositoryStatisticsManager.getStatisticsInRange( repositoryId, startDateInDF, endDateInDF );
+
+                if ( stats.isEmpty() )
                 {
-                    List<RepositoryStatistics> 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<RepositoryStatistics> 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;