portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r731466 [4/12] - in /portals/jetspeed-2/portal/branches/JPA_BRANCH: ./ components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/ components/jetspeed-page-manager/ com...
Date Mon, 05 Jan 2009 06:04:18 GMT
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageImpl.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageImpl.java Sun Jan  4 22:04:13 2009
@@ -52,7 +52,7 @@
 
     public PageImpl()
     {
-        super(new PageSecurityConstraintsImpl());
+        super(new PageSecurityConstraintsContextImpl());
     }
 
     /**
@@ -226,7 +226,7 @@
                 fragment.setSkin(addFragment.getSkin());
                 fragment.setDecorator(addFragment.getDecorator());
                 fragment.setState(addFragment.getState());
-                fragment.setSecurityConstraints(addFragment.getSecurityConstraints());
+                fragment.setSecurityConstraintsContext(addFragment.getSecurityConstraintsContext());
                 fragment.getProperties().clear();
                 fragment.getProperties().putAll(addFragment.getProperties());
                 fragment.setPreferences(addFragment.getPreferences());

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionElementList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionElementList.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionElementList.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionElementList.java Sun Jan  4 22:04:13 2009
@@ -55,7 +55,7 @@
     /* (non-Javadoc)
      * @see java.util.List#add(int,java.lang.Object)
      */
