portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r552610 - in /portals/jetspeed-2/trunk: applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/ applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/ applications/j2-admin/src/java/org/apache/jetspeed/portl...
Date Mon, 02 Jul 2007 22:25:30 GMT
Author: taylor
Date: Mon Jul  2 15:25:29 2007
New Revision: 552610

URL: http://svn.apache.org/viewvc?view=rev&rev=552610
Log:
http://issues.apache.org/jira/browse/JS2-707

When creating a new user, give option to create inside a subsite
Also added the same options to the User Registration portlet
This enables us to create users directly into subsites using either the User Admin portlet,
or self-reg

Modified:
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/SecurityResources.java
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/resources/SecurityResources.properties
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/resources/SecurityResources_en.properties
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
    portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/security/users/user-details-edit.jsp
    portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/security/users/user-details.jsp
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalAdministration.java
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/security/User.java
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/min-pages/page.security
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/pages/page.security

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java
Mon Jul  2 15:25:29 2007
@@ -33,6 +33,7 @@
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
 import javax.portlet.PortletPreferences;
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletResponse;
@@ -51,6 +52,7 @@
 import org.apache.jetspeed.security.SecurityException;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
+import org.apache.portals.bridges.util.PreferencesHelper;
 import org.apache.portals.bridges.velocity.AbstractVelocityMessagingPortlet;
 import org.apache.portals.gems.util.ValidationHelper;
 import org.apache.velocity.context.Context;
@@ -235,6 +237,13 @@
         this.redirectPath = config.getInitParameter(IP_REDIRECT_PATH);
     }
 
