From: Olivier Lamy Date: Mon, 30 Jan 2012 22:15:02 +0000 (+0000) Subject: add a service disabled in production env to log missing i18n X-Git-Tag: archiva-1.4-M3~1425 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=74af64e0bac8ffb2ce3f9c448758d1820b9fa6b1;p=archiva.git add a service disabled in production env to log missing i18n git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1238042 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp-js/pom.xml b/archiva-modules/archiva-web/archiva-webapp-js/pom.xml index f76175eae..e1ab376c4 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp-js/pom.xml @@ -36,6 +36,7 @@ /archiva true true + true @@ -544,6 +545,7 @@ ${project.build.directory}/appserver-base/conf/archiva.xml ${archiva.devMode} ${archiva.javascriptLog} + ${archiva.logMissingI18n} @@ -578,6 +580,7 @@ ${project.build.directory}/appserver-base/conf/archiva.xml ${archiva.devMode} ${archiva.javascriptLog} + ${archiva.logMissingI18n} @@ -610,6 +613,7 @@ ${project.build.directory}/appserver-base/conf/archiva.xml ${archiva.devMode} ${archiva.javascriptLog} + ${archiva.logMissingI18n} 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 cd58ddacd..44c9d1114 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 @@ -20,6 +20,8 @@ package org.apache.archiva.webapp.ui.services.api; import org.apache.archiva.web.runtime.ArchivaRuntimeInfo; import org.apache.archiva.webapp.ui.services.model.ApplicationRuntimeInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.inject.Inject; @@ -32,6 +34,8 @@ public class DefaultRuntimeInfoService implements RuntimeInfoService { + private Logger i18nLogger = LoggerFactory.getLogger( "archivaMissingi18n.logger" ); + private ArchivaRuntimeInfo archivaRuntimeInfo; @Inject @@ -49,4 +53,10 @@ public class DefaultRuntimeInfoService applicationRuntimeInfo.setVersion( this.archivaRuntimeInfo.getVersion() ); return applicationRuntimeInfo; } + + public Boolean logMissingI18n( String key ) + { + i18nLogger.info( "missing i18n key : '{}'", key ); + return Boolean.TRUE; + } } 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 43f609e7a..b3055d9a7 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 @@ -24,6 +24,7 @@ import org.codehaus.plexus.redback.authorization.RedbackAuthorization; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; /** @@ -38,4 +39,11 @@ public interface RuntimeInfoService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( noRestriction = true ) ApplicationRuntimeInfo getApplicationRuntimeInfo(); + + + @Path( "logMissingI18n" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization( noRestriction = true ) + Boolean logMissingI18n( @QueryParam( "key" ) String key ); } 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 fb438a8c2..e6794bd35 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 @@ -40,6 +40,8 @@ public class ApplicationRuntimeInfo private String copyrightRange; + private boolean logMissingI18n; + public ApplicationRuntimeInfo() { @@ -47,6 +49,8 @@ public class ApplicationRuntimeInfo this.javascriptLog = Boolean.getBoolean( "archiva.javascriptLog" ); + this.logMissingI18n = Boolean.getBoolean( "archiva.logMissingI18n" ); + this.copyrightRange = "2005 - " + Calendar.getInstance().get( Calendar.YEAR ); } @@ -110,6 +114,16 @@ public class ApplicationRuntimeInfo this.copyrightRange = copyrightRange; } + public boolean isLogMissingI18n() + { + return logMissingI18n; + } + + public void setLogMissingI18n( boolean logMissingI18n ) + { + this.logMissingI18n = logMissingI18n; + } + @Override public String toString() { @@ -121,6 +135,7 @@ public class ApplicationRuntimeInfo sb.append( ", buildNumber='" ).append( buildNumber ).append( '\'' ); sb.append( ", timestamp=" ).append( timestamp ); sb.append( ", copyrightRange='" ).append( copyrightRange ).append( '\'' ); + sb.append( ", logMissingI18n=" ).append( logMissingI18n ); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/jquery.i18n.properties-1.0.9.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/jquery.i18n.properties-1.0.9.js index cd99e0ac8..d8d3ae804 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/jquery.i18n.properties-1.0.9.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/jquery.i18n.properties-1.0.9.js @@ -52,7 +52,7 @@ $.i18n.properties = function(settings) { language: '', path: '', mode: 'vars', - cache: false, + cache: false, encoding: 'UTF-8', callback: null }; @@ -88,8 +88,12 @@ $.i18n.properties = function(settings) { */ $.i18n.prop = function(key /* Add parameters as function arguments as necessary */) { var value = $.i18n.map[key]; - if (value == null) + if (value == null) { + if (window.archivaRuntimeInfo.logMissingI18n){ + $.get('restServices/archivaUiServices/runtimeInfoService/logMissingI18n?key='+encodeURIComponent(key)); + } return '[' + key + ']'; + } // if(arguments.length < 2) // No arguments. // //if(key == 'spv.lbl.modified') {alert(value);}