You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by oc...@apache.org on 2011/08/26 06:16:34 UTC

svn commit: r1161988 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main: java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java resources/struts.xml webapp/WEB-INF/jsp/admin/systemStatus.jsp

Author: oching
Date: Fri Aug 26 04:16:34 2011
New Revision: 1161988

URL: http://svn.apache.org/viewvc?rev=1161988&view=rev
Log:
[MRM-1488] allow users with sysadmin role to flush cache from System Status page

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/systemStatus.jsp

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java?rev=1161988&r1=1161987&r2=1161988&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SystemStatusAction.java Fri Aug 26 04:16:34 2011
@@ -20,6 +20,7 @@ package org.apache.maven.archiva.web.act
  */
 
 import org.apache.archiva.repository.scanner.RepositoryScanner;
+import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
 import org.apache.maven.archiva.web.action.AbstractActionSupport;
 import org.codehaus.plexus.cache.Cache;
@@ -65,6 +66,8 @@ public class SystemStatusAction
 
     private String memoryStatus;
 
+    private String cacheKey;
+
     @PostConstruct
     public void initialize()
     {
@@ -95,6 +98,17 @@ public class SystemStatusAction
 
         return SUCCESS;
     }
+    
+    public String flush()
+    {
+        if( !StringUtils.isEmpty( cacheKey ) )
+        {
+            Cache cache = caches.get( cacheKey );
+            cache.clear();
+        }
+
+        return SUCCESS;
+    }
 
     private static String formatMemory( long l )
     {
@@ -120,4 +134,14 @@ public class SystemStatusAction
     {
         return queues;
     }
+
+    public String getCacheKey()
+    {
+        return cacheKey;
+    }
+
+    public void setCacheKey( String cacheKey )
+    {
+        this.cacheKey = cacheKey;
+    }
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml?rev=1161988&r1=1161987&r2=1161988&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml Fri Aug 26 04:16:34 2011
@@ -549,6 +549,10 @@
       <result name="success">/WEB-INF/jsp/admin/systemStatus.jsp</result>
     </action>
 
+    <action name="flushCache" class="systemStatus" method="flush">
+      <result name="success">/WEB-INF/jsp/admin/systemStatus.jsp</result>
+    </action>
+
     <!-- .\ LEGACY SUPPORT \.__________________________________________ -->
 
     <action name="legacyArtifactPath" class="legacyArtifactPathAction" method="input">

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/systemStatus.jsp
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/systemStatus.jsp?rev=1161988&r1=1161987&r2=1161988&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/systemStatus.jsp (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/systemStatus.jsp Fri Aug 26 04:16:34 2011
@@ -112,13 +112,18 @@
       <th>&nbsp;</th>
     </tr>
     <c:forEach var="cacheEntry" items="${caches}">
+      <c:set var="flushCacheUrl">
+        <s:url action="flushCache">
+          <s:param name="cacheKey">${cacheEntry.key}</s:param>
+        </s:url>
+      </c:set>
       <tr>
         <td>${cacheEntry.key}</td>
         <td align="right">${cacheEntry.value.statistics.size}</td>
         <td align="right">${cacheEntry.value.statistics.cacheHits}</td>
         <td align="right">${cacheEntry.value.statistics.cacheMiss}</td>
         <td align="right"><fmt:formatNumber value="${cacheEntry.value.statistics.cacheHitRate}" pattern="#%"/></td>
-        <td><a href="javascript:alert('Not yet implemented')">Flush</a></td>
+        <td><a href="${flushCacheUrl}">Flush</a></td>
       </tr>
     </c:forEach>
   </table>