]> source.dussan.org Git - archiva.git/commitdiff
prevent doing to much String->Properties transformation for loading i18n
authorOlivier Lamy <olamy@apache.org>
Mon, 23 Jan 2012 12:31:59 +0000 (12:31 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 23 Jan 2012 12:31:59 +0000 (12:31 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1234762 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java

index 1a21588ddb5dc684a79a2be374b2097de81baabc..33737feb57c231986e85ed15f01ad9c5e1e1501f 100644 (file)
@@ -22,7 +22,6 @@ import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
 import org.apache.archiva.rest.api.services.CommonServices;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
-import org.codehaus.plexus.util.StringInputStream;
 import org.codehaus.redback.rest.api.services.RedbackServiceException;
 import org.codehaus.redback.rest.api.services.UtilServices;
 import org.slf4j.Logger;
@@ -34,7 +33,6 @@ import javax.ws.rs.core.Response;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.StringReader;
 import java.util.Map;
 import java.util.Properties;
 
@@ -46,6 +44,8 @@ public class DefaultCommonServices
     implements CommonServices
 {
 
+    private static final String RESOURCE_NAME = "org/apache/archiva/i18n/default";
+
     private Logger log = LoggerFactory.getLogger( getClass() );
 
     @Inject
@@ -56,7 +56,7 @@ public class DefaultCommonServices
     {
         Properties properties = new Properties();
 
-        StringBuilder resourceName = new StringBuilder( "org/apache/archiva/i18n/default" );
+        StringBuilder resourceName = new StringBuilder( RESOURCE_NAME );
         try
         {
 
@@ -131,12 +131,17 @@ public class DefaultCommonServices
     {
         try
         {
-            String redbackProps = utilServices.getI18nResources( locale );
-            String archivaProps = getI18nResources( locale );
-            Properties properties = new Properties();
-            loadFromString( redbackProps, properties );
-            loadFromString( archivaProps, properties );
-            return fromProperties( properties );
+
+            Properties all = utilServices.getI18nProperties( locale );
+            StringBuilder resourceName = new StringBuilder( RESOURCE_NAME );
+            loadResource( all, resourceName, locale );
+
+            return fromProperties( all );
+        }
+        catch ( IOException e )
+        {
+            throw new ArchivaRestServiceException( e.getMessage(),
+                                                   Response.Status.INTERNAL_SERVER_ERROR.getStatusCode() );
         }
         catch ( RedbackServiceException e )
         {