You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2008/02/23 20:02:08 UTC

svn commit: r630505 [2/2] - in /incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki: ./ attachment/ auth/

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiEngine.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiEngine.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiEngine.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiEngine.java Sat Feb 23 11:02:00 2008
@@ -36,6 +36,8 @@
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 
+import com.ecyrd.jspwiki.action.WikiActionBean;
+import com.ecyrd.jspwiki.action.WikiActionBeanFactory;
 import com.ecyrd.jspwiki.attachment.Attachment;
 import com.ecyrd.jspwiki.attachment.AttachmentManager;
 import com.ecyrd.jspwiki.auth.AuthenticationManager;
@@ -61,13 +63,10 @@
 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;
 import com.ecyrd.jspwiki.ui.progress.ProgressManager;
-import com.ecyrd.jspwiki.url.URLConstructor;
 import com.ecyrd.jspwiki.util.ClassUtil;
 import com.ecyrd.jspwiki.util.WatchDog;
 import com.ecyrd.jspwiki.workflow.*;
@@ -141,10 +140,6 @@
     /** Property name for the default front page. */
     public static final String PROP_FRONTPAGE    = "jspwiki.frontPage";
 
-    /** Property name for setting the url generator instance */
-
-    public static final String PROP_URLCONSTRUCTOR = "jspwiki.urlConstructor";
-
     /** If this property is set to false, all filters are disabled when translating. */
     public static final String PROP_RUNFILTERS   = "jspwiki.runFilters";
 
@@ -161,6 +156,9 @@
     /** If true, uses UTF8 encoding for all data */
     private boolean          m_useUTF8      = true;
 
+    /** If true, always generate absolute URLs. */
+    private boolean         m_absoluteUrls = false;
+
     /** Stores the base URL. */
     private String           m_baseURL;
 
@@ -192,8 +190,8 @@
     /** Stores the ACL manager. */
     private AclManager       m_aclManager = null;
 
-    /** Resolves wiki actions, JSPs and special pages. */
-    private CommandResolver m_commandResolver = null;
+    /** Creates wiki action beans based on context names. */
+    private WikiActionBeanFactory m_beanFactory = null;
 
     private TemplateManager  m_templateManager = null;
 
@@ -220,9 +218,6 @@
 
     private ProgressManager  m_progressManager;
 
-    /** Constructs URLs */
-    private URLConstructor   m_urlConstructor;
-
     /** Generates RSS feed when requested. */
     private RSSGenerator     m_rssGenerator;
 
@@ -332,7 +327,6 @@
                 }
 
                 engine = new WikiEngine( context, appid, props );
