jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r722756 - in /incubator/jspwiki/trunk: doc/ etc/ lib/ src/com/ecyrd/jspwiki/ src/com/ecyrd/jspwiki/action/
Date Wed, 03 Dec 2008 04:26:49 GMT
Author: ajaquith
Date: Tue Dec  2 20:26:47 2008
New Revision: 722756

URL: http://svn.apache.org/viewvc?rev=722756&view=rev
Log:
Checked in the Stripes code (about 220 classes, tests, JSPs and other files. All code compiles clean, but the JSPs do NOT work at the moment. Unit tests run clean except for some stray failing Stripes-related unit tests. See the file doc/README - Stripes Migration for some (repeat, SOME) details of what it all means. I'll sort out the JSP issues later this week.

Added:
    incubator/jspwiki/trunk/doc/README - Stripes Migration
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/doc/README - Stripes Migration
    incubator/jspwiki/trunk/doc/Stripes R3 Notes
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/doc/Stripes R3 Notes
    incubator/jspwiki/trunk/etc/commons-logging.properties
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/etc/commons-logging.properties
    incubator/jspwiki/trunk/etc/stripes.tld
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/etc/stripes.tld
    incubator/jspwiki/trunk/lib/commons-logging.jar
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/lib/commons-logging.jar
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/
      - copied from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/AbstractActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/AbstractActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/AdministerProfilesActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/AdministerProfilesActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/AttachActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/AttachActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/CommentActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/CommentActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/DefaultWikiContext.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/DefaultWikiContext.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/DeleteActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/DeleteActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/EditActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/EditActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/ErrorActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/ErrorActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/GroupActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/GroupActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/GroupTypeConverter.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/GroupTypeConverter.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/HandlerInfo.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/HandlerInfo.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/HandlerPermission.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/HandlerPermission.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/InstallActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/InstallActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/LoginActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/LoginActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/MessageActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/MessageActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/NewBlogEntryActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/NewBlogEntryActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/NewPageActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/NewPageActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/NoneActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/NoneActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/PageInfoActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/PageInfoActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/PageModifiedActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/PageModifiedActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/PrincipalTypeConverter.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/PrincipalTypeConverter.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/RSSActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/RSSActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/RenameActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/RenameActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/SearchActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/SearchActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UploadActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UploadActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserPreferencesActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/ViewActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/ViewActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/WikiActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/WikiActionBeanContext.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiActionBeanContext.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/WikiContextFactory.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiContextFactory.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/WikiExceptionHandler.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiExceptionHandler.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/WikiInterceptor.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiInterceptor.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/WikiPageTypeConverter.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiPageTypeConverter.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/WikiRequestContext.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiRequestContext.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/WikiRuntimeConfiguration.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiRuntimeConfiguration.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/WorkflowActionBean.java
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WorkflowActionBean.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/action/package.html
      - copied unchanged from r722372, incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/package.html
Modified:
    incubator/jspwiki/trunk/etc/log4j.properties
    incubator/jspwiki/trunk/etc/web.xml   (contents, props changed)
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java   (contents, props changed)
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java   (contents, props changed)
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiPage.java   (contents, props changed)

Modified: incubator/jspwiki/trunk/etc/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/log4j.properties?rev=722756&r1=722755&r2=722756&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/log4j.properties (original)
+++ incubator/jspwiki/trunk/etc/log4j.properties Tue Dec  2 20:26:47 2008
@@ -75,3 +75,11 @@
 #log4j.appender.SpamAppender.File = @spamlog@
 #log4j.appender.SpamAppender.layout = org.apache.log4j.PatternLayout
 #log4j.appender.SpamAppender.layout.ConversionPattern=%d{ISO8601} %m%n
+
+# Enable this if you want to debug the Stripes framework
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.rootLogger=INFO, stdout
+log4j.logger.net.sourceforge.stripes=DEBUG

Modified: incubator/jspwiki/trunk/etc/web.xml
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/web.xml?rev=722756&r1=722755&r2=722756&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/web.xml (original)
+++ incubator/jspwiki/trunk/etc/web.xml Tue Dec  2 20:26:47 2008
@@ -41,10 +41,68 @@
       <filter-name>WikiServletFilter</filter-name>
       <filter-class>com.ecyrd.jspwiki.ui.WikiServletFilter</filter-class>
    </filter>
+   
+   <!-- Configuration of the Stripes Filter. The Stripes MVC framework provides
+         essential request routing, form processing and type conversion services
+         for JSPWiki. -->
+   <filter>
+      <description>
+         Configures the Stripes framework.
+      </description>
+      <display-name>Stripes Filter</display-name>
+      <filter-name>StripesFilter</filter-name>
+      <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
+      <!-- Look for ActionBean implementations in the JSPWiki "action" package.
+           If you have custom WikiActionBeans you want JSPWiki to use, specify them
+           here (comma-delimited). -->
+      <init-param>
+         <param-name>ActionResolver.Packages</param-name>
+         <param-value>com.ecyrd.jspwiki.action</param-value>
+      </init-param>
+      <!-- Tell Stripes to auto-discover custom extension classes from the "action"
+           package also. Extensions JSPWiki uses includes WikiActionBeanContext,
+           WikiRuntimeConfiguration, WikiInterceptor and the various TypeConverter
+           implementations for JSPWiki-specific types. -->
+      <init-param>
+         <param-name>Extension.Packages</param-name>
+         <param-value>com.ecyrd.jspwiki.action</param-value>
+      </init-param>
+      <!-- We override Stripes' normal resource bundle to use ours instead. -->
+      <init-param>
+         <param-name>LocalizationBundleFactory.FieldNameBundle</param-name>
+         <param-value>templates.default</param-value>
+      </init-param>
+      <init-param>
+         <param-name>LocalizationBundleFactory.ErrorMessageBundle</param-name>
+         <param-value>templates.default</param-value>
+      </init-param>
+      <!-- Locales supported by this wiki -->
+      <init-param>
+         <param-name>LocalePicker.Locales</param-name>
+         <param-value>en:UTF8,de:UTF8,es:UTF8,fi:UTF8,it:UTF8,ln:UTF8,zh_CN:UTF8,</param-value>
+      </init-param>
+      <!-- Library for parsing multi-part file uploads -->
+      <init-param>
+        <param-name>MultipartWrapper.Class</param-name>
+        <param-value>net.sourceforge.stripes.controller.multipart.CommonsMultipartWrapper</param-value>
+      </init-param>
+      <!-- Exception handler classes -->
+      <init-param>
+        <param-name>ExceptionHandler.Class</param-name>
+        <param-value>com.ecyrd.jspwiki.action.WikiExceptionHandler</param-value>
+      </init-param>
+   </filter>
+
+   <!--
+      This is new in 2.4.  This defines a servlet filter which filters all requests. 
+   -->
+
+   <!--
    <filter>
       <filter-name>WikiJSPFilter</filter-name>
       <filter-class>com.ecyrd.jspwiki.ui.WikiJSPFilter</filter-class>
    </filter>
+   -->
 
    <filter-mapping>
        <filter-name>WikiServletFilter</filter-name>
@@ -70,6 +128,19 @@
        <filter-name>WikiServletFilter</filter-name>
        <url-pattern>/JSON-RPC</url-pattern>
    </filter-mapping> 
+    <filter-mapping>
+        <filter-name>StripesFilter</filter-name>
+        <url-pattern>*.jsp</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+    </filter-mapping>
+
+    <filter-mapping>
+        <filter-name>StripesFilter</filter-name>
+        <servlet-name>StripesDispatcher</servlet-name>
+        <dispatcher>REQUEST</dispatcher>
+    </filter-mapping>
+
+   <!--
    <filter-mapping>
        <filter-name>WikiJSPFilter</filter-name>
        <url-pattern>/wiki/*</url-pattern>
@@ -78,7 +149,8 @@
        <filter-name>WikiJSPFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
-   
+   -->
+
    <!--
        HttpSessionListener used for managing WikiSession's.
      -->
@@ -86,6 +158,15 @@
       <listener-class>com.ecyrd.jspwiki.auth.SessionMonitor</listener-class>
    </listener>
    
+    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <!--         Configuration of the Stripes dispatcher Servlet.            -->
+    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+    <servlet>
+        <servlet-name>StripesDispatcher</servlet-name>
+        <servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+
    <!--
        Now, let's define the XML-RPC interfaces.  You probably don't have to
        touch these.
@@ -139,8 +220,10 @@
    <!-- Maps short URLS to JSPs; also, detects webapp shutdown. -->
    <servlet>
        <servlet-name>WikiServlet</servlet-name>
-       <servlet-class>com.ecyrd.jspwiki.WikiServlet</servlet-class>       
+       <servlet-class>com.ecyrd.jspwiki.WikiServlet</servlet-class>
+       <!--
        <load-on-startup>1</load-on-startup>
+       -->
    </servlet>
 
    <servlet>
@@ -157,6 +240,21 @@
        <servlet-class>com.ecyrd.jspwiki.attachment.AttachmentServlet</servlet-class>
    </servlet>
 
+    <servlet-mapping>
+        <servlet-name>StripesDispatcher</servlet-name>
+        <url-pattern>/dispatcher</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>StripesDispatcher</servlet-name>
+        <url-pattern>/action/*</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+        <servlet-name>StripesDispatcher</servlet-name>
+        <url-pattern>*.action</url-pattern>
+    </servlet-mapping>
+
    <!-- PLACEHOLDER FOR PRE-COMPILED JSP SERVLETS -->
 
    <!--
@@ -219,6 +317,22 @@
      <error-code>403</error-code>
      <location>/error/Forbidden.html</location>
    </error-page>
+   
+   <!-- Taglibs -->
+   <!--
+   <taglib>
+     <taglib-location>/WEB-INF/jstl-core.tld</taglib-location>
+     <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
+   </taglib>
+   <taglib>
+     <taglib-location>/WEB-INF/jstl-fmt.tld</taglib-location>
+     <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
+   </taglib>
+   -->
+   <taglib>
+     <taglib-location>/WEB-INF/stripes.tld</taglib-location>
+     <taglib-uri>http://stripes.sourceforge.net/stripes.tld</taglib-uri>
+   </taglib>
 
    <!--  REMOVE ME TO ENABLE JDBC DATABASE
    <resource-ref>

Propchange: incubator/jspwiki/trunk/etc/web.xml
            ('svn:eol-style' removed)

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java?rev=722756&r1=722755&r2=722756&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java Tue Dec  2 20:26:47 2008
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "17";
+    public static final String     BUILD         = "18";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java?rev=722756&r1=722755&r2=722756&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java Tue Dec  2 20:26:47 2008
@@ -20,27 +20,13 @@
  */
 package com.ecyrd.jspwiki;
 
-import java.io.IOException;
-import java.security.Permission;
 import java.security.Principal;
-import java.text.MessageFormat;
-import java.util.*;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.servlet.jsp.PageContext;
-
-import com.ecyrd.jspwiki.log.Logger;
-import com.ecyrd.jspwiki.log.LoggerFactory;
-
-import com.ecyrd.jspwiki.auth.*;
-import com.ecyrd.jspwiki.auth.permissions.AllPermission;
-import com.ecyrd.jspwiki.auth.user.UserDatabase;
-import com.ecyrd.jspwiki.i18n.InternationalizationManager;
-import com.ecyrd.jspwiki.tags.WikiTagBase;
-import com.ecyrd.jspwiki.ui.*;
-import com.ecyrd.jspwiki.preferences.Preferences;
+
+import com.ecyrd.jspwiki.action.*;
 
 /**
  *  <p>Provides state information throughout the processing of a page.  A
@@ -66,230 +52,92 @@
  *
  *  @author Andrew R. Jaquith
  */
-public class WikiContext
-    implements Cloneable, Command
+public interface WikiContext
+    extends Cloneable
 {
-    private    Command m_command = null;
-
-    private    WikiPage   m_page;
-    private    WikiPage   m_realPage;
-    private    WikiEngine m_engine;
-    private    String     m_template = "default";
-
-    private    HashMap<String,Object> m_variableMap = new HashMap<String,Object>();
-
-    /**
-     *  Stores the HttpServletRequest.  May be null, if the request did not
-     *  come from a servlet.
-     */
-    protected  HttpServletRequest m_request = null;
-
-    private    WikiSession m_session = null;
-
     /** User is administering JSPWiki (Install, SecurityConfig). */
-    public static final String    INSTALL  = WikiCommand.INSTALL.getRequestContext();
+    public static final String    INSTALL  = HandlerInfo.getHandlerInfo( InstallActionBean.class, "install" ).getRequestContext();
 
     /** The VIEW context - the user just wants to view the page
         contents. */
-    public static final String    VIEW     = PageCommand.VIEW.getRequestContext();
+    public static final String    VIEW     = HandlerInfo.getHandlerInfo( ViewActionBean.class, "view" ).getRequestContext();
 
     /** User wants to view or administer workflows. */
-    public static final String    WORKFLOW = WikiCommand.WORKFLOW.getRequestContext();
+    public static final String    WORKFLOW = HandlerInfo.getHandlerInfo( WorkflowActionBean.class, "view" ).getRequestContext();
 
     /** The EDIT context - the user is editing the page. */
-    public static final String    EDIT     = PageCommand.EDIT.getRequestContext();
+    public static final String    EDIT     = HandlerInfo.getHandlerInfo( EditActionBean.class, "edit" ).getRequestContext();
 
     /** User is preparing for a login/authentication. */
-    public static final String    LOGIN    = WikiCommand.LOGIN.getRequestContext();
+    public static final String    LOGIN    = HandlerInfo.getHandlerInfo( LoginActionBean.class, "login" ).getRequestContext();
 
     /** User is preparing to log out. */
-    public static final String    LOGOUT   = WikiCommand.LOGOUT.getRequestContext();
+    public static final String    LOGOUT   = HandlerInfo.getHandlerInfo( LoginActionBean.class, "logout" ).getRequestContext();
 
     /** JSPWiki wants to display a message. */
-    public static final String    MESSAGE  = WikiCommand.MESSAGE.getRequestContext();
+    public static final String    MESSAGE  = HandlerInfo.getHandlerInfo( MessageActionBean.class, "message" ).getRequestContext();
 
     /** User is viewing a DIFF between the two versions of the page. */
-    public static final String    DIFF     = PageCommand.DIFF.getRequestContext();
+    public static final String    DIFF     = HandlerInfo.getHandlerInfo( EditActionBean.class, "diff" ).getRequestContext();
 
     /** User is viewing page history. */
-    public static final String    INFO     = PageCommand.INFO.getRequestContext();
+    public static final String    INFO     = HandlerInfo.getHandlerInfo( PageInfoActionBean.class, "info" ).getRequestContext();
 
     /** User is previewing the changes he just made. */
-    public static final String    PREVIEW  = PageCommand.PREVIEW.getRequestContext();
+    public static final String    PREVIEW  = HandlerInfo.getHandlerInfo( EditActionBean.class, "preview" ).getRequestContext();
 
     /** User has an internal conflict, and does quite not know what to
         do. Please provide some counseling. */
-    public static final String    CONFLICT = PageCommand.CONFLICT.getRequestContext();
+    public static final String    CONFLICT = HandlerInfo.getHandlerInfo( PageModifiedActionBean.class, "conflict" ).getRequestContext();
 
     /** An error has been encountered and the user needs to be informed. */
-    public static final String    ERROR    = WikiCommand.ERROR.getRequestContext();
+    public static final String    ERROR    = HandlerInfo.getHandlerInfo( ErrorActionBean.class, "error" ).getRequestContext();
 
     /** User is uploading something. */
-    public static final String    UPLOAD   = PageCommand.UPLOAD.getRequestContext();
+    public static final String    UPLOAD   = HandlerInfo.getHandlerInfo( UploadActionBean.class, "upload" ).getRequestContext();
 
     /** User is commenting something. */
-    public static final String    COMMENT  = PageCommand.COMMENT.getRequestContext();
+    public static final String    COMMENT  = HandlerInfo.getHandlerInfo( CommentActionBean.class, "comment" ).getRequestContext();
 
     /** User is searching for content. */
-    public static final String    FIND     = WikiCommand.FIND.getRequestContext();
+    public static final String    FIND     = HandlerInfo.getHandlerInfo( SearchActionBean.class, "find" ).getRequestContext();
 
     /** User wishes to create a new group */
-    public static final String    CREATE_GROUP = WikiCommand.CREATE_GROUP.getRequestContext();
+    public static final String    CREATE_GROUP = HandlerInfo.getHandlerInfo( GroupActionBean.class, "create" ).getRequestContext();
 
     /** User is deleting an existing group. */
-    public static final String    DELETE_GROUP = GroupCommand.DELETE_GROUP.getRequestContext();
+    public static final String    DELETE_GROUP = HandlerInfo.getHandlerInfo( GroupActionBean.class, "delete" ).getRequestContext();
 
     /** User is editing an existing group. */
-    public static final String    EDIT_GROUP = GroupCommand.EDIT_GROUP.getRequestContext();
+    public static final String    EDIT_GROUP = HandlerInfo.getHandlerInfo( GroupActionBean.class, "save" ).getRequestContext();
 
     /** User is viewing an existing group */
-    public static final String    VIEW_GROUP = GroupCommand.VIEW_GROUP.getRequestContext();
+    public static final String    VIEW_GROUP = HandlerInfo.getHandlerInfo( GroupActionBean.class, "view" ).getRequestContext();
 
     /** User is editing preferences */
-    public static final String    PREFS    = WikiCommand.PREFS.getRequestContext();
+    public static final String    PREFS    = HandlerInfo.getHandlerInfo( UserPreferencesActionBean.class, "createAssertedName" ).getRequestContext();
 
     /** User is renaming a page. */
-    public static final String    RENAME   = PageCommand.RENAME.getRequestContext();
+    public static final String    RENAME   = HandlerInfo.getHandlerInfo( RenameActionBean.class, "rename" ).getRequestContext();
 
     /** User is deleting a page or an attachment. */
-    public static final String    DELETE   = PageCommand.DELETE.getRequestContext();
+    public static final String    DELETE   = HandlerInfo.getHandlerInfo( DeleteActionBean.class, "delete" ).getRequestContext();
 
     /** User is downloading an attachment. */
-    public static final String    ATTACH   = PageCommand.ATTACH.getRequestContext();
+    public static final String    ATTACH   = HandlerInfo.getHandlerInfo( AttachActionBean.class, "upload" ).getRequestContext();
 
     /** RSS feed is being generated. */
-    public static final String    RSS      = PageCommand.RSS.getRequestContext();
+    public static final String    RSS      = HandlerInfo.getHandlerInfo( RSSActionBean.class, "rss" ).getRequestContext();
 
     /** This is not a JSPWiki context, use it to access static files. */
-    public static final String    NONE     = PageCommand.NONE.getRequestContext();
+    public static final String    NONE     = "none";  
 
     /** Same as NONE; this is just a clarification. */
-    public static final String    OTHER    = PageCommand.OTHER.getRequestContext();
+    public static final String    OTHER    = "other";
 
     /** User is doing administrative things. */
-    public static final String    ADMIN    = WikiCommand.ADMIN.getRequestContext();
-
-    private static final Logger   log      = LoggerFactory.getLogger( WikiContext.class );
-
-    private static final Permission DUMMY_PERMISSION  = new java.util.PropertyPermission( "os.name", "read" );
-
-    /**
-     *  Create a new WikiContext for the given WikiPage. Delegates to
-     * {@link #WikiContext(WikiEngine, HttpServletRequest, WikiPage)}.
-     *  @param engine The WikiEngine that is handling the request.
-     *  @param page   The WikiPage.  If you want to create a
-     *  WikiContext for an older version of a page, you must use this
-     *  constructor.
-     */
-    public WikiContext( WikiEngine engine, WikiPage page )
-    {
-        this( engine, null, findCommand( engine, null, page ) );
-    }
-
-    /**
-     * <p>
-     * Creates a new WikiContext for the given WikiEngine, Command and
-     * HttpServletRequest.
-     * </p>
-     * <p>
-     * This constructor will also look up the HttpSession associated with the
-     * request, and determine if a WikiSession object is present. If not, a new
-     * one is created.
-     * </p>
-     * @param engine The WikiEngine that is handling the request
-     * @param request The HttpServletRequest that should be associated with this
-     *            context. This parameter may be <code>null</code>.
-     * @param command the command
-     * @throws IllegalArgumentException if <code>engine</code> or
-     *             <code>command</code> are <code>null</code>
-     */
-    public WikiContext( WikiEngine engine, HttpServletRequest request, Command command )
-        throws IllegalArgumentException
-    {
-        super();
-        if ( engine == null || command == null )
-        {
-            throw new IllegalArgumentException( "Parameter engine and command must not be null." );
-        }
-
-        m_engine = engine;
-        m_request = request;
-        m_session = WikiSession.getWikiSession( engine, request );
-        m_command = command;
-
-        // If PageCommand, get the WikiPage
-        if( command instanceof PageCommand )
-        {
-            m_page = (WikiPage)((PageCommand)command).getTarget();
-        }
-
-        // If page not supplied, default to front page to avoid NPEs
-        if( m_page == null )
-        {
-            m_page = m_engine.getPage( m_engine.getFrontPage() );
-
-            // Front page does not exist?
-            if( m_page == null )
-            {
-                m_page = new WikiPage( m_engine, m_engine.getFrontPage() );
-            }
-        }
-
-        m_realPage = m_page;
-
-        // Special case: retarget any empty 'view' PageCommands to the front page
-        if ( PageCommand.VIEW.equals( command ) && command.getTarget() == null )
-        {
-            m_command = command.targetedCommand( m_page );
-        }
-
-        // Debugging...
-        if( log.isDebugEnabled() )
-        {
-            HttpSession session = ( request == null ) ? null : request.getSession( false );
-            String sid = ( session == null ) ? "(null)" : session.getId();
-            log.debug( "Creating WikiContext for session ID=" + sid + "; target=" + getName() );
-        }
-
-        // Figure out what template to use
-        setDefaultTemplate( request );
-    }
-
-    /**
-     * Creates a new WikiContext for the given WikiEngine, WikiPage and
-     * HttpServletRequest. This method simply looks up the appropriate Command
-     * using {@link #findCommand(WikiEngine, HttpServletRequest, WikiPage)} and
-     * delegates to
-     * {@link #WikiContext(WikiEngine, HttpServletRequest, Command)}.
-     * @param engine The WikiEngine that is handling the request
-     * @param request The HttpServletRequest that should be associated with this
-     *            context. This parameter may be <code>null</code>.
-     * @param page The WikiPage. If you want to create a WikiContext for an
-     *            older version of a page, you must supply this parameter
-     */
-    public WikiContext(WikiEngine engine, HttpServletRequest request, WikiPage page)
-    {
-        this( engine, request, findCommand( engine, request, page ) );
-    }
-
-    /**
-     * {@inheritDoc}
-     * @see com.ecyrd.jspwiki.ui.Command#getContentTemplate()
-     */
-    public String getContentTemplate()
-    {
-        return m_command.getContentTemplate();
-    }
-
-    /**
-     * {@inheritDoc}
-     * @see com.ecyrd.jspwiki.ui.Command#getJSP()
-     */
-    public String getJSP()
-    {
-        return m_command.getContentTemplate();
-    }
-
+    public static final String    ADMIN    = "admin";
+ 
     /**
      *  Sets a reference to the real page whose content is currently being
      *  rendered.
@@ -309,13 +157,7 @@
      *  @since 2.3.14
      *  @see com.ecyrd.jspwiki.tags.InsertPageTag
      */
-    public WikiPage setRealPage( WikiPage page )
-    {
-        WikiPage old = m_realPage;
-        m_realPage = page;
-        updateCommand( m_command.getRequestContext() );
-        return old;
-    }
+    public WikiPage setRealPage( WikiPage page );
 
     /**
      *  Gets a reference to the real page whose content is currently being rendered.
@@ -334,63 +176,21 @@
      *  @see com.ecyrd.jspwiki.tags.InsertPageTag
      *  @see com.ecyrd.jspwiki.parser.JSPWikiMarkupParser
      */
-    public WikiPage getRealPage()
-    {
-        return m_realPage;
-    }
-
-    /**
-     *  Figure out to which page we are really going to.  Considers
-     *  special page names from the jspwiki.properties, and possible aliases.
-     *  This method forwards requests to
-     *  {@link com.ecyrd.jspwiki.ui.CommandResolver#getSpecialPageReference(String)}.
-     *  @return A complete URL to the new page to redirect to
-     *  @since 2.2
-     */
-
-    public String getRedirectURL()
-    {
-        String pagename = m_page.getName();
-        String redirURL = null;
-
-        redirURL = m_engine.getCommandResolver().getSpecialPageReference( pagename );
-
-        if( redirURL == null )
-        {
-            String alias = (String)m_page.getAttribute( WikiPage.ALIAS );
-
-            if( alias != null )
-            {
-                redirURL = getViewURL( alias );
-            }
-            else
-            {
-                redirURL = (String)m_page.getAttribute( WikiPage.REDIRECT );
-            }
-        }
-
-        return redirURL;
-    }
+    public WikiPage getRealPage();
 
     /**
      *  Returns the handling engine.
      *
      *  @return The wikiengine owning this context.
      */
-    public WikiEngine getEngine()
-    {
-        return m_engine;
-    }
+    public WikiEngine getEngine();
 
     /**
      *  Returns the page that is being handled.
      *
      *  @return the page which was fetched.
      */
-    public WikiPage getPage()
-    {
-        return m_page;
-    }
+    public WikiPage getPage();
 
     /**
      *  Sets the page that is being handled.
@@ -398,20 +198,13 @@
      *  @param page The wikipage
      *  @since 2.1.37.
      */
-    public void setPage( WikiPage page )
-    {
-        m_page = page;
-        updateCommand( m_command.getRequestContext() );
-    }
+    public void setPage( WikiPage page );
 
     /**
      *  Returns the request context.
      *  @return The name of the request context (e.g. VIEW).
      */
-    public String getRequestContext()
-    {
-        return m_command.getRequestContext();
-    }
+    public String getRequestContext();
 
     /**
      *  Sets the request context.  See above for the different
@@ -419,28 +212,7 @@
      *
      *  @param arg The request context (one of the predefined contexts.)
      */
-    public void setRequestContext( String arg )
-    {
-        updateCommand( arg );
-    }
-
-    /**
-     * {@inheritDoc}
-     * @see com.ecyrd.jspwiki.ui.Command#getTarget()
-     */
-    public Object getTarget()
-    {
-        return m_command.getTarget();
-    }
-
-    /**
-     * {@inheritDoc}
-     * @see com.ecyrd.jspwiki.ui.Command#getURLPattern()
-     */
-    public String getURLPattern()
-    {
-        return m_command.getURLPattern();
-    }
+    public void setRequestContext( String arg );
 
     /**
      *  Gets a previously set variable.
@@ -448,10 +220,7 @@
      *  @param key The variable name.
      *  @return The variable contents.
      */
-    public Object getVariable( String key )
-    {
-        return m_variableMap.get( key );
-    }
+    public Object getVariable( String key );
 
     /**
      *  Sets a variable.  The variable is valid while the WikiContext is valid,
@@ -461,11 +230,7 @@
      *  @param key The variable name.
      *  @param data The variable value.
      */
-    public void setVariable( String key, Object data )
-    {
-        m_variableMap.put( key, data );
-        updateCommand( m_command.getRequestContext() );
-    }
+    public void setVariable( String key, Object data );
 
     /**
      *  This method will safely return any HTTP parameters that
@@ -478,17 +243,7 @@
      *  @param paramName Parameter name to look for.
      *  @return HTTP parameter, or null, if no such parameter existed.
      */
-    public String getHttpParameter( String paramName )
-    {
-        String result = null;
-
-        if( m_request != null )
-        {
-            result = m_request.getParameter( paramName );
-        }
-
-        return result;
-    }
+    public String getHttpParameter( String paramName );
 
     /**
      *  If the request did originate from a HTTP request,
@@ -499,10 +254,7 @@
      *  @return Null, if no HTTP request was done.
      *  @since 2.0.13.
      */
-    public HttpServletRequest getHttpRequest()
-    {
-        return m_request;
-    }
+    public HttpServletRequest getHttpRequest();
 
     /**
      *  Sets the template to be used for this request.
@@ -510,42 +262,14 @@
      *  @param dir The template name
      *  @since 2.1.15.
      */
-    public void setTemplate( String dir )
-    {
-        m_template = dir;
-    }
-
-    /**
-     * Returns the target of this wiki context: a page, group name or JSP. If
-     * the associated Command is a PageCommand, this method returns the page's
-     * name. Otherwise, this method delegates to the associated Command's
-     * {@link com.ecyrd.jspwiki.ui.Command#getName()} method. Calling classes
-     * can rely on the results of this method for looking up canonically-correct
-     * page or group names. Because it does not automatically assume that the
-     * wiki context is a PageCommand, calling this method is inherently safer
-     * than calling <code>getPage().getName()</code>.
-     * @return the name of the target of this wiki context
-     * @see com.ecyrd.jspwiki.ui.PageCommand#getName()
-     * @see com.ecyrd.jspwiki.ui.GroupCommand#getName()
-     */
-    public String getName()
-    {
-        if ( m_command instanceof PageCommand )
-        {
-            return m_page != null ? m_page.getName() : "<no page>";
-        }
-        return m_command.getName();
-    }
+    public void setTemplate( String dir );
 
     /**
      *  Gets the template that is to be used throughout this request.
      *  @since 2.1.15.
      *  @return template name
      */
-    public String getTemplate()
-    {
-        return m_template;
-    }
+    public String getTemplate();
 
     /**
      *  Convenience method that gets the current user. Delegates the
@@ -556,15 +280,7 @@
      *
      *  @return The current user; or maybe null in case of internal calls.
      */
-    public Principal getCurrentUser()
-    {
-        if (m_session == null)
-        {
-            // This shouldn't happen, really...
-            return WikiPrincipal.GUEST;
-        }
-        return m_session.getUserPrincipal();
-    }
+    public Principal getCurrentUser();
 
     /**
      *  A shortcut to generate a VIEW url.
@@ -572,10 +288,7 @@
      *  @param page The page to which to link.
      *  @return An URL to the page.  This honours the current absolute/relative setting.
      */
-    public String getViewURL( String page )
-    {
-        return getURL( VIEW, page, null );
-    }
+    public String getViewURL( String page );
 
     /**
      *  Creates an URL for the given request context.
@@ -585,10 +298,7 @@
      *  @return An URL to the page, honours the absolute/relative setting in jspwiki.properties
      */
     public String getURL( String context,
-                          String page )
-    {
-        return getURL( context, page, null );
-    }
+                          String page );
 
     /**
      *  Returns an URL from a page. It this WikiContext instance was constructed
@@ -603,56 +313,15 @@
      */
     public String getURL( String context,
                           String page,
-                          String params )
-    {
-        boolean absolute = "absolute".equals(m_engine.getVariable( this, WikiEngine.PROP_REFSTYLE ));
-
-        // FIXME: is rather slow
-        return m_engine.getURL( context,
-                                page,
-                                params,
-                                absolute );
-
-    }
-
-    /**
-     * Returns the Command associated with this WikiContext.
-     * @return the command
-     */
-    public Command getCommand()
-    {
-        return m_command;
-    }
-
+                          String params );
+    
     /**
      *  Returns a shallow clone of the WikiContext.
      *
      *  @since 2.1.37.
      *  @return A shallow clone of the WikiContext
      */
