portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vku...@apache.org
Subject svn commit: r771944 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/security/ resources/org/apache/jetspeed/portlets/security/ resources/org/apache/jetspeed/portlets/security/resources/
Date Tue, 05 May 2009 17:54:05 GMT
Author: vkumar
Date: Tue May  5 17:54:04 2009
New Revision: 771944

URL: http://svn.apache.org/viewvc?rev=771944&view=rev
Log:
Adding User's preference in User browser portlet for default sub site and template directory
option for new User Home Page

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.html
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/security/resources/JetspeedPrincipalManagement.properties

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.java?rev=771944&r1=771943&r2=771944&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.java
Tue May  5 17:54:04 2009
@@ -19,12 +19,18 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 import javax.portlet.PortletRequest;
 import javax.portlet.ReadOnlyException;
 import javax.portlet.ValidatorException;
 
+import org.apache.commons.lang.StringUtils;
+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.AdminPortletWebPage;
 import org.apache.jetspeed.portlets.wicket.AbstractAdminWebApplication;
 import org.apache.jetspeed.profiler.rules.ProfilingRule;
@@ -34,6 +40,10 @@
 import org.apache.wicket.markup.html.form.DropDownChoice;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.form.RequiredTextField;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
 import org.apache.wicket.model.PropertyModel;
 import org.apache.wicket.model.ResourceModel;
 import org.slf4j.Logger;