+    public void doEdit(RenderRequest request, RenderResponse response)
+    throws PortletException, IOException
+    {
+        response.setContentType("text/html");
+        doPreferencesEdit(request, response);
+    }
+    
     public void doView(RenderRequest request, RenderResponse response)
             throws PortletException, IOException
     {
@@ -488,6 +497,15 @@
         ResourceBundle resource = getPortletConfig().getResourceBundle(
                 actionRequest.getLocale());
 
+        if (actionRequest.getPortletMode() == PortletMode.EDIT)
+        {
+            PortletPreferences prefs = actionRequest.getPreferences();
+            PreferencesHelper.requestParamsToPreferences(actionRequest);
+            prefs.store();
+            actionResponse.setPortletMode(PortletMode.VIEW);
+            return;
+        }
+        
         try
         {
 
@@ -651,13 +669,37 @@
             // Ok, we think we're good to go, let's create the user!
             try
             {
+                PortletPreferences prefs = actionRequest.getPreferences();
+                String template = prefs.getValue("newUserTemplateDirectory", "");
+                if (template.trim().length() == 0)
+                    template = null;
+                String subsiteRootFolder = prefs.getValue("subsiteRootFolder", "");
+                if (subsiteRootFolder.trim().length() == 0)
+                    subsiteRootFolder = null;
+                List prefRoles = getPreferencesList(prefs, IP_ROLES);
+                if (prefRoles.isEmpty())
+                    prefRoles = this.roles;
+                List prefGroups = getPreferencesList(prefs, IP_GROUPS);
+                if (prefGroups.isEmpty())
+                    prefGroups = this.groups;
+                
+                List names = getPreferencesList(prefs, IP_RULES_NAMES);
+                List values = getPreferencesList(prefs, IP_RULES_VALUES);
+                Map profileRules = new HashMap();
+                for (int ix = 0; ix < ((names.size() < values.size()) ? names.size()
+                        : values.size()); ix++)
+                {
+                    profileRules.put(names.get(ix), values.get(ix));
+                }
+                if (profileRules.isEmpty())
+                    profileRules = this.rules;
+                
                 admin.registerUser((String) userInfo.get("user.name"),
-                        (String) userInfo.get("password"), this.roles,
-                        this.groups, userAttributes, // note use of only
+                        (String) userInfo.get("password"), prefRoles,
+                        prefGroups, userAttributes, // note use of only
                                                         // PLT.D values here.
-                        rules, null); // passing in null causes use of default
-                                        // template
-
+                        profileRules, template, subsiteRootFolder); 
+                
                 String urlGUID = ForgottenPasswordPortlet.makeGUID(
                         (String) userInfo.get("user.name"), (String) userInfo
                                 .get("password"));
@@ -670,7 +712,6 @@
                 if (templ == null) { throw new Exception(
                         "email template not available"); }
 
-                PortletPreferences prefs = actionRequest.getPreferences();
                 boolean sendEmail = prefs.getValue("SendEmail", "true").equals("true");
                 if (sendEmail)
                 {
@@ -745,6 +786,18 @@
         return Arrays.asList(temps);
     }
 
+    protected List getPreferencesList(PortletPreferences prefs, String prefName)
+    {
+        String temp = prefs.getValue(prefName, "");
+        if (temp == null || temp.trim().length() == 0) return new ArrayList();
+
+        String[] temps = temp.split("\\,");
+        for (int ix = 0; ix < temps.length; ix++)
+            temps[ix] = temps[ix].trim();
+
+        return Arrays.asList(temps);
+    }
+    
     protected String generateReturnURL(PortletRequest request,
             PortletResponse response, String urlGUID)
     {

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/SecurityResources.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/SecurityResources.java?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/SecurityResources.java
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/SecurityResources.java
Mon Jul  2 15:25:29 2007
@@ -51,7 +51,7 @@
     public static final String MESSAGE_REFRESH_PROFILES = "refresh.profiles";
     public static final String MESSAGE_REFRESH_ROLES = "refresh.roles";
     public static final String MESSAGE_REFRESH_GROUPS = "refresh.groups";
-    
+    public static final String MESSAGE_REFRESH_SUBSITES = "refresh.subsites";    
     
     /** the selected non-leaf node in the tree view */
     public final static String REQUEST_NODE = "node";

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/resources/SecurityResources.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/resources/SecurityResources.properties?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/resources/SecurityResources.properties
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/resources/SecurityResources.properties
Mon Jul  2 15:25:29 2007
@@ -65,10 +65,15 @@
 user.details.preference.showPasswordExpiration=Show Password Expiration
 user.details.preference.showChangePasswordRequiredForAddUser=Define default \"Change Password
Required on First Login\" for new User
 user.details.preference.showRoleForAddUser=Define default Role for new User
-user.details.preference.showProfileForAddUser=Define default Profile for new User
+user.details.preference.showProfileForAddUser=Define default Profile for new User
+user.details.preference.showSubsiteForAddUser=Allow assignment of Subsite for new User
 user.details.preference.defaultChangePasswordRequired=Default \"Change Password Required
on First Login\"
 user.details.preference.defaultRole=Default Role for new User
-user.details.preference.defaultProfile=Default Profile for new User
+user.details.preference.requiredRole=Required Role for new User
+user.details.preference.defaultProfile=Default Profile for new User
+user.details.preference.defaultSubsite=Default Subsite for new User
+user.details.preference.newUserTemplateDirectory=New User Template Directory
+user.details.preference.subsiteRootFolder=Subsite Root Folder
 user.details.save.preferences=Save
 
 ## tree
@@ -87,4 +92,5 @@
 security.profiling.rule=Profiling Rule:
 security.add.user.submit=Add User
 security.add.new.user=Add New User
-security.remove.user=Remove User
\ No newline at end of file
+security.remove.user=Remove User
+security.subsites=Subsites:

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/resources/SecurityResources_en.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/resources/SecurityResources_en.properties?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/resources/SecurityResources_en.properties
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/resources/SecurityResources_en.properties
Mon Jul  2 15:25:29 2007
@@ -67,10 +67,15 @@
 user.details.preference.showPasswordExpiration=Show Password Expiration
 user.details.preference.showChangePasswordRequiredForAddUser=Define default \"Change Password
Required on First Login\" for new User
 user.details.preference.showRoleForAddUser=Define default Role for new User
-user.details.preference.showProfileForAddUser=Define default Profile for new User
+user.details.preference.showProfileForAddUser=Define default Profile for new User
+user.details.preference.showSubsiteForAddUser=Allow assignment of Subsite for new User
 user.details.preference.defaultChangePasswordRequired=Default \"Change Password Required
on First Login\"
-user.details.preference.defaultRole=Default Role for new User
+user.details.preference.defaultRole=Default Role for new User
+user.details.preference.requiredRole=Required Role for new User
 user.details.preference.defaultProfile=Default Profile for new User
+user.details.preference.defaultSubsite=Default Subsite for new User
+user.details.preference.newUserTemplateDirectory=New User Template Directory
+user.details.preference.subsiteRootFolder=Subsite Root Folder
 user.details.save.preferences=Save
 
 ## tree
@@ -89,7 +94,8 @@
 security.profiling.rule=Profiling Rule:
 security.add.user.submit=Add User
 security.add.new.user=Add New User
-security.remove.user=Remove User
+security.remove.user=Remove User
+security.subsites=Subsites:
 
 # forgotten password feature
 email.subject.forgotten.password = Password Notification

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/security/users/UserDetailsPortlet.java
Mon Jul  2 15:25:29 2007
@@ -17,6 +17,7 @@
 package org.apache.jetspeed.portlets.security.users;
 
 import java.io.IOException;
+import java.io.Serializable;
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -48,7 +49,9 @@
 import org.apache.jetspeed.om.common.UserAttribute;
 import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
 import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.folder.FolderNotFoundException;
 import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.NodeSet;
 import org.apache.jetspeed.portlets.security.SecurityResources;
 import org.apache.jetspeed.portlets.security.SecurityUtil;
 import org.apache.jetspeed.profiler.Profiler;
@@ -115,6 +118,8 @@
     /** the id of the rules control */
     private static final String RULES_CONTROL = "jetspeedRules";
     
+    /** the id of the subsites control */
+    private static final String SUBSITES_CONTROL = "jetspeedSubsites";
 
     /** the id of the groups control */
     private static final String GROUPS_CONTROL = "jetspeedGroups";
@@ -342,7 +347,8 @@
         else
         {
             renderRoleInformation(request);
-            renderProfileInformation(request);            
+            renderProfileInformation(request);
+            renderSubsiteInformation(request);
         }
         // check for ErrorMessages
         ArrayList errorMessages = (ArrayList)PortletMessaging.consume(request, SecurityResources.TOPIC_USER,
SecurityResources.ERROR_MESSAGES);
@@ -479,13 +485,62 @@
         }
         request.setAttribute(RULES_CONTROL, rules);        
     }
+
+    protected void renderSubsiteInformation(RenderRequest request)
+    {
+        // check for refresh on profiles list
+        String refreshSubsites = (String)PortletMessaging.consume(request, 
+                        SecurityResources.TOPIC_USERS, SecurityResources.MESSAGE_REFRESH_SUBSITES);
+        Collection subsites = null;        
+        if (refreshSubsites == null)
+        {        
+            subsites = (Collection) request.getPortletSession().getAttribute(SUBSITES_CONTROL);
+        }
+        
+        // build the subsites control and provide it to the view
+        if (subsites == null)
+        {
+            subsites = new ArrayList();
+            SubsiteInfo emptyone = new SubsiteInfo("","");
+            subsites.add(emptyone);
+            String subsiteRoot = request.getPreferences().getValue("subsiteRootFolder", "");
+            if (!subsiteRoot.equals(""))
+            {
+                try
+                {
+                    Folder subsiteFolder = pageManager.getFolder(subsiteRoot);
+                    NodeSet set = pageManager.getFolders(subsiteFolder);
+                    if (set != null && !set.isEmpty())
+                    {
+                        Iterator setIterator = set.iterator();
+                        while (setIterator.hasNext())
+                        {
+                            Folder f = (Folder)setIterator.next();
+                            subsites.add(new SubsiteInfo(f.getPath(), f.getTitle()));
+                        }
+                    }
+                }
+                catch (FolderNotFoundException fnfe)
+                {
+                    // subsites not used, ignore
+                }
+                catch (Exception e)
+                {
+                    
+                }
+            }
+            request.getPortletSession().setAttribute(SUBSITES_CONTROL, subsites);
+        }
+        request.setAttribute(SUBSITES_CONTROL, subsites);        
+    }
     
     public void doEdit(RenderRequest request, RenderResponse response)
     throws PortletException, IOException
     {
         response.setContentType("text/html");
         renderRoleInformation(request);
-        renderProfileInformation(request);            
+        renderProfileInformation(request);
+        renderSubsiteInformation(request);
         super.doEdit(request, response);
     }
 
@@ -499,6 +554,7 @@
             prefs.store();
             actionResponse.setPortletMode(PortletMode.VIEW);
             initPrefsAndAttr(actionRequest);
+            actionRequest.getPortletSession().removeAttribute(SUBSITES_CONTROL);
             return;
         }
         
