Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParentPageNameTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParentPageNameTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParentPageNameTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParentPageNameTag.java Sat Feb 23 11:29:13 2008 @@ -22,7 +22,6 @@ import java.io.IOException; import com.ecyrd.jspwiki.WikiEngine; -import com.ecyrd.jspwiki.WikiPage; import com.ecyrd.jspwiki.attachment.Attachment; /** @@ -40,18 +39,17 @@ public final int doWikiStartTag() throws IOException { - WikiEngine engine = m_wikiContext.getEngine(); - WikiPage page = m_wikiContext.getPage(); - - if( page != null ) + WikiEngine engine = m_actionBean.getEngine(); + + if( m_page != null ) { - if( page instanceof Attachment ) + if( m_page instanceof Attachment ) { - pageContext.getOut().print( engine.beautifyTitle( ((Attachment)page).getParentName()) ); + pageContext.getOut().print( engine.beautifyTitle( ((Attachment)m_page).getParentName()) ); } else { - String name = page.getName(); + String name = m_page.getName(); int entrystart = name.indexOf("_blogentry_");
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PermissionTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PermissionTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PermissionTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PermissionTag.java Sat Feb 23 11:29:13 2008 @@ -24,17 +24,14 @@ import org.apache.commons.lang.StringUtils; -import com.ecyrd.jspwiki.WikiPage; -import com.ecyrd.jspwiki.WikiProvider; -import com.ecyrd.jspwiki.WikiSession; +import com.ecyrd.jspwiki.*; +import com.ecyrd.jspwiki.action.GroupContext; import com.ecyrd.jspwiki.auth.AuthorizationManager; -import com.ecyrd.jspwiki.auth.GroupPrincipal; +import com.ecyrd.jspwiki.auth.authorize.Group; import com.ecyrd.jspwiki.auth.permissions.AllPermission; import com.ecyrd.jspwiki.auth.permissions.GroupPermission; import com.ecyrd.jspwiki.auth.permissions.PermissionFactory; import com.ecyrd.jspwiki.auth.permissions.WikiPermission; -import com.ecyrd.jspwiki.ui.Command; -import com.ecyrd.jspwiki.ui.GroupCommand; /** * Tells whether the user in the current wiki context possesses a particular @@ -109,44 +106,40 @@ */ private boolean checkPermission( String permission ) { - WikiSession session = m_wikiContext.getWikiSession(); - WikiPage page = m_wikiContext.getPage(); - AuthorizationManager mgr = m_wikiContext.getEngine().getAuthorizationManager(); + WikiEngine engine = m_actionBean.getEngine(); + WikiSession session = m_actionBean.getWikiSession(); + AuthorizationManager mgr = engine.getAuthorizationManager(); boolean gotPermission = false; if ( CREATE_GROUPS.equals( permission ) || CREATE_PAGES.equals( permission ) || EDIT_PREFERENCES.equals( permission ) || EDIT_PROFILE.equals( permission ) || LOGIN.equals( permission ) ) { - gotPermission = mgr.checkPermission( session, new WikiPermission( page.getWiki(), permission ) ); + gotPermission = mgr.checkPermission( session, new WikiPermission( engine.getApplicationName(), permission ) ); } - else if ( VIEW_GROUP.equals( permission ) - || EDIT_GROUP.equals( permission ) - || DELETE_GROUP.equals( permission ) ) - { - Command command = m_wikiContext.getCommand(); - gotPermission = false; - if ( command instanceof GroupCommand && command.getTarget() != null ) - { - GroupPrincipal group = (GroupPrincipal)command.getTarget(); - String groupName = group.getName(); - String action = "view"; - if( EDIT_GROUP.equals( permission ) ) - { - action = "edit"; - } - else if ( DELETE_GROUP.equals( permission ) ) - { - action = "delete"; - } - gotPermission = mgr.checkPermission( session, new GroupPermission( groupName, action ) ); - } + else if ( VIEW_GROUP.equals( permission ) ) + { + Group group = ((GroupContext)m_actionBean).getGroup(); + Permission perm = new GroupPermission( group.getName(), GroupPermission.VIEW_ACTION ); + gotPermission = mgr.checkPermission( session, perm ); + } + else if ( EDIT_GROUP.equals( permission ) ) + { + Group group = ((GroupContext)m_actionBean).getGroup(); + Permission perm = new GroupPermission( group.getName(), GroupPermission.VIEW_ACTION ); + gotPermission = mgr.checkPermission( session, perm ); + } + else if ( DELETE_GROUP.equals( permission ) ) + { + Group group = ((GroupContext)m_actionBean).getGroup(); + Permission perm = new GroupPermission( group.getName(), GroupPermission.VIEW_ACTION ); + gotPermission = mgr.checkPermission( session, perm ); } else if ( ALL_PERMISSION.equals( permission ) ) { - gotPermission = mgr.checkPermission( session, new AllPermission( m_wikiContext.getEngine().getApplicationName() ) ); + gotPermission = mgr.checkPermission( session, new AllPermission( engine.getApplicationName() ) ); } - else if ( page != null ) + else if ( m_actionBean instanceof WikiContext && m_page != null ) { // // Edit tag also checks that we're not trying to edit an @@ -154,15 +147,15 @@ // if( EDIT.equals(permission) ) { - WikiPage latest = m_wikiContext.getEngine().getPage( page.getName() ); - if( page.getVersion() != WikiProvider.LATEST_VERSION && - latest.getVersion() != page.getVersion() ) + WikiPage latest = engine.getPage( m_page.getName() ); + if( m_page.getVersion() != WikiProvider.LATEST_VERSION && + latest.getVersion() != m_page.getVersion() ) { return false; } } - Permission p = PermissionFactory.getPagePermission( page, permission ); + Permission p = PermissionFactory.getPagePermission( m_page, permission ); gotPermission = mgr.checkPermission( session, p ); } Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PluginTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PluginTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PluginTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PluginTag.java Sat Feb 23 11:29:13 2008 @@ -81,7 +81,7 @@ m_evaluated = true; - Map argmap = pm.parseArgs( args ); + Map<String,Object> argmap = pm.parseArgs( args ); if( body != null ) { Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PreviousVersionTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PreviousVersionTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PreviousVersionTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PreviousVersionTag.java Sat Feb 23 11:29:13 2008 @@ -21,8 +21,6 @@ import java.io.IOException; -import com.ecyrd.jspwiki.WikiPage; - /** * Outputs the version number of the previous version of this page. * @@ -37,14 +35,15 @@ public final int doWikiStartTag() throws IOException { - WikiPage page = m_wikiContext.getPage(); - - int version = page.getVersion(); + if ( m_page != null ) + { + int version = m_page.getVersion(); - version--; + version--; - if( version > 0 ) - pageContext.getOut().print( version ); + if( version > 0 ) + pageContext.getOut().print( version ); + } return SKIP_BODY; } Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSCoffeeCupLinkTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSCoffeeCupLinkTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSCoffeeCupLinkTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSCoffeeCupLinkTag.java Sat Feb 23 11:29:13 2008 @@ -60,7 +60,7 @@ public final int doWikiStartTag() throws IOException { - WikiEngine engine = m_wikiContext.getEngine(); + WikiEngine engine = m_actionBean.getEngine(); String rssURL = engine.getGlobalRSSURL(); Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSImageLinkTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSImageLinkTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSImageLinkTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSImageLinkTag.java Sat Feb 23 11:29:13 2008 @@ -23,8 +23,8 @@ import javax.servlet.jsp.JspWriter; -import com.ecyrd.jspwiki.WikiContext; import com.ecyrd.jspwiki.WikiEngine; +import com.ecyrd.jspwiki.action.NoneActionBean; /** * Writes an image link to the RSS file. @@ -58,7 +58,7 @@ public final int doWikiStartTag() throws IOException { - WikiEngine engine = m_wikiContext.getEngine(); + WikiEngine engine = m_actionBean.getEngine(); String rssURL = engine.getGlobalRSSURL(); @@ -66,7 +66,7 @@ { JspWriter out = pageContext.getOut(); out.print("<a href=\""+rssURL+"\">"); - out.print("<img src=\""+m_wikiContext.getURL( WikiContext.NONE,"images/xml.png")+"\""); + out.print("<img src=\""+m_actionBean.getContext().getURL( NoneActionBean.class,"images/xml.png")+"\""); out.print(" alt=\"[RSS]\" title=\""+getTitle()+"\"/>"); out.print("</a>"); } Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSLinkTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSLinkTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSLinkTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSLinkTag.java Sat Feb 23 11:29:13 2008 @@ -41,7 +41,7 @@ public final int doWikiStartTag() throws IOException { - WikiEngine engine = m_wikiContext.getEngine(); + WikiEngine engine = m_actionBean.getEngine(); String rssURL = engine.getGlobalRSSURL(); Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RequestResourceTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RequestResourceTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RequestResourceTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RequestResourceTag.java Sat Feb 23 11:29:13 2008 @@ -45,7 +45,7 @@ { if( m_type != null && m_resource != null ) { - TemplateManager.addResourceRequest( m_wikiContext, m_type, m_resource ); + TemplateManager.addResourceRequest( m_actionBean, m_type, m_resource ); } return SKIP_BODY; Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/SearchResultIteratorTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/SearchResultIteratorTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/SearchResultIteratorTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/SearchResultIteratorTag.java Sat Feb 23 11:29:13 2008 @@ -22,7 +22,6 @@ import java.io.IOException; import java.util.Collection; -import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.PageContext; @@ -31,8 +30,7 @@ import com.ecyrd.jspwiki.SearchResult; import com.ecyrd.jspwiki.WikiContext; import com.ecyrd.jspwiki.WikiEngine; -import com.ecyrd.jspwiki.ui.Command; -import com.ecyrd.jspwiki.ui.PageCommand; +import com.ecyrd.jspwiki.action.WikiActionBeanFactory; /** * Iterates through Search result results. @@ -93,8 +91,7 @@ } m_count = 0; - m_wikiContext = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT, - PageContext.REQUEST_SCOPE ); + m_wikiContext = (WikiContext) WikiActionBeanFactory.findActionBean( pageContext ); return nextResult(); } @@ -107,14 +104,10 @@ // Create a wiki context for the result WikiEngine engine = m_wikiContext.getEngine(); - HttpServletRequest request = m_wikiContext.getHttpRequest(); - Command command = PageCommand.VIEW.targetedCommand( r.getPage() ); - WikiContext context = new WikiContext( engine, request, command ); + WikiContext context = engine.getWikiActionBeanFactory().newViewActionBean( r.getPage() ); // Stash it in the page context - pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT, - context, - PageContext.REQUEST_SCOPE ); + WikiActionBeanFactory.saveActionBean( pageContext, context ); pageContext.setAttribute( getId(), r ); return EVAL_BODY_BUFFERED; Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TabTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TabTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TabTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TabTag.java Sat Feb 23 11:29:13 2008 @@ -110,7 +110,7 @@ */ public int doWikiStartTag() throws JspTagException { - TabbedSectionTag parent=(TabbedSectionTag)findAncestorWithClass( this, TabbedSectionTag.class ); + TabbedSectionTag parent=getParentTag(TabbedSectionTag.class ); // // Sanity checks @@ -157,7 +157,7 @@ */ public int doEndTag() throws javax.servlet.jsp.JspTagException { - TabbedSectionTag parent=(TabbedSectionTag)findAncestorWithClass( this, TabbedSectionTag.class ); + TabbedSectionTag parent=getParentTag( TabbedSectionTag.class ); StringBuffer sb = new StringBuffer(); Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TemplateDirTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TemplateDirTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TemplateDirTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TemplateDirTag.java Sat Feb 23 11:29:13 2008 @@ -36,7 +36,7 @@ public final int doWikiStartTag() throws IOException { - String template = m_wikiContext.getTemplate(); + String template = m_actionBean.getTemplate(); pageContext.getOut().print( template ); Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TranslateTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TranslateTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TranslateTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/TranslateTag.java Sat Feb 23 11:29:13 2008 @@ -20,11 +20,11 @@ package com.ecyrd.jspwiki.tags; import javax.servlet.jsp.JspException; -import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.BodyContent; import javax.servlet.jsp.tagext.BodyTagSupport; import com.ecyrd.jspwiki.WikiContext; +import com.ecyrd.jspwiki.action.WikiActionBeanFactory; import org.apache.log4j.Logger; @@ -46,8 +46,7 @@ { try { - WikiContext context = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT, - PageContext.REQUEST_SCOPE ); + WikiContext context = (WikiContext) WikiActionBeanFactory.findActionBean( pageContext ); BodyContent bc = getBodyContent(); String wikiText = bc.getString(); bc.clearBody(); Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UploadLinkTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UploadLinkTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UploadLinkTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UploadLinkTag.java Sat Feb 23 11:29:13 2008 @@ -22,7 +22,7 @@ import java.io.IOException; import javax.servlet.jsp.JspWriter; -import com.ecyrd.jspwiki.WikiContext; +import com.ecyrd.jspwiki.action.UploadActionBean; /** * Writes a link to the upload page. Body of the link becomes the actual text. @@ -49,9 +49,9 @@ if( m_pageName == null ) { - if( m_wikiContext.getPage() != null ) + if( m_page != null ) { - pageName = m_wikiContext.getPage().getName(); + pageName = m_page.getName(); } else { @@ -61,8 +61,7 @@ JspWriter out = pageContext.getOut(); - String url = m_wikiContext.getURL( WikiContext.UPLOAD, - pageName ); + String url = m_actionBean.getContext().getURL( UploadActionBean.class, pageName ); switch( m_format ) { Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserCheckTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserCheckTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserCheckTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserCheckTag.java Sat Feb 23 11:29:13 2008 @@ -124,9 +124,9 @@ public final int doWikiStartTag() throws IOException { - WikiSession session = m_wikiContext.getWikiSession(); + WikiSession session = m_actionBean.getWikiSession(); String status = session.getStatus(); - AuthenticationManager mgr = m_wikiContext.getEngine().getAuthenticationManager(); + AuthenticationManager mgr = m_actionBean.getEngine().getAuthenticationManager(); boolean containerAuth = mgr.isContainerAuthenticated(); boolean cookieAssertions = AuthenticationManager.allowsCookieAssertions(); Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserNameTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserNameTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserNameTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserNameTag.java Sat Feb 23 11:29:13 2008 @@ -42,7 +42,7 @@ public final int doWikiStartTag() throws IOException { - WikiEngine engine = this.m_wikiContext.getEngine(); + WikiEngine engine = this.m_actionBean.getEngine(); WikiSession wikiSession = WikiSession.getWikiSession( engine, (HttpServletRequest)pageContext.getRequest() ); Principal user = wikiSession.getUserPrincipal(); Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserProfileTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserProfileTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserProfileTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/UserProfileTag.java Sat Feb 23 11:29:13 2008 @@ -31,6 +31,7 @@ import com.ecyrd.jspwiki.WikiContext; import com.ecyrd.jspwiki.WikiEngine; import com.ecyrd.jspwiki.WikiSession; +import com.ecyrd.jspwiki.action.WikiActionBean; import com.ecyrd.jspwiki.auth.AuthenticationManager; import com.ecyrd.jspwiki.auth.GroupPrincipal; import com.ecyrd.jspwiki.auth.UserManager; @@ -121,8 +122,8 @@ public final int doWikiStartTag() throws IOException, WikiSecurityException { - UserManager manager = m_wikiContext.getEngine().getUserManager(); - UserProfile profile = manager.getUserProfile( m_wikiContext.getWikiSession() ); + UserManager manager = m_actionBean.getEngine().getUserManager(); + UserProfile profile = manager.getUserProfile( m_actionBean.getWikiSession() ); String result = null; if ( EXISTS.equals( m_prop ) || NOT_NEW.equals( m_prop ) ) @@ -148,7 +149,7 @@ } else if ( GROUPS.equals( m_prop ) ) { - result = printGroups( m_wikiContext ); + result = printGroups( m_actionBean ); } else if ( LOGINNAME.equals( m_prop ) ) { @@ -160,7 +161,7 @@ } else if ( ROLES.equals( m_prop ) ) { - result = printRoles( m_wikiContext ); + result = printRoles( m_actionBean ); } else if ( WIKINAME.equals( m_prop ) ) { @@ -171,7 +172,7 @@ // // Default back to the declared user name // - WikiEngine engine = this.m_wikiContext.getEngine(); + WikiEngine engine = this.m_actionBean.getEngine(); WikiSession wikiSession = WikiSession.getWikiSession( engine, (HttpServletRequest)pageContext.getRequest() ); Principal user = wikiSession.getUserPrincipal(); @@ -183,7 +184,7 @@ } else if ( CHANGE_PASSWORD.equals( m_prop ) || CHANGE_LOGIN_NAME.equals( m_prop ) ) { - AuthenticationManager authMgr = m_wikiContext.getEngine().getAuthenticationManager(); + AuthenticationManager authMgr = m_actionBean.getEngine().getAuthenticationManager(); if ( !authMgr.isContainerAuthenticated() || manager.getUserDatabase().isSharedWithContainer() ) { @@ -192,7 +193,7 @@ } else if ( NOT_CHANGE_PASSWORD.equals( m_prop ) || NOT_CHANGE_LOGIN_NAME.equals( m_prop ) ) { - AuthenticationManager authMgr = m_wikiContext.getEngine().getAuthenticationManager(); + AuthenticationManager authMgr = m_actionBean.getEngine().getAuthenticationManager(); if ( authMgr.isContainerAuthenticated() && !manager.getUserDatabase().isSharedWithContainer() ) { @@ -219,11 +220,11 @@ * and extracting those that are of type Group. * @return the list of groups, sorted by name */ - public static String printGroups( WikiContext context ) + public static String printGroups( WikiActionBean actionBean ) { - Principal[] roles = context.getWikiSession().getRoles(); - List tempRoles = new ArrayList(); - ResourceBundle rb = context.getBundle(InternationalizationManager.CORE_BUNDLE); + Principal[] roles = actionBean.getWikiSession().getRoles(); + List<String> tempRoles = new ArrayList<String>(); + ResourceBundle rb = actionBean.getBundle(InternationalizationManager.CORE_BUNDLE); for ( int i = 0; i < roles.length; i++ ) { @@ -240,7 +241,7 @@ StringBuffer sb = new StringBuffer(); for ( int i = 0; i < tempRoles.size(); i++ ) { - String name = (String)tempRoles.get( i ); + String name = tempRoles.get( i ); sb.append( name ); if ( i < ( tempRoles.size() - 1 ) ) @@ -260,11 +261,11 @@ * and extracting those that are of type Role. * @return the list of roles, sorted by name */ - public static String printRoles( WikiContext context ) + public static String printRoles( WikiActionBean actionBean ) { - Principal[] roles = context.getWikiSession().getRoles(); - List tempRoles = new ArrayList(); - ResourceBundle rb = context.getBundle(InternationalizationManager.CORE_BUNDLE); + Principal[] roles = actionBean.getWikiSession().getRoles(); + List<String> tempRoles = new ArrayList<String>(); + ResourceBundle rb = actionBean.getBundle(InternationalizationManager.CORE_BUNDLE); for ( int i = 0; i < roles.length; i++ ) { @@ -281,13 +282,14 @@ StringBuffer sb = new StringBuffer(); for ( int i = 0; i < tempRoles.size(); i++ ) { - String name = (String)tempRoles.get( i ); - - sb.append( name ); - if ( i < ( tempRoles.size() - 1 ) ) + String name = tempRoles.get( i ); { - sb.append(','); - sb.append(' '); + sb.append( name ); + if ( i < ( tempRoles.size() - 1 ) ) + { + sb.append(','); + sb.append(' '); + } } } Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/VariableTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/VariableTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/VariableTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/VariableTag.java Sat Feb 23 11:29:13 2008 @@ -77,14 +77,14 @@ throws JspException, IOException { - WikiEngine engine = m_wikiContext.getEngine(); + WikiEngine engine = m_actionBean.getEngine(); JspWriter out = pageContext.getOut(); String msg = null; String value = null; try { - value = engine.getVariableManager().getValue( m_wikiContext, + value = engine.getVariableManager().getValue( m_actionBean, getVar() ); } catch( NoSuchVariableException e ) Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiBodyTag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiBodyTag.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiBodyTag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiBodyTag.java Sat Feb 23 11:29:13 2008 @@ -22,13 +22,13 @@ import java.io.IOException; import javax.servlet.jsp.JspException; -import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.BodyTagSupport; import javax.servlet.jsp.tagext.TryCatchFinally; import org.apache.log4j.Logger; import com.ecyrd.jspwiki.WikiContext; +import com.ecyrd.jspwiki.action.WikiActionBeanFactory; /** * This is a class that provides the same services as the WikiTagBase, but this time it @@ -47,8 +47,7 @@ { try { - m_wikiContext = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT, - PageContext.REQUEST_SCOPE ); + m_wikiContext = (WikiContext) WikiActionBeanFactory.findActionBean( pageContext ); if( m_wikiContext == null ) { Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiTagBase.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiTagBase.java?rev=630513&r1=630512&r2=630513&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiTagBase.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiTagBase.java Sat Feb 23 11:29:13 2008 @@ -21,33 +21,56 @@ import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; -import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.tagext.TryCatchFinally; +import net.sourceforge.stripes.tag.StripesTagSupport; + import org.apache.log4j.Logger; -import com.ecyrd.jspwiki.TextUtil; -import com.ecyrd.jspwiki.WikiContext; +import com.ecyrd.jspwiki.*; +import com.ecyrd.jspwiki.action.WikiActionBean; +import com.ecyrd.jspwiki.action.WikiActionBeanFactory; +import com.ecyrd.jspwiki.ui.WikiInterceptor; /** + * <p> * Base class for JSPWiki tags. You do not necessarily have * to derive from this class, since this does some initialization. - * <P> + * </p> + * <p> * This tag is only useful if you're having an "empty" tag, with * no body content. + * </p> + * <p>The order of init method processing for subclasses of WikiTagBase is as follows:</p> + * <ul> + * <li>[EMAIL PROTECTED] #initTag()}</li> + * <li>[EMAIL PROTECTED] #doStartTag()}</li> + * <li>[EMAIL PROTECTED] #doWikiStartTag()} - implemented by subclasses</li> + * </ul> * * @author Janne Jalkanen * @since 2.0 */ public abstract class WikiTagBase - extends TagSupport + extends StripesTagSupport implements TryCatchFinally { - public static final String ATTR_CONTEXT = "jspwiki.context"; + /** + * The name of the request attribute used to store ActionBeans (WikiContexts). + * @deprecated Use [EMAIL PROTECTED] WikiInterceptor#ATTR_ACTIONBEAN} instead + */ + public static final String ATTR_CONTEXT = WikiInterceptor.ATTR_ACTIONBEAN; static Logger log = Logger.getLogger( WikiTagBase.class ); - protected WikiContext m_wikiContext; + protected WikiActionBean m_actionBean; + + private String m_id; + + /** + * If the ActionBean is a WikiContext and the page is non-null, this value will be set automatically by [EMAIL PROTECTED] #doStartTag()}. + */ + protected WikiPage m_page; /** * This method calls the parent setPageContext() but it also @@ -69,21 +92,46 @@ */ public void initTag() { - m_wikiContext = null; + m_actionBean = null; + m_page = null; return; } + /** + * Initializes the tag, and sets an internal reference to the current WikiActionBean + * by delegating to + * [EMAIL PROTECTED] com.ecyrd.jspwiki.action.WikiInterceptor#findActionBean( PageContext )}. + * (That method retrieves the WikiActionBean from page scope.). + * If the WikiActionBean is a WikiContext, a reference to the current wiki page will be + * set also. Both of these available as protected fields [EMAIL PROTECTED] #m_actionBean} and + * [EMAIL PROTECTED] #m_page}, respectively. It is considered an error condition if the + * WikiActionBean cannot be retrieved from the PageContext. + * It's also an error condition if the WikiActionBean is actually a WikiContext, and it + * returns a <code>null</code> WikiPage. + */ public int doStartTag() throws JspException { try { - m_wikiContext = (WikiContext) pageContext.getAttribute( ATTR_CONTEXT, - PageContext.REQUEST_SCOPE ); + // Retrieve the ActionBean injected by WikiInterceptor + m_actionBean = WikiActionBeanFactory.findActionBean( pageContext ); + + // It's really bad news if the WikiActionBean wasn't injected (or saved as a variable!) + if ( m_actionBean == null ) + { + throw new JspException( "Can't find WikiActionBean in page or request context. Make sure JSP saves it as a variable." ); + } - if( m_wikiContext == null ) + // If this is a WikiContext-style ActionBean, get the page (WikiInterceptor should have set it) + m_page = null; + if ( m_actionBean instanceof WikiContext ) { - throw new JspException("WikiContext may not be NULL - serious internal problem!"); + m_page = ((WikiContext)m_actionBean).getPage(); + if ( m_page == null ) + { + throw new JspException( "WikiContext has a null WikiPage. This should not happen, and probably indicates a bug in JSPWiki's core classes!" ); + } } return doWikiStartTag(); @@ -106,6 +154,15 @@ { return EVAL_PAGE; } + + public int doAfterBody() throws JspException { + return SKIP_BODY; + } + + public String getId() + { + return m_id; + } public void doCatch(Throwable arg0) throws Throwable { @@ -113,12 +170,18 @@ public void doFinally() { - m_wikiContext = null; + m_actionBean = null; + m_id = null; + m_page = null; } - public void setId(String id) + /** + * Sets the ID for this tag. Note that the ID is sanitized using [EMAIL PROTECTED] com.ecyrd.jspwiki.TextUtil#replaceEntities(String)}. + * @param id the id for this tag + */ + public void setId( String id ) { - super.setId( TextUtil.replaceEntities( id ) ); - } - + m_id = ( TextUtil.replaceEntities( id ) ); + } + }
