]> source.dussan.org Git - archiva.git/commitdiff
add a service disabled in production env to log missing i18n
authorOlivier Lamy <olamy@apache.org>
Mon, 30 Jan 2012 22:15:02 +0000 (22:15 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 30 Jan 2012 22:15:02 +0000 (22:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1238042 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/pom.xml
archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultRuntimeInfoService.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/RuntimeInfoService.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/model/ApplicationRuntimeInfo.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/jquery.i18n.properties-1.0.9.js

index f76175eaedf95d31eaacdb511d00eced8f43d7e0..e1ab376c486e12a56731cb175147d4c2407c6438 100644 (file)
@@ -36,6 +36,7 @@
     <tomcatRunPath>/archiva</tomcatRunPath>
     <archiva.devMode>true</archiva.devMode>
     <archiva.javascriptLog>true</archiva.javascriptLog>
+    <archiva.logMissingI18n>true</archiva.logMissingI18n>
   </properties>
 
   <dependencies>
             <archiva.user.configFileName>${project.build.directory}/appserver-base/conf/archiva.xml</archiva.user.configFileName>
             <archiva.devMode>${archiva.devMode}</archiva.devMode>
             <archiva.javascriptLog>${archiva.javascriptLog}</archiva.javascriptLog>
+            <archiva.logMissingI18n>${archiva.logMissingI18n}</archiva.logMissingI18n>
           </systemProperties>
         </configuration>
         <dependencies>
             <archiva.user.configFileName>${project.build.directory}/appserver-base/conf/archiva.xml</archiva.user.configFileName>
             <archiva.devMode>${archiva.devMode}</archiva.devMode>
             <archiva.javascriptLog>${archiva.javascriptLog}</archiva.javascriptLog>
+            <archiva.logMissingI18n>${archiva.logMissingI18n}</archiva.logMissingI18n>
           </systemProperties>
         </configuration>
         <dependencies>
             <archiva.user.configFileName>${project.build.directory}/appserver-base/conf/archiva.xml</archiva.user.configFileName>
             <archiva.devMode>${archiva.devMode}</archiva.devMode>
             <archiva.javascriptLog>${archiva.javascriptLog}</archiva.javascriptLog>
+            <archiva.logMissingI18n>${archiva.logMissingI18n}</archiva.logMissingI18n>
           </systemProperties>
         </configuration>
         <dependencies>
index cd58ddacd80dc57ea801c64d58152d70979e2d98..44c9d11144e265495121dcc5cc9f9253ac600098 100644 (file)
@@ -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;
+    }
 }
index 43f609e7ad0237aa9aa3b2eeb7627b82e1be409f..b3055d9a7a79f69d6739f6cbb011d7f3f0d1b651 100644 (file)
@@ -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 );
 }
index fb438a8c27b0fa02641a049ae7801a83341952e5..e6794bd352c4de757431482a37ef556f42769a2e 100644 (file)
@@ -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();
     }
index cd99e0ac8a08b4afcbe090350e5ca3d0d589d264..d8d3ae80401ad0f9a368b31db76d15417f6e7079 100644 (file)
@@ -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);}