@@ -585,13 +641,17 @@
         {
             try
             {
+                Preferences attributes = user.getUserAttributes();
+                String subsite = attributes.get(User.USER_INFO_SUBSITE, null);          
     
                 userManager.removeUser(userName);
                 PortletMessaging.publish(actionRequest, SecurityResources.TOPIC_USERS, SecurityResources.MESSAGE_REFRESH,
"true");
-                                
-                // TODO: handle subsite roots
-                if (pageManager.folderExists(Folder.USER_FOLDER + userName))
+                if (subsite == null)
+                {
+                    subsite = Folder.USER_FOLDER + userName;
+                }
+                if (pageManager.folderExists(subsite))
                 {
-                    Folder folder = pageManager.getFolder(Folder.USER_FOLDER + userName);
                   
+                    Folder folder = pageManager.getFolder(subsite);                    
                     pageManager.removeFolder(folder);
                 }
                             
@@ -1084,10 +1144,21 @@
                 }
                 
                 String templateFolder = actionRequest.getPreferences().getValue("newUserTemplateDirectory",
"/_user/template/");
-
+                String subsite = actionRequest.getParameter(SUBSITES_CONTROL);
+                if (SecurityUtil.isEmpty(subsite))
+                {
+                    subsite = Folder.USER_FOLDER + userName;
+                }
+                else
+                {
+                    subsite  = subsite + Folder.USER_FOLDER +  userName;
+                    Preferences attributes = user.getUserAttributes();
+                    attributes.put(User.USER_INFO_SUBSITE, subsite);                    
+                }
+                
                 // copy the entire dir tree from the template folder
                 Folder source = pageManager.getFolder(templateFolder);                
-                pageManager.deepCopyFolder(source, Folder.USER_FOLDER + userName, userName);
+                pageManager.deepCopyFolder(source, subsite, userName);
                 
                 // TODO: send message that site tree portlet invalidated
                 
@@ -1109,6 +1180,27 @@
         }
     }
     
