*/
import com.opensymphony.xwork.ActionSupport;
+import com.opensymphony.xwork.Preparable;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ConfigurationStore;
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory;
import org.apache.maven.archiva.reporting.ReportExecutor;
import org.apache.maven.archiva.reporting.ReportingDatabase;
import org.apache.maven.archiva.reporting.ReportingStore;
+import org.apache.maven.archiva.reporting.ReportingStoreException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
*/
public class ReportsAction
extends ActionSupport
+ implements Preparable
{
/**
* @plexus.requirement
*/
private ReportExecutor executor;
+ private Configuration configuration;
+
public String execute()
throws Exception
{
databases = new ArrayList();
- Configuration configuration = configurationStore.getConfigurationFromStore();
-
- for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); )
+ if ( repositoryId != null && !repositoryId.equals( "-" ) )
{
- RepositoryConfiguration repositoryConfiguration = (RepositoryConfiguration) i.next();
-
- ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
-
- ReportingDatabase database = reportingStore.getReportsFromStore( repository );
+ RepositoryConfiguration repositoryConfiguration = configuration.getRepositoryById( repositoryId );
+ getReport( repositoryConfiguration );
+ }
+ else
+ {
+ for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); )
+ {
+ RepositoryConfiguration repositoryConfiguration = (RepositoryConfiguration) i.next();
- databases.add( database );
+ getReport( repositoryConfiguration );
+ }
}
return SUCCESS;
}
+ private void getReport( RepositoryConfiguration repositoryConfiguration )
+ throws ReportingStoreException
+ {
+ ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
+
+ ReportingDatabase database = reportingStore.getReportsFromStore( repository );
+
+ databases.add( database );
+ }
+
public String runReport()
throws Exception
{
// TODO: this should be one that runs in the background - see the showcase
- Configuration configuration = configurationStore.getConfigurationFromStore();
-
RepositoryConfiguration repositoryConfiguration = configuration.getRepositoryById( repositoryId );
ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
{
return databases;
}
+
+ public void prepare()
+ throws Exception
+ {
+ configuration = configurationStore.getConfigurationFromStore();
+ }
+
+ public Configuration getConfiguration()
+ {
+ return configuration;
+ }
}
<div id="contentArea">
-<%-- TODO!: select report, repository and filter --%>
+<%-- TODO!: select report, filter --%>
+<ww:form action="reports" namespace="/admin">
+ <ww:select list="configuration.repositories" listKey="id" listValue="name" label="Repository" headerKey="-"
+ headerValue="(All repositories)" name="repositoryId"/>
+ <ww:submit value="Get Report"/>
+</ww:form>
<ww:set name="databases" value="databases"/>
<c:forEach items="${databases}" var="database">