You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2018/04/16 21:54:59 UTC

[maven-doxia-sitetools] branch master updated (bc54697 -> 053dcf9)

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

hboutemy pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git.


    from bc54697  updated Modello xsd url
     new 3e4c971  extracted method for better understanding
     new 053dcf9  [DOXIASITETOOLS-179] catch VelocityException instead of Exception

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../doxia/siterenderer/DefaultSiteRenderer.java    | 57 ++++++++++------------
 1 file changed, 27 insertions(+), 30 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
hboutemy@apache.org.

[maven-doxia-sitetools] 02/02: [DOXIASITETOOLS-179] catch VelocityException instead of Exception

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 053dcf9db0046bacfe5b1b47a4842011de7128cf
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Mon Apr 16 23:54:57 2018 +0200

    [DOXIASITETOOLS-179] catch VelocityException instead of Exception
    
    and keep cause message to display parsing error location
---
 .../maven/doxia/siterenderer/DefaultSiteRenderer.java  | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
index a279e9e..13eea52 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
@@ -383,7 +383,7 @@ public class DefaultSiteRenderer
             // TODO: DOXIA-111: the filter used here must be checked generally.
             if ( docRenderingContext.getAttribute( "velocity" ) != null )
             {
-                getLogger().debug( "Processing Velocity for " + docRenderingContext.getInputName() );
+                getLogger().debug( "Processing Velocity for " + docRenderingContext.getDoxiaSourcePath() );
                 try
                 {
                     Context vc = createDocumentVelocityContext( docRenderingContext, siteContext );
@@ -402,16 +402,10 @@ public class DefaultSiteRenderer
 
                     reader = new StringReader( doxiaContent );
                 }
-                catch ( Exception e )
+                catch ( VelocityException e )
                 {
-                    if ( getLogger().isDebugEnabled() )
-                    {
-                        getLogger().error( "Error parsing " + resource + " as a velocity template, using as text.", e );
-                    }
-                    else
-                    {
-                        getLogger().error( "Error parsing " + resource + " as a velocity template, using as text." );
-                    }
+                    throw new RendererException( "Error parsing " + docRenderingContext.getDoxiaSourcePath()
+                        + " as a Velocity template: " + e.getMessage(), e );
                 }
 
                 if ( parser.getType() == Parser.XML_TYPE && siteContext.isValidate() )
@@ -439,10 +433,6 @@ public class DefaultSiteRenderer
             }
             sink.enableLogging( new PlexusLoggerWrapper( getLogger() ) );
 
-            if ( reader == null ) // can happen if velocity throws above
-            {
-                throw new RendererException( "Error getting a parser for '" + doc + "'" );
-            }
             doxia.parse( reader, docRenderingContext.getParserId(), sink );
         }
         catch ( ParserNotFoundException e )

-- 
To stop receiving notification emails like this one, please contact
hboutemy@apache.org.

[maven-doxia-sitetools] 01/02: extracted method for better understanding

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3e4c9714711a5395fc2f8bd44e03d532387322c0
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Mon Apr 16 23:51:05 2018 +0200

    extracted method for better understanding
---
 .../doxia/siterenderer/DefaultSiteRenderer.java    | 39 +++++++++++++---------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
index f7abb91..a279e9e 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
@@ -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.
      *

-- 
To stop receiving notification emails like this one, please contact
hboutemy@apache.org.