jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r630505 [1/2] - in /incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki: ./ attachment/ auth/
Date Sat, 23 Feb 2008 19:02:08 GMT
Author: ajaquith
Date: Sat Feb 23 11:02:00 2008
New Revision: 630505

URL: http://svn.apache.org/viewvc?rev=630505&view=rev
Log:
Initial Stripes component commit.

Modified:
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/LinkCollector.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageManager.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageRenamer.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageTimeComparator.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/ReferenceManager.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/SearchResultComparator.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/TranslatorReader.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/VariableManager.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiContext.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiEngine.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiPage.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiSession.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/attachment/AttachmentManager.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/attachment/AttachmentServlet.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/PrincipalComparator.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/UserManager.java
    incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/LinkCollector.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/LinkCollector.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/LinkCollector.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/LinkCollector.java Sat Feb 23 11:02:00 2008
@@ -31,13 +31,13 @@
 public class LinkCollector
     implements StringTransmutator
 {
-    private ArrayList m_items = new ArrayList();
+    private ArrayList<String> m_items = new ArrayList<String>();
 
     /**
      * Returns a List of Strings representing links.
      * @return the link collection
      */
-    public Collection getLinks()
+    public Collection<String> getLinks()
     {
         return m_items;
     }

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageManager.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageManager.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageManager.java Sat Feb 23 11:02:00 2008
@@ -197,7 +197,7 @@
      *  @return A Collection of WikiPage objects.
      *  @throws ProviderException If the backend has problems.
      */
-    public Collection getAllPages()
+    public Collection<WikiPage> getAllPages()
         throws ProviderException
     {
         return m_provider.getAllPages();

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageRenamer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageRenamer.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageRenamer.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageRenamer.java Sat Feb 23 11:02:00 2008
@@ -108,7 +108,7 @@
         newName = MarkupParser.cleanLink( newName.trim() );
 
         // Get the collection of pages that the refered to the old name (the From name)...
-        Collection referrers = getReferrersCollection( oldName );
+        Collection<String> referrers = getReferrersCollection( oldName );
 
         log.debug( "Rename request for page '"+ oldName +"' to '" + newName + "'" );
 
@@ -136,7 +136,7 @@
             // Now we need to go and update.
             WikiPage p = m_wikiEngine.getPage(newName);
             String pagedata = m_wikiEngine.getPureText(p);
-            Collection refs = m_wikiEngine.scanWikiLinks(p,pagedata);
+            Collection<String> refs = m_wikiEngine.scanWikiLinks(p,pagedata);
             m_wikiEngine.getReferenceManager().updateReferences(newName,refs);
         }
 
@@ -145,26 +145,24 @@
 
 
     // Go gather and return a collection of page names that refer to the old name...
-    private Collection getReferrersCollection( String oldName )
+    private Collection<String> getReferrersCollection( String oldName )
     {
-        TreeSet list = new TreeSet();
+        TreeSet<String> list = new TreeSet<String>();
 
         WikiPage p = m_wikiEngine.getPage(oldName);
 
         if( p != null )
         {
-            Collection c = m_wikiEngine.getReferenceManager().findReferrers(oldName);
+            Collection<String> c = m_wikiEngine.getReferenceManager().findReferrers(oldName);
 
             if( c != null ) list.addAll(c);
 
             try
             {
-                Collection attachments = m_wikiEngine.getAttachmentManager().listAttachments(p);
+                Collection<Attachment> attachments = m_wikiEngine.getAttachmentManager().listAttachments(p);
 
-                for( Iterator i = attachments.iterator(); i.hasNext(); )
+                for( Attachment att : attachments )
                 {
-                    Attachment att = (Attachment) i.next();
-
                     c = m_wikiEngine.getReferenceManager().findReferrers(att.getName());
 
                     if( c != null ) list.addAll(c);
@@ -186,16 +184,14 @@
                                           String oldName,
                                           String newName,
                                           boolean changeReferrers,
-                                          Collection referrers)
+                                          Collection<String> referrers)
     {
         // Make a new list out of this, otherwise there is a ConcurrentModificationException
         // when the referrer is modifed at the end of this loop when it no longer refers to
         // the original page.
-        List referrersList = new ArrayList( referrers );
-        Iterator referrersIterator = referrersList.iterator();
-        while ( referrersIterator.hasNext() )
+        List<String> referrersList = new ArrayList<String>( referrers );
+        for ( String referrerName : referrersList )
         {
-            String referrerName = (String)referrersIterator.next();
             updateReferrerOnRename( context, oldName, newName, changeReferrers, referrerName );
         }
 
@@ -207,7 +203,7 @@
 
         String text = m_wikiEngine.getText( newName );
 
-        Collection updatedReferrers = m_wikiEngine.scanWikiLinks( m_wikiEngine.getPage(newName),text );
+        Collection<String> updatedReferrers = m_wikiEngine.scanWikiLinks( m_wikiEngine.getPage(newName),text );
         m_wikiEngine.getReferenceManager().updateReferences( newName, updatedReferrers );
     }
 
@@ -229,17 +225,17 @@
         try
         {
 
-            WikiContext tempCtx = new WikiContext( m_wikiEngine, m_wikiEngine.getPage(referrerName) );
+            WikiContext tempCtx = m_wikiEngine.getWikiActionBeanFactory().newViewActionBean( m_wikiEngine.getPage(referrerName) );
 
             if (context.getPage() != null)
             {
-                PageLock lock = m_wikiEngine.getPageManager().getCurrentLock( context.getPage() );
+                PageLock lock = m_wikiEngine.getPageManager().getCurrentLock( m_wikiEngine.getPage(referrerName) );
                 m_wikiEngine.getPageManager().unlockPage( lock );
 
                 tempCtx.getPage().setAuthor( context.getCurrentUser().getName() );
                 m_wikiEngine.saveText( tempCtx, text );
 
-                Collection updatedReferrers = m_wikiEngine.scanWikiLinks( m_wikiEngine.getPage(referrerName),text );
+                Collection<String> updatedReferrers = m_wikiEngine.scanWikiLinks( m_wikiEngine.getPage(referrerName),text );
 
                 m_wikiEngine.getReferenceManager().updateReferences( referrerName, updatedReferrers );
              }

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageTimeComparator.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageTimeComparator.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageTimeComparator.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/PageTimeComparator.java Sat Feb 23 11:02:00 2008
@@ -36,7 +36,7 @@
 // FIXME3.0: move to util package
 
 public class PageTimeComparator
-    implements Comparator, Serializable
+    implements Comparator<WikiPage>, Serializable
 {
     private static final long serialVersionUID = 0L;
 
@@ -45,7 +45,7 @@
     /**
      *  {@inheritDoc}
      */
-    public int compare( Object o1, Object o2 )
+    public int compare( WikiPage o1, WikiPage o2 )
     {
         WikiPage w1 = (WikiPage)o1;
         WikiPage w2 = (WikiPage)o2;
@@ -56,22 +56,19 @@
             return 0; // FIXME: Is this correct?
         }
 
-        Date w1LastMod = w1.getLastModified();
-        Date w2LastMod = w2.getLastModified();
-
-        if( w1LastMod == null )
+        if( w1.getLastModified() == null )
         {
             log.error( "NULL MODIFY DATE WITH "+w1.getName() );
             return 0;
         }
-        else if( w2LastMod == null )
+        else if( w2.getLastModified() == null )
         {
             log.error( "NULL MODIFY DATE WITH "+w2.getName() );
             return 0;
         }
 
         // This gets most recent on top
-        int timecomparison = w2LastMod.compareTo( w1LastMod );
+        int timecomparison = w2.getLastModified().compareTo( w1.getLastModified() );
 
         if( timecomparison == 0 )
         {

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/ReferenceManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/ReferenceManager.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/ReferenceManager.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/ReferenceManager.java Sat Feb 23 11:02:00 2008
@@ -121,15 +121,15 @@
      *  must contain Strings. The Collection may contain names of non-existing
      *  pages.
      */
-    private Map            m_refersTo;
-    private Map            m_unmutableRefersTo;
+    private Map<String,Set<String>> m_refersTo;
+    private Map<String,Set<String>> m_unmutableRefersTo;
 
     /** Maps page wikiname to a Set of referring pages. The Set must
      *  contain Strings. Non-existing pages (a reference exists, but not a file
      *  for the page contents) may have an empty Set in m_referredBy.
      */
-    private Map            m_referredBy;
-    private Map            m_unmutableReferredBy;
+    private Map<String,Set<String>> m_referredBy;
+    private Map<String,Set<String>> m_unmutableReferredBy;
 
     /** The WikiEngine that owns this object. */
     private WikiEngine     m_engine;
@@ -151,8 +151,8 @@
      */
     public ReferenceManager( WikiEngine engine )
     {
-        m_refersTo   = new HashMap();
-        m_referredBy = new HashMap();
+        m_refersTo   = new HashMap<String,Set<String>>();
+        m_referredBy = new HashMap<String,Set<String>>();
         m_engine = engine;
 
         m_matchEnglishPlurals = TextUtil.getBooleanProperty( engine.getWikiProperties(),
@@ -175,15 +175,15 @@
         String content = m_engine.getPageManager().getPageText( page.getName(),
                                                                 WikiPageProvider.LATEST_VERSION );
 
-        TreeSet res = new TreeSet();
-        Collection links = m_engine.scanWikiLinks( page, content );
+        TreeSet<String> res = new TreeSet<String>();
+        Collection<String> links = m_engine.scanWikiLinks( page, content );
 
         res.addAll( links );
-        Collection attachments = m_engine.getAttachmentManager().listAttachments( page );
+        Collection<Attachment> attachments = m_engine.getAttachmentManager().listAttachments( page );
 
-        for( Iterator atti = attachments.iterator(); atti.hasNext(); )
+        for( Attachment atti : attachments )
         {
-            res.add( ((Attachment)(atti.next())).getName() );
+            res.add( atti.getName() );
         }
 
         internalUpdateReferences( page.getName(), res );
@@ -197,7 +197,7 @@
      *               count.
      *  @since 2.2
      */
-    public void initialize( Collection pages )
+    public void initialize( Collection<WikiPage> pages )
         throws ProviderException
     {
         log.debug( "Initializing new ReferenceManager with "+pages.size()+" initial pages." );
@@ -222,10 +222,8 @@
             //
             long saved = unserializeFromDisk();
 
-            for( Iterator it = pages.iterator(); it.hasNext(); )
+            for( WikiPage page : pages )
             {
-                WikiPage page = (WikiPage) it.next();
-
                 unserializeAttrsFromDisk( page );
             }
 
@@ -235,11 +233,11 @@
             //  the references for them.
             //
 
-            Iterator it = pages.iterator();
+            Iterator<WikiPage> it = pages.iterator();
 
             while( it.hasNext() )
             {
-                WikiPage page = (WikiPage) it.next();
+                WikiPage page = it.next();
 
                 if( page instanceof Attachment )
                 {
@@ -269,10 +267,10 @@
             buildKeyLists( pages );
 
             // Scan the existing pages from disk and update references in the manager.
-            Iterator it = pages.iterator();
+            Iterator<WikiPage> it = pages.iterator();
             while( it.hasNext() )
             {
-                WikiPage page  = (WikiPage)it.next();
+                WikiPage page  = it.next();
 
                 if( page instanceof Attachment )
                 {
@@ -326,8 +324,8 @@
             }
 
             saved        = in.readLong();
-            m_refersTo   = (Map) in.readObject();
-            m_referredBy = (Map) in.readObject();
+            m_refersTo   = (Map<String,Set<String>>) in.readObject();
+            m_referredBy = (Map<String,Set<String>>) in.readObject();
 
             in.close();
 
@@ -590,7 +588,7 @@
 
     private void pageRemoved(String pageName)
     {
-        Collection refTo = (Collection)m_refersTo.get( pageName );
+        Collection<String> refTo = m_refersTo.get( pageName );
 
         if( refTo != null )
         {
@@ -598,7 +596,7 @@
             while( it_refTo.hasNext() )
             {
                 String referredPageName = (String)it_refTo.next();
-                Set refBy = (Set)m_referredBy.get( referredPageName );
+                Set<String> refBy = m_referredBy.get( referredPageName );
 
                 if( refBy == null )
                     throw new InternalWikiException("Refmgr out of sync: page "+pageName+" refers to "+referredPageName+", which has null referrers.");
@@ -619,7 +617,7 @@
             m_refersTo.remove( pageName );
         }
 
-        Set refBy = (Set) m_referredBy.get( pageName );
+        Set<String> refBy = m_referredBy.get( pageName );
         if( refBy == null || refBy.isEmpty() )
         {
             m_referredBy.remove( pageName );
@@ -656,7 +654,7 @@
      *  @param page Name of the page to update.
      *  @param references A Collection of Strings, each one pointing to a page this page references.
      */
-    public synchronized void updateReferences( String page, Collection references )
+    public synchronized void updateReferences( String page, Collection<String> references )
     {
         internalUpdateReferences(page, references);
 
@@ -674,21 +672,19 @@
      *  @param references A Collection of Strings, each one pointing to a page this page references.
      */
 
-    private void internalUpdateReferences(String page, Collection references)
+    private void internalUpdateReferences(String page, Collection<String> references)
     {
         page = getFinalPageName( page );
 
         //
         // Create a new entry in m_refersTo.
         //
-        Collection oldRefTo = (Collection)m_refersTo.get( page );
+        Collection<String> oldRefTo = m_refersTo.get( page );
         m_refersTo.remove( page );
 
-        TreeSet cleanedRefs = new TreeSet();
-        for( Iterator i = references.iterator(); i.hasNext(); )
+        TreeSet<String> cleanedRefs = new TreeSet<String>();
+        for( String ref : references )
         {
-            String ref = (String)i.next();
-
             ref = getFinalPageName( ref );
 
             cleanedRefs.add( ref );
@@ -703,7 +699,7 @@
         //
         if( !m_referredBy.containsKey( page ) )
         {
-            m_referredBy.put( page, new TreeSet() );
+            m_referredBy.put( page, new TreeSet<String>() );
         }
 
         //
@@ -716,10 +712,8 @@
         //
         //  Notify all referred pages of their referinesshoodicity.
         //
-        Iterator it = cleanedRefs.iterator();
-        while( it.hasNext() )
+        for( String referredPageName : cleanedRefs )
         {
-            String referredPageName = (String)it.next();
             updateReferredBy( getFinalPageName(referredPageName), page );
         }
     }
@@ -744,9 +738,9 @@
      * Cleans the 'referred by' list, removing references by 'referrer' to
      * any other page. Called after 'referrer' is removed.
      */
-    private void cleanReferredBy( String referrer,
-                                  Collection oldReferred,
-                                  Collection newReferred )
+    private void cleanReferredBy( String referrer, 
+                                  Collection<String> oldReferred,
+                                  Collection<String> newReferred )
     {
         // Two ways to go about this. One is to look up all pages previously
         // referred by referrer and remove referrer from their lists, and let
@@ -759,11 +753,9 @@
         if( oldReferred == null )
             return;
 
-        Iterator it = oldReferred.iterator();
-        while( it.hasNext() )
+        for( String referredPage : oldReferred )
         {
-            String referredPage = (String)it.next();
-            Set oldRefBy = (Set)m_referredBy.get( referredPage );
+            Set<String> oldRefBy = m_referredBy.get( referredPage );
             if( oldRefBy != null )
             {
                 oldRefBy.remove( referrer );
@@ -793,7 +785,7 @@
      *
      * @param pages   a Collection containing WikiPage objects.
      */
-    private synchronized void buildKeyLists( Collection pages )
+    private synchronized void buildKeyLists( Collection<WikiPage> pages )
     {
         m_refersTo.clear();
         m_referredBy.clear();
@@ -801,16 +793,14 @@
         if( pages == null )
             return;
 
-        Iterator it = pages.iterator();
         try
         {
-            while( it.hasNext() )
+            for( WikiPage page : pages )
             {
-                WikiPage page = (WikiPage)it.next();
                 // We add a non-null entry to referredBy to indicate the referred page exists
-                m_referredBy.put( page.getName(), new TreeSet() );
+                m_referredBy.put( page.getName(), new TreeSet<String>() );
                 // Just add a key to refersTo; the keys need to be in sync with referredBy.
-                m_refersTo.put( page.getName(), null );
+                m_refersTo.put( page.getName(), (TreeSet<String>)null );
             }
         }
         catch( ClassCastException e )
@@ -847,14 +837,14 @@
             }
         }
 
-        Set referrers = (Set)m_referredBy.get( page );
+        Set<String> referrers = m_referredBy.get( page );
 
         // Even if 'page' has not been created yet, it can still be referenced.
         // This requires we don't use m_referredBy keys when looking up missing
         // pages, of course.
         if(referrers == null)
         {
-            referrers = new TreeSet();
+            referrers = new TreeSet<String>();
             m_referredBy.put( page, referrers );
         }
         referrers.add( referrer );
@@ -874,13 +864,13 @@
         //  Remove this item from the referredBy list of any page
         //  which this item refers to.
         //
-        Collection c = (Collection)m_refersTo.get( pagename );
+        Collection<String> c = m_refersTo.get( pagename );
 
         if( c != null )
         {
-            for( Iterator i = c.iterator(); i.hasNext(); )
+            for( Iterator<String> i = c.iterator(); i.hasNext(); )
             {
-                Collection dref = (Collection) m_referredBy.get( i.next() );
+                Collection<String> dref = m_referredBy.get( i.next() );
 
                 dref.remove( pagename );
             }
@@ -898,16 +888,15 @@
      *  Finds all unreferenced pages. This requires a linear scan through
      *  m_referredBy to locate keys with null or empty values.
      */
-    public synchronized Collection findUnreferenced()
+    public synchronized Collection<String> findUnreferenced()
     {
-        ArrayList unref = new ArrayList();
+        List<String> unref = new ArrayList<String>();
 
-        Set keys = m_referredBy.keySet();
-        Iterator it = keys.iterator();
+        Iterator<String> it = m_referredBy.keySet().iterator();
 
         while( it.hasNext() )
         {
-            String key = (String) it.next();
+            String key = it.next();
             //Set refs = (Set) m_referredBy.get( key );
             Set refs = getReferenceList( m_referredBy, key );
             if( refs == null || refs.isEmpty() )
@@ -930,28 +919,19 @@
      * Each non-existant page name is shown only once - we don't return information
      * on who referred to it.
      */
-    public synchronized Collection findUncreated()
+    public synchronized Collection<String> findUncreated()
     {
-        TreeSet uncreated = new TreeSet();
+        Set<String> uncreated = new TreeSet<String>();
 
         // Go through m_refersTo values and check that m_refersTo has the corresponding keys.
         // We want to reread the code to make sure our HashMaps are in sync...
 
-        Collection allReferences = m_refersTo.values();
-        Iterator it = allReferences.iterator();
-
-        while( it.hasNext() )
+        for( Collection<String> refs : m_refersTo.values())
         {
-            Collection refs = (Collection)it.next();
-
             if( refs != null )
             {
-                Iterator rit = refs.iterator();
-
-                while( rit.hasNext() )
+                for ( String aReference : refs )
                 {
-                    String aReference = (String)rit.next();
-
                     if( m_engine.pageExists( aReference ) == false )
                     {
                         uncreated.add( aReference );
@@ -966,24 +946,24 @@
     /**
      *  Searches for the given page in the given Map.
      */
-    private Set getReferenceList( Map coll, String pagename )
+    private Set<String> getReferenceList( Map<String,Set<String>> coll, String pagename )
     {
-        Set refs = (Set)coll.get( pagename );
+        Set<String> refs = coll.get( pagename );
 
         if( m_matchEnglishPlurals )
         {
             //
             //  We'll add also matches from the "other" page.
             //
-            Set refs2;
+            Set<String> refs2;
 
             if( pagename.endsWith("s") )
             {
-                refs2 = (Set)coll.get( pagename.substring(0,pagename.length()-1) );
+                refs2 = coll.get( pagename.substring(0,pagename.length()-1) );
             }
             else
             {
-                refs2 = (Set)coll.get( pagename+"s" );
+                refs2 = coll.get( pagename+"s" );
             }
 
             if( refs2 != null )
@@ -1008,9 +988,9 @@
      *         does not exist, or if it has no references.
      */
     // FIXME: Return a Set instead of a Collection.
-    public synchronized Collection findReferrers( String pagename )
+    public synchronized Collection<String> findReferrers( String pagename )
     {
-        Set refs = getReferenceList( m_referredBy, pagename );
+        Set<String> refs = getReferenceList( m_referredBy, pagename );
 
         if( refs == null || refs.isEmpty() )
         {
@@ -1039,7 +1019,7 @@
      */
     public Set findReferredBy( String pageName )
     {
-        return (Set)m_unmutableReferredBy.get( getFinalPageName(pageName) );
+        return m_unmutableReferredBy.get( getFinalPageName(pageName) );
     }
 
     /**
@@ -1060,9 +1040,9 @@
      *         been indexed yet.
      * @since 2.2.33
      */
-    public Collection findRefersTo( String pageName )
+    public Collection<String> findRefersTo( String pageName )
     {
-        return (Collection)m_unmutableRefersTo.get( getFinalPageName(pageName) );
+        return m_unmutableRefersTo.get( getFinalPageName(pageName) );
     }
 
     /**
@@ -1115,9 +1095,9 @@
      *  @return A Set of all defined page names that ReferenceManager knows about.
      *  @since 2.3.24
      */
-    public Set findCreated()
+    public Set<String> findCreated()
     {
-        return new HashSet( m_refersTo.keySet() );
+        return new HashSet<String>( m_refersTo.keySet() );
     }
 
     private String getFinalPageName( String orig )

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/SearchResultComparator.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/SearchResultComparator.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/SearchResultComparator.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/SearchResultComparator.java Sat Feb 23 11:02:00 2008
@@ -28,7 +28,7 @@
  */
 // FIXME3.0: move to the search package
 public class SearchResultComparator
-    implements Comparator, Serializable
+    implements Comparator<SearchResult>, Serializable
 {
     private static final long serialVersionUID = 1L;
 
@@ -38,11 +38,8 @@
      *  
      *  {@inheritDoc}
      */
-    public int compare( Object o1, Object o2 )
+    public int compare( SearchResult s1, SearchResult s2 )
     {
-        SearchResult s1 = (SearchResult)o1;
-        SearchResult s2 = (SearchResult)o2;
-
         // Bigger scores are first.
 
         int res = s2.getScore() - s1.getScore();

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/TranslatorReader.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/TranslatorReader.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/TranslatorReader.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/TranslatorReader.java Sat Feb 23 11:02:00 2008
@@ -33,6 +33,7 @@
 import com.ecyrd.jspwiki.plugin.PluginManager;
 import com.ecyrd.jspwiki.plugin.PluginException;
 import com.ecyrd.jspwiki.plugin.WikiPlugin;
+import com.ecyrd.jspwiki.action.*;
 import com.ecyrd.jspwiki.attachment.AttachmentManager;
 import com.ecyrd.jspwiki.attachment.Attachment;
 import com.ecyrd.jspwiki.providers.ProviderException;
@@ -93,7 +94,7 @@
     private boolean        m_isdefinition = false;
 
     /** Contains style information, in multiple forms. */
-    private Stack          m_styleStack   = new Stack();
+    private Stack<Boolean>          m_styleStack   = new Stack<Boolean>();
 
      // general list handling
     private int            m_genlistlevel = 0;
@@ -110,17 +111,17 @@
     private WikiContext    m_context;
 
     /** Optionally stores internal wikilinks */
-    private ArrayList      m_localLinkMutatorChain    = new ArrayList();
-    private ArrayList      m_externalLinkMutatorChain = new ArrayList();
-    private ArrayList      m_attachmentLinkMutatorChain = new ArrayList();
-    private ArrayList      m_headingListenerChain     = new ArrayList();
+    private ArrayList<StringTransmutator>      m_localLinkMutatorChain    = new ArrayList<StringTransmutator>();
+    private ArrayList<StringTransmutator>      m_externalLinkMutatorChain = new ArrayList<StringTransmutator>();
+    private ArrayList<StringTransmutator>      m_attachmentLinkMutatorChain = new ArrayList<StringTransmutator>();
+    private ArrayList<HeadingListener>      m_headingListenerChain     = new ArrayList<HeadingListener>();
 
     /** Keeps image regexp Patterns */
     private ArrayList      m_inlineImagePatterns;
 
     private PatternMatcher m_inlineMatcher = new Perl5Matcher();
 
-    private ArrayList      m_linkMutators = new ArrayList();
+    private ArrayList<StringTransmutator>      m_linkMutators = new ArrayList<StringTransmutator>();
 
     /**
      *  This property defines the inline image pattern.  It's current value
@@ -444,7 +445,7 @@
     protected static Collection getImagePatterns( WikiEngine engine )
     {
         Properties props    = engine.getWikiProperties();
-        ArrayList  ptrnlist = new ArrayList();
+        ArrayList<String>  ptrnlist = new ArrayList<String>();
 
         for( Enumeration e = props.propertyNames(); e.hasMoreElements(); )
         {
@@ -1047,7 +1048,7 @@
 
                 if( isImageLink( reallink ) )
                 {
-                    attachment = m_context.getURL( WikiContext.ATTACH, attachment );
+                    attachment = m_context.getContext().getURL( AttachActionBean.class, attachment );
                     sb.append( handleImageLink( attachment, link, (cutpoint != -1) ) );
                 }
                 else
@@ -2392,8 +2393,7 @@
         {
             if( m_cleanTranslator == null )
             {
-                WikiContext dummyContext = new WikiContext( m_engine,
-                                                            m_context.getPage() );
+                WikiContext dummyContext = m_engine.getWikiActionBeanFactory().newViewActionBean( m_context.getPage() );
                 m_cleanTranslator = new TranslatorReader( dummyContext,
                                                           null,
                                                           new TextRenderer() );
@@ -2540,11 +2540,9 @@
             return makeLink( type, link, text, null );
         }
 
-        private final String getURL( String context, String link )
+        private final String getURL( Class<? extends WikiActionBean> beanClass, String link )
         {
-            return m_context.getURL( context,
-                                     link,
-                                     null );
+            return m_context.getContext().getURL( beanClass, link );
         }
 
         /**
@@ -2577,13 +2575,13 @@
             switch(type)
             {
               case READ:
-                result = "<a class=\"wikipage\" href=\""+getURL(WikiContext.VIEW,
+                result = "<a class=\"wikipage\" href=\""+getURL(ViewActionBean.class,
                                                                 link)+section+"\">"+text+"</a>";
                 break;
 
               case EDIT:
                 result = "<a class=\"createpage\" title=\"Create '"+link+"'\" href=\""+
-                         getURL(WikiContext.EDIT, link)+"\">"+
+                		  getURL(EditActionBean.class, link)+"\">"+
                          text+"</a>";
                 break;
 
@@ -2625,7 +2623,7 @@
                 break;
 
               case IMAGEWIKILINK:
-                String pagelink = getURL(WikiContext.VIEW,text);
+                String pagelink = getURL(ViewActionBean.class,text);
                 result = "<a class=\"wikipage\" href=\""+pagelink+"\"><img class=\"inline\" src=\""+link+"\" alt=\""+text+"\" /></a>";
                 break;
 
@@ -2640,13 +2638,13 @@
                 break;
 
               case ATTACHMENT:
-                String attlink = getURL( WikiContext.ATTACH,
+                String attlink = getURL( AttachActionBean.class,
                                          link );
 
-                String infolink = getURL( WikiContext.INFO,
+                String infolink = getURL( PageInfoActionBean.class,
                                           link );
 
-                String imglink = getURL( WikiContext.NONE,
+                String imglink = getURL( NoneActionBean.class,
                                          "images/attachment_small.png" );
 
                 result = "<a class=\"attachment\" href=\""+attlink+"\">"+text+"</a>"+
@@ -2877,7 +2875,7 @@
             if( m_useOutlinkImage )
             {
                 return "<img class=\"outlink\" src=\""+
-                       getURL( WikiContext.NONE,"images/out.png" )+"\" alt=\"\" />";
+                       getURL( NoneActionBean.class,"images/out.png" )+"\" alt=\"\" />";
             }
 
             return "";

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/VariableManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/VariableManager.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/VariableManager.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/VariableManager.java Sat Feb 23 11:02:00 2008
@@ -28,6 +28,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
+import com.ecyrd.jspwiki.action.WikiActionBean;
 import com.ecyrd.jspwiki.filters.PageFilter;
 import com.ecyrd.jspwiki.modules.InternalModule;
 
@@ -179,11 +180,11 @@
      *  @param defValue A default value.
      *  @return The variable value, or if not found, the default value.
      */
-    public String getValue( WikiContext context, String varName, String defValue )
+    public String getValue( WikiActionBean actionBean, String varName, String defValue )
     {
         try
         {
-            return getValue( context, varName );
+            return getValue( actionBean, varName );
         }
         catch( NoSuchVariableException e )
         {
@@ -217,7 +218,7 @@
      */
     // FIXME: Currently a bit complicated.  Perhaps should use reflection
     //        or something to make an easy way of doing stuff.
-    public String getValue( WikiContext context,
+    public String getValue( WikiActionBean actionBean,
                             String      varName )
         throws IllegalArgumentException,
                NoSuchVariableException
@@ -237,13 +238,14 @@
                 return ""; // FIXME: Should this be something different?
         }
         
-        if( name.equals("pagename") )
+        if( name.equals("pagename") && actionBean instanceof WikiContext )
         {
-            return context.getPage().getName();
+            WikiPage page = ((WikiContext)actionBean).getPage();
+            return ( page == null ? null : ((WikiContext)actionBean).getPage().getName() );
         }
         else if( name.equals("applicationname") )
         {
-            return context.getEngine().getApplicationName();
+            return actionBean.getEngine().getApplicationName();
         }
         else if( name.equals("jspwikiversion") )
         {
@@ -251,28 +253,28 @@
         }
         else if( name.equals("encoding") )
         {
-            return context.getEngine().getContentEncoding();
+            return actionBean.getEngine().getContentEncoding();
         }
         else if( name.equals("totalpages") )
         {
-            return Integer.toString(context.getEngine().getPageCount());
+            return Integer.toString(actionBean.getEngine().getPageCount());
         }
         else if( name.equals("pageprovider") )
         {
-            return context.getEngine().getCurrentProvider();
+            return actionBean.getEngine().getCurrentProvider();
         }
         else if( name.equals("pageproviderdescription") )
         {
-            return context.getEngine().getCurrentProviderInfo();
+            return actionBean.getEngine().getCurrentProviderInfo();
         }
         else if( name.equals("attachmentprovider") )
         {
-            WikiProvider p = context.getEngine().getAttachmentManager().getCurrentProvider();
+            WikiProvider p = actionBean.getEngine().getAttachmentManager().getCurrentProvider();
             return (p != null) ? p.getClass().getName() : "-";
         }
         else if( name.equals("attachmentproviderdescription") )
         {
-            WikiProvider p = context.getEngine().getAttachmentManager().getCurrentProvider();
+            WikiProvider p = actionBean.getEngine().getAttachmentManager().getCurrentProvider();
 
             return (p != null) ? p.getProviderInfo() : "-";
         }
@@ -280,13 +282,13 @@
         {
             StringBuffer res = new StringBuffer();
 
-            for( Iterator i = context.getEngine().getAllInterWikiLinks().iterator(); i.hasNext(); )
+            for( Iterator i = actionBean.getEngine().getAllInterWikiLinks().iterator(); i.hasNext(); )
             {
                 if( res.length() > 0 ) res.append(", ");
                 String link = (String) i.next();
                 res.append( link );
                 res.append( " --> " );
-                res.append( context.getEngine().getInterWikiURL(link) );    
+                res.append( actionBean.getEngine().getInterWikiURL(link) );
             }
             return res.toString();
         }
@@ -294,7 +296,7 @@
         {
             StringBuffer res = new StringBuffer();
 
-            for( Iterator i = context.getEngine().getAllInlinedImagePatterns().iterator(); i.hasNext(); )
+            for( Iterator i = actionBean.getEngine().getAllInlinedImagePatterns().iterator(); i.hasNext(); )
             {
                 if( res.length() > 0 ) res.append(", ");
                 
@@ -306,18 +308,18 @@
         }
         else if( name.equals("pluginpath") )
         {
-            String s = context.getEngine().getPluginSearchPath();
+            String s = actionBean.getEngine().getPluginSearchPath();
 
             return (s == null) ? "-" : s;
         }
         else if( name.equals("baseurl") )
         {
-            return context.getEngine().getBaseURL();
+            return actionBean.getEngine().getBaseURL();
         }
         else if( name.equals("uptime") )
         {
             Date now = new Date();
-            long secondsRunning = (now.getTime() - context.getEngine().getStartTime().getTime())/1000L;
+            long secondsRunning = (now.getTime() - actionBean.getEngine().getStartTime().getTime())/1000L;
 
             long seconds = secondsRunning % 60;
             long minutes = (secondsRunning /= 60) % 60;
@@ -328,22 +330,22 @@
         }
         else if( name.equals("loginstatus") )
         {
-            WikiSession session = context.getWikiSession();
+            WikiSession session = actionBean.getWikiSession();
             return session.getStatus();
         }
         else if( name.equals("username") )
         {
-            Principal wup = context.getCurrentUser();
+            Principal wup = actionBean.getCurrentUser();
 
             return wup != null ? wup.getName() : "not logged in";
         }
         else if( name.equals("requestcontext") )
         {
-            return context.getRequestContext();
+            return actionBean.getRequestContext();
         }
         else if( name.equals("pagefilters") )
         {
-            List filters = context.getEngine().getFilterManager().getFilterList();
+            List filters = actionBean.getEngine().getFilterManager().getFilterList();
             StringBuffer sb = new StringBuffer();
 
             for( Iterator i = filters.iterator(); i.hasNext(); )
@@ -366,9 +368,9 @@
             // Check if such a context variable exists,
             // returning its string representation.
             //
-            if( (context.getVariable( varName )) != null )
+            if( (actionBean.getVariable( varName )) != null )
             {
-                return context.getVariable( varName ).toString();
+                return actionBean.getVariable( varName ).toString();
             }
 
             //
@@ -376,7 +378,7 @@
             //  variables from the session and the request (in this order).
             //
 
-            HttpServletRequest req = context.getHttpRequest();
+            HttpServletRequest req = actionBean.getContext().getRequest();
             if( req != null && req.getSession() != null )
             {
                 HttpSession session = req.getSession();
@@ -388,7 +390,7 @@
                     if( (s = (String)session.getAttribute( varName )) != null )
                         return s;
 
-                    if( (s = context.getHttpParameter( varName )) != null )
+                    if( (s = actionBean.getContext().getRequest().getParameter( varName )) != null )
                         return s;
                 }
                 catch( ClassCastException e ) {}
@@ -396,23 +398,26 @@
 
             // And the final straw: see if the current page has named metadata.
             
-            WikiPage pg = context.getPage();
-            if( pg != null )
+            if ( actionBean instanceof WikiContext )
             {
-                Object metadata = pg.getAttribute( varName );
-                if( metadata != null )
-                    return metadata.toString();
-            }
+                WikiPage pg = ((WikiContext)actionBean).getPage();
+                if( pg != null )
+                {
+                    Object metadata = pg.getAttribute( varName );
+                    if( metadata != null )
+                        return( metadata.toString() );
+                }
             
-            // And the final straw part 2: see if the "real" current page has
-            // named metadata. This allows a parent page to control a inserted
-            // page through defining variables
-            WikiPage rpg = context.getRealPage();
-            if( rpg != null )
-            {
-                Object metadata = rpg.getAttribute( varName );
-                if( metadata != null )
-                    return metadata.toString();
+	            // And the final straw part 2: see if the "real" current page has
+    	        // named metadata. This allows a parent page to control a inserted
+        	    // page through defining variables
+         	   WikiPage rpg = ((WikiContext)actionBean).getRealPage();
+   				if( rpg != null )
+            	{
+                	Object metadata = rpg.getAttribute( varName );
+                	if( metadata != null )
+                    	return metadata.toString();
+            	}
             }
             
             // Next-to-final straw: attempt to fetch using property name
@@ -422,7 +427,7 @@
             
             if( varName.startsWith("jspwiki.") )
             {
-                Properties props = context.getEngine().getWikiProperties();
+                Properties props = actionBean.getEngine().getWikiProperties();
 
                 String s = props.getProperty( varName );
                 if( s != null )

Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiContext.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiContext.java?rev=630505&r1=630504&r2=630505&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiContext.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/WikiContext.java Sat Feb 23 11:02:00 2008
@@ -19,25 +19,18 @@
  */
 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.Locale;
+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 net.sourceforge.stripes.validation.Validate;
 
 import org.apache.log4j.Logger;
 
-import com.ecyrd.jspwiki.auth.*;
+import com.ecyrd.jspwiki.action.*;
 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.*;
 
 /**
  *  <p>Provides state information throughout the processing of a page.  A
@@ -64,266 +57,106 @@
  *  @author Janne Jalkanen
  *  @author Andrew R. Jaquith
  */
-public class WikiContext
-    implements Cloneable, Command
+public abstract class WikiContext extends AbstractActionBean
+    implements Cloneable
 {
-    private    Command m_command = null;
-
-    private    WikiPage   m_page;
-    private    WikiPage   m_realPage;
-    private    WikiEngine m_engine;
-    private    String     m_template = "default";
-
-    private    Map        m_variableMap = new HashMap();
-
-    /**
-     *  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();
+    private    WikiPage   m_page = null;
+    private    WikiPage   m_realPage = null;
 
+    /** User is administering JSPWiki (Install, SecurityConfig). @deprecated use ActionBean  */
+    public static final String    INSTALL  = InstallActionBean.class.getAnnotation(WikiRequestContext.class).value();
+    
     /** 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     = ViewActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User wants to view or administer workflows. */
-    public static final String    WORKFLOW = WikiCommand.WORKFLOW.getRequestContext();
+    public static final String    WORKFLOW = WorkflowActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** The EDIT context - the user is editing the page. */
-    public static final String    EDIT     = PageCommand.EDIT.getRequestContext();
+    public static final String    EDIT     = EditActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User is preparing for a login/authentication. */
-    public static final String    LOGIN    = WikiCommand.LOGIN.getRequestContext();
+    public static final String    LOGIN    = LoginActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User is preparing to log out. */
-    public static final String    LOGOUT   = WikiCommand.LOGOUT.getRequestContext();
+    public static final String    LOGOUT   = "logout";
 
     /** JSPWiki wants to display a message. */
-    public static final String    MESSAGE  = WikiCommand.MESSAGE.getRequestContext();
+    public static final String    MESSAGE  = MessageActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** 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     = DiffActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User is viewing page history. */
-    public static final String    INFO     = PageCommand.INFO.getRequestContext();
+    public static final String    INFO     = PageInfoActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User is previewing the changes he just made. */
-    public static final String    PREVIEW  = PageCommand.PREVIEW.getRequestContext();
+    public static final String    PREVIEW  = PreviewActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** 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 = PageModifiedActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** 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    = ErrorActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User is uploading something. */
-    public static final String    UPLOAD   = PageCommand.UPLOAD.getRequestContext();
+    public static final String    UPLOAD   = UploadActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User is commenting something. */
-    public static final String    COMMENT  = PageCommand.COMMENT.getRequestContext();
+    public static final String    COMMENT  = CommentActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User is searching for content. */
-    public static final String    FIND     = WikiCommand.FIND.getRequestContext();
+    public static final String    FIND     = SearchActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User wishes to create a new group */
-    public static final String    CREATE_GROUP = WikiCommand.CREATE_GROUP.getRequestContext();
-
+    public static final String    CREATE_GROUP = "createGroup";
+    
     /** User is deleting an existing group. */
-    public static final String    DELETE_GROUP = GroupCommand.DELETE_GROUP.getRequestContext();
-
+    public static final String    DELETE_GROUP = "deleteGroup";
+    
     /** User is editing an existing group. */
-    public static final String    EDIT_GROUP = GroupCommand.EDIT_GROUP.getRequestContext();
-
+    public static final String    EDIT_GROUP = GroupActionBean.class.getAnnotation(WikiRequestContext.class).value();
+    
     /** User is viewing an existing group */
-    public static final String    VIEW_GROUP = GroupCommand.VIEW_GROUP.getRequestContext();
-
+    public static final String    VIEW_GROUP = GroupActionBean.class.getAnnotation(WikiRequestContext.class).value();
+    
     /** User is editing preferences */
-    public static final String    PREFS    = WikiCommand.PREFS.getRequestContext();
-
+    public static final String    PREFS    = UserPreferencesActionBean.class.getAnnotation(WikiRequestContext.class).value();
+    
     /** User is renaming a page. */
-    public static final String    RENAME   = PageCommand.RENAME.getRequestContext();
+    public static final String    RENAME   = RenameActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User is deleting a page or an attachment. */
-    public static final String    DELETE   = PageCommand.DELETE.getRequestContext();
+    public static final String    DELETE   = DeleteActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** User is downloading an attachment. */
-    public static final String    ATTACH   = PageCommand.ATTACH.getRequestContext();
+    public static final String    ATTACH   = AttachActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** RSS feed is being generated. */
-    public static final String    RSS      = PageCommand.RSS.getRequestContext();
+    public static final String    RSS      = RSSActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     /** 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();
+    public static final String    ADMIN    = AdminActionBean.class.getAnnotation(WikiRequestContext.class).value();
 
     private static final Logger   log      = Logger.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>
-     * <p>
-     * After the WikiSession object is obtained, the current authentication
-     * status is checked. If not authenticated, or if the login status reported
-     * by the container has changed, the constructor attempts to log in the user
-     * with
-     * {@link com.ecyrd.jspwiki.auth.AuthenticationManager#login(HttpServletRequest)}.
-     * If an login process throws an exception, this method logs the error but
-     * does not re-throw it.
-     * </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>
+     * Creates a new WikiContext, without a WikiEngine, Request or WikiPage.
      */
-    public WikiContext( WikiEngine engine, HttpServletRequest request, Command command )
-        throws IllegalArgumentException
+    public WikiContext()
     {
         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 );
-        }
-
-        // Log in the user if new session or the container status changed
-        boolean doLogin = (request != null) && m_session.isNew();
-
-        // 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() );
-            log.debug( "Do we need to log the user in? " + doLogin );
-        }
-
-        if( doLogin || m_session.isContainerStatusChanged( request ) )
-        {
-            try
-            {
-                engine.getAuthenticationManager().login( request );
-            }
-            catch ( WikiSecurityException e )
-            {
-                // Login failed because config was screwy
-                log.error( "Could not log in user: " + e.getMessage() );
-            }
-        }
-
-        // Mark the session as "not new"
-        if( m_session.isNew() )
-        {
-            m_session.setNew( false );
-        }
-
-        // 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();
-    }
-
-    /**
-     *  Sets a reference to the real page whose content is currently being
-     *  rendered.
-     *  <p>
      *  Sometimes you may want to render the page using some other page's context.
      *  In those cases, it is highly recommended that you set the setRealPage()
      *  to point at the real page you are rendering.  Please see InsertPageTag
@@ -343,7 +176,6 @@
     {
         WikiPage old = m_realPage;
         m_realPage = page;
-        updateCommand( m_command.getRequestContext() );
         return old;
     }
 
@@ -370,52 +202,11 @@
     }
 
     /**
-     *  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;
-    }
-
-    /**
-     *  Returns the handling engine.
-     *
-     *  @return The wikiengine owning this context.
-     */
-    public WikiEngine getEngine()
-    {
-        return m_engine;
-    }
-
-    /**
-     *  Returns the page that is being handled.
-     *
-     *  @return the page which was fetched.
+     *  Returns the page that is being handled. If the page had not
+     *  been previously set, try to set it to the WikiEngine's
+     *  front page. It is possible that this method will return
+     *  <code>null</code>, so calling classes should check the 
+     *  return value.
      */
     public WikiPage getPage()
     {
@@ -423,82 +214,40 @@
     }
 
     /**
-     *  Sets the page that is being handled.
+     *  Sets the page that is being handled. Calling this
+     *  method also re-sets the "real page" to the same value.
      *
      *  @param page The wikipage
      *  @since 2.1.37.
      */
+    @Validate(required = true)
     public void setPage( WikiPage page )
     {
         m_page = page;
-        updateCommand( m_command.getRequestContext() );
-    }
-
-    /**
-     *  Returns the request context.
-     *  @return The name of the request context (e.g. VIEW).
-     */
-    public String getRequestContext()
-    {
-        return m_command.getRequestContext();
-    }
-
-    /**
-     *  Sets the request context.  See above for the different
-     *  request contexts (VIEW, EDIT, etc.)
-     *
-     *  @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();
-    }
-
-    /**
-     *  Gets a previously set variable.
-     *
-     *  @param key The variable name.
-     *  @return The variable contents.
-     */
-    public Object getVariable( String key )
-    {
-        return m_variableMap.get( key );
+        m_realPage = m_page;
     }
 
     /**
-     *  Sets a variable.  The variable is valid while the WikiContext is valid,
-     *  i.e. while page processing continues.  The variable data is discarded
-     *  once the page processing is finished.
-     *
-     *  @param key The variable name.
-     *  @param data The variable value.
+     * If the WikiPage contains a template attribute ({@link WikiEngine#PROP_TEMPLATEDIR}),
+     * this method returns its value; otherwise, it returns superclass value via
+     * {@link AbstractActionBean#getTemplate()}.
      */
-    public void setVariable( String key, Object data )
+    @Override
+    public String getTemplate()
     {
-        m_variableMap.put( key, data );
-        updateCommand( m_command.getRequestContext() );
+        if ( m_page != null )
+        {
+            String template = (String) m_page.getAttribute(WikiEngine.PROP_TEMPLATEDIR);
+            if ( template != null )
+            {
+                return template;
+            }
+        }
+        return super.getTemplate();
     }
 
     /**
-     *  This method will safely return any HTTP parameters that
+     *  This method will safely return any HTTP parameters that 
      *  might have been defined.  You should use this method instead
      *  of peeking directly into the result of getHttpRequest(), since
      *  this method is smart enough to do all of the right things,
@@ -512,9 +261,9 @@
     {
         String result = null;
 
-        if( m_request != null )
+        if( getContext() != null )
         {
-            result = m_request.getParameter( paramName );
+            result = getContext().getRequest().getParameter( paramName );
         }
 
         return result;
@@ -527,138 +276,45 @@
      *  return null, and YOU SHOULD CHECK FOR IT!
      *
      *  @return Null, if no HTTP request was done.
+     *  @deprecated use the method {@link #getContext()} to obtain the ActionBeanContext,
+     *  and call {@link com.ecyrd.jspwiki.action.WikiActionBeanContext#getRequest()} method.
      *  @since 2.0.13.
      */
     public HttpServletRequest getHttpRequest()
     {
-        return m_request;
-    }
-
-    /**
-     *  Sets the template to be used for this request.
-     *
-     *  @param dir The template name
-     *  @since 2.1.15.
-     */
-    public void setTemplate( String dir )
-    {
-        m_template = dir;
+        return getContext().getRequest();
     }
 
     /**
-     * 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()
+     * Returns the name of the WikiPage associated with this wiki context.
+     * @return the page name
      */
     public String getName()
     {
-        if ( m_command instanceof PageCommand )
-        {
-            return m_page != null ? m_page.getName() : "<no page>";
-        }
-        return m_command.getName();
+        return m_page != null ? m_page.getName() : "<no page>";
     }
 
     /**
-     *  Gets the template that is to be used throughout this request.
-     *  @since 2.1.15.
-     *  @return template name
-     */
-    public String getTemplate()
-    {
-        return m_template;
-    }
-
-    /**
-     *  Convenience method that gets the current user. Delegates the
-     *  lookup to the WikiSession associated with this WikiContect.
-     *  May return null, in case the current
-     *  user has not yet been determined; or this is an internal system.
-     *  If the WikiSession has not been set, <em>always</em> returns null.
-     *
-     *  @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();
-    }
-
-    /**
-     *  A shortcut to generate a VIEW url.
-     *
-     *  @param page The page to which to link.
-     *  @return An URL to the page.  This honours the current absolute/relative setting.
+     * Returns the URL for viewing a named wiki page, without parameters. 
+     * The URL will be encoded via the HttpServletResponse object, 
+     * which means that any outbound filters will be able to transform 
+     * it as needed. The URL returned will be absolute if the WikiEngine
+     * was configured to return absolute URLs; otherwise, the URL will be
+     * relative to the webapp context root.
+     * @param page the wiki page; if <code>null</code>, the front page will be used
+     * @return the URL
      */
     public String getViewURL( String page )
     {
-        return getURL( VIEW, page, null );
-    }
-
-    /**
-     *  Creates an URL for the given request context.
-     *
-     *  @param context e.g. WikiContext.EDIT
-     *  @param page The page to which to link
-     *  @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 );
-    }
-
-    /**
-     *  Returns an URL from a page. It this WikiContext instance was constructed
-     *  with an actual HttpServletRequest, we will attempt to construct the
-     *  URL using HttpUtil, which preserves the HTTPS portion if it was used.
-     *
-     *  @param context The request context (e.g. WikiContext.UPLOAD)
-     *  @param page    The page to which to link
-     *  @param params  A list of parameters, separated with "&amp;"
-     *
-     *  @return An URL to the given context and page.
-     */
-    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;
+        boolean absolute = "absolute".equals(getEngine().getVariable( this, WikiEngine.PROP_REFSTYLE ));
+        return getContext().getURL( ViewActionBean.class, page, null, absolute );
     }
 
     /**
      *  Returns a shallow clone of the WikiContext.
      *
      *  @since 2.1.37.
-     *  @return A shallow clone of the WikiContext
+     *  //TODO: this could be a problem...
      */
     public Object clone()
     {
@@ -668,15 +324,13 @@
             // 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;
+            WikiActionBeanContext context = getContext();
+            copy.setContext( context );
+            String template = getTemplate();
+            copy.setTemplate( template );
             return copy;
         }
         catch( CloneNotSupportedException e ){} // Never happens
@@ -685,172 +339,6 @@
     }
 
     /**
-     *  Returns the WikiSession associated with the context.
-     *  This method is guaranteed to always return a valid WikiSession.
-     *  If this context was constructed without an associated
-     *  HttpServletRequest, it will return {@link WikiSession#guestSession(WikiEngine)}.
-     *
-     *  @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;
-    }
-
-    /**
      *  Returns true, if the current user has administrative permissions (i.e. the omnipotent
      *  AllPermission).
      *
@@ -860,134 +348,10 @@
     public boolean hasAdminPermissions()
     {
         boolean admin = false;
-
-        admin = m_engine.getAuthorizationManager().checkPermission( getWikiSession(),
-                                                                    new AllPermission(m_engine.getApplicationName()) );
-
+        WikiEngine engine = getEngine();
+        admin = engine.getAuthorizationManager().checkPermission( getWikiSession(), 
+                                                                    new AllPermission(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 );
-        }
-    }
-
-    /**
-     *  Locates the i18n ResourceBundle given.  This method interprets
-     *  the request locale, and uses that to figure out which language the
-     *  user wants.
-     *  @see com.ecyrd.jspwiki.i18n.InternationalizationManager
-     *  @param bundle The name of the bundle you are looking for.
-     *  @return A resource bundle object
-     *  @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 = null;
-
-        if( m_request != null )
-            loc = m_request.getLocale();
-
-        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 )
-    {
-        HttpServletRequest request = context.getHttpRequest();
-        return ( request != null )
-                ? request.getLocale() : Locale.getDefault();
     }
 
 }



Mime
View raw message