This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch DOXIASITETOOLS-271
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git

commit 84dda3c5a1f02c9c4dbe44d8a259f7fa2a408836
Author: Michael Osipov <[email protected]>
AuthorDate: Sun Nov 6 11:36:52 2022 +0100

    Start
---
 .../apache/maven/doxia/tools/DefaultSiteTool.java  | 53 ++++++++++------------
 .../org/apache/maven/doxia/tools/SiteToolTest.java |  2 +-
 .../doxia/siterenderer/SiteRenderingContext.java   |  2 +-
 .../siterenderer/DefaultSiteRendererTest.java      |  6 +--
 4 files changed, 29 insertions(+), 34 deletions(-)

diff --git 
a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
 
b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
index ca364f5..92d64e7 100644
--- 
a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
+++ 
b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
@@ -335,9 +335,9 @@ public class DefaultSiteTool
     public File getSiteDescriptor( File siteDirectory, Locale locale )
     {
         Objects.requireNonNull( siteDirectory, "siteDirectory cannot be null" 
);
-        final Locale llocale = ( locale == null ) ? new Locale( "" ) : locale;
+        Objects.requireNonNull( locale, "locale cannot be null" );
 
-        File siteDescriptor = new File( siteDirectory, "site_" + 
llocale.getLanguage() + ".xml" );
+        File siteDescriptor = new File( siteDirectory, "site_" + 
locale.getLanguage() + ".xml" );
 
         if ( !siteDescriptor.isFile() )
         {
@@ -352,7 +352,7 @@ public class DefaultSiteTool
      * @param project the Maven project, not null.
      * @param localRepository the Maven local repository, not null.
      * @param repositories the Maven remote repositories, not null.
-     * @param locale the locale wanted for the site descriptor. If not null, 
searching for
+     * @param locale the locale wanted for the site descriptor. Not null, 
searching for
      * <code>site_<i>localeLanguage</i>.xml</code>, otherwise searching for 
<code>site.xml</code>.
      * @return the site descriptor into the local repository after download of 
it from repositories or null if not
      * found in repositories.
@@ -365,12 +365,11 @@ public class DefaultSiteTool
         Objects.requireNonNull( project, "project cannot be null" );
         Objects.requireNonNull( localRepository, "localRepository cannot be 
null" );
         Objects.requireNonNull( repositories, "repositories cannot be null" );
-
-        final Locale llocale = ( locale == null ) ? new Locale( "" ) : locale;
+        Objects.requireNonNull( locale, "locale cannot be null" );
 
         try
         {
-            return resolveSiteDescriptor( project, localRepository, 
repositories, llocale );
+            return resolveSiteDescriptor( project, localRepository, 
repositories, locale );
         }
         catch ( ArtifactNotFoundException e )
         {
@@ -393,17 +392,16 @@ public class DefaultSiteTool
                                                List<ArtifactRepository> 
repositories )
         throws SiteToolException
     {
+        Objects.requireNonNull( locale, "locale cannot be null" );
         Objects.requireNonNull( project, "project cannot be null" );
         Objects.requireNonNull( reactorProjects, "reactorProjects cannot be 
null" );
         Objects.requireNonNull( localRepository, "localRepository cannot be 
null" );
         Objects.requireNonNull( repositories, "repositories cannot be null" );
 
-        final Locale llocale = ( locale == null ) ? Locale.getDefault() : 
locale;
-
-        LOGGER.debug( "Computing decoration model of " + project.getId() + " 
for locale " + llocale );
+        LOGGER.debug( "Computing decoration model of " + project.getId() + " 
for locale " + locale );
 
         Map.Entry<DecorationModel, MavenProject> result =
-            getDecorationModel( 0, siteDirectory, llocale, project, 
reactorProjects, localRepository, repositories );
+            getDecorationModel( 0, siteDirectory, locale, project, 
reactorProjects, localRepository, repositories );
         DecorationModel decorationModel = result.getKey();
         MavenProject parentProject = result.getValue();
 
@@ -423,12 +421,12 @@ public class DefaultSiteTool
 
         if ( parentProject != null )
         {
-            populateParentMenu( decorationModel, llocale, project, 
parentProject, true );
+            populateParentMenu( decorationModel, locale, project, 
parentProject, true );
         }
 
         try
         {
-            populateModulesMenu( decorationModel, llocale, project, 
reactorProjects, localRepository, true );
+            populateModulesMenu( decorationModel, locale, project, 
reactorProjects, localRepository, true );
         }
         catch ( IOException e )
         {
@@ -506,7 +504,7 @@ public class DefaultSiteTool
      * if used through <code>&lt;menu ref="parent"/&gt;</code>.
      *
      * @param decorationModel the Doxia Sitetools DecorationModel, not null.
-     * @param locale the locale used for the i18n in DecorationModel. If null, 
using the default locale in the jvm.
+     * @param locale the locale used for the i18n in DecorationModel not null.
      * @param project a Maven project, not null.
      * @param parentProject a Maven parent project, not null.
      * @param keepInheritedRefs used for inherited references.
@@ -515,6 +513,7 @@ public class DefaultSiteTool
                                     MavenProject parentProject, boolean 
keepInheritedRefs )
     {
         Objects.requireNonNull( decorationModel, "decorationModel cannot be 
null" );
+        Objects.requireNonNull( locale, "locale cannot be null" );
         Objects.requireNonNull( project, "project cannot be null" );
         Objects.requireNonNull( parentProject, "parentProject cannot be null" 
);
 
@@ -530,8 +529,6 @@ public class DefaultSiteTool
             return;
         }
 
-        final Locale llocale = ( locale == null ) ? Locale.getDefault() : 
locale;
-
         String parentUrl = getDistMgmntSiteUrl( parentProject );
 
         if ( parentUrl != null )
@@ -570,7 +567,7 @@ public class DefaultSiteTool
         {
             if ( menu.getName() == null )
             {
-                menu.setName( i18n.getString( "site-tool", llocale, 
"decorationModel.menu.parentproject" ) );
+                menu.setName( i18n.getString( "site-tool", locale, 
"decorationModel.menu.parentproject" ) );
             }
 
             MenuItem item = new MenuItem();
@@ -585,7 +582,7 @@ public class DefaultSiteTool
      * if used through <code>&lt;menu ref="modules"/&gt;</code>.
      *
      * @param decorationModel the Doxia Sitetools DecorationModel, not null.
-     * @param locale the locale used for the i18n in DecorationModel. If null, 
using the default locale in the jvm.
+     * @param locale the locale used for the i18n in DecorationModel, not null.
      * @param project a Maven project, not null.
      * @param reactorProjects the Maven reactor projects, not null.
      * @param localRepository the Maven local repository, not null.
@@ -598,10 +595,11 @@ public class DefaultSiteTool
                                      boolean keepInheritedRefs )
         throws SiteToolException, IOException
     {
+        Objects.requireNonNull( decorationModel, "decorationModel cannot be 
null" );
+        Objects.requireNonNull( locale, "locale cannot be null" );
         Objects.requireNonNull( project, "project cannot be null" );
         Objects.requireNonNull( reactorProjects, "reactorProjects cannot be 
null" );
         Objects.requireNonNull( localRepository, "localRepository cannot be 
null" );
-        Objects.requireNonNull( decorationModel, "decorationModel cannot be 
null" );
 
         Menu menu = decorationModel.getMenuRef( "modules" );
 
@@ -615,14 +613,12 @@ public class DefaultSiteTool
             return;
         }
 
-        final Locale llocale = ( locale == null ) ? Locale.getDefault() : 
locale ;
-
         // we require child modules and reactors to process module menu
         if ( project.getModules().size() > 0 )
         {
             if ( menu.getName() == null )
             {
-                menu.setName( i18n.getString( "site-tool", llocale, 
"decorationModel.menu.projectmodules" ) );
+                menu.setName( i18n.getString( "site-tool", locale, 
"decorationModel.menu.projectmodules" ) );
             }
 
             for ( String module : (List<String>) project.getModules() )
@@ -699,6 +695,7 @@ public class DefaultSiteTool
                                      Map<String, List<MavenReport>> categories 
)
     {
         Objects.requireNonNull( decorationModel, "decorationModel cannot be 
null" );
+        Objects.requireNonNull( locale, "locale cannot be null" );
         Objects.requireNonNull( categories, "categories cannot be null" );
 
         Menu menu = decorationModel.getMenuRef( "reports" );
@@ -708,11 +705,9 @@ public class DefaultSiteTool
             return;
         }
 
-        final Locale llocale = ( locale == null ) ? Locale.getDefault() : 
locale;
-
         if ( menu.getName() == null )
         {
-            menu.setName( i18n.getString( "site-tool", llocale, 
"decorationModel.menu.projectdocumentation" ) );
+            menu.setName( i18n.getString( "site-tool", locale, 
"decorationModel.menu.projectdocumentation" ) );
         }
 
         boolean found = false;
@@ -722,9 +717,9 @@ public class DefaultSiteTool
             if ( !isEmptyList( categoryReports ) )
             {
                 MenuItem item = createCategoryMenu(
-                                                    i18n.getString( 
"site-tool", llocale,
+                                                    i18n.getString( 
"site-tool", locale,
                                                                     
"decorationModel.menu.projectinformation" ),
-                                                    "/project-info.html", 
categoryReports, llocale );
+                                                    "/project-info.html", 
categoryReports, locale );
                 menu.getItems().add( item );
                 found = true;
             }
@@ -733,8 +728,8 @@ public class DefaultSiteTool
             if ( !isEmptyList( categoryReports ) )
             {
                 MenuItem item =
-                    createCategoryMenu( i18n.getString( "site-tool", llocale, 
"decorationModel.menu.projectreports" ),
-                                        "/project-reports.html", 
categoryReports, llocale );
+                    createCategoryMenu( i18n.getString( "site-tool", locale, 
"decorationModel.menu.projectreports" ),
+                                        "/project-reports.html", 
categoryReports, locale );
                 menu.getItems().add( item );
                 found = true;
             }
@@ -784,7 +779,7 @@ public class DefaultSiteTool
             {
                 if ( LOGGER.isWarnEnabled() )
                 {
-                    LOGGER.warn( "The locale '" + locale + "' (" + 
locale.getDisplayName( Locale.ENGLISH )
+                    LOGGER.warn( "The locale '" + locale + "' (" + 
locale.getDisplayName( Locale.ROOT )
                         + ") is not currently supported by Maven Site - 
IGNORING."
                         + "\nContributions are welcome and greatly 
appreciated!"
                         + "\nIf you want to contribute a new translation, 
please visit "
diff --git 
a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
 
b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
index 071ba27..3215ab7 100644
--- 
a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
+++ 
b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
@@ -367,7 +367,7 @@ public class SiteToolTest
         List<MavenProject> reactorProjects = 
Collections.<MavenProject>singletonList( parentProject );
 
         DecorationModel model = tool.getDecorationModel( new File( 
childProject.getBasedir(), "src/site" ),
-                                                         Locale.getDefault(), 
childProject, reactorProjects,
+                                                         Locale.ROOT, 
childProject, reactorProjects,
                                                          getLocalRepo(), 
childProject.getRemoteArtifactRepositories() );
         assertNotNull( model );
 
diff --git 
a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
 
b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
index 434f971..1b4c57b 100644
--- 
a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
+++ 
b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
@@ -50,7 +50,7 @@ public class SiteRenderingContext
 
     private Map<String, ?> templateProperties;
 
-    private Locale locale = Locale.getDefault();
+    private Locale locale = Locale.ROOT;
 
     private List<Locale> siteLocales = new ArrayList<Locale>();
 
diff --git 
a/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
 
b/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
index e3eb8b4..936709e 100644
--- 
a/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
+++ 
b/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
@@ -142,7 +142,7 @@ public class DefaultSiteRendererTest
         }
 
         oldLocale = Locale.getDefault();
-        Locale.setDefault( Locale.ENGLISH );
+        Locale.setDefault( Locale.ROOT );
     }
 
     /**
@@ -345,7 +345,7 @@ public class DefaultSiteRendererTest
         skin.setFile( skinFile );
         SiteRenderingContext siteRenderingContext =
             renderer.createContextForSkin( skin, attributes, new 
DecorationModel(), "defaultWindowTitle",
-                                           Locale.ENGLISH );
+                                           Locale.ROOT );
         RenderingContext context = new RenderingContext( new File( "" ), 
"document.html", "generator" );
         SiteRendererSink sink = new SiteRendererSink( context );
         renderer.mergeDocumentIntoSite( writer, sink, siteRenderingContext );
@@ -379,7 +379,7 @@ public class DefaultSiteRendererTest
         skin.setFile( skinFile );
         SiteRenderingContext siteRenderingContext =
             renderer.createContextForSkin( skin, attributes,decoration, 
"defaultWindowTitle",
-                                                   Locale.ENGLISH );
+                                                   Locale.ROOT );
         siteRenderingContext.addSiteDirectory( getTestFile( siteDir ) );
         siteRenderingContext.setValidate( validate );
 

Reply via email to