jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mets...@apache.org
Subject svn commit: r759675 - in /incubator/jspwiki/trunk: ./ src/java/org/apache/wiki/ src/java/org/apache/wiki/action/ src/java/org/apache/wiki/tags/
Date Sun, 29 Mar 2009 13:00:25 GMT
Author: metskem
Date: Sun Mar 29 13:00:24 2009
New Revision: 759675

URL: http://svn.apache.org/viewvc?rev=759675&view=rev
Log:
3.0.0-svn-89  JSPWIKI-487 don't show deleted and renamed pages in the breadcrumbs, reported
by Bruno Peeters

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/AbstractPageActionBean.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RenameActionBean.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/BreadcrumbsTag.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=759675&r1=759674&r2=759675&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Mar 29 13:00:24 2009
@@ -1,3 +1,10 @@
+2009-03-29  Harry Metske <metskem@apache.org>
+
+        * 3.0.0-svn-89
+        
+        * JSPWIKI-487 don't show deleted and renamed pages in the breadcrumbs
+           reported by Bruno Peeters
+           
 2009-03-28  Janne Jalkanen <jalkanen@apache.org>
 
         * 3.0.0-svn-88

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=759675&r1=759674&r2=759675&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Sun Mar 29 13:00:24 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "88";
+    public static final String     BUILD         = "89";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/AbstractPageActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/AbstractPageActionBean.java?rev=759675&r1=759674&r2=759675&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/AbstractPageActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/AbstractPageActionBean.java Sun
Mar 29 13:00:24 2009
@@ -21,9 +21,13 @@
 
 package org.apache.wiki.action;
 
+import javax.servlet.http.HttpSession;
+
 import net.sourceforge.stripes.validation.Validate;
 
 import org.apache.wiki.api.WikiPage;
+import org.apache.wiki.tags.BreadcrumbsTag;
+import org.apache.wiki.tags.BreadcrumbsTag.FixedQueue;
 
 /**
  * Abstract {@link WikiActionBean} subclass used by all ActionBeans that use and
@@ -68,4 +72,23 @@
         getContext().setPage( page );
     }
 
+    /**
+     * Removes the deleted page from the breadCrumb trail
+     * 
+     * @param pageName the pageName to be removed from the breadcrumb
+     */
+    void deleteFromBreadCrumb( String pageName )
+    {
+        HttpSession session = getContext().getRequest().getSession( false );
+        if( session != null )
+        {
+            FixedQueue trail = (FixedQueue) session.getAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY
);
+            if( trail != null )
+            {
+                trail.removeItem( pageName );
+                session.setAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY, trail );
+            }
+        }
+    }
+
 }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java?rev=759675&r1=759674&r2=759675&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/DeleteActionBean.java Sun Mar
29 13:00:24 2009
@@ -48,7 +48,7 @@
 @UrlBinding( "/Delete.jsp" )
 public class DeleteActionBean extends AbstractPageActionBean
 {
-    private Logger log = LoggerFactory.getLogger( DeleteActionBean.class );
+    private static final Logger log = LoggerFactory.getLogger( DeleteActionBean.class );
 
     private int m_version = Integer.MIN_VALUE;
 
@@ -76,8 +76,9 @@
             log.info( "Deleting page " + pageName + ". User=" + request.getRemoteUser() +
", host="
                       + request.getRemoteAddr() );
             engine.deletePage( pageName );
+            
+            deleteFromBreadCrumb( pageName );
         }
-
         // Just delete a single version
         else
         {

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RenameActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RenameActionBean.java?rev=759675&r1=759674&r2=759675&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RenameActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RenameActionBean.java Sun Mar
29 13:00:24 2009
@@ -121,6 +121,8 @@
         log.info( "Page rename request for page '" + renameFrom + "' to new name '" + m_renameTo
+ "' from "
                   + request.getRemoteAddr() + " by " + request.getRemoteUser() );
         String renamedTo = engine.renamePage( getContext(), renameFrom, m_renameTo, m_changeReferences
);
+        
+        deleteFromBreadCrumb( renameFrom );
         log.info( "Page successfully renamed to '" + renamedTo + "'" );
         
         return new RedirectResolution( ViewActionBean.class ).addParameter( "page", renamedTo
);

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/BreadcrumbsTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/BreadcrumbsTag.java?rev=759675&r1=759674&r2=759675&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/BreadcrumbsTag.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/tags/BreadcrumbsTag.java Sun Mar 29 13:00:24
2009
@@ -55,7 +55,9 @@
     private static final long serialVersionUID = 0L;
 
     private static final Logger log = LoggerFactory.getLogger(BreadcrumbsTag.class);
-    private static final String BREADCRUMBTRAIL_KEY = "breadCrumbTrail";
+    
+    /** The name of the session attribute representing the breadcrumbtrail */
+    public static final String BREADCRUMBTRAIL_KEY = "breadCrumbTrail";
     private int m_maxQueueSize = 11;
     private String m_separator = ", ";
 
@@ -113,37 +115,44 @@
     /**
      *  {@inheritDoc}
      */
-    @SuppressWarnings("unchecked")
     @Override
     public int doWikiStartTag() throws IOException
     {
         HttpSession session = pageContext.getSession();
-        FixedQueue<String>  trail = (FixedQueue<String>) session.getAttribute(BREADCRUMBTRAIL_KEY);
+        FixedQueue  trail = (FixedQueue) session.getAttribute(BREADCRUMBTRAIL_KEY);
 
         String page = m_wikiContext.getPage().getName();
 
         if( trail == null )
         {
-            trail = new FixedQueue<String>(m_maxQueueSize);
+            trail = new FixedQueue(m_maxQueueSize);
         }
 
         if( m_wikiContext.getRequestContext().equals( WikiContext.VIEW ) )
         {
-            if( trail.isEmpty() )
+            if( m_wikiContext.getEngine().pageExists( page ) )
             {
-                trail.pushItem(page);
+                if( trail.isEmpty() )
+                {
+                    trail.pushItem( page );
+                }
+                else
+                {
+                    //
+                    // Don't add the page to the queue if the page was just
+                    // refreshed
+                    //
+                    if( !trail.getLast().equals( page ) )
+                    {
+                        trail.pushItem( page );
+                        log.debug( "added page: " + page );
+                    }
+                    log.debug( "didn't add page because of refresh" );
+                }
             }
             else
             {
-                //
-                // Don't add the page to the queue if the page was just refreshed
-                //
-                if( !trail.getLast().equals(page) )
-                {
-                    trail.pushItem(page);
-                    log.debug("added page: " + page);
-                }
-                log.debug("didn't add page because of refresh");
+                log.debug( "didn't add page because it doesn't exist: " + page );
             }
         }
 
@@ -182,8 +191,8 @@
     /**
      * Extends the LinkedList class to provide a fixed-size queue implementation
      */
-    public static class FixedQueue<T>
-        extends LinkedList<T>
+    public static class FixedQueue
+        extends LinkedList<String>
         implements Serializable
     {
         private int m_size;
@@ -194,16 +203,30 @@
             m_size = size;
         }
 
-        T pushItem(T o)
+        String pushItem(String pageName)
         {
-            add(o);
+            add(pageName);
             if( size() > m_size )
             {
                 return removeFirst();
             }
-
             return null;
         }
+        
+        /**
+         * @param pageName the page to be deleted from the breadcrumb
+         */
+        public void removeItem( String pageName )
+        {
+            for( int i = 0; i < size(); i++ )
+            {
+                String page = get( i );
+                if( page != null && page.equals( pageName ) )
+                {
+                    remove( page );
+                }
+            }
+        }
     }
 
 }



Mime
View raw message