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 mo...@apache.org on 2005/01/22 00:50:33 UTC

cvs commit: jakarta-jetspeed/webapp/WEB-INF/conf JetspeedResources.properties

morciuch    2005/01/21 15:50:33

  Modified:    src/java/org/apache/jetspeed/services/profiler
                        JetspeedProfilerService.java
               webapp/WEB-INF/conf JetspeedResources.properties
  Log:
  Added group profile merging support (disabled by default). See http://issues.apache.org/jira/browse/JS1-537 for details.
  
  Revision  Changes    Path
  1.59      +638 -255  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.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- JetspeedProfilerService.java	13 Jul 2004 22:45:29 -0000	1.58
  +++ JetspeedProfilerService.java	21 Jan 2005 23:50:33 -0000	1.59
  @@ -17,6 +17,8 @@
   package org.apache.jetspeed.services.profiler;
   
   //java.util
  +import java.util.Collections;
  +import java.util.Comparator;
   import java.util.Iterator;
   import java.util.LinkedList;
   import java.util.List;
  @@ -28,6 +30,8 @@
   import org.apache.commons.lang.SerializationUtils;
   import org.apache.jetspeed.capability.CapabilityMap;
   import org.apache.jetspeed.capability.CapabilityMapFactory;
  +import org.apache.jetspeed.om.BaseSecurityReference;
  +import org.apache.jetspeed.om.SecurityReference;
   import org.apache.jetspeed.om.profile.BasePSMLDocument;
   import org.apache.jetspeed.om.profile.Control;
   import org.apache.jetspeed.om.profile.Controller;
  @@ -42,6 +46,7 @@
   import org.apache.jetspeed.om.profile.psml.PsmlController;
   import org.apache.jetspeed.om.profile.psml.PsmlPortlets;
   import org.apache.jetspeed.om.profile.psml.PsmlSkin;
  +import org.apache.jetspeed.om.registry.SecurityEntry;
   import org.apache.jetspeed.om.security.Group;
   import org.apache.jetspeed.om.security.GroupRole;
   import org.apache.jetspeed.om.security.JetspeedUser;
  @@ -50,6 +55,7 @@
   import org.apache.jetspeed.services.PortalToolkit;
   import org.apache.jetspeed.services.Profiler;
   import org.apache.jetspeed.services.PsmlManager;
  +import org.apache.jetspeed.services.Registry;
   import org.apache.jetspeed.services.ServiceHelper;
   import org.apache.jetspeed.services.customlocalization.CustomLocalizationService;
   import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
  @@ -65,6 +71,7 @@
   import org.apache.turbine.services.resources.TurbineResources;
   import org.apache.turbine.util.DynamicURI;
   import org.apache.turbine.util.RunData;
  +
   /**
    * <p>This is an implementation of the <code>Profiler</code> interface.
    *
  @@ -90,70 +97,99 @@
    * @version $Id$
    */
   
  -public class JetspeedProfilerService  extends TurbineBaseService
  +public class JetspeedProfilerService
  +    extends TurbineBaseService
       implements ProfilerService
   {
       /**
        * Static initialization of the logger for this class
  -     */    
  -    private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(JetspeedProfilerService.class.getName());
  -    
  +     */
  +    protected static final JetspeedLogger logger =
  +        JetspeedLogFactoryService.getLogger(
  +            JetspeedProfilerService.class.getName());
  +
       // configuration keys
  -    private final static String CONFIG_RESOURCE_DEFAULT = "resource.default";
  -    private final static String CONFIG_RESOURCE_EXT     = "resource.ext";
  -    private final static String CONFIG_SECURITY         = "security";
  -    private final static String CONFIG_ROLE_FALLBACK    = "rolefallback";
  -    private final static String CONFIG_NEWUSER_TEMPLATE  = "newuser.template";
  -    private final static String CONFIG_NEWGROUP_TEMPLATE = "newgroup.template";
  -    private final static String CONFIG_NEWUSER_MEDIA     = "newuser.media_types";
  -    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";
  +    protected final static String CONFIG_RESOURCE_DEFAULT = "resource.default";
  +    protected final static String CONFIG_RESOURCE_EXT = "resource.ext";
  +    protected final static String CONFIG_SECURITY = "security";
  +    protected final static String CONFIG_ROLE_FALLBACK = "rolefallback";
  +    protected final static String CONFIG_NEWUSER_TEMPLATE = "newuser.template";
  +    protected final static String CONFIG_NEWGROUP_TEMPLATE =
  +        "newgroup.template";
  +    protected final static String CONFIG_NEWUSER_MEDIA = "newuser.media_types";
  +    protected final static String CONFIG_FALLBACK_LANGUAGE =
  +        "fallback.language";
  +    protected final static String CONFIG_FALLBACK_COUNTRY = "fallback.country";
  +    protected final static String CONFIG_FALLBACK_TO_ROOT = "fallback.to.root";
  +    protected final static String CONFIG_ROLE_MERGE = "rolemerge";
  +    protected final static String CONFIG_ROLE_MERGE_CONTROL =
  +        "rolemerge.control";
  +    protected final static String CONFIG_ROLE_MERGE_CONTROLLER =
  +        "rolemerge.controller";
  +    protected final static String CONFIG_GROUP_MERGE = "groupmerge";
  +    protected final static String CONFIG_GROUP_MERGE_CONTROL =
  +        "groupmerge.control";
  +    protected final static String CONFIG_GROUP_MERGE_CONTROLLER =
  +        "groupmerge.controller";
  +    protected final static String CONFIG_GROUP_MERGE_SECURITYREF =
  +        "groupmerge.securityref";
   
       // default configuration values
  -    private final static String DEFAULT_CONFIG_RESOURCE_DEFAULT = "default";
  -    private final static String DEFAULT_CONFIG_RESOURCE_EXT = ".psml";
  -    private final static boolean DEFAULT_CONFIG_SECURITY = false;
  -    private final static boolean DEFAULT_CONFIG_ROLE_FALLBACK = true;
  -    private final static String DEFAULT_CONFIG_NEWUSER_TEMPLATE = null;
  -    private final static String DEFAULT_CONFIG_NEWGROUP_TEMPLATE = "Jetspeed";
  -    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";
  +    protected final static String DEFAULT_CONFIG_RESOURCE_DEFAULT = "default";
  +    protected final static String DEFAULT_CONFIG_RESOURCE_EXT = ".psml";
  +    protected final static boolean DEFAULT_CONFIG_SECURITY = false;
  +    protected final static boolean DEFAULT_CONFIG_ROLE_FALLBACK = true;
  +    protected final static String DEFAULT_CONFIG_NEWUSER_TEMPLATE = null;
  +    protected final static String DEFAULT_CONFIG_NEWGROUP_TEMPLATE = "Jetspeed";
  +    protected final static String[] DEFAULT_CONFIG_NEWUSER_MEDIA =
  +        { "html", "wml" };
  +    protected final static String DEFAULT_CONFIG_ROLE_MERGE_CONTROL =
  +        "TabControl";
  +    protected final static String DEFAULT_CONFIG_ROLE_MERGE_CONTROLLER =
  +        "TabController";
  +    protected final static String DEFAULT_CONFIG_GROUP_MERGE_CONTROL =
  +        "TabControl";
  +    protected final static String DEFAULT_CONFIG_GROUP_MERGE_CONTROLLER =
  +        "TabController";
   
  -    private final static String PATH_EXTENSION_DELIMITER = ".";
  +    protected final static String PATH_EXTENSION_DELIMITER = ".";
       // messages
  -    private final static String MSG_MISSING_PARAMETER =
  +    protected final static String MSG_MISSING_PARAMETER =
           "JetspeedProfilerService initialization failed. Missing parameter:";
   
       // pluggable Locator and Profile classes
  -    private Class profileClass = null;
  -    private Class locatorClass = null;
  -    
  +    protected Class profileClass = null;
  +    protected Class locatorClass = null;
   
       // configuration parameters
  -    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
  +    protected String root; // the root psml resource directory
  +    protected String resourceDefault; // the default name for a resource
  +    protected String resourceExt; // the default extension for a resource
  +    protected String rolemergeControl;
  +    // the default control used with merged role profiles
  +    protected String rolemergeController;
  +    // the default controller used with merged role profiles	
  +    protected String groupmergeControl;
  +    // the default control used with merged group profiles	
  +    protected String groupmergeController;
  +    // the default controller used with merged group profiles    	
  +    protected String groupmergeSecurityref;
  +    // the default security ref used with merged group profiles
   
       // MODIFIED: A. Kempf
  -    String newUserTemplate = DEFAULT_CONFIG_NEWUSER_TEMPLATE;
  +    protected String newUserTemplate = DEFAULT_CONFIG_NEWUSER_TEMPLATE;
       // added by Bob Fleischman - June 2004
  -    String newGroupTemplate = DEFAULT_CONFIG_NEWGROUP_TEMPLATE;
  +    protected String newGroupTemplate = DEFAULT_CONFIG_NEWGROUP_TEMPLATE;
   
  -    boolean useSecurity = false;   // use security features
  -    boolean useRoleFallback = true;
  -    boolean useFallbackLanguage = true;
  -    boolean useFallbackCountry = true;
  -    boolean useFallbackToRoot = false;
  -    boolean useRoleMerge = false;
  +    protected boolean useSecurity = false; // use security features
  +    protected boolean useRoleFallback = true;
  +    protected boolean useFallbackLanguage = true;
  +    protected boolean useFallbackCountry = true;
  +    protected boolean useFallbackToRoot = false;
  +    protected boolean useRoleMerge = false;
  +    protected boolean useGroupMerge = false;
   
  -    String mediaTypes[] = null;
  +    protected String mediaTypes[] = null;
   
       /**
        * This methode creates a wml profile and a html profile
  @@ -164,7 +200,7 @@
        * mailto: A.Kempf@web.de
        */
       public Profile createProfile(RunData data, Profile profile)
  -            throws ProfileException
  +        throws ProfileException
       {
           Profile current = null;
           CapabilityMap map;
  @@ -177,7 +213,7 @@
           }
           else
           {
  -            map = ((JetspeedRunData)data).getCapability();
  +            map = ((JetspeedRunData) data).getCapability();
           }
           String mediaType = getMediaType(data, map);
   
  @@ -185,24 +221,25 @@
           if (newUserTemplate == null)
               return current;
   
  - // If we see a group use it, else fall back to the prrior method
  - // Remember that Roles can also have profiles so it is not enough to just check for profile.getGroup() == null
  - // newTemplate is then passed into the createProfile call a few lines later
  - if (profile.getGroup() != null)
  - {
  - newTemplate = newGroupTemplate;
  - }
  - else
  - {
  - newTemplate = newUserTemplate;
  - }
  +        // If we see a group use it, else fall back to the prrior method
  +        // Remember that Roles can also have profiles so it is not enough to just check for profile.getGroup() == null
  +        // newTemplate is then passed into the createProfile call a few lines later
  +        if (profile.getGroup() != null)
  +        {
  +            newTemplate = newGroupTemplate;
  +        }
  +        else
  +        {
  +            newTemplate = newUserTemplate;
  +        }
   
           if (mediaTypes != null)
           {
               Profile dummy;
  -            for (int ix=0; ix < mediaTypes.length; ix++)
  +            for (int ix = 0; ix < mediaTypes.length; ix++)
               {
  -                dummy = createProfile(data, profile, mediaTypes[ix], newTemplate);
  +                dummy =
  +                    createProfile(data, profile, mediaTypes[ix], newTemplate);
                   if (mediaTypes[ix].equalsIgnoreCase(mediaType))
                       current = dummy;
               }
  @@ -219,11 +256,13 @@
        * @exception throws a <code>InitializationException</code> if the service
        * fails to initialize
        */
  -    public synchronized void init(ServletConfig conf) throws InitializationException
  +    public synchronized void init(ServletConfig conf)
  +        throws InitializationException
       {
  -        
  +
           // already initialized
  -        if (getInit()) return;
  +        if (getInit())
  +            return;
   
           try
           {
  @@ -237,7 +276,7 @@
           // initialization done
           setInit(true);
   
  -     }
  +    }
   
       /**
        * This is the shutdown method called by the
  @@ -258,46 +297,31 @@
       public Profile getProfile(RunData data, CapabilityMap cm)
           throws ProfileException
       {
  -        JetspeedRunData rundata = (JetspeedRunData)data;
  +        JetspeedRunData rundata = (JetspeedRunData) data;
           Profile profile = fallbackProfile(rundata, cm);
           if (null == profile && useRoleFallback)
           {
  -            Vector profiles = new Vector();
               JetspeedUser user = rundata.getJetspeedUser();
               if (user != null)
               {
                   try
                   {
  -                    String paramRole = rundata.getParameters().getString(Profiler.PARAM_ROLE);
  -                    Iterator groupRoles = JetspeedSecurity.getRoles(user.getUserName());
  -                    if (groupRoles != null)
  +                    if (useRoleMerge == true)
                       {
  -                        while (groupRoles.hasNext())
  -                        {
  -                            // note: this is an unordered list. will need to change db schema to order it
  -                            GroupRole gr = (GroupRole) groupRoles.next();
  -                            rundata.getParameters().setString( Profiler.PARAM_ROLE, gr.getRole().getName() );
  -                            profile = fallbackProfile(rundata, cm);
  -                            if (profile != null)
  -                            {
  -                                profiles.add(profile);
  -                            }
  -                            rundata.getParameters().remove(Profiler.PARAM_ROLE);
  -                        }
  -                        profile = mergeRoleProfiles(data, profiles);
  -
  -                        // If something went wrong with merging, attempt another fallback
  -                        if (profile == null)
  -                        {
  -                            profile = fallbackProfile(rundata, cm);
  -                        }
  +                        profile = getRoleProfile(rundata, cm);
  +                    }
  +                    else if (useGroupMerge = true)
  +                    {
  +                        profile = getGroupProfile(rundata, cm);
  +                    }
  +                    else
  +                    {
  +                        profile = getRoleProfile(rundata, cm);
                       }
  -                    
  -                    rundata.getParameters().setString(Profiler.PARAM_ROLE, paramRole);
                   }
                   catch (Exception e)
                   {
  -                    logger.error( "Error getting profile", e );
  +                    logger.error("Error getting profile", e);
                       throw new ProfileException(e.toString());
                   }
               }
  @@ -306,6 +330,53 @@
       }
   
       /**
  +     * Process role profiles
  +     * 
  +     * @param rundata
  +     * @param cm
  +     * @return
  +     * @throws Exception
  +     */
  +    protected Profile getRoleProfile(JetspeedRunData rundata, CapabilityMap cm)
  +        throws Exception
  +    {
  +        Vector profiles = new Vector();
  +        Profile profile = null;
  +        String paramRole =
  +            rundata.getParameters().getString(Profiler.PARAM_ROLE);
  +        Iterator groupRoles =
  +            JetspeedSecurity.getRoles(rundata.getUser().getUserName());
  +        if (groupRoles != null)
  +        {
  +            while (groupRoles.hasNext())
  +            {
  +                // note: this is an unordered list. will need to change db schema to order it
  +                GroupRole gr = (GroupRole) groupRoles.next();
  +                rundata.getParameters().setString(
  +                    Profiler.PARAM_ROLE,
  +                    gr.getRole().getName());
  +                profile = fallbackProfile(rundata, cm);
  +                if (profile != null)
  +                {
  +                    profiles.add(profile);
  +                }
  +                rundata.getParameters().remove(Profiler.PARAM_ROLE);
  +            }
  +            profile = mergeRoleProfiles(rundata, profiles);
  +
  +            // If something went wrong with merging, attempt another fallback
  +            if (profile == null)
  +            {
  +                profile = fallbackProfile(rundata, cm);
  +            }
  +        }
  +
  +        rundata.getParameters().setString(Profiler.PARAM_ROLE, paramRole);
  +
  +        return profile;
  +    }
  +
  +    /**
        * 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,
  @@ -317,7 +388,7 @@
        * @return Merged profile
        * @exception Exception
        */
  -    private Profile mergeRoleProfiles(RunData data, Vector profiles)
  +    protected Profile mergeRoleProfiles(RunData data, Vector profiles)
           throws Exception
       {
           Profile result = null;
  @@ -353,21 +424,28 @@
   
                   // Process each role profile
                   int paneCount = 0;
  -                for (Iterator it = profiles.iterator(); it.hasNext(); )
  +                for (Iterator it = profiles.iterator(); it.hasNext();)
                   {
  -                    Profile roleProfile = (Profile)it.next();
  -                    mediaType = mediaType == null ? roleProfile.getMediaType() : mediaType;
  +                    Profile roleProfile = (Profile) it.next();
  +                    mediaType =
  +                        mediaType == null
  +                            ? roleProfile.getMediaType()
  +                            : mediaType;
                       Profile tmpProfile = (Profile) roleProfile.clone();
  -                    Portlets tmpPortlets = tmpProfile.getDocument().getPortlets();
  +                    Portlets tmpPortlets =
  +                        tmpProfile.getDocument().getPortlets();
   
                       // If topmost control is a tab control, then add each tab to the container
                       Control paneControl = tmpPortlets.getControl();
  -                    if (paneControl != null && paneControl.getName().equals(this.rolemergeControl))
  +                    if (paneControl != null
  +                        && paneControl.getName().equals(this.rolemergeControl))
                       {
  -                        for (int i = 0; i < tmpPortlets.getPortletsCount(); i++)
  +                        for (int i = 0;
  +                            i < tmpPortlets.getPortletsCount();
  +                            i++)
                           {
                               Portlets pane = tmpPortlets.getPortlets(i);
  -                            pane.setLayout(null);                            
  +                            pane.setLayout(null);
                               portlets.addPortlets(pane);
                               paneCount++;
                           }
  @@ -377,7 +455,14 @@
                       {
                           if (tmpPortlets.getTitle() == null)
                           {
  -                            String title = org.apache.turbine.util.StringUtils.firstLetterCaps(roleProfile.getRoleName());
  +                            String title =
  +                                org
  +                                    .apache
  +                                    .turbine
  +                                    .util
  +                                    .StringUtils
  +                                    .firstLetterCaps(
  +                                    roleProfile.getRoleName());
                               tmpPortlets.setTitle(title + " Home");
                           }
                           tmpPortlets.setLayout(null);
  @@ -387,7 +472,9 @@
   
                       if (logger.isDebugEnabled())
                       {
  -                        logger.debug("Profiler: Processing profile for role " + roleProfile.getRoleName());
  +                        logger.debug(
  +                            "Profiler: Processing profile for role "
  +                                + roleProfile.getRoleName());
                       }
                   }
   
  @@ -404,9 +491,220 @@
                   result = this.createProfile(locator, portlets);
   
               }
  -            catch (Exception e) 
  +            catch (Exception e)
               {
  -                logger.error("Exception",  e);
  +                logger.error("Exception", e);
  +            }
  +        }
  +
  +        return result;
  +    }
  +
  +    /**
  +     * Process group profiles
  +     * 
  +     * @param rundata
  +     * @param cm
  +     * @return
  +     * @throws Exception
  +     */
  +    protected Profile getGroupProfile(
  +        JetspeedRunData rundata,
  +        CapabilityMap cm)
  +        throws Exception
  +    {
  +        Vector profiles = new Vector();
  +        Profile profile = null;
  +        String paramRole =
  +            rundata.getParameters().getString(Profiler.PARAM_ROLE);
  +        Iterator groups =
  +            JetspeedSecurity.getGroups(rundata.getUser().getUserName());
  +        if (groups != null)
  +        {
  +            while (groups.hasNext())
  +            {
  +                // note: this is an unordered list. will need to change db schema to order it
  +                Group gr = (Group) groups.next();
  +                rundata.getParameters().setString(
  +                    Profiler.PARAM_GROUP,
  +                    gr.getName());
  +                profile = fallbackProfile(rundata, cm);
  +                if (profile != null)
  +                {
  +                    profiles.add(profile);
  +                }
  +                rundata.getParameters().remove(Profiler.PARAM_GROUP);
  +            }
  +            profile = mergeGroupProfiles(rundata, profiles);
  +
  +            // If something went wrong with merging, attempt another fallback
  +            if (profile == null)
  +            {
  +                profile = fallbackProfile(rundata, cm);
  +            }
  +        }
  +
  +        rundata.getParameters().setString(Profiler.PARAM_GROUP, paramRole);
  +
  +        return profile;
  +    }
  +
  +    /**
  +     * Merge group profiles to create default profile. Resulting psml will be a set of
  +     * tabs. If groups'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 group's name. For example, if group name is "news",
  +     * the resulting profile name will be "News Home".
  +     * 
  +     * The group profiles are pre-sorted by group name.
  +     * 
  +     * A default security ref is set for the newly generated profile. 
  +     *
  +     * @param data
  +     * @param profiles Vector of profiles for all groups user is part of
  +     * @return Merged profile
  +     * @exception Exception
  +     */
  +    protected Profile mergeGroupProfiles(RunData data, Vector profiles)
  +        throws Exception
  +    {
  +        Profile result = null;
  +        // If merge feature is not turned on, return
  +        // profile for the first group (if any)
  +        if (this.useGroupMerge == false)
  +        {
  +            if (profiles.size() > 0)
  +            {
  +                result = (Profile) profiles.get(0);
  +            }
  +        }
  +        // Proceed with merging all profiles
  +        else if (profiles.size() > 0)
  +        {
  +            // Sort the profiles by group name (Jetspeed should come out on top if all other
  +            // group names are lower case
  +            // TODO: Need to figure out a better method of controlling the tab sequence            
  +            Collections.sort(profiles, new Comparator()
  +            {
  +                public int compare(Object o1, Object o2)
  +                {
  +                    Profile e1 = (Profile) o1;
  +                    Profile e2 = (Profile) o2;
  +                    Comparable v1 = (Comparable) e1.getGroupName();
  +                    Comparable v2 = (Comparable) e2.getGroupName();
  +                    return v1.compareTo(v2);
  +                }
  +            });
  +
  +            try
  +            {
  +                // Create an empty portlet container
  +                Portlets portlets = new PsmlPortlets();
  +                Control control = new PsmlControl();
  +                control.setName(this.groupmergeControl);
  +                portlets.setControl(control);
  +                Controller controller = new PsmlController();
  +                controller.setName(this.groupmergeController);
  +                portlets.setController(controller);
  +
  +                // Set title
  +                portlets.setTitle("Home Page");
  +
  +                // Set the skin
  +                Skin skin = new PsmlSkin();
  +                skin.setName(PortalToolkit.getSkin((String) null).getName());
  +                portlets.setSkin(skin);
  +
  +                // Set top level security ref
  +                if (groupmergeSecurityref != null)
  +                {
  +                    SecurityEntry entry =
  +                        (SecurityEntry) Registry.getEntry(
  +                            Registry.SECURITY,
  +                            groupmergeSecurityref);
  +                    if (entry != null)
  +                    {
  +                        SecurityReference ref = new BaseSecurityReference();
  +                        ref.setParent(entry.getName());
  +                        portlets.setSecurityRef(ref);
  +                    }
  +                }
  +
  +                String mediaType = null;
  +
  +                // Process each group profile
  +                int paneCount = 0;
  +                for (Iterator it = profiles.iterator(); it.hasNext();)
  +                {
  +                    Profile groupProfile = (Profile) it.next();
  +                    mediaType =
  +                        mediaType == null
  +                            ? groupProfile.getMediaType()
  +                            : mediaType;
  +                    Profile tmpProfile = (Profile) groupProfile.clone();
  +                    Portlets tmpPortlets =
  +                        tmpProfile.getDocument().getPortlets();
  +
  +                    // If topmost control is a tab control, then add each tab to the container
  +                    Control paneControl = tmpPortlets.getControl();
  +                    if (paneControl != null
  +                        && paneControl.getName().equals(this.groupmergeControl))
  +                    {
  +                        for (int i = 0;
  +                            i < tmpPortlets.getPortletsCount();
  +                            i++)
  +                        {
  +                            Portlets pane = tmpPortlets.getPortlets(i);
  +                            pane.setLayout(null);
  +                            portlets.addPortlets(pane);
  +                            paneCount++;
  +                        }
  +                    }
  +                    // Otherwise, add the contents of profile as a pane
  +                    else
  +                    {
  +                        if (tmpPortlets.getTitle() == null)
  +                        {
  +                            String title =
  +                                org
  +                                    .apache
  +                                    .turbine
  +                                    .util
  +                                    .StringUtils
  +                                    .firstLetterCaps(
  +                                    groupProfile.getRoleName());
  +                            tmpPortlets.setTitle(title + " Home");
  +                        }
  +                        tmpPortlets.setLayout(null);
  +                        portlets.addPortlets(tmpPortlets);
  +                        paneCount++;
  +                    }
  +
  +                    if (logger.isDebugEnabled())
  +                    {
  +                        logger.debug(
  +                            "Profiler: Processing profile for group "
  +                                + groupProfile.getGroupName());
  +                    }
  +                }
  +
  +                // Create a new profile for the user
  +                ProfileLocator locator = createLocator();
  +                locator.setUser((JetspeedUser) data.getUser());
  +                locator.setMediaType(mediaType);
  +                locator.setName("default.psml");
  +                //locator.setName(this.resourceDefault + this.resourceExt);
  +
  +                // Regenerate the portlet ids so they are unique
  +                org.apache.jetspeed.util.PortletUtils.regenerateIds(portlets);
  +
  +                // Save the new profile to permament storage
  +                result = this.createProfile(locator, portlets);
  +
  +            }
  +            catch (Exception e)
  +            {
  +                logger.error("Exception merging group profiles", e);
               }
           }
   
  @@ -426,7 +724,7 @@
       {
           try
           {
  -            JetspeedRunData rundata = (JetspeedRunData)data;
  +            JetspeedRunData rundata = (JetspeedRunData) data;
               Profile profile = createProfile();
               JetspeedUser user = rundata.getJetspeedUser();
   
  @@ -435,87 +733,93 @@
   
               //  Is it a group, role, or user resource?
               //  It can only be one
  -            String param = rundata.getParameters().getString( Profiler.PARAM_GROUP );
  +            String param =
  +                rundata.getParameters().getString(Profiler.PARAM_GROUP);
   
               if (null != param)
               {
                   // GROUP Resource
  -                profile.setGroup( JetspeedSecurity.getGroup(param) );
  +                profile.setGroup(JetspeedSecurity.getGroup(param));
               }
               else
               {
  -                param = rundata.getParameters().getString( Profiler.PARAM_ROLE );
  +                param = rundata.getParameters().getString(Profiler.PARAM_ROLE);
                   if (null != param)
                   {
                       // ROLE Resource
  -                    if (user.hasLoggedIn())  // disallow role access for anonymous user
  +                    if (user.hasLoggedIn())
  +                        // disallow role access for anonymous user
                       {
  -                        profile.setRole( JetspeedSecurity.getRole(param) );
  +                        profile.setRole(JetspeedSecurity.getRole(param));
                       }
                       else
                       {
                           profile.setAnonymous(true);
  -                        profile.setUser( user );
  +                        profile.setUser(user);
                       }
                   }
  -                else  // it must be a user resource or anonymous resource
  -                {
  +                else // it must be a user resource or anonymous resource
  +                    {
                       // accessing another user's resource
  -                    param = rundata.getParameters().getString( Profiler.PARAM_USER );
  +                    param =
  +                        rundata.getParameters().getString(Profiler.PARAM_USER);
                       if (null != param)
                       {
   
  -                        if (param.equals(JetspeedSecurity.getAnonymousUserName()))
  +                        if (param
  +                            .equals(JetspeedSecurity.getAnonymousUserName()))
                           {
                               profile.setAnonymous(true);
                           }
                           if (user.getUserName().equals(param))
                           {
  -                            profile.setUser( user );
  +                            profile.setUser(user);
                           }
                           else
                           {
  -                            profile.setUser( JetspeedSecurity.getUser(param) );
  +                            profile.setUser(JetspeedSecurity.getUser(param));
                           }
                       }
                       else
                       {
  -                        profile.setAnonymous(user.getUserName().equals(JetspeedSecurity.getAnonymousUserName()));
  -                        profile.setUser( user );
  +                        profile.setAnonymous(
  +                            user.getUserName().equals(
  +                                JetspeedSecurity.getAnonymousUserName()));
  +                        profile.setUser(user);
                       }
                   }
               }
   
               // get resource name
               StringBuffer resource = new StringBuffer();
  -            param = rundata.getParameters().getString( Profiler.PARAM_PAGE );
  +            param = rundata.getParameters().getString(Profiler.PARAM_PAGE);
               if (null == param)
               {
  -               // the default resource
  -                resource.append( resourceDefault );
  -                resource.append( resourceExt );
  +                // the default resource
  +                resource.append(resourceDefault);
  +                resource.append(resourceExt);
               }
               else
  -            {   // a specific resource
  -                resource.append( param );
  -                if ( -1 == param.indexOf( PATH_EXTENSION_DELIMITER ) )
  -                    resource.append( resourceExt );
  +            { // a specific resource
  +                resource.append(param);
  +                if (-1 == param.indexOf(PATH_EXTENSION_DELIMITER))
  +                    resource.append(resourceExt);
               }
  -            profile.setName( resource.toString() );
  +            profile.setName(resource.toString());
   
               // LANGUAGE
               getLanguageSettings(profile, rundata);
   
  -            PSMLDocument doc = fallback( profile );
  +            PSMLDocument doc = fallback(profile);
               if (null != doc)
               {
  -                profile.setDocument( doc );
  +                profile.setDocument(doc);
                   return profile;
               }
           }
           catch (Exception e)
           {
  -            logger.error( "Exception in fallbackProfile", e );
  +            logger.error("Exception in fallbackProfile", e);
               throw new ProfileException(e.toString());
           }
           return null;
  @@ -528,18 +832,17 @@
        * @param rundata the rundata object for the current request
        * @return a new Profile object
        */
  -    public Profile getProfile(RunData rundata)
  -        throws ProfileException
  +    public Profile getProfile(RunData rundata) throws ProfileException
       {
           CapabilityMap cm = null;
   
           if (rundata instanceof JetspeedRunData)
           {
  -            cm = ((JetspeedRunData)rundata).getCapability();
  +            cm = ((JetspeedRunData) rundata).getCapability();
           }
           else
           {
  -            cm = CapabilityMapFactory.getCapabilityMap( rundata );
  +            cm = CapabilityMapFactory.getCapabilityMap(rundata);
           }
   
           return getProfile(rundata, cm);
  @@ -568,10 +871,9 @@
        * @param locator The locator containing criteria describing the profile.
        * @return a new Profile object
        */
  -    public Profile getProfile(ProfileLocator locator)
  -        throws ProfileException
  +    public Profile getProfile(ProfileLocator locator) throws ProfileException
       {
  -        PSMLDocument doc =  fallback(locator);
  +        PSMLDocument doc = fallback(locator);
           Profile profile = createProfile(locator);
           profile.setDocument(doc);
           return profile;
  @@ -583,18 +885,20 @@
        * @param profile The profile object which is modified with the new language settings.
        * @param rundata The request specific state.
        */
  -    protected void getLanguageSettings( Profile profile, RunData rundata )
  +    protected void getLanguageSettings(Profile profile, RunData rundata)
       {
  -        String language = rundata.getParameters().getString(Profiler.PARAM_LANGUAGE);
  +        String language =
  +            rundata.getParameters().getString(Profiler.PARAM_LANGUAGE);
   
           if (language != null)
           {
               // dont use locale based fall back            
               profile.setLanguage(language);
   
  -            if(! language.equals("-1"))
  +            if (!language.equals("-1"))
               {
  -                String country = rundata.getParameters().getString(Profiler.PARAM_COUNTRY);
  +                String country =
  +                    rundata.getParameters().getString(Profiler.PARAM_COUNTRY);
                   if (country != null)
                   {
                       profile.setCountry(country);
  @@ -603,30 +907,36 @@
           }
           else
           {
  -            Locale locale = (Locale)rundata.getUser().getTemp("locale");
  +            Locale locale = (Locale) rundata.getUser().getTemp("locale");
               if (locale == null)
               {
                   // Get the locale store it in the user object
  -                CustomLocalizationService locService = (CustomLocalizationService) ServiceUtil.getServiceByName(
  -                    LocalizationService.SERVICE_NAME);
  +                CustomLocalizationService locService =
  +                    (CustomLocalizationService) ServiceUtil.getServiceByName(
  +                        LocalizationService.SERVICE_NAME);
                   locale = locService.getLocale(rundata);
                   if (locale == null)
                   {
  -                    locale = new Locale(
  -                                    TurbineResources.getString("locale.default.language", "en"),
  -                                    TurbineResources.getString("locale.default.country", "US"));
  +                    locale =
  +                        new Locale(
  +                            TurbineResources.getString(
  +                                "locale.default.language",
  +                                "en"),
  +                            TurbineResources.getString(
  +                                "locale.default.country",
  +                                "US"));
                   }
                   rundata.getUser().setTemp("locale", locale);
               }
   
               if (useFallbackLanguage)
               {
  -                profile.setLanguage( locale.getLanguage() );
  +                profile.setLanguage(locale.getLanguage());
               }
   
               if (useFallbackCountry)
               {
  -                profile.setCountry( locale.getCountry() );
  +                profile.setCountry(locale.getCountry());
               }
           }
       }
  @@ -640,52 +950,54 @@
        * @param rundata The request specific state.
        * @return The found psml document, or null if not found.
        */
  -    protected PSMLDocument fallbackList( ProfileLocator original, RunData rundata )
  +    protected PSMLDocument fallbackList(
  +        ProfileLocator original,
  +        RunData rundata)
       {
           try
           {
               List locators = new LinkedList();
  -            ProfileLocator locator = (ProfileLocator)original.clone();
  +            ProfileLocator locator = (ProfileLocator) original.clone();
   
  -            locators.add( locator.clone() );
  +            locators.add(locator.clone());
   
               // remove country
               if (null != original.getCountry())
               {
                   locator.setCountry(null);
  -                locators.add( locator.clone() );
  +                locators.add(locator.clone());
               }
   
               // remove language
               if (null != original.getLanguage())
               {
                   locator.setLanguage(null);
  -                locators.add( locator.clone() );
  +                locators.add(locator.clone());
               }
   
               // fallback mediaType
               if (null != original.getMediaType())
               {
                   locator.setMediaType(null);
  -                locators.add( locator.clone() );
  +                locators.add(locator.clone());
               }
   
               if (null != original.getGroup())
               {
                   locator.setGroup(null);
  -                locators.add( locator.clone() );
  +                locators.add(locator.clone());
               }
               else if (null != original.getRole())
               {
                   locator.setRole(null);
  -                locators.add( locator.clone() );
  +                locators.add(locator.clone());
               }
               else if (null != original.getUser())
               {
                   locator.setUser(null);
  -                locators.add( locator.clone() );
  +                locators.add(locator.clone());
               }
  -            PSMLDocument doc = PsmlManager.getDocument( locators );
  +            PSMLDocument doc = PsmlManager.getDocument(locators);
               return doc;
   
           }
  @@ -711,27 +1023,29 @@
       {
           if (logger.isDebugEnabled())
           {
  -            logger.debug( "Profiler: fallback called with: " + locator );
  +            logger.debug("Profiler: fallback called with: " + locator);
           }
   
  -        PSMLDocument doc = PsmlManager.getDocument( locator );
  +        PSMLDocument doc = PsmlManager.getDocument(locator);
           if (null != doc)
               return doc;
   
           // remove country
  -        if (null != locator.getCountry() && (! locator.getCountry().equals("-1")))
  +        if (null != locator.getCountry()
  +            && (!locator.getCountry().equals("-1")))
           {
               locator.setCountry(null);
  -            doc = PsmlManager.getDocument( locator );
  +            doc = PsmlManager.getDocument(locator);
               if (null != doc)
                   return doc;
           }
   
           // remove language
  -        if (null != locator.getLanguage() && (! locator.getLanguage().equals("-1")))
  +        if (null != locator.getLanguage()
  +            && (!locator.getLanguage().equals("-1")))
           {
               locator.setLanguage(null);
  -            doc = PsmlManager.getDocument( locator );
  +            doc = PsmlManager.getDocument(locator);
               if (null != doc)
                   return doc;
           }
  @@ -742,7 +1056,7 @@
               if (null != locator.getMediaType())
               {
                   locator.setMediaType(null);
  -                doc = PsmlManager.getDocument( locator );
  +                doc = PsmlManager.getDocument(locator);
                   if (null != doc)
                       return doc;
               }
  @@ -753,21 +1067,21 @@
               if (null != locator.getGroup())
               {
                   locator.setGroup(null);
  -                doc = PsmlManager.getDocument( locator );
  +                doc = PsmlManager.getDocument(locator);
                   if (null != doc)
                       return doc;
               }
               else if (null != locator.getRole())
               {
                   locator.setRole(null);
  -                doc = PsmlManager.getDocument( locator );
  +                doc = PsmlManager.getDocument(locator);
                   if (null != doc)
                       return doc;
               }
               else if (null != locator.getUser())
               {
                   locator.setUser(null);
  -                doc = PsmlManager.getDocument( locator );
  +                doc = PsmlManager.getDocument(locator);
                   if (null != doc)
                       return doc;
               }
  @@ -791,7 +1105,8 @@
   
           if (null != rundata)
           {
  -            paramMediaType = rundata.getParameters().getString( Profiler.PARAM_MEDIA_TYPE );
  +            paramMediaType =
  +                rundata.getParameters().getString(Profiler.PARAM_MEDIA_TYPE);
               if (null != paramMediaType)
               {
                   return paramMediaType;
  @@ -813,40 +1128,98 @@
        * @exception throws a <code>InitializationException</code> if the service
        * fails to initialize
        */
  -    private void initConfiguration() throws InitializationException
  +    protected void initConfiguration() throws InitializationException
       {
           profileClass = ServiceHelper.loadModelClass(this, "profile.impl");
           locatorClass = ServiceHelper.loadModelClass(this, "locator.impl");
  -        
  -        // get configuration parameters from Jetspeed Resources
  -        ResourceService serviceConf = ((TurbineServices)TurbineServices.getInstance())
  -                                                     .getResources(ProfilerService.SERVICE_NAME);
  -
  -        resourceDefault = serviceConf.getString( CONFIG_RESOURCE_DEFAULT, DEFAULT_CONFIG_RESOURCE_DEFAULT );
   
  -        resourceExt = serviceConf.getString( CONFIG_RESOURCE_EXT, DEFAULT_CONFIG_RESOURCE_EXT );
  +        // get configuration parameters from Jetspeed Resources
  +        ResourceService serviceConf =
  +            ((TurbineServices) TurbineServices.getInstance()).getResources(
  +                ProfilerService.SERVICE_NAME);
  +
  +        resourceDefault =
  +            serviceConf.getString(
  +                CONFIG_RESOURCE_DEFAULT,
  +                DEFAULT_CONFIG_RESOURCE_DEFAULT);
  +
  +        resourceExt =
  +            serviceConf.getString(
  +                CONFIG_RESOURCE_EXT,
  +                DEFAULT_CONFIG_RESOURCE_EXT);
           if (-1 == resourceExt.indexOf(PATH_EXTENSION_DELIMITER))
           {
               resourceExt = PATH_EXTENSION_DELIMITER + resourceExt;
           }
  -        
  -        useSecurity = serviceConf.getBoolean( CONFIG_SECURITY, DEFAULT_CONFIG_SECURITY );
   
  -        useRoleFallback = serviceConf.getBoolean( CONFIG_ROLE_FALLBACK, DEFAULT_CONFIG_ROLE_FALLBACK );
  +        useSecurity =
  +            serviceConf.getBoolean(CONFIG_SECURITY, DEFAULT_CONFIG_SECURITY);
  +
  +        useRoleFallback =
  +            serviceConf.getBoolean(
  +                CONFIG_ROLE_FALLBACK,
  +                DEFAULT_CONFIG_ROLE_FALLBACK);
  +
  +        newUserTemplate =
  +            serviceConf.getString(
  +                CONFIG_NEWUSER_TEMPLATE,
  +                DEFAULT_CONFIG_NEWUSER_TEMPLATE);
  +
  +        newGroupTemplate =
  +            serviceConf.getString(
  +                CONFIG_NEWGROUP_TEMPLATE,
  +                DEFAULT_CONFIG_NEWGROUP_TEMPLATE);
   
  -        newUserTemplate = serviceConf.getString( CONFIG_NEWUSER_TEMPLATE, DEFAULT_CONFIG_NEWUSER_TEMPLATE );
  +        useFallbackToRoot =
  +            serviceConf.getBoolean(CONFIG_FALLBACK_TO_ROOT, useFallbackToRoot);
   
  -        newGroupTemplate = serviceConf.getString( CONFIG_NEWGROUP_TEMPLATE, DEFAULT_CONFIG_NEWGROUP_TEMPLATE );
  +        useFallbackLanguage =
  +            serviceConf.getBoolean(
  +                CONFIG_FALLBACK_LANGUAGE,
  +                useFallbackLanguage);
  +
  +        useRoleMerge = serviceConf.getBoolean(CONFIG_ROLE_MERGE, useRoleMerge);
  +        useGroupMerge =
  +            serviceConf.getBoolean(CONFIG_GROUP_MERGE, useGroupMerge);
  +
  +        if (useRoleMerge && useGroupMerge)
  +        {
  +            logger.warn(
  +                "Both role and group merging are enabled. Disabling the group merging feature");
  +            useGroupMerge = false;
  +        }
  +
  +        if (useRoleMerge)
  +        {
  +            useRoleFallback = true;
   
  -        useFallbackToRoot = serviceConf.getBoolean( CONFIG_FALLBACK_TO_ROOT, useFallbackToRoot );
  +            rolemergeControl =
  +                serviceConf.getString(
  +                    CONFIG_ROLE_MERGE_CONTROL,
  +                    DEFAULT_CONFIG_ROLE_MERGE_CONTROL);
   
  -        useFallbackLanguage = serviceConf.getBoolean( CONFIG_FALLBACK_LANGUAGE, useFallbackLanguage );
  +            rolemergeController =
  +                serviceConf.getString(
  +                    CONFIG_ROLE_MERGE_CONTROLLER,
  +                    DEFAULT_CONFIG_ROLE_MERGE_CONTROLLER);
  +        }
  +        else if (useGroupMerge)
  +        {
  +            useRoleFallback = true;
   
  -        useRoleMerge = serviceConf.getBoolean( CONFIG_ROLE_MERGE, useRoleMerge );
  +            groupmergeControl =
  +                serviceConf.getString(
  +                    CONFIG_GROUP_MERGE_CONTROL,
  +                    DEFAULT_CONFIG_GROUP_MERGE_CONTROL);
   
  -        rolemergeControl = serviceConf.getString( CONFIG_ROLE_MERGE_CONTROL, DEFAULT_CONFIG_ROLE_MERGE_CONTROL );
  +            groupmergeController =
  +                serviceConf.getString(
  +                    CONFIG_GROUP_MERGE_CONTROLLER,
  +                    DEFAULT_CONFIG_GROUP_MERGE_CONTROLLER);
   
  -        rolemergeController = serviceConf.getString( CONFIG_ROLE_MERGE_CONTROLLER, DEFAULT_CONFIG_ROLE_MERGE_CONTROLLER );
  +            groupmergeSecurityref =
  +                serviceConf.getString(CONFIG_GROUP_MERGE_SECURITYREF, null);
  +        }
   
           if (useFallbackLanguage == false)
           {
  @@ -854,7 +1227,10 @@
           }
           else
           {
  -            useFallbackCountry = serviceConf.getBoolean( CONFIG_FALLBACK_COUNTRY, useFallbackCountry );
  +            useFallbackCountry =
  +                serviceConf.getBoolean(
  +                    CONFIG_FALLBACK_COUNTRY,
  +                    useFallbackCountry);
           }
   
           try
  @@ -863,7 +1239,7 @@
           }
           catch (Exception e)
           {
  -            logger.error( "Error getting media types", e );
  +            logger.error("Error getting media types", e);
           }
   
           if (null == mediaTypes || mediaTypes.length == 0)
  @@ -872,33 +1248,33 @@
           }
       }
   
  -   /**
  -    * Builds a dynamic URI based on the current profiler group/role/page
  -    *
  -    * @param data The rundata object for the current request.
  -    * @param locator The description of the profile.
  -    * @return A new dynamic URI representing all profile parameters from the locator.
  -    */
  -    public DynamicURI makeDynamicURI( RunData data, ProfileLocator locator )
  +    /**
  +     * Builds a dynamic URI based on the current profiler group/role/page
  +     *
  +     * @param data The rundata object for the current request.
  +     * @param locator The description of the profile.
  +     * @return A new dynamic URI representing all profile parameters from the locator.
  +     */
  +    public DynamicURI makeDynamicURI(RunData data, ProfileLocator locator)
           throws ProfileException
       {
  -        DynamicURI uri = new DynamicURI( data );
  +        DynamicURI uri = new DynamicURI(data);
   
  -       // check mediatype to add to the uri
  +        // check mediatype to add to the uri
           String mtype = locator.getMediaType();
           if (null != mtype)
           {
               uri.addPathInfo(Profiler.PARAM_MEDIA_TYPE, mtype);
           }
   
  -       // check language to add to the uri
  +        // check language to add to the uri
           String language = locator.getLanguage();
           if (null != language)
           {
               uri.addPathInfo(Profiler.PARAM_LANGUAGE, language);
           }
   
  -       // check language to add to the uri
  +        // check language to add to the uri
           String country = locator.getCountry();
           if (null != country)
           {
  @@ -947,7 +1323,7 @@
        */
       public Profile createProfile()
       {
  -        return (Profile)ServiceHelper.createObject(this.profileClass);
  +        return (Profile) ServiceHelper.createObject(this.profileClass);
       }
   
       /**
  @@ -958,7 +1334,8 @@
        */
       public Profile createProfile(ProfileLocator locator)
       {
  -        Profile profile = (Profile)ServiceHelper.createObject(this.profileClass);
  +        Profile profile =
  +            (Profile) ServiceHelper.createObject(this.profileClass);
           profile.init(locator);
           return profile;
       }
  @@ -971,7 +1348,7 @@
        */
       public ProfileLocator createLocator()
       {
  -        return (ProfileLocator)ServiceHelper.createObject(this.locatorClass);
  +        return (ProfileLocator) ServiceHelper.createObject(this.locatorClass);
       }
   
       /**
  @@ -985,13 +1362,13 @@
        */
   
       public Profile createProfile(ProfileLocator locator, Portlets portlets)
  -            throws ProfileException
  +        throws ProfileException
       {
           if (portlets == null)
           {
               portlets = new PsmlPortlets();
           }
  -        
  +
           Profile profile = createProfile(locator);
           PSMLDocument doc = new BasePSMLDocument(null, portlets);
           profile.setDocument(doc);
  @@ -1018,29 +1395,33 @@
        * for a new user
        */
   
  -    public Profile createProfile( RunData data, Profile profile, String contentType, String from )
  -            throws ProfileException
  +    public Profile createProfile(
  +        RunData data,
  +        Profile profile,
  +        String contentType,
  +        String from)
  +        throws ProfileException
       {
  -      if ((contentType == null) || (contentType.length() < 2))
  -        contentType = "html";
  +        if ((contentType == null) || (contentType.length() < 2))
  +            contentType = "html";
   
  - if ((from == null) || (from.length() < 2))
  - {
  -//
  -// This is just for groups - Roles will continue to be treated like users
  -//
  - if (profile.getGroup() != null)
  - from = DEFAULT_CONFIG_NEWGROUP_TEMPLATE;
  - else
  - from = DEFAULT_CONFIG_NEWUSER_TEMPLATE;
  - }
  -
  -// turbine was hardcoded here - RMF June 2004
  -// if ((from == null) || (from.length() < 2))
  -// from = "turbine";
  +        if ((from == null) || (from.length() < 2))
  +        {
  +            //
  +            // This is just for groups - Roles will continue to be treated like users
  +            //
  +            if (profile.getGroup() != null)
  +                from = DEFAULT_CONFIG_NEWGROUP_TEMPLATE;
  +            else
  +                from = DEFAULT_CONFIG_NEWUSER_TEMPLATE;
  +        }
   
  +        // turbine was hardcoded here - RMF June 2004
  +        // if ((from == null) || (from.length() < 2))
  +        // from = "turbine";
   
  -        if ((null == profile.getDocument()) || (!profile.getMediaType().equalsIgnoreCase (contentType)))
  +        if ((null == profile.getDocument())
  +            || (!profile.getMediaType().equalsIgnoreCase(contentType)))
           {
               // locate the default resource
   
  @@ -1052,11 +1433,11 @@
                   // If group is not null assume this is a Group we are requesting
                   if (profile.getGroup() != null)
                   {
  -                    locator.setGroup( JetspeedSecurity.getGroup(from) );
  +                    locator.setGroup(JetspeedSecurity.getGroup(from));
                   }
                   else
                   {
  -                    locator.setUser( JetspeedSecurity.getUser(from) );
  +                    locator.setUser(JetspeedSecurity.getUser(from));
                   }
   
                   locator.setMediaType(contentType);
  @@ -1064,17 +1445,19 @@
   
                   if (doc != null)
                   {
  -                    PSMLDocument clonedDoc = (PSMLDocument) SerializationUtils.clone(doc);
  -                    org.apache.jetspeed.util.PortletUtils.regenerateIds(clonedDoc.getPortlets());
  +                    PSMLDocument clonedDoc =
  +                        (PSMLDocument) SerializationUtils.clone(doc);
  +                    org.apache.jetspeed.util.PortletUtils.regenerateIds(
  +                        clonedDoc.getPortlets());
                       profile.setDocument(clonedDoc);
                   }
   
  -                profile.setName( resourceDefault + resourceExt );
  +                profile.setName(resourceDefault + resourceExt);
   
               }
               catch (Exception e)
               {
  -                logger.error( "Error creating profile", e );
  +                logger.error("Error creating profile", e);
                   throw new ProfileException(e.toString());
               }
           }
  @@ -1084,7 +1467,7 @@
               profile.setMediaType(contentType);
   
               PSMLDocument doc = PsmlManager.createDocument(profile);
  -            Profile newProfile = (Profile)profile.clone();
  +            Profile newProfile = (Profile) profile.clone();
               newProfile.setDocument(doc);
   
               return newProfile;
  @@ -1097,29 +1480,30 @@
   
       }
   
  -   /** Create a new profile.
  -     *
  -     * @deprecated Should be removed when old customizer is removed.
  -     *
  -     * @param rundata The rundata object for the current request.
  -     * @param profile The description of the new profile to be created.
  -     * @param mt The specific mime type, which is converted to a mediatype.
  -     * @return The newly created profile.
  -     */
  -    public Profile createProfile( RunData data, Profile profile, MimeType mt )
  +    /** Create a new profile.
  +      *
  +      * @deprecated Should be removed when old customizer is removed.
  +      *
  +      * @param rundata The rundata object for the current request.
  +      * @param profile The description of the new profile to be created.
  +      * @param mt The specific mime type, which is converted to a mediatype.
  +      * @return The newly created profile.
  +      */
  +    public Profile createProfile(RunData data, Profile profile, MimeType mt)
           throws ProfileException
       {
  -        CapabilityMap cm = CapabilityMapFactory.getCapabilityMap(mt.getContentType());
  -        profile.setMediaType( getMediaType(data, cm) );
  +        CapabilityMap cm =
  +            CapabilityMapFactory.getCapabilityMap(mt.getContentType());
  +        profile.setMediaType(getMediaType(data, cm));
           return createProfile(data, profile);
       }
   
  -   /**
  -     *  Removes a profile.
  -     *
  -     * @param locator The profile locator criteria.
  -     */
  -    public void removeProfile( ProfileLocator locator )
  +    /**
  +      *  Removes a profile.
  +      *
  +      * @param locator The profile locator criteria.
  +      */
  +    public void removeProfile(ProfileLocator locator)
       {
           PsmlManager.removeDocument(locator);
       }
  @@ -1129,9 +1513,9 @@
        * @param locator The profile locator criteria.
        * @return The list of profiles matching the locator criteria.
        */
  -    public Iterator query( QueryLocator locator )
  +    public Iterator query(QueryLocator locator)
       {
  -        return PsmlManager.query( locator );
  +        return PsmlManager.query(locator);
       }
   
       /**
  @@ -1142,4 +1526,3 @@
           return this.useRoleFallback && this.useRoleMerge;
       }
   }
  -
  
  
  
  1.131     +17 -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.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- JetspeedResources.properties	29 Aug 2004 23:09:29 -0000	1.130
  +++ JetspeedResources.properties	21 Jan 2005 23:50:33 -0000	1.131
  @@ -509,6 +509,22 @@
   # Control to use in merged profile
   services.Profiler.rolemerge.control=TabControl
   
  +#
  +# Profiler Group-based merge fallback options
  +#
  +# When rolefallback is true and groupmerge is true, new user's profile will 
  +# be an aggregate of psml from each group the user is part of.
  +services.Profiler.groupmerge=false
  +
  +# Controller to use in merged profile
  +services.Profiler.groupmerge.controller=TabController
  +
  +# Control to use in merged profile
  +services.Profiler.groupmerge.control=TabControl
  +
  +# Security ref to use in merged profile
  +services.Profiler.groupmerge.securityref=admin_and_owner_only
  +
   # default profile and locator class impls
   services.Profiler.profile.impl = org.apache.jetspeed.om.profile.BaseProfile
   services.Profiler.locator.impl = org.apache.jetspeed.om.profile.BaseProfileLocator
  
  
  

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