-    public void add(int index, Object element)
+    public synchronized void add(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // validate index
@@ -97,7 +97,7 @@
     /* (non-Javadoc)
      * @see java.util.List#get(int)
      */
-    public Object get(int index)
+    public synchronized Object get(int index)
     {
         // implement for modifiable AbstractList
         return menuDefinition.accessElements().get(index);
@@ -106,7 +106,7 @@
     /* (non-Javadoc)
      * @see java.util.List#remove(int)
      */
-    public Object remove(int index)
+    public synchronized Object remove(int index)
     {
         // implement for modifiable AbstractList
         return menuDefinition.accessElements().remove(index);
@@ -115,7 +115,7 @@
     /* (non-Javadoc)
      * @see java.util.List#set(int,java.lang.Object)
      */
-    public Object set(int index, Object element)
+    public synchronized Object set(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // verify element
@@ -131,7 +131,7 @@
     /* (non-Javadoc)
      * @see java.util.List#size()
      */
-    public int size()
+    public synchronized int size()
     {
         // implement for modifiable AbstractList
         return menuDefinition.accessElements().size();

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionList.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionList.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionList.java Sun Jan  4 22:04:13 2009
@@ -17,10 +17,9 @@
 package org.apache.jetspeed.om.page.impl;
 
 import java.util.AbstractList;
+import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
-
 
 /**
  * PageMenuDefinitionList
@@ -107,7 +106,7 @@
     {
         if (removedMenuDefinitions == null)
         {
-            removedMenuDefinitions = DatabasePageManagerUtils.createList();
+            removedMenuDefinitions = new ArrayList();
         }
         return removedMenuDefinitions;
     }
@@ -115,7 +114,7 @@
     /* (non-Javadoc)
      * @see java.util.List#add(int,java.lang.Object)
      */
-    public void add(int index, Object element)
+    public synchronized void add(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // validate index
@@ -132,7 +131,7 @@
     /* (non-Javadoc)
      * @see java.util.List#get(int)
      */
-    public Object get(int index)
+    public synchronized Object get(int index)
     {
         // implement for modifiable AbstractList
         return page.accessMenus().get(index);
@@ -141,7 +140,7 @@
     /* (non-Javadoc)
      * @see java.util.List#remove(int)
      */
-    public Object remove(int index)
+    public synchronized Object remove(int index)
     {
         // implement for modifiable AbstractList:
         // save removed element 
@@ -156,7 +155,7 @@
     /* (non-Javadoc)
      * @see java.util.List#set(int,java.lang.Object)
      */
-    public Object set(int index, Object element)
+    public synchronized Object set(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // verify menu definition
@@ -172,7 +171,7 @@
     /* (non-Javadoc)
      * @see java.util.List#size()
      */
-    public int size()
+    public synchronized int size()
     {
         // implement for modifiable AbstractList
         return page.accessMenus().size();

Copied: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsContextImpl.java (from r728362, portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsImpl.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsContextImpl.java?p2=portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsContextImpl.java&p1=portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsImpl.java&r1=728362&r2=731466&rev=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsContextImpl.java Sun Jan  4 22:04:13 2009
@@ -17,15 +17,15 @@
 package org.apache.jetspeed.om.page.impl;
 
 /**
- * PageSecurityConstraintsImpl
+ * PageSecurityConstraintsContextImpl
  *
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
  * @version $Id$
  */
-public class PageSecurityConstraintsImpl extends SecurityConstraintsImpl
+public class PageSecurityConstraintsContextImpl extends SecurityConstraintsContextImpl
 {
     /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#getSecurityConstraintClass()
+     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsContextImpl#getSecurityConstraintClass()
      */
     public Class getSecurityConstraintClass()
     {
@@ -33,7 +33,7 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#getSecurityConstraintsRefClass()
+     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsContextImpl#getSecurityConstraintsRefClass()
      */
     public Class getSecurityConstraintsRefClass()
     {

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsDefList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsDefList.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsDefList.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsDefList.java Sun Jan  4 22:04:13 2009
@@ -17,10 +17,9 @@
 package org.apache.jetspeed.om.page.impl;
 
 import java.util.AbstractList;
+import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
-
 /**
  * PageSecurityConstraintsDefList
  *
@@ -85,7 +84,7 @@
     {
         if (removedConstraintsDefs == null)
         {
-            removedConstraintsDefs = DatabasePageManagerUtils.createList();
+            removedConstraintsDefs = new ArrayList();
         }
         return removedConstraintsDefs;
     }
@@ -93,7 +92,7 @@
     /* (non-Javadoc)
      * @see java.util.List#add(int,java.lang.Object)
      */
-    public void add(int index, Object element)
+    public synchronized void add(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // validate index
@@ -112,7 +111,7 @@
     /* (non-Javadoc)
      * @see java.util.List#get(int)
      */
-    public Object get(int index)
+    public synchronized Object get(int index)
     {
         // implement for modifiable AbstractList
         return pageSecurity.accessConstraintsDefs().get(index);
@@ -121,7 +120,7 @@
     /* (non-Javadoc)
      * @see java.util.List#remove(int)
      */
-    public Object remove(int index)
+    public synchronized Object remove(int index)
     {
         // implement for modifiable AbstractList
         SecurityConstraintsDefImpl removed = (SecurityConstraintsDefImpl)pageSecurity.accessConstraintsDefs().remove(index);
@@ -138,7 +137,7 @@
     /* (non-Javadoc)
      * @see java.util.List#set(int,java.lang.Object)
      */
-    public Object set(int index, Object element)
+    public synchronized Object set(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // verify constraints definition
@@ -156,7 +155,7 @@
     /* (non-Javadoc)
      * @see java.util.List#size()
      */
-    public int size()
+    public synchronized int size()
     {
         // implement for modifiable AbstractList
         return pageSecurity.accessConstraintsDefs().size();

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsRefList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsRefList.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsRefList.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageSecurityConstraintsRefList.java Sun Jan  4 22:04:13 2009
@@ -17,10 +17,9 @@
 package org.apache.jetspeed.om.page.impl;
 
 import java.util.AbstractList;
+import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
-
 /**
  * PageSecurityConstraintsRefList
  *
@@ -85,7 +84,7 @@
     {
         if (removedConstraintsRefs == null)
         {
-            removedConstraintsRefs = DatabasePageManagerUtils.createList();
+            removedConstraintsRefs = new ArrayList();
         }
         return removedConstraintsRefs;
     }
@@ -93,7 +92,7 @@
     /* (non-Javadoc)
      * @see java.util.List#add(int,java.lang.Object)
      */
-    public void add(int index, Object element)
+    public synchronized void add(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // validate index
@@ -135,7 +134,7 @@
     /* (non-Javadoc)
      * @see java.util.List#get(int)
      */
-    public Object get(int index)
+    public synchronized Object get(int index)
     {
         // implement for modifiable AbstractList:
         // unwrap constraints ref name string
@@ -145,7 +144,7 @@
     /* (non-Javadoc)
      * @see java.util.List#remove(int)
      */
-    public Object remove(int index)
+    public synchronized Object remove(int index)
     {
         // implement for modifiable AbstractList:
         // save removed element 
@@ -160,7 +159,7 @@
     /* (non-Javadoc)
      * @see java.util.List#set(int,java.lang.Object)
      */
-    public Object set(int index, Object element)
+    public synchronized Object set(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // wrap and verify constraints ref name string
@@ -178,7 +177,7 @@
     /* (non-Javadoc)
      * @see java.util.List#size()
      */
-    public int size()
+    public synchronized int size()
     {
         // implement for modifiable AbstractList
         return pageSecurity.accessGlobalConstraintsRefs().size();

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintDefList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintDefList.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintDefList.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintDefList.java Sun Jan  4 22:04:13 2009
@@ -55,7 +55,7 @@
     /* (non-Javadoc)
      * @see java.util.List#add(int,java.lang.Object)
      */
-    public void add(int index, Object element)
+    public synchronized void add(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // validate index
@@ -97,7 +97,7 @@
     /* (non-Javadoc)
      * @see java.util.List#get(int)
      */
-    public Object get(int index)
+    public synchronized Object get(int index)
     {
         // implement for modifiable AbstractList
         return constraintsDef.accessConstraintDefs().get(index);
@@ -106,7 +106,7 @@
     /* (non-Javadoc)
      * @see java.util.List#remove(int)
      */
-    public Object remove(int index)
+    public synchronized Object remove(int index)
     {
         // implement for modifiable AbstractList
         return constraintsDef.accessConstraintDefs().remove(index);
@@ -115,7 +115,7 @@
     /* (non-Javadoc)
      * @see java.util.List#set(int,java.lang.Object)
      */
-    public Object set(int index, Object element)
+    public synchronized Object set(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // verify constraint
@@ -131,7 +131,7 @@
     /* (non-Javadoc)
      * @see java.util.List#size()
      */
-    public int size()
+    public synchronized int size()
     {
         // implement for modifiable AbstractList
         return constraintsDef.accessConstraintDefs().size();

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintList.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintList.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintList.java Sun Jan  4 22:04:13 2009
@@ -28,9 +28,9 @@
  */
 class SecurityConstraintList extends AbstractList
 {
-    private SecurityConstraintsImpl constraints;
+    private SecurityConstraintsContextImpl constraints;
 
-    SecurityConstraintList(SecurityConstraintsImpl constraints)
+    SecurityConstraintList(SecurityConstraintsContextImpl constraints)
     {
         super();
         this.constraints = constraints;
@@ -62,7 +62,7 @@
     /* (non-Javadoc)
      * @see java.util.List#add(int,java.lang.Object)
      */
-    public void add(int index, Object element)
+    public synchronized void add(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // validate index
@@ -106,7 +106,7 @@
     /* (non-Javadoc)
      * @see java.util.List#get(int)
      */
-    public Object get(int index)
+    public synchronized Object get(int index)
     {
         // implement for modifiable AbstractList
         return constraints.accessConstraints().get(index);
@@ -115,7 +115,7 @@
     /* (non-Javadoc)
      * @see java.util.List#remove(int)
      */
-    public Object remove(int index)
+    public synchronized Object remove(int index)
     {
         // implement for modifiable AbstractList
         Object removed = constraints.accessConstraints().remove(index);
@@ -130,7 +130,7 @@
     /* (non-Javadoc)
      * @see java.util.List#set(int,java.lang.Object)
      */
-    public Object set(int index, Object element)
+    public synchronized Object set(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // verify constraint
@@ -148,7 +148,7 @@
     /* (non-Javadoc)
      * @see java.util.List#size()
      */
-    public int size()
+    public synchronized int size()
     {
         // implement for modifiable AbstractList
         return constraints.accessConstraints().size();

Copied: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsContextImpl.java (from r728362, portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsImpl.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsContextImpl.java?p2=portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsContextImpl.java&p1=portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsImpl.java&r1=728362&r2=731466&rev=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsContextImpl.java Sun Jan  4 22:04:13 2009
@@ -16,22 +16,23 @@
  */
 package org.apache.jetspeed.om.page.impl;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.jetspeed.om.common.SecurityConstraints;
+import org.apache.jetspeed.om.common.SecurityConstraintsContext;
 import org.apache.jetspeed.om.page.PageSecurity;
 import org.apache.jetspeed.om.page.SecurityConstraintImpl;
 import org.apache.jetspeed.om.page.SecurityConstraintsDef;
 import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
 
 /**
- * SecurityConstraintsImpl
+ * SecurityConstraintsContextImpl
  *
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
  * @version $Id$
  */
-public class SecurityConstraintsImpl implements SecurityConstraints
+public class SecurityConstraintsContextImpl implements SecurityConstraintsContext
 {
     private String owner;
     private List constraints;
@@ -173,7 +174,7 @@
                 // fail if any action not permitted
                 if ((!actionPermitted && anyActionsPermitted) || actionNotPermitted)
                 {
-                    throw new SecurityException("SecurityConstraintsImpl.checkConstraints(): Access for " + action + " not permitted.");
+                    throw new SecurityException("SecurityConstraintsContextImpl.checkConstraints(): Access for " + action + " not permitted.");
                 }
             }
         }
@@ -184,7 +185,7 @@
             if ((getOwner() != null) && !actions.isEmpty())
             {
                 String action = (String)actions.get(0);
-                throw new SecurityException("SecurityConstraintsImpl.checkConstraints(): Access for " + action + " not permitted, (not owner).");
+                throw new SecurityException("SecurityConstraintsContextImpl.checkConstraints(): Access for " + action + " not permitted, (not owner).");
             }
         }
     }
@@ -213,7 +214,7 @@
         }
 
         // construct new ordered security constraints list
-        allConstraints = DatabasePageManagerUtils.createList();
+        allConstraints = new ArrayList();
 
         // add any defined security constraints
         if ((getSecurityConstraints() != null) && !getSecurityConstraints().isEmpty())
@@ -279,7 +280,7 @@
                 {
                     if (constraints == null)
                     {
-                        constraints = DatabasePageManagerUtils.createList();
+                        constraints = new ArrayList();
                     }
                     constraints.addAll(securityConstraintsDef.getSecurityConstraints());
                 }

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsDefImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsDefImpl.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsDefImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsDefImpl.java Sun Jan  4 22:04:13 2009
@@ -31,7 +31,7 @@
 {
     private int id;
     private String name;
-    private List constraintDefs = DatabasePageManagerUtils.createList();
+    private List constraintDefs;
 
     private SecurityConstraintDefList securityConstraintDefs;
 

Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsRefList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsRefList.java?rev=731466&r1=731465&r2=731466&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsRefList.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsRefList.java Sun Jan  4 22:04:13 2009
@@ -17,10 +17,9 @@
 package org.apache.jetspeed.om.page.impl;
 
 import java.util.AbstractList;
+import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
-
 /**
  * SecurityConstraintsRefList
  *
@@ -29,11 +28,11 @@
  */
 class SecurityConstraintsRefList extends AbstractList
 {
-    private SecurityConstraintsImpl constraints;
+    private SecurityConstraintsContextImpl constraints;
 
     private List removedConstraintsRefs;
 
-    SecurityConstraintsRefList(SecurityConstraintsImpl constraints)
+    SecurityConstraintsRefList(SecurityConstraintsContextImpl constraints)
     {
         super();
         this.constraints = constraints;
@@ -105,7 +104,7 @@
     {
         if (removedConstraintsRefs == null)
         {
-            removedConstraintsRefs = DatabasePageManagerUtils.createList();
+            removedConstraintsRefs = new ArrayList();
         }
         return removedConstraintsRefs;
     }
@@ -113,7 +112,7 @@
     /* (non-Javadoc)
      * @see java.util.List#add(int,java.lang.Object)
      */
-    public void add(int index, Object element)
+    public synchronized void add(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // validate index
@@ -157,7 +156,7 @@
     /* (non-Javadoc)
      * @see java.util.List#get(int)
      */
-    public Object get(int index)
+    public synchronized Object get(int index)
     {
         // implement for modifiable AbstractList:
         // unwrap constraints ref name string
@@ -167,7 +166,7 @@
     /* (non-Javadoc)
      * @see java.util.List#remove(int)
      */
-    public Object remove(int index)
+    public synchronized Object remove(int index)
     {
         // implement for modifiable AbstractList
         BaseSecurityConstraintsRef removed = (BaseSecurityConstraintsRef)constraints.accessConstraintsRefs().remove(index);
@@ -184,7 +183,7 @@
     /* (non-Javadoc)
      * @see java.util.List#set(int,java.lang.Object)
      */
-    public Object set(int index, Object element)
+    public synchronized Object set(int index, Object element)
     {
         // implement for modifiable AbstractList:
         // wrap and verify constraints ref name string
@@ -204,7 +203,7 @@
     /* (non-Javadoc)
      * @see java.util.List#size()
      */
-    public int size()
+    public synchronized int size()
     {
         // implement for modifiable AbstractList
         return constraints.accessConstraintsRefs().size();

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseElementImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseElementImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseElementImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseElementImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,536 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.page.jpa;
+
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.om.common.SecurityConstraintsContext;
+import org.apache.jetspeed.om.page.BaseElement;
+import org.apache.jetspeed.om.page.PageSecurity;
+import org.apache.jetspeed.om.page.SecurityConstraintImpl;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.jpa.DatabasePageManager;
+import org.apache.jetspeed.security.Group;
+import org.apache.jetspeed.security.JSSubject;
+import org.apache.jetspeed.security.PermissionFactory;
+import org.apache.jetspeed.security.Role;
+import org.apache.jetspeed.security.User;
+
+/**
+ * BaseElementImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@MappedSuperclass
+public abstract class BaseElementImpl extends SecurityConstraintsContextImpl implements BaseElement
+{
+    private static final Log log = LogFactory.getLog(BaseElementImpl.class);
+
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    private int id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @Basic
+    @Column (name="NAME")
+    private String name;
+
+    @Transient
+    private DatabasePageManager pageManager;
+    @Transient
+    private boolean constraintsEnabled;
+    @Transient
+    private boolean permissionsEnabled;
+    @Transient
+    private long cachedConstraintsVersion;
+
+    private static PermissionFactory pf;
+    
+    public static void setPermissionsFactory(PermissionFactory pf)
+    {
+        BaseElementImpl.pf = pf;
+    }
+
+    /**
+     * Default constructor.
+     */
+    protected BaseElementImpl()
+    {
+        // set up owning relationship for embedded context,
+        // (see comments below)
+        setOwningObject(this);
+    }
+    
+    /**
+     * getName
+     *
+     * @return element name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * setName
+     *
+     * @param name element name
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * Return page manager for this element.
+     * 
+     * @return infused page manager.
+     */
+    public PageManager getPageManager()
+    {
+        // page manager should never be null
+        if (pageManager == null)
+        {
+            // log error since this is unexpected
+            log.error("Element "+name+" not managed: operations probably invoked before element added to page manager");
+        }
+        return pageManager;
+    }
+
+    /**
+     * setPageManager
+     *
+     * Infuses page manager for use by this element.
+     *
+     * @param pageManager page manager that manages this element.
+     */
+    public void setPageManager(DatabasePageManager pageManager)
+    {
+        this.pageManager = pageManager;
+    }
+
+    /**
+     * setConstraintsEnabled
+     *
+     * @param enabled enable/disable security constraints checks
+     */
+    public void setConstraintsEnabled(boolean enabled)
+    {
+        constraintsEnabled = enabled;
+    }
+    
+    /**
+     * setPermissionsEnabled
+     *
+     * @param enabled enable/disable security permissions checks
+     */
+    public void setPermissionsEnabled(boolean enabled)
+    {
+        permissionsEnabled = enabled;
+    }
+
+    /**
+     * grantViewActionAccess
+     *
+     * @return granted access for view action
+     */
+    public boolean grantViewActionAccess()
+    {
+        // by default, access must be checked
+        return false;
+    }
+
+    /**
+     * getEffectivePageSecurity
+     *
+     * @return effective page security object
+     */
+    public PageSecurity getEffectivePageSecurity()
+    {
+        // no page security available by default
+        return null;
+    }
+
+    /**
+     * checkConstraints
+     *
+     * Check fully parameterized principal against specified security constraint scope.
+     *
+     * @param actions actions to check
+     * @param userPrincipals principal users list
+     * @param rolePrincipals principal roles list
+     * @param groupPrincipals principal group list
+     * @param checkNodeOnly check node scope only
+     * @param checkParentsOnly check parent folder scope only
+     * @throws SecurityException
+     */
+    public void checkConstraints(List actions, List userPrincipals, List rolePrincipals, List groupPrincipals, boolean checkNodeOnly, boolean checkParentsOnly) throws SecurityException
+    {
+        // check node constraints if available
+        SecurityConstraintsContextImpl constraints = (SecurityConstraintsContextImpl)getSecurityConstraintsContext();
+        if ((constraints != null) && !constraints.isEmpty())
+        {
+            constraints.checkConstraints(actions, userPrincipals, rolePrincipals, groupPrincipals, getEffectivePageSecurity());
+        }
+    }
+
+    /**
+     * getLogicalPermissionPath
+     *
+     * @return path used for permissions checks
+     */
+    public String getLogicalPermissionPath()
+    {
+        // same as physical path by default
+        return getPhysicalPermissionPath();
+    }
+
+    /**
+     * getPhysicalPermissionPath
+     *
+     * @return path used for permissions checks
+     */
+    public String getPhysicalPermissionPath()
+    {
+        // no permissions path available by default
+        return null;
+    }
+
+    /**
+     * checkPermissions
+     *
+     * @param mask mask of actions to check
+     * @param checkNodeOnly check node scope only
+     * @param checkParentsOnly check parent folder scope only
+     * @throws SecurityException
+     */
+    public void checkPermissions(int mask, boolean checkNodeOnly, boolean checkParentsOnly) throws SecurityException
+    {
+        // check page and folder permissions
+        String physicalPermissionPath = getPhysicalPermissionPath();
+        if (physicalPermissionPath != null)
+        {
+            // check permissions using physical path
+            try
+            {
+                checkPermissions(physicalPermissionPath, mask, checkNodeOnly, checkParentsOnly);
+            }
+            catch (SecurityException physicalSE)
+            {
+                // fallback check using logical path if available and different
+                String logicalPermissionPath = getLogicalPermissionPath();
+                if ((logicalPermissionPath != null) && !logicalPermissionPath.equals(physicalPermissionPath))
+                {
+                    checkPermissions(logicalPermissionPath, mask, checkNodeOnly, checkParentsOnly);
+                }
+                else
+                {
+                    throw physicalSE;
+                }
+            }
+        }
+    }
+
+    /**
+     * checkPermissions
+     *
+     * @param path permissions path to check
+     * @param mask mask of actions to check
+     * @param checkNodeOnly check node scope only
+     * @param checkParentsOnly check parent folder scope only
+     * @throws SecurityException
+     */
+    public void checkPermissions(String path, int mask, boolean checkNodeOnly, boolean checkParentsOnly) throws SecurityException
+    {
+        // check actions permissions
+        try
+        {
+            // check for granted page permissions
+            AccessController.checkPermission((Permission)pf.newPermission(pf.PAGE_PERMISSION, path, mask));
+        }
+        catch (SecurityException se)
+        {
+            // fallback check for granted folder permissions
+            AccessController.checkPermission((Permission)pf.newPermission(pf.FOLDER_PERMISSION, path, mask));
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#getConstraintsEnabled()
+     */
+    public boolean getConstraintsEnabled()
+    {
+        return constraintsEnabled;
+    }
+    
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o)
+    {
+        // compare element by id
+        return ((o != null) && getClass().equals(o.getClass()) && (id != 0) && (id == ((BaseElementImpl)o).id));
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        // use id to generate hashCode
+        return id;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#getSecurityConstraintsContext()
+     */
+    public SecurityConstraintsContext getSecurityConstraintsContext()
+    {
+        long managedCachedConstraintsVersion = pageManager.getCachedConstraintsVersion();
+        if (cachedConstraintsVersion < managedCachedConstraintsVersion)
+        {
+            resetCachedSecurityConstraints();
+            cachedConstraintsVersion = managedCachedConstraintsVersion;
+        }
+        return accessSecurityConstraintsContext();
+    }
+    
+    /**
+     * Access derived class security constraints.
+     * 
+     * @return element security constraints.
+     */
+    protected abstract SecurityConstraintsContextImpl accessSecurityConstraintsContext();
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#setSecurityConstraintsContext(org.apache.jetspeed.om.common.SecurityConstraintsContext)
+     */
+    public void setSecurityConstraintsContext(SecurityConstraintsContext constraintsContext)
+    {
+        SecurityConstraintsContextImpl baseElementConstraintsContext = (SecurityConstraintsContextImpl)getSecurityConstraintsContext();
+        if (baseElementConstraintsContext != null)
+        {
+            // set constraints configuration for instance
+            baseElementConstraintsContext.setOwner(constraintsContext.getOwner());
+            baseElementConstraintsContext.setSecurityConstraints(constraintsContext.getSecurityConstraints());
+            baseElementConstraintsContext.setSecurityConstraintsRefs(constraintsContext.getSecurityConstraintsRefs());
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#checkConstraints(java.lang.String)
+     */
+    public void checkConstraints(String actions) throws SecurityException
+    {
+        // skip checks if not enabled
+        if (!getConstraintsEnabled())
+        {
+            return;
+        }
+
+        // validate specified actions
+        if (actions == null)
+        {
+            throw new SecurityException("BaseElementImpl.checkConstraints(): No actions specified.");
+        }
+
+        // get action names lists; separate view and other
+        // actions to mimic file system permissions logic
+        List viewActionList = SecurityConstraintImpl.parseCSVList(actions);
+        List otherActionsList = null;
+        if (viewActionList.size() == 1)
+        {
+            if (!viewActionList.contains(JetspeedActions.VIEW))
+            {
+                otherActionsList = viewActionList;
+                viewActionList = null;
+            }
+        }
+        else
+        {
+            otherActionsList = viewActionList;
+            viewActionList = null;
+            if (otherActionsList.remove(JetspeedActions.VIEW))
+            {
+                viewActionList = new ArrayList();
+                viewActionList.add(JetspeedActions.VIEW);
+            }
+        }
+
+        // get current request context subject
+        Subject subject = JSSubject.getSubject(AccessController.getContext());
+        if (subject == null)
+        {
+            throw new SecurityException("BaseElementImpl.checkConstraints(): Missing JSSubject.");
+        }
+
+        // get user/group/role principal names
+        List userPrincipals = null;
+        List rolePrincipals = null;
+        List groupPrincipals = null;
+        Iterator principals = subject.getPrincipals().iterator();
+        while (principals.hasNext())
+        {
+            Principal principal = (Principal) principals.next();
+            if (principal instanceof User)
+            {
+                if (userPrincipals == null)
+                {
+                    userPrincipals = new LinkedList();
+                }
+                userPrincipals.add(principal.getName());
+            }
+            else if (principal instanceof Role)
+            {
+                if (rolePrincipals == null)
+                {
+                    rolePrincipals = new LinkedList();
+                }
+                rolePrincipals.add(principal.getName());
+            }
+            else if (principal instanceof Group)
+            {
+                if (groupPrincipals == null)
+                {
+                    groupPrincipals = new LinkedList();
+                }
+                groupPrincipals.add(principal.getName());
+            }
+        }
+
+        // check constraints using parsed action and access lists
+        if (viewActionList != null)
+        {
+            checkConstraints(viewActionList, userPrincipals, rolePrincipals, groupPrincipals, false, grantViewActionAccess());
+        }
+        if (otherActionsList != null)
+        {
+            checkConstraints(otherActionsList, userPrincipals, rolePrincipals, groupPrincipals, true, false);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#resetCachedSecurityConstraints()
+     */
+    public void resetCachedSecurityConstraints()
+    {
+        // propagate to constraints
+        SecurityConstraintsContextImpl constraintsContext = accessSecurityConstraintsContext();
+        if (constraintsContext != null)
+        {
+            if (constraintsContext != this)
+            {
+                constraintsContext.resetCachedSecurityConstraints();                
+            }
+            else
+            {
+                super.resetCachedSecurityConstraints();
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#getPermissionsEnabled()
+     */
+    public boolean getPermissionsEnabled()
+    {
+        return permissionsEnabled;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#checkPermissions(java.lang.String)
+     */
+    public void checkPermissions(int mask) throws SecurityException
+    {
+        // skip checks if not enabled
+        if (!getPermissionsEnabled())
+        {
+            return;
+        }
+
+        // separate view and other actions to mimic file system permissions logic
+        boolean viewAction = (mask & JetspeedActions.MASK_VIEW) == JetspeedActions.MASK_VIEW;
+        int otherMask = mask & ~JetspeedActions.MASK_VIEW;
+
+        // check permissions using parsed actions
+        if (viewAction)
+        {
+            checkPermissions(JetspeedActions.MASK_VIEW, false, grantViewActionAccess());
+        }
+        if (otherMask != 0)
+        {
+            checkPermissions(otherMask, true, false);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#checkAccess(java.lang.String)
+     */
+    public void checkAccess(String actions) throws SecurityException
+    {
+        // check access permissions and constraints as enabled
+        if (getPermissionsEnabled())
+        {
+            int mask = pf.parseActions(actions);
+            checkPermissions(mask);
+        }
+        if (getConstraintsEnabled())
+        {
+            checkConstraints(actions);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseElement#getId()
+     */
+    public String getId()
+    {
+        return Integer.toString(id);
+    }
+
+    /**
+     * Test whether element is newly created.
+     * 
+     * @return new status of element.
+     */
+    public boolean isNew()
+    {
+        return (id == 0);
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseMetadataLocalizedFieldImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseMetadataLocalizedFieldImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseMetadataLocalizedFieldImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseMetadataLocalizedFieldImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,238 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.page.jpa;
+
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.PostLoad;
+import javax.persistence.PrePersist;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.om.portlet.LocalizedField;
+import org.apache.jetspeed.util.HashCodeBuilder;
+import org.apache.jetspeed.util.JetspeedLocale;
+
+@MappedSuperclass
+public class BaseMetadataLocalizedFieldImpl implements LocalizedField
+{
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="METADATA_ID")
+    private int id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @Basic
+    @Column (name="VALUE")
+    private String value;
+    @Basic
+    @Column (name="NAME")
+    private String name;
+    @Basic
+    @Column (name="LOCALE")
+    private String localeField;
+
+    @PostLoad
+    private void postLoad()
+    {
+        locale = stringToLocale(localeField);
+    }    
+    @PrePersist
+    private void prePersist()
+    {
+        localeField = localeToString(locale);
+    }
+    
+    @Transient
+    private Locale locale;
+    
+    /**
+     * Explicitly set inverse relationship when this object
+     * is added to a one-to-many collection. JPA does not
+     * manage bidirectional relationships.
+     * 
+     * @param inverse inverse relationship owning object.
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.LocalizedField#getLocale()
+     */
+    public Locale getLocale()
+    {
+        return locale;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.LocalizedField#getName()
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.LocalizedField#getValue()
+     */
+    public String getValue()
+    {
+        return value;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.LocalizedField#setLocale(java.util.Locale)
+     */
+    public void setLocale(Locale locale)
+    {
+        this.locale = locale;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.LocalizedField#setName(java.lang.String)
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.portlet.LocalizedField#setValue(java.lang.String)
+     */
+    public void setValue(String value)
+    {
+        this.value = value;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return "Name: " + name + " Value: " + value + " Locale: " + locale;
+    }
+    
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o)
+    {
+        boolean result = false;
+        if (o instanceof BaseMetadataLocalizedFieldImpl)
+        {
+            BaseMetadataLocalizedFieldImpl other = (BaseMetadataLocalizedFieldImpl)o;
+            result = (this.name == null) ? (other.name == null) : (this.name.equals(other.name));
+            result = result && ((this.value == null) ? (other.value == null) : (this.value.equals(other.value)));
+            result = result && ((this.locale == null) ? (other.locale == null) : (this.locale.equals(other.locale)));
+        }
+        return result;
+    }
+    
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        HashCodeBuilder hasher = new HashCodeBuilder(27, 101);
+        hasher.append(name).append(value);
+        if(locale != null)
+        {    
+            hasher.append(locale.getCountry()).append(locale.getLanguage()).append(locale.getVariant());
+        }
+        return hasher.toHashCode();
+    }
+    
+    /**
+     * Convert locale into locale string field value.
+     * 
+     * @param locale locale to convert.
+     * @return locale string field value.
+     */
+    public static String localeToString(Locale locale)
+    {
+        String country = locale.getCountry();
+        String language = locale.getLanguage();
+        String variant = locale.getVariant();
+        StringBuffer buffer = new StringBuffer(40);
+        if (language != null)
+        {
+            buffer.append(language);
+        }
+        buffer.append(',');
+        if (country != null)
+        {
+            buffer.append(country);
+        }
+        buffer.append(',');
+        if (variant != null)
+        {
+            buffer.append(variant);
+        }
+        return buffer.toString().trim();
+    }
+
+    /**
+     * Convert locale string field value into locale.
+     * 
+     * @param locale locale string field value to convert.
+     * @return locale.
+     */
+    public static Locale stringToLocale(String locale)
+    {
+        StringTokenizer tokenizer = new StringTokenizer(locale, ",");
+        if (tokenizer.hasMoreTokens() == false)            
+        {
+            return JetspeedLocale.getDefaultLocale();
+        }
+        String language = tokenizer.nextToken().trim();
+        String country = null;
+        String variant = null;
+        if (tokenizer.hasMoreTokens())
+        {
+            country = tokenizer.nextToken().trim();
+        }           
+        if (tokenizer.hasMoreTokens())
+        {
+            variant = tokenizer.nextToken().trim();
+        }
+        if (country != null && language != null && variant != null)
+        {
+            return new Locale (language, country, variant);
+        }
+        else if (country != null && language != null)
+        {
+            return new Locale(language, country);
+        }
+        else if (language != null)
+        {
+            return new Locale(language, ""); // JDK 1.3 compatibility
+        }
+        else
+        {
+            return JetspeedLocale.getDefaultLocale();
+        }
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseSecurityConstraintImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseSecurityConstraintImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseSecurityConstraintImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseSecurityConstraintImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.page.jpa;
+
+import java.util.List;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.PostLoad;
+import javax.persistence.PrePersist;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.om.page.AbstractSecurityConstraintImpl;
+
+/**
+ * <p>
+ * BaseSecurityConstraintImpl
+ * </p>
+ * <p>
+ *
+ * </p>
+ * @author <a href="mailto:rwatler@finali.com">Randy Watler</a>
+ * @version $Id: SecurityConstraintImpl.java 516448 2007-03-09 16:25:47Z ate $
+ *
+ */
+@MappedSuperclass
+public class BaseSecurityConstraintImpl extends AbstractSecurityConstraintImpl
+{
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="CONSTRAINT_ID")
+    private int id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @Basic
+    @Column (name="APPLY_ORDER")
+    private int applyOrder;
+    @Basic
+    @Column (name="USER_PRINCIPALS_ACL")
+    private String usersACLField;
+    @Basic
+    @Column (name="ROLE_PRINCIPALS_ACL")
+    private String rolesACLField;
+    @Basic
+    @Column (name="GROUP_PRINCIPALS_ACL")
+    private String groupsACLField;
+    @Basic
+    @Column (name="PERMISSIONS_ACL")
+    private String permissionsACLField;
+    
+    @PostLoad
+    private void postLoad()
+    {
+        usersList = parseCSVList(usersACLField);
+        rolesList = parseCSVList(rolesACLField);
+        groupsList = parseCSVList(groupsACLField);
+        permissionsList = parseCSVList(permissionsACLField);
+    }    
+    @PrePersist
+    private void prePersist()
+    {
+        usersACLField = formatCSVList(usersList);
+        rolesACLField = formatCSVList(rolesList);
+        groupsACLField = formatCSVList(groupsList);
+        permissionsACLField = formatCSVList(permissionsList);
+    }
+    
+    @Transient
+    private List usersList;
+    @Transient
+    private List rolesList;
+    @Transient
+    private List groupsList;
+    @Transient
+    private List permissionsList;
+
+    /**
+     * Explicitly set inverse relationship when this object
+     * is added to a one-to-many collection. JPA does not
+     * manage bidirectional relationships.
+     * 
+     * @param inverse inverse relationship owning object.
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+    }
+    
+    /**
+     * getApplyOrder
+     *
+     * @return apply order for constraints
+     */
+    public int getApplyOrder()
+    {
+        return applyOrder;
+    }
+
+    /**
+     * setApplyOrder
+     *
+     * @param order apply order for constraints
+     */
+    public void setApplyOrder(int order)
+    {
+        applyOrder = order;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraint#getUsers()
+     */
+    public List getUsers()
+    {
+        return usersList;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.AbstractSecurityConstraintImpl#setUsers(java.util.List)
+     */
+    public void setUsers(List users)
+    {
+        usersList = users;
+        super.setUsers(users);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraint#getRoles()
+     */
+    public List getRoles()
+    {
+        return rolesList;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.AbstractSecurityConstraintImpl#setRoles(java.util.List)
+     */
+    public void setRoles(List roles)
+    {
+        rolesList = roles;
+        super.setRoles(roles);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraint#getGroups()
+     */
+    public List getGroups()
+    {
+        return groupsList;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.AbstractSecurityConstraintImpl#setGroups(java.util.List)
+     */
+    public void setGroups(List groups)
+    {
+        groupsList = groups;
+        super.setGroups(groups);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraint#getPermissions()
+     */
+    public List getPermissions()
+    {
+        return permissionsList;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.AbstractSecurityConstraintImpl#setPermissions(java.util.List)
+     */
+    public void setPermissions(List permissions)
+    {
+        permissionsList = permissions;
+        super.setPermissions(permissions);
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseSecurityConstraintsRef.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseSecurityConstraintsRef.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseSecurityConstraintsRef.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/BaseSecurityConstraintsRef.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.page.jpa;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Version;
+
+/**
+ * BaseSecurityConstraintsRef
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@MappedSuperclass
+public class BaseSecurityConstraintsRef
+{
+    @Id
+    @GeneratedValue (strategy=GenerationType.AUTO)
+    @Column (name="CONSTRAINTS_REF_ID")
+    private int id;
+    @Version
+    @Column (name="JPA_VERSION")
+    private int jpaVersion;
+    @Basic
+    @Column (name="APPLY_ORDER")
+    private int applyOrder;
+    @Basic
+    @Column (name="NAME")
+    private String name;
+
+    /**
+     * Explicitly set inverse relationship when this object
+     * is added to a one-to-many collection. JPA does not
+     * manage bidirectional relationships.
+     * 
+     * @param inverse inverse relationship owning object.
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+    }
+    
+    /**
+     * getApplyOrder
+     *
+     * @return apply order for constraints
+     */
+    public int getApplyOrder()
+    {
+        return applyOrder;
+    }
+
+    /**
+     * setApplyOrder
+     *
+     * @param order apply order for constraints
+     */
+    public void setApplyOrder(int order)
+    {
+        applyOrder = order;
+    }
+
+    /**
+     * getName
+     *
+     * @return name of referenced constraint
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * setName
+     *
+     * @param name name of referenced constraint
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o)
+    {
+        if (o instanceof BaseSecurityConstraintsRef)
+        {
+            if (name != null)
+            {
+                return name.equals(((BaseSecurityConstraintsRef)o).getName());
+            }
+            return (((BaseSecurityConstraintsRef)o).getName() == null);
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        if (name != null)
+        {
+            return name.hashCode();
+        }
+        return 0;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FilteredFragmentList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FilteredFragmentList.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FilteredFragmentList.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/jpa/FilteredFragmentList.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.page.jpa;
+
+import java.util.AbstractList;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * FragmentList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class FilteredFragmentList extends AbstractList
+{
+    private FragmentImpl fragment;
+    private List filteredList;
+
+    FilteredFragmentList(FragmentImpl fragment, List filteredList)
+    {
+        super();
+        this.fragment = fragment;
+        this.filteredList = filteredList;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public synchronized void add(int index, Object element)
+    {
+        // implement for modifiable AbstractList
+        filteredList.add(index, element);
+        // add object to persistent list
+        fragment.accessFragments().add(element);
+        // maintain page implementation reference
+        if ((fragment.getFragmentsPage() != null) && (element instanceof FragmentImpl))
+        {
+            ((FragmentImpl)element).setFragmentsPage(fragment.getFragmentsPage());
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public synchronized Object get(int index)
+    {
+        // implement for modifiable AbstractList
+        return filteredList.get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public synchronized Object remove(int index)
+    {
+        // implement for modifiable AbstractList
+        Object o = filteredList.remove(index);
+        // remove removed object from persistent list
+        if (o != null)
+        {
+            ListIterator iter = fragment.accessFragments().listIterator();
+            while (iter.hasNext())
+            {
+                if (iter.next() == o)
+                {
+                    iter.remove();
+                    break;
+                }
+            }
+        }
+        return o;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public synchronized Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList
+        Object o = filteredList.set(index, element);
+        // replace replaced object in persistent list
+        if (o != null)
+        {
+            ListIterator iter = fragment.accessFragments().listIterator();
+            while (iter.hasNext())
+            {
+                if (iter.next() == o)
+                {
+                    iter.set(element);
+                    break;
+                }
+            }
+        }
+        // maintain page implementation reference
+        if ((fragment.getFragmentsPage() != null) && (element instanceof FragmentImpl))
+        {
+            ((FragmentImpl)element).setFragmentsPage(fragment.getFragmentsPage());
+        }
+        return o;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public synchronized int size()
+    {
+        // implement for modifiable AbstractList
+        return filteredList.size();
+    }
+}



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