]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1580] system status page flush cache link.
authorOlivier Lamy <olamy@apache.org>
Mon, 12 Mar 2012 14:30:09 +0000 (14:30 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 12 Mar 2012 14:30:09 +0000 (14:30 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299684 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SystemStatusService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java
archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/user-trash-full.png [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/user-trash.png [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html

index 91773482fd77e1db21a62e8d344e8a1e53eb2ce6..056b57b1cd7b42559d0e5294c462335e811e1f1c 100644 (file)
@@ -65,4 +65,11 @@ public interface SystemStatusService
     List<CacheEntry> getCacheEntries()
         throws ArchivaRestServiceException;
 
+    @Path( "clearCache/{key}" )
+    @GET
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+    Boolean clearCache( @PathParam( "key" ) String cacheKey )
+        throws ArchivaRestServiceException;
+
 }
index 9bda1ecf561dfdae151ceee6b1fe34dd68d88ad1..b951db3ae422ff9894f00ccde4c241c86ac16ef4 100644 (file)
@@ -126,4 +126,18 @@ public class DefaultSystemStatusService
 
         return cacheEntries;
     }
+
+    public Boolean clearCache( String cacheKey )
+        throws ArchivaRestServiceException
+    {
+        Cache cache = caches.get( cacheKey );
+        if ( cache == null )
+        {
+            throw new ArchivaRestServiceException( "no cache for key: " + cacheKey,
+                                                   Response.Status.BAD_REQUEST.getStatusCode() );
+        }
+
+        cache.clear();
+        return Boolean.TRUE;
+    }
 }
index dd5a6502eda2d1f7243eb6fe920f75aabd9f1305..95a0245bce6fb8cb55ec7783d20c0491c4f81dd5 100644 (file)
@@ -298,6 +298,14 @@ system-status.header.scanning.inprogress.none=No scans in progress.
 system-status.queues.grid.header.key=Queue
 system-status.queues.grid.header.number=Size
 system-status.header.main=System Status
+system-status.caches.grid.header.cacheHits=Hits
+system-status.queues.grid.header.size=Size
+system-status.caches.grid.header.cacheMiss=Misses
+system-status.caches.grid.header.cacheHitRate=Hit Ratio
+system-status.caches.grid.header.flush=Flush
+system-status.caches.grid.header.key=Cache
+system-status.caches.flushed=Cache {0} flushed.
+system-status.caches.grid.header.size=Size
 
 
 
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/user-trash-full.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/user-trash-full.png
new file mode 100644 (file)
index 0000000..695d215
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/user-trash-full.png differ
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/user-trash.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/user-trash.png
new file mode 100644 (file)
index 0000000..0e0953c
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/user-trash.png differ
index 5fe5d8fec45cf10abfc24e3a2dd3d71c8a881fa1..c3480b333f7befa32de4714e1ea51b69ca195dee 100644 (file)
@@ -603,6 +603,18 @@ $(function() {
     });
   }
 
+  flushCache=function(key){
+    clearUserMessages();
+    $("#main-content #status_caches").html(smallSpinnerImg());
+    $.ajax("restServices/archivaServices/systemStatusService/clearCache/"+encodeURIComponent(key), {
+        type: "GET",
+        success: function(data){
+          displaySuccessMessage( $.i18n.prop("system-status.caches.flushed",key));
+          displayCacheEntries();
+        }
+    });
+  }
+
   displaySystemStatus=function(){
     screenChange();
     var mainContent=$("#main-content");
index 9b2dcc09683b5c043dd111437b88dfc25980051b..39a76eda78813d983c542b126975c59ce9dcdc7b 100644 (file)
         <th>${$.i18n.prop('system-status.caches.grid.header.cacheHits')}</th>
         <th>${$.i18n.prop('system-status.caches.grid.header.cacheMiss')}</th>
         <th>${$.i18n.prop('system-status.caches.grid.header.cacheHitRate')}</th>
+        <th>${$.i18n.prop('system-status.caches.grid.header.flush')}</th>
       </tr>
     </thead>
     <tbody>
         <td>${cacheEntry.cacheHits}</td>
         <td>${cacheEntry.cacheMiss}</td>
         <td>${cacheEntry.cacheHitRate}</td>
+        <td>
+          <a href="#" onclick="flushCache('${cacheEntry.key}')">
+            {{if  cacheEntry.size > 0 }}
+              <img src="images/user-trash-full.png"/>
+            {{else}}
+              <img src="images/user-trash.png"/>
+            {{/if}}
+          </a>
+        </td>
       </tr>
     {{/each}}
     </tbody>