-    public Object clone()
-    {
-        try
-        {
-            // super.clone() must always be called to make sure that inherited objects
-            // get the right type
-            WikiContext copy = (WikiContext)super.clone();
-
-            copy.m_engine = m_engine;
-            copy.m_command = m_command;
-
-            copy.m_template       = m_template;
-            copy.m_variableMap    = m_variableMap;
-            copy.m_request        = m_request;
-            copy.m_session        = m_session;
-            copy.m_page           = m_page;
-            copy.m_realPage       = m_realPage;
-            return copy;
-        }
-        catch( CloneNotSupportedException e ){} // Never happens
-
-        return null;
-    }
+    public Object clone();
 
     /**
      *  Creates a deep clone of the WikiContext.  This is useful when you want
@@ -661,30 +330,7 @@
      *  @since  2.8.0
      *  @return A deep clone of the WikiContext.
      */
-    public WikiContext deepClone()
-    {
-        try
-        {
-            // super.clone() must always be called to make sure that inherited objects
-            // get the right type
-            WikiContext copy = (WikiContext)super.clone();
-
-            //  No need to deep clone these
-            copy.m_engine  = m_engine;
-            copy.m_command = m_command; // Static structure
-
-            copy.m_template       = m_template;
-            copy.m_variableMap    = (HashMap<String,Object>)m_variableMap.clone();
-            copy.m_request        = m_request;
-            copy.m_session        = m_session;
-            copy.m_page           = (WikiPage)m_page.clone();
-            copy.m_realPage       = (WikiPage)m_realPage.clone();
-            return copy;
-        }
-        catch( CloneNotSupportedException e ){} // Never happens
-
-        return null;
-    }
+    public WikiContext deepClone();
     
     /**
      *  Returns the WikiSession associated with the context.
@@ -694,163 +340,7 @@
      *
      *  @return The WikiSession associate with this context.
      */