-                context.setAttribute( ATTR_WIKIENGINE, engine );
             }
             catch( Exception e )
             {
@@ -374,22 +368,32 @@
     protected WikiEngine( ServletContext context, String appid, Properties props )
         throws WikiException
     {
+        super();
         m_servletContext = context;
         m_appid          = appid;
 
-        try
+        // Stash the WikiEngine in the servlet context
+        if ( context != null )
         {
+            context.setAttribute( ATTR_WIKIENGINE,  this );
             //
             //  Note: May be null, if JSPWiki has been deployed in a WAR file.
             //
             m_rootPath = context.getRealPath("/");
+        }
+        
+        try
+        {
             initialize( props );
             log.info("Root path for this Wiki is: '"+m_rootPath+"'");
         }
         catch( Exception e )
         {
             String msg = Release.APPNAME+": Unable to load and setup properties from jspwiki.properties. "+e.getMessage();
-            context.log( msg );
+            if ( context != null )
+            {
+                context.log( msg );
+            }
             throw new WikiException( msg );
         }
     }
@@ -442,9 +446,6 @@
 
         log.debug("Configuring WikiEngine...");
 
-        //  Initializes the CommandResolver
-        m_commandResolver  = new CommandResolver( this, props );
-
         //
         //  Create and find the default working directory.
         //
@@ -483,7 +484,7 @@
 
         m_useUTF8        = "UTF-8".equals( TextUtil.getStringProperty( props, PROP_ENCODING, "ISO-8859-1" ) );
         m_baseURL        = TextUtil.getStringProperty( props, PROP_BASEURL, "" );
-
+        m_absoluteUrls = "absolute".equals( m_properties.getProperty( PROP_REFSTYLE ) );
 
         m_beautifyTitle  = TextUtil.getBooleanProperty( props,
                                                         PROP_BEAUTIFYTITLE,
@@ -492,6 +493,9 @@
         m_templateDir    = TextUtil.getStringProperty( props, PROP_TEMPLATEDIR, "default" );
         m_frontPage      = TextUtil.getStringProperty( props, PROP_FRONTPAGE,   "Main" );
 
+        //  Initializes the WikiActionBeanResolver -- this MUST be done after setting the baseURL
+        m_beanFactory  = new WikiActionBeanFactory( this, props );
+
         //
         //  Initialize the important modules.  Any exception thrown by the
         //  managers means that we will not start up.
@@ -501,11 +505,6 @@
         //        of a better way to do the startup-sequence.
         try
         {
-            Class urlclass = ClassUtil.findClass( "com.ecyrd.jspwiki.url",
-                    TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor" ) );
-            m_urlConstructor = (URLConstructor) urlclass.newInstance();
-            m_urlConstructor.initialize( this, props );
-
             m_pageManager       = (PageManager)ClassUtil.getMappedObject(PageManager.class.getName(), this, props );
             m_pluginManager     = (PluginManager)ClassUtil.getMappedObject(PluginManager.class.getName(), this, props );
             m_differenceManager = (DifferenceManager)ClassUtil.getMappedObject(DifferenceManager.class.getName(), this, props );
@@ -581,21 +580,6 @@
             log.fatal( "Failed to start managers.", e );
             throw new WikiException( "Failed to start managers: "+e.getMessage() );
         }
-        catch (ClassNotFoundException e)
-        {
-            log.fatal( "JSPWiki could not start, URLConstructor was not found: ",e );
-            throw new WikiException(e.getMessage());
-        }
-        catch (InstantiationException e)
-        {
-            log.fatal( "JSPWiki could not start, URLConstructor could not be instantiated: ",e );
-            throw new WikiException(e.getMessage());
-        }
-        catch (IllegalAccessException e)
-        {
-            log.fatal( "JSPWiki could not start, URLConstructor cannot be accessed: ",e );
-            throw new WikiException(e.getMessage());
-        }
 
         //
         //  Initialize the good-to-have-but-not-fatal modules.
@@ -655,7 +639,7 @@
     {
         try
         {
-            ArrayList pages = new ArrayList();
+            ArrayList<WikiPage> pages = new ArrayList<WikiPage>();
             pages.addAll( m_pageManager.getAllPages() );
             pages.addAll( m_attachmentManager.getAllAttachments() );
 
@@ -702,17 +686,16 @@
     }
 
     /**
-     *  Returns the set of properties that the WikiEngine was initialized
-     *  with.  Note that this method returns a direct reference, so it's possible
-     *  to manipulate the properties.  However, this is not advised unless you
-     *  really know what you're doing.
-     *
+     *  Returns a copy of the properties that the WikiEngine was initialized
+     *  with.
      *  @return The wiki properties
      */
 
     public Properties getWikiProperties()
     {
-        return m_properties;
+        Properties propsCopy = new Properties();
+        propsCopy.putAll( m_properties );
+        return propsCopy;
     }
 
     /**
@@ -783,73 +766,6 @@
     }
 
     /**
-     * <p>
-     * Returns the basic absolute URL to a page, without any modifications. You
-     * may add any parameters to this.
-     * </p>
-     * <p>
-     * Since 2.3.90 it is safe to call this method with <code>null</code>
-     * pageName, in which case it will default to the front page.
-     * </p>
-     * @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.
-     */
-    public String getViewURL( String pageName )
-    {
-        if( pageName == null )
-        {
-            pageName = getFrontPage();
-        }
-        return getURLConstructor().makeURL( WikiContext.VIEW, pageName, true, null );
-    }
-
-    /**
-     *  Returns the basic URL to an editor.  Please use WikiContext.getURL() or
-     *  WikiEngine.getURL() instead.
-     *
-     *  @see #getURL(String, String, String, boolean)
-     *  @see WikiContext#getURL(String, String)
-     *  @deprecated
-     *
-     *  @since 2.0.3
-     */
-    public String getEditURL( String pageName )
-    {
-        return m_urlConstructor.makeURL( WikiContext.EDIT, pageName, false, null );
-    }
-
-    /**
-     *  Returns the basic attachment URL.Please use WikiContext.getURL() or
-     *  WikiEngine.getURL() instead.
-     *
-     *  @see #getURL(String, String, String, boolean)
-     *  @see WikiContext#getURL(String, String)
-     *  @since 2.0.42.
-     *  @param attName Attachment name
-     *  @deprecated
-     */
-    public String getAttachmentURL( String attName )
-    {
-        return m_urlConstructor.makeURL( WikiContext.ATTACH, attName, false, null );
-    }
-
-    /**
-     *  Returns an URL if a WikiContext is not available.
-     *
-     *  @param context The WikiContext (VIEW, EDIT, etc...)
-     *  @param pageName Name of the page, as usual
-     *  @param params List of parameters. May be null, if no parameters.
-     *  @param absolute If true, will generate an absolute URL regardless of properties setting.
-     *  @return An URL (absolute or relative).
-     */
-    public String getURL( String context, String pageName, String params, boolean absolute )
-    {
-        if( pageName == null ) pageName = getFrontPage();
-        return m_urlConstructor.makeURL( context, pageName, absolute, params );
-    }
-
-    /**
      *  Returns the default front page, if no page is used.
      *
      *  @return The front page name.
@@ -983,7 +899,7 @@
      */
     public Collection getAllInterWikiLinks()
     {
-        Vector v = new Vector();
+        Vector<String> v = new Vector<String>();
 
         for( Enumeration i = m_properties.propertyNames(); i.hasMoreElements(); )
         {
@@ -1010,26 +926,6 @@
     }
 
     /**
-     *  <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)}.
-     *  </p>
-     *  <p>
-     *  Special pages are defined in jspwiki.properties using the jspwiki.specialPage
-     *  setting.  They're typically used to give Wiki page names to e.g. custom JSP
-     *  pages.
-     *  </p>
-     *
-     *  @param original The page to check
-     *  @return A reference to the page, or null, if there's no special page.
-     */
-    public String getSpecialPageReference( String original )
-    {
-        return m_commandResolver.getSpecialPageReference( original );
-    }
-
-    /**
      *  Returns the name of the application.
      *
      *  @return A string describing the name of this application.
@@ -1112,7 +1008,7 @@
 
         try
         {
-            if( m_commandResolver.getSpecialPageReference(page) != null ) return true;
+            if( m_beanFactory.getSpecialPageReference(page) != null ) return true;
 
             if( getFinalPageName( page ) != null )
             {
@@ -1141,7 +1037,7 @@
     public boolean pageExists( String page, int version )
         throws ProviderException
     {
-        if( m_commandResolver.getSpecialPageReference(page) != null ) return true;
+        if( m_beanFactory.getSpecialPageReference(page) != null ) return true;
 
         String finalName = getFinalPageName( page );
 
@@ -1197,7 +1093,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.ui.WikiActionBeanFactory#getFinalPageName(String)}.
      *  @since 2.0
      *  @param page Page name.
      *  @return The rewritten page name, or null, if the page does not exist.
@@ -1206,7 +1102,7 @@
     public String getFinalPageName( String page )
         throws ProviderException
     {
-        return m_commandResolver.getFinalPageName( page );
+        return m_beanFactory.getFinalPageName( page );
     }
 
     /**
@@ -1437,9 +1333,7 @@
     {
         WikiPage page = getPage( pagename, version );
 
-        WikiContext context = new WikiContext( this,
-                                               page );
-        context.setRequestContext( WikiContext.NONE );
+        WikiContext context = m_beanFactory.newViewActionBean( page );
 
         String res = getHTML( context, page );
 
@@ -1489,7 +1383,7 @@
      * it fires a "shutdown" WikiEngineEvent to all registered
      * listeners.
      */
-    protected void shutdown()
+    public void shutdown()
     {
         fireEvent( WikiEngineEvent.SHUTDOWN );
         m_filterManager.destroy();
@@ -1503,11 +1397,11 @@
      *  @param pagedata The page contents
      *  @return a Collection of Strings
      */
-    protected Collection scanWikiLinks( WikiPage page, String pagedata )
+    protected Collection<String> scanWikiLinks( WikiPage page, String pagedata )
     {
         LinkCollector localCollector = new LinkCollector();
 
-        textToHTML( new WikiContext(this,page),
+        textToHTML( m_beanFactory.newViewActionBean( page ),
                     pagedata,
                     localCollector,
                     null,
@@ -1755,14 +1649,14 @@
 
     // FIXME: Should really get a Date object and do proper comparisons.
     //        This is terribly wasteful.
-    public Collection getRecentChanges()
+    public Collection<WikiPage> getRecentChanges()
     {
         try
         {
-            Collection pages = m_pageManager.getAllPages();
-            Collection  atts = m_attachmentManager.getAllAttachments();
+            Collection<WikiPage> pages = m_pageManager.getAllPages();
+            Collection<Attachment>  atts = m_attachmentManager.getAllAttachments();
 
-            TreeSet sortedPages = new TreeSet( new PageTimeComparator() );
+            TreeSet<WikiPage> sortedPages = new TreeSet<WikiPage>( new PageTimeComparator() );
 
             sortedPages.addAll( pages );
             sortedPages.addAll( atts );
@@ -1957,16 +1851,16 @@
      *  throw a NoSuchVariableException, but returns null in case the variable does
      *  not exist.
      *
-     *  @param context WikiContext to look the variable in
+     *  @param actionBean WikiActionBean to look up the variable in
      *  @param name Name of the variable to look for
      *  @return Variable value, or null, if there is no such variable.
      *  @since 2.2
      */
-    public String getVariable( WikiContext context, String name )
+    public String getVariable( WikiActionBean actionBean, String name )
     {
         try
         {
-            return m_variableManager.getValue( context, name );
+            return m_variableManager.getValue( actionBean, name );
         }
         catch( NoSuchVariableException e )
         {
@@ -1989,9 +1883,9 @@
      * Returns the CommandResolver for this wiki engine.
      * @return the resolver
      */
-    public CommandResolver getCommandResolver()
+    public WikiActionBeanFactory getWikiActionBeanFactory()
     {
-        return m_commandResolver;
+        return m_beanFactory;
     }
 
     /**
@@ -2057,47 +1951,6 @@
     }
 
     /**
-     *  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
-    //        name as well, or check it elsewhere.
-    public WikiContext createContext( HttpServletRequest request,
-                                      String requestContext )
-    {
-        if( !m_isConfigured )
-        {
-            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 );
-    }
-
-    /**
      *  Deletes a page or an attachment completely, including all versions.  If the page
      *  does not exist, does nothing.
      *
@@ -2178,15 +2031,6 @@
     }
 
     /**
-     * @since 2.2.6
-     * @return the URL constructor
-     */
-    public URLConstructor getURLConstructor()
-    {
-        return m_urlConstructor;
-    }
-
-    /**
      * @since 2.1.165
      * @return the RSS generator
      */
@@ -2350,8 +2194,31 @@
             WikiEventManager.fireEvent(this,new WikiEngineEvent(this,type));
         }
     }
+    
+    /**
+     * Returns <code>true</code> if this WikiEngine has been successfully
+     * initialized; <code>false</code> otherwise.
+     * @return the initialization status
+     */
+    public boolean isConfigured()
+    {
+        return m_isConfigured;
+    }
+    
+    /**
+     * Returns <code>true</code> if this WikiEngine is configured to use
+     * absolute references when generating URLs. The absolute reference will
+     * begin with the "base URL" configured by the property <code>jspwiki.baseURL</code>
+     * in <code>jspwiki.properties</code>. This value can also be obtained by
+     * calling {@link #getBaseURL()}.
+     * @return <code>true</code> if the wiki generates absolute URLs
+     */
+    public boolean useAbsoluteUrls()
+    {
+        return m_absoluteUrls;
+    }
 
-    private Map m_attributes = Collections.synchronizedMap(new HashMap());
+    private Map<String,Object> m_attributes = Collections.synchronizedMap(new HashMap<String,Object>());
 
     /**
      * Adds an attribute to the engine for the duration of this engine.  The

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiPage.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiPage.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiPage.java Sat Feb 23 11:02:00 2008
@@ -19,11 +19,14 @@
  */
 package com.ecyrd.jspwiki;
 
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
+import com.ecyrd.jspwiki.attachment.Attachment;
 import com.ecyrd.jspwiki.auth.acl.Acl;
+import com.ecyrd.jspwiki.providers.ProviderException;
 import com.ecyrd.jspwiki.providers.WikiPageProvider;
 
 /**
@@ -49,6 +52,7 @@
     private int              m_version = WikiPageProvider.LATEST_VERSION;
     private String           m_author = null;
     private final HashMap    m_attributes = new HashMap();
+    private String           m_qualifiedName;
 
     /**
      *  "Summary" is a short summary of the page.  It is a String.
@@ -77,6 +81,7 @@
         m_engine = engine;
         m_name = name;
         m_wiki = engine.getApplicationName();
+        m_qualifiedName =m_wiki + ":" + m_name;
     }
 
     /**
@@ -88,7 +93,24 @@
     {
         return m_name;
     }
+    
+    public String getQualifiedName()
+    {
+        return m_qualifiedName;
+    }
 
+    /**
+     * Convenience method that returns the collection of 
+     * Attachment objects associated with this WikiPage.
+     * It simply delegates to
+     * {@link com.ecyrd.jspwiki.attachment.AttachmentManager#listAttachments(WikiPage)}.
+     * @return the collection
+     */
+    public Collection<Attachment> getAttachments() throws ProviderException
+    {
+        return m_engine.getAttachmentManager().listAttachments( this );
+    }
+    
     /**
      *  A WikiPage may have a number of attributes, which might or might not be 
      *  available.  Typically attributes are things that do not need to be stored

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiSession.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiSession.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiSession.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiSession.java Sat Feb 23 11:02:00 2008
@@ -110,11 +110,11 @@
 
     private static final String ALL                   = "*";
 
-    private static ThreadLocal  c_guestSession        = new ThreadLocal();
+    private static ThreadLocal<WikiSession> c_guestSession  = new ThreadLocal<WikiSession>();
 
     private final Subject       m_subject             = new Subject();
 
-    private final Map           m_messages            = new HashMap();
+    private final Map<String,Set<String>> m_messages = new HashMap<String,Set<String>>();
 
     private String              m_cachedCookieIdentity= null;
 
@@ -125,8 +125,6 @@
     /** The WikiEngine that created this session. */
     private WikiEngine          m_engine              = null;
 
-    private boolean             m_isNew               = true;
-
     private String              m_status              = ANONYMOUS;
 
     private Principal           m_userPrincipal       = WikiPrincipal.GUEST;
@@ -156,25 +154,6 @@
     }
 
     /**
-     * Returns <code>true</code> if the wiki session is newly initialized.
-     *
-     * @return True, if this is a new session.
-     */
-    protected final boolean isNew()
-    {
-        return m_isNew;
-    }
-
-    /**
-     * Sets the status of this wiki session.
-     * @param isNew whether this session should be considered "new".
-     */
-    protected final void setNew( boolean isNew )
-    {
-        m_isNew = isNew;
-    }
-
-    /**
      * Private constructor to prevent WikiSession from being instantiated
      * directly.
      */
@@ -347,10 +326,10 @@
         {
             message = "";
         }
-        Set messages = (Set)m_messages.get( topic );
+        Set<String> messages = m_messages.get( topic );
         if (messages == null )
         {
-            messages = new LinkedHashSet();
+            messages = new LinkedHashSet<String>();
             m_messages.put( topic, messages );
         }
         messages.add( message );
@@ -370,7 +349,7 @@
      */
     public final void clearMessages( String topic )
     {
-        Set messages = (Set)m_messages.get( topic );
+        Set<String> messages = m_messages.get( topic );
         if ( messages != null )
         {
             m_messages.clear();
@@ -397,12 +376,12 @@
      */
     public final String[] getMessages( String topic )
     {
-        Set messages = (Set)m_messages.get( topic );
+        Set<String> messages = m_messages.get( topic );
         if ( messages == null || messages.size() == 0 )
         {
             return new String[0];
         }
-        return (String[])messages.toArray( new String[messages.size()] );
+        return messages.toArray( new String[messages.size()] );
     }
 
     /**
@@ -414,19 +393,18 @@
      */
     public final Principal[] getPrincipals()
     {
-        ArrayList principals = new ArrayList();
+        List<Principal> principals = new ArrayList<Principal>();
 
         // Take the first non Role as the main Principal
-        for( Iterator it = m_subject.getPrincipals().iterator(); it.hasNext(); )
+        for( Principal principal : m_subject.getPrincipals() )
         {
-            Principal principal = (Principal) it.next();
-            if ( AuthenticationManager.isUserPrincipal( principal ) )
+        	if ( AuthenticationManager.isUserPrincipal( principal ) )
             {
-                principals.add( principal );
-            }
-        }
+            	principals.add( principal );
+			}
+		}
 
-        return (Principal[]) principals.toArray( new Principal[principals.size()] );
+        return principals.toArray( new Principal[principals.size()] );
     }
 
     /**
@@ -444,7 +422,7 @@
      */
     public final Principal[] getRoles()
     {
-        Set roles = new HashSet();
+        Set<Principal> roles = new HashSet<Principal>();
 
         // Add all of the Roles possessed by the Subject directly
         roles.addAll( m_subject.getPrincipals( Role.class ) );
@@ -453,7 +431,7 @@
         roles.addAll( m_subject.getPrincipals( GroupPrincipal.class ) );
 
         // Return a defensive copy
-        Principal[] roleArray = ( Principal[] )roles.toArray( new Principal[roles.size()] );
+        Principal[] roleArray = roles.toArray( new Principal[roles.size()] );
         Arrays.sort( roleArray, WikiPrincipal.COMPARATOR );
         return roleArray;
     }
@@ -731,11 +709,10 @@
     protected final void injectUserProfilePrincipals()
     {
         // Copy all Role and GroupPrincipal principals into a temporary cache
-        Set oldPrincipals = m_subject.getPrincipals();
-        Set newPrincipals = new HashSet();
-        for (Iterator it = oldPrincipals.iterator(); it.hasNext();)
+        Set<Principal> oldPrincipals = m_subject.getPrincipals();
+        Set<Principal> newPrincipals = new HashSet<Principal>();
+        for ( Principal principal : oldPrincipals )
         {
-            Principal principal = (Principal)it.next();
             if ( AuthenticationManager.isRolePrincipal( principal ) )
             {
                 newPrincipals.add( principal );
@@ -784,16 +761,15 @@
      */
     protected final void updatePrincipals()
     {
-        Set principals = m_subject.getPrincipals();
+        Set<Principal> principals = m_subject.getPrincipals();
         m_loginPrincipal = null;
         m_userPrincipal = null;
         Principal wikinamePrincipal = null;
         Principal fullnamePrincipal = null;
         Principal otherPrincipal = null;
 
-        for( Iterator it = principals.iterator(); it.hasNext(); )
+        for( Principal currentPrincipal : principals )
         {
-            Principal currentPrincipal = (Principal) it.next();
             if ( !( currentPrincipal instanceof Role || currentPrincipal instanceof GroupPrincipal ) )
             {
                 // For login principal, take the first PrincipalWrapper or WikiPrincipal of type LOGIN_NAME
@@ -957,7 +933,7 @@
 
     private static WikiSession staticGuestSession( WikiEngine engine )
     {
-        WikiSession session = (WikiSession) c_guestSession.get();
+        WikiSession session = c_guestSession.get();
 
         if( session == null )
         {

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/attachment/AttachmentManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/attachment/AttachmentManager.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/attachment/AttachmentManager.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/attachment/AttachmentManager.java Sat Feb 23 11:02:00 2008
@@ -307,22 +307,22 @@
      */
 
     // FIXME: This API should be changed to return a List.
-    public Collection listAttachments( WikiPage wikipage )
+    public Collection<Attachment> listAttachments( WikiPage wikipage )
         throws ProviderException
     {
         if( m_provider == null )
         {
-            return new ArrayList();
+            return new ArrayList<Attachment>();
         }
 
-        Collection atts = m_provider.listAttachments( wikipage );
+        Collection<Attachment> atts = m_provider.listAttachments( wikipage );
 
         //
         //  This is just a sanity check; all of our providers return a Collection.
         //
         if( atts instanceof List )
         {
-            Collections.sort( (List) atts );
+            Collections.sort( (List<Attachment>)atts );
         }
 
         return atts;
@@ -525,7 +525,7 @@
      *          return an empty collection.
      *  @throws ProviderException If something went wrong with the backend
      */
-    public Collection getAllAttachments()
+    public Collection<Attachment> getAllAttachments()
         throws ProviderException
     {
         if( attachmentsEnabled() )
@@ -533,7 +533,7 @@
             return m_provider.listAllChanged( new Date(0L) );
         }
 
-        return new ArrayList();
+        return new ArrayList<Attachment>();
     }
 
     /**

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/attachment/AttachmentServlet.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/attachment/AttachmentServlet.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/attachment/AttachmentServlet.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/attachment/AttachmentServlet.java Sat Feb 23 11:02:00 2008
@@ -43,6 +43,8 @@
 import org.apache.log4j.Logger;
 
 import com.ecyrd.jspwiki.*;
+import com.ecyrd.jspwiki.action.AttachActionBean;
+import com.ecyrd.jspwiki.action.UploadActionBean;
 import com.ecyrd.jspwiki.auth.AuthorizationManager;
 import com.ecyrd.jspwiki.auth.permissions.PermissionFactory;
 import com.ecyrd.jspwiki.dav.AttachmentDavProvider;
@@ -227,7 +229,15 @@
     public void doGet( HttpServletRequest  req, HttpServletResponse res )
         throws IOException, ServletException
     {
-        WikiContext context = m_engine.createContext( req, WikiContext.ATTACH );
+        WikiContext context;
+        try 
+        {
+            context = (WikiContext)m_engine.getWikiActionBeanFactory().newActionBean( req, res, AttachActionBean.class );
+        }
+        catch ( WikiException e )
+        {
+            throw new ServletException( e.getMessage() );
+        }
 
         String version  = req.getParameter( HDR_VERSION );
         String nextPage = req.getParameter( "nextpage" );
@@ -468,7 +478,7 @@
     {
         try
         {
-            String nextPage = upload( req );
+            String nextPage = upload( req, res );
             req.getSession().removeAttribute("msg");
             res.sendRedirect( nextPage );
         }
@@ -488,8 +498,6 @@
     public void doPut( HttpServletRequest req, HttpServletResponse res )
         throws IOException, ServletException
     {
-        String errorPage = m_engine.getURL( WikiContext.ERROR, "", null, false ); // If something bad happened, Upload should be able to take care of most stuff
-
         String p = new String(req.getPathInfo().getBytes("ISO-8859-1"), "UTF-8");
         DavPath path = new DavPath( p );
 
@@ -497,11 +505,21 @@
         {
             InputStream data = req.getInputStream();
 
-            WikiContext context = m_engine.createContext( req, WikiContext.UPLOAD );
+            WikiContext context;
+            String errorPage; // If something bad happened, Upload should be able to take care of most stuff
+
+            try 
+            {
+                context = (WikiContext)m_engine.getWikiActionBeanFactory().newActionBean( req, res, UploadActionBean .class );
+            }
+            catch ( WikiException e )
+            {
+                throw new ServletException( e.getMessage() );
+            }
 
             String wikipage = path.get( 0 );
 
-            errorPage = context.getURL( WikiContext.UPLOAD,
+            errorPage = context.getContext().getURL( UploadActionBean.class,
                                         wikipage );
 
             String changeNote = null; // FIXME: Does not quite work
@@ -559,14 +577,13 @@
      *  @throws RedirectException If there's an error and a redirection is needed
      *  @throws IOException If upload fails
      */
-    protected String upload( HttpServletRequest req )
+    protected String upload( HttpServletRequest req, HttpServletResponse res )
         throws RedirectException,
                IOException
     {
         String msg     = "";
         String attName = "(unknown)";
-        String errorPage = m_engine.getURL( WikiContext.ERROR, "", null, false ); // If something bad happened, Upload should be able to take care of most stuff
-        String nextPage = errorPage;
+        String nextPage;
 
         String progressId = req.getParameter( "progressid" );
 
@@ -576,7 +593,15 @@
 
             // Create the context _before_ Multipart operations, otherwise
             // strict servlet containers may fail when setting encoding.
-            WikiContext context = m_engine.createContext( req, WikiContext.ATTACH );
+            WikiContext context;
+            try 
+            {
+                context = (WikiContext)m_engine.getWikiActionBeanFactory().newActionBean( req, res, AttachActionBean.class );
+            }
+            catch ( WikiException e )
+            {
+                throw new IOException( e.getMessage() );
+            }
 
             UploadListener pl = new UploadListener();
 
@@ -589,6 +614,7 @@
                                                      "UTF-8",
                                                      pl );
 
+            String errorPage = context.getContext().getURL( UploadActionBean.class, context.getPage().getName() );
             nextPage        = validateNextPage( multi.getParameter( "nextpage" ), errorPage );
             String wikipage = multi.getParameter( "page" );
             String changeNote = multi.getParameter( "changenote" );

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/PrincipalComparator.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/PrincipalComparator.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/PrincipalComparator.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/PrincipalComparator.java Sat Feb 23 11:02:00 2008
@@ -30,7 +30,7 @@
  * @since 2.3
  */
 public class PrincipalComparator
-    implements Comparator, Serializable
+    implements Comparator<Principal>, Serializable 
 {
     private static final long serialVersionUID = 1L;
 
@@ -41,14 +41,10 @@
      * @return the result of the comparison
      * @see java.util.Comparator#compare(Object, Object)
      */
-    public int compare( Object o1, Object o2 )
+    public int compare( Principal o1, Principal o2 )
     {
         Collator collator = Collator.getInstance();
-        if ( o1 instanceof Principal && o2 instanceof Principal )
-        {
-            return collator.compare( ((Principal)o1).getName(), ((Principal)o2).getName() );
-        }
-        throw new ClassCastException( "Objects must be of type Principal.");
+        return collator.compare( o1.getName(), o2.getName() );
     }
 
 }

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/UserManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/UserManager.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/UserManager.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/UserManager.java Sat Feb 23 11:02:00 2008
@@ -28,9 +28,12 @@
 import javax.mail.internet.AddressException;
 import javax.servlet.http.HttpServletRequest;
 
+import net.sourceforge.stripes.action.UrlBinding;
+
 import org.apache.log4j.Logger;
 
 import com.ecyrd.jspwiki.*;
+import com.ecyrd.jspwiki.action.LoginActionBean;
 import com.ecyrd.jspwiki.auth.permissions.AllPermission;
 import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
 import com.ecyrd.jspwiki.auth.user.AbstractUserDatabase;
@@ -84,7 +87,7 @@
     // private static final String  PROP_ACLMANAGER     = "jspwiki.aclManager";
 
     /** Associateds wiki sessions with profiles */
-    private final Map        m_profiles     = new WeakHashMap();
+    private final Map<WikiSession,UserProfile> m_profiles = new WeakHashMap<WikiSession,UserProfile>(); 
 
     /** The user database loads, manages and persists user identities */
     private UserDatabase     m_database;
@@ -205,7 +208,7 @@
     public final UserProfile getUserProfile( WikiSession session )
     {
         // Look up cached user profile
-        UserProfile profile = (UserProfile)m_profiles.get( session );
+        UserProfile profile = m_profiles.get( session );
         boolean newProfile = profile == null;
         Principal user = null;
 
@@ -428,7 +431,7 @@
     {
         // Retrieve the user's profile (may have been previously cached)
         UserProfile profile = getUserProfile( context.getWikiSession() );
-        HttpServletRequest request = context.getHttpRequest();
+        HttpServletRequest request = context.getContext().getRequest();
 
         // Extract values from request stream (cleanse whitespace as needed)
         String loginName = request.getParameter( PARAM_LOGINNAME );
@@ -469,6 +472,7 @@
      * (see {@link WikiSession#getMessages()}.
      * @param context the current wiki context
      * @param profile the supplied UserProfile
+     * @deprecated
      */
     public final void validateProfile( WikiContext context, UserProfile profile )
     {
@@ -749,7 +753,7 @@
                         + "Your name : " + profile.getFullname() + "\n"
                         + "E-mail    : " + profile.getEmail() + "\n\n"
                         + "If you forget your password, you can reset it at "
-                        + m_engine.getURL(WikiContext.LOGIN, null, null, true);
+                        + m_engine.getBaseURL() + LoginActionBean.class.getAnnotation(UrlBinding.class).value();
                     MailUtil.sendMessage( m_engine, to, subject, content);
                 }
                 catch ( AddressException e)

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java Sat Feb 23 11:02:00 2008
@@ -59,7 +59,7 @@
     public static final String UNSPECIFIED  = "unspecified";
     
     /** Static instance of Comparator that allows Principals to be sorted. */
-    public static final Comparator COMPARATOR = new PrincipalComparator();
+    public static final Comparator<Principal> COMPARATOR = new PrincipalComparator();
     
     private static final String[] VALID_TYPES;
     
@@ -95,6 +95,10 @@
      */
     public WikiPrincipal( String name, String type )
     {
+        if ( name == null )
+        {
+            throw new IllegalArgumentException( "Name cannot be null" );
+        }
         m_name = name;
         if ( Arrays.binarySearch( VALID_TYPES, type ) < 0 )
         {