extracted method for better understanding
authorHervé Boutemy <hboutemy@apache.org>
Mon, 16 Apr 2018 21:51:05 +0000 (23:51 +0200)
committerHervé Boutemy <hboutemy@apache.org>
Mon, 16 Apr 2018 21:51:05 +0000 (23:51 +0200)
doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java

index f7abb91..a279e9e 100644 (file)
@@ -397,22 +397,7 @@ public class DefaultSiteRenderer
                     if ( siteContext.getProcessedContentOutput() != null )
                     {
                         // save Velocity processing result, ie the Doxia content that will be parsed after
-                        if ( !siteContext.getProcessedContentOutput().exists() )
-                        {
-                            siteContext.getProcessedContentOutput().mkdirs();
-                        }
-
-                        String input = docRenderingContext.getInputName();
-                        File outputFile = new File( siteContext.getProcessedContentOutput(),
-                                                    input.substring( 0, input.length() - 3 ) );
-
-                        File outputParent = outputFile.getParentFile();
-                        if ( !outputParent.exists() )
-                        {
-                            outputParent.mkdirs();
-                        }
-
-                        FileUtils.fileWrite( outputFile, siteContext.getInputEncoding(), doxiaContent );
+                        saveVelocityProcessedContent( docRenderingContext, siteContext, doxiaContent );
                     }
 
                     reader = new StringReader( doxiaContent );
@@ -485,6 +470,28 @@ public class DefaultSiteRenderer
         mergeDocumentIntoSite( writer, (DocumentContent) sink, siteContext );
     }
 
+    private void saveVelocityProcessedContent( RenderingContext docRenderingContext, SiteRenderingContext siteContext,
+                                               String doxiaContent )
+        throws IOException
+    {
+        if ( !siteContext.getProcessedContentOutput().exists() )
+        {
+            siteContext.getProcessedContentOutput().mkdirs();
+        }
+
+        String input = docRenderingContext.getInputName();
+        File outputFile = new File( siteContext.getProcessedContentOutput(),
+                                    input.substring( 0, input.length() - 3 ) );
+
+        File outputParent = outputFile.getParentFile();
+        if ( !outputParent.exists() )
+        {
+            outputParent.mkdirs();
+        }
+
+        FileUtils.fileWrite( outputFile, siteContext.getInputEncoding(), doxiaContent );
+    }
+
     /**
      * Creates a Velocity Context with all generic tools configured wit the site rendering context.
      *