From: Olivier Lamy Date: Mon, 12 Mar 2012 14:30:09 +0000 (+0000) Subject: [MRM-1580] system status page flush cache link. X-Git-Tag: archiva-1.4-M3~1051 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=97a31442eabc3d87658540e90a99a458c8dedb51;p=archiva.git [MRM-1580] system status page flush cache link. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299684 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SystemStatusService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SystemStatusService.java index 91773482f..056b57b1c 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SystemStatusService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SystemStatusService.java @@ -65,4 +65,11 @@ public interface SystemStatusService List 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; + } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java index 9bda1ecf5..b951db3ae 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java @@ -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; + } } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index dd5a6502e..95a0245bc 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -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 index 000000000..695d215a7 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 index 000000000..0e0953c73 Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/user-trash.png differ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js index 5fe5d8fec..c3480b333 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js @@ -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"); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html index 9b2dcc096..39a76eda7 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html @@ -367,6 +367,7 @@ ${$.i18n.prop('system-status.caches.grid.header.cacheHits')} ${$.i18n.prop('system-status.caches.grid.header.cacheMiss')} ${$.i18n.prop('system-status.caches.grid.header.cacheHitRate')} + ${$.i18n.prop('system-status.caches.grid.header.flush')} @@ -377,6 +378,15 @@ ${cacheEntry.cacheHits} ${cacheEntry.cacheMiss} ${cacheEntry.cacheHitRate} + + + {{if cacheEntry.size > 0 }} + + {{else}} + + {{/if}} + + {{/each}}