]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1441] add repository scanning details to system status page
authorBrett Porter <brett@apache.org>
Mon, 6 Dec 2010 13:27:53 +0000 (13:27 +0000)
committerBrett Porter <brett@apache.org>
Mon, 6 Dec 2010 13:27:53 +0000 (13:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@1042633 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/DefaultRepositoryScanner.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScanner.java
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/systemStatus.jsp

index 37ee25220a7b41310741ffca67fb029a4d2610bc..635806b5b3f7af10ba0c091ffbb0af9ca2107536 100644 (file)
@@ -21,7 +21,9 @@ package org.apache.maven.archiva.repository.scanner;
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.maven.archiva.configuration.FileTypes;
@@ -32,6 +34,8 @@ import org.apache.maven.archiva.consumers.RepositoryContentConsumer;
 import org.apache.maven.archiva.repository.RepositoryException;
 import org.codehaus.plexus.util.DirectoryWalker;
 
+import javax.swing.*;
+
 /**
  * DefaultRepositoryScanner
  *
@@ -50,7 +54,9 @@ public class DefaultRepositoryScanner
      * @plexus.requirement
      */
     private RepositoryContentConsumers consumerUtil;
-    
+
+    private Set<RepositoryScannerInstance> inProgressScans = new LinkedHashSet<RepositoryScannerInstance>();
+
     public RepositoryScanStatistics scan( ManagedRepositoryConfiguration repository, long changesSince )
         throws RepositoryException
     {
@@ -73,7 +79,7 @@ public class DefaultRepositoryScanner
         }
 
         File repositoryBase = new File( repository.getLocation() );
-        
+
         if ( !repositoryBase.exists() )
         {
             throw new UnsupportedOperationException( "Unable to scan a repository, directory "
@@ -111,6 +117,8 @@ public class DefaultRepositoryScanner
         RepositoryScannerInstance scannerInstance = new RepositoryScannerInstance( repository, knownContentConsumers,
                                                                                    invalidContentConsumers, changesSince );
 
+        inProgressScans.add( scannerInstance );
+
         dirWalker.addDirectoryWalkListener( scannerInstance );
 
         // Execute scan.
@@ -120,7 +128,9 @@ public class DefaultRepositoryScanner
 
         stats.setKnownConsumers( gatherIds( knownContentConsumers ) );
         stats.setInvalidConsumers( gatherIds( invalidContentConsumers ) );
-        
+
+        inProgressScans.remove( scannerInstance );
+
         return stats;
     }
 
@@ -132,5 +142,10 @@ public class DefaultRepositoryScanner
             ids.add( consumer.getId() );
         }
         return ids;
-    }   
+    }
+
+    public Set<RepositoryScannerInstance> getInProgressScans()
+    {
+        return inProgressScans;
+    }
 }
index 1ecd3e811bf579feeaa57612f1b9907cfac6a7cf..98ac2910f8de856372f5da4f16b85081e39a78a5 100644 (file)
@@ -24,7 +24,9 @@ import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
 import org.apache.maven.archiva.repository.RepositoryException;
 
+import java.util.Collection;
 import java.util.List;
+import java.util.Set;
 
 /**
  * RepositoryScanner 
@@ -107,4 +109,5 @@ public interface RepositoryScanner
                                              List<String> ignoredContentPatterns, long changesSince )
         throws RepositoryException;
 
+    Set<RepositoryScannerInstance> getInProgressScans();
 }
index 63229aa9797122174c172db39aa185d1ca21a507..cd25dc396671b9b5e857bad07f754bda512d7a7e 100644 (file)
@@ -163,4 +163,18 @@ public class RepositoryScannerInstance
         log.debug( "Repository Scanner: " + message );
     }
     
+    public ManagedRepositoryConfiguration getRepository()
+    {
+        return repository;
+    }
+
+    public RepositoryScanStatistics getStats()
+    {
+        return stats;
+    }
+
+    public long getChangesSince()
+    {
+        return changesSince;
+    }
 }
index 9334fd40568a90b23f21c61cb315ae8e49b9f78f..012d0d684da4d80c2022b5caada8e493958be87a 100644 (file)
@@ -19,20 +19,9 @@ package org.apache.maven.archiva.web.action.admin;
  * under the License.
  */
 
-import com.opensymphony.xwork2.Preparable;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.functors.RepositoryConfigurationComparator;
-import org.apache.maven.archiva.database.ArchivaDAO;
-import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
-import org.apache.maven.archiva.model.RepositoryContentStatistics;
 import org.apache.maven.archiva.repository.scanner.RepositoryScanner;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
 import org.apache.maven.archiva.web.action.PlexusActionSupport;
-import org.apache.maven.archiva.web.util.ContextUtils;
-import org.apache.struts2.interceptor.ServletRequestAware;
 import org.codehaus.plexus.cache.Cache;
 import org.codehaus.plexus.redback.rbac.Resource;
 import org.codehaus.plexus.taskqueue.TaskQueue;
@@ -40,12 +29,7 @@ import org.codehaus.redback.integration.interceptor.SecureAction;
 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.codehaus.redback.integration.interceptor.SecureActionException;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
 
 /**
  * Shows system status information for the administrator.
@@ -67,6 +51,11 @@ public class SystemStatusAction
      */
     private Map<String,Cache> caches;
 
+    /**
+     * @plexus.requirement
+     */
+    private RepositoryScanner scanner;
+
     private String memoryStatus;
 
     public SecureActionBundle getSecureActionBundle()
@@ -102,6 +91,11 @@ public class SystemStatusAction
         return memoryStatus;
     }
 
+    public RepositoryScanner getScanner()
+    {
+        return scanner;
+    }
+
     public Map<String, Cache> getCaches()
     {
         return caches;
index 438aa4d4e3ae0830c6fcfd7dcd46c4ae1f003883..c9a9fd8cb3e416b3a2b38d87da24e903266cfbce 100644 (file)
     </c:forEach>
   </table>
 
+  <h2>Repository Scans</h2>
+
+  <c:choose>
+  <c:when test="${!empty scanner.inProgressScans}">
+  <table>
+    <tr>
+      <th>Repository</th>
+      <th>Files processed</th>
+      <th>New files</th>
+    </tr>
+    <c:forEach var="scan" items="${scanner.inProgressScans}">
+      <tr>
+        <td>${scan.repository.name} (${scan.repository.id})</td>
+        <td>${scan.stats.totalFileCount}</td>
+        <td>${scan.stats.newFileCount}</td>
+      </tr>
+    </c:forEach>
+  </table>
+  </c:when>
+  <c:otherwise>
+  <p>No scans in progress.</p>
+  </c:otherwise>
+  </c:choose>
+
   <h2>Caches</h2>
 
   <table>