portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morci...@apache.org
Subject cvs commit: jakarta-jetspeed/xdocs changes.xml
Date Wed, 05 Mar 2003 22:53:21 GMT
morciuch    2003/03/05 14:53:21

  Modified:    docs/site changes.html
               src/java/org/apache/jetspeed/modules/actions/portlets/security
                        UserRoleUpdateAction.java
               xdocs    changes.xml
  Log:
  Assigning new role will merge the role's psml (see Bugzilla issue# 17289)
  
  Revision  Changes    Path
  1.113     +3 -2      jakarta-jetspeed/docs/site/changes.html
  
  Index: changes.html
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/docs/site/changes.html,v
  retrieving revision 1.112
  retrieving revision 1.113
  diff -u -r1.112 -r1.113
  --- changes.html	26 Feb 2003 17:50:06 -0000	1.112
  +++ changes.html	5 Mar 2003 22:53:21 -0000	1.113
  @@ -5,7 +5,6 @@
           
   <!-- start the processing -->
       <!-- ====================================================================== -->
  -    <!-- GENERATED FILE, DO NOT EDIT, EDIT THE XML FILE IN xdocs INSTEAD! -->
       <!-- Main Page Section -->
       <!-- ====================================================================== -->
       <html>
  @@ -15,7 +14,6 @@
                           
              
                                       
  -                        
               <title>Jetspeed - Jetspeed Changes Log</title>
           </head>
   
  @@ -134,6 +132,9 @@
     action (add/remove/update/fix) - [Bug # xxx -] date - description (committer's initials)
[Thanks to developer_name]
   </li>
   -->
  +<li>
  +  Add -   Bug # 17289 - 2003/03/05 - Assigning new role will merge the role's psml (MO)
  +</li>
   <li>
     Add -                 2003/02/26 - ChangeLanguagePortlet, contributed by Dessė Massimiliano
(DST)
   </li>
  
  
  
  1.7       +91 -3     jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/security/UserRoleUpdateAction.java
  
  Index: UserRoleUpdateAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/security/UserRoleUpdateAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- UserRoleUpdateAction.java	4 Mar 2003 00:04:54 -0000	1.6
  +++ UserRoleUpdateAction.java	5 Mar 2003 22:53:21 -0000	1.7
  @@ -75,7 +75,13 @@
   // jetspeed services
   import org.apache.jetspeed.services.JetspeedSecurity;
   import org.apache.jetspeed.services.resources.JetspeedResources;
  -
  +import org.apache.jetspeed.services.Profiler;
  +import org.apache.jetspeed.om.profile.ProfileLocator;
  +import org.apache.jetspeed.om.profile.Profile;
  +import org.apache.jetspeed.om.profile.Portlets;
  +import org.apache.jetspeed.services.PsmlManager;
  +import org.apache.jetspeed.util.PortletUtils;
  +import org.apache.jetspeed.services.rundata.JetspeedRunData;
   
   // jetspeed velocity
   import org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction;
  @@ -233,8 +239,14 @@
                       if (newValue == true)
                       {
                           // grant a role to a user
  -                        JetspeedSecurity.grantRole( user.getUserName(),
  -                                                ((Role)roles.get(ix)).getName() );
  +                        Role newRole = (Role) roles.get(ix);
  +                        JetspeedSecurity.grantRole( user.getUserName(), newRole.getName());
  +
  +                        // If role profile merging is active, append profile for the new
role
  +                        if (Profiler.useRoleProfileMerging())
  +                        {
  +                            appendNewRoleProfile((JetspeedRunData) rundata, user, newRole);
  +                        }
                       }
                       else
                       {
  @@ -265,6 +277,82 @@
                   duri.addPathInfo(SecurityConstants.PARAM_ENTITY_ID, user.getUserName());
               rundata.setRedirectURI(duri.toString());
   
  +        }
  +    }
  +
  +    /**
  +     * Appends profile for specified role to the end of profile for specified user
  +     * 
  +     * @param user   User to append to
  +     * @param role   Role to append from
  +     * @exception Exception
  +     */
  +    private void appendNewRoleProfile(JetspeedRunData jdata, JetspeedUser user, Role role)
  +    throws Exception
  +    {
  +        // Retrieve the role profile
  +        ProfileLocator roleLocator = Profiler.createLocator();
  +        roleLocator.setRole(role);
  +        roleLocator.setMediaType(jdata.getCapability().getPreferredMediaType());
  +        roleLocator.setName("default.psml");
  +        Profile roleProfile = Profiler.getProfile(roleLocator);
  +        if (roleProfile != null)
  +        {
  +            if (Log.getLogger().isDebugEnabled())
  +            {
  +                Log.debug("UserRoleUpdateAction: retrieved profile for role: " + roleProfile.getPath());
  +            }
  +        }
  +
  +        // Retrieve the user profile
  +        ProfileLocator userLocator = Profiler.createLocator();
  +        userLocator.setUser(user);
  +        userLocator.setMediaType(jdata.getCapability().getPreferredMediaType());
  +        userLocator.setName("default.psml");
  +        Profile userProfile = Profiler.getProfile(userLocator);
  +        if (userProfile != null)
  +        {
  +            if (Log.getLogger().isDebugEnabled())
  +            {
  +                Log.debug("UserRoleUpdateAction: retrieved profile for user: " + userProfile.getPath());
  +            }
  +        }
  +
  +        // Append role profile to user profile
  +        if (roleProfile != null && userProfile != null)
  +        {
  +            Profile tmpProfile = (Profile) roleProfile.clone();
  +            Portlets rolePortlets = tmpProfile.getDocument().getPortlets();
  +            Portlets userPortlets = userProfile.getDocument().getPortlets();
  +
  +            // Handle pane based profile
  +            if (rolePortlets.getPortletsCount() > 0)
  +            {
  +                for (int i = 0; i < rolePortlets.getPortletsCount(); i++)
  +                {
  +                    Portlets pane = rolePortlets.getPortlets(i);
  +                    pane.setLayout(null);                            
  +                    userPortlets.addPortlets(pane);
  +                    if (Log.getLogger().isDebugEnabled())
  +                    {
  +                        Log.debug("UserRoleUpdateAction: appended pane: " + pane.getId()
+ " to user: " + user.getUserName());
  +                    }
  +                }
  +            }
  +            // Handle profile with no panes
  +            else
  +            {
  +                String title = org.apache.turbine.util.StringUtils.firstLetterCaps(roleProfile.getRoleName());
  +                rolePortlets.setTitle(title + " Home");
  +                rolePortlets.setLayout(null);
  +                userPortlets.addPortlets(rolePortlets);
  +            }
  +
  +            // Regenerate ids
  +            PortletUtils.regenerateIds(userPortlets);
  +
  +            // Save the user profile
  +            PsmlManager.store(userProfile);
           }
       }
   
  
  
  
  1.130     +4 -1      jakarta-jetspeed/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/xdocs/changes.xml,v
  retrieving revision 1.129
  retrieving revision 1.130
  diff -u -r1.129 -r1.130
  --- changes.xml	26 Feb 2003 17:50:07 -0000	1.129
  +++ changes.xml	5 Mar 2003 22:53:21 -0000	1.130
  @@ -23,6 +23,9 @@
   </li>
   -->
   <li>
  +  Add -   Bug # 17289 - 2003/03/05 - Assigning new role will merge the role's psml (MO)
  +</li>
  +<li>
     Add -                 2003/02/26 - ChangeLanguagePortlet, contributed by Dessė Massimiliano
(DST)
   </li>
   <li>
  
  
  

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


Mime
View raw message