Author: woonsan
Date: Thu Mar 25 16:19:48 2010
New Revision: 927473

URL: http://svn.apache.org/viewvc?rev=927473&view=rev
Log:
JS2-1133: Fixing internal error upon adding a new user.
This problem was caused by the fact that the new ui pipeline deployment does 
not have any profiling rules in database.
So, only when the rules are available, the profiling rule will be set for the 
principal.

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

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=927473&r1=927472&r2=927473&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
 Thu Mar 25 16:19:48 2010
@@ -40,6 +40,7 @@ import org.apache.jetspeed.portlets.wick
 import org.apache.jetspeed.portlets.wicket.component.CheckBoxPropertyColumn;
 import 
org.apache.jetspeed.portlets.wicket.component.JavascriptEventConfirmation;
 import org.apache.jetspeed.portlets.wicket.component.PortletOddEvenItem;
+import org.apache.jetspeed.profiler.Profiler;
 import org.apache.jetspeed.profiler.rules.PrincipalRule;
 import org.apache.jetspeed.profiler.rules.ProfilingRule;
 import org.apache.jetspeed.security.InvalidNewPasswordException;
@@ -467,12 +468,16 @@ public class JetspeedPrincipalManagement
                         try
                         {
                             String ruleName = getRuleName();
-                            getServiceLocator().getProfiler()
-                                    .setRuleForPrincipal(
-                                            getPrincipal(),
-                                            getServiceLocator().getProfiler()
-                                                    .getRule(ruleName),
-                                            locatorName);
+                            Profiler profiler = 
getServiceLocator().getProfiler();
+                            ProfilingRule profilingRule = 
profiler.getRule(ruleName);
+                            if (profilingRule != null)
+                            {
+                                profiler.setRuleForPrincipal(getPrincipal(), 
profilingRule, locatorName);
+                            }
+                            else
+                            {
+                                log.error("Failed to set profiling rule for 
the principal. Invalid profiling rule: " + ruleName);
+                            }
                             getServiceLocator()
                                     .getAuditActivity()
                                     .logAdminAuthorizationActivity(
@@ -719,28 +724,39 @@ public class JetspeedPrincipalManagement
                         {
                             roleManager.addRoleToUser(getUserName(), 
requiredRole);
                         }
-                       
+                        
+                        Profiler profiler = getServiceLocator().getProfiler();
+                        
                         if (!StringUtils.isEmpty(getProfilingRule()))
                         {
-                            getServiceLocator()
-                                    .getProfiler()
-                                    .setRuleForPrincipal(
-                                            principal,
-                                            getServiceLocator()
-                                                    .getProfiler()
-                                                    
.getRule(getProfilingRule()),
-                                            "default");
-                        }else if(!StringUtils.isEmpty(defaultProfile)){
-                            getServiceLocator()
-                            .getProfiler()
-                            .setRuleForPrincipal(
-                                    principal,
-                                    getServiceLocator()
-                                            .getProfiler()
-                                            .getRule(defaultProfile),
-                                    "default");
+                            ProfilingRule profilingRule = 
profiler.getRule(getProfilingRule());
+                            
+                            if (profilingRule != null)
+                            {
+                                profiler.setRuleForPrincipal(principal, 
profilingRule, "default");
+                            }
+                            else
+                            {
+                                log.error("Failed to set profiling rule for 
principal. Invalid profiling rule: " + getProfilingRule());
+                            }
+                        }
+                        else if (!StringUtils.isEmpty(defaultProfile)) 
+                        {
+                            ProfilingRule defaultProfilingRule = 
profiler.getRule(defaultProfile);
+                            
+                            if (defaultProfilingRule != null)
+                            {
+                                profiler.setRuleForPrincipal(principal, 
defaultProfilingRule, "default");
+                            }
+                            else
+                            {
+                                if (log.isDebugEnabled())
+                                {
+                                    log.debug("Default profiling rule is not 
applied to the principal because the default profiling rule is not found: " + 
defaultProfile);
+                                }
+                            }
                         }
-                       
+                        
                         String subSite;
                         if (!StringUtils.isEmpty(defaultSubsite))
                         {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to