portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r331687 - in /portals/jetspeed-2/trunk/components/page-manager/src: java/org/apache/jetspeed/page/AbstractPageManager.java test/org/apache/jetspeed/page/TestPageImporter.java
Date Tue, 08 Nov 2005 05:31:05 GMT
Author: taylor
Date: Mon Nov  7 21:31:03 2005
New Revision: 331687

URL: http://svn.apache.org/viewcvs?rev=331687&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-395

page.security copying implemented

Modified:
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestPageImporter.java

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java?rev=331687&r1=331686&r2=331687&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
Mon Nov  7 21:31:03 2005
@@ -25,7 +25,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.exception.JetspeedException;
-import org.apache.jetspeed.om.common.GenericMetadata;
 import org.apache.jetspeed.om.common.LocalizedField;
 import org.apache.jetspeed.om.common.SecurityConstraint;
 import org.apache.jetspeed.om.common.SecurityConstraints;
@@ -697,6 +696,14 @@
         }
         return copiedElements;
     }
+
+    protected void copyConstraint(SecurityConstraint srcConstraint, SecurityConstraint dstConstraint)
+    {
+        dstConstraint.setUsers(srcConstraint.getUsers());                
+        dstConstraint.setRoles(srcConstraint.getRoles());
+        dstConstraint.setGroups(srcConstraint.getGroups());
+        dstConstraint.setPermissions(srcConstraint.getPermissions());        
+    }
     
     protected SecurityConstraints copySecurityConstraints(SecurityConstraints source)
     {
@@ -713,10 +720,7 @@
             {
                 SecurityConstraint srcConstraint = (SecurityConstraint)constraints.next();
                 SecurityConstraint dstConstraint = newSecurityConstraint();
-                dstConstraint.setUsers(srcConstraint.getUsers());                
-                dstConstraint.setRoles(srcConstraint.getRoles());
-                dstConstraint.setGroups(srcConstraint.getGroups());
-                dstConstraint.setPermissions(srcConstraint.getPermissions());
+                copyConstraint(srcConstraint, dstConstraint);
                 copiedConstraints.add(dstConstraint);
             }
             security.setSecurityConstraints(copiedConstraints);
@@ -739,19 +743,53 @@
     throws JetspeedException
     {
         PageSecurity copy = this.newPageSecurity();
+        // this is backwards
+        copy.setGlobalSecurityConstraintsRefs(new ArrayList());
+        copy.setSecurityConstraintsDefs(new ArrayList());                
+        
+        
+//        private List constraintsDefs;
+//        private List globalConstraintsRefs;
+//
+//        private List securityConstraintsDefs;
+//        private Map securityConstraintsDefsMap;
+//        private List globalSecurityConstraintsRefs;
+        
+        
         copy.setHidden(source.isHidden());
         copy.setPath(source.getPath());
 //        copy.setShortTitle(source.getTitle());        
 //        copy.setTitle(source.getTitle());
         
         if (source.getSecurityConstraints() != null)
-            copySecurityConstraints(source.getSecurityConstraints());        
+        {
+            SecurityConstraints constraints = copySecurityConstraints(source.getSecurityConstraints());
+            copy.setSecurityConstraints(constraints);
+        }            
+        
+        Iterator defs = source.getSecurityConstraintsDefs().iterator();
+        while (defs.hasNext())
+        {
+            SecurityConstraintsDef def = (SecurityConstraintsDef)defs.next();
+            SecurityConstraintsDef defCopy = this.newSecurityConstraintsDef();          
 
+            defCopy.setName(def.getName());                
+            List copiedConstraints = new ArrayList();
+            defCopy.setSecurityConstraints(copiedConstraints);
+            Iterator constraints = def.getSecurityConstraints().iterator();
+            while (constraints.hasNext())
+            {
+                SecurityConstraint srcConstraint = (SecurityConstraint)constraints.next();
+                SecurityConstraint dstConstraint = newSecurityConstraint();
+                copyConstraint(srcConstraint, dstConstraint);
+                copiedConstraints.add(dstConstraint);
+            }                                            
+            copy.getSecurityConstraintsDefs().add(defCopy);            
+        }
         
         Iterator globals = source.getGlobalSecurityConstraintsRefs().iterator();
         while (globals.hasNext())
         {
             String global = (String)globals.next();
-            System.out.println("copy = " + copy.getGlobalSecurityConstraintsRefs());
             copy.getGlobalSecurityConstraintsRefs().add(global);
         }
         

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestPageImporter.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestPageImporter.java?rev=331687&r1=331686&r2=331687&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestPageImporter.java
(original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestPageImporter.java
Mon Nov  7 21:31:03 2005
@@ -120,15 +120,15 @@
         assertNotNull("db manager is null", dbManager);
         assertNotNull("castor manager is null", castorManager);
 
-        // create the root page security
-        PageSecurity rootSecurity = dbManager.copyPageSecurity(castorManager.getPageSecurity());
       
-        dbManager.updatePageSecurity(rootSecurity);
         
         // create root folder
         Folder fsRoot = castorManager.getFolder("/");
+                
         Folder root = importFolder(fsRoot);         
-        
-        
+                   
+        // create the root page security
+        PageSecurity rootSecurity = dbManager.copyPageSecurity(castorManager.getPageSecurity());
       
+        dbManager.updatePageSecurity(rootSecurity);
         
         // NOTE: this will delete EVERYTHING
         // dbManager.removeFolder(root);



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