import org.apache.maven.archiva.scheduler.task.DataRefreshTask;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.taskqueue.Task;
import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
*/
public class DataRefreshExecutor
extends AbstractLogEnabled
- implements TaskExecutor
+ implements TaskExecutor, Initializable
{
/**
* Configuration store.
*/
private DiscovererConsumerFactory consumerFactory;
+ private long lastRunTime = 0;
+
public void executeTask( Task task )
throws TaskExecutionException
{
getLogger().info( " Files : " + stats.getFilesIncluded() );
getLogger().info( " Consumed: " + stats.getFilesConsumed() );
getLogger().info( " Skipped : " + stats.getFilesSkipped() );
+
+ // TODO: Do we really need to check first?
+ if ( stats.getTimestampFinished() > lastRunTime )
+ {
+ lastRunTime = stats.getTimestampFinished();
+ }
}
time = System.currentTimeMillis() - time;
return filtered;
}
+ public void initialize()
+ throws InitializationException
+ {
+ Configuration configuration = archivaConfiguration.getConfiguration();
+
+ for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); )
+ {
+ RepositoryConfiguration repositoryConfiguration = (RepositoryConfiguration) i.next();
+
+ if ( !repositoryConfiguration.isIndexed() )
+ {
+ continue;
+ }
+
+ ArtifactRepository repository = repoFactory.createRepository( repositoryConfiguration );
+
+ DiscovererStatistics stats = new DiscovererStatistics( repository );
+ if ( stats.getTimestampFinished() > lastRunTime )
+ {
+ lastRunTime = stats.getTimestampFinished();
+ }
+ }
+ }
+
+ public long getLastRunTime()
+ {
+ return lastRunTime;
+ }
}
*/
import com.opensymphony.xwork.Preparable;
+
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory;
-import org.apache.maven.archiva.configuration.RepositoryConfiguration;
-import org.apache.maven.archiva.discoverer.DiscovererException;
-import org.apache.maven.archiva.discoverer.filter.AcceptAllArtifactFilter;
-import org.apache.maven.archiva.discoverer.filter.SnapshotArtifactFilter;
-import org.apache.maven.archiva.reporting.database.ReportingDatabase;
-import org.apache.maven.archiva.reporting.executor.ReportExecutor;
-import org.apache.maven.archiva.reporting.group.ReportGroup;
-import org.apache.maven.archiva.reporting.store.ReportingStoreException;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.codehaus.plexus.security.rbac.Resource;
import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
/**
* Repository reporting.
*
public String execute()
throws Exception
{
- databases = new ArrayList();
-
- if ( repositoryId != null && !repositoryId.equals( "-" ) )
- {
- RepositoryConfiguration repositoryConfiguration = configuration.getRepositoryById( repositoryId );
- getReport( repositoryConfiguration, reportGroup );
- }
- else
- {
- for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); )
- {
- RepositoryConfiguration repositoryConfiguration = (RepositoryConfiguration) i.next();
-
- getReport( repositoryConfiguration, reportGroup );
- }
- }
+
return SUCCESS;
}
public String runReport()
throws Exception
{
- ReportGroup reportGroup = (ReportGroup) reports.get( this.reportGroup );
-
- RepositoryConfiguration repositoryConfiguration = configuration.getRepositoryById( repositoryId );
- ArtifactRepository repository = factory.createRepository( repositoryConfiguration );
-
- ReportingDatabase database = executor.getReportDatabase( repository, reportGroup );
- if ( database.isInProgress() )
- {
- return SUCCESS;
- }
-
- generateReport( database, repositoryConfiguration, reportGroup, repository );
+
return SUCCESS;
}
return configuration;
}
- public Map getReports()
- {
- return reports;
- }
-
- public String getFilter()
- {
- return filter;
- }
-
- public void setFilter( String filter )
- {
- this.filter = filter;
- }
-
public SecureActionBundle getSecureActionBundle()
throws SecureActionException
{
import com.opensymphony.xwork.ModelDriven;
import com.opensymphony.xwork.Preparable;
import com.opensymphony.xwork.Validateable;
+
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.InvalidConfigurationException;
import org.apache.maven.archiva.indexer.RepositoryIndexException;
import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
-import org.apache.maven.archiva.scheduler.executors.IndexerTaskExecutor;
+import org.apache.maven.archiva.scheduler.executors.DataRefreshExecutor;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.plexus.scheduler.CronExpressionValidator;
private ArchivaConfiguration archivaConfiguration;
/**
- * @plexus.requirement role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" role-hint="indexer"
+ * @plexus.requirement role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" role-hint="data-refresh"
*/
- private IndexerTaskExecutor indexer;
+ private DataRefreshExecutor dataRefresh;
/**
* The configuration.
i++;
}
- if ( indexer.getLastIndexingTime() != 0 )
+ if ( dataRefresh.getLastRunTime() != 0 )
{
- lastIndexingTime = new Date( indexer.getLastIndexingTime() ).toString();
+ lastIndexingTime = new Date( dataRefresh.getLastRunTime() ).toString();
}
else
{
public String runIndexer()
throws TaskExecutionException
{
- taskScheduler.runIndexer();
+ taskScheduler.runDataRefresh();
return SUCCESS;
}