+    public class SubsiteInfo implements Serializable
+    {
+        private String title;
+        private String path;
+
+        public SubsiteInfo(String path, String title)
+        {
+            this.path = path;
+            this.title = title;
+        }
+        
+        public String getPath()
+        {
+            return path;
+        }
+                
+        public String getTitle()
+        {
+            return title;
+        }        
+    }
     /*
     private void setSecurityConstraints(Folder folder, String userName)
     {
@@ -1116,5 +1208,6 @@
         constraints.setOwner(userName);
         folder.setSecurityConstraints(constraints);        
     }
-    */
+    */    
+    
 }

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/portlet.xml?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/portlet.xml Mon Jul
 2 15:25:29 2007
@@ -288,6 +288,10 @@
             <value>true</value>
         </preference>
         <preference>
+            <name>showSubsiteForAddUser</name>
+            <value>true</value>
+        </preference>
+        <preference>
             <name>defaultChangePasswordRequired</name>
             <value>false</value>
         </preference>
@@ -307,6 +311,14 @@
      		<name>requiredRole</name>
             <value></value>   
         </preference>
+        <preference>
+     		<name>subsiteRootFolder</name>
+            <value>/__subsite-root/_hostname/</value>   
+        </preference>        
+        <preference>
+     		<name>defaultSubsite</name>
+            <value></value>   
+        </preference>                
     </portlet-preferences>
 </portlet>
 
@@ -1098,6 +1110,10 @@
         <value>/WEB-INF/view/userreg/userRegistration.vm</value>
     </init-param>
     <init-param>
+        <name>EditPage</name>
+        <value>/WEB-INF/view/edit-prefs.vm</value>
+    </init-param>            
+    <init-param>
         <description>This option will generate a new password for each user registration</description>
         <name>Option_Generate_Passwords</name>
         <value>false</value>
@@ -1153,6 +1169,7 @@
     <supports>
         <mime-type>text/html</mime-type>
         <portlet-mode>VIEW</portlet-mode>
+        <portlet-mode>EDIT</portlet-mode>
     </supports>
     <supported-locale>en</supported-locale>
     <supported-locale>ja</supported-locale>
@@ -1167,6 +1184,30 @@
             <name>SendEmail</name>
             <value>false</value>
         </preference>    
