From 135fe5f01f57f076847faf7d51e8631c72c60f2f Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 12 Mar 2012 11:34:40 +0000 Subject: [PATCH] [MRM-1580] system status page display version infos. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299632 13f79535-47bb-0310-9956-ffa450edef68 --- .../api/DefaultRuntimeInfoService.java | 9 ++- .../ui/services/api/RuntimeInfoService.java | 5 +- .../model/ApplicationRuntimeInfo.java | 12 ++++ .../src/main/webapp/index-dev.html | 58 ++------------- .../src/main/webapp/index.html | 72 +++---------------- .../main/webapp/js/archiva/general-admin.js | 4 ++ .../src/main/webapp/js/archiva/i18nload.js | 9 +-- .../src/main/webapp/js/archiva/utils.js | 12 ---- .../web/action/AbstractActionSupport.java | 7 +- 9 files changed, 43 insertions(+), 145 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultRuntimeInfoService.java b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultRuntimeInfoService.java index 0f1c576b3..c7408e0c3 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultRuntimeInfoService.java +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultRuntimeInfoService.java @@ -27,6 +27,9 @@ import org.springframework.stereotype.Service; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Context; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; /** * @author Olivier Lamy @@ -49,13 +52,17 @@ public class DefaultRuntimeInfoService this.archivaRuntimeInfo = archivaRuntimeInfo; } - public ApplicationRuntimeInfo getApplicationRuntimeInfo() + public ApplicationRuntimeInfo getApplicationRuntimeInfo( String locale ) { ApplicationRuntimeInfo applicationRuntimeInfo = new ApplicationRuntimeInfo(); applicationRuntimeInfo.setBuildNumber( this.archivaRuntimeInfo.getBuildNumber() ); applicationRuntimeInfo.setTimestamp( this.archivaRuntimeInfo.getTimestamp() ); applicationRuntimeInfo.setVersion( this.archivaRuntimeInfo.getVersion() ); applicationRuntimeInfo.setBaseUrl( getBaseUrl( httpServletRequest ) ); + + SimpleDateFormat sfd = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssz", new Locale( locale ) ); + applicationRuntimeInfo.setTimestampStr( sfd.format( new Date( archivaRuntimeInfo.getTimestamp() ) ) ); + return applicationRuntimeInfo; } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoService.java b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoService.java index b3055d9a7..fd50bed4e 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoService.java +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoService.java @@ -23,6 +23,7 @@ import org.codehaus.plexus.redback.authorization.RedbackAuthorization; import javax.ws.rs.GET; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; @@ -34,11 +35,11 @@ import javax.ws.rs.core.MediaType; @Path( "/runtimeInfoService/" ) public interface RuntimeInfoService { - @Path( "archivaRuntimeInfo" ) + @Path( "archivaRuntimeInfo/{locale}" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( noRestriction = true ) - ApplicationRuntimeInfo getApplicationRuntimeInfo(); + ApplicationRuntimeInfo getApplicationRuntimeInfo( @PathParam( "locale" ) String locale ); @Path( "logMissingI18n" ) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/model/ApplicationRuntimeInfo.java b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/model/ApplicationRuntimeInfo.java index 351bc6182..15dc6d3ec 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/model/ApplicationRuntimeInfo.java +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/model/ApplicationRuntimeInfo.java @@ -44,6 +44,7 @@ public class ApplicationRuntimeInfo private String baseUrl; + private String timestampStr; public ApplicationRuntimeInfo() { @@ -136,6 +137,16 @@ public class ApplicationRuntimeInfo this.baseUrl = baseUrl; } + public String getTimestampStr() + { + return timestampStr; + } + + public void setTimestampStr( String timestampStr ) + { + this.timestampStr = timestampStr; + } + @Override public String toString() { @@ -149,6 +160,7 @@ public class ApplicationRuntimeInfo sb.append( ", copyrightRange='" ).append( copyrightRange ).append( '\'' ); sb.append( ", logMissingI18n=" ).append( logMissingI18n ); sb.append( ", baseUrl='" ).append( baseUrl ).append( '\'' ); + sb.append( ", timestampStr='" ).append( timestampStr ).append( '\'' ); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index-dev.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index-dev.html index 675793d4c..e65c3d8eb 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index-dev.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index-dev.html @@ -44,61 +44,11 @@ + diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html index 0cd557eab..81bc7fc32 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html @@ -11,6 +11,8 @@ + + Apache Archiva @@ -45,70 +47,12 @@ 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 832c96888..1b1ebe1fb 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 @@ -584,6 +584,10 @@ $(function() { mainContent.find("#status_current_time").html(curTime); } }); + + var versionInfo="Build number: "+window.archivaRuntimeInfo.buildNumber+" - Build Timestamp: "+window.archivaRuntimeInfo.timestampStr; + mainContent.find("#status_version_info").html(versionInfo); + } }); \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/i18nload.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/i18nload.js index be0aea864..5ff8c072c 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/i18nload.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/i18nload.js @@ -20,14 +20,7 @@ $(function() { // load i18n resources from rest call - usedLang=function(){ - var browserLang = $.i18n.browserLang(); - var requestLang = $.urlParam('request_lang'); - if (requestLang) { - browserLang=requestLang; - } - return browserLang; - } + var browserLang = usedLang(); $.log("use browserLang:"+browserLang); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js index 5ae75e730..8ef021330 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js @@ -31,18 +31,6 @@ $.log = (function(message) { } }); -/** - * return value of a param in the url - * @param name - */ -$.urlParam = function(name){ - var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); - if (results) { - return results[1] || 0; - } - return null; -} - /** * display a success message * @param text the success text diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java index 4af3b36cf..71537aa10 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java @@ -198,25 +198,24 @@ public abstract class AbstractActionSupport public String getArchivaVersion() { - return archivaRuntimeInfo.getVersion(); //(String) archivaRuntimeProperties.get( "archiva.version" ); + return archivaRuntimeInfo.getVersion(); } public String getArchivaBuildNumber() { - return archivaRuntimeInfo.getBuildNumber();// (String) archivaRuntimeProperties.get( "archiva.buildNumber" ); + return archivaRuntimeInfo.getBuildNumber(); } public String getArchivaBuildTimestamp() { return Long.toString( - archivaRuntimeInfo.getTimestamp() ); //(String) archivaRuntimeProperties.get( "archiva.timestamp" ); + archivaRuntimeInfo.getTimestamp() ); } public String getArchivaBuildTimestampDateStr() { SimpleDateFormat sfd = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssz", getLocale() ); return sfd.format( new Date( archivaRuntimeInfo.getTimestamp() ) ); - //new Date( NumberUtils.createLong( (String) archivaRuntimeProperties.get( "archiva.timestamp" ) ) ) ); } /** -- 2.39.5