weaver      2005/04/29 06:59:09

  Modified:    
components/registry/src/java/org/apache/jetspeed/components/portletentity
                        PersistenceBrokerPortletEntityAccess.java
                        PortletEntityImpl.java
                        PortletEntityAccessComponentImpl.java
  Log:
  See JS2-252: http://issues.apache.org/jira/browse/JS2-252
  
  Revision  Changes    Path
  1.5       +4 -3      
jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
  
  Index: PersistenceBrokerPortletEntityAccess.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PersistenceBrokerPortletEntityAccess.java 11 Jan 2005 20:00:01 -0000      
1.4
  +++ PersistenceBrokerPortletEntityAccess.java 29 Apr 2005 13:59:08 -0000      
1.5
  @@ -24,6 +24,7 @@
   import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
   import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
   import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
  +import org.apache.jetspeed.om.page.ContentFragment;
   import org.apache.jetspeed.om.page.Fragment;
   import org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl;
   import org.apache.jetspeed.util.JetspeedObjectID;
  @@ -79,7 +80,7 @@
        * @return @throws
        *         PortletEntityNotGeneratedException
        */
  -    public MutablePortletEntity generateEntityFromFragment( Fragment 
fragment, String principal )
  +    public MutablePortletEntity generateEntityFromFragment( ContentFragment 
fragment, String principal )
               throws PortletEntityNotGeneratedException
       {
           PortletDefinition pd = 
registry.getPortletDefinitionByUniqueName(fragment.getName());
  @@ -119,7 +120,7 @@
        * @return @throws
        *         PortletEntityNotGeneratedException
        */
  -    public MutablePortletEntity generateEntityFromFragment( Fragment 
fragment )
  +    public MutablePortletEntity generateEntityFromFragment( ContentFragment 
fragment )
               throws PortletEntityNotGeneratedException
       {
           return generateEntityFromFragment(fragment, null);
  
  
  
  1.9       +29 -25    
jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java
  
  Index: PortletEntityImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PortletEntityImpl.java    29 Oct 2004 14:04:16 -0000      1.8
  +++ PortletEntityImpl.java    29 Apr 2005 13:59:08 -0000      1.9
  @@ -71,7 +71,8 @@
       protected List originalPreferences;
   
       // protected PrefsPreferenceSetImpl preferenceSet;
  -    protected ThreadLocal preferenceSetRef = new ThreadLocal();
  +    // protected ThreadLocal preferenceSetRef = new ThreadLocal();
  +    protected Map perPrincipalPrefs = new HashMap();
   
       protected Map originalValues;
   
  @@ -120,22 +121,23 @@
        */
       public PreferenceSet getPreferenceSet()
       {
  -        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) 
preferenceSetRef.get();
  +        Principal currentUser = getPrincipal();
  +        return getPreferenceSet(currentUser);
  +    }
  +
  +    public PreferenceSet getPreferenceSet(Principal principal)
  +    {
  +        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) 
perPrincipalPrefs.get(principal);
           try
           {
               if (preferenceSet == null || !dirty)
               {
  -                Principal currentUser = getPrincipal();
                   //TODO: need to be setting this from 
PortletEntityAccessComponent until then it will always be null.                
  -                if (currentUser == null)
  -                {
  -                    currentUser = new 
PortletEntityUserPrincipal(NO_PRINCIPAL);
  -                }
  -                String prefNodePath = 
MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" + getId() +"/"+ 
currentUser.getName() +"/"
  +                String prefNodePath = 
MutablePortletEntity.PORTLET_ENTITY_ROOT + "/" + getId() +"/"+ 
principal.getName() +"/"
                           + PrefsPreference.PORTLET_PREFERENCES_ROOT;
                   Preferences prefNode = 
Preferences.userRoot().node(prefNodePath);
                   preferenceSet = new PrefsPreferenceSetImpl(prefNode);
  -                preferenceSetRef.set(preferenceSet);
  +                perPrincipalPrefs.put(principal, preferenceSet);
                   backupValues(preferenceSet);
                   dirty = true;
               }
  @@ -147,7 +149,6 @@
               ise.initCause(e);
               throw ise;
           }
  -
           return preferenceSet;
       }
   
  @@ -176,14 +177,6 @@
   
       public PortletDefinition getPortletDefinition()
       {
  -//        if(portletDefinition == null)
  -//        {
  -//            Filter filter = store.newFilter();
  -//            filter.addEqualTo("app.name", appName);
  -//            filter.addEqualTo("name", portletName);
  -//            Object query = store.newQuery(PortletDefinitionImpl.class, 
filter);
  -//            this.portletDefinition = (PortletDefinitionComposite) 