+        <preference>
+            <name>newUserTemplateDirectory</name>
+            <value>/_user/template/</value>
+        </preference>        
+        <preference>
+     		<name>subsiteRootFolder</name>
+            <value></value>   
+        </preference>        
+        <preference>
+     		<name>roles</name>
+            <value>user</value>   
+        </preference>        
+        <preference>
+     		<name>groups</name>
+            <value></value>   
+        </preference>        
+        <preference>
+     		<name>rulesNames</name>
+            <value>page</value>   
+        </preference>        
+        <preference>
+     		<name>rulesValues</name>
+            <value>j2</value>   
+        </preference>        
     </portlet-preferences>
  </portlet>
     
@@ -1750,6 +1791,10 @@
             <value>true</value>
         </preference>
         <preference>
+            <name>showSubsiteForAddUser</name>
+            <value>true</value>
+        </preference>        
+        <preference>
             <name>defaultChangePasswordRequired</name>
             <value>false</value>
         </preference>
@@ -1769,6 +1814,14 @@
      		<name>requiredRole</name>
             <value>user</value>   
         </preference>
+        <preference>
+     		<name>subsiteRootFolder</name>
+            <value>/__subsite-root/_hostname/</value>   
+        </preference>        
+        <preference>
+     		<name>defaultSubsite</name>
+            <value></value>   
+        </preference>                        
     </portlet-preferences>
 </portlet>
 

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/security/users/user-details-edit.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/security/users/user-details-edit.jsp?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/security/users/user-details-edit.jsp
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/security/users/user-details-edit.jsp
Mon Jul  2 15:25:29 2007
@@ -33,7 +33,7 @@
 <form action="<portlet:actionURL/>" method="post">
 <c:set var="prefs" value="${renderRequest.preferences.map}"/>
 <table border="0" cellspacing="2" cellpadding="3">
-  <c:forEach var="prefName" items="showUserTab,showAttributesTab,showPasswordTab,showPasswordExpiration,showRoleTab,showGroupTab,showProfileTab,showPasswordOnUserTab,showChangePasswordRequiredForAddUser,showRoleForAddUser,showProfileForAddUser,defaultChangePasswordRequired">
+  <c:forEach var="prefName" items="showUserTab,showAttributesTab,showPasswordTab,showPasswordExpiration,showRoleTab,showGroupTab,showProfileTab,showPasswordOnUserTab,showChangePasswordRequiredForAddUser,showRoleForAddUser,showProfileForAddUser,showSubsiteForAddUser,defaultChangePasswordRequired">
   <tr>
     <c:set var="prefValue" value='${prefs[prefName][0]}'/>
     <td class="portlet-section-alternate">
@@ -62,7 +62,24 @@
               </c:forEach>
           </select>      
     </td>
-  </tr>
+  </tr>
+ <tr>
+    <c:set var="prefName" value="requiredRole"/>
+    <c:set var="prefValue" value='${prefs[prefName][0]}'/>
+    <td class="portlet-section-alternate">
+      <font class="portlet-form-field-label"><fmt:message key="user.details.preference.${prefName}"/></font>
+    </td>
+    <td class="portlet-section-body">
+      <select name="<c:out value="${prefName}"/>" class="portlet-form-field-label">
    
+              <option value=""/>                
+              <c:forEach var="item" items="${jetspeedRoles}">
+                <option value="<c:out value='${item}'/>" <c:if test="${item ==
prefValue}">selected="true"</c:if>>
+                    <c:out value="${item}"/>
+                </option>
+              </c:forEach>
+          </select>      
+    </td>
+  </tr>  
   <tr>
     <c:set var="prefName" value="defaultProfile"/>
     <c:set var="prefValue" value='${prefs[prefName][0]}'/>
@@ -80,6 +97,36 @@
           </select>      
     </td>
   </tr>
+  <tr>
+    <c:set var="prefName" value="newUserTemplateDirectory"/>
+    <c:set var="prefValue" value='${prefs[prefName][0]}'/>
+    <td class="portlet-section-alternate">
+      <font class="portlet-form-field-label"><fmt:message key="user.details.preference.${prefName}"/></font>
+    </td>
+    <td class="portlet-section-body">
+    	<input type="text" name="<c:out value="${prefName}"/>" value="<c:out value="${prefValue}"/>"
class="portlet-form-field-label"/>
+    </td>
+  </tr>
+  <tr>
+    <c:set var="prefName" value="subsiteRootFolder"/>
+    <c:set var="prefValue" value='${prefs[prefName][0]}'/>
+    <td class="portlet-section-alternate">
+      <font class="portlet-form-field-label"><fmt:message key="user.details.preference.${prefName}"/></font>
+    </td>
+    <td class="portlet-section-body">
+    	<input type="text" name="<c:out value="${prefName}"/>" value="<c:out value="${prefValue}"/>"
class="portlet-form-field-label"/>
+    </td>
+  </tr>
+  <tr>
+    <c:set var="prefName" value="defaultSubsite"/>
+    <c:set var="prefValue" value='${prefs[prefName][0]}'/>
+    <td class="portlet-section-alternate">
+      <font class="portlet-form-field-label"><fmt:message key="user.details.preference.${prefName}"/></font>
+    </td>
+    <td class="portlet-section-body">
+    	<input type="text" name="<c:out value="${prefName}"/>" value="<c:out value="${prefValue}"/>"
class="portlet-form-field-label"/>
+    </td>
+  </tr>  
 </table>
 <input type="submit" value="<fmt:message key="user.details.save.preferences"/>"
