Move (private) JSPWikiMarkupParser#getLocalBooleanProperty to (public) WikiContext#getBooleanWikiProperty
Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/a39e7581 Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/a39e7581 Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/a39e7581 Branch: refs/heads/master Commit: a39e7581fd69a05762cc982a7309a4e456812774 Parents: b917316 Author: juanpablo <juanpa...@apache.org> Authored: Sun Dec 3 01:09:18 2017 +0100 Committer: juanpablo <juanpa...@apache.org> Committed: Sun Dec 3 01:09:18 2017 +0100 ---------------------------------------------------------------------- .../main/java/org/apache/wiki/WikiContext.java | 27 +++++++++-- .../apache/wiki/parser/JSPWikiMarkupParser.java | 47 +++----------------- 2 files changed, 28 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jspwiki/blob/a39e7581/jspwiki-war/src/main/java/org/apache/wiki/WikiContext.java ---------------------------------------------------------------------- diff --git a/jspwiki-war/src/main/java/org/apache/wiki/WikiContext.java b/jspwiki-war/src/main/java/org/apache/wiki/WikiContext.java index ee7f2fb..b916e92 100644 --- a/jspwiki-war/src/main/java/org/apache/wiki/WikiContext.java +++ b/jspwiki-war/src/main/java/org/apache/wiki/WikiContext.java @@ -14,7 +14,7 @@ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations - under the License. + under the License. */ package org.apache.wiki; @@ -39,6 +39,7 @@ import org.apache.wiki.ui.GroupCommand; import org.apache.wiki.ui.Installer; import org.apache.wiki.ui.PageCommand; import org.apache.wiki.ui.WikiCommand; +import org.apache.wiki.util.TextUtil; /** * <p>Provides state information throughout the processing of a page. A @@ -465,6 +466,24 @@ public class WikiContext } /** + * This is just a simple helper method which will first check the context + * if there is already an override in place, and if there is not, + * it will then check the given properties. + * + * @param key What key are we searching for? + * @param defValue Default value for the boolean + * @return {@code true} or {@code false}. + */ + public boolean getBooleanWikiProperty( final String key, final boolean defValue ) { + Object bool = getVariable( key ); + if( bool != null ) { + return TextUtil.isPositive( (String) bool ); + } + + return TextUtil.getBooleanProperty( getEngine().getWikiProperties(), key, defValue ); + } + + /** * This method will safely return any HTTP parameters that * might have been defined. You should use this method instead * of peeking directly into the result of getHttpRequest(), since @@ -654,7 +673,7 @@ public class WikiContext /** * Creates a deep clone of the WikiContext. This is useful when you want * to be sure that you don't accidentally mess with page attributes, etc. - * + * * @since 2.8.0 * @return A deep clone of the WikiContext. */ @@ -682,7 +701,7 @@ public class WikiContext return null; } - + /** * Returns the WikiSession associated with the context. * This method is guaranteed to always return a valid WikiSession. @@ -698,7 +717,7 @@ public class WikiContext /** * This method can be used to find the WikiContext programmatically - * from a JSP PageContext. We check the request context. + * from a JSP PageContext. We check the request context. * The wiki context, if it exists, * is looked up using the key * {@link org.apache.wiki.tags.WikiTagBase#ATTR_CONTEXT}. http://git-wip-us.apache.org/repos/asf/jspwiki/blob/a39e7581/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java ---------------------------------------------------------------------- diff --git a/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java b/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java index 407328d..c3ea8b6 100644 --- a/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java +++ b/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java @@ -250,30 +250,17 @@ public class JSPWikiMarkupParser extends MarkupParser { m_camelCaseLinks ); } - - Boolean wysiwygVariable = (Boolean)m_context.getVariable( RenderingManager.WYSIWYG_EDITOR_MODE ); if( wysiwygVariable != null ) { m_wysiwygEditorMode = wysiwygVariable.booleanValue(); } - m_plainUris = getLocalBooleanProperty( m_context, - PROP_PLAINURIS, - m_plainUris ); - m_useOutlinkImage = getLocalBooleanProperty( m_context, - PROP_USEOUTLINKIMAGE, - m_useOutlinkImage ); - m_useAttachmentImage = getLocalBooleanProperty( m_context, - PROP_USEATTACHMENTIMAGE, - m_useAttachmentImage ); - m_allowHTML = getLocalBooleanProperty( m_context, - MarkupParser.PROP_ALLOWHTML, - m_allowHTML ); - - m_useRelNofollow = getLocalBooleanProperty( m_context, - PROP_USERELNOFOLLOW, - m_useRelNofollow ); + m_plainUris = m_context.getBooleanWikiProperty( PROP_PLAINURIS, m_plainUris ); + m_useOutlinkImage = m_context.getBooleanWikiProperty( PROP_USEOUTLINKIMAGE, m_useOutlinkImage ); + m_useAttachmentImage = m_context.getBooleanWikiProperty( PROP_USEATTACHMENTIMAGE, m_useAttachmentImage ); + m_allowHTML = m_context.getBooleanWikiProperty( PROP_ALLOWHTML, m_allowHTML ); + m_useRelNofollow = m_context.getBooleanWikiProperty( PROP_USERELNOFOLLOW, m_useRelNofollow ); if( m_engine.getUserManager().getUserDatabase() == null || m_engine.getAuthorizationManager() == null ) { @@ -284,30 +271,6 @@ public class JSPWikiMarkupParser extends MarkupParser { } /** - * This is just a simple helper method which will first check the context - * if there is already an override in place, and if there is not, - * it will then check the given properties. - * - * @param context WikiContext to check first - * @param key What key are we searching for? - * @param defValue Default value for the boolean - * @return True or false - */ - private static boolean getLocalBooleanProperty( WikiContext context, - String key, - boolean defValue ) - { - Object bool = context.getVariable(key); - - if( bool != null ) - { - return TextUtil.isPositive( (String) bool ); - } - - return TextUtil.getBooleanProperty( context.getEngine().getWikiProperties(), key, defValue ); - } - - /** * Returns link name, if it exists; otherwise it returns null. */ private String linkExists( String page )