@@ -44,11 +54,33 @@
  */
 public class JetspeedPrincipalManagementEditPortlet extends AdminPortletWebPage
 {
-
     private String subite;
     private String profile;
     private String role;
+    private String templateDir;
+    private String subSiteRoot;
     private Logger log = LoggerFactory.getLogger(JetspeedPrincipalManagementEditPortlet.class);
+    IModel getProfileList = new LoadableDetachableModel()
+    {
+        protected Object load()
+        {
+            return getProfiles();
+        }
+    };
+    IModel getRoleNames = new LoadableDetachableModel()
+    {
+        protected Object load()
+        {
+            return getRoles();
+        }
+    };
+    IModel getSubSites = new LoadableDetachableModel()
+    {
+        protected Object load()
+        {
+            return getSubSites();
+        }
+    };
 
     public JetspeedPrincipalManagementEditPortlet()
     {
@@ -56,13 +88,20 @@
         subite = request.getPreferences().getValue(JetspeedPrincipalManagementPortlet.DEFAULT_SUBSITE,
"");
         profile = request.getPreferences().getValue(JetspeedPrincipalManagementPortlet.DEFAULT_PROFILE,
"");
         role = request.getPreferences().getValue(JetspeedPrincipalManagementPortlet.DEFAULT_ROLE,
"");
+        templateDir = request.getPreferences().getValue(JetspeedPrincipalManagementPortlet.NEW_USER_TEMPLATE_DIR,
"");
+        subSiteRoot = request.getPreferences().getValue(JetspeedPrincipalManagementPortlet.SUB_SITE_ROOT,
"");
+        add(new FeedbackPanel("feedback"));
         Form userPrefernces = new Form("userPrefernces");
+        userPrefernces.add(new Label("subsiterootLabel", new ResourceModel("subsiteroot")));
+        userPrefernces.add(new TextField("subsiteroot", new PropertyModel(this, "subSiteRoot")));
       
         userPrefernces.add(new Label("subsiteLabel", new ResourceModel("default.subsite")));
-        userPrefernces.add(new RequiredTextField("defaultSubSite", new PropertyModel(this,
"subite")));
+        userPrefernces.add(new DropDownChoice("defaultSubSite", new PropertyModel(this, "subite"),getSubSites));
+        userPrefernces.add(new Label("templateDirLabel", new ResourceModel("templatedir")));
+        userPrefernces.add(new RequiredTextField("templateDir", new PropertyModel(this, "templateDir")));
         userPrefernces.add(new Label("profileLabel", new ResourceModel("default.profile")));
-        userPrefernces.add(new DropDownChoice("profile", new PropertyModel(this, "profile"),
getProfileList()));
+        userPrefernces.add(new DropDownChoice("profile", new PropertyModel(this, "profile"),
getProfileList));
         userPrefernces.add(new Label("roleLabel", new ResourceModel("default.role")));
-        userPrefernces.add(new DropDownChoice("role", new PropertyModel(this, "role"), getRoleNames()));
+        userPrefernces.add(new DropDownChoice("role", new PropertyModel(this, "role"), getRoleNames));
         userPrefernces.add(new Button("addUserPrefernces", new ResourceModel("common.save"))
         {
             @Override
@@ -80,6 +119,8 @@
                     request.getPreferences().setValue(JetspeedPrincipalManagementPortlet.DEFAULT_ROLE,
getRole());
                     request.getPreferences().setValue(JetspeedPrincipalManagementPortlet.DEFAULT_SUBSITE,
getSubite());
                     request.getPreferences().setValue(JetspeedPrincipalManagementPortlet.DEFAULT_PROFILE,
getProfile());
+                    request.getPreferences().setValue(JetspeedPrincipalManagementPortlet.NEW_USER_TEMPLATE_DIR,
getTemplateDir());
+                    request.getPreferences().setValue(JetspeedPrincipalManagementPortlet.SUB_SITE_ROOT,
getSubSiteRoot());
                     request.getPreferences().store();
                     if (log.isDebugEnabled())
                     {
@@ -165,29 +206,95 @@
     {
         this.role = role;
     }
-    
-    private List<String> getProfileList()
+
+    /**
+     * @return the templateDir
+     */
+    public String getTemplateDir()
+    {
+        return templateDir;
+    }
+
+    /**
+     * @param templateDir
+     *            the templateDir to set
+     */
+    public void setTemplateDir(String templateDir)
+    {
+        this.templateDir = templateDir;
+    }
+
+    /**
+     * @return the subSiteRootr
+     */
+    public String getSubSiteRoot()
+    {
+        return subSiteRoot;
+    }
+
+    /**
+     * @param subSiteRootr
+     *            the subSiteRootr to set
+     */
+    public void setSubSiteRoot(String subSiteRoot)
+    {
+        this.subSiteRoot = subSiteRoot;
+    }
+
+    private List<String> getProfiles()
     {
         ArrayList<String> profileList = new ArrayList<String>();
-        List profileRules = (List)((AbstractAdminWebApplication)getApplication()).getServiceLocator().getProfiler().getRules();
-        for(int counter=0;counter<profileRules.size();counter++)
+        List profileRules = (List) ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getProfiler().getRules();
+        for (int counter = 0; counter < profileRules.size(); counter++)
         {
-            profileList.add(((ProfilingRule)profileRules.get(counter)).getId());
+            profileList.add(((ProfilingRule) profileRules.get(counter)).getId());
         }
-        
         return profileList;
     }
-    
-    private List<String> getRoleNames()
+
+    private List<String> getRoles()
     {
-        List<String> roleNames=Collections.EMPTY_LIST;
-        try{
-            roleNames= ((AbstractAdminWebApplication)getApplication()).getServiceLocator().getRoleManager().getRoleNames("");
 
+        List<String> roleNames = Collections.EMPTY_LIST;
+        try
+        {
+            roleNames = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getRoleManager().getRoleNames("");
         }
-        catch (SecurityException e) {
+        catch (SecurityException e)
+        {
             error(e.getMessage());
         }
-        
-        return  roleNames;
+        return roleNames;
+    }
+
+    private List<String> getSubSites()
+    {
+        List<String> subsites = new ArrayList<String>();
+        subsites.add("");
+        PageManager pageManager = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPageManager();
+        if (!StringUtils.isEmpty(getSubSiteRoot()))
+        {
+            try
+            {
+                Folder subsiteFolder = pageManager.getFolder(getSubSiteRoot());
+                NodeSet set = pageManager.getFolders(subsiteFolder);
+                if (set != null && !set.isEmpty())
+                {
+                    Iterator setIterator = set.iterator();
+                    while (setIterator.hasNext())
+                    {
+                        Folder f = (Folder) setIterator.next();
+                        subsites.add(f.getTitle());
+                    }
+                }
+            }
+            catch (FolderNotFoundException fnfe)
+            {
+                // subsites not used, ignore
+            }
+            catch (Exception e)
+            {
+            }
+        }
+        return subsites;
     }
 }

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java?rev=771944&r1=771943&r2=771944&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
Tue May  5 17:54:04 2009
@@ -31,6 +31,10 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.jetspeed.audit.AuditActivity;
+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.NodeException;
 import org.apache.jetspeed.portlets.AdminPortletWebPage;
 import org.apache.jetspeed.portlets.wicket.AbstractAdminWebApplication;
 import org.apache.jetspeed.portlets.wicket.component.CheckBoxPropertyColumn;
@@ -104,6 +108,8 @@
     public static final String DEFAULT_SUBSITE = "defaultSubsite";
     public static final String DEFAULT_ROLE = "defaultRole";
     public static final String DEFAULT_PROFILE = "defaultProfile";
+    public static final String NEW_USER_TEMPLATE_DIR = "newUserTemplateDirectory";
+    public static final String SUB_SITE_ROOT = "subsiteRootFolder";
 
     private static final java.sql.Date MAX_DATE = java.sql.Date
             .valueOf("8099-01-01");
@@ -662,6 +668,9 @@
             final String defaultRole = preferences.getValue(DEFAULT_ROLE ,"");
             final String defaultProfile = preferences.getValue(DEFAULT_PROFILE ,"");
             final String defaultSubsite = preferences.getValue(DEFAULT_SUBSITE ,"");
+            final String templateFolder = preferences.getValue(NEW_USER_TEMPLATE_DIR, "/_user/template/");
+            final String subsiteRoot = preferences.getValue(SUB_SITE_ROOT,"");
+            profilingRule = defaultProfile.toString();
             
             add(new FeedbackPanel("feedback"));
             Form userForm = new Form("newUserForm");
@@ -689,6 +698,7 @@
                     JetspeedPrincipal principal = getManager().newPrincipal(
                             getUserName(), false);
                     RoleManager roleManager = ((AbstractAdminWebApplication)getApplication()).getServiceLocator().getRoleManager();
+                    PageManager pageManager = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPageManager();
                     try
                     {
                         getManager().addPrincipal(principal, null);
@@ -719,12 +729,36 @@
                                             .getRule(defaultProfile),
                                     "default");
                         }
-                        
-                        if(!StringUtils.isEmpty(defaultSubsite))
+                       
+                        String subSite;
+                        if (!StringUtils.isEmpty(defaultSubsite))
                         {
                             user.getSecurityAttributes().getAttribute(User.JETSPEED_USER_SUBSITE_ATTRIBUTE,true).setStringValue(defaultSubsite);
+                            user.getSecurityAttributes().getAttribute(User.JETSPEED_USER_SUBSITE_ATTRIBUTE,
true).setStringValue(defaultSubsite);
+                            subSite = subsiteRoot + defaultSubsite + Folder.USER_FOLDER +
user.getName();
                         }
                         
+                        else
+                        {
+                            subSite = Folder.USER_FOLDER + user.getName();;
+                        }
+                        
+                        if (!StringUtils.isEmpty(templateFolder))
+                        {
+                            try
+                            {
+                                Folder source = pageManager.getFolder(templateFolder);
+                                pageManager.deepCopyFolder(source, subSite, user.getName());
+                            }
+                            catch (FolderNotFoundException e)
+                            {
+                                error(e.getMessage());
+                            }
+                            catch (NodeException e)
+                            {
+                                error(e.getMessage());
+                            }
+                        }
                         userManager.updateUser(user);
                                                 
                         PasswordCredential credential = userManager

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.html?rev=771944&r1=771943&r2=771944&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.html
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementEditPortlet.html
Tue May  5 17:54:04 2009
@@ -19,12 +19,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <html xmlns="http://www.w3.org/1999/xhtml" >
+	<div wicket:id="feedback"></div>
     <form wicket:id="userPrefernces">
         <table  cellpadding="0" cellspacing="1" border="1" width="300px">
             <tr>
+                <td><span wicket:id="subsiterootLabel"/></td>
+                <td><input type="text" wicket:id="subsiteroot" class="portlet-form-field-label"
/></td>				            
+            </tr>
+            <tr>
                 <td><span wicket:id="subsiteLabel"/></td>
-                <td><input type="text" wicket:id="defaultSubSite" class="portlet-form-field-label"
/></td>				
+                <td><select wicket:id="defaultSubSite"></select></td>
			
             </tr>
+            
+            <tr>
+                <td><span wicket:id="templateDirLabel"/></td>
+                <td><input type="text" wicket:id="templateDir" class="portlet-form-field-label"
/></td>				
+            </tr>            
             <tr>
                 <td><span wicket:id="profileLabel"/></td>
                 <td><select wicket:id="profile"></select></td>		
	

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/security/resources/JetspeedPrincipalManagement.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/security/resources/JetspeedPrincipalManagement.properties?rev=771944&r1=771943&r2=771944&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/security/resources/JetspeedPrincipalManagement.properties
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/security/resources/JetspeedPrincipalManagement.properties
Tue May  5 17:54:04 2009
@@ -58,6 +58,8 @@
 default.role=Default role
 default.profile=Default profile
 default.subsite=Default sub-site
+subsiteroot =Sub site root
+templatedir =New User template directory
 
 JetspeedPrincipalManagementPortlet$PrincipalNameValidator=User already exists, cannot add
new user
 chgpwd.error.invalidPassword=Current password invalid



---------------------------------------------------------------------
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