class="portlet-form-button" />
 </form>

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/security/users/user-details.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/security/users/user-details.jsp?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/security/users/user-details.jsp
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/security/users/user-details.jsp
Mon Jul  2 15:25:29 2007
@@ -655,6 +655,31 @@
       <input type="hidden" name="jetspeedRules" value="<c:out value="${defaultProfile}"/>">
     </c:otherwise>
   </c:choose>
+
+  <c:set var="defaultSubsite" value='${prefs["defaultSubsite"][0]}'/>
+
+  <c:choose>
+    <c:when test='${prefs["showSubsiteForAddUser"][0]}'>
+      <!-- Select Subsites -->
+      <tr colspan="2" align="right">
+        <td nowrap class="portlet-section-alternate" align="right"><fmt:message
key="security.subsites"/>&nbsp;</td>
+        <td class="portlet-section-body" align="left">
+     		<select name="jetspeedSubsites" class="portlet-form-field-label">		
+    			<option value=""/> 		
+    			<c:forEach var="ss" items="${jetspeedSubsites}">
+    			    <option value="<c:out value='${ss.path}'/>"
+      			    <c:if test="${ss.path == defaultSubsite}">selected="true"</c:if>>
+    				  <c:out value="${ss.title}"/>
+    			    </option>
+    			</c:forEach>
+    		</select>      
+        </td>
+      </tr>
+    </c:when>
+    <c:otherwise>
+      <input type="hidden" name="jetspeedSubsites" value="<c:out value="${defaultSubsite}"/>">
+    </c:otherwise>
+  </c:choose>
   
 </table>
 <br/>

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
Mon Jul  2 15:25:29 2007
@@ -25,6 +25,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.prefs.Preferences;
 
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletRequest;
@@ -149,7 +150,20 @@
     {
         registerUser(userName, password, (List)null, null, null, null, null);
     }
-        
+
+    public void registerUser(
+            String userName, 
+            String password, 
+            List roles, 
+            List groups, 
+            Map userInfo, 
+            Map rules, 
+            String folderTemplate)
+    throws RegistrationException    
+    {
+        registerUser(userName, password, roles, groups, userInfo, rules, folderTemplate,
null);
+    }
+    
     /* (non-Javadoc)
      * @see org.apache.jetspeed.administration.PortalAdministration#registerUser(java.lang.String,
java.lang.String, java.util.Map, java.awt.List, java.awt.List, java.lang.String)
      */    
@@ -160,7 +174,8 @@
             List groups, 
             Map userInfo, 
             Map rules, 
-            String folderTemplate)
+            String folderTemplate,
+            String subsite)
     throws RegistrationException    
     {
         try 
@@ -225,11 +240,11 @@
                 while (ruleEntries.hasNext())
                 {           
                     Map.Entry entry = (Map.Entry)ruleEntries.next();                    
-                    ProfilingRule rule = profiler.getRule((String)entry.getKey());
+                    ProfilingRule rule = profiler.getRule((String)entry.getValue());
                     if (rule != null)
                     {
                         Principal principal = SecurityHelper.getBestPrincipal(user.getSubject(),
UserPrincipal.class);
-                        profiler.setRuleForPrincipal(principal, rule, (String)entry.getValue());
+                        profiler.setRuleForPrincipal(principal, rule, (String)entry.getKey());
                     }
                 }
             }
@@ -239,13 +254,24 @@
                 folderTemplate = this.folderTemplate; 
             }
             
