portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r1666716 - in /portals/jetspeed-2/portal/trunk: applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/security/ applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/ components/jetspeed-portal/src/main/java/or...
Date Sat, 14 Mar 2015 16:58:02 GMT
Author: taylor
Date: Sat Mar 14 16:58:01 2015
New Revision: 1666716

URL: http://svn.apache.org/r1666716
Log:
JS2-1293: adding profiler support to User Manager Rest APIs. Making Fast(Ajax) User Manager
default

Modified:
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/security/user-mgt.psml
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/user-mgt.psml
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/UserDataTableBean.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/UserDetailBean.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/UserManagerService.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/folder/Folder.java

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/security/user-mgt.psml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/security/user-mgt.psml?rev=1666716&r1=1666715&r2=1666716&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/security/user-mgt.psml
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/Administrative/security/user-mgt.psml
Sat Mar 14 16:58:01 2015
@@ -30,7 +30,7 @@ limitations under the License.
   <metadata name="title" xml:lang="ko">사용자 관리</metadata>
 
   <fragment id="um-2" type="layout" name="jetspeed-layouts::VelocityOneColumn">
-    <fragment id="um-3" type="portlet" name="j2-admin::JetspeedPrincipalManagementUserPortlet">
+    <fragment id="um-3" type="portlet" name="j2-admin::JetspeedAjaxUserManager">
       <property layout="TwoColumns" name="row" value="0" />
       <property layout="TwoColumns" name="column" value="0" />
     </fragment>

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/user-mgt.psml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/user-mgt.psml?rev=1666716&r1=1666715&r2=1666716&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/user-mgt.psml
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/Administrative/user-mgt.psml
Sat Mar 14 16:58:01 2015
@@ -30,7 +30,7 @@ limitations under the License.
   <metadata name="title" xml:lang="ko">사용자 관리</metadata>
 
   <fragment id="um-2" type="layout" name="jetspeed-layouts::VelocityOneColumn">
-    <fragment id="um-3" type="portlet" name="j2-admin::JetspeedPrincipalManagementUserPortlet">
+    <fragment id="um-3" type="portlet" name="j2-admin::JetspeedAjaxUserManager">
       <property layout="TwoColumns" name="row" value="0" />
       <property layout="TwoColumns" name="column" value="0" />
     </fragment>

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/UserDataTableBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/UserDataTableBean.java?rev=1666716&r1=1666715&r2=1666716&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/UserDataTableBean.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/UserDataTableBean.java
Sat Mar 14 16:58:01 2015
@@ -16,16 +16,15 @@
  */
 package org.apache.jetspeed.services.beans;
 
+import org.apache.jetspeed.security.JetspeedPrincipal;
+import org.apache.jetspeed.security.JetspeedPrincipalResultList;
+
+import javax.xml.bind.annotation.XmlRootElement;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.jetspeed.security.JetspeedPrincipal;
-import org.apache.jetspeed.security.JetspeedPrincipalResultList;
-
 /**
  * DTO for user search result list to be displayed in the view. The object will
  * be transformed to JSON to be transfered to the JS client.
@@ -45,6 +44,8 @@ public class UserDataTableBean implement
 	private String dir = "asc";
 	private long pageSize = 5;
 	private List<HashMap<String, String>> records = null;
+	private List<String> availableRules = null;
+	private List<String> templates = null;
 
 	public UserDataTableBean() {
 	}
@@ -169,4 +170,19 @@ public class UserDataTableBean implement
 		this.records = records;
 	}
 
+	public List<String> getAvailableRules() {
+		return availableRules;
+	}
+
+	public void setAvailableRules(List<String> availableRules) {
+		this.availableRules = availableRules;
+	}
+
+	public List<String> getTemplates() {
+		return templates;
+	}
+
+	public void setTemplates(List<String> templates) {
+		this.templates = templates;
+	}
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/UserDetailBean.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/UserDetailBean.java?rev=1666716&r1=1666715&r2=1666716&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/UserDetailBean.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/beans/UserDetailBean.java
Sat Mar 14 16:58:01 2015
@@ -16,19 +16,18 @@
  */
 package org.apache.jetspeed.services.beans;
 
