Author: metskem
Date: Thu Feb 26 21:57:21 2009
New Revision: 748329
URL: http://svn.apache.org/viewvc?rev=748329&view=rev
Log:
3.0.0-svn-74 plugin localization, some strong type checking, IfPlugin style
reformatting, updated Dutch translation, fixed TranslationsCheck
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/CoreResources_nl.properties
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/plugin/PluginResources.properties
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/plugin/PluginResources_nl.properties
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/templates/default_nl.properties
incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/BugReportHandler.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Denounce.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/IfPlugin.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Image.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/InterWikiLinksPlugin.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/PluginManager.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/TableOfContents.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java
incubator/jspwiki/trunk/tests/java/TranslationsCheck.java
incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java
Modified: incubator/jspwiki/trunk/ChangeLog
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Thu Feb 26 21:57:21 2009
@@ -1,3 +1,17 @@
+2009-02-26 Harry Metske <[email protected]>
+
+ * 3.0.0-svn-74
+
+ * localized messages in all plugin
+
+ * updated Dutch translation
+
+ * reformatted the IfPlugin
+
+ * added a few strong typing
+
+ * fixed the TranslationsCheck (location of i18n files were changed)
+
2009-02-25 Harry Metske <[email protected]>
* 3.0.0-svn-73
Modified:
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/CoreResources_nl.properties
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/CoreResources_nl.properties?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/CoreResources_nl.properties
(original)
+++
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/CoreResources_nl.properties
Thu Feb 26 21:57:21 2009
@@ -6,8 +6,6 @@
# " = "
# ' = ' Note that ' is NOT HTML, and does not necessarily work in
all browsers.
-# Comment.jsp
-comment.by=Reactie van {0}
# Common things
# Date format used across JSPWiki. Please see "SimpleDateFormat" on
information
@@ -154,7 +152,6 @@
varmgr.authenticated=geauthenticeerd
varmgr.asserted=aangenomen identiteit
varmgr.anonymous=anoniem
-varmgr.dateformat.invalid=ongeldig datum formaat opgegeven:
varmgr.dateformat.noformat=geen datum formaat opgegeven.
######################################################################
@@ -199,3 +196,39 @@
attach.add.selectfile=Selecteer een bestand:
#Copied from src/WebContent/WEB-INF/classes/templates/default.properties.
attach.add.changenote=Opmerking:
+
+converter.byte.outOfRange = De waarde ({1}) opgegeven in veld {0} is buiten
het bereik van {2} tot {3}
+converter.creditCard.invalidCreditCard = De waarde ({1}) is geen geldig credit
card number
+converter.date.invalidDate = De waarde ({1}) opgegeven in veld {0} moet een
geldige datum zijn
+converter.email.invalidEmail = De opgegeven waarde ({1}) is geen geldig email
address
+converter.enum.notAnEnumeratedValue = De waarde "{1}" is niet geldig voor veld
{0}
+converter.float.outOfRange = De waarde ({1}) opgegeven in veld {0} is buiten
het bereik van {2} tot {3}
+converter.integer.outOfRange = De waarde ({1}) opgegeven in veld {0} is buiten
het bereik van {2} tot {3}
+converter.number.invalidNumber = De waarde ({1}) opgegeven in veld {0} moet
een geldig getal zijn
+converter.short.outOfRange = De waarde ({1}) opgegeven in veld {0} is buiten
het bereik van {2} tot {3}
+profile.nameCollision = The {0} is al in gebruik
+profile.noPasswordMatch = Wachtwoorde moeten gelijk zijn
+profile.saveError = Onverwacht probleem bij het opslaan van het profiel
+stripes.errors.afterError = </li>
+stripes.errors.beforeError = <li style="color: #b72222;">
+stripes.errors.footer = </ol>
+stripes.errors.header = <div style="color:#b72222; font-weight: bold">Gaarne
de volgende fouten herstellen:</div><ol>
+stripes.fieldErrors.afterError = </span><br />
+stripes.fieldErrors.beforeError = <span style="color: #b72222;">
+stripes.fieldErrors.footer =
+stripes.fieldErrors.header =
+stripes.messages.afterMessage = </li>
+stripes.messages.beforeMessage = <li>
+stripes.messages.footer = </ul>
+stripes.messages.header = <ul class="messages">
+validation.expression.valueFailedExpression = De waarde opgegeven ({1}) voor
veld {0} is ongeldig
+validation.file.postBodyTooBig = Totale upload size van {3} KB overschrijdt de
maximaal toegestane waarde van {2} KB
+validation.mask.valueDoesNotMatch = <em>{1}</em> is geen geldig {0}
+validation.maxlength.valueTooLong = {0} dient meer dan {2} characters lang te
zijn
+validation.maxvalue.valueAboveMaximum = De maximale waarde voor {0} is {2}
+validation.minlength.valueTooShort = {0} moet minimaal {2} characters lang zijn
+validation.minvalue.valueBelowMinimum = De minimale waarde voor {0} is {2}
+validation.required.valueNotPresent = {0} is een verplicht veld
+varmgr.dateformat.invalid.format = Geen geldig datum formaat opgegeven:
+varmgr.dateformat.invalid.parm = Parameter niet herkend:
+version.invalid = Versie {1} bestaat niet.
\ No newline at end of file
Modified:
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/plugin/PluginResources.properties
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/plugin/PluginResources.properties?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/plugin/PluginResources.properties
(original)
+++
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/plugin/PluginResources.properties
Thu Feb 26 21:57:21 2009
@@ -15,13 +15,14 @@
# TableOfContents
tableofcontents.title = Table of Contents
+tableofcontents.unable.construct=Unable to construct table of contents (see
logs)
# BugReportHandler
bugreporthandler.new = A new page has been created: {0}
bugreporthandler.unable = Unable to create a new page!
bugreporthandler.titlerequired = Title is required!
-
+bugreporthandler.savenotallowed=Saving not allowed, reason:
# CurrentTimePlugin
currenttimeplugin.badformat = You specified a bad format
@@ -62,4 +63,26 @@
plugin.insert.nopage1=There is no page called
plugin.insert.nopage2=Would you like to
plugin.insert.nopage3=create it?
-plugin.insert.definepage=You have to define a page!
\ No newline at end of file
+plugin.insert.definepage=You have to define a page!
+
+# AbstractFilteredPlugin
+plugin.abstract.excludeparm.malformed=Exclude-parameter has a malformed
pattern:
+plugin.abstract.includeparm.malformed=Include-parameter has a malformed
pattern:
+plugin.abstract.showLastModified=showLastModified=true is only valid if
show=count is also specified
+
+# DenouncePlugin
+plugin.denounce.no.parameter=Denounce: No parameter defined:
+
+# IfPlugin
+plugin.if.faulty.pattern=Faulty pattern:
+
+# ImagePlugin
+plugin.image.parmsrc.req.1=Parameter
+plugin.image.parmsrc.req.2=is required for Image plugin
+plugin.image.attachinfo.failed=Attachment info failed:
+
+# InterWikiLinksPlugin
+plugin.interwikilinks.noconstruct=Unable to construct InterwikiLinks plugin
output (see logs)
+
+# UndefinedPagesPlugin
+plugin.undefined.parm.invalid=parameter is not valid for the
UndefinedPagesPlugin :
\ No newline at end of file
Modified:
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/plugin/PluginResources_nl.properties
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/plugin/PluginResources_nl.properties?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/plugin/PluginResources_nl.properties
(original)
+++
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/plugin/PluginResources_nl.properties
Thu Feb 26 21:57:21 2009
@@ -20,12 +20,14 @@
# TableOfContents
tableofcontents.title=Inhoudsopgave
+tableofcontents.unable.construct=Kon de inhoudsopgave niet opmaken (kijk in
de logs)
# BugReportHandler
bugreporthandler.new=Nieuwe pagina gemaakt: {0}
bugreporthandler.unable=Kon geen nieuwe pagina aanmaken
bugreporthandler.titlerequired=Een titel is verplicht !
+bugreporthandler.savenotallowed=Opslaan niet toegestaan, reden:
# CurrentTimePlugin
@@ -70,4 +72,26 @@
plugin.insert.nopage1=Er bestaat geen pagina met de naam
plugin.insert.nopage2=Wil je 'm
plugin.insert.nopage3=aanmaken ?
-plugin.insert.definepage=Je moet een pagina opgeven !
\ No newline at end of file
+plugin.insert.definepage=Je moet een pagina opgeven !
+
+# AbstractFilteredPlugin
+plugin.abstract.excludeparm.malformed=Exclude-parameter heeft een ongeldig
patroon:
+plugin.abstract.includeparm.malformed=Include-parameter heeft een ongeldig
patroon:
+plugin.abstract.showLastModified=showLastModified=true is alleen geldig als
show=count ook is opgegeven
+
+# DenouncePlugin
+plugin.denounce.no.parameter=Denounce: Geen parameter gedefinieerd:
+
+# IfPlugin
+plugin.if.faulty.pattern=Vaut patroon:
+
+# ImagePlugin
+plugin.image.parmsrc.req.1=Parameter
+plugin.image.parmsrc.req.2=is verplicht voor de Image plugin
+plugin.image.attachinfo.failed=Attachment info fout:
+
+# InterWikiLinksPlugin
+plugin.interwikilinks.noconstruct=Kon InterwikiLinks plugin output niet
genereren (kijk in de logs)
+
+# UndefinedPagesPlugin
+plugin.undefined.parm.invalid=parameter is not geldig voor de
UndefinedPagesPlugin
\ No newline at end of file
Modified:
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/templates/default_nl.properties
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/templates/default_nl.properties?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/templates/default_nl.properties
(original)
+++
incubator/jspwiki/trunk/src/WebContent/WEB-INF/classes/templates/default_nl.properties
Thu Feb 26 21:57:21 2009
@@ -445,8 +445,6 @@
javascript.edit.toolbar.makeSelection=Gelieve eerst een selectie te maken
javascript.edit.resize=Sleep om de grootte van het tekstveld te wijzigen
javascript.edit.areyousure=Indien u de Bewaar knop niet gebruikt, worden uw
wijzigingen niet bewaard. Weet u zeker dat u deze pagina wilt verlaten ?
-javascript.favs.show=Click om favorieten weer te geven
-javascript.favs.hide=Click om favorieten te verbergen
javascript.quick.edit=[Bewerk]
javascript.quick.edit.title=Bewerk sectie {0}...
javascript.collapse=Klik om de inhoud dicht te klappen
@@ -468,3 +466,11 @@
javascript.sectionediting.label=Sectie Overzicht
javascript.tip.default.title=Meer...
javascript.prefs.areyousure=Indien u de Bewaar Gebruikers Instellingen knop
niet gebruikt, worden uw wijzigingen niet bewaard. Weet u zeker dat u deze
pagina wilt verlaten ?
+
+Orientation.LEFT = Links
+Orientation.RIGHT = Rechts
+editgroup.illegalname = De groep naam {1} is ongeldig. Kies een andere!
+javascript.favorites.hide = Klik om je favorieten te verbergen
+javascript.favorites.show = Klik om je favorieten te tonen
+login.lostpw.name = Account email
+login.lostpw.submit = Reset wachtwoord!
\ No newline at end of file
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Thu Feb 26
21:57:21 2009
@@ -77,7 +77,7 @@
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "73";
+ public static final String BUILD = "74";
/**
* This is the generic version string you should use
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/AbstractFilteredPlugin.java
Thu Feb 26 21:57:21 2009
@@ -123,7 +123,7 @@
* @throws PluginException if any of the plugin parameters are malformed
*/
// FIXME: The compiled pattern strings should really be cached somehow.
- public void initialize( WikiContext context, Map params )
+ public void initialize( WikiContext context, Map<String,String> params )
throws PluginException
{
m_dateFormat = Preferences.getDateFormat( context, TimeFormat.DATETIME
);
@@ -181,7 +181,9 @@
}
catch( PatternSyntaxException e )
{
- throw new PluginException("Exclude-parameter has a malformed
pattern: "+e.getMessage());
+ throw new PluginException( context.getBundle(
WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE )
+ .getString( "plugin.abstract.excludeparm.malformed" )
+ + e.getMessage() );
}
}
@@ -205,7 +207,9 @@
}
catch( PatternSyntaxException e )
{
- throw new PluginException("Include-parameter has a malformed
pattern: "+e.getMessage());
+ throw new PluginException( context.getBundle(
WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE )
+ .getString( "plugin.abstract.includeparm.malformed" )
+ + e.getMessage() );
}
}
@@ -232,7 +236,8 @@
}
else
{
- throw new PluginException( "showLastModified=true is only
valid if show=count is also specified" );
+ throw new PluginException( context.getBundle(
WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE )
+ .getString( "plugin.abstract.showLastModified" ) );
}
}
}
@@ -346,14 +351,14 @@
* @param numItems How many items to show.
* @return The WikiText
*/
- protected String wikitizeCollection( Collection links, String separator,
int numItems )
+ protected String wikitizeCollection( Collection<String> links, String
separator, int numItems )
{
if( links == null || links.isEmpty() )
return "";
StringBuilder output = new StringBuilder();
- Iterator it = links.iterator();
+ Iterator<String> it = links.iterator();
int count = 0;
//
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/BugReportHandler.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/BugReportHandler.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/BugReportHandler.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/BugReportHandler.java
Thu Feb 26 21:57:21 2009
@@ -185,7 +185,7 @@
{
log.info("Saving not allowed, reason: '"+e.getMessage()+"', can't
redirect to "+e.getRedirect());
- throw new PluginException("Saving not allowed, reason:
"+e.getMessage());
+ throw new PluginException( rb.getString(
"bugreporthandler.savenotallowed" ) + e.getMessage() );
}
catch( WikiException e )
{
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Denounce.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Denounce.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Denounce.java
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Denounce.java Thu
Feb 26 21:57:21 2009
@@ -132,7 +132,7 @@
/**
* {...@inheritdoc}
*/
- public String execute( WikiContext context, Map params )
+ public String execute( WikiContext context, Map<String,String> params )
throws PluginException
{
String link = (String) params.get( PARAM_LINK );
@@ -141,7 +141,9 @@
if( link == null )
{
- throw new PluginException("Denounce: No parameter "+PARAM_LINK+"
defined!");
+ throw new PluginException( context.getBundle(
WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE )
+ .getString( "plugin.denounce.no.parameter" )
+ + PARAM_LINK );
}
HttpServletRequest request = context.getHttpRequest();
@@ -165,9 +167,9 @@
/**
* Returns true, if the path is found among the referers.
*/
- private boolean matchPattern( List list, String path )
+ private boolean matchPattern( List<Pattern> list, String path )
{
- for( Iterator i = list.iterator(); i.hasNext(); )
+ for( Iterator<Pattern> i = list.iterator(); i.hasNext(); )
{
Pattern pattern = (Pattern)i.next();
if (pattern.matcher(path).find())
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/IfPlugin.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/IfPlugin.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/IfPlugin.java
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/IfPlugin.java Thu
Feb 26 21:57:21 2009
@@ -33,159 +33,186 @@
import org.apache.wiki.api.PluginException;
import org.apache.wiki.util.TextUtil;
-
/**
- * The IfPlugin allows parts of a WikiPage to be executed conditionally.
- * You can also use shorthand "If" to run it.
- * Parameters:
- * <ul>
- * <li><b>group</b> - A "|" -separated list of group names.
- * <li><b>user</b> - A "|" -separated list of user names.
- * <li><b>ip</b> - A "|" -separated list of ip addresses.
- * <li><b>var</b> - A wiki variable
- * <li><b>page</b> - A page name
- * <li><b>contains</b> - A Perl5 regexp pattern
- * <li><b>is</b> - A Perl5 regexp pattern
- * <li><b>exists</b> - "true" or "false".
- * </ul>
- *
- * <p>If any of them match, the body of the plugin is executed. You can
- * negate the content by prefixing it with a "!". For example, to greet
- * all admins, put the following in your LeftMenu:</p>
- * <pre>
+ * The IfPlugin allows parts of a WikiPage to be executed conditionally. You
can
+ * also use shorthand "If" to run it. Parameters:
+ * <ul>
+ * <li><b>group</b> - A "|" -separated list of group names.
+ * <li><b>user</b> - A "|" -separated list of user names.
+ * <li><b>ip</b> - A "|" -separated list of ip addresses.
+ * <li><b>var</b> - A wiki variable
+ * <li><b>page</b> - A page name
+ * <li><b>contains</b> - A Perl5 regexp pattern
+ * <li><b>is</b> - A Perl5 regexp pattern
+ * <li><b>exists</b> - "true" or "false".
+ * </ul>
+ * <p>
+ * If any of them match, the body of the plugin is executed. You can negate the
+ * content by prefixing it with a "!". For example, to greet all admins, put
the
+ * following in your LeftMenu:
+ * </p>
+ *
+ * <pre>
* [{If group='Admin'
- *
* Hello, Admin, and your mighty powers!}]
- * </pre>
- *
- * <p>In order to send a message to everybody except Jack use</p>
- * <pre>
+ * </pre>
+ * <p>
+ * In order to send a message to everybody except Jack use
+ * </p>
+ *
+ * <pre>
* [{If user='!Jack'
- *
* %%warning
* Jack's surprise birthday party at eleven!
* %%}]
- * </pre>
- *
- * <p>Note that you can't use "!Jack|!Jill", because for Jack, !Jill matches;
- * and for Jill, !Jack matches. These are not regular expressions (though
- * they might become so in the future).<p>
- *
- * <p>To check for page content, use</p>
- * <pre>
+ * </pre>
+ * <p>
+ * Note that you can't use "!Jack|!Jill", because for Jack, !Jill matches; and
+ * for Jill, !Jack matches. These are not regular expressions (though they
might
+ * become so in the future).
+ * <p>
+ * <p>
+ * To check for page content, use
+ * </p>
+ *
+ * <pre>
* [{If page='TestPage' contains='xyzzy'
- *
- * Page contains the text "xyzzy"}]
- * </pre>
- *
- * <p>The difference between "contains" and "is" is that "is" is always an
exact match,
- * whereas "contains" just checks if a pattern is available.</p>
- *
- * <p>To check for page existence, use</p>
- * <pre>
+ * Page contains the text "xyzzy"}]
+ * </pre>
+ * <p>
+ * The difference between "contains" and "is" is that "is" is always an exact
+ * match, whereas "contains" just checks if a pattern is available.
+ * </p>
+ * <p>
+ * To check for page existence, use
+ * </p>
+ *
+ * <pre>
* [{If page='TestPage' exists='true'
- *
- * Page "TestPage" exists.}]
- * </pre>
- * <p>With the same mechanism, it's also possible to test for the existence
- * of a variable - just use "var" instead of "page".</p>
- *
- * <p>Another caveat is that the plugin body content is not counted
- * towards ReferenceManager links. So any links do not appear on any
reference
- * lists. Depending on your position, this may be a good or a bad
- * thing.</p>
- *
- * <h3>Calling Externally</h3>
- *
- * <p>The functional, decision-making part of this plugin may be called from
- * other code (e.g., other plugins) since it is available as a static method
- * {...@link #ifInclude(WikiContext,Map)}. Note that the plugin body may
contain
- * references to other plugins.</p>
- *
- * @author Murray Altheim
- * @since 2.6
+ * Page "TestPage" exists.}]
+ * </pre>
+ * <p>
+ * With the same mechanism, it's also possible to test for the existence of a
+ * variable - just use "var" instead of "page".
+ * </p>
+ * <p>
+ * Another caveat is that the plugin body content is not counted towards
+ * ReferenceManager links. So any links do not appear on any reference lists.
+ * Depending on your position, this may be a good or a bad thing.
+ * </p>
+ * <h3>Calling Externally</h3>
+ * <p>
+ * The functional, decision-making part of this plugin may be called from other
+ * code (e.g., other plugins) since it is available as a static method
+ * {...@link #ifInclude(WikiContext,Map)}. Note that the plugin body may
contain
+ * references to other plugins.
+ * </p>
+ *
+ * @author Murray Altheim
+ * @since 2.6
*/
@ModuleData( aliases = { "If" } )
public class IfPlugin implements WikiPlugin
{
- /** The parameter name for setting the group to check. Value is
<tt>{...@value}</tt>. */
- public static final String PARAM_GROUP = "group";
+ /**
+ * The parameter name for setting the group to check. Value is
+ * <tt>{...@value}</tt>.
+ */
+ public static final String PARAM_GROUP = "group";
+
+ /**
+ * The parameter name for setting the user id to check. Value is
+ * <tt>{...@value}</tt>.
+ */
+ public static final String PARAM_USER = "user";
+
+ /**
+ * The parameter name for setting the ip address to check. Value is
+ * <tt>{...@value}</tt>.
+ */
+ public static final String PARAM_IP = "ip";
+
+ /**
+ * The parameter name for setting the page name to check. Value is
+ * <tt>{...@value}</tt>.
+ */
+ public static final String PARAM_PAGE = "page";
- /** The parameter name for setting the user id to check. Value is
<tt>{...@value}</tt>. */
- public static final String PARAM_USER = "user";
-
- /** The parameter name for setting the ip address to check. Value is
<tt>{...@value}</tt>. */
- public static final String PARAM_IP = "ip";
-
- /** The parameter name for setting the page name to check. Value is
<tt>{...@value}</tt>. */
- public static final String PARAM_PAGE = "page";
-
- /** The parameter name for setting the contents of the page to check.
Value is <tt>{...@value}</tt>. */
+ /**
+ * The parameter name for setting the contents of the page to check. Value
+ * is <tt>{...@value}</tt>.
+ */
public static final String PARAM_CONTAINS = "contains";
-
- /** The parameter name for setting the variable name to check. Value is
<tt>{...@value}</tt>. */
- public static final String PARAM_VAR = "var";
-
- /** The parameter name for setting the exact content to check. Value is
<tt>{...@value}</tt>. */
- public static final String PARAM_IS = "is";
-
- /** The parameter name for checking whether a page/var exists. Value is
<tt>{...@value}</tt>. */
- public static final String PARAM_EXISTS = "exists";
/**
- * {...@inheritdoc}
+ * The parameter name for setting the variable name to check. Value is
+ * <tt>{...@value}</tt>.
+ */
+ public static final String PARAM_VAR = "var";
+
+ /**
+ * The parameter name for setting the exact content to check. Value is
+ * <tt>{...@value}</tt>.
+ */
+ public static final String PARAM_IS = "is";
+
+ /**
+ * The parameter name for checking whether a page/var exists. Value is
+ * <tt>{...@value}</tt>.
+ */
+ public static final String PARAM_EXISTS = "exists";
+
+ /**
+ * {...@inheritdoc}
*/
- public String execute(WikiContext context, Map params) throws
PluginException
+ public String execute( WikiContext context, Map<String, String> params )
throws PluginException
{
- return ifInclude(context,params)
- ? context.getEngine().textToHTML(
- context,(String)params.get(PluginManager.PARAM_BODY) )
- : "" ;
+ return ifInclude( context, params ) ? context.getEngine().textToHTML(
context,
+
(String) params.get( PluginManager.PARAM_BODY ) )
+ : "";
}
-
/**
- * Returns a boolean result based on processing the WikiContext and
- * parameter Map as according to the rules stated in the IfPlugin
- * documentation.
- * As a static method this may be called by other classes.
- *
- * @param context The current WikiContext.
- * @param params The parameter Map which contains key-value pairs.
+ * Returns a boolean result based on processing the WikiContext and
+ * parameter Map as according to the rules stated in the IfPlugin
+ * documentation. As a static method this may be called by other classes.
+ *
+ * @param context The current WikiContext.
+ * @param params The parameter Map which contains key-value pairs.
* @throws PluginException If something goes wrong
* @return True, if the condition holds.
*/
- public static boolean ifInclude( WikiContext context, Map params ) throws
PluginException
+ public static boolean ifInclude( WikiContext context, Map<String, String>
params ) throws PluginException
{
boolean include = false;
- String group = (String)params.get(PARAM_GROUP);
- String user = (String)params.get(PARAM_USER);
- String ip = (String)params.get(PARAM_IP);
- String page = (String)params.get(PARAM_PAGE);
- String contains = (String)params.get(PARAM_CONTAINS);
- String var = (String)params.get(PARAM_VAR);
- String is = (String)params.get(PARAM_IS);
- String exists = (String)params.get(PARAM_EXISTS);
-
- include |= checkGroup(context, group);
- include |= checkUser(context, user);
- include |= checkIP(context, ip);
+ String group = (String) params.get( PARAM_GROUP );
+ String user = (String) params.get( PARAM_USER );
+ String ip = (String) params.get( PARAM_IP );
+ String page = (String) params.get( PARAM_PAGE );
+ String contains = (String) params.get( PARAM_CONTAINS );
+ String var = (String) params.get( PARAM_VAR );
+ String is = (String) params.get( PARAM_IS );
+ String exists = (String) params.get( PARAM_EXISTS );
+
+ include |= checkGroup( context, group );
+ include |= checkUser( context, user );
+ include |= checkIP( context, ip );
if( page != null )
{
- String content = context.getEngine().getPureText(page,
WikiProvider.LATEST_VERSION).trim();
- include |= checkContains(content,contains);
- include |= checkIs(content,is);
- include |= checkExists(context,page,exists);
+ String content = context.getEngine().getPureText( page,
WikiProvider.LATEST_VERSION ).trim();
+ include |= checkContains( content, contains, context );
+ include |= checkIs( content, is, context );
+ include |= checkExists( context, page, exists );
}
if( var != null )
{
- String content = context.getEngine().getVariable(context, var);
- include |= checkContains(content,contains);
- include |= checkIs(content,is);
- include |= checkVarExists(content,exists);
+ String content = context.getEngine().getVariable( context, var );
+ include |= checkContains( content, contains, context );
+ include |= checkIs( content, is, context );
+ include |= checkVarExists( content, exists );
}
return include;
@@ -193,33 +220,36 @@
private static boolean checkExists( WikiContext context, String page,
String exists )
{
- if( exists == null ) return false;
- return !context.getEngine().pageExists(page) ^
TextUtil.isPositive(exists);
+ if( exists == null )
+ return false;
+ return !context.getEngine().pageExists( page ) ^ TextUtil.isPositive(
exists );
}
private static boolean checkVarExists( String varContent, String exists )
{
- if( exists == null ) return false;
- return (varContent == null ) ^ TextUtil.isPositive(exists);
+ if( exists == null )
+ return false;
+ return (varContent == null) ^ TextUtil.isPositive( exists );
}
private static boolean checkGroup( WikiContext context, String group )
{
- if( group == null ) return false;
- String[] groupList = StringUtils.split(group,'|');
+ if( group == null )
+ return false;
+ String[] groupList = StringUtils.split( group, '|' );
boolean include = false;
for( int i = 0; i < groupList.length; i++ )
{
String gname = groupList[i];
boolean invert = false;
- if( groupList[i].startsWith("!") )
+ if( groupList[i].startsWith( "!" ) )
{
- gname = groupList[i].substring(1);
+ gname = groupList[i].substring( 1 );
invert = true;
}
- Principal g =
context.getEngine().getAuthorizationManager().resolvePrincipal(gname);
+ Principal g =
context.getEngine().getAuthorizationManager().resolvePrincipal( gname );
include |=
context.getEngine().getAuthorizationManager().isUserInRole(
context.getWikiSession(), g ) ^ invert;
}
@@ -228,15 +258,16 @@
private static boolean checkUser( WikiContext context, String user )
{
- if( user == null || context.getCurrentUser() == null ) return false;
+ if( user == null || context.getCurrentUser() == null )
+ return false;
- String[] list = StringUtils.split(user,'|');
+ String[] list = StringUtils.split( user, '|' );
boolean include = false;
for( int i = 0; i < list.length; i++ )
{
boolean invert = false;
- if( list[i].startsWith("!") )
+ if( list[i].startsWith( "!" ) )
{
invert = true;
}
@@ -249,15 +280,16 @@
// TODO: Add subnetwork matching, e.g. 10.0.0.0/8
private static boolean checkIP( WikiContext context, String ipaddr )
{
- if( ipaddr == null || context.getHttpRequest() == null ) return false;
+ if( ipaddr == null || context.getHttpRequest() == null )
+ return false;
- String[] list = StringUtils.split(ipaddr,'|');
+ String[] list = StringUtils.split( ipaddr, '|' );
boolean include = false;
for( int i = 0; i < list.length; i++ )
{
boolean invert = false;
- if( list[i].startsWith("!") )
+ if( list[i].startsWith( "!" ) )
{
invert = true;
}
@@ -267,37 +299,39 @@
return include;
}
- private static boolean doMatch( String content, String pattern )
- throws PluginException
+ private static boolean doMatch( String content, String pattern,
WikiContext context ) throws PluginException
{
try
{
Pattern matchPattern = Pattern.compile( pattern );
- // m_exceptPattern = compiler.compile( exceptPattern,
Perl5Compiler.SINGLELINE_MASK );
+ // m_exceptPattern = compiler.compile( exceptPattern,
+ // Perl5Compiler.SINGLELINE_MASK );
return matchPattern.matcher( content ).matches();
}
catch( PatternSyntaxException e )
{
- throw new PluginException("Faulty pattern "+pattern);
+ throw new PluginException( context.getBundle(
WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE )
+ .getString( "plugin.if.faulty.pattern" )
+ + pattern );
}
}
- private static boolean checkContains( String pagecontent, String
matchPattern )
- throws PluginException
+ private static boolean checkContains( String pagecontent, String
matchPattern, WikiContext context ) throws PluginException
{
- if( pagecontent == null || matchPattern == null ) return false;
+ if( pagecontent == null || matchPattern == null )
+ return false;
- return doMatch( pagecontent, ".*"+matchPattern+".*" );
+ return doMatch( pagecontent, ".*" + matchPattern + ".*", context );
}
- private static boolean checkIs( String content, String matchPattern )
- throws PluginException
+ private static boolean checkIs( String content, String matchPattern,
WikiContext context ) throws PluginException
{
- if( content == null || matchPattern == null ) return false;
+ if( content == null || matchPattern == null )
+ return false;
- matchPattern = "^"+matchPattern+"$";
+ matchPattern = "^" + matchPattern + "$";
- return doMatch(content, matchPattern);
+ return doMatch( content, matchPattern, context );
}
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Image.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Image.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Image.java
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/Image.java Thu Feb
26 21:57:21 2009
@@ -21,6 +21,7 @@
package org.apache.wiki.plugin;
import java.util.Map;
+import java.util.ResourceBundle;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiEngine;
@@ -101,6 +102,7 @@
public String execute( WikiContext context, Map params )
throws PluginException
{
+ ResourceBundle rb = context.getBundle(
WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
WikiEngine engine = context.getEngine();
String src = getCleanParameter( params, PARAM_SRC );
String align = getCleanParameter( params, PARAM_ALIGN );
@@ -117,7 +119,8 @@
if( src == null )
{
- throw new PluginException("Parameter 'src' is required for Image
plugin");
+ throw new PluginException( rb.getString( "
plugin.image.parmsrc.req.1" ) + " 'src' "
+ + rb.getString( "
plugin.image.parmsrc.req.2" ) );
}
if( cssclass == null ) cssclass = "imageplugin";
@@ -139,7 +142,7 @@
}
catch( ProviderException e )
{
- throw new PluginException( "Attachment info failed:
"+e.getMessage() );
+ throw new PluginException( rb.getString(
"plugin.image.attachinfo.failed" ) + e.getMessage() );
}
StringBuilder result = new StringBuilder();
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/InterWikiLinksPlugin.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/InterWikiLinksPlugin.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/InterWikiLinksPlugin.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/InterWikiLinksPlugin.java
Thu Feb 26 21:57:21 2009
@@ -22,6 +22,7 @@
import java.util.Collection;
import java.util.Map;
+import java.util.ResourceBundle;
import org.apache.log4j.Logger;
import org.apache.wiki.WikiContext;
@@ -80,6 +81,7 @@
*/
public String execute( WikiContext context, Map<String, String> params )
throws PluginException
{
+ ResourceBundle rb = context.getBundle(
WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
try
{
StringBuffer sb = new StringBuffer();
@@ -180,7 +182,7 @@
catch( Exception e )
{
log.error( "Could not construct InterwikiLinks plugin output,
reason: ", e );
- throw new PluginException( "Unable to construct InterwikiLinks
plugin output (see logs)" );
+ throw new PluginException( rb.getString(
"plugin.interwikilinks.noconstruct" ) );
}
}
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/PluginManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/PluginManager.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/PluginManager.java
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/PluginManager.java
Thu Feb 26 21:57:21 2009
@@ -556,14 +556,11 @@
*
* @throws PluginException From the plugin itself, it propagates, waah!
*/
- public String execute( WikiContext context,
- String commandline )
- throws PluginException
+ public String execute( WikiContext context, String commandline ) throws
PluginException
{
if( !m_pluginsEnabled )
return "";
- ResourceBundle rb =
context.getBundle(WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
Object[] obArgs = { commandline };
Matcher matcher = m_pluginPattern.matcher( commandline );
@@ -585,12 +582,14 @@
{
String msg = "Missing parameter in plugin definition:
"+commandline;
log.warn( msg, e );
+ ResourceBundle rb =
context.getBundle(WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
throw new PluginException( MessageFormat.format( rb.getString(
"plugin.error.missingparameter" ), obArgs ) );
}
catch( IOException e )
{
String msg = "Zyrf. Problems with parsing arguments:
"+commandline;
log.warn( msg, e );
+ ResourceBundle rb =
context.getBundle(WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
throw new PluginException( MessageFormat.format( rb.getString(
"plugin.error.parsingarguments" ), obArgs ) );
}
@@ -649,13 +648,15 @@
{
String msg = "Missing parameter in plugin definition:
"+commandline;
log.warn( msg, e );
- throw new PluginException( msg );
+ ResourceBundle rb = context.getBundle(
WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
+ throw new PluginException( rb.getString(
"plugin.error.missingparameter" ) );
}
catch( IOException e )
{
String msg = "Zyrf. Problems with parsing arguments:
"+commandline;
log.warn( msg, e );
- throw new PluginException( msg );
+ ResourceBundle rb = context.getBundle(
WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
+ throw new PluginException( rb.getString(
"plugin.error.parsingarguments" ) );
}
return null;
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/TableOfContents.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/TableOfContents.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/TableOfContents.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/TableOfContents.java
Thu Feb 26 21:57:21 2009
@@ -229,7 +229,7 @@
catch(Exception e)
{
log.error("Could not construct table of contents: Filter
Error", e);
- throw new PluginException("Unable to construct table of
contents (see logs)");
+ throw new PluginException( rb.getString(
"tableofcontents.unable.construct" ) );
}
context.setVariable( VAR_ALREADY_PROCESSING, "x" );
@@ -244,7 +244,7 @@
catch( IOException e )
{
log.error("Could not construct table of contents", e);
- throw new PluginException("Unable to construct table of contents
(see logs)");
+ throw new PluginException( rb.getString(
"tableofcontents.unable.construct" ) );
}
sb.append("</div>\n</div>\n");
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java
Thu Feb 26 21:57:21 2009
@@ -39,14 +39,12 @@
* </ul>
*
*/
-public class UndefinedPagesPlugin
- extends AbstractFilteredPlugin
+public class UndefinedPagesPlugin extends AbstractFilteredPlugin
{
/**
* {...@inheritdoc}
*/
- @SuppressWarnings("unchecked")
- public String execute( WikiContext context, Map params )
+ public String execute( WikiContext context, Map<String,String> params )
throws PluginException
{
ReferenceManager refmgr = context.getEngine().getReferenceManager();
@@ -64,7 +62,9 @@
if (m_lastModified)
{
- throw new PluginException("parameter " + PARAM_LASTMODIFIED + " is
not valid for the UndefinedPagesPlugin");
+ throw new PluginException( context.getBundle(
WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE )
+ .getString( "plugin.undefined.parm.invalid" )
+ + " : " + PARAM_LASTMODIFIED );
}
if (m_show.equals(PARAM_SHOW_VALUE_COUNT))
Modified: incubator/jspwiki/trunk/tests/java/TranslationsCheck.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/TranslationsCheck.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/TranslationsCheck.java (original)
+++ incubator/jspwiki/trunk/tests/java/TranslationsCheck.java Thu Feb 26
21:57:21 2009
@@ -69,32 +69,32 @@
try
{
- diff("/etc/i18n/CoreResources.properties",
- "/etc/i18n/CoreResources_" + suffix + ".properties");
- detectDuplicates("/etc/i18n/CoreResources_" + suffix +
".properties");
+ diff("/src/WebContent/WEB-INF/classes/CoreResources.properties",
+ "/src/WebContent/WEB-INF/classes/CoreResources_" + suffix +
".properties");
+ detectDuplicates("/src/WebContent/WEB-INF/classes/CoreResources_"
+ suffix + ".properties");
}
catch( FileNotFoundException e )
{
- System.err.println("Unable to locate "+"/etc/i18n/CoreResources_"
+ suffix + ".properties");
+ System.err.println("Unable to locate
"+"/src/WebContent/WEB-INF/classes/CoreResources_" + suffix + ".properties");
}
try
{
- diff("/etc/i18n/templates/default.properties",
- "/etc/i18n/templates/default_" + suffix + ".properties");
- detectDuplicates("/etc/i18n/templates/default_" + suffix +
".properties");
+
diff("/src/WebContent/WEB-INF/classes/templates/default.properties",
+ "/src/WebContent/WEB-INF/classes/templates/default_" + suffix
+ ".properties");
+
detectDuplicates("/src/WebContent/WEB-INF/classes/templates/default_" + suffix
+ ".properties");
}
catch( FileNotFoundException e )
{
- System.err.println("Unable to locate
"+"/etc/i18n/templates/default_" + suffix + ".properties");
+ System.err.println("Unable to locate
"+"/src/WebContent/WEB-INF/classes/templates/default_" + suffix +
".properties");
}
try
{
- diff("/etc/i18n/plugin/PluginResources.properties",
- "/etc/i18n/plugin/PluginResources_" + suffix + ".properties");
+
diff("/src/WebContent/WEB-INF/classes/plugin/PluginResources.properties",
+ "/src/WebContent/WEB-INF/classes/plugin/PluginResources_" +
suffix + ".properties");
- detectDuplicates("/etc/i18n/plugin/PluginResources_" + suffix +
".properties");
+
detectDuplicates("/src/WebContent/WEB-INF/classes/plugin/PluginResources_" +
suffix + ".properties");
System.out.println("Duplicates overall (two or more occurences):");
System.out.println("--------------------------------------------");
@@ -108,7 +108,7 @@
}
catch( FileNotFoundException e )
{
- System.err.println("Unable to locate
"+"/etc/i18n/plugin/PluginResources_" + suffix + ".properties");
+ System.err.println("Unable to locate
"+"/src/WebContent/WEB-INF/classes/plugin/PluginResources_" + suffix +
".properties");
}
System.out.println("NOTE: Please remember that dependent on the usage
of these i18n files, outdated " +
Modified:
incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java?rev=748329&r1=748328&r2=748329&view=diff
==============================================================================
---
incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java
(original)
+++
incubator/jspwiki/trunk/tests/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java
Thu Feb 26 21:57:21 2009
@@ -97,7 +97,7 @@
assertEquals("1", result);
// test if the proper exception is thrown:
- String expectedExceptionString = "parameter showLastModified is not
valid for the UndefinedPagesPlugin";
+ String expectedExceptionString = "parameter is not valid for the
UndefinedPagesPlugin : showLastModified";
String exceptionString = null;
try
{