jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mets...@apache.org
Subject svn commit: r756702 - in /incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH: ChangeLog src/com/ecyrd/jspwiki/Release.java src/com/ecyrd/jspwiki/tags/BreadcrumbsTag.java src/webdocs/Delete.jsp src/webdocs/Rename.jsp
Date Fri, 20 Mar 2009 18:32:58 GMT
Author: metskem
Date: Fri Mar 20 18:32:55 2009
New Revision: 756702

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

Modified:
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/tags/BreadcrumbsTag.java
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/Delete.jsp
    incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/Rename.jsp

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog?rev=756702&r1=756701&r2=756702&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/ChangeLog Fri Mar 20 18:32:55 2009
@@ -1,3 +1,10 @@
+2009-03-20 Harry Metske <metskem@apache.org>
+
+        * 2.8.2-svn-15
+
+        * JSPWIKI-487 don't show deleted and renamed pages in the breadcrumbs
+           reported by Bruno Peeters
+        
 2009-03-19  Andrew Jaquith <ajaquith AT apache DOT org>
 
         * 2.8.2-svn-14

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java?rev=756702&r1=756701&r2=756702&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/Release.java Fri Mar
20 18:32:55 2009
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "14";
+    public static final String     BUILD         = "15";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/tags/BreadcrumbsTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/tags/BreadcrumbsTag.java?rev=756702&r1=756701&r2=756702&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/tags/BreadcrumbsTag.java
(original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/com/ecyrd/jspwiki/tags/BreadcrumbsTag.java
Fri Mar 20 18:32:55 2009
@@ -53,7 +53,8 @@
     private static final long serialVersionUID = 0L;
 
     private static final Logger log = Logger.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 = ", ";
 
@@ -111,37 +112,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 (m_wikiContext.getRequestContext().equals(WikiContext.VIEW))
         {
-            if( trail.isEmpty() )
+            if (m_wikiContext.getEngine().pageExists(page))
             {
-                trail.pushItem(page);
-            }
-            else
-            {
-                //
-                // Don't add the page to the queue if the page was just refreshed
-                //
-                if( !trail.getLast().equals(page) )
+                if (trail.isEmpty())
                 {
                     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");
+                }
+            }
+            else
+            {
+                log.debug("didn't add page because it doesn't exist: " + page);
             }
         }
 
@@ -180,8 +188,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;
@@ -192,7 +200,7 @@
             m_size = size;
         }
 
-        T pushItem(T o)
+        String pushItem(String o)
         {
             add(o);
             if( size() > m_size )
@@ -202,7 +210,23 @@
 
             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);
+                }
+            }
+        }
 
+    }
 }
 

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/Delete.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/Delete.jsp?rev=756702&r1=756701&r2=756702&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/Delete.jsp (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/Delete.jsp Fri Mar 20 18:32:55
2009
@@ -1,5 +1,7 @@
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.tags.BreadcrumbsTag" %>
+<%@ page import="com.ecyrd.jspwiki.tags.BreadcrumbsTag.FixedQueue" %>
 <%@ page import="java.util.*" %>
 <%@ page import="com.ecyrd.jspwiki.attachment.Attachment" %>
 <%@ page errorPage="/Error.jsp" %>
@@ -38,7 +40,15 @@
         log.info("Deleting page "+pagereq+". User="+request.getRemoteUser()+", host="+request.getRemoteAddr()
);
 
         wiki.deletePage( pagereq );
-        response.sendRedirect(wiki.getViewURL(redirTo));
+
+        FixedQueue trail = (FixedQueue) session.getAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY
);
+        if( trail != null )
+        {
+            trail.removeItem( pagereq );
+            session.setAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY, trail );
+        }
+
+        response.sendRedirect(wikiContext.getURL( WikiContext.VIEW, pagereq ) );
         return;
     }
     else if( delete != null )

Modified: incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/Rename.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/Rename.jsp?rev=756702&r1=756701&r2=756702&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/Rename.jsp (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_8_BRANCH/src/webdocs/Rename.jsp Fri Mar 20 18:32:55
2009
@@ -1,5 +1,7 @@
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.tags.BreadcrumbsTag" %>
+<%@ page import="com.ecyrd.jspwiki.tags.BreadcrumbsTag.FixedQueue" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
@@ -37,17 +39,21 @@
         {
             String renamedTo = wiki.renamePage(wikiContext, renameFrom, renameTo, changeReferences);
 
+            FixedQueue trail = (FixedQueue) session.getAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY
);
+            if( trail != null )
+            {
+                trail.removeItem( renameFrom );
+                session.setAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY, trail );
+            }
+
             log.info("Page successfully renamed to '"+renamedTo+"'");
 
             response.sendRedirect( wikiContext.getURL( WikiContext.VIEW, renamedTo ) );
             return;
         }
-        else
-        {
-            wikiSession.addMessage("rename", rb.getString("rename.empty"));
+       wikiSession.addMessage("rename", rb.getString("rename.empty"));
 
-            log.info("Page rename request failed because new page name was left blank");
-        }
+      log.info("Page rename request failed because new page name was left blank");
     }
     catch (WikiException e)
     {



Mime
View raw message