+import org.apache.jetspeed.security.Group;
+import org.apache.jetspeed.security.PasswordCredential;
+import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.security.User;
+
+import javax.xml.bind.annotation.XmlRootElement;
 import java.io.Serializable;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.jetspeed.security.Group;
-import org.apache.jetspeed.security.PasswordCredential;
-import org.apache.jetspeed.security.Role;
-import org.apache.jetspeed.security.User;
-
 /**
  * DTO for user details data. The object will be transformed to JSON to be
  * transfered to the JS client.
@@ -48,13 +47,15 @@ public class UserDetailBean implements S
 	private List<String> groups = null;
 	private List<String> availableRoles = null;
 	private List<String> availableGroups = null;
-
+	private List<String> availableRules = null;
+	private String rule = null;
 	private static final long serialVersionUID = 1L;
 
 	public UserDetailBean() {
 	}
 
-	public UserDetailBean(User user, PasswordCredential credential, List<Role> roles,
List<Group> groups, List<String> allRoles, List<String> allGroups) {
+	public UserDetailBean(User user, PasswordCredential credential, List<Role> roles,
List<Group> groups,
+						  List<String> allRoles, List<String> allGroups, String rule, List<String>
profilingRules) {
 		this.name = user.getName();
 		this.infoMap = user.getInfoMap();
 		this.creationDate = user.getCreationDate();
@@ -62,6 +63,8 @@ public class UserDetailBean implements S
 		this.enabled = user.isEnabled();
 		this.availableRoles = allRoles;
 		this.availableGroups = allGroups;
+		this.availableRules = profilingRules;
+		this.rule = rule;
 		this.credentialUpdateRequired = credential.isUpdateRequired();
 		for (Role role : roles) {
 			this.roles = (this.roles == null ? new ArrayList<String>() : this.roles);
@@ -222,4 +225,20 @@ public class UserDetailBean implements S
 	public boolean isCredentialUpdateRequired() {
 		return credentialUpdateRequired;
 	}
+
+	public List<String> getAvailableRules() {
+		return availableRules;
+	}
+
+	public void setAvailableRules(List<String> availableRules) {
+		this.availableRules = availableRules;
+	}
+
+	public String getRule() {
+		return rule;
+	}
+
+	public void setRule(String rule) {
+		this.rule = rule;
+	}
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/UserManagerService.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/UserManagerService.java?rev=1666716&r1=1666715&r2=1666716&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/UserManagerService.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/services/rest/UserManagerService.java
Sat Mar 14 16:58:01 2015
@@ -16,25 +16,6 @@
  */
 package org.apache.jetspeed.services.rest;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.Response.Status;
-
 import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.administration.PortalConfigurationConstants;
@@ -42,7 +23,10 @@ import org.apache.jetspeed.exception.Jet
 import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.Node;
+import org.apache.jetspeed.profiler.ProfileLocator;
 import org.apache.jetspeed.profiler.Profiler;
+import org.apache.jetspeed.profiler.rules.PrincipalRule;
 import org.apache.jetspeed.profiler.rules.ProfilingRule;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.security.Group;
