raphael     2002/11/03 07:10:07

  Modified:    src/java/org/apache/jetspeed/om/registry PortletEntry.java
                        RegistryEntry.java
               src/java/org/apache/jetspeed/om/registry/base
                        BaseCachedParameter.java BaseCategory.java
                        BaseClientEntry.java BaseMediaType.java
                        BaseMediaTypeRegistry.java BaseMetaInfo.java
                        BaseParameter.java BasePortletControlEntry.java
                        BasePortletEntry.java BaseRegistry.java
                        BaseRegistryEntry.java BaseSecurity.java
                        BaseSecurityEntry.java
  Log:
  Fix Registry performance issue by changing the way fragments are persisted
  
  Revision  Changes    Path
  1.4       +24 -24    
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/PortletEntry.java
  
  Index: PortletEntry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/PortletEntry.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PortletEntry.java 28 Mar 2002 23:13:14 -0000      1.3
  +++ PortletEntry.java 3 Nov 2002 15:10:06 -0000       1.4
  @@ -69,7 +69,7 @@
    *   another PortletEntry definition whose registry name can be retrieved by 
getParent()
    *   </dd>
    * </dl></p>
  - * 
  + *
    * @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
    * @version $Id$
    */
  @@ -86,7 +86,7 @@
   
       /** @return the URL associated with this portlet or null */
       public String getURL();
  -                                
  +
       /**
        * Sets the URL for this PortletEntry
        * @param url the new PortletEntry URL
  @@ -95,7 +95,7 @@
   
       /**
        * Determines whether to use the URL as part of the unique id to the portlet 
cache.
  -     * This can be used to control the lifetime of the portlet. 
  +     * This can be used to control the lifetime of the portlet.
        * The URL is used in combination with the parameter names and values for this 
portlet
        * to uniquely identify to portlet. Parameters may also be optionally included 
in the cache key.
        * This value can be set in the portlet registry.
  @@ -106,7 +106,7 @@
   
       /**
        * Determines whether to use the URL as part of the unique id to the portlet 
cache.
  -     * This can be used to control the lifetime of the portlet. 
  +     * This can be used to control the lifetime of the portlet.
        * The URL is used in combination with the parameter names and values for this 
portlet
        * to uniquely identify to portlet. Parameters may also be optionally included 
in the cache key.
        * This value can be set in the portlet registry.
  @@ -132,22 +132,22 @@
   
       /** @return the entry name from which this one is derived */
       public String getParent();
  -                       
  +
       /**
        * Sets the ancestor for this PortletEntry.
        * @param parent the new ancestor entry name. This name should
        * be defined in the system registry
        */
       public void setParent( String parent );
  -        
  -    /** @return true is this entry is only accessible by the 
  +
  +    /** @return true is this entry is only accessible by the
         * portal administrators.
         */
       public boolean isAdmin();
   
       /** @return true is the PortletEntry is marked as an application */
       public boolean isApplication();
  -                                
  +
       /** Sets the application status of this portlet entry. If an entry
        *  is maked as application, the associated portlet will only be displayed
        *  in Maximized mode and can be retrieved specifically
  @@ -155,26 +155,26 @@
        *  @param application the new application status
        */
       public void setApplication( boolean application );
  -        
  +
       /** @return the type of this entry */
       public String getType();
  -    
  +
       /** Sets the type of this entry. The type specifies whether it is
  -     *  abstract, instance or ref 
  +     *  abstract, instance or ref
        *
        *  @param type the new type for the PortletEntry
        */
       public void setType( String type );
   
   
  -    /** 
  +    /**
        * Returns a list of the categories
        *
        * @return an iterator on the categories
        */
       public Iterator listCategories();
   
  -    /** 
  +    /**
        * Test if a given category exists for this entry
        *
        * @param name the category name
  @@ -182,44 +182,44 @@
        */
       public boolean hasCategory(String name);
   
  -    /** 
  +    /**
        * Test if a given category exists for this entry, in the specified group of 
categories.
        *
        * @param name the category name
  -     * @param group the category group 
  +     * @param group the category group
        * @return true is the category exists in the specified group
        */
       public boolean hasCategory(String name, String group);
  -    
  -    /** 
  +
  +    /**
        * Add a new category to this portlet entry in the default group.
        *
        * @param name the category name
        */
       public void addCategory(String name);
   
  -    /** 
  +    /**
        * Add a new category to this portlet entry.
        *
        * @param name the category name
        * @param group the category group name
        */
       public void addCategory(String name, String group);
  -    
  -    /** 
  +
  +    /**
        * Remove a category from this portlet entry in the default group.
        *
        * @param name the category name
        */
       public void removeCategory(String name);
   
  -    /** 
  +    /**
        * Remove a category from this portlet entry in the specified group.
        *
  -     * @param name the media type name to remove. 
  +     * @param name the media type name to remove.
        * @param group the category group name
        */
       public void removeCategory(String name, String group);
  -    
  +
   }
   
  
  
  
  1.9       +18 -18    
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/RegistryEntry.java
  
  Index: RegistryEntry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/RegistryEntry.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RegistryEntry.java        28 Jun 2002 05:37:31 -0000      1.8
  +++ RegistryEntry.java        3 Nov 2002 15:10:06 -0000       1.9
  @@ -63,7 +63,7 @@
   /**
    * RegistryEntry is the base interface that objects must implement in order
    * to be used with the Registry service.
  - * 
  + *
    * @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
    * @author <a href="mailto:burton@;apache.org">Kevin A. Burton</a>
    * @version $Id$
  @@ -75,58 +75,58 @@
        * registry class.
        */
       public long getId();
  -        
  +
       /**
        * @return the name of this entry. This value should be unique within its
        * registry class.
        */
       public String getName();
  -    
  +
       /**
        * Changes the name of this entry
        * @param name the new name for this entry
        */
       public void setName(String name);
  -    
  +
       /**
        * @return the entry title in the default locale for this entry, if set
        */
       public String getTitle();
  -                                
  +
       /**
        * Sets the title of the portlet entry
        * @param title the new title for the entry
        */
       public void setTitle(String title);
  -                                
  +
       /**
        * @return the entry description in the default locale for this entry, if set
        */
       public String getDescription();
  -                                
  +
       /**
        * Sets the description for the portlet entry
        * @param description the new description for the entry
        */
       public void setDescription(String description);
   
  -    /** 
  +    /**
        * @return the security properties for this entry
        */
       public Security getSecurity();
  -    
  -    /** 
  +
  +    /**
        * Set the security properties for this entry
        * @param security the new security properties
        */
       public void setSecurity(Security security);
   
  -    /** 
  +    /**
        * @return the metainfo properties for this entry
        */
       public MetaInfo getMetaInfo();
  -    
  -    /** 
  +
  +    /**
        * Set the metainfo properties for this entry
        * @param metainfo the new metainfo properties
        */
  @@ -134,7 +134,7 @@
   
   
       /**
  -     * Test if this entry should be visible in a list of the registry contents 
  +     * Test if this entry should be visible in a list of the registry contents
        * @return true if the entry should be hidden
        */
       public boolean isHidden();
  @@ -144,15 +144,15 @@
        * a registry list
        */
       public void setHidden(boolean hidden);
  -   
  +
       /** Getter for property securityRef.
        * @return Value of property securityRef.
        */
       public SecurityReference getSecurityRef();
  -    
  +
       /** Setter for property securityRef.
        * @param securityRef New value of property securityRef.
        */
       public void setSecurityRef(SecurityReference securityRef);
  -    
  +
   }
  
  
  
  1.2       +7 -7      
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseCachedParameter.java
  
  Index: BaseCachedParameter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseCachedParameter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseCachedParameter.java  26 Mar 2002 09:06:53 -0000      1.1
  +++ BaseCachedParameter.java  3 Nov 2002 15:10:06 -0000       1.2
  @@ -51,7 +51,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  - 
  +
   package org.apache.jetspeed.om.registry.base;
   
   import org.apache.jetspeed.om.registry.*;
  @@ -60,19 +60,19 @@
   import java.util.List;
   
   /**
  - * Bean like implementation of the Parameter interface suitable for 
  + * Bean like implementation of the Parameter interface suitable for
    * Castor serialization.
  - * 
  + *
    * @see org.apache.jetspeed.om.registry.Parameter
    * @author <a href="mailto:taylor@;apache.org">David Sean Taylor</a>
    * @version $Id$
    */
  -public class BaseCachedParameter extends BaseParameter 
  +public class BaseCachedParameter extends BaseParameter
       implements CachedParameter, java.io.Serializable
   {
       private boolean cachedOnName = true;
  -    private boolean cachedOnValue = true;    
  -    
  +    private boolean cachedOnValue = true;
  +
       public boolean isCachedOnName()
       {
           return cachedOnName;
  
  
  
  1.2       +53 -7     
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseCategory.java
  
  Index: BaseCategory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseCategory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseCategory.java 28 Mar 2002 23:13:15 -0000      1.1
  +++ BaseCategory.java 3 Nov 2002 15:10:06 -0000       1.2
  @@ -60,18 +60,64 @@
   import org.apache.jetspeed.om.registry.Category;
   
   /**
  - * Bean like implementation of the Category interface suitable for 
  + * Bean like implementation of the Category interface suitable for
    * Castor serialization.
  - * 
  + *
    * @see org.apache.jetspeed.om.registry.Security
    * @author <a href="mailto:taylor@;apache.org">David Sean Taylor</a>
    * @version $Id$
    */
  -public class BaseCategory implements Category
  +public class BaseCategory implements Category, java.io.Serializable
   {
       private String name;
       private String group = "Jetspeed";
   
  +    /**
  +     * Implements the equals operation so that 2 elements are equal if
  +     * all their member values are equal.
  +     */
  +    public boolean equals(Object object)
  +    {
  +        if (object==null)
  +        {
  +            return false;
  +        }
  +
  +        BaseCategory obj = (BaseCategory)object;
  +
  +        if (name!=null)
  +        {
  +            if (!name.equals(obj.getName()))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (obj.getName()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        if (group!=null)
  +        {
  +            if(!group.equals(obj.getGroup()))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (obj.getGroup()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        return true;
  +    }
  +
       /** @return the string Name */
       public String getName()
       {
  @@ -79,7 +125,7 @@
       }
   
       /** Sets the string Name
  -     * 
  +     *
        * @param value the new Name value
        */
       public void setName(String name)
  @@ -94,12 +140,12 @@
       }
   
       /** Sets the string Group
  -     * 
  +     *
        * @param value the new Group value
        */
       public void setGroup(String group)
       {
           this.group = group;
       }
  -    
  +
   }
  
  
  
  1.2       +2 -2      
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseClientEntry.java
  
  Index: BaseClientEntry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseClientEntry.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseClientEntry.java      30 Oct 2002 15:52:05 -0000      1.1
  +++ BaseClientEntry.java      3 Nov 2002 15:10:06 -0000       1.2
  @@ -66,7 +66,7 @@
    * @version $Id$
    */
   public class BaseClientEntry extends BaseRegistryEntry
  -     implements ClientEntry, java.io.Serializable
  +        implements ClientEntry, java.io.Serializable
   {
       private String useragentpattern = "";
       private String manufacturer = "";
  
  
  
  1.2       +32 -4     
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseMediaType.java
  
  Index: BaseMediaType.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseMediaType.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseMediaType.java        29 Jul 2001 13:41:54 -0000      1.1
  +++ BaseMediaType.java        3 Nov 2002 15:10:06 -0000       1.2
  @@ -56,7 +56,7 @@
   
   /**
    * Utility object for serializing with Castor a MediaTypeEntry reference
  - * 
  + *
    * @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
    * @version $Id$
    */
  @@ -64,13 +64,41 @@
   {
   
       private String name;
  -    
  +
  +    /**
  +     * Implements the equals operation so that 2 elements are equal if
  +     * all their member values are equal.
  +     */
  +    public boolean equals(Object object)
  +    {
  +        if (object==null)
  +        {
  +            return false;
  +        }
  +
  +        BaseMediaType obj = (BaseMediaType)object;
  +
  +        if (name!=null)
  +        {
  +            return name.equals(obj.getRef());
  +        }
  +        else
  +        {
  +            if (obj.getRef()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        return true;
  +    }
  +
       /** @return the media type name that is referenced */
       public String getRef()
       {
           return this.name;
       }
  -                                
  +
       /** Sets the media type name referenced by this object
        * @param name the required media type name
        */
  
  
  
  1.3       +79 -79    
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseMediaTypeRegistry.java
  
  Index: BaseMediaTypeRegistry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseMediaTypeRegistry.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseMediaTypeRegistry.java        3 Nov 2002 14:32:37 -0000       1.2
  +++ BaseMediaTypeRegistry.java        3 Nov 2002 15:10:06 -0000       1.3
  @@ -77,7 +77,7 @@
    * @version $Id$
    */
   public class BaseMediaTypeRegistry extends BaseRegistry
  -     implements MediaTypeRegistry
  +        implements MediaTypeRegistry
   {
   
       /*
  @@ -88,71 +88,71 @@
        */
       public Iterator findForCapability(CapabilityMap cm)
       {
  -             if (cm == null)
  -             {
  -                     return null;
  -             }
  -
  -             String type = cm.getPreferredType().getContentType();
  -             List result = new ArrayList();
  -
  -             if (DEBUG && Log.getLogger().isDebugEnabled())
  -             {
  -                     Log.debug("MediaTypeRegistry: looking for type " + type );
  -             }
  -
  -             if (type == null)
  -             {
  -                     return result.iterator();
  -             }
  -
  -             try
  -             {
  -                     Enumeration en = getEntries();
  -                     while(en.hasMoreElements())
  -                     {
  -                             MediaTypeEntry mte = (MediaTypeEntry)en.nextElement();
  -
  -                             if (DEBUG && Log.getLogger().isDebugEnabled())
  -                             {
  -                                     Log.debug("MediaTypeRegistry: found 
MediaTypeEntry for type " + mte.getMimeType() );
  -                             }
  -                             if (type.equals(mte.getMimeType()))
  -                             {
  -                                     result.add(mte);
  -                             }
  -                     }
  -             }
  -             catch(Exception e)
  -             {
  -                     Log.error(e);
  -             }
  -
  -             if (DEBUG && Log.getLogger().isDebugEnabled())
  -             {
  -                     Log.debug("MediaTypeRegistry: found " + result.size() + " 
entries." );
  -             }
  +        if (cm == null)
  +        {
  +            return null;
  +        }
  +
  +        String type = cm.getPreferredType().getContentType();
  +        List result = new ArrayList();
  +
  +        if (DEBUG && Log.getLogger().isDebugEnabled())
  +        {
  +            Log.debug("MediaTypeRegistry: looking for type " + type );
  +        }
  +
  +        if (type == null)
  +        {
  +            return result.iterator();
  +        }
  +
  +        try
  +        {
  +            Enumeration en = getEntries();
  +            while(en.hasMoreElements())
  +            {
  +                MediaTypeEntry mte = (MediaTypeEntry)en.nextElement();
  +
  +                if (DEBUG && Log.getLogger().isDebugEnabled())
  +                {
  +                    Log.debug("MediaTypeRegistry: found MediaTypeEntry for type " + 
mte.getMimeType() );
  +                }
  +                if (type.equals(mte.getMimeType()))
  +                {
  +                    result.add(mte);
  +                }
  +            }
  +        }
  +        catch(Exception e)
  +        {
  +            Log.error(e);
  +        }
  +
  +        if (DEBUG && Log.getLogger().isDebugEnabled())
  +        {
  +            Log.debug("MediaTypeRegistry: found " + result.size() + " entries." );
  +        }
   
  -             return result.iterator();
  +        return result.iterator();
   
  -     }
  +    }
   
       /**
       @see Registry#setEntry
       */
       public void setEntry( RegistryEntry entry ) throws InvalidEntryException
       {
  -             // Delegate to the RegistryService to ensure correct handling of
  -             // persistence if using file fragments
  +        // Delegate to the RegistryService to ensure correct handling of
  +        // persistence if using file fragments
   
  -             try
  -             {
  -                     Registry.addEntry(Registry.MEDIA_TYPE, entry);
  -             }
  -             catch (RegistryException e)
  -             {
  -                     Log.error(e);
  -             }
  +        try
  +        {
  +            Registry.addEntry(Registry.MEDIA_TYPE, entry);
  +        }
  +        catch (RegistryException e)
  +        {
  +            Log.error(e);
  +        }
       }
   
       /**
  @@ -160,17 +160,17 @@
       */
       public void addEntry( RegistryEntry entry ) throws InvalidEntryException
       {
  -             // Delegate to the RegistryService to ensure correct handling of
  -             // persistence if using file fragments
  +        // Delegate to the RegistryService to ensure correct handling of
  +        // persistence if using file fragments
   
  -             try
  -             {
  -                     Registry.addEntry(Registry.MEDIA_TYPE, entry);
  -             }
  -             catch (RegistryException e)
  -             {
  -                     Log.error(e);
  -             }
  +        try
  +        {
  +            Registry.addEntry(Registry.MEDIA_TYPE, entry);
  +        }
  +        catch (RegistryException e)
  +        {
  +            Log.error(e);
  +        }
       }
   
       /**
  @@ -178,10 +178,10 @@
       */
       public void removeEntry( String name )
       {
  -             // Delegate to the RegistryService to ensure correct handling of
  -             // persistence if using file fragments
  +        // Delegate to the RegistryService to ensure correct handling of
  +        // persistence if using file fragments
   
  -             Registry.removeEntry(Registry.MEDIA_TYPE, name);
  +        Registry.removeEntry(Registry.MEDIA_TYPE, name);
       }
   
       /**
  @@ -189,13 +189,13 @@
       */
       public void removeEntry( RegistryEntry entry )
       {
  -             // Delegate to the RegistryService to ensure correct handling of
  -             // persistence if using file fragments
  +        // Delegate to the RegistryService to ensure correct handling of
  +        // persistence if using file fragments
   
  -             if (entry != null)
  -             {
  -                     Registry.removeEntry(Registry.MEDIA_TYPE, entry.getName());
  -             }
  +        if (entry != null)
  +        {
  +            Registry.removeEntry(Registry.MEDIA_TYPE, entry.getName());
  +        }
       }
   
       /**
  @@ -206,6 +206,6 @@
        */
       public RegistryEntry createEntry()
       {
  -             return new BaseMediaTypeEntry();
  -     }
  +        return new BaseMediaTypeEntry();
  +    }
   }
  
  
  
  1.3       +79 -18    
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseMetaInfo.java
  
  Index: BaseMetaInfo.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseMetaInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseMetaInfo.java 1 Apr 2002 23:16:53 -0000       1.2
  +++ BaseMetaInfo.java 3 Nov 2002 15:10:06 -0000       1.3
  @@ -57,19 +57,19 @@
   import org.apache.jetspeed.om.registry.*;
   
   /**
  - * Bean like implementation of the Metainfo interface suitable for 
  + * Bean like implementation of the Metainfo interface suitable for
    * Castor serialization.
  - * 
  + *
    * @see org.apache.jetspeed.om.registry.MetaInfo
    * @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
    * @version $Id$
    */
   public class BaseMetaInfo implements MetaInfo, java.io.Serializable
  -{     
  +{
       private String title;
  -     
  +
       private String description;
  -         
  +
       private String image;
   
       public BaseMetaInfo()
  @@ -82,46 +82,107 @@
           this.image = image;
       }
   
  -    /** @return the title for this entry */         
  +    /**
  +     * Implements the equals operation so that 2 elements are equal if
  +     * all their member values are equal.
  +     */
  +    public boolean equals(Object object)
  +    {
  +        if (object==null)
  +        {
  +            return false;
  +        }
  +
  +        BaseMetaInfo obj = (BaseMetaInfo)object;
  +
  +        if (title!=null)
  +        {
  +            if (!title.equals(obj.getTitle()))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (obj.getTitle()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        if (description!=null)
  +        {
  +            if(!description.equals(obj.getDescription()))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (obj.getDescription()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        if (image!=null)
  +        {
  +            if(!image.equals(obj.getImage()))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (obj.getImage()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        return true;
  +    }
  +
  +    /** @return the title for this entry */
       public String getTitle()
       {
           return this.title;
       }
  -                    
  +
       /** Sets the title for this entry
        * @param title the new title for this entry
  -     */                    
  +     */
       public void setTitle( String title )
       {
           this.title = title;
       }
  -    
  -    /** @return the description for this entry */         
  +
  +    /** @return the description for this entry */
       public String getDescription()
       {
           return this.description;
       }
  -                                
  +
       /** Sets the description for this entry
        * @param description the new description for this entry
  -     */                    
  +     */
       public void setDescription( String description )
       {
           this.description = description;
       }
  -    
  -    /** @return the image link for this entry */         
  +
  +    /** @return the image link for this entry */
       public String getImage()
       {
           return this.image;
       }
  -                                
  +
       /** Sets the image URL attached to this entry
        * @param image the image URL to link to this entry
  -     */                    
  +     */
       public void setImage( String image )
       {
           this.image = image;
       }
  -    
  +
   }
  
  
  
  1.2       +56 -10    
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseParameter.java
  
  Index: BaseParameter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseParameter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseParameter.java        29 Jul 2001 13:41:54 -0000      1.1
  +++ BaseParameter.java        3 Nov 2002 15:10:06 -0000       1.2
  @@ -51,7 +51,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  - 
  +
   package org.apache.jetspeed.om.registry.base;
   
   import org.apache.jetspeed.om.registry.*;
  @@ -60,9 +60,9 @@
   import java.util.List;
   
   /**
  - * Bean like implementation of the Parameter interface suitable for 
  + * Bean like implementation of the Parameter interface suitable for
    * Castor serialization.
  - * 
  + *
    * @see org.apache.jetspeed.om.registry.Parameter
    * @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
    * @version $Id$
  @@ -73,15 +73,61 @@
   
       private String value = null;
       private String type = null;
  -    
  +
  +    /**
  +     * Implements the equals operation so that 2 elements are equal if
  +     * all their member values are equal.
  +     */
  +    public boolean equals(Object object)
  +    {
  +        if (object==null)
  +        {
  +            return false;
  +        }
  +
  +        BaseParameter obj = (BaseParameter)object;
  +
  +        if (value!=null)
  +        {
  +            if (!value.equals(obj.getValue()))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (obj.getValue()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        if (type!=null)
  +        {
  +            if(!type.equals(obj.getType()))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (obj.getType()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        return super.equals(object);
  +    }
  +
       /** @return the value for this parameter */
       public String getValue()
       {
           return this.value;
       }
  -    
  +
       /** Sets the value of this parameter.
  -     * 
  +     *
        * @param value the new parameter value
        */
       public void setValue(String value)
  @@ -94,13 +140,13 @@
       {
           return this.type;
       }
  -    
  +
       /** Sets the type of this parameter.value.
  -     * 
  +     *
        * @param type the new parameter type
        */
       public void setType(String type)
       {
           this.type = type;
  -    }    
  +    }
   }
  
  
  
  1.2       +4 -4      
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BasePortletControlEntry.java
  
  Index: BasePortletControlEntry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BasePortletControlEntry.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasePortletControlEntry.java      29 Jul 2001 13:41:54 -0000      1.1
  +++ BasePortletControlEntry.java      3 Nov 2002 15:10:06 -0000       1.2
  @@ -59,12 +59,12 @@
   /**
    * Default bean like implementation of the PortletControlEntry registry
    * entry
  - * 
  + *
    * @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
    * @version $Id$
    */
  -public class BasePortletControlEntry extends BasePortletInfoEntry 
  +public class BasePortletControlEntry extends BasePortletInfoEntry
       implements PortletControlEntry
  -{   
  +{
       // no special properties yet
   }
  
  
  
  1.4       +139 -49   
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BasePortletEntry.java
  
  Index: BasePortletEntry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BasePortletEntry.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BasePortletEntry.java     28 Mar 2002 23:13:15 -0000      1.3
  +++ BasePortletEntry.java     3 Nov 2002 15:10:06 -0000       1.4
  @@ -66,26 +66,119 @@
   /**
    * Default bean like implementation of the PortletEntry interface
    * suitable for serialization with Castor
  - * 
  + *
    * @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
    * @version $Id$
    */
   public class BasePortletEntry extends BasePortletInfoEntry
  -   implements PortletEntry
  +   implements PortletEntry, java.io.Serializable
   {
   
       private String parent;
  -     
  +
       private ContentURL url = new BaseContentURL();
   
       protected Vector categories = new Vector();
  -     
  +
       private boolean application;
  -    
  +
       private String type = PortletEntry.TYPE_ABSTRACT;
   
       private boolean isRef = true;
   
  +    /**
  +     * Implements the equals operation so that 2 elements are equal if
  +     * all their member values are equal.
  +     */
  +    public boolean equals(Object object)
  +    {
  +        if (object==null)
  +        {
  +            return false;
  +        }
  +
  +        BasePortletEntry obj = (BasePortletEntry)object;
  +
  +        if (application!=obj.isApplication())
  +        {
  +            return false;
  +        }
  +
  +        if (parent!=null)
  +        {
  +            if (!parent.equals(obj.getParent()))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (obj.getParent()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        if (type!=null)
  +        {
  +            if (!type.equals(obj.getType()))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (obj.getType()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        if (url!=null)
  +        {
  +            if (!url.equals(obj.getContentURL()))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (obj.getContentURL()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        Iterator i = categories.iterator();
  +        Iterator i2 = obj.getCategories().iterator();
  +        while(i.hasNext())
  +        {
  +            BaseCategory c1 = (BaseCategory)i.next();
  +            BaseCategory c2 = null;
  +
  +            if (i2.hasNext())
  +            {
  +                c2 = (BaseCategory)i2.next();
  +            }
  +            else
  +            {
  +                return false;
  +            }
  +
  +            if (!c1.equals(c2))
  +            {
  +                return false;
  +            }
  +        }
  +
  +        if (i2.hasNext())
  +        {
  +            return false;
  +        }
  +
  +        return super.equals(object);
  +    }
  +
       /** @return the URL associated with this portlet or null */
       public String getURL()
       {
  @@ -115,13 +208,13 @@
       {
           return url;
       }
  -            
  +
       /** @return the entry name from which this one is derived */
       public String getParent()
       {
           return this.parent;
       }
  -                
  +
       /** @return the classname associated to this entry */
       public String getClassname()
       {
  @@ -133,7 +226,7 @@
           return classname;
       }
   
  -                
  +
       /**
        * Sets the ancestor for this PortletEntry.
        * @param parent the new ancestor entry name. This name should
  @@ -143,8 +236,8 @@
       {
           this.parent = parent;
       }
  -        
  -    /** @return true is this entry is only accessible by the 
  +
  +    /** @return true is this entry is only accessible by the
         * portal administrators.
         */
       public boolean isAdmin()
  @@ -153,16 +246,16 @@
           {
               return "admin".equals(getSecurity().getRole());
           }
  -        
  +
           return false;
       }
  -    
  +
       /** @return true is the PortletEntry is marked as an application */
       public boolean isApplication()
       {
           return this.application;
       }
  -    
  +
       /** Sets the application status of this portlet entry. If an entry
        *  is maked as application, the associated portlet will only be displayed
        *  in Maximized mode and can be retrieved specifically
  @@ -173,15 +266,15 @@
       {
           this.application = application;
       }
  -    
  +
       /** @return the type of this entry */
       public String getType()
       {
           return this.type;
       }
  -    
  +
       /** Sets the type of this entry. The type specifies whether it is
  -     *  abstract, instance or ref 
  +     *  abstract, instance or ref
        *
        *  @param type the new type for the PortletEntry
        */
  @@ -189,7 +282,7 @@
       {
           this.isRef = PortletEntry.TYPE_REF.equals(type);
           this.type = type;
  -    }    
  +    }
   
       /** This method is used by the Castor persistence system to retrieve
        *  the application status
  @@ -210,7 +303,7 @@
           if (isRef)
           {
              return getParentEntry().getTitle();
  -        }        
  +        }
           return null;
       }
   
  @@ -223,7 +316,7 @@
           if (isRef)
           {
               return getParentEntry().getDescription();
  -        }        
  +        }
           return null;
       }
   
  @@ -231,7 +324,7 @@
       public PortletEntry getParentEntry()
       {
           PortletEntry parent = null;
  -        parent = (PortletEntry)Registry.getEntry( Registry.PORTLET, getParent() );  
      
  +        parent = (PortletEntry)Registry.getEntry( Registry.PORTLET, getParent() );
           if (parent == null)
           {
               parent = new BasePortletEntry();
  @@ -267,10 +360,10 @@
               {
                   hash.put(i.next(),"1");
               }
  -        
  +
               return hash.keySet().iterator();
           }
  -        
  +
           return super.getParameterNames();
       }
   
  @@ -282,11 +375,11 @@
        */
       public Parameter getParameter( String name )
       {
  -        Parameter p = super.getParameter(name);        
  +        Parameter p = super.getParameter(name);
           if (isRef && p == null)
           {
               return getParentEntry().getParameter(name);
  -        }        
  +        }
           return p;
       }
   
  @@ -296,7 +389,7 @@
           return (CachedParameter)p;
       }
   
  -    /** Returns a map of parameter values keyed on the parameter names 
  +    /** Returns a map of parameter values keyed on the parameter names
        *  @return the parameter values map
        */
       public Map getParameterMap()
  @@ -309,11 +402,11 @@
               map.putAll(params);
               return map;
           }
  -        
  -        return params;        
  +
  +        return params;
       }
   
  -    /** 
  +    /**
        * Returns a list of the supported media type names
        *
        * @return an iterator on the supported media type names
  @@ -323,7 +416,7 @@
           if (isRef)
           {
               Map types = new HashMap();
  -        
  +
               Iterator i = super.listMediaTypes();
               while(i.hasNext())
               {
  @@ -335,18 +428,18 @@
               {
                   types.put(i.next(),"1");
               }
  -            
  +
               return types.keySet().iterator();
           }
  -            
  +
           return super.listMediaTypes();
       }
   
  -    /** 
  +    /**
        * Test if a given media type is supported by this entry.
        * The test is done by a case sensitive name comparison
        *
  -     * @param name the media type name to test for. 
  +     * @param name the media type name to test for.
        * @return true is the media type is supported false otherwise
        */
       public boolean hasMediaType(String name)
  @@ -355,7 +448,7 @@
           {
               return super.hasMediaType(name) || getParentEntry().hasMediaType(name);
           }
  -        
  +
           return super.hasMediaType(name);
       }
   
  @@ -387,7 +480,7 @@
           this.categories = v;
       }
   
  -    /** 
  +    /**
        * Returns a list of the supported media type names
        *
        * @return an iterator on the supported media type names
  @@ -397,7 +490,7 @@
           return new PortletIterator(this, "getCategories");
       }
   
  -    /** 
  +    /**
        * Test if a given category exists for this entry
        *
        * @param name the category name
  @@ -408,11 +501,11 @@
           return hasCategory(name, PortletEntry.DEFAULT_GROUP);
       }
   
  -    /** 
  +    /**
        * Test if a given category exists for this entry, in the specified group of 
categories.
        *
        * @param name the category name
  -     * @param group the category group 
  +     * @param group the category group
        * @return true is the category exists in the specified group
        */
       public boolean hasCategory(String name, String group)
  @@ -427,8 +520,8 @@
           return false;
       }
   
  -    
  -    /** 
  +
  +    /**
        * Add a new category to this portlet entry in the default group.
        *
        * @param name the category name
  @@ -438,7 +531,7 @@
           addCategory(name, PortletEntry.DEFAULT_GROUP);
       }
   
  -    /** 
  +    /**
        * Add a new category to this portlet entry.
        *
        * @param name the category name
  @@ -454,8 +547,8 @@
               categories.add(cat);
           }
       }
  -    
  -    /** 
  +
  +    /**
        * Remove a category from this portlet entry in the default group.
        *
        * @param name the category name
  @@ -465,10 +558,10 @@
           removeCategory(name, PortletEntry.DEFAULT_GROUP);
       }
   
  -    /** 
  +    /**
        * Remove a category from this portlet entry in the specified group.
        *
  -     * @param name the media type name to remove. 
  +     * @param name the media type name to remove.
        * @param group the category group name
        */
       public void removeCategory(String name, String group)
  @@ -483,9 +576,6 @@
               }
           }
       }
  -    
  -
  -
   }
   
   
  
  
  
  1.5       +5 -4      
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseRegistry.java
  
  Index: BaseRegistry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseRegistry.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BaseRegistry.java 30 Oct 2002 15:52:05 -0000      1.4
  +++ BaseRegistry.java 3 Nov 2002 15:10:06 -0000       1.5
  @@ -70,6 +70,7 @@
    */
   public class BaseRegistry implements Registry
   {
  +        protected static final boolean DEBUG = false;
   
       protected Map entries = new TreeMap();
   
  @@ -215,11 +216,11 @@
        */
       public RegistryEntry createEntry()
       {
  -             return new BaseRegistryEntry();
  -     }
  +        return new BaseRegistryEntry();
  +    }
   
   
  -     // RegistryService specific methods
  +    // RegistryService specific methods
   
       /**
        * This method is used  to only set the entry in the local
  
  
  
  1.7       +72 -2     
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseRegistryEntry.java
  
  Index: BaseRegistryEntry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseRegistryEntry.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BaseRegistryEntry.java    30 Oct 2002 15:52:05 -0000      1.6
  +++ BaseRegistryEntry.java    3 Nov 2002 15:10:06 -0000       1.7
  @@ -63,7 +63,6 @@
   import org.apache.jetspeed.om.registry.MetaInfo;
   import org.apache.jetspeed.om.registry.Security;
   import org.apache.jetspeed.om.registry.RegistryEntry;
  -//import org.apache.jetspeed.om.registry.*;
   
   /**
    * Base simple bean-like implementation of the RegistryEntry interface
  @@ -108,6 +107,77 @@
           this.setMetaInfo(meta);
           BaseSecurity security = new BaseSecurity(role);
           this.setSecurity(security);
  +    }
  +
  +    /**
  +     * Implements the equals operation so that 2 elements are equal if
  +     * all their member values are equal.
  +     */
  +    public boolean equals(Object entry)
  +    {
  +        if (entry==null)
  +        {
  +            return false;
  +        }
  +
  +        BaseRegistryEntry e = (BaseRegistryEntry)entry;
  +
  +        if (e.getId()!=getId())
  +        {
  +            return false;
  +        }
  +
  +        if (e.isHidden()!=isHidden())
  +        {
  +            return false;
  +        }
  +
  +        if (name!=null)
  +        {
  +            if (!e.name.equals(name))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (e.name!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        if (metaInfo != null)
  +        {
  +            if (!metaInfo.equals(e.metaInfo))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (e.metaInfo!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        if (security!=null)
  +        {
  +            if (!security.equals(e.security))
  +            {
  +                return false;
  +            }
  +        }
  +        else
  +        {
  +            if (e.security!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        return true;
       }
   
       /** @see RegistryEntry#getName */
  
  
  
  1.3       +33 -5     
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurity.java
  
  Index: BaseSecurity.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurity.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BaseSecurity.java 1 Apr 2002 23:16:53 -0000       1.2
  +++ BaseSecurity.java 3 Nov 2002 15:10:06 -0000       1.3
  @@ -57,9 +57,9 @@
   import org.apache.jetspeed.om.registry.*;
   
   /**
  - * Bean like implementation of the Security interface suitable for 
  + * Bean like implementation of the Security interface suitable for
    * Castor serialization.
  - * 
  + *
    * @see org.apache.jetspeed.om.registry.Security
    * @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
    * @version $Id$
  @@ -68,7 +68,7 @@
   {
   
       private String role;
  -            
  +
       public BaseSecurity()
       {}
   
  @@ -77,12 +77,40 @@
           this.role = role;
       }
   
  +    /**
  +     * Implements the equals operation so that 2 elements are equal if
  +     * all their member values are equal.
  +     */
  +    public boolean equals(Object object)
  +    {
  +        if (object==null)
  +        {
  +            return false;
  +        }
  +
  +        BaseSecurity obj = (BaseSecurity)object;
  +
  +        if (role!=null)
  +        {
  +            return role.equals(obj.getRole());
  +        }
  +        else
  +        {
  +            if (obj.getRole()!=null)
  +            {
  +                return false;
  +            }
  +        }
  +
  +        return true;
  +    }
  +
       /** @return the role name that is required for accessing this entry */
       public String getRole()
       {
           return this.role;
       }
  -                                
  +
       /** Sets the role name required for accessing this entry
        * @param role the required role name
        */
  
  
  
  1.6       +29 -29    
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurityEntry.java
  
  Index: BaseSecurityEntry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurityEntry.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BaseSecurityEntry.java    25 Aug 2002 19:09:42 -0000      1.5
  +++ BaseSecurityEntry.java    3 Nov 2002 15:10:06 -0000       1.6
  @@ -67,35 +67,35 @@
   
   /**
    * Interface for manipulatin the Security Entry on the registry entries
  - * 
  + *
    * @author <a href="mailto:paulsp@;apache.org">Paul Spencer</a>
    * @version $Id$
    */
   public class BaseSecurityEntry extends BaseRegistryEntry implements SecurityEntry, 
java.io.Serializable
   {
  -    
  +
       /** Holds value of property accesses. */
       private Vector accesses;
  -    
  -    private Map accessMap = null;
  -    
  +
  +    private transient Map accessMap = null;
  +
       public static final String ALL_ACTIONS = "*";
  -    
  +
       public static final String ALL_ROLES = "*";
  -    
  +
       public static final String ALL_USERS = "*";
  -    
  +
       private static final String OWNER_MAP = "owner";
  -    
  +
       private static final String ROLE_MAP = "role";
  -    
  +
       private static final String USER_MAP = "user";
  -    
  -    private static Object accessMapSync = new Object();
  +
  +    private transient static Object accessMapSync = new Object();
   
       public BaseSecurityEntry()
       { }
  -    
  +
       /** Getter for property accesses.
        * @return Value of property accesses.
        */
  @@ -103,7 +103,7 @@
       {
           return accesses;
       }
  -    
  +
       /** Setter for property accesses.
        * @param accesses New value of property accesses.
        */
  @@ -111,7 +111,7 @@
       {
           this.accesses = accesses;
       }
  -    
  +
       /**
        * Aututhorizes action for a role.
        *
  @@ -129,12 +129,12 @@
       {
           Map allowMap = null;
           boolean allow = false;
  -        
  +
           if (accessMap == null)
           {
               buildAccessMap();
           }
  -        
  +
           // Checked action
           allowMap = (Map) accessMap.get(action);
           allow = isInAllowMap(allowMap, ROLE_MAP, role, ALL_ROLES);
  @@ -146,11 +146,11 @@
           // Checked all actions
           allowMap = (Map) accessMap.get(ALL_ACTIONS);
           allow = isInAllowMap(allowMap, ROLE_MAP, role, ALL_ROLES);
  -        
  +
           // Not allowed
           return allow;
       }
  -    
  +
       /**
        * Aututhorizes action for a named user
        *
  @@ -216,31 +216,31 @@
           // Checked all actions
           allowMap = (Map) accessMap.get(ALL_ACTIONS);
           allow = isInAllowMap(allowMap, USER_MAP, userName, ALL_USERS);
  -        
  +
           // Not allowed
           return allow;
   
       }
  -    
  +
       private void buildAccessMap()
       {
           Map actionMap = null;
           SecurityAccess accessElement = null;
  -        
  +
           synchronized (accessMapSync)
           {
               if (accessMap == null)
               {
                   accessMap = new HashMap();
               }
  -            
  +
               accessMap.clear();
           }
           // Build allow map
           for (Iterator accessIterator = getAccesses().iterator(); 
accessIterator.hasNext();)
           {
               accessElement = (SecurityAccess) accessIterator.next();
  -            
  +
               // Get action map of the action.  Create one if none exists
               String action = accessElement.getAction();
   
  @@ -258,9 +258,9 @@
               addAllows(actionMap, accessElement);
           }
       }
  -    
  +
       /**
  -     * Add access elements to the access map.  The elements will be 
  +     * Add access elements to the access map.  The elements will be
        * appened to the appropiate map.
        *
        * @param accessMap to receive accessElements
  @@ -274,7 +274,7 @@
           Map roleMap = null;  // Map of roles allowed
           Map userMap = null;  // Map of users allowed
           String userName = null;
  -        
  +
           if (accessElement.getAllAllows() == null)
           {
               return;
  @@ -336,7 +336,7 @@
        * @param mapKey role or user to test
        * @param allKey ALL_ROLE or ALL_USER
        * @return <CODE>true</CODE> or <CODE>false</CODE>
  -     */    
  +     */
       private boolean isInAllowMap(Map allowMap, String mapType, String mapKey, 
String allKey)
       {
           boolean allow = false;
  
  
  

--
To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@;jakarta.apache.org>

Reply via email to