portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r776748 - /portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java
Date Wed, 20 May 2009 16:04:14 GMT
Author: ate
Date: Wed May 20 16:04:14 2009
New Revision: 776748

URL: http://svn.apache.org/viewvc?rev=776748&view=rev
Log:
JS2-1019: Several import/export mapping bugs in the JetspeedSerializer implementations
See: https://issues.apache.org/jira/browse/JS2-1019
- Restoring the fix David committed yesterday which I accidentally dropped

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java?rev=776748&r1=776747&r2=776748&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java
Wed May 20 16:04:14 2009
@@ -32,12 +32,14 @@
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.serializer.objects.JSPrincipalRule;
+import org.apache.jetspeed.serializer.objects.JSPrincipalRules;
 import org.apache.jetspeed.serializer.objects.JSProfilingRule;
 import org.apache.jetspeed.serializer.objects.JSProfilingRules;
 import org.apache.jetspeed.serializer.objects.JSRuleCriterion;
 import org.apache.jetspeed.serializer.objects.JSRuleCriterions;
 import org.apache.jetspeed.serializer.objects.JSSnapshot;
 import org.apache.jetspeed.serializer.objects.JSPrincipal;
+import org.apache.jetspeed.serializer.objects.JSUser;
 
 /**
  * JetspeedProfilerSerializer - Profiler component serializer
@@ -179,35 +181,51 @@
                 try
                 {
                     User user = userManager.getUser(_user.getName());
-                    
-                    for (JSPrincipalRule pr : _user.getRules())
-                    {
-                        ProfilingRule pRule = pm.getRule(pr.getRule());
-        
-                        try
-                        {
-                            PrincipalRule p1 = pm.createPrincipalRule();
-                            p1.setLocatorName(pr.getLocator());
-                            p1.setProfilingRule(pRule);
-                            p1.setPrincipalName(user.getName());
-                            pm.storePrincipalRule(p1);
-                        }
-                        catch (Exception eRole)
-                        {
-                            eRole.printStackTrace();
-                        }
-                    }
+                    recreatePrincipalRules(_user.getRules(),user.getName());
                 }
                 catch (Exception eUser)
                 {
                     eUser.printStackTrace();
                 }
             }
-               
+        }
+        // also get Rules for each old user
+        for (JSUser _user : snapshot.getOldUsers())
+        {
+            try
+            {
+                User user = userManager.getUser(_user.getName());
+                recreatePrincipalRules(_user.getRules(),user.getName());
+            }
+            catch (Exception eUser)
+            {
+                eUser.printStackTrace();
+            }
         }
         
         log.debug("recreateUserPrincipalRules - done");
     }
+    
+    private void recreatePrincipalRules(JSPrincipalRules rules, String principalName)
+    {
+        for (JSPrincipalRule pr : rules)
+        {
+            ProfilingRule pRule = pm.getRule(pr.getRule());
+
+            try
+            {
+                PrincipalRule p1 = pm.createPrincipalRule();
+                p1.setLocatorName(pr.getLocator());
+                p1.setProfilingRule(pRule);
+                p1.setPrincipalName(principalName);
+                pm.storePrincipalRule(p1);
+            }
+            catch (Exception eRole)
+            {
+                eRole.printStackTrace();
+            }
+        }
+    }
 
     /**
      * recreate a rule criterion object from the deserialized wrapper



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