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 2009/04/20 00:23:05 UTC

svn commit: r766533 - in /incubator/jspwiki/trunk/src/java/org/apache/wiki/tags: InsertPageTag.java LinkTag.java

Author: ajaquith
Date: Sun Apr 19 22:23:05 2009
New Revision: 766533

URL: http://svn.apache.org/viewvc?rev=766533&view=rev
Log:
Fixed bug in InsertPageTag caused by recent introduction of PageNotFoundException, that was causing content not to be properly inserted. Fixed bugs with similar cause in LinkTag.

Modified:
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertPageTag.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertPageTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertPageTag.java?rev=766533&r1=766532&r2=766533&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertPageTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/InsertPageTag.java Sun Apr 19 22:23:05 2009
@@ -95,49 +95,41 @@
                ProviderException
     {
         WikiEngine engine = m_wikiContext.getEngine();
-        WikiPage   insertedPage;
+        WikiPage   insertedPage = null;
 
-        //
-        //  NB: The page might not really exist if the user is currently
-        //      creating it (i.e. it is not yet in the cache or providers), 
-        //      AND we got the page from the wikiContext.
-        //
-
-        if( m_pageName == null )
+        try
+        {
+            insertedPage = m_pageName == null ? m_wikiContext.getPage() : engine.getPage( m_pageName );
+        }
+        catch ( PageNotFoundException e )
         {
-            insertedPage = m_wikiContext.getPage();
-            if( !engine.pageExists(insertedPage) ) return SKIP_BODY;
+            // Couldn't find either the context page, or the one supplied to the tag. Oops!
         }
-        else
+        
+        if( insertedPage == null )
         {
-            try
-            {
-                insertedPage = engine.getPage( m_pageName );
-                // FIXME: Do version setting later.
-                // page.setVersion( WikiProvider.LATEST_VERSION );
+            return SKIP_BODY;
+        }
+        
+        // FIXME: Do version setting later.
+        // page.setVersion( WikiProvider.LATEST_VERSION );
 
-                log.debug("Inserting page "+insertedPage);
+        log.debug("Inserting page "+insertedPage);
 
-                JspWriter out = pageContext.getOut();
+        JspWriter out = pageContext.getOut();
 
-                WikiPage oldPage = m_wikiContext.setRealPage( insertedPage );
-                
-                switch( m_mode )
-                {
-                  case HTML:
-                    out.print( engine.getHTML( m_wikiContext, insertedPage ) );
-                    break;
-                  case PLAIN:
-                    out.print( engine.getText( m_wikiContext, insertedPage ) );
-                    break;
-                }
-                m_wikiContext.setRealPage( oldPage );
-            }
-            catch( PageNotFoundException e )
-            {
-                // No worries. Nothing to include here...
-            }
+        WikiPage oldPage = m_wikiContext.setRealPage( insertedPage );
+        
+        switch( m_mode )
+        {
+          case HTML:
+            out.print( engine.getHTML( m_wikiContext, insertedPage ) );
+            break;
+          case PLAIN:
+            out.print( engine.getText( m_wikiContext, insertedPage ) );
+            break;
         }
+        m_wikiContext.setRealPage( oldPage );
 
         return SKIP_BODY;
     }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java?rev=766533&r1=766532&r2=766533&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/LinkTag.java Sun Apr 19 22:23:05 2009
@@ -282,13 +282,22 @@
         }
         else if( m_pageName != null && m_pageName.length() > 0 )
         {
-            WikiPage p = engine.getPage( m_pageName );
+            WikiPage p = null;
+            try
+            {
+                p = engine.getPage( m_pageName );
+            }
+            catch ( PageNotFoundException e )
+            {
+                // Page doesn't exist yet, but that's ok; make sure version is null
+                m_version = null;
+            }
 
             String parms = (m_version != null) ? "version="+getVersion() : null;
 
             parms = addParamsForRecipient( parms, m_containedParams );
 
-            if( p.isAttachment() )
+            if( p != null && p.isAttachment() )
             {
                 String ctx = m_context;
                 // Switch context appropriately when attempting to view an