You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by tr...@apache.org on 2006/07/13 16:33:10 UTC
svn commit: r421641 -
/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
Author: trygvis
Date: Thu Jul 13 07:33:10 2006
New Revision: 421641
URL: http://svn.apache.org/viewvc?rev=421641&view=rev
Log:
o Making sure file= snippets work correctly.
Modified:
maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java
URL: http://svn.apache.org/viewvc/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java?rev=421641&r1=421640&r2=421641&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java (original)
+++ maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/snippet/SnippetMacro.java Thu Jul 13 07:33:10 2006
@@ -59,22 +59,18 @@
String fileParam = (String) request.getParameter( "file" );
- StringBuffer snippet;
+ URL url;
if ( !StringUtils.isEmpty( urlParam ) )
{
try
{
- snippet = getSnippet( new URL( urlParam ), id );
+ url = new URL( urlParam );
}
catch ( MalformedURLException e )
{
throw new IllegalArgumentException( urlParam + " is a malformed URL" );
}
- catch ( IOException e )
- {
- throw new MacroExecutionException( "Error reading snippet", e );
- }
}
else if ( !StringUtils.isEmpty( fileParam ) )
{
@@ -87,20 +83,27 @@
try
{
- snippet = new StringBuffer( FileUtils.fileRead( f ) );
+ url = f.toURL();
}
- catch ( FileNotFoundException e )
- {
- throw new MacroExecutionException( "No such file: '" + f.getAbsolutePath() + "'." );
- }
- catch ( IOException e )
+ catch ( MalformedURLException e )
{
- throw new MacroExecutionException( "Error while readin file: '" + f.getAbsolutePath() + "'.", e );
+ throw new IllegalArgumentException( urlParam + " is a malformed URL" );
}
}
else
{
throw new IllegalArgumentException( "Either the 'url' or the 'file' param has to be given." );
+ }
+
+ StringBuffer snippet;
+
+ try
+ {
+ snippet = getSnippet( url, id );
+ }
+ catch ( IOException e )
+ {
+ throw new MacroExecutionException( "Error reading snippet", e );
}
sink.verbatim( true );