morciuch 2002/09/11 11:30:55
Modified: docs/site changes.html config_guide.html todo.html
src/java/org/apache/jetspeed/services Profiler.java
src/java/org/apache/jetspeed/services/profiler
JetspeedProfilerService.java ProfilerService.java
src/java/org/apache/jetspeed/services/security/turbine
TurbineUserManagement.java
webapp/WEB-INF/conf JetspeedResources.properties
xdocs changes.xml config_guide.xml todo.xml
Log:
Implemented "Role profile merging" functionality (see Bugzilla bug# 11735).
This feature is disabled by default and may be activated by setting
services.Profiler.rolemerge=true in jr.props.
Revision Changes Path
1.55 +3 -0 jakarta-jetspeed/docs/site/changes.html
Index: changes.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/docs/site/changes.html,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- changes.html 10 Sep 2002 15:12:08 -0000 1.54
+++ changes.html 11 Sep 2002 18:30:54 -0000 1.55
@@ -129,6 +129,9 @@
</li>
-->
<li>
+ Add - Bug # 11735 - 2002/09/11 - Implemented role profile merging feature (MO)
+</li>
+<li>
Add - Bug # 11741 - 2002/09/10 - Implemented Print Friendly Format portlet action
(MO)
</li>
<li>
1.17 +25 -0 jakarta-jetspeed/docs/site/config_guide.html
Index: config_guide.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/docs/site/config_guide.html,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- config_guide.html 27 Aug 2002 20:17:05 -0000 1.16
+++ config_guide.html 11 Sep 2002 18:30:54 -0000 1.17
@@ -1258,6 +1258,31 @@
</table>
</div>
<p>Remember to set the
"services.Profiler.newuser.template" property to nothing.</p>
+ <p>In other configurations, it may
be useful to create inital user PSML based on the roles the
+user is a assigned. The role profile merging feature aggregates PSML from each role
to create
+a single tabbed profile. To enable this feature the following settings have to be
set to true:</p>
+ <div align="left">
+ <table cellspacing="4" cellpadding="0" border="0">
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#ffffff"><pre>
+services.Profiler.rolefallback=true
+services.Profiler.rolemerge=true
+</pre></td>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1"
height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ </table>
+ </div>
</blockquote>
</td></tr>
<tr><td><br/></td></tr>
1.42 +3 -3 jakarta-jetspeed/docs/site/todo.html
Index: todo.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/docs/site/todo.html,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- todo.html 10 Sep 2002 15:12:08 -0000 1.41
+++ todo.html 11 Sep 2002 18:30:54 -0000 1.42
@@ -430,7 +430,7 @@
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
- Role Profile Merging
+ Role Profile Merging. <strong>Done</strong>
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
@@ -515,7 +515,7 @@
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
- On-Line Profile Import-Export <strong>Done</strong>
+ On-Line Profile Import-Export. <strong>Done</strong>
</font>
</td>
@@ -533,7 +533,7 @@
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
- "Print Friendly Format" action icon <strong>Done</strong>
+ "Print Friendly Format" action icon. <strong>Done</strong>
</font>
</td>
<td bgcolor="#a0ddf0" colspan="" rowspan=""
valign="top" align="left">
1.17 +10 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/services/Profiler.java
Index: Profiler.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/Profiler.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- Profiler.java 26 Jul 2002 01:47:21 -0000 1.16
+++ Profiler.java 11 Sep 2002 18:30:55 -0000 1.17
@@ -75,6 +75,7 @@
* @see org.apache.jetspeed.services.Profiler
* @see org.apache.jetspeed.services.profiler.ProfilerService
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mark Orciuch</a>
* @version $Id$
*/
public class Profiler
@@ -198,6 +199,14 @@
public static Iterator query( QueryLocator locator )
{
return getService().query( locator );
+ }
+
+ /**
+ * @see ProfilerService#useRoleProfileMerging
+ */
+ public static boolean useRoleProfileMerging()
+ {
+ return getService().useRoleProfileMerging();
}
}
1.36 +175 -15
jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfilerService.java
Index: JetspeedProfilerService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfilerService.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- JetspeedProfilerService.java 26 Jul 2002 01:47:21 -0000 1.35
+++ JetspeedProfilerService.java 11 Sep 2002 18:30:55 -0000 1.36
@@ -62,10 +62,9 @@
import java.util.Iterator;
import java.util.List;
import java.util.LinkedList;
+import java.util.Vector;
// java.net
-import java.net.URL;
-import java.net.MalformedURLException;
import javax.servlet.ServletConfig;
//turbine.util
@@ -74,28 +73,36 @@
import org.apache.turbine.util.DynamicURI;
// turbine.services
-import org.apache.turbine.services.Service;
import org.apache.turbine.services.TurbineBaseService;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.services.InitializationException;
-import org.apache.turbine.services.servlet.TurbineServlet;
import org.apache.turbine.services.localization.LocaleDetector;
import org.apache.turbine.services.resources.TurbineResources;
-import org.apache.turbine.services.template.TurbineTemplate;
import org.apache.turbine.services.resources.ResourceService;
-import org.apache.turbine.util.security.DataBackendException;
-import org.apache.turbine.util.security.AccessControlList;
-
// jetspeed.om
import org.apache.jetspeed.om.security.JetspeedUser;
import org.apache.jetspeed.om.security.Role;
import org.apache.jetspeed.om.security.Group;
-import org.apache.jetspeed.om.profile.*;
+import org.apache.jetspeed.om.profile.Profile;
+import org.apache.jetspeed.om.profile.Portlets;
+import org.apache.jetspeed.om.profile.QueryLocator;
+import org.apache.jetspeed.om.profile.ProfileLocator;
+import org.apache.jetspeed.om.profile.BaseProfileLocator;
+import org.apache.jetspeed.om.profile.BaseProfile;
+import org.apache.jetspeed.om.profile.ProfileException;
import org.apache.jetspeed.om.profile.psml.PsmlPortlets;
-import org.apache.jetspeed.om.registry.RegistryException;
+import org.apache.jetspeed.om.profile.PSMLDocument;
+import org.apache.jetspeed.om.profile.psml.PsmlControl;
+import org.apache.jetspeed.om.profile.psml.PsmlController;
+import org.apache.jetspeed.om.profile.Control;
+import org.apache.jetspeed.om.profile.Controller;
+import org.apache.jetspeed.om.profile.Skin;
+import org.apache.jetspeed.om.profile.psml.PsmlSkin;
+import org.apache.jetspeed.om.profile.BasePSMLDocument;
import org.apache.jetspeed.om.registry.MediaTypeEntry;
+import org.apache.jetspeed.om.profile.Entry;
// jetspeed.capability
import org.apache.jetspeed.capability.CapabilityMap;
@@ -103,16 +110,14 @@
// jetspeed.services
import org.apache.jetspeed.services.Profiler;
-import org.apache.jetspeed.services.resources.JetspeedResources;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.services.Registry;
import org.apache.jetspeed.services.JetspeedSecurity;
import org.apache.jetspeed.services.PsmlManager;
+import org.apache.jetspeed.services.idgenerator.JetspeedIdGenerator;
// jetspeed.util
import org.apache.jetspeed.util.MimeType;
-import org.apache.jetspeed.util.FileCopy;
-import org.apache.jetspeed.util.DirectoryUtils;
/**
* <p>This is an implementation of the <code>Profiler</code> interface.
@@ -135,6 +140,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Santiago Gala</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mark Orciuch</a>
* @version $Id$
*/
@@ -152,6 +158,9 @@
private final static String CONFIG_FALLBACK_LANGUAGE = "fallback.language";
private final static String CONFIG_FALLBACK_COUNTRY = "fallback.country";
private final static String CONFIG_FALLBACK_TO_ROOT = "fallback.to.root";
+ private final static String CONFIG_ROLE_MERGE = "rolemerge";
+ private final static String CONFIG_ROLE_MERGE_CONTROL = "rolemerge.control";
+ private final static String CONFIG_ROLE_MERGE_CONTROLLER =
"rolemerge.controller";
// default configuration values
private final static String DEFAULT_CONFIG_RESOURCE_DEFAULT = "default";
@@ -161,6 +170,8 @@
private final static String DEFAULT_CONFIG_NEWUSER_TEMPLATE = null;
private final static String [] DEFAULT_CONFIG_NEWUSER_MEDIA =
{ "html", "wml" };
+ private final static String DEFAULT_CONFIG_ROLE_MERGE_CONTROL = "TabControl";
+ private final static String DEFAULT_CONFIG_ROLE_MERGE_CONTROLLER =
"TabController";
private final static String PATH_EXTENSION_DELIMITER = ".";
// messages
@@ -172,6 +183,8 @@
String root; // the root psml resource directory
String resourceDefault; // the default name for a resource
String resourceExt; // the default extension for a resource
+ String rolemergeControl; // the default control used with merged role
profiles
+ String rolemergeController; // the default controller used with merged role
profiles
// MODIFIED: A. Kempf
String newUserTemplate = DEFAULT_CONFIG_NEWUSER_TEMPLATE;
@@ -181,6 +194,7 @@
boolean useFallbackLanguage = true;
boolean useFallbackCountry = true;
boolean useFallbackToRoot = false;
+ boolean useRoleMerge = false;
String mediaTypes[] = null;
@@ -293,6 +307,7 @@
Profile profile = fallbackProfile(rundata, cm);
if (null == profile && useRoleFallback)
{
+ Vector profiles = new Vector();
JetspeedUser user = rundata.getJetspeedUser();
if (user != null)
{
@@ -308,7 +323,16 @@
rundata.getParameters().setString( Profiler.PARAM_ROLE,
role.getName() );
profile = fallbackProfile(rundata, cm);
if (profile != null)
- break;
+ {
+ profiles.add(profile);
+ }
+ }
+ profile = mergeRoleProfiles(data, profiles);
+
+ // If something went wrong with merging, attempt another
fallback
+ if (profile == null)
+ {
+ profile = fallbackProfile(rundata, cm);
}
}
}
@@ -322,6 +346,129 @@
}
/**
+ * Merge role profiles to create default profile. Resulting psml will be a set
of
+ * tabs. If role's psml is a tab control, each tab is placed in the resulting
psml
+ * as is. Otherwise, a new tab is created and psml is placed there. In this
case,
+ * tab name will be derived from role's name. For example, if role name is
"news",
+ * the resulting profile name will be "News Home".
+ *
+ * @param data
+ * @param profiles Vector of profiles for all roles user is part of
+ * @return Merged profile
+ * @exception Exception
+ */
+ private Profile mergeRoleProfiles(RunData data, Vector profiles)
+ throws Exception
+ {
+ Profile result = null;
+ // If merge feature is not turned on, return
+ // profile for the first role (if any)
+ if (!this.useRoleMerge)
+ {
+ if (profiles.size() > 0)
+ {
+ result = (Profile) profiles.get(0);
+ }
+ }
+ // Proceed with merging all profiles
+ else if (profiles.size() > 0)
+ {
+ try
+ {
+ // Create an empty portlet container
+ Portlets portlets = new PsmlPortlets();
+ Control control = new PsmlControl();
+ control.setName(this.rolemergeControl);
+ portlets.setControl(control);
+ Controller controller = new PsmlController();
+ controller.setName(this.rolemergeController);
+ portlets.setController(controller);
+
+ // Set the skin
+ Skin skin = new PsmlSkin();
+
skin.setName(org.apache.jetspeed.services.PortalToolkit.getSkin((String)
null).getName());
+ portlets.setSkin(skin);
+
+ String mediaType = null;
+
+ // Process each role profile
+ for (Iterator it = profiles.iterator(); it.hasNext(); )
+ {
+ Profile roleProfile = (Profile)it.next();
+ mediaType = mediaType == null ? roleProfile.getMediaType() :
mediaType;
+ Profile tmpProfile = (Profile) roleProfile.clone();
+ Portlets tmpPortlets = tmpProfile.getDocument().getPortlets();
+
+ // If topmost control is a tab control, then add each tab to
the container
+ Control tabControl = tmpPortlets.getControl();
+ if (tabControl != null &&
tabControl.getName().equals(this.rolemergeControl))
+ {
+ int tabCount = tmpPortlets.getPortletsCount();
+ for (int i = 0; i < tabCount; i++)
+ {
+ Portlets tab = tmpPortlets.getPortlets(i);
+ portlets.addPortlets(tab);
+ }
+ }
+ // Otherwise, add the contents of profile as a tab
+ else
+ {
+ String title =
org.apache.turbine.util.StringUtils.firstLetterCaps(roleProfile.getRoleName());
+ tmpPortlets.setTitle(title + " Home");
+ portlets.addPortlets(tmpPortlets);
+ }
+
+ if (Log.getLogger().isDebugEnabled())
+ {
+ Log.debug("JetspeedProfilerService: Processing profile for
role " + roleProfile.getRoleName());
+ }
+ }
+
+ // Create a new profile for the user
+ ProfileLocator locator = new BaseProfileLocator();
+ locator.setUser((JetspeedUser) data.getUser());
+ locator.setMediaType(mediaType);
+ locator.setName(this.resourceDefault + this.resourceExt);
+
+ // Regenerate the portlet ids so they are unique
+ this.regenerateIds(portlets);
+
+ // Save the new profile to permament storage
+ result = this.createProfile(locator, portlets);
+
+ }
+ catch (Exception e) {
+ Log.error(e);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Regenerates jspeid for all portlets and entries
+ *
+ * @param profile Profile to process
+ * @return Profile with portlet ids regenerated
+ */
+ private void regenerateIds(Portlets topPortlets)
+ throws Exception
+ {
+ // Display some portlets
+ Portlets[] portlets = topPortlets.getPortletsArray();
+ for (int i = 0; i < portlets.length; i++)
+ {
+ portlets[i].setId(JetspeedIdGenerator.getNextPeid());
+ Entry[] entries = portlets[i].getEntriesArray();
+ for (int j = 0; j < entries.length; j++)
+ {
+ entries[j].setId(JetspeedIdGenerator.getNextPeid());
+ }
+ regenerateIds(portlets[i]);
+ }
+ }
+
+ /**
* get the Profile object using the Rundata state and capability map
* this is the mapping functionality of the profiler
*
@@ -750,6 +897,12 @@
useFallbackLanguage = serviceConf.getBoolean( CONFIG_FALLBACK_LANGUAGE,
useFallbackLanguage );
+ useRoleMerge = serviceConf.getBoolean( CONFIG_ROLE_MERGE, useRoleMerge );
+
+ rolemergeControl = serviceConf.getString( CONFIG_ROLE_MERGE_CONTROL,
DEFAULT_CONFIG_ROLE_MERGE_CONTROL );
+
+ rolemergeController = serviceConf.getString( CONFIG_ROLE_MERGE_CONTROLLER,
DEFAULT_CONFIG_ROLE_MERGE_CONTROLLER );
+
if (useFallbackLanguage == false)
{
useFallbackCountry = false;
@@ -956,4 +1109,11 @@
return PsmlManager.query( locator );
}
+ /**
+ * @see
org.apache.jetspeed.services.profiler.ProfilerService#useRoleProfileMerging
+ */
+ public boolean useRoleProfileMerging()
+ {
+ return this.useRoleFallback && this.useRoleMerge;
+ }
}
1.14 +9 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/ProfilerService.java
Index: ProfilerService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/ProfilerService.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ProfilerService.java 28 Jun 2002 05:37:33 -0000 1.13
+++ ProfilerService.java 11 Sep 2002 18:30:55 -0000 1.14
@@ -69,6 +69,7 @@
*
* @see org.apache.jetspeed.om.profile.Profile
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mark Orciuch</a>
* @version $Id$
*/
@@ -170,5 +171,12 @@
* @return The list of profiles matching the locator criteria.
*/
public Iterator query( QueryLocator locator );
+
+ /**
+ * Returns status of role profile merging feature
+ *
+ * @return True if role profile merging is active
+ */
+ public boolean useRoleProfileMerging();
}
1.4 +3 -2
jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/turbine/TurbineUserManagement.java
Index: TurbineUserManagement.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/security/turbine/TurbineUserManagement.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TurbineUserManagement.java 26 Jul 2002 01:47:21 -0000 1.3
+++ TurbineUserManagement.java 11 Sep 2002 18:30:55 -0000 1.4
@@ -111,6 +111,7 @@
*
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Mark Orciuch</a>
* @version $Id$
*/
@@ -343,7 +344,7 @@
try
{
JetspeedRunData rundata = getRunData();
- if (rundata != null)
+ if (rundata != null && Profiler.useRoleProfileMerging() == false)
{
Profile profile = new BaseProfile();
profile.setUser(user);
1.88 +13 -1
jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties
Index: JetspeedResources.properties
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- JetspeedResources.properties 10 Sep 2002 01:54:35 -0000 1.87
+++ JetspeedResources.properties 11 Sep 2002 18:30:55 -0000 1.88
@@ -410,6 +410,18 @@
# If resource is not found under mediatype, keep searching?
services.Profiler.fallback.to.root=false
+#
+# Profiler Role-based merge fallback options
+#
+# When rolefallback is true and rolemerge is true, new user's profile will
+# be an aggregate of psml from each role the user is part of.
+services.Profiler.rolemerge=false
+
+# Controller to use in merged profile
+services.Profiler.rolemerge.controller=TabController
+
+# Control to use in merged profile
+services.Profiler.rolemerge.control=TabControl
#########################################
# Template Locator Service #
1.73 +4 -1 jakarta-jetspeed/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/xdocs/changes.xml,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- changes.xml 10 Sep 2002 15:12:08 -0000 1.72
+++ changes.xml 11 Sep 2002 18:30:55 -0000 1.73
@@ -23,6 +23,9 @@
</li>
-->
<li>
+ Add - Bug # 11735 - 2002/09/11 - Implemented role profile merging feature (MO)
+</li>
+<li>
Add - Bug # 11741 - 2002/09/10 - Implemented Print Friendly Format portlet action
(MO)
</li>
<li>
1.11 +7 -0 jakarta-jetspeed/xdocs/config_guide.xml
Index: config_guide.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/xdocs/config_guide.xml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- config_guide.xml 27 Aug 2002 20:17:30 -0000 1.10
+++ config_guide.xml 11 Sep 2002 18:30:55 -0000 1.11
@@ -617,6 +617,13 @@
services.Profiler.rolefallback=true
</source>
<p>Remember to set the "services.Profiler.newuser.template" property to nothing.</p>
+<p>In other configurations, it may be useful to create inital user PSML based on
the roles the
+user is a assigned. The role profile merging feature aggregates PSML from each role
to create
+a single tabbed profile. To enable this feature the following settings have to be
set to true:</p>
+<source>
+services.Profiler.rolefallback=true
+services.Profiler.rolemerge=true
+</source>
</subsection>
<subsection name = "Assigning Roles, Media Type">
<p>When a new user is created, you can configure which roles are automatically
signed to that new user.
1.31 +2 -2 jakarta-jetspeed/xdocs/todo.xml
Index: todo.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/xdocs/todo.xml,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- todo.xml 10 Sep 2002 15:12:08 -0000 1.30
+++ todo.xml 11 Sep 2002 18:30:55 -0000 1.31
@@ -147,7 +147,7 @@
</tr>
<tr>
<td>11735</td>
- <td>Role Profile Merging</td>
+ <td>Role Profile Merging. <strong>Done</strong></td>
<td>MO</td>
</tr>
<tr>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>