Author: hboutemy
Date: Sat Jan 23 15:06:45 2016
New Revision: 1726406
URL: http://svn.apache.org/viewvc?rev=1726406&view=rev
Log:
[DOXIA-511] migrated to o.a.m.doxia.parser.module (DOXIA-510) and added
multiple extensions support (DOXIA-527)
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/AbstractITextRender.java
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/AbstractPdfRenderer.java
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java
maven/doxia/doxia-sitetools/trunk/pom.xml
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java?rev=1726406&r1=1726405&r2=1726406&view=diff
==============================================================================
---
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java
(original)
+++
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java
Sat Jan 23 15:06:45 2016
@@ -43,8 +43,8 @@ import org.apache.maven.doxia.parser.Par
import org.apache.maven.doxia.parser.Parser;
import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
import org.apache.maven.doxia.logging.PlexusLoggerWrapper;
-import org.apache.maven.doxia.module.site.SiteModule;
-import org.apache.maven.doxia.module.site.manager.SiteModuleManager;
+import org.apache.maven.doxia.parser.module.ParserModule;
+import org.apache.maven.doxia.parser.module.ParserModuleManager;
import org.apache.maven.doxia.util.XmlValidator;
import org.apache.velocity.VelocityContext;
@@ -75,7 +75,7 @@ public abstract class AbstractDocumentRe
implements DocumentRenderer
{
@Requirement
- protected SiteModuleManager siteModuleManager;
+ protected ParserModuleManager parserModuleManager;
@Requirement
protected Doxia doxia;
@@ -96,14 +96,14 @@ public abstract class AbstractDocumentRe
* Render an aggregate document from the files found in a Map.
*
* @param filesToProcess the Map of Files to process. The Map should
contain as keys the paths of the
- * source files (relative to {@link #getBaseDir() baseDir}), and the
corresponding SiteModule as values.
+ * source files (relative to {@link #getBaseDir() baseDir}), and the
corresponding ParserModule as values.
* @param outputDirectory the output directory where the aggregate
document should be generated.
* @param documentModel the document model, containing all the metadata,
etc.
* @throws org.apache.maven.doxia.docrenderer.DocumentRendererException if
any
* @throws java.io.IOException if any
* @deprecated since 1.1.2, use {@link #render(Map, File, DocumentModel,
DocumentRendererContext)}
*/
- public abstract void render( Map<String, SiteModule> filesToProcess, File
outputDirectory,
+ public abstract void render( Map<String, ParserModule> filesToProcess,
File outputDirectory,
DocumentModel documentModel )
throws DocumentRendererException, IOException;
@@ -129,14 +129,14 @@ public abstract class AbstractDocumentRe
* Render an aggregate document from the files found in a Map.
*
* @param filesToProcess the Map of Files to process. The Map should
contain as keys the paths of the
- * source files (relative to {@link #getBaseDir() baseDir}), and the
corresponding SiteModule as values.
+ * source files (relative to {@link #getBaseDir() baseDir}), and the
corresponding ParserModule as values.
* @param outputDirectory the output directory where the aggregate
document should be generated.
* @param documentModel the document model, containing all the metadata,
etc.
* @param context the rendering context when processing files.
* @throws org.apache.maven.doxia.docrenderer.DocumentRendererException if
any
* @throws java.io.IOException if any
*/
- public void render( Map<String, SiteModule> filesToProcess, File
outputDirectory, DocumentModel documentModel,
+ public void render( Map<String, ParserModule> filesToProcess, File
outputDirectory, DocumentModel documentModel,
DocumentRendererContext context )
throws DocumentRendererException, IOException
{
@@ -215,14 +215,14 @@ public abstract class AbstractDocumentRe
* Render documents separately for each file found in a Map.
*
* @param filesToProcess the Map of Files to process. The Map should
contain as keys the paths of the
- * source files (relative to {@link #getBaseDir() baseDir}), and the
corresponding SiteModule as values.
+ * source files (relative to {@link #getBaseDir() baseDir}), and the
corresponding ParserModule as values.
* @param outputDirectory the output directory where the documents should
be generated.
* @throws org.apache.maven.doxia.docrenderer.DocumentRendererException if
any
* @throws java.io.IOException if any
* @since 1.1.1
* @deprecated since 1.1.2, use {@link #renderIndividual(Map, File,
DocumentRendererContext)}
*/
- public void renderIndividual( Map<String, SiteModule> filesToProcess, File
outputDirectory )
+ public void renderIndividual( Map<String, ParserModule> filesToProcess,
File outputDirectory )
throws DocumentRendererException, IOException
{
// nop
@@ -232,14 +232,14 @@ public abstract class AbstractDocumentRe
* Render documents separately for each file found in a Map.
*
* @param filesToProcess the Map of Files to process. The Map should
contain as keys the paths of the
- * source files (relative to {@link #getBaseDir() baseDir}), and the
corresponding SiteModule as values.
+ * source files (relative to {@link #getBaseDir() baseDir}), and the
corresponding ParserModule as values.
* @param outputDirectory the output directory where the documents should
be generated.
* @param context the rendering context.
* @throws org.apache.maven.doxia.docrenderer.DocumentRendererException if
any
* @throws java.io.IOException if any
* @since 1.1.2
*/
- public void renderIndividual( Map<String, SiteModule> filesToProcess, File
outputDirectory,
+ public void renderIndividual( Map<String, ParserModule> filesToProcess,
File outputDirectory,
DocumentRendererContext context )
throws DocumentRendererException, IOException
{
@@ -248,7 +248,7 @@ public abstract class AbstractDocumentRe
/**
* Returns a Map of files to process. The Map contains as keys the paths
of the source files
- * (relative to {@link #getBaseDir() baseDir}), and the corresponding
SiteModule as values.
+ * (relative to {@link #getBaseDir() baseDir}), and the corresponding
ParserModule as values.
*
* @param baseDirectory the directory containing the source files.
* This should follow the standard Maven convention, ie
containing all the site modules.
@@ -256,52 +256,56 @@ public abstract class AbstractDocumentRe
* @throws java.io.IOException in case of a problem reading the files
under baseDirectory.
* @throws org.apache.maven.doxia.docrenderer.DocumentRendererException if
any
*/
- public Map<String, SiteModule> getFilesToProcess( File baseDirectory )
+ public Map<String, ParserModule> getFilesToProcess( File baseDirectory )
throws IOException, DocumentRendererException
{
if ( !baseDirectory.isDirectory() )
{
getLogger().warn( "No files found to process!" );
- return new HashMap<String, SiteModule>();
+ return new HashMap<String, ParserModule>();
}
setBaseDir( baseDirectory.getAbsolutePath() );
- Map<String, SiteModule> filesToProcess = new LinkedHashMap<String,
SiteModule>();
+ Map<String, ParserModule> filesToProcess = new LinkedHashMap<String,
ParserModule>();
Map<String, String> duplicatesFiles = new LinkedHashMap<String,
String>();
- Collection<SiteModule> modules = siteModuleManager.getSiteModules();
- for ( SiteModule module : modules )
+ Collection<ParserModule> modules =
parserModuleManager.getParserModules();
+ for ( ParserModule module : modules )
{
File moduleBasedir = new File( baseDirectory,
module.getSourceDirectory() );
if ( moduleBasedir.exists() )
{
// TODO: handle in/excludes
- @SuppressWarnings ( "unchecked" )
List<String> allFiles = FileUtils.getFileNames( moduleBasedir,
"**/*.*", null, false );
- String lowerCaseExtension = module.getExtension().toLowerCase(
Locale.ENGLISH );
+ String[] extensions = getExtensions( module );
List<String> docs = new LinkedList<String>( allFiles );
// Take care of extension case
for ( Iterator<String> it = docs.iterator(); it.hasNext(); )
{
String name = it.next().trim();
- if ( !name.toLowerCase( Locale.ENGLISH ).endsWith( "." +
lowerCaseExtension ) )
+ if ( !endsWithIgnoreCase( name, extensions ) )
{
it.remove();
}
}
+ String[] vmExtensions = new String[extensions.length];
+ for ( int i = 0; i < extensions.length; i++ )
+ {
+ vmExtensions[i] = extensions[i] + ".vm";
+ }
List<String> velocityFiles = new LinkedList<String>( allFiles
);
// *.xml.vm
for ( Iterator<String> it = velocityFiles.iterator();
it.hasNext(); )
{
String name = it.next().trim();
- if ( !name.toLowerCase( Locale.ENGLISH ).endsWith(
lowerCaseExtension + ".vm" ) )
+ if ( !endsWithIgnoreCase( name, vmExtensions ) )
{
it.remove();
}
@@ -334,27 +338,60 @@ public abstract class AbstractDocumentRe
return filesToProcess;
}
+ protected static String[] getExtensions( ParserModule module )
+ {
+ String[] extensions = new String[module.getExtensions().length];
+ for ( int i = module.getExtensions().length - 1; i >= 0; i-- )
+ {
+ extensions[i] = '.' + module.getExtensions()[i];
+ }
+ return extensions;
+ }
+
+ // TODO replace with StringUtils.endsWithIgnoreCase() from
maven-shared-utils 0.7
+ protected static boolean endsWithIgnoreCase( String str, String searchStr )
+ {
+ if ( str.length() < searchStr.length() )
+ {
+ return false;
+ }
+
+ return str.regionMatches( true, str.length() - searchStr.length(),
searchStr, 0, searchStr.length() );
+ }
+
+ protected static boolean endsWithIgnoreCase( String str, String[]
searchStrs )
+ {
+ for ( String searchStr : searchStrs )
+ {
+ if ( endsWithIgnoreCase( str, searchStr ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Returns a Map of files to process. The Map contains as keys the paths
of the source files
- * (relative to {@link #getBaseDir() baseDir}), and the corresponding
SiteModule as values.
+ * (relative to {@link #getBaseDir() baseDir}), and the corresponding
ParserModule as values.
*
* @param files The Collection of source files.
* @return a Map of files to process.
*/
- public Map<String, SiteModule> getFilesToProcess( Collection<String> files
)
+ public Map<String, ParserModule> getFilesToProcess( Collection<String>
files )
{
//
----------------------------------------------------------------------
// Map all the file names to parser ids
//
----------------------------------------------------------------------
- Map<String, SiteModule> filesToProcess = new HashMap<String,
SiteModule>();
+ Map<String, ParserModule> filesToProcess = new HashMap<String,
ParserModule>();
- Collection<SiteModule> modules = siteModuleManager.getSiteModules();
- for ( SiteModule siteModule : modules )
+ Collection<ParserModule> modules =
parserModuleManager.getParserModules();
+ for ( ParserModule module : modules )
{
- String extension = "." + siteModule.getExtension();
+ String[] extensions = getExtensions( module );
- String sourceDirectory = File.separator +
siteModule.getSourceDirectory() + File.separator;
+ String sourceDirectory = File.separator +
module.getSourceDirectory() + File.separator;
for ( String file : files )
{
@@ -363,14 +400,14 @@ public abstract class AbstractDocumentRe
if ( file.indexOf( sourceDirectory ) != -1 )
{
- filesToProcess.put( file, siteModule );
+ filesToProcess.put( file, module );
}
- else if ( file.toLowerCase( Locale.ENGLISH ).endsWith(
extension ) )
+ else
{
// don't overwrite if it's there already
- if ( !filesToProcess.containsKey( file ) )
+ if ( endsWithIgnoreCase( file, extensions ) &&
!filesToProcess.containsKey( file ) )
{
- filesToProcess.put( file, siteModule );
+ filesToProcess.put( file, module );
}
}
}
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/AbstractITextRender.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/AbstractITextRender.java?rev=1726406&r1=1726405&r2=1726406&view=diff
==============================================================================
---
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/AbstractITextRender.java
(original)
+++
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/itext/AbstractITextRender.java
Sat Jan 23 15:06:45 2016
@@ -51,8 +51,8 @@ import org.apache.maven.doxia.document.i
import org.apache.maven.doxia.module.itext.ITextSink;
import org.apache.maven.doxia.module.itext.ITextSinkFactory;
import org.apache.maven.doxia.module.itext.ITextUtil;
-import org.apache.maven.doxia.module.site.SiteModule;
-import org.apache.maven.doxia.module.site.manager.SiteModuleManager;
+import org.apache.maven.doxia.parser.module.ParserModule;
+import org.apache.maven.doxia.parser.module.ParserModuleManager;
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
import org.apache.xml.utils.DefaultErrorHandler;
@@ -91,7 +91,7 @@ public abstract class AbstractITextRende
/**
* @plexus.requirement
*/
- protected SiteModuleManager siteModuleManager;
+ protected ParserModuleManager parserModuleManager;
/**
* @plexus.requirement
@@ -103,20 +103,36 @@ public abstract class AbstractITextRende
TRANSFORMER_FACTORY.setErrorListener( new DefaultErrorHandler() );
}
+ private List<String> getModuleFileNames( ParserModule module, File
moduleBasedir )
+ throws IOException
+ {
+ StringBuilder includes = new StringBuilder();
+
+ for ( String extension: module.getExtensions() )
+ {
+ if ( includes.length() > 0 )
+ {
+ includes.append( ',' );
+ }
+ includes.append( "**/*." );
+ includes.append( extension );
+ }
+
+ return FileUtils.getFileNames( moduleBasedir, includes.toString(),
null, false );
+ }
+
/** {@inheritDoc} */
public void render( File siteDirectory, File outputDirectory )
throws DocumentRendererException, IOException
{
- Collection<SiteModule> modules = siteModuleManager.getSiteModules();
- for ( SiteModule module : modules )
+ Collection<ParserModule> modules =
parserModuleManager.getParserModules();
+ for ( ParserModule module : modules )
{
File moduleBasedir = new File( siteDirectory,
module.getSourceDirectory() );
if ( moduleBasedir.exists() )
{
- @SuppressWarnings ( "unchecked" )
- List<String> docs =
- FileUtils.getFileNames( moduleBasedir, "**/*." +
module.getExtension(), null, false );
+ List<String> docs = getModuleFileNames( module, moduleBasedir
);
for ( String doc : docs )
{
@@ -195,16 +211,15 @@ public abstract class AbstractITextRende
}
List<File> iTextFiles = new LinkedList<File>();
- Collection<SiteModule> modules = siteModuleManager.getSiteModules();
- for ( SiteModule module : modules )
+ Collection<ParserModule> modules =
parserModuleManager.getParserModules();
+ for ( ParserModule module : modules )
{
File moduleBasedir = new File( siteDirectory,
module.getSourceDirectory() );
if ( moduleBasedir.exists() )
{
@SuppressWarnings ( "unchecked" )
- List<String> docs =
- FileUtils.getFileNames( moduleBasedir, "**/*." +
module.getExtension(), null, false );
+ List<String> docs = getModuleFileNames( module, moduleBasedir
);
for ( String doc : docs )
{
@@ -296,7 +311,7 @@ public abstract class AbstractITextRende
* @throws org.apache.maven.doxia.docrenderer.DocumentRendererException
* @throws java.io.IOException
*/
- private void parse( String fullPathDoc, SiteModule module, File
outputITextFile )
+ private void parse( String fullPathDoc, ParserModule module, File
outputITextFile )
throws DocumentRendererException, IOException
{
Writer writer = WriterFactory.newXmlWriter( outputITextFile );
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/AbstractPdfRenderer.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/AbstractPdfRenderer.java?rev=1726406&r1=1726405&r2=1726406&view=diff
==============================================================================
---
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/AbstractPdfRenderer.java
(original)
+++
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/AbstractPdfRenderer.java
Sat Jan 23 15:06:45 2016
@@ -26,7 +26,7 @@ import java.util.Map;
import org.apache.maven.doxia.docrenderer.AbstractDocumentRenderer;
import org.apache.maven.doxia.docrenderer.DocumentRendererException;
import org.apache.maven.doxia.document.DocumentModel;
-import org.apache.maven.doxia.module.site.SiteModule;
+import org.apache.maven.doxia.parser.module.ParserModule;
/**
* Abstract pdf renderer, this doesn't depend on the framework.
@@ -46,7 +46,7 @@ public abstract class AbstractPdfRendere
}
/** {@inheritDoc} */
- public void render( Map<String, SiteModule> filesToProcess, File
outputDirectory, DocumentModel documentModel )
+ public void render( Map<String, ParserModule> filesToProcess, File
outputDirectory, DocumentModel documentModel )
throws DocumentRendererException, IOException
{
render( filesToProcess, outputDirectory, documentModel, null );
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java?rev=1726406&r1=1726405&r2=1726406&view=diff
==============================================================================
---
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java
(original)
+++
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/fo/FoPdfRenderer.java
Sat Jan 23 15:06:45 2016
@@ -40,7 +40,7 @@ import org.apache.maven.doxia.module.fo.
import org.apache.maven.doxia.module.fo.FoSink;
import org.apache.maven.doxia.module.fo.FoSinkFactory;
import org.apache.maven.doxia.module.fo.FoUtils;
-import org.apache.maven.doxia.module.site.SiteModule;
+import org.apache.maven.doxia.parser.module.ParserModule;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
@@ -73,7 +73,7 @@ public class FoPdfRenderer
/** {@inheritDoc} */
@Override
- public void render( Map<String, SiteModule> filesToProcess, File
outputDirectory, DocumentModel documentModel )
+ public void render( Map<String, ParserModule> filesToProcess, File
outputDirectory, DocumentModel documentModel )
throws DocumentRendererException, IOException
{
render( filesToProcess, outputDirectory, documentModel, null );
@@ -81,7 +81,7 @@ public class FoPdfRenderer
/** {@inheritDoc} */
@Override
- public void render( Map<String, SiteModule> filesToProcess, File
outputDirectory, DocumentModel documentModel,
+ public void render( Map<String, ParserModule> filesToProcess, File
outputDirectory, DocumentModel documentModel,
DocumentRendererContext context )
throws DocumentRendererException, IOException
{
@@ -183,7 +183,7 @@ public class FoPdfRenderer
/** {@inheritDoc} */
@Override
- public void renderIndividual( Map<String, SiteModule> filesToProcess, File
outputDirectory )
+ public void renderIndividual( Map<String, ParserModule> filesToProcess,
File outputDirectory )
throws DocumentRendererException, IOException
{
renderIndividual( filesToProcess, outputDirectory, null );
@@ -191,23 +191,26 @@ public class FoPdfRenderer
/** {@inheritDoc} */
@Override
- public void renderIndividual( Map<String, SiteModule> filesToProcess, File
outputDirectory,
+ public void renderIndividual( Map<String, ParserModule> filesToProcess,
File outputDirectory,
DocumentRendererContext context )
throws DocumentRendererException, IOException
{
- for ( Map.Entry<String, SiteModule> entry : filesToProcess.entrySet() )
+ for ( Map.Entry<String, ParserModule> entry :
filesToProcess.entrySet() )
{
String key = entry.getKey();
- SiteModule module = entry.getValue();
+ ParserModule module = entry.getValue();
File fullDoc = new File( getBaseDir(), module.getSourceDirectory()
+ File.separator + key );
String output = key;
- String lowerCaseExtension = module.getExtension().toLowerCase(
Locale.ENGLISH );
- if ( output.toLowerCase( Locale.ENGLISH ).indexOf( "." +
lowerCaseExtension ) != -1 )
+ for ( String extension : module.getExtensions() )
{
- output =
- output.substring( 0, output.toLowerCase( Locale.ENGLISH
).indexOf( "." + lowerCaseExtension ) );
+ String lowerCaseExtension = extension.toLowerCase(
Locale.ENGLISH );
+ if ( output.toLowerCase( Locale.ENGLISH ).indexOf( "." +
lowerCaseExtension ) != -1 )
+ {
+ output =
+ output.substring( 0, output.toLowerCase(
Locale.ENGLISH ).indexOf( "." + lowerCaseExtension ) );
+ }
}
File outputFOFile = new File( outputDirectory, output + ".fo" );
@@ -232,14 +235,14 @@ public class FoPdfRenderer
}
}
- private void mergeAllSources( Map<String, SiteModule> filesToProcess,
FoAggregateSink sink,
+ private void mergeAllSources( Map<String, ParserModule> filesToProcess,
FoAggregateSink sink,
DocumentRendererContext context )
throws DocumentRendererException, IOException
{
- for ( Map.Entry<String, SiteModule> entry : filesToProcess.entrySet() )
+ for ( Map.Entry<String, ParserModule> entry :
filesToProcess.entrySet() )
{
String key = entry.getKey();
- SiteModule module = entry.getValue();
+ ParserModule module = entry.getValue();
sink.setDocumentName( key );
File fullDoc = new File( getBaseDir(), module.getSourceDirectory()
+ File.separator + key );
@@ -287,36 +290,39 @@ public class FoPdfRenderer
DocumentRendererContext context )
throws DocumentRendererException, IOException
{
- Collection<SiteModule> modules = siteModuleManager.getSiteModules();
- for ( SiteModule module : modules )
+ Collection<ParserModule> modules =
parserModuleManager.getParserModules();
+ for ( ParserModule module : modules )
{
File moduleBasedir = new File( getBaseDir(),
module.getSourceDirectory() );
if ( moduleBasedir.exists() )
{
- String doc = href + "." + module.getExtension();
- File source = new File( moduleBasedir, doc );
-
- // Velocity file?
- if ( !source.exists() )
+ for ( String extension : module.getExtensions() )
{
- if ( href.indexOf( "." + module.getExtension() ) != -1 )
+ String doc = href + "." + extension;
+ File source = new File( moduleBasedir, doc );
+
+ // Velocity file?
+ if ( !source.exists() )
{
- doc = href + ".vm";
+ if ( href.indexOf( "." + extension ) != -1 )
+ {
+ doc = href + ".vm";
+ }
+ else
+ {
+ doc = href + "." + extension + ".vm";
+ }
+ source = new File( moduleBasedir, doc );
}
- else
+
+ if ( source.exists() )
{
- doc = href + "." + module.getExtension() + ".vm";
+ sink.setDocumentName( doc );
+ sink.setDocumentTitle( tocItem.getName() );
+
+ parse( source.getPath(), module.getParserId(), sink,
context );
}
- source = new File( moduleBasedir, doc );
- }
-
- if ( source.exists() )
- {
- sink.setDocumentName( doc );
- sink.setDocumentTitle( tocItem.getName() );
-
- parse( source.getPath(), module.getParserId(), sink,
context );
}
}
}
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java?rev=1726406&r1=1726405&r2=1726406&view=diff
==============================================================================
---
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java
(original)
+++
maven/doxia/doxia-sitetools/trunk/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/pdf/itext/ITextPdfRenderer.java
Sat Jan 23 15:06:45 2016
@@ -59,7 +59,7 @@ import org.apache.maven.doxia.document.D
import org.apache.maven.doxia.module.itext.ITextSink;
import org.apache.maven.doxia.module.itext.ITextSinkFactory;
import org.apache.maven.doxia.module.itext.ITextUtil;
-import org.apache.maven.doxia.module.site.SiteModule;
+import org.apache.maven.doxia.parser.module.ParserModule;
import org.apache.xml.utils.DefaultErrorHandler;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
@@ -135,7 +135,7 @@ public class ITextPdfRenderer
/** {@inheritDoc} */
@Override
- public void render( Map<String, SiteModule> filesToProcess, File
outputDirectory, DocumentModel documentModel )
+ public void render( Map<String, ParserModule> filesToProcess, File
outputDirectory, DocumentModel documentModel )
throws DocumentRendererException, IOException
{
render( filesToProcess, outputDirectory, documentModel, null );
@@ -143,7 +143,7 @@ public class ITextPdfRenderer
/** {@inheritDoc} */
@Override
- public void render( Map<String, SiteModule> filesToProcess, File
outputDirectory, DocumentModel documentModel,
+ public void render( Map<String, ParserModule> filesToProcess, File
outputDirectory, DocumentModel documentModel,
DocumentRendererContext context )
throws DocumentRendererException, IOException
{
@@ -199,7 +199,7 @@ public class ITextPdfRenderer
/** {@inheritDoc} */
@Override
- public void renderIndividual( Map<String, SiteModule> filesToProcess, File
outputDirectory )
+ public void renderIndividual( Map<String, ParserModule> filesToProcess,
File outputDirectory )
throws DocumentRendererException, IOException
{
renderIndividual( filesToProcess, outputDirectory, null );
@@ -207,22 +207,25 @@ public class ITextPdfRenderer
/** {@inheritDoc} */
@Override
- public void renderIndividual( Map<String, SiteModule> filesToProcess, File
outputDirectory,
+ public void renderIndividual( Map<String, ParserModule> filesToProcess,
File outputDirectory,
DocumentRendererContext context )
throws DocumentRendererException, IOException
{
- for ( Map.Entry<String, SiteModule> entry : filesToProcess.entrySet() )
+ for ( Map.Entry<String, ParserModule> entry :
filesToProcess.entrySet() )
{
String key = entry.getKey();
- SiteModule module = entry.getValue();
+ ParserModule module = entry.getValue();
File fullDoc = new File( getBaseDir(), module.getSourceDirectory()
+ File.separator + key );
String output = key;
- String lowerCaseExtension = module.getExtension().toLowerCase(
Locale.ENGLISH );
- if ( output.toLowerCase( Locale.ENGLISH ).indexOf( "." +
lowerCaseExtension ) != -1 )
+ for ( String extension : module.getExtensions() )
{
- output =
- output.substring( 0, output.toLowerCase( Locale.ENGLISH
).indexOf( "." + lowerCaseExtension ) );
+ String lowerCaseExtension = extension.toLowerCase(
Locale.ENGLISH );
+ if ( output.toLowerCase( Locale.ENGLISH ).indexOf( "." +
lowerCaseExtension ) != -1 )
+ {
+ output =
+ output.substring( 0, output.toLowerCase(
Locale.ENGLISH ).indexOf( "." + lowerCaseExtension ) );
+ }
}
File outputITextFile = new File( outputDirectory, output + ".xml"
);
@@ -257,7 +260,7 @@ public class ITextPdfRenderer
* @throws DocumentRendererException in case of a parsing problem.
* @throws IOException if the source and/or target document cannot be
opened.
*/
- private void parse( File fullDoc, SiteModule module, File iTextFile,
DocumentRendererContext context )
+ private void parse( File fullDoc, ParserModule module, File iTextFile,
DocumentRendererContext context )
throws DocumentRendererException, IOException
{
if ( getLogger().isDebugEnabled() )
@@ -541,15 +544,15 @@ public class ITextPdfRenderer
* @throws IOException if any
* @since 1.1.1
*/
- private List<File> parseAllFiles( Map<String, SiteModule> filesToProcess,
File outputDirectory,
+ private List<File> parseAllFiles( Map<String, ParserModule>
filesToProcess, File outputDirectory,
DocumentRendererContext context )
throws DocumentRendererException, IOException
{
List<File> iTextFiles = new LinkedList<File>();
- for ( Map.Entry<String, SiteModule> entry : filesToProcess.entrySet() )
+ for ( Map.Entry<String, ParserModule> entry :
filesToProcess.entrySet() )
{
String key = entry.getKey();
- SiteModule module = entry.getValue();
+ ParserModule module = entry.getValue();
File fullDoc = new File( getBaseDir(), module.getSourceDirectory()
+ File.separator + key );
String outputITextName = key.substring( 0, key.lastIndexOf( '.' )
+ 1 ) + "xml";
@@ -598,42 +601,45 @@ public class ITextPdfRenderer
href = href.substring( 0, href.lastIndexOf( '.' ) );
}
- Collection<SiteModule> modules =
siteModuleManager.getSiteModules();
- for ( SiteModule module : modules )
+ Collection<ParserModule> modules =
parserModuleManager.getParserModules();
+ for ( ParserModule module : modules )
{
File moduleBasedir = new File( getBaseDir(),
module.getSourceDirectory() );
if ( moduleBasedir.exists() )
{
- String doc = href + "." + module.getExtension();
- File source = new File( moduleBasedir, doc );
-
- // Velocity file?
- if ( !source.exists() )
+ for ( String extension : module.getExtensions() )
{
- if ( href.indexOf( "." + module.getExtension() ) != -1
)
+ String doc = href + "." + extension;
+ File source = new File( moduleBasedir, doc );
+
+ // Velocity file?
+ if ( !source.exists() )
{
- doc = href + ".vm";
+ if ( href.indexOf( "." + extension ) != -1 )
+ {
+ doc = href + ".vm";
+ }
+ else
+ {
+ doc = href + "." + extension + ".vm";
+ }
+ source = new File( moduleBasedir, doc );
}
- else
+
+ if ( source.exists() )
{
- doc = href + "." + module.getExtension() + ".vm";
+ String outputITextName = doc.substring( 0,
doc.lastIndexOf( '.' ) + 1 ) + "xml";
+ File outputITextFileTmp = new File(
outputDirectory, outputITextName );
+ outputITextFileTmp.deleteOnExit();
+ if ( !outputITextFileTmp.getParentFile().exists() )
+ {
+ outputITextFileTmp.getParentFile().mkdirs();
+ }
+
+ iTextFiles.add( outputITextFileTmp );
+ parse( source, module, outputITextFileTmp, context
);
}
- source = new File( moduleBasedir, doc );
- }
-
- if ( source.exists() )
- {
- String outputITextName = doc.substring( 0,
doc.lastIndexOf( '.' ) + 1 ) + "xml";
- File outputITextFileTmp = new File( outputDirectory,
outputITextName );
- outputITextFileTmp.deleteOnExit();
- if ( !outputITextFileTmp.getParentFile().exists() )
- {
- outputITextFileTmp.getParentFile().mkdirs();
- }
-
- iTextFiles.add( outputITextFileTmp );
- parse( source, module, outputITextFileTmp, context );
}
}
}
Modified: maven/doxia/doxia-sitetools/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/pom.xml?rev=1726406&r1=1726405&r2=1726406&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/pom.xml (original)
+++ maven/doxia/doxia-sitetools/trunk/pom.xml Sat Jan 23 15:06:45 2016
@@ -265,6 +265,9 @@ under the License.
<!-- DOXIASITETOOLS-85 RenderingContext package changed -->
<exclude>org/apache/maven/doxia/siterenderer/*Renderer</exclude>
<exclude>org/apache/maven/doxia/siterenderer/sink/*</exclude>
+ <!-- DOXIA-511 -->
+
<exclude>org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer</exclude>
+
<exclude>org/apache/maven/doxia/docrenderer/itext/AbstractITextRender</exclude>
</excludes>
</configuration>
</execution>