You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by rw...@apache.org on 2010/03/12 21:33:04 UTC
svn commit: r922416 [1/2] - in /portals/jetspeed-2/portal/trunk:
components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/
components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/
components/jetspeed-p...
Author: rwatler
Date: Fri Mar 12 20:33:04 2010
New Revision: 922416
URL: http://svn.apache.org/viewvc?rev=922416&view=rev
Log:
Portal Site Enhancements to support subsite user registration and PSML access
-----------------------------------------------------------------------------
- implement portal site site view method to return fully qualified PageManager PSML path
to user folder
- implement portal site site view method to return fully qualified PageManager PSML path
to portal root base folder
- remove current user principal access code, (Subject, SubjectHelper, etc.), from portal
site component to allow standalone PortalSiteSessionContext and PortalSiteRequestContext
instances used to register new portal users in subsite
Modified:
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/AbstractSiteView.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/PhysicalSiteView.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewSearchPath.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/AbstractPageValveImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/PageValveImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/request/JetspeedRequestContext.java
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/portalsite/PortalSiteRequestContext.java
portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/portalsite/PortalSiteSessionContext.java
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java?rev=922416&r1=922415&r2=922416&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteRequestContextImpl.java Fri Mar 12 20:33:04 2010
@@ -71,6 +71,11 @@ public class PortalSiteRequestContextImp
private String requestServerName;
/**
+ * requestUserPrincipal - request user principal name
+ */
+ private String requestUserPrincipal;
+
+ /**
* requestFallback - flag indicating whether request should fallback to root folder
* if locators do not select a page or access is forbidden
*/
@@ -168,16 +173,18 @@ public class PortalSiteRequestContextImp
*
* @param sessionContext session context
* @param requestProfileLocators request profile locators
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
* @param useHistory flag indicating whether to use visited page
* history to select default page per site folder
* @param forceReservedVisible force reserved/hidden folders visible in site view
*/
- public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators, boolean requestFallback, boolean useHistory, boolean forceReservedVisible)
+ public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators, String requestUserPrincipal, boolean requestFallback, boolean useHistory, boolean forceReservedVisible)
{
this.sessionContext = sessionContext;
this.requestProfileLocators = requestProfileLocators;
+ this.requestUserPrincipal = requestUserPrincipal;
this.requestFallback = requestFallback;
this.useHistory = useHistory;
this.forceReservedVisible = forceReservedVisible;
@@ -188,14 +195,15 @@ public class PortalSiteRequestContextImp
*
* @param sessionContext session context
* @param requestProfileLocators request profile locators
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
* @param useHistory flag indicating whether to use visited page
* history to select default page per site folder
*/
- public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators, boolean requestFallback, boolean useHistory)
+ public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators, String requestUserPrincipal, boolean requestFallback, boolean useHistory)
{
- this(sessionContext, requestProfileLocators, requestFallback, useHistory, false);
+ this(sessionContext, requestProfileLocators, requestUserPrincipal, requestFallback, useHistory, false);
}
/**
@@ -203,12 +211,13 @@ public class PortalSiteRequestContextImp
*
* @param sessionContext session context
* @param requestProfileLocators request profile locators
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
*/
- public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators, boolean requestFallback)
+ public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators, String requestUserPrincipal, boolean requestFallback)
{
- this(sessionContext, requestProfileLocators, requestFallback, true, false);
+ this(sessionContext, requestProfileLocators, requestUserPrincipal, requestFallback, true, false);
}
/**
@@ -216,10 +225,11 @@ public class PortalSiteRequestContextImp
*
* @param sessionContext session context
* @param requestProfileLocators request profile locators
+ * @param requestUserPrincipal request user principal
*/
- public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators)
+ public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, Map requestProfileLocators, String requestUserPrincipal)
{
- this(sessionContext, requestProfileLocators, true, true, false);
+ this(sessionContext, requestProfileLocators, requestUserPrincipal, true, true, false);
}
/**
@@ -228,16 +238,18 @@ public class PortalSiteRequestContextImp
* @param sessionContext session context
* @param requestPath request path
* @param requestServerName request server name
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
* @param useHistory flag indicating whether to use visited page
* history to select default page per site folder
*/
- public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, String requestPath, String requestServerName, boolean requestFallback, boolean useHistory)
+ public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, String requestPath, String requestServerName, String requestUserPrincipal, boolean requestFallback, boolean useHistory)
{
this.sessionContext = sessionContext;
this.requestPath = requestPath;
this.requestServerName = requestServerName;
+ this.requestUserPrincipal = requestUserPrincipal;
this.requestFallback = requestFallback;
this.useHistory = useHistory;
}
@@ -248,12 +260,13 @@ public class PortalSiteRequestContextImp
* @param sessionContext session context
* @param requestPath request path
* @param requestServerName request server name
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
*/
- public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, String requestPath, String requestServerName, boolean requestFallback)
+ public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, String requestPath, String requestServerName, String requestUserPrincipal, boolean requestFallback)
{
- this(sessionContext, requestPath, requestServerName, requestFallback, true);
+ this(sessionContext, requestPath, requestServerName, requestUserPrincipal, requestFallback, true);
}
/**
@@ -262,10 +275,11 @@ public class PortalSiteRequestContextImp
* @param sessionContext session context
* @param requestPath request path
* @param requestServerName request server name
+ * @param requestUserPrincipal request user principal
*/
- public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, String requestPath, String requestServerName)
+ public PortalSiteRequestContextImpl(PortalSiteSessionContextImpl sessionContext, String requestPath, String requestServerName, String requestUserPrincipal)
{
- this(sessionContext, requestPath, requestServerName, true, true);
+ this(sessionContext, requestPath, requestServerName, requestUserPrincipal, true, true);
}
/**
@@ -379,11 +393,11 @@ public class PortalSiteRequestContextImp
String [] selectedRequestPageContentPath = new String[]{null};
if (requestProfileLocators != null)
{
- requestPage = sessionContext.selectRequestPage(requestProfileLocators, requestFallback, useHistory, forceReservedVisible, selectedRequestPageContentPath);
+ requestPage = sessionContext.selectRequestPage(requestProfileLocators, requestUserPrincipal, requestFallback, useHistory, forceReservedVisible, selectedRequestPageContentPath);
}
else
{
- requestPage = sessionContext.selectRequestPage(requestPath, requestServerName, requestFallback, useHistory, selectedRequestPageContentPath);
+ requestPage = sessionContext.selectRequestPage(requestPath, requestServerName, requestUserPrincipal, requestFallback, useHistory, selectedRequestPageContentPath);
}
if (requestPage != null)
{
@@ -686,11 +700,11 @@ public class PortalSiteRequestContextImp
{
if (requestProfileLocators != null)
{
- requestRootFolder = sessionContext.getRequestRootFolder(requestProfileLocators, forceReservedVisible);
+ requestRootFolder = sessionContext.getRequestRootFolder(requestProfileLocators, requestUserPrincipal, forceReservedVisible);
}
else
{
- requestRootFolder = sessionContext.getRequestRootFolder();
+ requestRootFolder = sessionContext.getRequestRootFolder(requestUserPrincipal);
}
}
return requestRootFolder;
@@ -910,6 +924,26 @@ public class PortalSiteRequestContextImp
}
return null;
}
+
+ /**
+ * getUserFolderPath - return primary concrete root user folder path
+ *
+ * @return user folder path or null
+ */
+ public String getUserFolderPath()
+ {
+ return sessionContext.getUserFolderPath(requestProfileLocators, requestUserPrincipal, forceReservedVisible);
+ }
+
+ /**
+ * getBaseFolderPath - return primary concrete root base folder path
+ *
+ * @return base folder path or null
+ */
+ public String getBaseFolderPath()
+ {
+ return sessionContext.getBaseFolderPath(requestProfileLocators, requestUserPrincipal, forceReservedVisible);
+ }
/**
* filterHiddenNodes - utility to filter hidden node views out of node sets
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java?rev=922416&r1=922415&r2=922416&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/impl/PortalSiteSessionContextImpl.java Fri Mar 12 20:33:04 2010
@@ -17,15 +17,12 @@
package org.apache.jetspeed.portalsite.impl;
import java.io.Serializable;
-import java.security.AccessController;
-import java.security.Principal;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.security.auth.Subject;
import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
@@ -161,45 +158,49 @@ public class PortalSiteSessionContextImp
* newRequestContext - create a new request context instance with fallback and history
*
* @param requestProfileLocators request profile locators
+ * @param requestUserPrincipal request user principal
* @return new request context instance
*/
- public PortalSiteRequestContext newRequestContext(Map requestProfileLocators)
+ public PortalSiteRequestContext newRequestContext(Map requestProfileLocators, String requestUserPrincipal)
{
- return new PortalSiteRequestContextImpl(this, requestProfileLocators, true, true, false);
+ return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestUserPrincipal, true, true, false);
}
/**
* newRequestContext - create a new request context instance with history
*
* @param requestProfileLocators request profile locators
+ * @param requestUserPrincipal request user principal
* @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)
+ public PortalSiteRequestContext newRequestContext(Map requestProfileLocators, String requestUserPrincipal, boolean requestFallback)
{
- return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestFallback, true, false);
+ return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestUserPrincipal, requestFallback, true, false);
}
/**
* newRequestContext - create a new request context instance
*
* @param requestProfileLocators request profile locators
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
* @param useHistory flag indicating whether to use visited page
* history to select default page per site folder
* @return new request context instance
*/
- public PortalSiteRequestContext newRequestContext(Map requestProfileLocators, boolean requestFallback, boolean useHistory)
+ public PortalSiteRequestContext newRequestContext(Map requestProfileLocators, String requestUserPrincipal, boolean requestFallback, boolean useHistory)
{
- return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestFallback, useHistory, false);
+ return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestUserPrincipal, requestFallback, useHistory, false);
}
/**
* newRequestContext - create a new request context instance
*
* @param requestProfileLocators request profile locators
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
* @param useHistory flag indicating whether to use visited page
@@ -207,9 +208,9 @@ public class PortalSiteSessionContextImp
* @param forceReservedVisible force reserved/hidden folders visible in site view
* @return new request context instance
*/
- public PortalSiteRequestContext newRequestContext(Map requestProfileLocators, boolean requestFallback, boolean useHistory, boolean forceReservedVisible)
+ public PortalSiteRequestContext newRequestContext(Map requestProfileLocators, String requestUserPrincipal, boolean requestFallback, boolean useHistory, boolean forceReservedVisible)
{
- return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestFallback, useHistory, forceReservedVisible);
+ return new PortalSiteRequestContextImpl(this, requestProfileLocators, requestUserPrincipal, requestFallback, useHistory, forceReservedVisible);
}
/**
@@ -218,11 +219,12 @@ public class PortalSiteSessionContextImp
*
* @param requestPath request path
* @param requestServerName request server name
+ * @param requestUserPrincipal request user principal
* @return new request context instance
*/
- public PortalSiteRequestContext newRequestContext(String requestPath, String requestServerName)
+ public PortalSiteRequestContext newRequestContext(String requestPath, String requestServerName, String requestUserPrincipal)
{
- return new PortalSiteRequestContextImpl(this, requestPath, requestServerName, true, true);
+ return new PortalSiteRequestContextImpl(this, requestPath, requestServerName, requestUserPrincipal, true, true);
}
/**
@@ -231,13 +233,14 @@ public class PortalSiteSessionContextImp
*
* @param requestPath request path
* @param requestServerName request server name
+ * @param requestUserPrincipal request user principal
* @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(String requestPath, String requestServerName, boolean requestFallback)
+ public PortalSiteRequestContext newRequestContext(String requestPath, String requestServerName, String requestUserPrincipal, boolean requestFallback)
{
- return new PortalSiteRequestContextImpl(this, requestPath, requestServerName, requestFallback, true);
+ return new PortalSiteRequestContextImpl(this, requestPath, requestServerName, requestUserPrincipal, requestFallback, true);
}
/**
@@ -246,15 +249,16 @@ public class PortalSiteSessionContextImp
*
* @param requestPath request path
* @param requestServerName request server name
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
* @param useHistory flag indicating whether to use visited page
* history to select default page per site folder
* @return new request context instance
*/
- public PortalSiteRequestContext newRequestContext(String requestPath, String requestServerName, boolean requestFallback, boolean useHistory)
+ public PortalSiteRequestContext newRequestContext(String requestPath, String requestServerName, String requestUserPrincipal, boolean requestFallback, boolean useHistory)
{
- return new PortalSiteRequestContextImpl(this, requestPath, requestServerName, requestFallback, useHistory);
+ return new PortalSiteRequestContextImpl(this, requestPath, requestServerName, requestUserPrincipal, requestFallback, useHistory);
}
/**
@@ -262,6 +266,7 @@ public class PortalSiteSessionContextImp
*
* @param requestPath request path
* @param requestServerName request server name
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
* @param useHistory flag indicating whether to use visited page
@@ -271,15 +276,16 @@ public class PortalSiteSessionContextImp
* @throws NodeNotFoundException if not found
* @throws SecurityException if view access not granted
*/
- public BaseConcretePageElement selectRequestPage(String requestPath, String requestServerName, boolean requestFallback, boolean useHistory, String [] requestPageContentPath) throws NodeNotFoundException
+ public BaseConcretePageElement selectRequestPage(String requestPath, String requestServerName, String requestUserPrincipal, boolean requestFallback, boolean useHistory, String [] requestPageContentPath) throws NodeNotFoundException
{
- return selectRequestPage(null, requestPath, requestServerName, requestFallback, useHistory, false, requestPageContentPath);
+ return selectRequestPage(null, requestPath, requestServerName, requestUserPrincipal, requestFallback, useHistory, false, requestPageContentPath);
}
/**
* selectRequestPage - select page view for request given profile locators
*
* @param requestProfileLocators map of profile locators for request
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
* @param useHistory flag indicating whether to use visited page
@@ -290,9 +296,9 @@ public class PortalSiteSessionContextImp
* @throws NodeNotFoundException if not found
* @throws SecurityException if view access not granted
*/
- public BaseConcretePageElement selectRequestPage(Map requestProfileLocators, boolean requestFallback, boolean useHistory, boolean forceReservedVisible, String [] requestPageContentPath) throws NodeNotFoundException
+ public BaseConcretePageElement selectRequestPage(Map requestProfileLocators, String requestUserPrincipal, boolean requestFallback, boolean useHistory, boolean forceReservedVisible, String [] requestPageContentPath) throws NodeNotFoundException
{
- return selectRequestPage(requestProfileLocators, null, null, requestFallback, useHistory, forceReservedVisible, requestPageContentPath);
+ return selectRequestPage(requestProfileLocators, null, null, requestUserPrincipal, requestFallback, useHistory, forceReservedVisible, requestPageContentPath);
}
/**
@@ -301,6 +307,7 @@ public class PortalSiteSessionContextImp
* @param requestProfileLocators map of profile locators for request
* @param requestPath request path if no locators specified
* @param requestServerName request server name if no locators specified
+ * @param requestUserPrincipal request user principal
* @param requestFallback flag specifying whether to fallback to root folder
* if locators do not select a page or access is forbidden
* @param useHistory flag indicating whether to use visited page
@@ -311,10 +318,10 @@ public class PortalSiteSessionContextImp
* @throws NodeNotFoundException if not found
* @throws SecurityException if view access not granted
*/
- private BaseConcretePageElement selectRequestPage(Map requestProfileLocators, String requestPath, String requestServerName, boolean requestFallback, boolean useHistory, boolean forceReservedVisible, String [] requestPageContentPath) throws NodeNotFoundException
+ private BaseConcretePageElement selectRequestPage(Map requestProfileLocators, String requestPath, String requestServerName, String requestUserPrincipal, boolean requestFallback, boolean useHistory, boolean forceReservedVisible, String [] requestPageContentPath) throws NodeNotFoundException
{
// validate and update session profile locators if modified
- if (updateSessionProfileLocators(requestProfileLocators, forceReservedVisible))
+ if (updateSessionProfileLocators(requestProfileLocators, requestUserPrincipal, forceReservedVisible))
{
// extract page request path and server from the locators
// if specified, otherwise use specified parameters
@@ -1077,28 +1084,30 @@ public class PortalSiteSessionContextImp
/**
* getRequestRootFolder - select root folder view for given profile locators
*
+ * @param requestUserPrincipal request user principal
* @return root folder view for request
* @throws NodeNotFoundException if not found
* @throws SecurityException if view access not granted
*/
- public Folder getRequestRootFolder() throws NodeNotFoundException
+ public Folder getRequestRootFolder(String requestUserPrincipal) throws NodeNotFoundException
{
- return getRequestRootFolder(null, false);
+ return getRequestRootFolder(null, requestUserPrincipal, false);
}
/**
* getRequestRootFolder - select root folder view for given profile locators
*
* @param requestProfileLocators map of profile locators for request
+ * @param requestUserPrincipal request user principal
* @param requestForceReservedVisible force reserved/hidden folders visible for request
* @return root folder view for request
* @throws NodeNotFoundException if not found
* @throws SecurityException if view access not granted
*/
- public Folder getRequestRootFolder(Map requestProfileLocators, boolean requestForceReservedVisible) throws NodeNotFoundException
+ public Folder getRequestRootFolder(Map requestProfileLocators, String requestUserPrincipal, boolean requestForceReservedVisible) throws NodeNotFoundException
{
// validate and update session profile locators if modified
- if (updateSessionProfileLocators(requestProfileLocators, requestForceReservedVisible))
+ if (updateSessionProfileLocators(requestProfileLocators, requestUserPrincipal, requestForceReservedVisible))
{
// valid site view required from session profile locators
AbstractSiteView view = getSiteView();
@@ -1118,37 +1127,38 @@ public class PortalSiteSessionContextImp
* session profile locators
*
* @param requestProfileLocators map of profile locators for request
+ * @param requestUserPrincipal request user principal
* @param requestForceReservedVisible force reserved/hidden folders visible for request
* @return profile locators validation flag
*/
- private boolean updateSessionProfileLocators(Map requestProfileLocators, boolean requestForceReservedVisible)
+ private boolean updateSessionProfileLocators(Map requestProfileLocators, String requestUserPrincipal, boolean requestForceReservedVisible)
{
// valid request profile locators are required
if ((requestProfileLocators == null) || !requestProfileLocators.isEmpty())
{
// get current user principal; ignore derivative
// changes in role and group principals
- String currentUserPrincipal = null;
- Subject subject = JSSubject.getSubject(AccessController.getContext());
- if (subject != null)
- {
- Iterator principals = subject.getPrincipals().iterator();
- while (principals.hasNext())
- {
- Principal principal = (Principal) principals.next();
- if (principal instanceof User)
- {
- if (currentUserPrincipal == null)
- {
- currentUserPrincipal = principal.getName();
- }
- else
- {
- currentUserPrincipal += "|" + principal.getName();
- }
- }
- }
- }
+ //String currentUserPrincipal = null;
+ //Subject subject = JSSubject.getSubject(AccessController.getContext());
+ //if (subject != null)
+ //{
+ // Iterator principals = subject.getPrincipals().iterator();
+ // while (principals.hasNext())
+ // {
+ // Principal principal = (Principal) principals.next();
+ // if (principal instanceof User)
+ // {
+ // if (currentUserPrincipal == null)
+ // {
+ // currentUserPrincipal = principal.getName();
+ // }
+ // else
+ // {
+ // currentUserPrincipal += "|" + principal.getName();
+ // }
+ // }
+ // }
+ //}
// detect stale session, modification of user
// principal, or changed profile locators for
@@ -1159,8 +1169,8 @@ public class PortalSiteSessionContextImp
boolean updated = false;
synchronized (this)
{
- userUpdate = (((userPrincipal == null) && (currentUserPrincipal != null)) ||
- ((userPrincipal != null) && !userPrincipal.equals(currentUserPrincipal)));
+ userUpdate = (((userPrincipal == null) && (requestUserPrincipal != null)) ||
+ ((userPrincipal != null) && !userPrincipal.equals(requestUserPrincipal)));
locatorsUpdate = !locatorsEquals(profileLocators, requestProfileLocators);
forceReservedVisibleUpdate = (forceReservedVisible != requestForceReservedVisible);
if (stale || userUpdate || locatorsUpdate || forceReservedVisibleUpdate)
@@ -1171,7 +1181,7 @@ public class PortalSiteSessionContextImp
clearSessionProfileLocators();
profileLocators = requestProfileLocators;
forceReservedVisible = requestForceReservedVisible;
- userPrincipal = currentUserPrincipal;
+ userPrincipal = requestUserPrincipal;
updated = true;
}
locatorsLastUpdateCheck = System.currentTimeMillis();
@@ -1221,7 +1231,7 @@ public class PortalSiteSessionContextImp
{
debug.append("Updated stale");
}
- debug.append(" context: user=" + currentUserPrincipal + ", profileLocators=(");
+ debug.append(" context: user=" + requestUserPrincipal + ", profileLocators=(");
if (requestProfileLocators != null)
{
boolean firstEntry = true;
@@ -1293,12 +1303,14 @@ public class PortalSiteSessionContextImp
{
// access site view and test for creation
Map createViewProfileLocators = null;
+ String createViewUserPrincipal = null;
boolean createView = false;
synchronized (this)
{
view = siteView;
createView = ((view == null) && (pageManager != null));
createViewProfileLocators = profileLocators;
+ createViewUserPrincipal = userPrincipal;
}
// create new site view if necessary
@@ -1317,14 +1329,14 @@ public class PortalSiteSessionContextImp
}
else
{
- view = new PhysicalSiteView(pageManager);
+ view = new PhysicalSiteView(pageManager, userPrincipal);
}
// update site view if not already made available by another
// request thread
synchronized (this)
{
- if ((siteView == null) && (pageManager != null) && (profileLocators == createViewProfileLocators))
+ if ((siteView == null) && (pageManager != null) && (profileLocators == createViewProfileLocators) && (userPrincipal == createViewUserPrincipal))
{
siteView = view;
viewCreated = true;
@@ -1497,6 +1509,46 @@ public class PortalSiteSessionContextImp
}
/**
+ * getUserFolderPath - return primary concrete root user folder path
+ *
+ * @param requestProfileLocators map of profile locators for request
+ * @param requestUserPrincipal request user principal
+ * @param forceReservedVisible force reserved/hidden folders visible for request
+ * @return user folder path or null
+ */
+ public String getUserFolderPath(Map requestProfileLocators, String requestUserPrincipal, boolean requestForceReservedVisible)
+ {
+ // validate and update session profile locators if modified
+ if (updateSessionProfileLocators(requestProfileLocators, requestUserPrincipal, forceReservedVisible))
+ {
+ // return user folder path in site view
+ AbstractSiteView view = getSiteView();
+ return ((view != null) ? view.getUserFolderPath() : null);
+ }
+ return null;
+ }
+
+ /**
+ * getBaseFolderPath - return primary concrete root base folder path
+ *
+ * @param requestProfileLocators map of profile locators for request
+ * @param requestUserPrincipal request user principal
+ * @param forceReservedVisible force reserved/hidden folders visible for request
+ * @return base folder path or null
+ */
+ public String getBaseFolderPath(Map requestProfileLocators, String requestUserPrincipal, boolean requestForceReservedVisible)
+ {
+ // validate and update session profile locators if modified
+ if (updateSessionProfileLocators(requestProfileLocators, requestUserPrincipal, forceReservedVisible))
+ {
+ // return base folder path in site view
+ AbstractSiteView view = getSiteView();
+ return ((view != null) ? view.getBaseFolderPath() : null);
+ }
+ return null;
+ }
+
+ /**
* getMenuDefinitionLocatorCache - get menu definition locators cache
* for absolute menus
*
@@ -1517,7 +1569,7 @@ public class PortalSiteSessionContextImp
{
menuDefinitionLocatorCache = cache;
}
-
+
/**
* locatorsEquals - test profile locator maps for equivalence
* ignoring request specifics
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/AbstractSiteView.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/AbstractSiteView.java?rev=922416&r1=922415&r2=922416&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/AbstractSiteView.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/AbstractSiteView.java Fri Mar 12 20:33:04 2010
@@ -837,4 +837,18 @@ public abstract class AbstractSiteView
* @return managed dynamic page
*/
public abstract FragmentDefinition getManagedFragmentDefinition(FragmentDefinition fragmentDefinition);
+
+ /**
+ * getUserFolderPath - return primary concrete root user folder path
+ *
+ * @return user folder path or null
+ */
+ public abstract String getUserFolderPath();
+
+ /**
+ * getBaseFolderPath - return primary concrete root base folder path
+ *
+ * @return base folder path or null
+ */
+ public abstract String getBaseFolderPath();
}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/PhysicalSiteView.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/PhysicalSiteView.java?rev=922416&r1=922415&r2=922416&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/PhysicalSiteView.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/PhysicalSiteView.java Fri Mar 12 20:33:04 2010
@@ -43,6 +43,11 @@ public class PhysicalSiteView extends Ab
private static final List NULL_LOCATORS = new ArrayList(0);
/**
+ * userPrincipal - user principal for view
+ */
+ private String userPrincipal;
+
+ /**
* menuDefinitionLocatorsCache - cached menu definition locators
*/
private ConcurrentHashMap menuDefinitionLocatorsCache = new ConcurrentHashMap();
@@ -52,9 +57,10 @@ public class PhysicalSiteView extends Ab
*
* @param pageManager PageManager component instance
*/
- public PhysicalSiteView(PageManager pageManager)
+ public PhysicalSiteView(PageManager pageManager, String userPrincipal)
{
super(pageManager);
+ this.userPrincipal = userPrincipal;
}
/**
@@ -268,4 +274,24 @@ public class PhysicalSiteView extends Ab
// physical view is directly managed
return fragmentDefinition;
}
+
+ /**
+ * getUserFolderPath - return primary concrete root user folder path
+ *
+ * @return user folder path or null
+ */
+ public String getUserFolderPath()
+ {
+ return ((userPrincipal != null) ? Folder.USER_FOLDER+userPrincipal : null);
+ }
+
+ /**
+ * getBaseFolderPath - return primary concrete root base folder path
+ *
+ * @return base folder path or null
+ */
+ public String getBaseFolderPath()
+ {
+ return Folder.PATH_SEPARATOR;
+ }
}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java?rev=922416&r1=922415&r2=922416&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SearchPathsSiteView.java Fri Mar 12 20:33:04 2010
@@ -19,6 +19,7 @@ package org.apache.jetspeed.portalsite.v
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import org.apache.jetspeed.om.folder.Folder;
@@ -68,6 +69,16 @@ public class SearchPathsSiteView extends
private boolean forceReservedVisible;
/**
+ * userSearchPath - primary user search path
+ */
+ private SiteViewSearchPath userSearchPath;
+
+ /**
+ * baseSearchPath - base search path
+ */
+ private SiteViewSearchPath baseSearchPath;
+
+ /**
* SearchPathsSiteView - validating constructor
*
* @param pageManager PageManager component instance
@@ -82,7 +93,7 @@ public class SearchPathsSiteView extends
{
// validate search path format and existence
this.searchPaths = new ArrayList(searchPaths.size());
- StringBuffer searchPathsStringBuffer = new StringBuffer();
+ StringBuilder searchPathsStringBuilder = new StringBuilder();
Iterator pathsIter = searchPaths.iterator();
while (pathsIter.hasNext())
{
@@ -105,14 +116,14 @@ public class SearchPathsSiteView extends
this.searchPaths.add(searchPath);
// construct search paths as string
- if (searchPathsStringBuffer.length() == 0)
+ if (searchPathsStringBuilder.length() == 0)
{
- searchPathsStringBuffer.append(searchPath);
+ searchPathsStringBuilder.append(searchPath);
}
else
{
- searchPathsStringBuffer.append(',');
- searchPathsStringBuffer.append(searchPath);
+ searchPathsStringBuilder.append(',');
+ searchPathsStringBuilder.append(searchPath);
}
}
}
@@ -133,20 +144,103 @@ public class SearchPathsSiteView extends
// save search paths as string
if (this.searchPaths.isEmpty())
{
- this.searchPaths.add(new SiteViewSearchPath(ProfileLocator.PAGE_LOCATOR, Folder.PATH_SEPARATOR));
+ this.searchPaths.add(new SiteViewSearchPath(ProfileLocator.PAGE_LOCATOR));
this.searchPathsString = Folder.PATH_SEPARATOR;
}
else
{
- this.searchPathsString = searchPathsStringBuffer.toString();
+ this.searchPathsString = searchPathsStringBuilder.toString();
+
+ // find primary user search path
+ Iterator searchPathsIter = this.searchPaths.iterator();
+ while (searchPathsIter.hasNext())
+ {
+ SiteViewSearchPath searchPath = (SiteViewSearchPath)searchPathsIter.next();
+ if (searchPath.isUserPath())
+ {
+ this.userSearchPath = searchPath;
+ break;
+ }
+ }
+ }
+
+ // find base search path
+ if (this.searchPaths.size() == 1)
+ {
+ // single non-principal search path is the base
+ // search path
+ SiteViewSearchPath searchPath = (SiteViewSearchPath)this.searchPaths.get(0);
+ if (!searchPath.isPrincipalPath())
+ {
+ this.baseSearchPath = searchPath;
+ }
+ }
+ else
+ {
+ // scan for the search path that are common to all
+ // more specific search paths starting at the least
+ // specific search path
+ ListIterator searchPathsIter = this.searchPaths.listIterator(this.searchPaths.size());
+ while (searchPathsIter.hasPrevious())
+ {
+ SiteViewSearchPath searchPath = (SiteViewSearchPath)searchPathsIter.previous();
+ int scanSearchPathsIndex = searchPathsIter.previousIndex();
+ if (scanSearchPathsIndex == -1)
+ {
+ // most specific non-principal search path is the
+ // base path since all less specific search paths are
+ // part of the current search path
+ if (!searchPath.isPrincipalPath())
+ {
+ this.baseSearchPath = searchPath;
+ }
+ break;
+ }
+ else if (!searchPath.isPrincipalPath() && ((this.baseSearchPath == null) || (searchPath.getPathDepth() > this.baseSearchPath.getPathDepth())))
+ {
+ // scan more specific search paths to test whether the
+ // current search path is common to all
+ boolean isCommonSearchPath = true;
+ ListIterator scanSearchPathsIter = this.searchPaths.listIterator(scanSearchPathsIndex+1);
+ while (scanSearchPathsIter.hasPrevious())
+ {
+ SiteViewSearchPath scanSearchPath = (SiteViewSearchPath)scanSearchPathsIter.previous();
+ if (!scanSearchPath.toString().startsWith(searchPath.toString()))
+ {
+ isCommonSearchPath = false;
+ break;
+ }
+ }
+ // if all more specific search paths are start with
+ // the current search path, the current search path is
+ // a base search path candidate: continue scan for a
+ // more specific common search path; otherwise, the
+ // last base search path is the most common possible: done
+ if (isCommonSearchPath)
+ {
+ this.baseSearchPath = searchPath;
+ continue;
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ // longest non-principal common base search path found: done
+ break;
+ }
+ }
}
}
else
{
// root search path with no aggregation
this.searchPaths = new ArrayList(1);
- this.searchPaths.add(new SiteViewSearchPath(ProfileLocator.PAGE_LOCATOR, Folder.PATH_SEPARATOR));
+ this.searchPaths.add(new SiteViewSearchPath(ProfileLocator.PAGE_LOCATOR));
this.searchPathsString = Folder.PATH_SEPARATOR;
+ this.baseSearchPath = (SiteViewSearchPath)this.searchPaths.get(0);
}
this.forceReservedVisible = forceReservedVisible;
}
@@ -284,6 +378,84 @@ public class SearchPathsSiteView extends
}
return null;
}
+
+ /**
+ * StringBuilder implementation for constructing search paths.
+ */
+ private static class PathStringBuilder
+ {
+ private StringBuilder stringBuilder;
+ private boolean userPath;
+ private boolean principalPath;
+ private int pathDepth;
+
+ public PathStringBuilder()
+ {
+ this.stringBuilder = new StringBuilder();
+ }
+
+ public PathStringBuilder(String s)
+ {
+ this.stringBuilder = new StringBuilder(s);
+ }
+
+ public PathStringBuilder append(String s)
+ {
+ stringBuilder.append(s);
+ return this;
+ }
+
+ public PathStringBuilder append(char c)
+ {
+ stringBuilder.append(c);
+ return this;
+ }
+
+ public int length()
+ {
+ return stringBuilder.length();
+ }
+
+ public void setLength(int length)
+ {
+ stringBuilder.setLength(length);
+ }
+
+ public String toString()
+ {
+ return stringBuilder.toString();
+ }
+
+ public boolean isUserPath()
+ {
+ return userPath;
+ }
+
+ public void setUserPath(boolean userPath)
+ {
+ this.userPath = userPath;
+ }
+
+ public boolean isPrincipalPath()
+ {
+ return principalPath;
+ }
+
+ public void setPrincipalPath(boolean principalPath)
+ {
+ this.principalPath = principalPath;
+ }
+
+ public int getPathDepth()
+ {
+ return pathDepth;
+ }
+
+ public void setPathDepth(int pathDepth)
+ {
+ this.pathDepth = pathDepth;
+ }
+ }
/**
* mergeSearchPathList - append search paths from profile locator
@@ -313,7 +485,7 @@ public class SearchPathsSiteView extends
// initialize path construction variables
String pathRoot = Folder.PATH_SEPARATOR;
List paths = new ArrayList(8);
- paths.add(new StringBuffer(pathRoot));
+ paths.add(new PathStringBuilder(pathRoot));
int pathDepth = 0;
int lastPathsCount = 0;
String lastPropertyName = null;
@@ -340,6 +512,7 @@ public class SearchPathsSiteView extends
// and contains proper path prefix for each subsite
// path folder name
pathRoot = properties[i].getValue();
+ int pathRootDepth = 0;
if (!pathRoot.startsWith(Folder.PATH_SEPARATOR))
{
pathRoot = Folder.PATH_SEPARATOR + pathRoot;
@@ -357,15 +530,20 @@ public class SearchPathsSiteView extends
{
pathRoot = pathRoot.substring(0, folderIndex) + Folder.RESERVED_SUBSITE_FOLDER_PREFIX + pathRoot.substring(folderIndex);
}
+ pathRootDepth++;
folderIndex = pathRoot.indexOf(Folder.PATH_SEPARATOR, folderIndex) + 1;
}
while ((folderIndex != -1) && (folderIndex != pathRoot.length()));
}
-
+
+ // construct prefix path root
+ PathStringBuilder path = new PathStringBuilder(pathRoot);
+ path.setPathDepth(pathRootDepth);
+
// reset locator paths using new prefix
pathDepth = 0;
paths.clear();
- paths.add(new StringBuffer(pathRoot));
+ paths.add(path);
lastPathsCount = 0;
lastPropertyName = null;
lastPropertyValueLength = 0;
@@ -391,6 +569,12 @@ public class SearchPathsSiteView extends
// value case as provided by profiler
String propertyName = properties[i].getName().toLowerCase();
String propertyValue = properties[i].getValue();
+ // classify principal paths
+ String prefixedPropertyName = Folder.RESERVED_FOLDER_PREFIX+propertyName;
+ boolean userPath = prefixedPropertyName.equals(Folder.RESERVED_USER_FOLDER_NAME);
+ boolean rolePath = (!userPath && prefixedPropertyName.equals(Folder.RESERVED_ROLE_FOLDER_NAME));
+ boolean groupPath = (!userPath && !rolePath && prefixedPropertyName.equals(Folder.RESERVED_GROUP_FOLDER_NAME));
+ boolean principalPath = (userPath || rolePath || groupPath);
// detect duplicate control names which indicates multiple
// values: must duplicate locator paths for each value; different
// control values are simply appended to all locator paths
@@ -403,11 +587,14 @@ public class SearchPathsSiteView extends
Iterator pathsIter = paths.iterator();
for (int count = 0; (pathsIter.hasNext() && (count < lastPathsCount)); count++)
{
- StringBuffer path = (StringBuffer) pathsIter.next();
- StringBuffer multipleValuePath = new StringBuffer(path.toString());
+ PathStringBuilder path = (PathStringBuilder) pathsIter.next();
+ PathStringBuilder multipleValuePath = new PathStringBuilder(path.toString());
multipleValuePath.setLength(multipleValuePath.length() - lastPropertyValueLength - 1);
multipleValuePath.append(propertyValue);
multipleValuePath.append(Folder.PATH_SEPARATOR_CHAR);
+ multipleValuePath.setUserPath(userPath);
+ multipleValuePath.setPrincipalPath(path.isPrincipalPath() || principalPath);
+ multipleValuePath.setPathDepth(path.getPathDepth()+1);
multipleValuePaths.add(multipleValuePath);
}
paths.addAll(multipleValuePaths);
@@ -423,12 +610,15 @@ public class SearchPathsSiteView extends
Iterator pathsIter = paths.iterator();
while (pathsIter.hasNext())
{
- StringBuffer path = (StringBuffer) pathsIter.next();
+ PathStringBuilder path = (PathStringBuilder) pathsIter.next();
path.append(Folder.RESERVED_FOLDER_PREFIX);
path.append(propertyName);
path.append(Folder.PATH_SEPARATOR_CHAR);
path.append(propertyValue);
path.append(Folder.PATH_SEPARATOR_CHAR);
+ path.setUserPath(userPath);
+ path.setPrincipalPath(path.isPrincipalPath() || principalPath);
+ path.setPathDepth(path.getPathDepth()+1);
}
// reset last locator property vars
@@ -476,7 +666,7 @@ public class SearchPathsSiteView extends
}
if ((pathDepth == 1) && !navigatedPathRoot)
{
- locatorSearchPaths.add(addLocatorSearchPathsAt++, new StringBuffer(pathRoot));
+ locatorSearchPaths.add(addLocatorSearchPathsAt++, new PathStringBuilder(pathRoot));
}
// reset locator search path ordering since navigated root
@@ -499,7 +689,8 @@ public class SearchPathsSiteView extends
Iterator locatorSearchPathsIter = locatorSearchPaths.iterator();
while (locatorSearchPathsIter.hasNext())
{
- SiteViewSearchPath searchPath = new SiteViewSearchPath(locatorName, locatorSearchPathsIter.next().toString());
+ PathStringBuilder searchPathBuilder = (PathStringBuilder)locatorSearchPathsIter.next();
+ SiteViewSearchPath searchPath = new SiteViewSearchPath(locatorName, searchPathBuilder.toString(), searchPathBuilder.isUserPath(), searchPathBuilder.isPrincipalPath(), searchPathBuilder.getPathDepth());
// test search path uniqueness
int existsAt = searchPaths.indexOf(searchPath);
if (existsAt != -1)
@@ -748,4 +939,24 @@ public class SearchPathsSiteView extends
FragmentDefinitionProxy fragmentDefinitionProxy = (FragmentDefinitionProxy)NodeProxy.getNodeProxy(fragmentDefinition);
return ((fragmentDefinitionProxy != null) ? fragmentDefinitionProxy.getFragmentDefinition() : null);
}
+
+ /**
+ * getUserFolderPath - return primary concrete root user folder path
+ *
+ * @return user folder path or null
+ */
+ public String getUserFolderPath()
+ {
+ return ((userSearchPath != null) ? userSearchPath.toString() : null);
+ }
+
+ /**
+ * getBaseFolderPath - return primary concrete root base folder path
+ *
+ * @return base folder path or null
+ */
+ public String getBaseFolderPath()
+ {
+ return ((baseSearchPath != null) ? baseSearchPath.toString() : null);
+ }
}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewSearchPath.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewSearchPath.java?rev=922416&r1=922415&r2=922416&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewSearchPath.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/main/java/org/apache/jetspeed/portalsite/view/SiteViewSearchPath.java Fri Mar 12 20:33:04 2010
@@ -29,6 +29,8 @@ import org.apache.jetspeed.om.folder.Fol
*/
public class SiteViewSearchPath
{
+ private static final String USER_PATH_PATTERN = ".*"+Folder.USER_FOLDER+"[^"+Folder.PATH_SEPARATOR+"]+";
+
/**
* locatorName - profile locator name
*/
@@ -40,6 +42,32 @@ public class SiteViewSearchPath
private String searchPath;
/**
+ * userPath - user path flag
+ */
+ private boolean userPath;
+
+ /**
+ * principalPath - principal path flag
+ */
+ private boolean principalPath;
+
+ /**
+ * pathDepth - path depth
+ */
+ private int pathDepth;
+
+ /**
+ * SiteViewSearchPath - root path constructor
+ * folder separator from search path
+ *
+ * @param locatorName profile locator name
+ */
+ public SiteViewSearchPath(String locatorName)
+ {
+ this(locatorName, Folder.PATH_SEPARATOR, false, false, 0);
+ }
+
+ /**
* SiteViewSearchPath - validating constructor that strips any trailing
* folder separator from search path
*
@@ -48,6 +76,55 @@ public class SiteViewSearchPath
*/
public SiteViewSearchPath(String locatorName, String searchPath)
{
+ this(locatorName, searchPath, searchPath.matches(USER_PATH_PATTERN), principalSearchPath(searchPath), searchPathDepth(searchPath));
+ }
+
+ /**
+ * searchPathDepth - compute search path depth
+ *
+ * @param searchPath search path
+ */
+ private static int searchPathDepth(String searchPath)
+ {
+ // count control/reserved folder names in path
+ int depth = 0;
+ int length = searchPath.length();
+ int prefixLength = Folder.RESERVED_FOLDER_PREFIX.length();
+ int index = searchPath.indexOf(Folder.PATH_SEPARATOR_CHAR);
+ while (index != -1)
+ {
+ if (searchPath.regionMatches(index+1, Folder.RESERVED_FOLDER_PREFIX, 0, prefixLength))
+ {
+ depth++;
+ }
+ index = searchPath.indexOf(Folder.PATH_SEPARATOR_CHAR, index+1);
+ }
+ return depth;
+ }
+
+ /**
+ * principalSearchPath - compute principal search path flag
+ *
+ * @param principal search path flag
+ */
+ private static boolean principalSearchPath(String searchPath)
+ {
+ // test reserved principal folder names in path
+ return (searchPath.contains(Folder.USER_FOLDER) || searchPath.contains(Folder.ROLE_FOLDER) || searchPath.contains(Folder.GROUP_FOLDER));
+ }
+
+ /**
+ * SiteViewSearchPath - validating constructor that strips any trailing
+ * folder separator from search path
+ *
+ * @param locatorName profile locator name
+ * @param searchPath search path
+ * @param userPath user path flag
+ * @param principalPath principal path flag
+ * @param pathDepth path depth
+ */
+ public SiteViewSearchPath(String locatorName, String searchPath, boolean userPath, boolean principalPath, int pathDepth)
+ {
this.locatorName = locatorName;
if (searchPath.endsWith(Folder.PATH_SEPARATOR) && !searchPath.equals(Folder.PATH_SEPARATOR))
{
@@ -57,6 +134,9 @@ public class SiteViewSearchPath
{
this.searchPath = searchPath;
}
+ this.userPath = userPath;
+ this.principalPath = principalPath;
+ this.pathDepth = pathDepth;
}
/**
@@ -102,4 +182,34 @@ public class SiteViewSearchPath
{
return locatorName;
}
+
+ /**
+ * isUserPath - return user path flag
+ *
+ * @return user path flag
+ */
+ public boolean isUserPath()
+ {
+ return userPath;
+ }
+
+ /**
+ * isPrincipalPath - return principal path flag
+ *
+ * @return principal path flag
+ */
+ public boolean isPrincipalPath()
+ {
+ return principalPath;
+ }
+
+ /**
+ * getPathDepth - return path depth
+ *
+ * @return path depth
+ */
+ public int getPathDepth()
+ {
+ return pathDepth;
+ }
}
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java?rev=922416&r1=922415&r2=922416&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal-site/src/test/java/org/apache/jetspeed/portalsite/TestPortalSite.java Fri Mar 12 20:33:04 2010
@@ -360,6 +360,8 @@ public class TestPortalSite extends Abst
assertEquals("folder1", rootFolder1View.getName());
assertEquals("group folder1", rootFolder1View.getTitle());
assertEquals("/_user/user/folder1", extractFileSystemPathFromId(rootFolder1View.getId()));
+ assertEquals("/_user/user", aggregateView.getUserFolderPath());
+ assertEquals("/", aggregateView.getBaseFolderPath());
// test degenerate aggregating SiteView
aggregateView = new SearchPathsSiteView(pageManager, "/__subsite-root", false);
@@ -460,9 +462,11 @@ public class TestPortalSite extends Abst
assertEquals("page1.psml", folder1Page1View.getName());
assertEquals("/_group/group/folder1/page1.psml", extractFileSystemPathFromId(folder1Page1View.getId()));
assertEquals("alternate-locator-name", extractLocatorNameFromView(folder1Page1View));
+ assertEquals("/_user/user", profileView.getUserFolderPath());
+ assertEquals("/", profileView.getBaseFolderPath());
// test physical SiteView
- PhysicalSiteView basePhysicalView = new PhysicalSiteView(pageManager);
+ PhysicalSiteView basePhysicalView = new PhysicalSiteView(pageManager, "user");
rootFolderView = basePhysicalView.getRootFolderView();
assertNotNull(rootFolderView);
assertEquals("/", rootFolderView.getName());
@@ -540,6 +544,8 @@ public class TestPortalSite extends Abst
assertEquals(0, rootUserUserView.getLinks().size());
assertEquals(1, rootUserUserView.getFragmentDefinitions().size());
assertNotNull(rootUserUserView.getFragmentDefinition("definition1.fpsml"));
+ assertEquals("/_user/user", basePhysicalView.getUserFolderPath());
+ assertEquals("/", basePhysicalView.getBaseFolderPath());
}
/**
@@ -557,6 +563,8 @@ public class TestPortalSite extends Abst
locator.add("page", false, false, "home");
SearchPathsSiteView profileView = new SearchPathsSiteView(pageManager, locator, false);
assertEquals("/_hostname/dash/_user/joe,/_hostname/dash,/", profileView.getSearchPathsString());
+ assertEquals("/_hostname/dash/_user/joe", profileView.getUserFolderPath());
+ assertEquals("/_hostname/dash", profileView.getBaseFolderPath());
locator = new JetspeedProfileLocator();
locator.init(null, "/");
@@ -568,6 +576,8 @@ public class TestPortalSite extends Abst
locator.add("page", false, false, "home");
profileView = new SearchPathsSiteView(pageManager, locator, false);
assertEquals("/_hostname/dash/_user/joe,/_hostname/dash/_role/user,/_hostname/dash,/", profileView.getSearchPathsString());
+ assertEquals("/_hostname/dash/_user/joe", profileView.getUserFolderPath());
+ assertEquals("/_hostname/dash", profileView.getBaseFolderPath());
locator = new JetspeedProfileLocator();
locator.init(null, "/");
@@ -580,6 +590,8 @@ public class TestPortalSite extends Abst
locator.add("path", false, false, "home");
profileView = new SearchPathsSiteView(pageManager, locator, false);
assertEquals("/__subsite-root/_hostname/localhost/_user/sublocal,/__subsite-root/_hostname/localhost/_role/somerole,/__subsite-root/_hostname/localhost,/__subsite-root", profileView.getSearchPathsString());
+ assertEquals("/__subsite-root/_hostname/localhost/_user/sublocal", profileView.getUserFolderPath());
+ assertEquals("/__subsite-root/_hostname/localhost", profileView.getBaseFolderPath());
}
/**
@@ -604,7 +616,7 @@ public class TestPortalSite extends Abst
locator.add("group", true, false, "group");
Map locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators);
+ PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
BaseConcretePageElement requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -663,11 +675,13 @@ public class TestPortalSite extends Abst
assertEquals("/_group/group/link0.link", extractFileSystemPathFromId(requestRootLinkViews.get("link0.link").getId()));
assertNotNull(requestRootLinkViews.get("link1.link"));
assertEquals("/link1.link", extractFileSystemPathFromId(requestRootLinkViews.get("link1.link").getId()));
+ assertEquals("/_user/user", requestContext.getUserFolderPath());
+ assertEquals("/", requestContext.getBaseFolderPath());
// physical site setup
sessionContext = portalSite.newSessionContext();
assertNotNull(sessionContext);
- requestContext = sessionContext.newRequestContext("/", null);
+ requestContext = sessionContext.newRequestContext("/", null, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -732,6 +746,8 @@ public class TestPortalSite extends Abst
assertEquals("/link0.link", extractFileSystemPathFromId(requestRootLinkViews.get("link0.link").getId()));
assertNotNull(requestRootLinkViews.get("link1.link"));
assertEquals("/link1.link", extractFileSystemPathFromId(requestRootLinkViews.get("link1.link").getId()));
+ assertEquals("/_user/user", requestContext.getUserFolderPath());
+ assertEquals("/", requestContext.getBaseFolderPath());
}
/**
@@ -752,7 +768,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
Map locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators);
+ PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
BaseConcretePageElement requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -766,7 +782,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -780,7 +796,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -794,7 +810,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -808,7 +824,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -821,7 +837,7 @@ public class TestPortalSite extends Abst
locator.add("page", false, false, "/folder3/default-folder0/");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, null);
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -836,7 +852,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "admin");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators, true, true, true);
+ requestContext = sessionContext.newRequestContext(locators, "admin", true, true, true);
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -847,7 +863,7 @@ public class TestPortalSite extends Abst
// physical site requests
sessionContext = portalSite.newSessionContext();
assertNotNull(sessionContext);
- requestContext = sessionContext.newRequestContext("/", null);
+ requestContext = sessionContext.newRequestContext("/", null, null);
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -857,7 +873,7 @@ public class TestPortalSite extends Abst
sessionContext = portalSite.newSessionContext();
assertNotNull(sessionContext);
- requestContext = sessionContext.newRequestContext("/_user/user/page2.psml", null);
+ requestContext = sessionContext.newRequestContext("/_user/user/page2.psml", null, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -892,7 +908,7 @@ public class TestPortalSite extends Abst
locator.init(null, "/");
locator.add("group", true, false, "group");
locators.put("group", locator);
- PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators);
+ PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
Set customMenuNames = requestContext.getCustomMenuNames();
assertNotNull(customMenuNames);
@@ -1193,7 +1209,7 @@ public class TestPortalSite extends Abst
locator.init(null, "/folder0");
locator.add("group", true, false, "group");
locators.put("group", locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
Menu topMenu2 = requestContext.getMenu("top");
assertNotNull(topMenu2);
@@ -1257,7 +1273,7 @@ public class TestPortalSite extends Abst
locator.init(null, "/page1.psml");
locator.add("group", true, false, "group");
locators.put("group", locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
assertNull(requestContext.getMenu("no-such-menu"));
Menu topMenu3 = requestContext.getMenu("top");
@@ -1403,7 +1419,7 @@ public class TestPortalSite extends Abst
locator.init(null, "/page0.psml");
locator.add("group", true, false, "group");
locators.put("group", locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
Menu templateTestMenu2 = requestContext.getMenu("template-test");
assertNotNull(templateTestMenu2);
@@ -1426,7 +1442,7 @@ public class TestPortalSite extends Abst
locator.init(null, "/folder1");
locator.add("group", true, false, "group");
locators.put("group", locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
Menu backMenu2 = requestContext.getMenu("back");
assertNotNull(backMenu2);
@@ -1652,7 +1668,7 @@ public class TestPortalSite extends Abst
// physical site menus
sessionContext = portalSite.newSessionContext();
assertNotNull(sessionContext);
- requestContext = sessionContext.newRequestContext("/", null);
+ requestContext = sessionContext.newRequestContext("/", null, "user");
assertNotNull(requestContext);
customMenuNames = requestContext.getCustomMenuNames();
assertNotNull(customMenuNames);
@@ -1868,7 +1884,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
Map locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators);
+ PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
Menu topMenu = requestContext.getMenu("top");
assertNotNull(topMenu);
@@ -1909,7 +1925,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
topMenu = requestContext.getMenu("top");
assertNotNull(topMenu);
@@ -1950,7 +1966,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
topMenu = requestContext.getMenu("top");
assertNotNull(topMenu);
@@ -1990,7 +2006,7 @@ public class TestPortalSite extends Abst
assertNotNull(sessionContext);
// first request at /: hidden page suppressed
- requestContext = sessionContext.newRequestContext("/", null);
+ requestContext = sessionContext.newRequestContext("/", null, null);
assertNotNull(requestContext);
pagesMenu = requestContext.getMenu("pages");
assertNotNull(pagesMenu);
@@ -2010,7 +2026,7 @@ public class TestPortalSite extends Abst
assertFalse(hiddenElement);
// second request at /hidden.psml: hidden page visible
- requestContext = sessionContext.newRequestContext("/hidden.psml", null);
+ requestContext = sessionContext.newRequestContext("/hidden.psml", null, null);
assertNotNull(requestContext);
pagesMenu = requestContext.getMenu("pages");
assertNotNull(pagesMenu);
@@ -2048,7 +2064,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
Map locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators);
+ PortalSiteRequestContext requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
BaseConcretePageElement requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2063,7 +2079,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2078,7 +2094,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2093,7 +2109,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2108,7 +2124,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2123,7 +2139,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2138,7 +2154,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2153,7 +2169,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2168,7 +2184,7 @@ public class TestPortalSite extends Abst
locator.add("user", true, false, "user");
locators = new HashMap();
locators.put(ProfileLocator.PAGE_LOCATOR, locator);
- requestContext = sessionContext.newRequestContext(locators);
+ requestContext = sessionContext.newRequestContext(locators, "user");
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2181,7 +2197,7 @@ public class TestPortalSite extends Abst
// physical site view
sessionContext = portalSite.newSessionContext();
assertNotNull(sessionContext);
- requestContext = sessionContext.newRequestContext("/document.doc", null);
+ requestContext = sessionContext.newRequestContext("/document.doc", null, null);
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2191,7 +2207,7 @@ public class TestPortalSite extends Abst
assertNotNull(requestContext.getPageContentPath());
assertEquals("/document", requestContext.getPageContentPath());
- requestContext = sessionContext.newRequestContext("/preview/contentfolder/draft/document.doc", "test.domain.com");
+ requestContext = sessionContext.newRequestContext("/preview/contentfolder/draft/document.doc", "test.domain.com", null);
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
@@ -2201,7 +2217,7 @@ public class TestPortalSite extends Abst
assertNotNull(requestContext.getPageContentPath());
assertEquals("/preview/contentfolder/draft/document", requestContext.getPageContentPath());
- requestContext = sessionContext.newRequestContext("/document.psml", null);
+ requestContext = sessionContext.newRequestContext("/document.psml", null, null);
assertNotNull(requestContext);
requestPageView = requestContext.getPage();
assertNotNull(requestPageView);
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/AbstractPageValveImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/AbstractPageValveImpl.java?rev=922416&r1=922415&r2=922416&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/AbstractPageValveImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/AbstractPageValveImpl.java Fri Mar 12 20:33:04 2010
@@ -17,9 +17,11 @@
package org.apache.jetspeed.pipeline.valve.impl;
import java.io.IOException;
+import java.security.Principal;
import java.util.HashMap;
import java.util.Map;
+import javax.security.auth.Subject;
import javax.servlet.http.HttpServletResponse;
import org.apache.jetspeed.PortalReservedParameters;
@@ -38,6 +40,8 @@ import org.apache.jetspeed.portalsite.Po
import org.apache.jetspeed.portalsite.PortalSiteRequestContext;
import org.apache.jetspeed.profiler.ProfilerException;
import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.SubjectHelper;
+import org.apache.jetspeed.security.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -120,8 +124,20 @@ public abstract class AbstractPageValveI
log.debug("Request path: "+requestPath);
}
+ // get request subject/principal
+ Subject requestSubject = request.getSubject();
+ if (requestSubject == null)
+ {
+ throw new ProfilerException("Missing subject for request: " + requestPath);
+ }
+ Principal requestUserPrincipal = SubjectHelper.getBestPrincipal(requestSubject, User.class);
+ if (requestUserPrincipal == null)
+ {
+ throw new ProfilerException("Missing principal for request: " + requestPath);
+ }
+
// get request page and set page action access
- setRequestPage(request, requestPath);
+ setRequestPage(request, requestPath, requestUserPrincipal);
ContentPage requestPage = request.getPage();
if (requestPage != null)
{
@@ -207,8 +223,9 @@ public abstract class AbstractPageValveI
*
* @param request invoked request
* @param requestPath invoked request path
+ * @param requestUserPrincipal invoked request user principal
*/
- protected abstract void setRequestPage(RequestContext request, String requestPath) throws NodeNotFoundException, ProfilerException;
+ protected abstract void setRequestPage(RequestContext request, String requestPath, Principal requestUserPrincipal) throws NodeNotFoundException, ProfilerException;
/**
* Set request page and associated session and request attributes
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org