+            if (subsite == null)
+            {
+                subsite = Folder.USER_FOLDER + userName;
+            }
+            else
+            {
+                subsite  = subsite + Folder.USER_FOLDER +  userName;
+            }            
+            
+            
             // This next chunk of code is the fancy way to force the creation of the user
             // template pages to be created with subject equal to the new user
             // otherwise it would be created as guest, and guest does not have enough privs.
             final String innerFolderTemplate = folderTemplate;
-            final String innerUserName = userName;
+            final String innerSubsite = subsite;
             final PageManager innerPageManager = pageManager;
-            final String innerUser = userName;
+            final String innerUserName = userName;
+            final User innerUser = user;
             User powerUser = userManager.getUser(this.adminUser);
             JetspeedException pe = (JetspeedException) JSSubject.doAsPrivileged(powerUser.getSubject(),
new PrivilegedAction()
                 {
@@ -253,12 +279,19 @@
                     {
                          try
                         {
-//                           create user's home folder                        
+                             if (innerSubsite != null)
+                             {
+                                 Preferences attributes = innerUser.getUserAttributes();
+                                 attributes.put(User.USER_INFO_SUBSITE, innerSubsite);  
                                 
+                             }                                         
+                             // create user's home folder                        
                              // deep copy from the default folder template tree, creating
a deep-copy of the template
                              // in the new user's folder tree
-                            Folder source = innerPageManager.getFolder(innerFolderTemplate);
                           
-                            innerPageManager.deepCopyFolder(source, Folder.USER_FOLDER +
innerUserName, innerUser);
-                            Folder newFolder = pageManager.getFolder(Folder.USER_FOLDER +
innerUserName);                            
+                            Folder source = innerPageManager.getFolder(innerFolderTemplate);
+                            
+                            
+                            innerPageManager.deepCopyFolder(source, innerSubsite, innerUserName);
+                            Folder newFolder = pageManager.getFolder(innerSubsite);     
                      
                             newFolder.setTitle("Home Folder");
                             newFolder.setShortTitle("Home");
                              

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalAdministration.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalAdministration.java?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalAdministration.java
(original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalAdministration.java
Mon Jul  2 15:25:29 2007
@@ -51,6 +51,8 @@
      *              Well known rules names are 'page' and 'menu' 
      * @param folderTemplate The full PSML path name of a folder to be deep
      *               copied as the new user's set of folders, pages, links
+     * @param subsite The subsite folder to place the new user in
+     * @since 2.1.1              
      */
     void registerUser(String userName, 
                       String password, 
@@ -58,7 +60,17 @@
                       List groups,
                       Map userInfo,                       
                       Map rules,
-                      String template)
+                      String template,
+                      String subsiteFolder)
+        throws RegistrationException;
+
+    void registerUser(String userName, 
+            String password, 
+            List roles, 
+            List groups,
+            Map userInfo,                       
+            Map rules,
+            String template)
         throws RegistrationException;
  
     /**

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/security/User.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/security/User.java?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/security/User.java
(original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/security/User.java
Mon Jul  2 15:25:29 2007
@@ -34,6 +34,11 @@
     final static String USER_INFO_PROPERTY_SET = "userinfo";
     
     /**
+     * the subsite path for a given user stored as a user attribute
+     */
+    final static String USER_INFO_SUBSITE = "subsite";
+    
+    /**
      * <p>Getter for the user {@link Subject} populated with the 
      * application principals.</p>
      * @return The {@link Subject}.

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/min-pages/page.security
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/min-pages/page.security?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/min-pages/page.security (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/min-pages/page.security Mon Jul  2 15:25:29
2007
@@ -34,6 +34,10 @@
       <users>*</users>
       <permissions>view</permissions>
     </security-constraint>
+    <security-constraint>
+      <roles>admin</roles>
+      <permissions>view, edit</permissions>
+    </security-constraint>    
   </security-constraints-def>
   
   <security-constraints-def name="public-edit">

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/pages/page.security
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/pages/page.security?view=diff&rev=552610&r1=552609&r2=552610
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/pages/page.security (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/pages/page.security Mon Jul  2 15:25:29 2007
@@ -50,6 +50,10 @@
       <users>*</users>
       <permissions>view</permissions>
     </security-constraint>
+    <security-constraint>
+      <roles>admin</roles>
+      <permissions>view, edit</permissions>
+    </security-constraint>    
   </security-constraints-def>
   <security-constraints-def name="public-edit">
     <security-constraint>



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


Mime
View raw message