@@ -60,6 +44,27 @@ import org.apache.jetspeed.services.bean
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 /**
  * UserManagerService. This REST service provides access to the jetspeed user manager. The
access of all methods are restricted to the users with the 'admin'
  * role.
@@ -138,7 +143,8 @@ public class UserManagerService
             result.setStartIndex(startIndex);
             result.setPageSize(results);
             result.setRecordsReturned(results);
-            
+            result.setAvailableRules(getProfilingRuleNames());
+            result.setTemplates(getUserTemplates());
             return result;
         }
         catch (SecurityException e)
@@ -178,8 +184,9 @@ public class UserManagerService
             List<String> availableRoles = roleManager.getRoleNames(null);
             List<Group> groups = groupManager.getGroupsForUser(user.getName());
             List<String> availableGroups = groupManager.getGroupNames(null);
-            
-            return new UserDetailBean(user, credential, roles, groups, availableRoles, availableGroups);
+            List<String> ruleNames = getProfilingRuleNames();
+            String userRule = getProfilingRuleForUser(user);
+            return new UserDetailBean(user, credential, roles, groups, availableRoles, availableGroups,
userRule, ruleNames);
         }
         catch (Exception e)
         {
@@ -207,7 +214,8 @@ public class UserManagerService
                                     @FormParam("user_email") String userEmail, @FormParam("password")
String password,
                                     @FormParam("password_confirm") String passwordConfirm,
@FormParam("user_enabled") Boolean userEnabled,
                                     @FormParam("credential_update_required") Boolean credentialUpdateRequired,
@FormParam("roles") List<String> roles,
-                                    @FormParam("groups") List<String> groups)
+                                    @FormParam("groups") List<String> groups,
+                                    @FormParam("rule") String rule)
     {
         checkPrivilege(servletRequest, JetspeedActions.VIEW);
         
@@ -302,7 +310,30 @@ public class UserManagerService
                     groupManager.addUserToGroup(userName, groupName);
                 }
             }
-            
+            if (rule == null || rule.trim().length() == 0) {
+                Collection<PrincipalRule> userRules = profiler.getRulesForPrincipal(user);
+                PrincipalRule deleteRule = null;
+                for (PrincipalRule userRule : userRules) {
+                    if (userRule.getLocatorName().equals(ProfileLocator.PAGE_LOCATOR)) {
+                        deleteRule = userRule;
+                        break;
+                    }
+                }
+                if (deleteRule != null) {
+                    profiler.deletePrincipalRule(deleteRule);
+                }
+            }
+            else {
+                ProfilingRule profilingRule  = profiler.getRule(rule);
+                if (profilingRule != null) {
+                    profiler.setRuleForPrincipal(user, profilingRule, ProfileLocator.PAGE_LOCATOR);
+                }
+                else
+                {
+                    log.error("Failed to set profiling rule for principal. Invalid profiling
rule: " + rule);
+                }
+
+            }
             return new Boolean(true);
         }
         catch (WebApplicationException e)
@@ -351,7 +382,8 @@ public class UserManagerService
     public Boolean createUser(@Context HttpServletRequest servletRequest, @Context UriInfo
uriInfo, @FormParam("name") String userName,
                               @FormParam("user_name_given") String userNameGiven, @FormParam("user_name_family")
String userNameFamily,
                               @FormParam("user_email") String userEmail, @FormParam("password")
String password,
-                              @FormParam("password_confirm") String passwordConfirm, @FormParam("credential_update_required")
Boolean credentialUpdateRequired)
+                              @FormParam("password_confirm") String passwordConfirm, @FormParam("credential_update_required")
Boolean credentialUpdateRequired,
+                              @FormParam("newrule") String rule)
     {
         checkPrivilege(servletRequest, JetspeedActions.VIEW);
         
@@ -404,19 +436,15 @@ public class UserManagerService
             }
             
             // add default user profiling rules
-            String[] defaultUserProfilingRules = Jetspeed.getConfiguration().getStringArray(PortalConfigurationConstants.REGISTRATION_ROLES_DEFAULT);
-            
-            for (String defaultUserProfilingRule : defaultUserProfilingRules)
-            {
-                ProfilingRule profilingRule = profiler.getRule(defaultUserProfilingRule);
-                
+            if (rule != null && rule.trim().length() > 0) {
+                ProfilingRule profilingRule = profiler.getRule(rule);
                 if (profilingRule != null)
                 {
-                    profiler.setRuleForPrincipal(user, profilingRule, "default");
+                    profiler.setRuleForPrincipal(user, profilingRule, ProfileLocator.PAGE_LOCATOR);
                 }
                 else
                 {
-                    log.error("Failed to set profiling rule for principal. Invalid profiling
rule: " + defaultUserProfilingRule);
+                    log.error("Failed to set profiling rule for principal. Invalid profiling
rule: " + rule);
                 }
             }
             
@@ -493,6 +521,45 @@ public class UserManagerService
         }
     }
 
+    protected List<String> getProfilingRuleNames() {
+        List<String> names = new ArrayList<>();
+        names.add("");
+        Collection<ProfilingRule> rules = profiler.getRules();
+        for (ProfilingRule rule : rules) {
+            names.add(rule.getId());
+        }
+        return names;
+    }
+
+    protected String getProfilingRuleForUser(User user) {
+        Collection<PrincipalRule> userRules = profiler.getRulesForPrincipal(user);
+        for (PrincipalRule userRule : userRules) {
+            if (userRule.getLocatorName().equals(ProfileLocator.PAGE_LOCATOR)) {
+                return userRule.getProfilingRule().getId();
+            }
+        }
+        return "";
+    }
+
+    protected List<String> getUserTemplates() {
+        String defaultTemplateFolder = Jetspeed.getConfiguration().getString(PortalConfigurationConstants.PSML_TEMPLATE_FOLDER);
+        List<String> templates = new ArrayList<>();
+        try {
+            Folder templateFolder = pageManager.getFolder(Folder.USER_TEMPLATE_FOLDER);
+            Iterator<Node> folders = templateFolder.getFolders().iterator();
+            while (folders.hasNext()) {
+                Folder folder = (Folder)folders.next();
+                // LEFT OFF HERE - need display and page name
+                String name = (folder.getShortTitle() == null ? (folder.getTitle() == null
? folder.getName() : folder.getTitle()) : folder.getShortTitle());
+                templates.add(name);
+            }
+        }
+        catch (Exception e) {
+            log.error("Failed to retrieve templates", e);
+        }
+        return templates;
+    }
+
     protected void checkPrivilege(HttpServletRequest servletRequest, String action)
     {
         RequestContext requestContext = (RequestContext) servletRequest.getAttribute(RequestContext.REQUEST_PORTALENV);

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/folder/Folder.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/folder/Folder.java?rev=1666716&r1=1666715&r2=1666716&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/folder/Folder.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/folder/Folder.java
Sat Mar 14 16:58:01 2015
@@ -54,7 +54,8 @@ public interface Folder extends Node, Se
     String RESERVED_MEDIATYPE_FOLDER_NAME = RESERVED_FOLDER_PREFIX + "mediatype";
     String RESERVED_LANGUAGE_FOLDER_NAME = RESERVED_FOLDER_PREFIX + "language";
     String RESERVED_COUNTRY_FOLDER_NAME = RESERVED_FOLDER_PREFIX + "country";
-    
+    String RESERVED_USER_TEMPLATE_FOLDER_NAME = RESERVED_FOLDER_PREFIX + "template";
+
     String USER_FOLDER = PATH_SEPARATOR + RESERVED_USER_FOLDER_NAME + PATH_SEPARATOR;
     String ROLE_FOLDER = PATH_SEPARATOR + RESERVED_ROLE_FOLDER_NAME + PATH_SEPARATOR;
     String GROUP_FOLDER = PATH_SEPARATOR + RESERVED_GROUP_FOLDER_NAME + PATH_SEPARATOR;
@@ -62,6 +63,7 @@ public interface Folder extends Node, Se
     String LANGUAGE_FOLDER = PATH_SEPARATOR + RESERVED_LANGUAGE_FOLDER_NAME + PATH_SEPARATOR;
     String COUNTRY_FOLDER = PATH_SEPARATOR + RESERVED_COUNTRY_FOLDER_NAME + PATH_SEPARATOR;
     String SUBSITE_ROOT_FOLDER = RESERVED_SUBSITE_FOLDER_PREFIX + "subsite-root" + PATH_SEPARATOR;
+    String USER_TEMPLATE_FOLDER =  PATH_SEPARATOR + RESERVED_USER_TEMPLATE_FOLDER_NAME +
PATH_SEPARATOR;
 
     int RESERVED_FOLDER_NONE = 0;    
     int RESERVED_FOLDER_SUBSITES = 1;



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