-    public WikiSession getWikiSession()
-    {
-        return m_session;
-    }
-
-    /**
-     *  This method can be used to find the WikiContext programmatically
-     *  from a JSP PageContext. We check the request context. 
-     *  The wiki context, if it exists,
-     *  is looked up using the key
-     *  {@link com.ecyrd.jspwiki.tags.WikiTagBase#ATTR_CONTEXT}.
-     *
-     *  @since 2.4
-     *  @param pageContext the JSP page context
-     *  @return Current WikiContext, or null, of no context exists.
-     */
-    public static WikiContext findContext( PageContext pageContext )
-    {
-        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
-        WikiContext context = (WikiContext)request.getAttribute( WikiTagBase.ATTR_CONTEXT );
-        return context;
-    }
-
-    /**
-     * Returns the permission required to successfully execute this context.
-     * For example, the a wiki context of VIEW for a certain page means that
-     * the PagePermission "view" is required for the page. In some cases, no
-     * particular permission is required, in which case a dummy permission will
-     * be returned ({@link java.util.PropertyPermission}<code> "os.name",
-     * "read"</code>). This method is guaranteed to always return a valid,
-     * non-null permission.
-     * @return the permission
-     * @since 2.4
-     */
-    public Permission requiredPermission()
-    {
-        // This is a filthy rotten hack -- absolutely putrid
-        if ( WikiCommand.INSTALL.equals( m_command ) )
-        {
-            // See if admin users exists
-            boolean adminExists = false;
-            try
-            {
-                UserManager userMgr = m_engine.getUserManager();
-                UserDatabase userDb = userMgr.getUserDatabase();
-                userDb.findByLoginName( Installer.ADMIN_ID );
-                adminExists = true;
-            }
-            catch ( NoSuchPrincipalException e )
-            {
-                return DUMMY_PERMISSION;
-            }
-            if ( adminExists )
-            {
-                return new AllPermission( m_engine.getApplicationName() );
-            }
-        }
-
-        // TODO: we should really break the contract so that this
-        // method returns null, but until then we will use this hack
-        if ( m_command.requiredPermission() == null )
-        {
-            return DUMMY_PERMISSION;
-        }
-
-        return m_command.requiredPermission();
-    }
-
-    /**
-     * Associates a target with the current Command and returns
-     * the new targeted Command. If the Command associated with this
-     * WikiContext is already "targeted", it is returned instead.
-     * @see com.ecyrd.jspwiki.ui.Command#targetedCommand(java.lang.Object)
-     *
-     * {@inheritDoc}
-     */
-    public Command targetedCommand( Object target )
-    {
-        if ( m_command.getTarget() == null )
-        {
-            return m_command.targetedCommand( target );
-        }
-        return m_command;
-    }
-
-    /**
-     * Checks whether the current user has access to this wiki context,
-     * by obtaining the required Permission ({@link #requiredPermission()})
-     * and delegating the access check to
-     * {@link com.ecyrd.jspwiki.auth.AuthorizationManager#checkPermission(WikiSession, Permission)}.
-     * If the user is allowed, this method returns <code>true</code>;
-     * <code>false</code> otherwise. If access is allowed,
-     * the wiki context will be added to the request as an attribute
-     * with the key name {@link com.ecyrd.jspwiki.tags.WikiTagBase#ATTR_CONTEXT}.
-     * Note that this method will automatically redirect the user to
-     * a login or error page, as appropriate, if access fails. This is
-     * NOT guaranteed to be default behavior in the future.
-     * @param response the http response
-     * @return the result of the access check
-     * @throws IOException In case something goes wrong
-     */
-    public boolean hasAccess( HttpServletResponse response ) throws IOException
-    {
-        return hasAccess( response, true );
-    }
-
-    /**
-     * Checks whether the current user has access to this wiki context (and
-     * optionally redirects if not), by obtaining the required Permission ({@link #requiredPermission()})
-     * and delegating the access check to
-     * {@link com.ecyrd.jspwiki.auth.AuthorizationManager#checkPermission(WikiSession, Permission)}.
-     * If the user is allowed, this method returns <code>true</code>;
-     * <code>false</code> otherwise. If access is allowed,
-     * the wiki context will be added to the request as attribute
-     * with the key name {@link com.ecyrd.jspwiki.tags.WikiTagBase#ATTR_CONTEXT}.
-     * @return the result of the access check
-     * @param response The servlet response object
-     * @param redirect If true, makes an automatic redirect to the response
-     * @throws IOException If something goes wrong
-     */
-    public boolean hasAccess( HttpServletResponse response, boolean redirect ) throws IOException
-    {
-        AuthorizationManager mgr = m_engine.getAuthorizationManager();
-        boolean allowed = mgr.checkPermission( m_session, requiredPermission() );
-        ResourceBundle rb = getBundle(InternationalizationManager.CORE_BUNDLE);
-
-        // Stash the wiki context
-        if( allowed )
-        {
-            if ( m_request != null && m_request.getAttribute( WikiTagBase.ATTR_CONTEXT ) == null )
-            {
-                m_request.setAttribute( WikiTagBase.ATTR_CONTEXT, this );
-            }
-        }
-
-        // If access not allowed, redirect
-        if( !allowed && redirect )
-        {
-            Principal currentUser  = m_session.getUserPrincipal();
-            Object[] arguments = { getName() };
-            if( m_session.isAuthenticated() )
-            {
-                log.info("User "+currentUser.getName()+" has no access - forbidden (permission=" + requiredPermission() + ")" );
-                String pageurl = m_page.getName();
-                m_session.addMessage( MessageFormat.format( rb.getString("security.error.noaccess.logged"), arguments) );
-                response.sendRedirect( m_engine.getURL(WikiContext.LOGIN, pageurl, null, false ) );
-            }
-            else
-            {
-                log.info("User "+currentUser.getName()+" has no access - redirecting (permission=" + requiredPermission() + ")");
-                String pageurl = m_page.getName();
-                m_session.addMessage( MessageFormat.format( rb.getString("security.error.noaccess"), arguments) );
-                response.sendRedirect( m_engine.getURL(WikiContext.LOGIN, pageurl, null, false ) );
-            }
-        }
-        return allowed;
-    }
+    public WikiSession getWikiSession();
 
     /**
      *  Returns true, if the current user has administrative permissions (i.e. the omnipotent
@@ -859,102 +349,7 @@
      *  @since 2.4.46
      *  @return true, if the user has all permissions.
      */
