]> source.dussan.org Git - archiva.git/commitdiff
Correcting last compile errors. Providing stable 'last run' indicator
authorJoakim Erdfelt <joakime@apache.org>
Wed, 14 Feb 2007 22:42:29 +0000 (22:42 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Wed, 14 Feb 2007 22:42:29 +0000 (22:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@507728 13f79535-47bb-0310-9956-ffa450edef68

archiva-MRM-239/archiva-core/src/main/java/org/apache/maven/archiva/scheduler/executors/DataRefreshExecutor.java
archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ReportsAction.java
archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/ConfigureAction.java
archiva-MRM-239/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/RunRepositoryTaskAction.java

index 237f21903b7e54b3aafda9ef237b077f25c42eba..64e93d69aa032ad9f81958c659143d01380aa892 100644 (file)
@@ -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;
+    }
 }
index 773f0f5d84fe8c7f23a3dbcfda941af7ed9e4b03..0f3404b99488d57e3eeed6f5efb474b3106408dc 100644 (file)
@@ -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
     {
index 34e3a981abe94e389473fb1469f57ec375264b94..607a1cf93df538d20472a036b5ee848b29217db6 100644 (file)
@@ -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
         {
index c0fa12f82cfa4f7298cddfdcc68b02f2d2afe97f..b57dfab2e00b1516ec8b8cae3addd16251393619 100644 (file)
@@ -45,7 +45,7 @@ public class RunRepositoryTaskAction
     public String runIndexer()
         throws TaskExecutionException
     {
-        taskScheduler.runIndexer();
+        taskScheduler.runDataRefresh();
 
         return SUCCESS;
     }