From: Joakim Erdfelt Date: Wed, 14 Feb 2007 22:42:29 +0000 (+0000) Subject: Correcting last compile errors. Providing stable 'last run' indicator X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b36b5b172cbf95cae24d3a22c105e67b634dcd42;p=archiva.git Correcting last compile errors. Providing stable 'last run' indicator git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@507728 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-MRM-239/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/executors/DataRefreshExecutor.java b/archiva-MRM-239/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/executors/DataRefreshExecutor.java index 237f21903..64e93d69a 100644 --- a/archiva-MRM-239/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/executors/DataRefreshExecutor.java +++ b/archiva-MRM-239/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/executors/DataRefreshExecutor.java @@ -31,6 +31,8 @@ import org.apache.maven.archiva.discoverer.DiscovererStatistics; 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; @@ -52,7 +54,7 @@ import java.util.List; */ public class DataRefreshExecutor extends AbstractLogEnabled - implements TaskExecutor + implements TaskExecutor, Initializable { /** * Configuration store. @@ -81,6 +83,8 @@ public class DataRefreshExecutor */ private DiscovererConsumerFactory consumerFactory; + private long lastRunTime = 0; + public void executeTask( Task task ) throws TaskExecutionException { @@ -145,6 +149,12 @@ public class DataRefreshExecutor 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; @@ -181,4 +191,32 @@ public class DataRefreshExecutor 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; + } } diff --git a/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java b/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java index 773f0f5d8..0f3404b99 100644 --- a/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java +++ b/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java @@ -20,31 +20,17 @@ package org.apache.maven.archiva.web.action; */ 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. * @@ -70,40 +56,14 @@ public class ReportsAction 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; } @@ -119,21 +79,6 @@ public class ReportsAction 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 { diff --git a/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java b/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java index 34e3a981a..607a1cf93 100644 --- a/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java +++ b/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java @@ -22,12 +22,13 @@ package org.apache.maven.archiva.web.action.admin; 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; @@ -56,9 +57,9 @@ public class ConfigureAction 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. @@ -157,9 +158,9 @@ public class ConfigureAction i++; } - if ( indexer.getLastIndexingTime() != 0 ) + if ( dataRefresh.getLastRunTime() != 0 ) { - lastIndexingTime = new Date( indexer.getLastIndexingTime() ).toString(); + lastIndexingTime = new Date( dataRefresh.getLastRunTime() ).toString(); } else { diff --git a/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RunRepositoryTaskAction.java b/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RunRepositoryTaskAction.java index c0fa12f82..b57dfab2e 100644 --- a/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RunRepositoryTaskAction.java +++ b/archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RunRepositoryTaskAction.java @@ -45,7 +45,7 @@ public class RunRepositoryTaskAction public String runIndexer() throws TaskExecutionException { - taskScheduler.runIndexer(); + taskScheduler.runDataRefresh(); return SUCCESS; }