-    public boolean hasAdminPermissions()
-    {
-        boolean admin = false;
-
-        admin = m_engine.getAuthorizationManager().checkPermission( getWikiSession(),
-                                                                    new AllPermission(m_engine.getApplicationName()) );
-
-        return admin;
-    }
-
-    /**
-     * Figures out which template a new WikiContext should be using.
-     * @param request the HTTP request
-     */
-    protected void setDefaultTemplate( HttpServletRequest request )
-    {
-        // FIXME: Most definitely this should be checked for
-        //        existence, or else it is possible to create pages that
-        //        cannot be shown.
-        String defaultTemplate = m_engine.getTemplateDir();
-
-        //  Figure out which template we should be using for this page.
-        String template = null;
-        if ( request != null )
-        {
-            template = request.getParameter( "skin" );
-        }
-
-        // If request doesn't supply the value, extract from wiki page
-        if( template == null )
-        {
-            WikiPage page = getPage();
-            if ( page != null )
-            {
-                template = (String)page.getAttribute( WikiEngine.PROP_TEMPLATEDIR );
-            }
-
-        }
-
-        // If something over-wrote the default, set the new value.
-        if ( template != null )
-        {
-            setTemplate( template );
-        }
-        else
-        {
-            setTemplate( defaultTemplate );
-        }
-    }
-
-    /**
-     * Looks up and returns a PageCommand based on a supplied WikiPage and HTTP
-     * request. First, the appropriate Command is obtained by examining the HTTP
-     * request; the default is {@link PageCommand#VIEW}. If the Command is a
-     * PageCommand (and it should be, in most cases), a targeted Command is
-     * created using the (non-<code>null</code>) WikiPage as target.
-     * @param engine the wiki engine
-     * @param request the HTTP request
-     * @param page the wiki page
-     * @return the correct command
-     */
-    protected static Command findCommand( WikiEngine engine, HttpServletRequest request, WikiPage page )
-    {
-        String defaultContext = PageCommand.VIEW.getRequestContext();
-        Command command = engine.getCommandResolver().findCommand( request, defaultContext );
-        if ( command instanceof PageCommand && page != null )
-        {
-            command = command.targetedCommand( page );
-        }
-        return command;
-    }
-
-    /**
-     * Protected method that updates the internally cached Command.
-     * Will always be called when the page name, request context, or variable
-     * changes.
-     * @param requestContext the desired request context
-     * @since 2.4
-     */
-    protected void updateCommand( String requestContext )
-    {
-        if ( requestContext == null )
-        {
-            m_command = PageCommand.NONE;
-        }
-        else
-        {
-            CommandResolver resolver = m_engine.getCommandResolver();
-            m_command = resolver.findCommand( m_request, requestContext );
-        }
-
-        if ( m_command instanceof PageCommand && m_page != null )
-        {
-            m_command = m_command.targetedCommand( m_page );
-        }
-    }
+    public boolean hasAdminPermissions();
 
     /**
      *  Locates the i18n ResourceBundle given.  This method interprets
@@ -966,30 +361,6 @@
      *  @throws MissingResourceException If the bundle cannot be found
      */
     // FIXME: This method should really cache the ResourceBundles or something...
