portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r372587 - in /portals/jetspeed-2/trunk: components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/ components/portal/src/java/org/apache/jetspeed/profiler/impl/ jetspeed-api/src/java/org/apache/jetspeed/portalsite/ src/webapp/WEB-...
Date Thu, 26 Jan 2006 19:09:17 GMT
Author: rwatler
Date: Thu Jan 26 11:09:11 2006
New Revision: 372587

URL: http://svn.apache.org/viewcvs?rev=372587&view=rev
Log:
added root folder/page fallback control to portal-site component and profiler valve: allows
requested page acceee to fail with 403/404 in valve w/o automatic fallback

Modified:
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
    portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/pipelines.xml

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java?rev=372587&r1=372586&r2=372587&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
Thu Jan 26 11:09:11 2006
@@ -56,6 +56,12 @@
     private Map requestProfileLocators;
 
     /**
+     * requestFallback - flag indicating whether request should fallback to root folder
+     *                   if locators do not select a page or access is forbidden
+     */
+    private boolean requestFallback;
+
+    /**
      * page - cached request profiled page proxy
      */
     private Page requestPage;
@@ -112,10 +118,11 @@
      * @param sessionContext session context
      * @param requestProfileLocators request profile locators
      */
-    public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map
requestProfileLocators)
+    public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map
requestProfileLocators, boolean requestFallback)
     {
         this.sessionContext = sessionContext;
         this.requestProfileLocators = requestProfileLocators;
+        this.requestFallback = requestFallback;
     }
 
     /**
@@ -165,7 +172,7 @@
         // cached in this context
         if (requestPage == null)
         {
-            requestPage = sessionContext.selectRequestPage(requestProfileLocators);     
      
+            requestPage = sessionContext.selectRequestPage(requestProfileLocators, requestFallback);
           
         }
         return requestPage;
     }

Modified: portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java?rev=372587&r1=372586&r2=372587&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal-site/src/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
Thu Jan 26 11:09:11 2006
@@ -118,26 +118,41 @@
     }
 
     /**
-     * newRequestContext - create a new request context instance
+     * newRequestContext - create a new request context instance with fallback
      *
      * @param requestProfileLocators request profile locators
      * @return new request context instance
      */
     public PortalSiteRequestContext newRequestContext(Map requestProfileLocators)
     {
+        return newRequestContext(requestProfileLocators, true);
+    }
+
+    /**
+     * newRequestContext - create a new request context instance
+     *
+     * @param requestProfileLocators request profile locators
+     * @param requestFallback flag specifying whether to fallback to root folder
+     *                        if locators do not select a page or access is forbidden
+     * @return new request context instance
+     */
+    public PortalSiteRequestContext newRequestContext(Map requestProfileLocators, boolean
requestFallback)
+    {
         // TODO - potentially cache N request contexts and reuse
-        return new PortalSiteRequestContextImpl(this, requestProfileLocators);
+        return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestFallback);
     }
 
     /**
      * selectRequestPage - select page proxy for request given profile locators
      *
      * @param requestProfileLocators map of profile locators for request
+     * @param requestFallback flag specifying whether to fallback to root folder
+     *                        if locators do not select a page or access is forbidden
      * @return selected page proxy for request
      * @throws NodeNotFoundException if not found
      * @throws SecurityException if view access not granted
      */
