jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r884036 - in /incubator/jspwiki/trunk/src: WebContent/SisterSites.jsp java/org/apache/wiki/action/RSSActionBean.java
Date Wed, 25 Nov 2009 11:07:13 GMT
Author: ajaquith
Date: Wed Nov 25 11:07:13 2009
New Revision: 884036

URL: http://svn.apache.org/viewvc?rev=884036&view=rev
Log:
SisterSites received the Stripes treatment. We didn't need to do it just yet. It's all just
gravy at this point in the release cycle.

Modified:
    incubator/jspwiki/trunk/src/WebContent/SisterSites.jsp
    incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RSSActionBean.java

Modified: incubator/jspwiki/trunk/src/WebContent/SisterSites.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/WebContent/SisterSites.jsp?rev=884036&r1=884035&r2=884036&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/WebContent/SisterSites.jsp (original)
+++ incubator/jspwiki/trunk/src/WebContent/SisterSites.jsp Wed Nov 25 11:07:13 2009
@@ -18,39 +18,5 @@
     specific language governing permissions and limitations
     under the License.  
 --%>
-<%@ page import="java.util.*,org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.log.Logger" %>
-<%@ page import="org.apache.wiki.log.LoggerFactory" %>
-<%@ page import="java.text.*" %>
-<%@ page import="org.apache.wiki.rss.*" %>
-<%@ page import="org.apache.wiki.util.*" %>
-<%!
-    Logger log = LoggerFactory.getLogger("JSPWiki");
-%>
-<%
-    /*
-     *  This JSP creates support for the SisterSites standard,
-     *  as specified by http://usemod.com/cgi-bin/mb.pl?SisterSitesImplementationGuide
-     *
-     *  FIXME: Does not honor the ACL's on the pages.
-     */
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
-    // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, "rss" );
-    
-    Set<String> allPages = wiki.getReferenceManager().findCreated();
-    
-    response.setContentType("text/plain; charset=UTF-8");
-    for( Iterator<String> i = allPages.iterator(); i.hasNext(); )
-    {
-        String pageName = i.next();
-        
-        // Let's not add attachments.
-        // TODO: This is a kludge and not forward-compatible.
-        
-        if( pageName.indexOf("/") != -1 ) continue; 
-        String url = wiki.getViewURL( pageName );
-        
-        out.write( url + " " + pageName + "\n" );
-    }
- %>
\ No newline at end of file
+<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="s" %>
+<s:useActionBean beanclass="org.apache.wiki.action.RSSActionBean" event="sisterSites"
executeResolution="true" id="wikiActionBean" />

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RSSActionBean.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RSSActionBean.java?rev=884036&r1=884035&r2=884036&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RSSActionBean.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/RSSActionBean.java Wed Nov 25
11:07:13 2009
@@ -21,14 +21,23 @@
 
 package org.apache.wiki.action;
 
-import org.apache.wiki.auth.permissions.PagePermission;
-import org.apache.wiki.ui.stripes.HandlerPermission;
-import org.apache.wiki.ui.stripes.WikiRequestContext;
+import java.security.Permission;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletResponse;
 
 import net.sourceforge.stripes.action.HandlesEvent;
 import net.sourceforge.stripes.action.Resolution;
+import net.sourceforge.stripes.action.StreamingResolution;
 import net.sourceforge.stripes.action.UrlBinding;
 
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiSession;
+import org.apache.wiki.auth.AuthorizationManager;
+import org.apache.wiki.auth.permissions.PagePermission;
+import org.apache.wiki.auth.permissions.PermissionFactory;
+import org.apache.wiki.ui.stripes.HandlerPermission;
+import org.apache.wiki.ui.stripes.WikiRequestContext;
 
 @UrlBinding( "/rss.jsp" )
 public class RSSActionBean extends AbstractActionBean
@@ -40,4 +49,43 @@
     {
         return null;
     }
+
+    /**
+     * Generates a StreamingResolution with the names and URLs of all pages the
+     * user as has access to, following the SisterSites standard. This event
+     * method respects ACLs on pages.
+     * 
+     * @see http://usemod.com/cgi-bin/mb.pl?SisterSitesImplementationGuide
+     * @return
+     */
+    @HandlesEvent( "sisterSites" )
+    public Resolution sisterSites()
+    {
+        Resolution r = new StreamingResolution( "text/plain; charset=UTF-8" )
+        {
+            @SuppressWarnings("deprecation")
+            @Override
+            protected void stream( HttpServletResponse response ) throws Exception
+            {
+                WikiEngine engine = getContext().getEngine();
+                AuthorizationManager mgr = engine.getAuthorizationManager();
+                WikiSession session = getContext().getWikiSession();
+                Set<String> allPages = engine.getReferenceManager().findCreated();
+                for( String page : allPages )
+                {
+                    if( page.indexOf( "/" ) == -1 )
+                    {
+                        Permission permission = PermissionFactory.getPagePermission( page,
PagePermission.VIEW_ACTION );
+                        if ( mgr.checkPermission( session, permission ) )
+                        {
+                            String url = engine.getViewURL( page );
+                            response.getWriter().write( url + " " + page + "\n" );
+                        }
+                    }
+                }
+            }
+            
+        };
+        return r;
+    }
 }



Mime
View raw message