-    public ResourceBundle getBundle( String bundle ) throws MissingResourceException
-    {
-        Locale loc = Preferences.getLocale( this );
-       
-        ResourceBundle b = m_engine.getInternationalizationManager().getBundle(bundle, loc);
-
-        return b;
-    }
-
-    /**
-     *  Returns the locale of the HTTP request if available,
-     *  otherwise returns the default Locale of the server.
-     *
-     *  @return A valid locale object
-     *  @param context The WikiContext
-     */
-    public static Locale getLocale( WikiContext context )
-    {
-        return Preferences.getLocale( context );
-/*
-        HttpServletRequest request = context.getHttpRequest();
-        return ( request != null )
-                ? request.getLocale() : Locale.getDefault();
-*/
-    }
+    public ResourceBundle getBundle( String bundle ) throws MissingResourceException;
 
 }

Propchange: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java
            ('svn:eol-style' removed)

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java?rev=722756&r1=722755&r2=722756&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java Tue Dec  2 20:26:47 2008
@@ -32,12 +32,15 @@
 import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.lang.time.StopWatch;
 import com.ecyrd.jspwiki.log.Logger;
 import com.ecyrd.jspwiki.log.LoggerFactory;
 //import org.apache.log4j.PropertyConfigurator;
 
+import com.ecyrd.jspwiki.action.WikiActionBeanContext;
+import com.ecyrd.jspwiki.action.WikiContextFactory;
 import com.ecyrd.jspwiki.attachment.Attachment;
 import com.ecyrd.jspwiki.attachment.AttachmentManager;
 import com.ecyrd.jspwiki.auth.AuthenticationManager;