-    public Page selectRequestPage(Map requestProfileLocators) throws NodeNotFoundException
+    public Page selectRequestPage(Map requestProfileLocators, boolean requestFallback) throws
NodeNotFoundException
     {
         // validate and update session profile locators if modified
         if (updateSessionProfileLocators(requestProfileLocators))
@@ -170,14 +185,14 @@
             }
             catch (NodeNotFoundException nnfe)
             {
-                if (requestPath.equals(Folder.PATH_SEPARATOR))
+                if (!requestFallback || requestPath.equals(Folder.PATH_SEPARATOR))
                 {
                     throw nnfe;
                 }
             }
             catch (SecurityException se)
             {
-                if (requestPath.equals(Folder.PATH_SEPARATOR))
+                if (!requestFallback || requestPath.equals(Folder.PATH_SEPARATOR))
                 {
                     throw se;
                 }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java?rev=372587&r1=372586&r2=372587&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
Thu Jan 26 11:09:11 2006
@@ -84,17 +84,25 @@
     private PageManager pageManager;
    
     /**
+     * requestFallback - flag indicating whether request should fallback to root folder
+     *                   if locators do not select a page or access is forbidden
+     */
+    private boolean requestFallback;
+
+    /**
      * ProfilerValveImpl - constructor
      *
      * @param profiler profiler component reference
      * @param portalSite portal site component reference
      * @param pageManager page manager component reference
+     * @param requestFallback flag to enable root folder fallback
      */
-    public ProfilerValveImpl( Profiler profiler, PortalSite portalSite, PageManager pageManager
)
+    public ProfilerValveImpl( Profiler profiler, PortalSite portalSite, PageManager pageManager,
boolean requestFallback )
     {
         this.profiler = profiler;
         this.portalSite = portalSite;
         this.pageManager = pageManager;
+        this.requestFallback = requestFallback;
     }
      
     /*
@@ -152,7 +160,13 @@
             // and portal site components
             if (locators != null)
             {
-                // get or create portalsite session context
+                // get or create portalsite session context; the session
+                // context maintains the user view of the site and is
+                // searched against to locate the requested page and
+                // used to build site menus from its extent; this is
+                // cached in the session because locators seldom change
+                // during the session so the session view of the site can
+                // be cached unless locators do change;
                 PortalSiteSessionContext sessionContext = (PortalSiteSessionContext)request.getSessionAttribute(PORTAL_SITE_SESSION_CONTEXT_ATTR_KEY);
                 if (sessionContext == null)
                 {
@@ -161,8 +175,15 @@
                 }
 
                 // construct and save a new portalsite request context
-                // using session context and locators map
-                PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators);
+                // using session context, locators map, and fallback; the
+                // request context uses the locators to initialize or resets
+                // the session context if locators have changed for this
+                // request; the request context also acts as a short term
+                // request cache for the selected page and built menus;
+                // however, creating the request context here does not
+                // select the page or build menus: that is done when the
+                // request context is accessed subsequently
+                PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators,
requestFallback);
                 request.setAttribute(PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY, requestContext);
 
                 // additionally save request context under legacy key
@@ -170,7 +191,14 @@
                 request.setAttribute(PROFILED_PAGE_CONTEXT_ATTR_KEY, requestContext);
 
                 // get profiled page from portalsite request context
-                // and save profile locators map
+                // and save profile locators map; accessing the request
+                // context here and in subsequent valves/decorators
+                // latently selects the page and builds menus from the
+                // user site view using the request context locators;
+                // the managed page accesed here is the raw selected page
+                // as returned by the PageManager component; accessing
+                // the managed page here selects the current page for the
+                // request
                 request.setPage(new ContentPageImpl(requestContext.getManagedPage()));
                 request.setProfileLocators(requestContext.getLocators());
             }
@@ -180,6 +208,12 @@
         }
         catch (SecurityException se)
         {
+            // fallback to portal root folder/default page if
+            // no user is available and request path is not
+            // already attempting to access the root folder;
+            // this is rarely the case since the anonymous
+            // user is normally defined unless the default
+            // security system has been replaced/overridden
             if (request.getRequest().getUserPrincipal() == null &&
                 request.getPath() != null &&
                 !request.getPath().equals("/"))
@@ -191,6 +225,8 @@
                 catch (IOException ioe){}
                 return;
             }
+
+            // return standard HTTP 403 - FORBIDDEN status
             log.error(se.getMessage(), se);
             try
             {                
@@ -203,6 +239,7 @@
         }
         catch (NodeNotFoundException nnfe)
         {
+            // return standard HTTP 404 - NOT FOUND status
             log.error(nnfe.getMessage(), nnfe);
             try
             {

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java?rev=372587&r1=372586&r2=372587&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java
(original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java
Thu Jan 26 11:09:11 2006
@@ -28,12 +28,22 @@
 public interface PortalSiteSessionContext
 {
     /**
-     * newRequestContext - create a new request context instance
+     * newRequestContext - create a new request context instance with fallback
      *
      * @param requestProfileLocators request profile locators
      * @return new request context instance
      */
     PortalSiteRequestContext newRequestContext(Map requestProfileLocators);
+
+    /**
+     * newRequestContext - create a new request context instance
+     *
+     * @param requestProfileLocators request profile locators
+     * @param requestFallback flag specifying whether to fallback to root folder
+     *                        if locators do not select a page or access is forbidden
+     * @return new request context instance
+     */
+    PortalSiteRequestContext newRequestContext(Map requestProfileLocators, boolean requestFallback);
 
     /**
      * getPageManager - return PageManager component instance

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/pipelines.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/pipelines.xml?rev=372587&r1=372586&r2=372587&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/pipelines.xml (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/pipelines.xml Thu Jan 26 11:09:11
2006
@@ -73,15 +73,21 @@
         class="org.apache.jetspeed.profiler.impl.ProfilerValveImpl"
         init-method="initialize"
   >
-   <constructor-arg>
+   <constructor-arg index="0">
        <ref bean="org.apache.jetspeed.profiler.Profiler" />
    </constructor-arg>
-   <constructor-arg>
+   <constructor-arg index="1">
        <ref bean="org.apache.jetspeed.portalsite.PortalSite" />
    </constructor-arg>
-   <constructor-arg>
+   <constructor-arg index="2">
        <ref bean="org.apache.jetspeed.page.PageManager" />
    </constructor-arg>
+   <!--
+       request fallback to root folder/page enabled by default;
+       if set to false, requests generate HTTP 403/404 errors
+       for access errors or missing pages
+   -->
+   <constructor-arg index="3"><value>true</value></constructor-arg>
   
   </bean> 
   
   <bean id="containerValve"



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message