store.getObjectByQuery(query);
  -//        }
           return this.portletDefinition;
       }
   
  @@ -206,13 +199,18 @@
        */
       public void store() throws IOException
       {
  +        store(getPrincipal());
  +    }
  +    
  +    public void store(Principal principal) throws IOException
  +    {
           if (pac == null)
           {
               throw new IllegalStateException("You must call 
PortletEntityImpl.setPorteltEntityDao() before "
                       + "invoking PortletEntityImpl.store().");
           }
   
  -        PreferenceSet preferenceSet = (PreferenceSet)preferenceSetRef.get();
  +        PreferenceSet preferenceSet = 
(PreferenceSet)perPrincipalPrefs.get(principal);
           pac.storePreferenceSet(preferenceSet, this);
           dirty = false;
           if (preferenceSet != null)
  @@ -231,7 +229,7 @@
   
       public void reset() throws IOException
       {
  -        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) 
preferenceSetRef.get();
  +        PrefsPreferenceSetImpl preferenceSet = (PrefsPreferenceSetImpl) 
perPrincipalPrefs.get(getPrincipal());
           try
           {
               if (originalValues != null && preferenceSet != null)
  @@ -342,7 +340,13 @@
        */
       public Principal getPrincipal()
       {
  -        return (Principal) principalRef.get();
  +        Principal principal = (Principal) principalRef.get();
  +        if (principal == null)
  +        {
  +            principal = new PortletEntityUserPrincipal(NO_PRINCIPAL);
  +        }
  +        
  +        return principal;
       }
   
       /**
  @@ -387,10 +391,10 @@
            */
           public boolean equals( Object obj )
           {
  -            if (obj != null && obj instanceof PortletEntityUserPrincipal)
  +            if (obj != null && obj instanceof Principal)
               {
  -                PortletEntityUserPrincipal p = (PortletEntityUserPrincipal) 
obj;
  -                return name != null && p.name != null && name.equals(p.name);
  +                Principal p = (Principal) obj;
  +                return name != null && p.getName() != null && 
name.equals(p.getName());
               }
               else
               {
  
  
  
  1.28      +3 -2      
jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityAccessComponentImpl.java
  
  Index: PortletEntityAccessComponentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/components/portletentity/PortletEntityAccessComponentImpl.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- PortletEntityAccessComponentImpl.java     11 Jan 2005 20:00:02 -0000      
1.27
  +++ PortletEntityAccessComponentImpl.java     29 Apr 2005 13:59:08 -0000      
1.28
  @@ -31,6 +31,7 @@
   import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
   import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
   import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
  +import org.apache.jetspeed.om.page.ContentFragment;
   import org.apache.jetspeed.om.page.Fragment;
   import org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl;
   import org.apache.jetspeed.util.JetspeedObjectID;
  @@ -89,7 +90,7 @@
        * @param principal
        * @return
        */
  -    public MutablePortletEntity generateEntityFromFragment( Fragment 
fragment, String principal )
  +    public MutablePortletEntity generateEntityFromFragment( ContentFragment 
fragment, String principal )
               throws PortletEntityNotGeneratedException
       {
           PortletDefinition pd = 
registry.getPortletDefinitionByUniqueName(fragment.getName());
  @@ -128,7 +129,7 @@
        * @return
        * @throws PortletEntityNotGeneratedException
        */
  -    public MutablePortletEntity generateEntityFromFragment( Fragment 
fragment )
  +    public MutablePortletEntity generateEntityFromFragment( ContentFragment 
fragment )
               throws PortletEntityNotGeneratedException
       {
           return generateEntityFromFragment(fragment, null);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to