@@ -64,8 +67,6 @@
 import com.ecyrd.jspwiki.rss.RSSGenerator;
 import com.ecyrd.jspwiki.rss.RSSThread;
 import com.ecyrd.jspwiki.search.SearchManager;
-import com.ecyrd.jspwiki.ui.Command;
-import com.ecyrd.jspwiki.ui.CommandResolver;
 import com.ecyrd.jspwiki.ui.EditorManager;
 import com.ecyrd.jspwiki.ui.TemplateManager;
 import com.ecyrd.jspwiki.ui.admin.AdminBeanManager;
@@ -196,8 +197,8 @@
     /** Stores the ACL manager. */
     private AclManager       m_aclManager = null;
 
-    /** Resolves wiki actions, JSPs and special pages. */
-    private CommandResolver m_commandResolver = null;
+    /** Creates WikiContexts. */
+    private WikiContextFactory m_contextFactory = null;
 
     private TemplateManager  m_templateManager = null;
 
@@ -459,9 +460,6 @@
 
         log.debug("Configuring WikiEngine...");
 
-        //  Initializes the CommandResolver
-        m_commandResolver  = new CommandResolver( this, props );
-
         //
         //  Create and find the default working directory.
         //
@@ -522,6 +520,9 @@
         //        of a better way to do the startup-sequence.
         try
         {
+            //  Initialize the WikiContextFactory -- this MUST be done after setting the baseURL
+            m_contextFactory  = new WikiContextFactory( this, props );
+            
             Class urlclass = ClassUtil.findClass( "com.ecyrd.jspwiki.url",
                     TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor" ) );
             m_urlConstructor = (URLConstructor) urlclass.newInstance();
@@ -824,6 +825,7 @@
      * @since 2.0.3
      * @param pageName The name of the page.  May be null, in which case defaults to the front page.
      * @return An absolute URL to the page.
+     * @deprecated
      */
     public String getViewURL( String pageName )
     {
@@ -1050,7 +1052,7 @@
      *  <p>If the page is a special page, then returns a direct URL
      *  to that page.  Otherwise returns <code>null</code>.
      *  This method delegates requests to
-     *  {@link com.ecyrd.jspwiki.ui.CommandResolver#getSpecialPageReference(String)}.
+     *  {@link com.ecyrd.jspwiki.action.WikiContextFactory#getSpecialPageReference(String)}.
      *  </p>
      *  <p>
      *  Special pages are defined in jspwiki.properties using the jspwiki.specialPage
@@ -1063,7 +1065,7 @@
      */
     public String getSpecialPageReference( String original )
     {
-        return m_commandResolver.getSpecialPageReference( original );
+        return m_contextFactory.getSpecialPageReference( original );
     }
 
     /**
@@ -1149,7 +1151,7 @@
 
         try
         {
-            if( m_commandResolver.getSpecialPageReference(page) != null ) return true;
+            if( m_contextFactory.getSpecialPageReference(page) != null ) return true;
 
             if( getFinalPageName( page ) != null )
             {
@@ -1178,7 +1180,7 @@
     public boolean pageExists( String page, int version )
         throws ProviderException
     {
-        if( m_commandResolver.getSpecialPageReference(page) != null ) return true;
+        if( m_contextFactory.getSpecialPageReference(page) != null ) return true;
 
         String finalName = getFinalPageName( page );
 
@@ -1234,7 +1236,7 @@
      *  Returns the correct page name, or null, if no such
      *  page can be found.  Aliases are considered. This
      *  method simply delegates to
-     *  {@link com.ecyrd.jspwiki.ui.CommandResolver#getFinalPageName(String)}.
+     *  {@link com.ecyrd.jspwiki.action.WikiContextFactory#getFinalPageName(String)}.
      *  @since 2.0
      *  @param page Page name.
      *  @return The rewritten page name, or null, if the page does not exist.
@@ -1243,7 +1245,7 @@
     public String getFinalPageName( String page )
         throws ProviderException
     {
-        return m_commandResolver.getFinalPageName( page );
+        return m_contextFactory.getFinalPageName( page );
     }
 
     /**
@@ -1474,9 +1476,7 @@
     {
         WikiPage page = getPage( pagename, version );
 
-        WikiContext context = new WikiContext( this,
-                                               page );
-        context.setRequestContext( WikiContext.NONE );
+        WikiContext context = m_contextFactory.newViewContext( null, null, page );
 
         String res = getHTML( context, page );
 
@@ -1526,7 +1526,7 @@
      * it fires a "shutdown" WikiEngineEvent to all registered
      * listeners.
      */
-    protected void shutdown()
+    public void shutdown()
     {
         fireEvent( WikiEngineEvent.SHUTDOWN );
         m_filterManager.destroy();
@@ -1544,7 +1544,7 @@
     {
         LinkCollector localCollector = new LinkCollector();
 
-        textToHTML( new WikiContext(this,page),
+        textToHTML( m_contextFactory.newViewContext( null, null, page ),
                     pagedata,
                     localCollector,
                     null,
@@ -2033,12 +2033,12 @@
     }
 
     /**
-     * Returns the CommandResolver for this wiki engine.
-     * @return the resolver
+     * Returns the WikiContextFactory for this wiki engine.
+     * @return the factory
      */
-    public CommandResolver getCommandResolver()
+    public WikiContextFactory getWikiContextFactory()
     {
-        return m_commandResolver;
+        return m_contextFactory;
     }
 
     /**
@@ -2104,29 +2104,11 @@
     }
 
     /**
-     *  Figure out to which page we are really going to.  Considers
-     *  special page names from the jspwiki.properties, and possible aliases.
-     *  This method delgates requests to
-     *  {@link com.ecyrd.jspwiki.WikiContext#getRedirectURL()}.
-     *  @param context The Wiki Context in which the request is being made.
-     *  @return A complete URL to the new page to redirect to
-     *  @since 2.2
-     */
-
-    public String getRedirectURL( WikiContext context )
-    {
-        return context.getRedirectURL();
-    }
-
-    /**
      *  Shortcut to create a WikiContext from a supplied HTTP request,
      *  using a default wiki context.
      *  @param request the HTTP request
      *  @param requestContext the default context to use
      *  @return a new WikiContext object.
-     *
-     *  @see com.ecyrd.jspwiki.ui.CommandResolver
-     *  @see com.ecyrd.jspwiki.ui.Command
      *  @since 2.1.15.
      */
     // FIXME: We need to have a version which takes a fixed page
@@ -2138,10 +2120,21 @@
         {
             throw new InternalWikiException("WikiEngine has not been properly started.  It is likely that the configuration is faulty.  Please check all logs for the possible reason.");
         }
-
-        // Build the wiki context
-        Command command = m_commandResolver.findCommand( request, requestContext );
-        return new WikiContext( this, request, command );
+        
+        // Build the wiki context... dummy reply and response objects will be added by WikiContextFactory
+        try
+        {
+            WikiActionBeanContext context = m_contextFactory.newContext( request, (HttpServletResponse)null, requestContext );
+            
+            // Stash the action bean/wiki context, and return it!
+            WikiContextFactory.saveContext( request, context );
+            return context;
+        }
+        catch ( WikiException e )
+        {
+            log.error( "Could not create context: " + e.getMessage() );
+            return null;
+        }
     }
 
     /**

Propchange: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiEngine.java
            ('svn:eol-style' removed)

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiPage.java?rev=722756&r1=722755&r2=722756&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiPage.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiPage.java Tue Dec  2 20:26:47 2008
@@ -92,6 +92,17 @@
     {
         return m_name;
     }
+    
+    /**
+     * Returns the full, qualified, name of the WikiPage that includes the wiki name.
+     * Used by the {@link com.ecyrd.jspwiki.action.HandlerInfo} class and
+     * {@link com.ecyrd.jspwiki.action.HandlerPermission} annotations.
+     * @return the qualified page name, for example <code>mywiki:Main</code>
+     */
+    public String getQualifiedName()
+    {
+        return m_wiki + ":" + m_name;
+    }
 
     /**
      *  A WikiPage may have a number of attributes, which might or might not be 

Propchange: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiPage.java
            ('svn:eol-style' removed)



Mime
View raw message