Return-Path: Delivered-To: apmail-portals-jetspeed-dev-archive@www.apache.org Received: (qmail 672 invoked from network); 26 Jan 2006 19:09:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Jan 2006 19:09:44 -0000 Received: (qmail 13388 invoked by uid 500); 26 Jan 2006 19:09:41 -0000 Delivered-To: apmail-portals-jetspeed-dev-archive@portals.apache.org Received: (qmail 13357 invoked by uid 500); 26 Jan 2006 19:09:41 -0000 Mailing-List: contact jetspeed-dev-help@portals.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@portals.apache.org Received: (qmail 13346 invoked by uid 99); 26 Jan 2006 19:09:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jan 2006 11:09:41 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 26 Jan 2006 11:09:40 -0800 Received: (qmail 484 invoked by uid 65534); 26 Jan 2006 19:09:19 -0000 Message-ID: <20060126190919.483.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: jetspeed-dev@portals.apache.org From: rwatler@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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" > - + - + - + + + true