mirror of https://github.com/apache/archiva.git
formatting only
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@886673 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
94ece43b50
commit
fc37f62c5c
|
@ -114,55 +114,55 @@ public class GenerateReportAction
|
||||||
private Collection<String> repositoryIds;
|
private Collection<String> repositoryIds;
|
||||||
|
|
||||||
public static final String ALL_REPOSITORIES = "All Repositories";
|
public static final String ALL_REPOSITORIES = "All Repositories";
|
||||||
|
|
||||||
protected Map<String, List<RepositoryProblemReport>> repositoriesMap =
|
protected Map<String, List<RepositoryProblemReport>> repositoriesMap =
|
||||||
new TreeMap<String, List<RepositoryProblemReport>>();
|
new TreeMap<String, List<RepositoryProblemReport>>();
|
||||||
|
|
||||||
// for statistics report
|
// for statistics report
|
||||||
/**
|
/**
|
||||||
* @plexus.requirement role-hint="simple"
|
* @plexus.requirement role-hint="simple"
|
||||||
*/
|
*/
|
||||||
private RepositoryStatisticsReportGenerator generator;
|
private RepositoryStatisticsReportGenerator generator;
|
||||||
|
|
||||||
private List<String> selectedRepositories = new ArrayList<String>();
|
private List<String> selectedRepositories = new ArrayList<String>();
|
||||||
|
|
||||||
private List<String> availableRepositories;
|
private List<String> availableRepositories;
|
||||||
|
|
||||||
private String startDate;
|
private String startDate;
|
||||||
|
|
||||||
private String endDate;
|
private String endDate;
|
||||||
|
|
||||||
private int reposSize;
|
private int reposSize;
|
||||||
|
|
||||||
private String selectedRepo;
|
private String selectedRepo;
|
||||||
|
|
||||||
private List<RepositoryStatistics> repositoryStatistics = new ArrayList<RepositoryStatistics>();
|
private List<RepositoryStatistics> repositoryStatistics = new ArrayList<RepositoryStatistics>();
|
||||||
|
|
||||||
private DataLimits limits = new DataLimits();
|
private DataLimits limits = new DataLimits();
|
||||||
|
|
||||||
private String[] datePatterns = new String[] { "MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy",
|
private String[] datePatterns =
|
||||||
"dd MMMMM yyyy", "dd/MM/yy", "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy",
|
new String[]{"MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy", "MMMMM/dd/yy", "dd MMMMM yyyy", "dd/MM/yy",
|
||||||
"MM-dd-yy" };
|
"dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM", "MM-dd-yyyy", "MM-dd-yy"};
|
||||||
|
|
||||||
public static final String SEND_FILE = "send-file";
|
public static final String SEND_FILE = "send-file";
|
||||||
|
|
||||||
private InputStream inputStream;
|
private InputStream inputStream;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void prepare()
|
public void prepare()
|
||||||
{
|
{
|
||||||
repositoryIds = new ArrayList<String>();
|
repositoryIds = new ArrayList<String>();
|
||||||
repositoryIds.add( ALL_REPOSITORIES ); // comes first to be first in the list
|
repositoryIds.add( ALL_REPOSITORIES ); // comes first to be first in the list
|
||||||
repositoryIds.addAll( (List<String>) dao.query( new UniqueFieldConstraint( RepositoryProblem.class.getName(),
|
repositoryIds.addAll( (List<String>) dao.query(
|
||||||
"repositoryId" ) ) );
|
new UniqueFieldConstraint( RepositoryProblem.class.getName(), "repositoryId" ) ) );
|
||||||
|
|
||||||
availableRepositories = new ArrayList<String>();
|
availableRepositories = new ArrayList<String>();
|
||||||
|
|
||||||
// remove selected repositories in the option for the statistics report
|
// remove selected repositories in the option for the statistics report
|
||||||
availableRepositories.addAll( archivaConfiguration.getConfiguration().getManagedRepositoriesAsMap().keySet() );
|
availableRepositories.addAll( archivaConfiguration.getConfiguration().getManagedRepositoriesAsMap().keySet() );
|
||||||
for( String repo : selectedRepositories )
|
for ( String repo : selectedRepositories )
|
||||||
{
|
{
|
||||||
if( availableRepositories.contains( repo ) )
|
if ( availableRepositories.contains( repo ) )
|
||||||
{
|
{
|
||||||
availableRepositories.remove( repo );
|
availableRepositories.remove( repo );
|
||||||
}
|
}
|
||||||
|
@ -176,95 +176,99 @@ public class GenerateReportAction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the statistics report.
|
* Generate the statistics report.
|
||||||
*
|
*
|
||||||
* check whether single repo report or comparison report
|
* check whether single repo report or comparison report
|
||||||
* 1. if it is a single repository, get all the statistics for the repository on the specified date
|
* 1. if it is a single repository, get all the statistics for the repository on the specified date
|
||||||
* - if no date is specified, get only the latest
|
* - if no date is specified, get only the latest
|
||||||
* (total page = 1 --> no pagination since only the most recent stats will be displayed)
|
* (total page = 1 --> no pagination since only the most recent stats will be displayed)
|
||||||
* - otherwise, get everything within the date range (total pages = repo stats / rows per page)
|
* - otherwise, get everything within the date range (total pages = repo stats / rows per page)
|
||||||
* - required params: repository, startDate, endDate
|
* - required params: repository, startDate, endDate
|
||||||
*
|
*
|
||||||
* 2. if multiple repositories, get the latest statistics on each repository on the specified date
|
* 2. if multiple repositories, get the latest statistics on each repository on the specified date
|
||||||
* - if no date is specified, use the current date endDate
|
* - if no date is specified, use the current date endDate
|
||||||
* - required params: repositories, endDate
|
* - required params: repositories, endDate
|
||||||
* - total pages = repositories / rows per page
|
* - total pages = repositories / rows per page
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String generateStatistics()
|
public String generateStatistics()
|
||||||
{
|
{
|
||||||
if( rowCount < 10 )
|
if ( rowCount < 10 )
|
||||||
{
|
{
|
||||||
addFieldError( "rowCount", "Row count must be larger than 10." );
|
addFieldError( "rowCount", "Row count must be larger than 10." );
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
reposSize = selectedRepositories.size();
|
reposSize = selectedRepositories.size();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RepositoryContentStatisticsDAO repoContentStatsDao = dao.getRepositoryContentStatisticsDAO();
|
RepositoryContentStatisticsDAO repoContentStatsDao = dao.getRepositoryContentStatisticsDAO();
|
||||||
Date startDateInDF = null;
|
Date startDateInDF = null;
|
||||||
Date endDateInDF = null;
|
Date endDateInDF = null;
|
||||||
|
|
||||||
if( selectedRepositories.size() > 1 )
|
if ( selectedRepositories.size() > 1 )
|
||||||
{
|
{
|
||||||
limits.setTotalCount( selectedRepositories.size() );
|
limits.setTotalCount( selectedRepositories.size() );
|
||||||
limits.setCurrentPage( 1 );
|
limits.setCurrentPage( 1 );
|
||||||
limits.setPerPageCount( 1 );
|
limits.setPerPageCount( 1 );
|
||||||
limits.setCountOfPages( 1 );
|
limits.setCountOfPages( 1 );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
startDateInDF = getStartDateInDateFormat();
|
startDateInDF = getStartDateInDateFormat();
|
||||||
endDateInDF = getEndDateInDateFormat();
|
endDateInDF = getEndDateInDateFormat();
|
||||||
}
|
}
|
||||||
catch ( ParseException e )
|
catch ( ParseException e )
|
||||||
{
|
{
|
||||||
addActionError( "Error parsing date(s)." );
|
addActionError( "Error parsing date(s)." );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( startDateInDF.after( endDateInDF ) )
|
if ( startDateInDF.after( endDateInDF ) )
|
||||||
{
|
{
|
||||||
addFieldError( "startDate", "Start Date must be earlier than the End Date" );
|
addFieldError( "startDate", "Start Date must be earlier than the End Date" );
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// multiple repos
|
// multiple repos
|
||||||
generateReportForMultipleRepos(repoContentStatsDao, startDateInDF, endDateInDF, true);
|
generateReportForMultipleRepos( repoContentStatsDao, startDateInDF, endDateInDF, true );
|
||||||
}
|
}
|
||||||
else if ( selectedRepositories.size() == 1 )
|
else if ( selectedRepositories.size() == 1 )
|
||||||
{
|
{
|
||||||
limits.setCurrentPage( getPage() );
|
limits.setCurrentPage( getPage() );
|
||||||
limits.setPerPageCount( getRowCount() );
|
limits.setPerPageCount( getRowCount() );
|
||||||
|
|
||||||
selectedRepo = selectedRepositories.get( 0 );
|
selectedRepo = selectedRepositories.get( 0 );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
startDateInDF = getStartDateInDateFormat();
|
startDateInDF = getStartDateInDateFormat();
|
||||||
endDateInDF = getEndDateInDateFormat();
|
endDateInDF = getEndDateInDateFormat();
|
||||||
|
|
||||||
if( startDateInDF.after( endDateInDF ) )
|
if ( startDateInDF.after( endDateInDF ) )
|
||||||
{
|
{
|
||||||
addFieldError( "startDate", "Start Date must be earlier than the End Date" );
|
addFieldError( "startDate", "Start Date must be earlier than the End Date" );
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<RepositoryContentStatistics> contentStats = repoContentStatsDao.queryRepositoryContentStatistics(
|
List<RepositoryContentStatistics> contentStats =
|
||||||
new RepositoryContentStatisticsByRepositoryConstraint( selectedRepo, startDateInDF, endDateInDF ) );
|
repoContentStatsDao.queryRepositoryContentStatistics(
|
||||||
|
new RepositoryContentStatisticsByRepositoryConstraint( selectedRepo, startDateInDF,
|
||||||
if( contentStats == null || contentStats.isEmpty() )
|
endDateInDF ) );
|
||||||
{
|
|
||||||
addActionError( "No statistics available for repository. Repository might not have been scanned." );
|
if ( contentStats == null || contentStats.isEmpty() )
|
||||||
|
{
|
||||||
|
addActionError(
|
||||||
|
"No statistics available for repository. Repository might not have been scanned." );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
limits.setTotalCount( contentStats.size() );
|
limits.setTotalCount( contentStats.size() );
|
||||||
int extraPage = ( limits.getTotalCount() % limits.getPerPageCount() ) != 0 ? 1 : 0;
|
int extraPage = ( limits.getTotalCount() % limits.getPerPageCount() ) != 0 ? 1 : 0;
|
||||||
int totalPages = ( limits.getTotalCount() / limits.getPerPageCount() ) + extraPage;
|
int totalPages = ( limits.getTotalCount() / limits.getPerPageCount() ) + extraPage;
|
||||||
limits.setCountOfPages( totalPages );
|
limits.setCountOfPages( totalPages );
|
||||||
|
|
||||||
repositoryStatistics = generator.generateReport( contentStats, selectedRepo, startDateInDF, endDateInDF, limits );
|
repositoryStatistics =
|
||||||
|
generator.generateReport( contentStats, selectedRepo, startDateInDF, endDateInDF, limits );
|
||||||
}
|
}
|
||||||
catch ( ObjectNotFoundException oe )
|
catch ( ObjectNotFoundException oe )
|
||||||
{
|
{
|
||||||
|
@ -278,92 +282,96 @@ public class GenerateReportAction
|
||||||
}
|
}
|
||||||
catch ( ParseException pe )
|
catch ( ParseException pe )
|
||||||
{
|
{
|
||||||
addActionError( pe.getMessage() );
|
addActionError( pe.getMessage() );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." );
|
addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." );
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( repositoryStatistics.isEmpty() )
|
if ( repositoryStatistics.isEmpty() )
|
||||||
{
|
{
|
||||||
return BLANK;
|
return BLANK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( ArchivaReportException e )
|
catch ( ArchivaReportException e )
|
||||||
{
|
{
|
||||||
addActionError( "Error encountered while generating report :: " + e.getMessage() );
|
addActionError( "Error encountered while generating report :: " + e.getMessage() );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Export report to CSV.
|
* Export report to CSV.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String downloadStatisticsReport()
|
public String downloadStatisticsReport()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Date startDateInDF = null;
|
Date startDateInDF = null;
|
||||||
Date endDateInDF = null;
|
Date endDateInDF = null;
|
||||||
|
|
||||||
selectedRepositories = parseSelectedRepositories();
|
selectedRepositories = parseSelectedRepositories();
|
||||||
repositoryStatistics = new ArrayList<RepositoryStatistics>();
|
repositoryStatistics = new ArrayList<RepositoryStatistics>();
|
||||||
|
|
||||||
RepositoryContentStatisticsDAO repoContentStatsDao = dao.getRepositoryContentStatisticsDAO();
|
RepositoryContentStatisticsDAO repoContentStatsDao = dao.getRepositoryContentStatisticsDAO();
|
||||||
if( selectedRepositories.size() > 1 )
|
if ( selectedRepositories.size() > 1 )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
startDateInDF = getStartDateInDateFormat();
|
startDateInDF = getStartDateInDateFormat();
|
||||||
endDateInDF = getEndDateInDateFormat();
|
endDateInDF = getEndDateInDateFormat();
|
||||||
}
|
}
|
||||||
catch ( ParseException e )
|
catch ( ParseException e )
|
||||||
{
|
{
|
||||||
addActionError( "Error parsing date(s)." );
|
addActionError( "Error parsing date(s)." );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( startDateInDF.after( endDateInDF ) )
|
if ( startDateInDF.after( endDateInDF ) )
|
||||||
{
|
{
|
||||||
addFieldError( "startDate", "Start Date must be earlier than the End Date" );
|
addFieldError( "startDate", "Start Date must be earlier than the End Date" );
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// multiple repos
|
// multiple repos
|
||||||
generateReportForMultipleRepos( repoContentStatsDao, startDateInDF, endDateInDF, false );
|
generateReportForMultipleRepos( repoContentStatsDao, startDateInDF, endDateInDF, false );
|
||||||
}
|
}
|
||||||
else if ( selectedRepositories.size() == 1 )
|
else if ( selectedRepositories.size() == 1 )
|
||||||
{
|
{
|
||||||
selectedRepo = selectedRepositories.get( 0 );
|
selectedRepo = selectedRepositories.get( 0 );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
startDateInDF = getStartDateInDateFormat();
|
startDateInDF = getStartDateInDateFormat();
|
||||||
endDateInDF = getEndDateInDateFormat();
|
endDateInDF = getEndDateInDateFormat();
|
||||||
|
|
||||||
if( startDateInDF.after( endDateInDF ) )
|
if ( startDateInDF.after( endDateInDF ) )
|
||||||
{
|
{
|
||||||
addFieldError( "startDate", "Start Date must be earlier than the End Date" );
|
addFieldError( "startDate", "Start Date must be earlier than the End Date" );
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<RepositoryContentStatistics> contentStats = repoContentStatsDao.queryRepositoryContentStatistics(
|
List<RepositoryContentStatistics> contentStats =
|
||||||
new RepositoryContentStatisticsByRepositoryConstraint( selectedRepo, startDateInDF, endDateInDF ) );
|
repoContentStatsDao.queryRepositoryContentStatistics(
|
||||||
|
new RepositoryContentStatisticsByRepositoryConstraint( selectedRepo, startDateInDF,
|
||||||
if( contentStats == null || contentStats.isEmpty() )
|
endDateInDF ) );
|
||||||
{
|
|
||||||
addActionError( "No statistics available for repository. Repository might not have been scanned." );
|
if ( contentStats == null || contentStats.isEmpty() )
|
||||||
|
{
|
||||||
|
addActionError(
|
||||||
|
"No statistics available for repository. Repository might not have been scanned." );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
repositoryStatistics = generator.generateReport( contentStats, selectedRepo, startDateInDF, endDateInDF, false );
|
repositoryStatistics =
|
||||||
|
generator.generateReport( contentStats, selectedRepo, startDateInDF, endDateInDF, false );
|
||||||
}
|
}
|
||||||
catch ( ObjectNotFoundException oe )
|
catch ( ObjectNotFoundException oe )
|
||||||
{
|
{
|
||||||
|
@ -377,56 +385,56 @@ public class GenerateReportAction
|
||||||
}
|
}
|
||||||
catch ( ParseException pe )
|
catch ( ParseException pe )
|
||||||
{
|
{
|
||||||
addActionError( pe.getMessage() );
|
addActionError( pe.getMessage() );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." );
|
addFieldError( "availableRepositories", "Please select a repository (or repositories) from the list." );
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( repositoryStatistics.isEmpty() )
|
if ( repositoryStatistics.isEmpty() )
|
||||||
{
|
{
|
||||||
return BLANK;
|
return BLANK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( ArchivaReportException e )
|
catch ( ArchivaReportException e )
|
||||||
{
|
{
|
||||||
addActionError( "Error encountered while generating report :: " + e.getMessage() );
|
addActionError( "Error encountered while generating report :: " + e.getMessage() );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write output stream depending on single or comparison report
|
// write output stream depending on single or comparison report
|
||||||
StringBuffer input = getInput();
|
StringBuffer input = getInput();
|
||||||
StringReader reader = new StringReader( input.toString() );
|
StringReader reader = new StringReader( input.toString() );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
inputStream = new ByteArrayInputStream( IOUtils.toByteArray( reader ) );
|
inputStream = new ByteArrayInputStream( IOUtils.toByteArray( reader ) );
|
||||||
}
|
}
|
||||||
catch ( IOException i )
|
catch ( IOException i )
|
||||||
{
|
{
|
||||||
addActionError( "Error occurred while generating CSV file." );
|
addActionError( "Error occurred while generating CSV file." );
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SEND_FILE;
|
return SEND_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack for parsing the struts list passed as param in <s:url ../>
|
// hack for parsing the struts list passed as param in <s:url ../>
|
||||||
private List<String> parseSelectedRepositories()
|
private List<String> parseSelectedRepositories()
|
||||||
{
|
{
|
||||||
List<String> pasedSelectedRepos = new ArrayList<String>();
|
List<String> pasedSelectedRepos = new ArrayList<String>();
|
||||||
|
|
||||||
for( String repo : selectedRepositories )
|
for ( String repo : selectedRepositories )
|
||||||
{
|
{
|
||||||
String[] tokens = StringUtils.split( repo, ',' );
|
String[] tokens = StringUtils.split( repo, ',' );
|
||||||
if( tokens.length > 1 )
|
if ( tokens.length > 1 )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < tokens.length; i++ )
|
for ( int i = 0; i < tokens.length; i++ )
|
||||||
{
|
{
|
||||||
pasedSelectedRepos.add( StringUtils.remove( StringUtils.remove( tokens[i], '[' ), ']' ).trim() );
|
pasedSelectedRepos.add( StringUtils.remove( StringUtils.remove( tokens[i], '[' ), ']' ).trim() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -438,16 +446,16 @@ public class GenerateReportAction
|
||||||
return pasedSelectedRepos;
|
return pasedSelectedRepos;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateReportForMultipleRepos( RepositoryContentStatisticsDAO repoContentStatsDao,
|
private void generateReportForMultipleRepos( RepositoryContentStatisticsDAO repoContentStatsDao, Date startDateInDF,
|
||||||
Date startDateInDF, Date endDateInDF, boolean useLimits )
|
Date endDateInDF, boolean useLimits )
|
||||||
throws ArchivaReportException
|
throws ArchivaReportException
|
||||||
{
|
{
|
||||||
for ( String repo : selectedRepositories )
|
for ( String repo : selectedRepositories )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<RepositoryContentStatistics> contentStats = repoContentStatsDao.queryRepositoryContentStatistics(
|
List<RepositoryContentStatistics> contentStats = repoContentStatsDao.queryRepositoryContentStatistics(
|
||||||
new RepositoryContentStatisticsByRepositoryConstraint( repo, startDateInDF, endDateInDF ) );
|
new RepositoryContentStatisticsByRepositoryConstraint( repo, startDateInDF, endDateInDF ) );
|
||||||
|
|
||||||
if ( contentStats == null || contentStats.isEmpty() )
|
if ( contentStats == null || contentStats.isEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -455,15 +463,16 @@ public class GenerateReportAction
|
||||||
// TODO set repo's stats to 0
|
// TODO set repo's stats to 0
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( useLimits )
|
if ( useLimits )
|
||||||
{
|
{
|
||||||
repositoryStatistics.addAll( generator.generateReport( contentStats, repo, startDateInDF, endDateInDF,
|
repositoryStatistics.addAll(
|
||||||
limits ) );
|
generator.generateReport( contentStats, repo, startDateInDF, endDateInDF, limits ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
repositoryStatistics.addAll( generator.generateReport( contentStats, repo, startDateInDF, endDateInDF, true ) );
|
repositoryStatistics.addAll(
|
||||||
|
generator.generateReport( contentStats, repo, startDateInDF, endDateInDF, true ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( ObjectNotFoundException oe )
|
catch ( ObjectNotFoundException oe )
|
||||||
|
@ -506,89 +515,91 @@ public class GenerateReportAction
|
||||||
{
|
{
|
||||||
endDateInDF = DateUtils.parseDate( endDate, datePatterns );
|
endDateInDF = DateUtils.parseDate( endDate, datePatterns );
|
||||||
}
|
}
|
||||||
|
|
||||||
return endDateInDF;
|
return endDateInDF;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringBuffer getInput()
|
private StringBuffer getInput()
|
||||||
{
|
{
|
||||||
StringBuffer input = null;
|
StringBuffer input = null;
|
||||||
|
|
||||||
if( selectedRepositories.size() == 1 )
|
if ( selectedRepositories.size() == 1 )
|
||||||
{
|
|
||||||
input = new StringBuffer( "Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count," +
|
|
||||||
"Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" );
|
|
||||||
|
|
||||||
for( RepositoryStatistics stats : repositoryStatistics )
|
|
||||||
{
|
|
||||||
input.append( stats.getDateOfScan() ).append( "," );
|
|
||||||
input.append( stats.getFileCount() ).append( "," );
|
|
||||||
input.append( stats.getTotalSize() ).append( "," );
|
|
||||||
input.append( stats.getArtifactCount() ).append( "," );
|
|
||||||
input.append( stats.getGroupCount() ).append( "," );
|
|
||||||
input.append( stats.getProjectCount() ).append( "," );
|
|
||||||
input.append( stats.getPluginCount() ).append( "," );
|
|
||||||
input.append( stats.getArchetypeCount() ).append( "," );
|
|
||||||
input.append( stats.getJarCount() ).append( "," );
|
|
||||||
input.append( stats.getWarCount() ).append( "," );
|
|
||||||
input.append( stats.getDeploymentCount() ).append( "," );
|
|
||||||
input.append( stats.getDownloadCount() ).append( "\n" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( selectedRepositories.size() > 1 )
|
|
||||||
{
|
{
|
||||||
input = new StringBuffer( "Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count," +
|
input = new StringBuffer(
|
||||||
"Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" );
|
"Date of Scan,Total File Count,Total Size,Artifact Count,Group Count,Project Count," +
|
||||||
|
"Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" );
|
||||||
for( RepositoryStatistics stats : repositoryStatistics )
|
|
||||||
{
|
for ( RepositoryStatistics stats : repositoryStatistics )
|
||||||
input.append( stats.getRepositoryId() ).append( "," );
|
{
|
||||||
input.append( stats.getFileCount() ).append( "," );
|
input.append( stats.getDateOfScan() ).append( "," );
|
||||||
input.append( stats.getTotalSize() ).append( "," );
|
input.append( stats.getFileCount() ).append( "," );
|
||||||
input.append( stats.getArtifactCount() ).append( "," );
|
input.append( stats.getTotalSize() ).append( "," );
|
||||||
input.append( stats.getGroupCount() ).append( "," );
|
input.append( stats.getArtifactCount() ).append( "," );
|
||||||
input.append( stats.getProjectCount() ).append( "," );
|
input.append( stats.getGroupCount() ).append( "," );
|
||||||
input.append( stats.getPluginCount() ).append( "," );
|
input.append( stats.getProjectCount() ).append( "," );
|
||||||
input.append( stats.getArchetypeCount() ).append( "," );
|
input.append( stats.getPluginCount() ).append( "," );
|
||||||
input.append( stats.getJarCount() ).append( "," );
|
input.append( stats.getArchetypeCount() ).append( "," );
|
||||||
input.append( stats.getWarCount() ).append( "," );
|
input.append( stats.getJarCount() ).append( "," );
|
||||||
input.append( stats.getDeploymentCount() ).append( "," );
|
input.append( stats.getWarCount() ).append( "," );
|
||||||
input.append( stats.getDownloadCount() ).append( "\n" );
|
input.append( stats.getDeploymentCount() ).append( "," );
|
||||||
}
|
input.append( stats.getDownloadCount() ).append( "\n" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if ( selectedRepositories.size() > 1 )
|
||||||
|
{
|
||||||
|
input = new StringBuffer(
|
||||||
|
"Repository,Total File Count,Total Size,Artifact Count,Group Count,Project Count," +
|
||||||
|
"Plugins,Archetypes,Jars,Wars,Deployments,Downloads\n" );
|
||||||
|
|
||||||
|
for ( RepositoryStatistics stats : repositoryStatistics )
|
||||||
|
{
|
||||||
|
input.append( stats.getRepositoryId() ).append( "," );
|
||||||
|
input.append( stats.getFileCount() ).append( "," );
|
||||||
|
input.append( stats.getTotalSize() ).append( "," );
|
||||||
|
input.append( stats.getArtifactCount() ).append( "," );
|
||||||
|
input.append( stats.getGroupCount() ).append( "," );
|
||||||
|
input.append( stats.getProjectCount() ).append( "," );
|
||||||
|
input.append( stats.getPluginCount() ).append( "," );
|
||||||
|
input.append( stats.getArchetypeCount() ).append( "," );
|
||||||
|
input.append( stats.getJarCount() ).append( "," );
|
||||||
|
input.append( stats.getWarCount() ).append( "," );
|
||||||
|
input.append( stats.getDeploymentCount() ).append( "," );
|
||||||
|
input.append( stats.getDownloadCount() ).append( "\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date getDefaultStartDate()
|
private Date getDefaultStartDate()
|
||||||
{
|
{
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
cal.clear();
|
cal.clear();
|
||||||
cal.set( 1900, 1, 1, 0, 0, 0 );
|
cal.set( 1900, 1, 1, 0, 0, 0 );
|
||||||
|
|
||||||
return cal.getTime();
|
return cal.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date getDefaultEndDate()
|
private Date getDefaultEndDate()
|
||||||
{
|
{
|
||||||
return Calendar.getInstance().getTime();
|
return Calendar.getInstance().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String execute()
|
public String execute()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
if( repositoryId == null )
|
if ( repositoryId == null )
|
||||||
{
|
{
|
||||||
addFieldError( "repositoryId", "You must provide a repository id.");
|
addFieldError( "repositoryId", "You must provide a repository id." );
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rowCount < 10 )
|
if ( rowCount < 10 )
|
||||||
{
|
{
|
||||||
addFieldError( "rowCount", "Row count must be larger than 10." );
|
addFieldError( "rowCount", "Row count must be larger than 10." );
|
||||||
return INPUT;
|
return INPUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<RepositoryProblem> problemArtifacts =
|
List<RepositoryProblem> problemArtifacts =
|
||||||
dao.getRepositoryProblemDAO().queryRepositoryProblems( configureConstraint() );
|
dao.getRepositoryProblemDAO().queryRepositoryProblems( configureConstraint() );
|
||||||
|
|
||||||
|
@ -606,11 +617,11 @@ public class GenerateReportAction
|
||||||
contextPath + "/browse/" + problemArtifact.getGroupId() + "/" + problemArtifact.getArtifactId() );
|
contextPath + "/browse/" + problemArtifact.getGroupId() + "/" + problemArtifact.getArtifactId() );
|
||||||
|
|
||||||
addToList( problemArtifactReport );
|
addToList( problemArtifactReport );
|
||||||
|
|
||||||
// retained the reports list because this is the datasource for the jasper report
|
// retained the reports list because this is the datasource for the jasper report
|
||||||
reports.add( problemArtifactReport );
|
reports.add( problemArtifactReport );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( reports.size() <= rowCount )
|
if ( reports.size() <= rowCount )
|
||||||
{
|
{
|
||||||
isLastPage = true;
|
isLastPage = true;
|
||||||
|
@ -638,7 +649,7 @@ public class GenerateReportAction
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isJasperPresent()
|
private static boolean isJasperPresent()
|
||||||
{
|
{
|
||||||
if ( jasperPresent == null )
|
if ( jasperPresent == null )
|
||||||
|
@ -689,32 +700,32 @@ public class GenerateReportAction
|
||||||
|
|
||||||
return constraint;
|
return constraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecureActionBundle getSecureActionBundle()
|
public SecureActionBundle getSecureActionBundle()
|
||||||
throws SecureActionException
|
throws SecureActionException
|
||||||
{
|
{
|
||||||
SecureActionBundle bundle = new SecureActionBundle();
|
SecureActionBundle bundle = new SecureActionBundle();
|
||||||
|
|
||||||
bundle.setRequiresAuthentication( true );
|
bundle.setRequiresAuthentication( true );
|
||||||
bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_ACCESS_REPORT, Resource.GLOBAL );
|
bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_ACCESS_REPORT, Resource.GLOBAL );
|
||||||
|
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToList( RepositoryProblemReport repoProblemReport )
|
private void addToList( RepositoryProblemReport repoProblemReport )
|
||||||
{
|
{
|
||||||
List<RepositoryProblemReport> problemsList = null;
|
List<RepositoryProblemReport> problemsList = null;
|
||||||
|
|
||||||
if ( repositoriesMap.containsKey( repoProblemReport.getRepositoryId() ) )
|
if ( repositoriesMap.containsKey( repoProblemReport.getRepositoryId() ) )
|
||||||
{
|
{
|
||||||
problemsList = ( List<RepositoryProblemReport> ) repositoriesMap.get( repoProblemReport.getRepositoryId() );
|
problemsList = (List<RepositoryProblemReport>) repositoriesMap.get( repoProblemReport.getRepositoryId() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
problemsList = new ArrayList<RepositoryProblemReport>();
|
problemsList = new ArrayList<RepositoryProblemReport>();
|
||||||
repositoriesMap.put( repoProblemReport.getRepositoryId(), problemsList );
|
repositoriesMap.put( repoProblemReport.getRepositoryId(), problemsList );
|
||||||
}
|
}
|
||||||
|
|
||||||
problemsList.add( repoProblemReport );
|
problemsList.add( repoProblemReport );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,14 +796,14 @@ public class GenerateReportAction
|
||||||
|
|
||||||
public void setRepositoriesMap( Map<String, List<RepositoryProblemReport>> repositoriesMap )
|
public void setRepositoriesMap( Map<String, List<RepositoryProblemReport>> repositoriesMap )
|
||||||
{
|
{
|
||||||
this.repositoriesMap = repositoriesMap;
|
this.repositoriesMap = repositoriesMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, List<RepositoryProblemReport>> getRepositoriesMap()
|
public Map<String, List<RepositoryProblemReport>> getRepositoriesMap()
|
||||||
{
|
{
|
||||||
return repositoriesMap;
|
return repositoriesMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSelectedRepositories()
|
public List<String> getSelectedRepositories()
|
||||||
{
|
{
|
||||||
return selectedRepositories;
|
return selectedRepositories;
|
||||||
|
@ -842,7 +853,7 @@ public class GenerateReportAction
|
||||||
{
|
{
|
||||||
this.repositoryStatistics = repositoryStatistics;
|
this.repositoryStatistics = repositoryStatistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getReposSize()
|
public int getReposSize()
|
||||||
{
|
{
|
||||||
return reposSize;
|
return reposSize;
|
||||||
|
@ -872,9 +883,9 @@ public class GenerateReportAction
|
||||||
{
|
{
|
||||||
this.limits = limits;
|
this.limits = limits;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getInputStream()
|
public InputStream getInputStream()
|
||||||
{
|
{
|
||||||
return inputStream;
|
return inputStream;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue