This is an automated email from the ASF dual-hosted git repository. juanpablo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jspwiki.git
commit 7706acfe7e13e5433c126e7480712112cc1bb329 Author: juanpablo <[email protected]> AuthorDate: Fri Mar 27 23:45:25 2020 +0100 use ContextEnum.PAGE_VIEW.getRequestContext() instead of WikiContext.VIEW --- .../apache/wiki/filters/PingWeblogsComFilter.java | 6 +-- .../main/java/org/apache/wiki/forms/FormOpen.java | 4 +- .../java/org/apache/wiki/forms/FormOutput.java | 4 +- .../apache/wiki/parser/JSPWikiMarkupParser.java | 7 ++-- .../java/org/apache/wiki/plugin/IndexPlugin.java | 4 +- .../java/org/apache/wiki/plugin/InsertPage.java | 3 +- .../org/apache/wiki/plugin/PageViewPlugin.java | 4 +- .../apache/wiki/plugin/ReferredPagesPlugin.java | 4 +- .../main/java/org/apache/wiki/plugin/Search.java | 4 +- .../apache/wiki/plugin/WeblogArchivePlugin.java | 4 +- .../java/org/apache/wiki/plugin/WeblogPlugin.java | 7 ++-- .../java/org/apache/wiki/tags/BreadcrumbsTag.java | 4 +- .../java/org/apache/wiki/tags/CalendarTag.java | 4 +- .../org/apache/wiki/url/DefaultURLConstructor.java | 3 +- .../org/apache/wiki/url/ShortURLConstructor.java | 5 ++- .../apache/wiki/url/ShortViewURLConstructor.java | 5 ++- .../java/org/apache/wiki/xmlrpc/RPCHandler.java | 8 ++-- .../apache/wiki/url/DefaultURLConstructorTest.java | 47 +++++++++++----------- .../apache/wiki/url/ShortURLConstructorTest.java | 47 +++++++++++----------- .../wiki/url/ShortViewURLConstructorTest.java | 47 +++++++++++----------- .../ImageLinkAttributeProviderState.java | 4 +- .../LocalFootnoteLinkNodePostProcessorState.java | 4 +- ...LocalFootnoteRefLinkNodePostProcessorState.java | 4 +- .../LocalLinkNodePostProcessorState.java | 16 ++++---- 24 files changed, 129 insertions(+), 120 deletions(-) diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java index dff8d2c..37b5519 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java @@ -19,8 +19,8 @@ package org.apache.wiki.filters; import org.apache.log4j.Logger; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.filters.BasePageFilter; import org.apache.xmlrpc.AsyncCallback; @@ -81,10 +81,10 @@ public class PingWeblogsComFilter extends BasePageFilter { final XmlRpcClient xmlrpc = new XmlRpcClient(m_pingURL); final Vector< String > params = new Vector<>(); params.addElement( "The Butt Ugly Weblog" ); // FIXME: Must be settable - params.addElement( engine.getURL( WikiContext.VIEW, blogName, null ) ); + params.addElement( engine.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), blogName, null ) ); if( log.isDebugEnabled() ) { - log.debug( "Pinging weblogs.com with URL: " + engine.getURL( WikiContext.VIEW, blogName, null ) ); + log.debug( "Pinging weblogs.com with URL: " + engine.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), blogName, null ) ); } xmlrpc.executeAsync("weblogUpdates.ping", params, diff --git a/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOpen.java b/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOpen.java index 7ee9368..d62866e 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOpen.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOpen.java @@ -19,8 +19,8 @@ package org.apache.wiki.forms; import org.apache.log4j.Logger; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.api.plugin.Plugin; import org.apache.wiki.preferences.Preferences; @@ -86,7 +86,7 @@ public class FormOpen extends FormElement { final String sourcePage = ctx.getPage().getName(); String submitServlet = params.get( PARAM_SUBMITHANDLER ); if( submitServlet == null ) - submitServlet = ctx.getURL( WikiContext.VIEW, sourcePage ); + submitServlet = ctx.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), sourcePage ); String method = params.get( PARAM_METHOD ); if( method == null ) method="post"; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java b/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java index 968b1e1..0816408 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java @@ -19,8 +19,8 @@ package org.apache.wiki.forms; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.api.plugin.Plugin; import org.apache.wiki.plugin.DefaultPluginManager; @@ -87,7 +87,7 @@ public class FormOutput extends FormElement { } final String sourcePage = ctx.getPage().getName(); - final String submitServlet = ctx.getURL( WikiContext.VIEW, sourcePage ); + final String submitServlet = ctx.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), sourcePage ); // If there is previous FormInfo available - say, from a // FormSet plugin - use it. diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java index 00d199b..75ce2fc 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java @@ -33,6 +33,7 @@ import org.apache.wiki.StringTransmutator; import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Acl; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Page; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.api.plugin.Plugin; @@ -286,11 +287,11 @@ public class JSPWikiMarkupParser extends MarkupParser { switch(type) { case READ: - el = createAnchor( READ, m_context.getURL(WikiContext.VIEW, link), text, section ); + el = createAnchor( READ, m_context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), link), text, section ); break; case EDIT: - el = createAnchor( EDIT, m_context.getURL(WikiContext.EDIT,link), text, "" ); + el = createAnchor( EDIT, m_context.getURL( ContextEnum.PAGE_EDIT.getRequestContext(),link), text, "" ); el.setAttribute("title", MessageFormat.format( rb.getString( "markupparser.link.create" ), link ) ); break; @@ -336,7 +337,7 @@ public class JSPWikiMarkupParser extends MarkupParser { break; case IMAGEWIKILINK: - final String pagelink = m_context.getURL(WikiContext.VIEW,text); + final String pagelink = m_context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), text ); el = new Element("img").setAttribute("class","inline"); el.setAttribute("src",link); el.setAttribute("alt",text); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/IndexPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/IndexPlugin.java index d062319..f326714 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/IndexPlugin.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/IndexPlugin.java @@ -20,8 +20,8 @@ package org.apache.wiki.plugin; import org.apache.log4j.Logger; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.api.exceptions.ProviderException; import org.apache.wiki.api.plugin.Plugin; @@ -90,7 +90,7 @@ public class IndexPlugin extends AbstractReferralPlugin implements Plugin { } else { currentDiv.addContent(", "); } - currentDiv.addContent(getLink(context.getURL(WikiContext.VIEW,name),name)); + currentDiv.addContent( getLink( context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), name ), name ) ); } } catch( final ProviderException e ) { diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java index 22e634c..153fab3 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java @@ -20,6 +20,7 @@ package org.apache.wiki.plugin; import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.core.Page; import org.apache.wiki.api.exceptions.PluginException; @@ -177,7 +178,7 @@ public class InsertPage implements Plugin { if( pageData.length() > maxlen ) { pageData = pageData.substring( 0, maxlen )+" ..."; - moreLink = "<p><a href=\""+context.getURL(WikiContext.VIEW,includedPage)+"\">"+rb.getString("insertpage.more")+"</a></p>"; + moreLink = "<p><a href=\""+context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(),includedPage)+"\">"+rb.getString("insertpage.more")+"</a></p>"; } res.append("<div class=\"inserted-page "); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/PageViewPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PageViewPlugin.java index 2c041fb..e898b21 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/PageViewPlugin.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PageViewPlugin.java @@ -28,8 +28,8 @@ import org.apache.oro.text.regex.PatternCompiler; import org.apache.oro.text.regex.PatternMatcher; import org.apache.oro.text.regex.Perl5Matcher; import org.apache.wiki.WikiBackgroundThread; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.core.Page; import org.apache.wiki.api.exceptions.PluginException; @@ -346,7 +346,7 @@ public class PageViewPlugin extends AbstractReferralPlugin implements Plugin, In Counter counter = m_counters.get( pagename ); // only count in view mode, keep storage values in sync - if( increment && WikiContext.VIEW.equalsIgnoreCase( context.getRequestContext() ) ) { + if( increment && ContextEnum.PAGE_VIEW.getRequestContext().equalsIgnoreCase( context.getRequestContext() ) ) { if( counter == null ) { counter = new Counter(); m_counters.put( pagename, counter ); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferredPagesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferredPagesPlugin.java index f2f4fff..67ff112 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferredPagesPlugin.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferredPagesPlugin.java @@ -25,8 +25,8 @@ import org.apache.oro.text.regex.PatternCompiler; import org.apache.oro.text.regex.PatternMatcher; import org.apache.oro.text.regex.Perl5Compiler; import org.apache.oro.text.regex.Perl5Matcher; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.core.Page; import org.apache.wiki.api.exceptions.PluginException; @@ -244,7 +244,7 @@ public class ReferredPagesPlugin implements Plugin { m_result.append("<ul>\n"); } - final String href = context.getURL( WikiContext.VIEW, link ); + final String href = context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), link ); m_result.append( "<li><a class=\"wikipage\" href=\"" + href + "\">" + TextUtil.replaceEntities(link) + "</a>\n" ); m_exists.add( link ); getReferredPages( context, link, depth ); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Search.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Search.java index 4edbcf1..6956baa 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Search.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Search.java @@ -19,8 +19,8 @@ package org.apache.wiki.plugin; import org.apache.log4j.Logger; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.api.exceptions.ProviderException; @@ -133,7 +133,7 @@ public class Search implements Plugin { final Element name = XhtmlUtil.element(XHTML.td); name.setAttribute(XHTML.ATTR_width,"30%"); - name.addContent( XhtmlUtil.link(context.getURL( WikiContext.VIEW, sr.getPage().getName() ), + name.addContent( XhtmlUtil.link(context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), sr.getPage().getName() ), engine.getManager( RenderingManager.class ).beautifyTitle(sr.getPage().getName() ) ) ); row.addContent(name); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogArchivePlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogArchivePlugin.java index f1ee8be..a65734a 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogArchivePlugin.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogArchivePlugin.java @@ -18,8 +18,8 @@ */ package org.apache.wiki.plugin; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.core.Page; import org.apache.wiki.api.exceptions.PluginException; @@ -67,7 +67,7 @@ public class WeblogArchivePlugin implements Plugin { weblogName = context.getPage().getName(); } - final String pttrn = "'" + context.getURL( WikiContext.VIEW, weblogName,"weblog.startDate='ddMMyy'&weblog.days=%d" ) + "'"; + final String pttrn = "'" + context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), weblogName,"weblog.startDate='ddMMyy'&weblog.days=%d" ) + "'"; m_monthUrlFormat = new SimpleDateFormat( pttrn ); final StringBuilder sb = new StringBuilder(); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java index 64de099..af768de 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java @@ -21,6 +21,7 @@ package org.apache.wiki.plugin; import org.apache.log4j.Logger; import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.core.Page; import org.apache.wiki.api.exceptions.PluginException; @@ -331,7 +332,7 @@ public class WeblogPlugin implements Plugin, ParserStagePlugin { } buffer.append(html.substring(0, cutoff)); if (hasBeenCutOff) { - buffer.append(" <a href=\""+entryCtx.getURL(WikiContext.VIEW, entry.getName())+"\">"+rb.getString("weblogentryplugin.more")+"</a>\n"); + buffer.append(" <a href=\""+entryCtx.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), entry.getName())+"\">"+rb.getString("weblogentryplugin.more")+"</a>\n"); } } else { buffer.append(html); @@ -347,14 +348,14 @@ public class WeblogPlugin implements Plugin, ParserStagePlugin { if( author != null ) { if( engine.getManager( PageManager.class ).wikiPageExists(author) ) { - author = "<a href=\""+entryCtx.getURL( WikiContext.VIEW, author )+"\">"+engine.getManager( RenderingManager.class ).beautifyTitle(author)+"</a>"; + author = "<a href=\""+entryCtx.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), author )+"\">"+engine.getManager( RenderingManager.class ).beautifyTitle(author)+"</a>"; } } else { author = "AnonymousCoward"; } buffer.append( MessageFormat.format( rb.getString("weblogentryplugin.postedby"), author)); - buffer.append( "<a href=\"" + entryCtx.getURL( WikiContext.VIEW, entry.getName() ) + "\">" + rb.getString("weblogentryplugin.permalink") + "</a>" ); + buffer.append( "<a href=\"" + entryCtx.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), entry.getName() ) + "\">" + rb.getString("weblogentryplugin.permalink") + "</a>" ); final String commentPageName = TextUtil.replaceString( entry.getName(), "blogentry", "comments" ); if( hasComments ) { diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/BreadcrumbsTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/BreadcrumbsTag.java index a6f44bc..fea1742 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/tags/BreadcrumbsTag.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/BreadcrumbsTag.java @@ -19,7 +19,7 @@ package org.apache.wiki.tags; import org.apache.log4j.Logger; -import org.apache.wiki.WikiContext; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.pages.PageManager; import org.apache.wiki.util.TextUtil; @@ -126,7 +126,7 @@ public class BreadcrumbsTag extends WikiTagBase } } - if( m_wikiContext.getRequestContext().equals( WikiContext.VIEW ) ) { + if( m_wikiContext.getRequestContext().equals( ContextEnum.PAGE_VIEW.getRequestContext() ) ) { if( m_wikiContext.getEngine().getManager( PageManager.class ).wikiPageExists( page ) ) { if( trail.isEmpty() ) { trail.pushItem( page ); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/CalendarTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/CalendarTag.java index 9b1b28b..21ee007 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/tags/CalendarTag.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/CalendarTag.java @@ -19,7 +19,7 @@ package org.apache.wiki.tags; import org.apache.log4j.Logger; -import org.apache.wiki.WikiContext; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.core.Page; import org.apache.wiki.pages.PageManager; @@ -201,7 +201,7 @@ public class CalendarTag extends WikiTagBase { final String pageName = thePage.getName(); final String calendarDate = m_dateFormat.format( day.getTime() ); - String url = m_wikiContext.getURL( WikiContext.VIEW, pageName,"calendar.date="+calendarDate ); + String url = m_wikiContext.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), pageName,"calendar.date="+calendarDate ); if( queryString != null && queryString.length() > 0 ) { // diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java index d60a2d4..c09c1b7 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java @@ -21,6 +21,7 @@ package org.apache.wiki.url; import org.apache.commons.lang3.StringUtils; import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Command; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import org.apache.wiki.ui.CommandResolver; import org.apache.wiki.util.TextUtil; @@ -100,7 +101,7 @@ public class DefaultURLConstructor implements URLConstructor { * @throws IllegalArgumentException if the context cannot be found */ public static String getURLPattern( final String context, final String name ) throws IllegalArgumentException { - if( context.equals(WikiContext.VIEW) && name == null) { + if( context.equals( ContextEnum.PAGE_VIEW.getRequestContext() ) && name == null) { // FIXME return "%uWiki.jsp"; } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java index b94a7bf..563060d 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java @@ -21,6 +21,7 @@ package org.apache.wiki.url; import org.apache.log4j.Logger; import org.apache.wiki.InternalWikiException; import org.apache.wiki.WikiContext; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import org.apache.wiki.util.TextUtil; @@ -68,7 +69,7 @@ public class ShortURLConstructor extends DefaultURLConstructor { private String makeURL( final String context, final String name ) { final String viewurl = "%p" + m_urlPrefix + "%n"; - if( context.equals( WikiContext.VIEW ) ) { + if( context.equals( ContextEnum.PAGE_VIEW.getRequestContext() ) ) { if( name == null ) { return doReplacement("%u","" ); } @@ -124,7 +125,7 @@ public class ShortURLConstructor extends DefaultURLConstructor { @Override public String makeURL( final String context, final String name, String parameters ) { if( parameters != null && parameters.length() > 0 ) { - if( context.equals( WikiContext.ATTACH ) || context.equals( WikiContext.VIEW ) ) { + if( context.equals( ContextEnum.PAGE_ATTACH.getRequestContext() ) || context.equals( ContextEnum.PAGE_VIEW.getRequestContext() ) ) { parameters = "?" + parameters; } else if( context.equals(WikiContext.NONE) ) { parameters = (name.indexOf('?') != -1 ) ? "&" : "?" + parameters; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java index 2c2ab39..d0fdc33 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java @@ -19,6 +19,7 @@ package org.apache.wiki.url; import org.apache.wiki.WikiContext; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; import javax.servlet.http.HttpServletRequest; @@ -40,7 +41,7 @@ public class ShortViewURLConstructor extends ShortURLConstructor { private String makeURL( final String context, final String name ) { final String viewurl = "%p" + m_urlPrefix + "%n"; - if( context.equals( WikiContext.VIEW ) ) { + if( context.equals( ContextEnum.PAGE_VIEW.getRequestContext() ) ) { if( name == null ) { return doReplacement("%u","" ); } @@ -56,7 +57,7 @@ public class ShortViewURLConstructor extends ShortURLConstructor { @Override public String makeURL( final String context, final String name, String parameters ) { if( parameters != null && parameters.length() > 0 ) { - if( context.equals( WikiContext.ATTACH ) || context.equals( WikiContext.VIEW ) || name == null ) { + if( context.equals( ContextEnum.PAGE_ATTACH.getRequestContext() ) || context.equals( ContextEnum.PAGE_VIEW.getRequestContext() ) || name == null ) { parameters = "?" + parameters; } else if( context.equals(WikiContext.NONE) ) { parameters = (name.indexOf('?') != -1 ) ? "&" : "?" + parameters; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java index 44812d0..e0f942e 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java @@ -19,9 +19,9 @@ package org.apache.wiki.xmlrpc; import org.apache.wiki.LinkCollector; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Attachment; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Page; import org.apache.wiki.api.spi.Wiki; import org.apache.wiki.auth.permissions.PagePermission; @@ -242,9 +242,9 @@ public class RPCHandler extends AbstractRPCHandler { // if( m_engine.getManager( PageManager.class ).wikiPageExists( link ) ) { - ht.put( "href", context.getURL( WikiContext.VIEW, link ) ); + ht.put( "href", context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), link ) ); } else { - ht.put( "href", context.getURL( WikiContext.EDIT, link ) ); + ht.put( "href", context.getURL( ContextEnum.PAGE_EDIT.getRequestContext(), link ) ); } result.add( ht ); @@ -257,7 +257,7 @@ public class RPCHandler extends AbstractRPCHandler { final Hashtable<String, String> ht = new Hashtable<>(); ht.put( "page", toRPCString( link ) ); ht.put( "type", LINK_LOCAL ); - ht.put( "href", context.getURL( WikiContext.ATTACH, link ) ); + ht.put( "href", context.getURL( ContextEnum.PAGE_ATTACH.getRequestContext(), link ) ); result.add( ht ); } diff --git a/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java index c08ee80..1dc9b88 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java @@ -24,6 +24,7 @@ package org.apache.wiki.url; import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.exceptions.WikiException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -37,13 +38,13 @@ public class DefaultURLConstructorTest Properties props = TestEngine.getTestProperties(); - private URLConstructor getConstructor( String prefix ) + private URLConstructor getConstructor( final String prefix ) throws WikiException { if( prefix != null ) props.setProperty( ShortViewURLConstructor.PROP_PREFIX, prefix ); testEngine = new TestEngine(props); - URLConstructor constr = new DefaultURLConstructor(); + final URLConstructor constr = new DefaultURLConstructor(); constr.initialize( testEngine, props ); @@ -54,70 +55,70 @@ public class DefaultURLConstructorTest public void testViewURL1() throws Exception { - URLConstructor c = getConstructor("wiki/" ); + final URLConstructor c = getConstructor("wiki/" ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL( ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL2() throws Exception { - URLConstructor c = getConstructor( null ); + final URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL3() throws Exception { - URLConstructor c = getConstructor( null ); + final URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL4() throws Exception { - URLConstructor c = getConstructor( null ); + final URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL5() throws Exception { - URLConstructor c = getConstructor( "" ); + final URLConstructor c = getConstructor( "" ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL6() throws Exception { - URLConstructor c = getConstructor( null ); + final URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL7() throws Exception { - URLConstructor c = getConstructor( "view/" ); + final URLConstructor c = getConstructor( "view/" ); - Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testEditURL1() throws Exception { - URLConstructor c = getConstructor( null ); + final URLConstructor c = getConstructor( null ); Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",null) ); } @@ -126,7 +127,7 @@ public class DefaultURLConstructorTest public void testAttachURL1() throws Exception { - URLConstructor c = getConstructor( null ); + final URLConstructor c = getConstructor( null ); Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @@ -135,7 +136,7 @@ public class DefaultURLConstructorTest public void testAttachURLRelative1() throws Exception { - URLConstructor c = getConstructor( null ); + final URLConstructor c = getConstructor( null ); Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @@ -144,7 +145,7 @@ public class DefaultURLConstructorTest public void testOtherURL1() throws Exception { - URLConstructor c = getConstructor( null ); + final URLConstructor c = getConstructor( null ); Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",null) ); } @@ -153,7 +154,7 @@ public class DefaultURLConstructorTest public void testOtherURL2() throws Exception { - URLConstructor c = getConstructor( null ); + final URLConstructor c = getConstructor( null ); Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(WikiContext.NONE,"foo.jsp","a=1&b=2") ); } @@ -162,9 +163,9 @@ public class DefaultURLConstructorTest public void testEmptyURL() throws Exception { - URLConstructor c = getConstructor( null ); + final URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Wiki.jsp?page=", c.makeURL(WikiContext.VIEW,"",null) ); + Assertions.assertEquals( "/test/Wiki.jsp?page=", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"",null) ); } } diff --git a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java index fd0a1c9..4b62f9f 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java @@ -24,6 +24,7 @@ package org.apache.wiki.url; import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.exceptions.WikiException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -37,13 +38,13 @@ public class ShortURLConstructorTest Properties props = TestEngine.getTestProperties(); - private URLConstructor getConstructor(String prefix) + private URLConstructor getConstructor( final String prefix) throws WikiException { if( prefix != null ) props.setProperty( ShortURLConstructor.PROP_PREFIX, prefix ); testEngine = new TestEngine(props); - URLConstructor constr = new ShortURLConstructor(); + final URLConstructor constr = new ShortURLConstructor(); constr.initialize( testEngine, props ); @@ -54,70 +55,70 @@ public class ShortURLConstructorTest public void testViewURL1() throws Exception { - URLConstructor c = getConstructor("wiki/" ); + final URLConstructor c = getConstructor("wiki/" ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL( ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL2() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL3() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL4() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL5() throws Exception { - URLConstructor c = getConstructor("" ); + final URLConstructor c = getConstructor("" ); - Assertions.assertEquals( "/test/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL6() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL7() throws Exception { - URLConstructor c = getConstructor("view/" ); + final URLConstructor c = getConstructor("view/" ); - Assertions.assertEquals( "/test/view/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/view/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testEditURL1() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); Assertions.assertEquals( "/test/wiki/Main?do=Edit", c.makeURL(WikiContext.EDIT,"Main",null) ); } @@ -126,7 +127,7 @@ public class ShortURLConstructorTest public void testAttachURL1() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @@ -135,7 +136,7 @@ public class ShortURLConstructorTest public void testAttachURLRelative1() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @@ -144,7 +145,7 @@ public class ShortURLConstructorTest public void testOtherURL1() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",null) ); } @@ -153,7 +154,7 @@ public class ShortURLConstructorTest public void testOtherURL2() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(WikiContext.NONE,"foo.jsp","a=1&b=2") ); } @@ -162,9 +163,9 @@ public class ShortURLConstructorTest public void testEmptyURL() throws Exception { - URLConstructor c = getConstructor("wiki/" ); + final URLConstructor c = getConstructor("wiki/" ); - Assertions.assertEquals( "/test/wiki/", c.makeURL(WikiContext.VIEW,"",null) ); + Assertions.assertEquals( "/test/wiki/", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"",null) ); } } diff --git a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java index 3f9b763..a2fdad0 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java @@ -24,6 +24,7 @@ package org.apache.wiki.url; import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.exceptions.WikiException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -37,13 +38,13 @@ public class ShortViewURLConstructorTest Properties props = TestEngine.getTestProperties(); - private URLConstructor getConstructor(String prefix) + private URLConstructor getConstructor( final String prefix) throws WikiException { if( prefix != null ) props.setProperty( ShortViewURLConstructor.PROP_PREFIX, prefix ); testEngine = new TestEngine(props); - URLConstructor constr = new ShortViewURLConstructor(); + final URLConstructor constr = new ShortViewURLConstructor(); constr.initialize( testEngine, props ); @@ -54,70 +55,70 @@ public class ShortViewURLConstructorTest public void testViewURL1() throws Exception { - URLConstructor c = getConstructor("wiki/" ); + final URLConstructor c = getConstructor("wiki/" ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL( ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL2() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL3() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL4() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL5() throws Exception { - URLConstructor c = getConstructor("" ); + final URLConstructor c = getConstructor("" ); - Assertions.assertEquals( "/test/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL6() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); - Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/wiki/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testViewURL7() throws Exception { - URLConstructor c = getConstructor("view/" ); + final URLConstructor c = getConstructor("view/" ); - Assertions.assertEquals( "/test/view/Main", c.makeURL(WikiContext.VIEW,"Main",null) ); + Assertions.assertEquals( "/test/view/Main", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"Main",null) ); } @Test public void testEditURL1() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",null) ); } @@ -126,7 +127,7 @@ public class ShortViewURLConstructorTest public void testAttachURL1() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @@ -135,7 +136,7 @@ public class ShortViewURLConstructorTest public void testAttachURLRelative1() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); } @@ -144,7 +145,7 @@ public class ShortViewURLConstructorTest public void testOtherURL1() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",null) ); } @@ -153,7 +154,7 @@ public class ShortViewURLConstructorTest public void testOtherURL2() throws Exception { - URLConstructor c = getConstructor(null ); + final URLConstructor c = getConstructor(null ); Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(WikiContext.NONE,"foo.jsp","a=1&b=2") ); } @@ -162,9 +163,9 @@ public class ShortViewURLConstructorTest public void testEmptyURL() throws Exception { - URLConstructor c = getConstructor("wiki/" ); + final URLConstructor c = getConstructor("wiki/" ); - Assertions.assertEquals( "/test/wiki/", c.makeURL(WikiContext.VIEW,"",null) ); + Assertions.assertEquals( "/test/wiki/", c.makeURL(ContextEnum.PAGE_VIEW.getRequestContext(),"",null) ); } } diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/ImageLinkAttributeProviderState.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/ImageLinkAttributeProviderState.java index 20d87ba..239204a 100755 --- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/ImageLinkAttributeProviderState.java +++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/ImageLinkAttributeProviderState.java @@ -20,8 +20,8 @@ package org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.html.Attributes; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.markdown.nodes.JSPWikiLink; import org.apache.wiki.parser.LinkParsingOperations; import org.apache.wiki.parser.MarkupParser; @@ -55,7 +55,7 @@ public class ImageLinkAttributeProviderState implements NodeAttributeProviderSta attributes.replaceValue( "class", MarkupParser.CLASS_EXTERNAL ); attributes.replaceValue( "href", urlRef ); } else if ( isLinkFromText && linkOperations.linkExists( link.getText().toString() ) ) { - final String pagelink = wikiContext.getURL( WikiContext.VIEW, link.getText().toString() ); + final String pagelink = wikiContext.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), link.getText().toString() ); attributes.replaceValue( "class", MarkupParser.CLASS_WIKIPAGE ); attributes.replaceValue( "href", pagelink ); } diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalFootnoteLinkNodePostProcessorState.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalFootnoteLinkNodePostProcessorState.java index e43abfc..0b278f5 100755 --- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalFootnoteLinkNodePostProcessorState.java +++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalFootnoteLinkNodePostProcessorState.java @@ -3,8 +3,8 @@ package org.apache.wiki.markdown.extensions.jspwikilinks.postprocessor; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.NodeTracker; import com.vladsch.flexmark.util.sequence.CharSubSequence; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.markdown.nodes.JSPWikiLink; @@ -26,7 +26,7 @@ public class LocalFootnoteLinkNodePostProcessorState implements NodePostProcesso */ @Override public void process( final NodeTracker state, final JSPWikiLink link ) { - link.setUrl( CharSubSequence.of( wikiContext.getURL( WikiContext.VIEW, link.getUrl().toString() ) ) ); + link.setUrl( CharSubSequence.of( wikiContext.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), link.getUrl().toString() ) ) ); } } diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalFootnoteRefLinkNodePostProcessorState.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalFootnoteRefLinkNodePostProcessorState.java index a9727e8..80ac99b 100755 --- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalFootnoteRefLinkNodePostProcessorState.java +++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalFootnoteRefLinkNodePostProcessorState.java @@ -22,8 +22,8 @@ import com.vladsch.flexmark.ast.Text; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.NodeTracker; import com.vladsch.flexmark.util.sequence.CharSubSequence; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.markdown.nodes.JSPWikiLink; @@ -45,7 +45,7 @@ public class LocalFootnoteRefLinkNodePostProcessorState implements NodePostProce */ @Override public void process( final NodeTracker state, final JSPWikiLink link ) { - link.setUrl( CharSubSequence.of( wikiContext.getURL( WikiContext.VIEW, link.getUrl().toString() ) ) ); + link.setUrl( CharSubSequence.of( wikiContext.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), link.getUrl().toString() ) ) ); final Text opBracket = new Text( CharSubSequence.of( "[" ) ); final Text clBracket = new Text( CharSubSequence.of( "]" ) ); link.prependChild( opBracket ); diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalLinkNodePostProcessorState.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalLinkNodePostProcessorState.java index 3fd4bff..9e011f6 100755 --- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalLinkNodePostProcessorState.java +++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalLinkNodePostProcessorState.java @@ -23,8 +23,8 @@ import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.NodeTracker; import com.vladsch.flexmark.util.sequence.CharSubSequence; import org.apache.oro.text.regex.Pattern; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.attachment.AttachmentManager; import org.apache.wiki.markdown.nodes.JSPWikiLink; import org.apache.wiki.parser.LinkParsingOperations; @@ -63,7 +63,7 @@ public class LocalLinkNodePostProcessorState implements NodePostProcessorState< final String attachment = wikiContext.getEngine().getManager( AttachmentManager.class ).getAttachmentInfoName( wikiContext, link.getUrl().toString() ); if( attachment != null ) { if( !linkOperations.isImageLink( link.getUrl().toString(), isImageInlining, inlineImagePatterns ) ) { - final String attlink = wikiContext.getURL( WikiContext.ATTACH, link.getUrl().toString() ); + final String attlink = wikiContext.getURL( ContextEnum.PAGE_ATTACH.getRequestContext(), link.getUrl().toString() ); link.setUrl( CharSubSequence.of( attlink ) ); link.removeChildren(); final HtmlInline content = new HtmlInline( CharSubSequence.of( link.getText().toString() ) ); @@ -80,22 +80,22 @@ public class LocalLinkNodePostProcessorState implements NodePostProcessorState< if( matchedLink != null ) { String sectref = "#section-" + wikiContext.getEngine().encodeName( matchedLink + "-" + MarkupParser.wikifyLink( namedSection ) ); sectref = sectref.replace('%', '_'); - link.setUrl( CharSubSequence.of( wikiContext.getURL( WikiContext.VIEW, link.getUrl().toString() + sectref ) ) ); + link.setUrl( CharSubSequence.of( wikiContext.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), link.getUrl().toString() + sectref ) ) ); } else { - link.setUrl( CharSubSequence.of( wikiContext.getURL( WikiContext.EDIT, link.getUrl().toString() ) ) ); + link.setUrl( CharSubSequence.of( wikiContext.getURL( ContextEnum.PAGE_EDIT.getRequestContext(), link.getUrl().toString() ) ) ); } } else { if( linkOperations.linkExists( link.getUrl().toString() ) ) { - link.setUrl( CharSubSequence.of( wikiContext.getURL( WikiContext.VIEW, link.getUrl().toString() ) ) ); + link.setUrl( CharSubSequence.of( wikiContext.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), link.getUrl().toString() ) ) ); } else { - link.setUrl( CharSubSequence.of( wikiContext.getURL( WikiContext.EDIT, link.getUrl().toString() ) ) ); + link.setUrl( CharSubSequence.of( wikiContext.getURL( ContextEnum.PAGE_EDIT.getRequestContext(), link.getUrl().toString() ) ) ); } } } void addAttachmentLink( final NodeTracker state, final JSPWikiLink link ) { - final String infolink = wikiContext.getURL( WikiContext.INFO, link.getWikiLink() ); - final String imglink = wikiContext.getURL( WikiContext.NONE, "images/attachment_small.png" ); + final String infolink = wikiContext.getURL( ContextEnum.PAGE_INFO.getRequestContext(), link.getWikiLink() ); + final String imglink = wikiContext.getURL( ContextEnum.PAGE_NONE.getRequestContext(), "images/attachment_small.png" ); final HtmlInline aimg = new HtmlInline( CharSubSequence.of( "<a href=\""+ infolink + "\" class=\"infolink\">" + "<img src=\""+ imglink + "\" border=\"0\" alt=\"(info)\" />" + "</a>" ) );
