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 ce80e1a53c7355a09453c191e574f76ba77f627d Author: juanpablo <[email protected]> AuthorDate: Sat Mar 28 00:11:36 2020 +0100 more substitutions of WikiContext constants with ContextEnum ones --- .../apache/wiki/attachment/AttachmentServlet.java | 10 +++--- .../wiki/auth/DefaultAuthorizationManager.java | 4 +-- .../java/org/apache/wiki/filters/SpamFilter.java | 10 +++--- .../htmltowiki/HtmlStringToWikiTranslator.java | 34 +++++++++---------- .../apache/wiki/htmltowiki/XHtmlToWikiConfig.java | 10 +++--- .../apache/wiki/parser/JSPWikiMarkupParser.java | 20 ++++------- .../java/org/apache/wiki/parser/PluginContent.java | 4 +-- .../main/java/org/apache/wiki/plugin/Groups.java | 4 +-- .../main/java/org/apache/wiki/plugin/Image.java | 4 +-- .../java/org/apache/wiki/plugin/InsertPage.java | 5 ++- .../src/main/java/org/apache/wiki/plugin/Note.java | 4 +-- .../apache/wiki/plugin/RecentChangesPlugin.java | 4 ++- .../apache/wiki/plugin/ReferringPagesPlugin.java | 16 +++++---- .../org/apache/wiki/plugin/WeblogEntryPlugin.java | 4 +-- .../java/org/apache/wiki/plugin/WeblogPlugin.java | 3 +- .../wiki/render/DefaultRenderingManager.java | 6 ++-- .../java/org/apache/wiki/tags/EditLinkTag.java | 8 ++--- .../wiki/tasks/auth/SaveUserProfileTask.java | 4 +-- .../org/apache/wiki/url/DefaultURLConstructor.java | 7 ++-- .../org/apache/wiki/url/ShortURLConstructor.java | 39 +++++++++++----------- .../apache/wiki/url/ShortViewURLConstructor.java | 3 +- .../org/apache/wiki/ui/CommandResolverTest.java | 25 +++++++------- .../apache/wiki/url/DefaultURLConstructorTest.java | 11 +++--- 23 files changed, 116 insertions(+), 123 deletions(-) diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java index f1e6692..43d4e13 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java @@ -25,9 +25,9 @@ import org.apache.commons.fileupload.ProgressListener; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.log4j.Logger; -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.Engine; import org.apache.wiki.api.core.Page; import org.apache.wiki.api.core.Session; @@ -185,7 +185,7 @@ public class AttachmentServlet extends HttpServlet { // FIXME: Messages would need to be localized somehow. @Override public void doGet( final HttpServletRequest req, final HttpServletResponse res ) throws IOException { - final Context context = Wiki.context().create( m_engine, req, WikiContext.ATTACH ); + final Context context = Wiki.context().create( m_engine, req, ContextEnum.PAGE_ATTACH.getRequestContext() ); final AttachmentManager mgr = m_engine.getManager( AttachmentManager.class ); final AuthorizationManager authmgr = m_engine.getManager( AuthorizationManager.class ); final String version = req.getParameter( HDR_VERSION ); @@ -264,7 +264,7 @@ public class AttachmentServlet extends HttpServlet { res.sendRedirect( validateNextPage( TextUtil.urlEncodeUTF8(nextPage), - m_engine.getURL( WikiContext.ERROR, "", null ) + m_engine.getURL( ContextEnum.WIKI_ERROR.getRequestContext(), "", null ) ) ); } @@ -388,7 +388,7 @@ public class AttachmentServlet extends HttpServlet { protected String upload( final HttpServletRequest req ) throws RedirectException, IOException { final String msg; final String attName = "(unknown)"; - final String errorPage = m_engine.getURL( WikiContext.ERROR, "", null ); // If something bad happened, Upload should be able to take care of most stuff + final String errorPage = m_engine.getURL( ContextEnum.WIKI_ERROR.getRequestContext(), "", null ); // If something bad happened, Upload should be able to take care of most stuff String nextPage = errorPage; final String progressId = req.getParameter( "progressid" ); @@ -401,7 +401,7 @@ public class AttachmentServlet extends HttpServlet { final FileItemFactory factory = new DiskFileItemFactory(); // Create the context _before_ Multipart operations, otherwise strict servlet containers may fail when setting encoding. - final Context context = Wiki.context().create( m_engine, req, WikiContext.ATTACH ); + final Context context = Wiki.context().create( m_engine, req, ContextEnum.PAGE_ATTACH.getRequestContext() ); final UploadListener pl = new UploadListener(); m_engine.getManager( ProgressManager.class ).startProgress( pl, progressId ); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java index 3e5de32..835c421 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java @@ -19,10 +19,10 @@ package org.apache.wiki.auth; import org.apache.log4j.Logger; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Acl; import org.apache.wiki.api.core.AclEntry; 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.core.Session; @@ -220,7 +220,7 @@ public class DefaultAuthorizationManager implements AuthorizationManager { log.info( "User " + currentUser.getName() + " has no access - redirecting (permission=" + context.requiredPermission() + ")" ); context.getWikiSession().addMessage( MessageFormat.format( rb.getString("security.error.noaccess"), context.getName() ) ); } - response.sendRedirect( m_engine.getURL(WikiContext.LOGIN, pageurl, null ) ); + response.sendRedirect( m_engine.getURL( ContextEnum.WIKI_LOGIN.getRequestContext(), pageurl, null ) ); } return allowed; } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java index 19b982c..c215ce1 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java @@ -29,9 +29,9 @@ 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.InternalWikiException; -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.Engine; import org.apache.wiki.api.core.Page; import org.apache.wiki.api.exceptions.ProviderException; @@ -554,7 +554,7 @@ public class SpamFilter extends BasePageFilter { final String userAgent = req.getHeader( "User-Agent" ); final String referrer = req.getHeader( "Referer"); final String permalink = context.getViewURL( context.getPage().getName() ); - final String commentType = context.getRequestContext().equals( WikiContext.COMMENT ) ? "comment" : "edit"; + final String commentType = context.getRequestContext().equals( ContextEnum.PAGE_COMMENT.getRequestContext() ) ? "comment" : "edit"; final String commentAuthor = context.getCurrentUser().getName(); final String commentAuthorEmail = null; final String commentAuthorURL = null; @@ -896,10 +896,10 @@ public class SpamFilter extends BasePageFilter { */ private String getRedirectPage( final Context ctx ) { if( m_useCaptcha ) { - return ctx.getURL( WikiContext.NONE, "Captcha.jsp", "page= " +ctx.getEngine().encodeName( ctx.getPage().getName() ) ); + return ctx.getURL( ContextEnum.PAGE_NONE.getRequestContext(), "Captcha.jsp", "page= " +ctx.getEngine().encodeName( ctx.getPage().getName() ) ); } - return ctx.getURL( WikiContext.VIEW, m_errorPage ); + return ctx.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), m_errorPage ); } /** @@ -993,7 +993,7 @@ public class SpamFilter extends BasePageFilter { final Change change = getChange( context, EditorManager.getEditedText( pageContext ) ); log( context, REJECT, "MissingHash", change.m_change ); - final String redirect = context.getURL( WikiContext.VIEW,"SessionExpired" ); + final String redirect = context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(),"SessionExpired" ); ( ( HttpServletResponse )pageContext.getResponse() ).sendRedirect( redirect ); return false; } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/htmltowiki/HtmlStringToWikiTranslator.java b/jspwiki-main/src/main/java/org/apache/wiki/htmltowiki/HtmlStringToWikiTranslator.java index 327aabc..fa026d9 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/htmltowiki/HtmlStringToWikiTranslator.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/htmltowiki/HtmlStringToWikiTranslator.java @@ -18,10 +18,7 @@ */ package org.apache.wiki.htmltowiki; -import java.io.IOException; -import java.io.StringReader; - -import org.apache.wiki.WikiContext; +import org.apache.wiki.api.core.Context; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.JDOMException; @@ -29,6 +26,9 @@ import org.jdom2.input.SAXBuilder; import org.jdom2.input.sax.XMLReaderSAX2Factory; import org.jdom2.output.XMLOutputter; +import java.io.IOException; +import java.io.StringReader; + /** * Converting Html to Wiki Markup with NekoHtml for converting html to xhtml and * Xhtml2WikiTranslator for converting xhtml to Wiki Markup. @@ -55,7 +55,7 @@ public class HtmlStringToWikiTranslator * @throws JDOMException If parsing fails * @throws IOException For other kinds of errors. */ - public String translate( String html ) throws JDOMException, IOException + public String translate( final String html ) throws JDOMException, IOException { return translate( html, new XHtmlToWikiConfig() ); } @@ -71,7 +71,7 @@ public class HtmlStringToWikiTranslator * @throws JDOMException If parsing fails * @throws IOException For other kinds of errors. */ - public String translate( String html, WikiContext wikiContext ) throws JDOMException, IOException + public String translate( final String html, final Context wikiContext ) throws JDOMException, IOException { return translate( html, new XHtmlToWikiConfig( wikiContext ) ); } @@ -87,11 +87,11 @@ public class HtmlStringToWikiTranslator * @throws IOException For other kinds of errors. */ - public String translate( String html, XHtmlToWikiConfig config ) throws JDOMException, IOException + public String translate( final String html, final XHtmlToWikiConfig config ) throws JDOMException, IOException { - Element element = htmlStringToElement( html ); - XHtmlElementToWikiTranslator xhtmlTranslator = new XHtmlElementToWikiTranslator( element, config ); - String wikiMarkup = xhtmlTranslator.getWikiString(); + final Element element = htmlStringToElement( html ); + final XHtmlElementToWikiTranslator xhtmlTranslator = new XHtmlElementToWikiTranslator( element, config ); + final String wikiMarkup = xhtmlTranslator.getWikiString(); return wikiMarkup; } @@ -103,11 +103,11 @@ public class HtmlStringToWikiTranslator * @throws JDOMException * @throws IOException */ - private Element htmlStringToElement( String html ) throws JDOMException, IOException + private Element htmlStringToElement( final String html ) throws JDOMException, IOException { - SAXBuilder builder = new SAXBuilder( new XMLReaderSAX2Factory( true, CYBERNEKO_PARSER), null, null ); - Document doc = builder.build( new StringReader( html ) ); - Element element = doc.getRootElement(); + final SAXBuilder builder = new SAXBuilder( new XMLReaderSAX2Factory( true, CYBERNEKO_PARSER), null, null ); + final Document doc = builder.build( new StringReader( html ) ); + final Element element = doc.getRootElement(); return element; } @@ -117,10 +117,10 @@ public class HtmlStringToWikiTranslator * @param element The element to get HTML from. * @return HTML */ - public static String element2String( Element element ) + public static String element2String( final Element element ) { - Document document = new Document( element ); - XMLOutputter outputter = new XMLOutputter(); + final Document document = new Document( element ); + final XMLOutputter outputter = new XMLOutputter(); return outputter.outputString( document ); } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/htmltowiki/XHtmlToWikiConfig.java b/jspwiki-main/src/main/java/org/apache/wiki/htmltowiki/XHtmlToWikiConfig.java index 9a84af8..f4c92fb 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/htmltowiki/XHtmlToWikiConfig.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/htmltowiki/XHtmlToWikiConfig.java @@ -18,8 +18,8 @@ */ package org.apache.wiki.htmltowiki; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.Context; +import org.apache.wiki.api.core.ContextEnum; /** @@ -50,10 +50,10 @@ public class XHtmlToWikiConfig { // Figure out the actual URLs. // NB: The logic here will fail if you add something else after the Wiki page name in VIEW or ATTACH - m_wikiJspPage = wikiContext.getURL( WikiContext.VIEW, "" ); - m_editJspPage = wikiContext.getURL( WikiContext.EDIT, "" ); - m_attachPage = wikiContext.getURL( WikiContext.ATTACH, "" ); - m_pageInfoJsp = wikiContext.getURL( WikiContext.INFO, "" ); + m_wikiJspPage = wikiContext.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), "" ); + m_editJspPage = wikiContext.getURL( ContextEnum.PAGE_EDIT.getRequestContext(), "" ); + m_attachPage = wikiContext.getURL( ContextEnum.PAGE_ATTACH.getRequestContext(), "" ); + m_pageInfoJsp = wikiContext.getURL( ContextEnum.PAGE_INFO.getRequestContext(), "" ); } private void setWikiContext( final Context wikiContext ) { 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 75ce2fc..8f981f8 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 @@ -30,7 +30,6 @@ import org.apache.oro.text.regex.Perl5Compiler; import org.apache.oro.text.regex.Perl5Matcher; import org.apache.wiki.InternalWikiException; 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; @@ -354,19 +353,12 @@ public class JSPWikiMarkupParser extends MarkupParser { break; case ATTACHMENT: - final String attlink = m_context.getURL( WikiContext.ATTACH, - link ); - - final String infolink = m_context.getURL( WikiContext.INFO, - link ); - - final String imglink = m_context.getURL( WikiContext.NONE, - "images/attachment_small.png" ); - + final String attlink = m_context.getURL( ContextEnum.PAGE_ATTACH.getRequestContext(), link ); + final String infolink = m_context.getURL( ContextEnum.PAGE_INFO.getRequestContext(), link ); + final String imglink = m_context.getURL( ContextEnum.PAGE_NONE.getRequestContext(), "images/attachment_small.png" ); el = createAnchor( ATTACHMENT, attlink, text, "" ); - if( m_engine.getManager( AttachmentManager.class ).forceDownload( attlink ) ) - { + if( m_engine.getManager( AttachmentManager.class ).forceDownload( attlink ) ) { el.setAttribute("download", ""); } @@ -924,7 +916,7 @@ public class JSPWikiMarkupParser extends MarkupParser { { if( m_outlinkImageURL == null ) { - m_outlinkImageURL = m_context.getURL( WikiContext.NONE, OUTLINK_IMAGE ); + m_outlinkImageURL = m_context.getURL( ContextEnum.PAGE_NONE.getRequestContext(), OUTLINK_IMAGE ); } el = new Element( "img" ).setAttribute( "class", OUTLINK ); @@ -1205,7 +1197,7 @@ public class JSPWikiMarkupParser extends MarkupParser { callMutatorChain( m_attachmentLinkMutatorChain, attachment ); if( m_linkParsingOperations.isImageLink( linkref, isImageInlining(), getInlineImagePatterns() ) ) { - attachment = m_context.getURL( WikiContext.ATTACH, attachment ); + attachment = m_context.getURL( ContextEnum.PAGE_ATTACH.getRequestContext(), attachment ); sb.append( handleImageLink( attachment, linktext, link.hasReference() ) ); } else { makeLink( ATTACHMENT, attachment, linktext, null, link.getAttributes() ); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java index 4796d29..183632a 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java @@ -45,10 +45,10 @@ import java.util.ResourceBundle; /** * Stores the contents of a plugin in a WikiDocument DOM tree. * <p/> - * If the WikiContext.VAR_WYSIWYG_EDITOR_MODE is set to Boolean.TRUE in the context, then the plugin is rendered as WikiMarkup. + * If the Context.VAR_WYSIWYG_EDITOR_MODE is set to Boolean.TRUE in the context, then the plugin is rendered as WikiMarkup. * This allows an HTML editor to work without rendering the plugin each time as well. * <p/> - * If WikiContext.VAR_EXECUTE_PLUGINS is set to Boolean.FALSE, then the plugin is not executed. + * If Context.VAR_EXECUTE_PLUGINS is set to Boolean.FALSE, then the plugin is not executed. * * @since 2.4 */ diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java index f3f3808..6c8a9f6 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.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.exceptions.PluginException; import org.apache.wiki.api.plugin.Plugin; @@ -62,7 +62,7 @@ public class Groups implements Plugin { final String name = groups[ i ].getName(); // Make URL - final String url = engine.getManager( URLConstructor.class ).makeURL( WikiContext.VIEW_GROUP, name, null ); + final String url = engine.getManager( URLConstructor.class ).makeURL( ContextEnum.GROUP_VIEW.getRequestContext(), name, null ); // Create hyperlink s.append( "<a href=\"" ); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Image.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Image.java index ad27ef0..eae9e67 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Image.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Image.java @@ -18,9 +18,9 @@ */ package org.apache.wiki.plugin; -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.Engine; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.api.exceptions.ProviderException; @@ -125,7 +125,7 @@ public class Image implements Plugin { final Attachment att = mgr.getAttachmentInfo( context, src ); if( att != null ) { - src = context.getURL( WikiContext.ATTACH, att.getName() ); + src = context.getURL( ContextEnum.PAGE_ATTACH.getRequestContext(), att.getName() ); } } catch( final ProviderException e ) { throw new PluginException( "Attachment info failed: " + e.getMessage() ); 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 153fab3..00a1e85 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 @@ -18,7 +18,6 @@ */ 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; @@ -162,7 +161,7 @@ public class InsertPage implements Plugin { * its own page, because we need the links to be correct. */ - final WikiContext includedContext = (WikiContext) context.clone(); + final Context includedContext = context.clone(); includedContext.setPage( page ); String pageData = engine.getManager( PageManager.class ).getPureText( page ); @@ -202,7 +201,7 @@ public class InsertPage implements Plugin { res.append( defaultstr ); } else { res.append( "There is no page called '" + includedPage + "'. Would you like to " ); - res.append( "<a href=\"" + context.getURL( WikiContext.EDIT, includedPage ) + "\">create it?</a>" ); + res.append( "<a href=\"" + context.getURL( ContextEnum.PAGE_EDIT.getRequestContext(), includedPage ) + "\">create it?</a>" ); } } } else { diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Note.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Note.java index ae90b30..607aa8b 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Note.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Note.java @@ -20,8 +20,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.exceptions.PluginException; import org.apache.wiki.api.plugin.Plugin; @@ -84,7 +84,7 @@ public class Note implements Plugin { if( resource != null && resource.startsWith( "/" ) ) { resource = resource.substring(1); } - return ctx.getURL( WikiContext.NONE, resource ); + return ctx.getURL( ContextEnum.PAGE_NONE.getRequestContext(), resource ); } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java index 496e859..e44ef05 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java @@ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils; 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; @@ -136,7 +137,8 @@ public class RecentChangesPlugin extends AbstractReferralPlugin implements Plugi olddate = lastmod; } - final String href = context.getURL( pageref instanceof Attachment ? WikiContext.ATTACH : WikiContext.VIEW, pageref.getName() ); + final String href = context.getURL( pageref instanceof Attachment ? ContextEnum.PAGE_ATTACH.getRequestContext() + : ContextEnum.PAGE_VIEW.getRequestContext(), pageref.getName() ); Element link = XhtmlUtil.link( href, engine.getManager( RenderingManager.class ).beautifyTitle( pageref.getName() ) ); final Element row = XhtmlUtil.element( XHTML.tr ); final Element col = XhtmlUtil.element( XHTML.td ); diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringPagesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringPagesPlugin.java index 026d7e9..f0cdfb0 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringPagesPlugin.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringPagesPlugin.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.Page; import org.apache.wiki.api.exceptions.PluginException; import org.apache.wiki.api.plugin.Plugin; @@ -82,7 +82,7 @@ public class ReferringPagesPlugin extends AbstractReferralPlugin { if( page != null ) { Collection< String > links = refmgr.findReferrers( page.getName() ); - String wikitext = ""; + String wikitext; super.initialize( context, params ); @@ -108,9 +108,13 @@ public class ReferringPagesPlugin extends AbstractReferralPlugin { final Object[] args = { "" + ( links.size() - items) }; extras = MessageFormat.format(extras, args); - result.append( "<br />" ); - result.append( "<a class='morelink' href='"+context.getURL( WikiContext.INFO, page.getName() )+"' "); - result.append( ">"+extras+"</a><br />"); + result.append( "<br />" ) + .append( "<a class='morelink' href='" ) + .append( context.getURL( ContextEnum.PAGE_INFO.getRequestContext(), page.getName() ) ) + .append( "' " ) + .append( ">" ) + .append( extras ) + .append( "</a><br />" ); } } @@ -126,7 +130,7 @@ public class ReferringPagesPlugin extends AbstractReferralPlugin { result = new StringBuilder(); result.append( links.size() ); if( m_lastModified ) { - result.append( " (" + m_dateFormat.format( m_dateLastModified ) + ")" ); + result.append( " (" ).append( m_dateFormat.format( m_dateLastModified ) ).append( ")" ); } } } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java index 42b00b8..05b88ee 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.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.core.Page; import org.apache.wiki.api.exceptions.PluginException; @@ -104,7 +104,7 @@ public class WeblogEntryPlugin implements Plugin { entryText = rb.getString("weblogentryplugin.newentry"); } - final String url = context.getURL(WikiContext.NONE, "NewBlogEntry.jsp", "page=" + engine.encodeName( weblogName ) ); + final String url = context.getURL( ContextEnum.PAGE_NONE.getRequestContext(), "NewBlogEntry.jsp", "page=" + engine.encodeName( weblogName ) ); return "<a href=\"" + url + "\">" + entryText + "</a>"; } 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 af768de..397e6ce 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 @@ -19,7 +19,6 @@ 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; @@ -369,7 +368,7 @@ public class WeblogPlugin implements Plugin, ParserStagePlugin { final String addcomment = rb.getString("weblogentryplugin.addcomment"); buffer.append( "<a href=\""+ - entryCtx.getURL( WikiContext.COMMENT, commentPageName, "nc=" + numComments ) + "\">" + + entryCtx.getURL( ContextEnum.PAGE_COMMENT.getRequestContext(), commentPageName, "nc=" + numComments ) + "\">" + MessageFormat.format( addcomment, numComments ) + "</a>" ); } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java b/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java index 17a7810..26c7211 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java @@ -24,9 +24,9 @@ import net.sf.ehcache.Element; import org.apache.commons.lang3.time.StopWatch; import org.apache.log4j.Logger; import org.apache.wiki.StringTransmutator; -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.Engine; import org.apache.wiki.api.core.Page; import org.apache.wiki.api.exceptions.FilterException; @@ -250,7 +250,7 @@ public class DefaultRenderingManager implements RenderingManager { } boolean useCache( final Context context ) { - return m_useCache && WikiContext.VIEW.equals( context.getRequestContext() ); + return m_useCache && ContextEnum.PAGE_VIEW.getRequestContext().equals( context.getRequestContext() ); } /** @@ -296,7 +296,7 @@ public class DefaultRenderingManager implements RenderingManager { public String getHTML( final String pagename, final int version ) { final Page page = m_engine.getManager( PageManager.class ).getPage( pagename, version ); final Context context = Wiki.context().create( m_engine, page ); - context.setRequestContext( WikiContext.NONE ); + context.setRequestContext( ContextEnum.PAGE_NONE.getRequestContext() ); return getHTML( context, page ); } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/EditLinkTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/EditLinkTag.java index ad0957b..3ed3af7 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/tags/EditLinkTag.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/EditLinkTag.java @@ -18,7 +18,7 @@ */ package org.apache.wiki.tags; -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; @@ -114,11 +114,11 @@ public class EditLinkTag extends WikiLinkTag { final JspWriter out = pageContext.getOut(); switch( m_format ) { case ANCHOR: - out.print("<a href=\""+m_wikiContext.getURL(WikiContext.EDIT,pageName, versionString) - +"\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\">"); + out.print( "<a href=\"" + m_wikiContext.getURL( ContextEnum.PAGE_EDIT.getRequestContext(), pageName, versionString ) + + "\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\">" ); break; case URL: - out.print( m_wikiContext.getURL(WikiContext.EDIT,pageName,versionString) ); + out.print( m_wikiContext.getURL( ContextEnum.PAGE_EDIT.getRequestContext(), pageName, versionString ) ); break; } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java b/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java index 22f0f20..3cb09a0 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java @@ -1,7 +1,7 @@ package org.apache.wiki.tasks.auth; 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.exceptions.WikiException; import org.apache.wiki.auth.UserManager; @@ -67,7 +67,7 @@ public class SaveUserProfileTask extends Task { profile.getLoginName(), profile.getFullname(), profile.getEmail(), - m_engine.getURL( WikiContext.LOGIN, null, null ) ); + m_engine.getURL( ContextEnum.WIKI_LOGIN.getRequestContext(), null, null ) ); MailUtil.sendMessage( m_engine.getWikiProperties(), to, subject, content); } catch ( final AddressException e) { LOG.debug( e.getMessage(), e ); 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 c09c1b7..04a1ec8 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 @@ -19,7 +19,6 @@ 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; @@ -128,9 +127,9 @@ public class DefaultURLConstructor implements URLConstructor { @Override public String makeURL( final String context, final String name, String parameters ) { if( parameters != null && parameters.length() > 0 ) { - if( context.equals( WikiContext.ATTACH ) ) { + if( context.equals( ContextEnum.PAGE_ATTACH.getRequestContext() ) ) { parameters = "?" + parameters; - } else if( context.equals( WikiContext.NONE ) ) { + } else if( context.equals( ContextEnum.PAGE_NONE.getRequestContext() ) ) { parameters = name.indexOf( '?' ) != -1 ? "&" : "?" + parameters; } else { parameters = "&" + parameters; @@ -149,7 +148,7 @@ public class DefaultURLConstructor implements URLConstructor { @Override public String parsePage( final String context, final HttpServletRequest request, final Charset encoding ) { String pagereq = request.getParameter( "page" ); - if( context.equals(WikiContext.ATTACH) ) { + if( context.equals( ContextEnum.PAGE_ATTACH.getRequestContext() ) ) { pagereq = URLConstructor.parsePageFromURL( request, encoding ); } 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 563060d..de57f1e 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 @@ -20,7 +20,6 @@ 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; @@ -74,45 +73,45 @@ public class ShortURLConstructor extends DefaultURLConstructor { return doReplacement("%u","" ); } return doReplacement( viewurl, name ); - } else if( context.equals( WikiContext.PREVIEW ) ) { + } else if( context.equals( ContextEnum.PAGE_PREVIEW.getRequestContext() ) ) { if( name == null ) { return doReplacement("%u","" ); } return doReplacement( viewurl + "?do=Preview", name ); - } else if( context.equals( WikiContext.EDIT ) ) { + } else if( context.equals( ContextEnum.PAGE_EDIT.getRequestContext() ) ) { return doReplacement( viewurl + "?do=Edit", name ); - } else if( context.equals( WikiContext.ATTACH ) ) { + } else if( context.equals( ContextEnum.PAGE_ATTACH.getRequestContext() ) ) { return doReplacement( "%uattach/%n", name ); - } else if( context.equals( WikiContext.INFO ) ) { + } else if( context.equals( ContextEnum.PAGE_INFO.getRequestContext() ) ) { return doReplacement( viewurl + "?do=PageInfo", name ); - } else if( context.equals( WikiContext.DIFF ) ) { + } else if( context.equals( ContextEnum.PAGE_DIFF.getRequestContext() ) ) { return doReplacement( viewurl + "?do=Diff", name ); - } else if( context.equals( WikiContext.NONE ) ) { + } else if( context.equals( ContextEnum.PAGE_NONE.getRequestContext() ) ) { return doReplacement( "%u%n", name ); - } else if( context.equals( WikiContext.UPLOAD ) ) { + } else if( context.equals( ContextEnum.PAGE_UPLOAD.getRequestContext() ) ) { return doReplacement( viewurl + "?do=Upload", name ); - } else if( context.equals( WikiContext.COMMENT ) ) { + } else if( context.equals( ContextEnum.PAGE_COMMENT.getRequestContext() ) ) { return doReplacement( viewurl + "?do=Comment", name ); - } else if( context.equals( WikiContext.LOGIN ) ) { + } else if( context.equals( ContextEnum.WIKI_LOGIN.getRequestContext() ) ) { final String loginUrl = "%pLogin.jsp?redirect=%n"; return doReplacement( loginUrl, name ); - } else if( context.equals( WikiContext.DELETE ) ) { + } else if( context.equals( ContextEnum.PAGE_DELETE.getRequestContext() ) ) { return doReplacement( viewurl + "?do=Delete", name ); - } else if( context.equals( WikiContext.CONFLICT ) ) { + } else if( context.equals( ContextEnum.PAGE_CONFLICT.getRequestContext() ) ) { return doReplacement( viewurl + "?do=PageModified", name ); - } else if( context.equals( WikiContext.PREFS ) ) { + } else if( context.equals( ContextEnum.WIKI_PREFS.getRequestContext() ) ) { return doReplacement( viewurl + "?do=UserPreferences", name ); - } else if( context.equals( WikiContext.FIND ) ) { + } else if( context.equals( ContextEnum.WIKI_FIND.getRequestContext() ) ) { return doReplacement( viewurl + "?do=Search", name ); - } else if( context.equals( WikiContext.ERROR ) ) { + } else if( context.equals( ContextEnum.WIKI_ERROR.getRequestContext() ) ) { return doReplacement( "%uError.jsp", name ); - } else if( context.equals( WikiContext.CREATE_GROUP ) ) { + } else if( context.equals( ContextEnum.WIKI_CREATE_GROUP.getRequestContext() ) ) { return doReplacement( viewurl + "?do=NewGroup", name ); - } else if( context.equals( WikiContext.DELETE_GROUP ) ) { + } else if( context.equals( ContextEnum.GROUP_DELETE.getRequestContext() ) ) { return doReplacement( viewurl + "?do=DeleteGroup", name ); - } else if( context.equals( WikiContext.EDIT_GROUP ) ) { + } else if( context.equals( ContextEnum.GROUP_EDIT.getRequestContext() ) ) { return doReplacement( viewurl + "?do=EditGroup", name ); - } else if( context.equals( WikiContext.VIEW_GROUP ) ) { + } else if( context.equals( ContextEnum.GROUP_VIEW.getRequestContext() ) ) { return doReplacement( viewurl + "?do=Group&group=%n", name ); } @@ -127,7 +126,7 @@ public class ShortURLConstructor extends DefaultURLConstructor { if( parameters != null && parameters.length() > 0 ) { if( context.equals( ContextEnum.PAGE_ATTACH.getRequestContext() ) || context.equals( ContextEnum.PAGE_VIEW.getRequestContext() ) ) { parameters = "?" + parameters; - } else if( context.equals(WikiContext.NONE) ) { + } else if( context.equals(ContextEnum.PAGE_NONE.getRequestContext()) ) { parameters = (name.indexOf('?') != -1 ) ? "&" : "?" + parameters; } else { parameters = "&"+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 d0fdc33..659446f 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 @@ -18,7 +18,6 @@ */ package org.apache.wiki.url; -import org.apache.wiki.WikiContext; import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Engine; @@ -59,7 +58,7 @@ public class ShortViewURLConstructor extends ShortURLConstructor { if( parameters != null && parameters.length() > 0 ) { if( context.equals( ContextEnum.PAGE_ATTACH.getRequestContext() ) || context.equals( ContextEnum.PAGE_VIEW.getRequestContext() ) || name == null ) { parameters = "?" + parameters; - } else if( context.equals(WikiContext.NONE) ) { + } else if( context.equals(ContextEnum.PAGE_NONE.getRequestContext()) ) { parameters = (name.indexOf('?') != -1 ) ? "&" : "?" + parameters; } else { parameters = "&" + parameters; diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java index ee45442..e43ae6e 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java @@ -28,6 +28,7 @@ import org.apache.wiki.WikiContext; import org.apache.wiki.WikiEngine; import org.apache.wiki.WikiPage; import org.apache.wiki.api.core.Command; +import org.apache.wiki.api.core.ContextEnum; import org.apache.wiki.api.core.Page; import org.apache.wiki.auth.GroupPrincipal; import org.apache.wiki.pages.PageManager; @@ -62,9 +63,9 @@ public class CommandResolverTest { @Test public void testFindStaticWikiAction() { // If we look for action with "edit" request context, we get EDIT action - Command a = CommandResolver.findCommand( WikiContext.EDIT ); + Command a = CommandResolver.findCommand( ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertEquals( PageCommand.EDIT, a ); - Assertions.assertEquals( WikiContext.EDIT, a.getRequestContext() ); + Assertions.assertEquals( ContextEnum.PAGE_EDIT.getRequestContext(), a.getRequestContext() ); // Ditto for prefs context a = CommandResolver.findCommand( WikiContext.PREFS ); @@ -85,7 +86,7 @@ public class CommandResolverTest { MockHttpServletRequest request = m_engine.newHttpRequest( "" ); // Passing an EDIT request with no explicit page params means the EDIT action - Command a = resolver.findCommand( request, WikiContext.EDIT ); + Command a = resolver.findCommand( request, ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertEquals( PageCommand.EDIT, a ); Assertions.assertEquals( "EditContent.jsp", a.getContentTemplate() ); Assertions.assertEquals( "Edit.jsp", a.getJSP() ); @@ -106,21 +107,21 @@ public class CommandResolverTest { // Request for "UserPreference.jsp" should resolve to PREFS action request = m_engine.newHttpRequest( "/UserPreferences.jsp" ); - a = resolver.findCommand( request, WikiContext.EDIT ); + a = resolver.findCommand( request, ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertEquals( WikiCommand.PREFS, a ); Assertions.assertNull( a.getTarget() ); // Request for "NewGroup.jsp" should resolve to CREATE_GROUP action // but targeted at the wiki request = m_engine.newHttpRequest( "/NewGroup.jsp" ); - a = resolver.findCommand( request, WikiContext.EDIT ); + a = resolver.findCommand( request, ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertNotSame( WikiCommand.CREATE_GROUP, a ); Assertions.assertEquals( WikiCommand.CREATE_GROUP.getRequestContext(), a.getRequestContext() ); Assertions.assertEquals( m_engine.getApplicationName(), a.getTarget() ); // But request for JSP not mapped to action should get default request = m_engine.newHttpRequest( "/NonExistent.jsp" ); - a = resolver.findCommand( request, WikiContext.EDIT ); + a = resolver.findCommand( request, ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertEquals( PageCommand.EDIT, a ); Assertions.assertNull( a.getTarget() ); } @@ -132,7 +133,7 @@ public class CommandResolverTest { // Passing an EDIT request with page param yields a wrapped action MockHttpServletRequest request = m_engine.newHttpRequest( "/Edit.jsp?page=SinglePage" ); request.getParameterMap().put( "page", new String[]{ "SinglePage" } ); - Command a = resolver.findCommand( request, WikiContext.EDIT ); + Command a = resolver.findCommand( request, ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertNotSame( PageCommand.EDIT, a ); Assertions.assertEquals( "EditContent.jsp", a.getContentTemplate() ); Assertions.assertEquals( "Edit.jsp", a.getJSP() ); @@ -142,7 +143,7 @@ public class CommandResolverTest { // Passing an EDIT request with page=Search yields FIND action, *not* edit request.setContextPath( "/Edit.jsp?page=Search" ); request.getParameterMap().put( "page", new String[]{ "Search" } ); - a = resolver.findCommand( request, WikiContext.EDIT ); + a = resolver.findCommand( request, ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertEquals( WikiCommand.FIND, a ); Assertions.assertEquals( "FindContent.jsp", a.getContentTemplate() ); Assertions.assertEquals( "Search.jsp", a.getJSP() ); @@ -152,7 +153,7 @@ public class CommandResolverTest { // Passing an EDIT request with group="Foo" yields wrapped VIEW_GROUP request = m_engine.newHttpRequest( "/Group.jsp?group=Foo" ); request.getParameterMap().put( "group", new String[]{ "Foo" } ); - a = resolver.findCommand( request, WikiContext.EDIT ); + a = resolver.findCommand( request, ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertNotSame( GroupCommand.VIEW_GROUP, a ); Assertions.assertEquals( "GroupContent.jsp", a.getContentTemplate() ); Assertions.assertEquals( "Group.jsp", a.getJSP() ); @@ -164,19 +165,19 @@ public class CommandResolverTest { public void testFindWikiActionWithPath() { // Passing an EDIT request with View JSP yields EDIT of the Front page MockHttpServletRequest request = m_engine.newHttpRequest( "/Wiki.jsp" ); - Command a = resolver.findCommand( request, WikiContext.EDIT ); + Command a = resolver.findCommand( request, ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertNotNull( a.getTarget() ); Assertions.assertEquals( ((WikiPage)a.getTarget()).getName(), m_engine.getFrontPage() ); // Passing an EDIT request with Group JSP yields VIEW_GROUP request = m_engine.newHttpRequest( "/Group.jsp" ); - a = resolver.findCommand( request, WikiContext.EDIT ); + a = resolver.findCommand( request, ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertEquals( GroupCommand.VIEW_GROUP, a ); Assertions.assertNull( a.getTarget() ); // Passing an EDIT request with UserPreferences JSP yields PREFS request = m_engine.newHttpRequest( "/UserPreferences.jsp" ); - a = resolver.findCommand( request, WikiContext.EDIT ); + a = resolver.findCommand( request, ContextEnum.PAGE_EDIT.getRequestContext() ); Assertions.assertEquals( WikiCommand.PREFS, a ); Assertions.assertNull( a.getTarget() ); } 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 1dc9b88..996f7b8 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 @@ -23,7 +23,6 @@ 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; @@ -120,7 +119,7 @@ public class DefaultURLConstructorTest { final URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",null) ); + Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(ContextEnum.PAGE_EDIT.getRequestContext(),"Main",null) ); } @Test @@ -129,7 +128,7 @@ public class DefaultURLConstructorTest { final URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); + Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(ContextEnum.PAGE_ATTACH.getRequestContext(),"Main/foo.txt",null) ); } @Test @@ -138,7 +137,7 @@ public class DefaultURLConstructorTest { final URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) ); + Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(ContextEnum.PAGE_ATTACH.getRequestContext(),"Main/foo.txt",null) ); } @Test @@ -147,7 +146,7 @@ public class DefaultURLConstructorTest { final URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",null) ); + Assertions.assertEquals( "/test/foo.jsp", c.makeURL(ContextEnum.PAGE_NONE.getRequestContext(),"foo.jsp",null) ); } @Test @@ -156,7 +155,7 @@ public class DefaultURLConstructorTest { final URLConstructor c = getConstructor( null ); - Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(WikiContext.NONE,"foo.jsp","a=1&b=2") ); + Assertions.assertEquals( "/test/foo.jsp?a=1&b=2", c.makeURL(ContextEnum.PAGE_NONE.getRequestContext(),"foo.jsp","a=1&b=2") ); } @Test
