portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raph...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry NormalizedPortletEntry.java CastorRegistryService.java RegistryUtils.java
Date Wed, 02 May 2001 21:11:36 GMT
raphael     01/05/02 14:11:35

  Modified:    src/java/org/apache/jetspeed/services/registry
                        CastorRegistryService.java
  Added:       src/java/org/apache/jetspeed/services/registry
                        NormalizedPortletEntry.java
  Removed:     src/java/org/apache/jetspeed/services/registry
                        RegistryUtils.java
  Log:
  add parameter normalization to the Registry
  
  Revision  Changes    Path
  1.3       +9 -2      jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java
  
  Index: CastorRegistryService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/CastorRegistryService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CastorRegistryService.java	2001/05/02 14:17:27	1.2
  +++ CastorRegistryService.java	2001/05/02 21:11:27	1.3
  @@ -98,7 +98,7 @@
    * </p>
    *
    * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
  - * @version $Id: CastorRegistryService.java,v 1.2 2001/05/02 14:17:27 raphael Exp $
  + * @version $Id: CastorRegistryService.java,v 1.3 2001/05/02 21:11:27 raphael Exp $
    */
   public class CastorRegistryService
       extends TurbineBaseService
  @@ -315,11 +315,18 @@
                           RegistryEntry entry = (RegistryEntry)en3.nextElement();
                           try 
                           {
  +                            if (entry instanceof PortletEntry)
  +                            {
  +                                if (PortletEntry.TYPE_REF.equals(((PortletEntry)entry).getType()))
  +                                {
  +                                    entry = new NormalizedPortletEntry((PortletEntry)entry);
  +                                }
  +                            }
                               registry.addEntry(entry);
                           }
                           catch (RegistryException e)
                           {
  -                            Log.error("Unable to able entry "+entry.getName(),e);
  +                            Log.error("Unable to add entry "+entry.getName(),e);
                           }
                       }
                   }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/services/registry/NormalizedPortletEntry.java
  
  Index: NormalizedPortletEntry.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.jetspeed.services.registry;
  
  import org.apache.jetspeed.om.newregistry.*;
  import org.apache.jetspeed.om.newregistry.base.*;
  import org.apache.jetspeed.services.Registry;
  import java.util.*;
  
  /**
   * This implementation of the registry PortletEntry normalizes the parameters,
   * classname and URL of "ref" type entries by integrating its parents' parameters
   * 
   * @author <a href="mailto:raphael@apache.org">RaphaŽl Luta</a>
   * @version $Id: NormalizedPortletEntry.java,v 1.1 2001/05/02 21:11:29 raphael Exp $
   */
  public class NormalizedPortletEntry extends BasePortletEntry
  {
  
      /** the real portlet entry */
      private PortletEntry entry;
       
      private boolean isRef = true;
      
      public NormalizedPortletEntry(PortletEntry real)
      {
          this.entry = real;
          this.isRef = PortletEntry.TYPE_REF.equals(entry.getType());
      }
      
      /** @see RegistryEntry.getName */
      public String getName()
      {
          return entry.getName();
      }
                                  
      /** @see RegistryEntry.setName */
      public void setName( String name )
      {
          entry.setName(name);
      }
  
      /** @see RegistryEntry.getTitle */
      public String getTitle()
      {
          if (isRef && (entry.getTitle() == null) )
          {
              return getParentEntry().getTitle();
          }
          
          return entry.getTitle();
      }
                                  
      /** @see RegistryEntry.setTitle */
      public void setTitle(String title)
      {
          entry.setTitle(title);
      }
  
      /** @see RegistryEntry.getDescription */
      public String getDescription()
      {
          if (isRef && (entry.getDescription() == null) )
          {
              return getParentEntry().getDescription();
          }
          
          return entry.getDescription();
      }
                                  
      /** @see RegistryEntry.setDescription */
      public void setDescription(String description)
      {
          entry.setDescription(description);
      }
  
      /** @see RegistryEntry.getSecurity */
      public Security getSecurity()
      {
          return entry.getSecurity();
      }
                                  
      /** @see RegistryEntry.setSecurity */
      public void setSecurity( Security security )
      {
          entry.setSecurity(security);
      }
  
      /** @see RegistryEntry.isHidden */
      public boolean isHidden()
      {
          // RL: should we normalize this ?
          return entry.isHidden();
      }                        
          
      /** @see RegistryEntry.setHidden */
      public void setHidden( boolean hidden )
      {
          entry.setHidden( hidden );
      }    
  
      /** @return the classname associated to this entry */
      public String getClassname()
      {
          if (isRef && (entry.getClassname() == null) )
          {
              return getParentEntry().getClassname();
          }
  
          return entry.getClassname();
      }
  
      /** Sets the classname for this entry. This classname is used for instanciating
       *  the associated element
       *
       *  @param classname the classname used for instanciating the component associated with

       *  this entry
       */
      public void setClassname( String classname )
      {
          entry.setClassname(classname);
      }
      
      /** @return an enumeration of this entry parameter names */
      public Enumeration getParameterNames()
      {
          if (isRef)
          {
              Hashtable hash = new Hashtable();
              Enumeration en = entry.getParameterNames();
              while(en.hasMoreElements())
              {
                  hash.put(en.nextElement(),"1");
              }
              en = getParentEntry().getParameterNames();
              while(en.hasMoreElements())
              {
                  hash.put(en.nextElement(),"1");
              }
          
              return hash.keys();
          }
          
          return entry.getParameterNames();
      }
  
      /** Search for a named parameter and return the associated
       *  parameter object. The search is case sensitive.
       *
       *  @return the parameter object for a given parameter name
       *  @param name the parameter name to look for
       */
      public Parameter getParameter( String name )
      {
          Parameter p = entry.getParameter(name);
  
          if (isRef && (p == null) )
          {
              p = getParentEntry().getParameter(name);
          }
          
          return p;
      }
      
      
      /** Returns a map of parameter values keyed on the parameter names 
       *  @return the parameter values map
       */
      public Map getParameterMap()
      {
          if (isRef)
          {
              Map params = getParentEntry().getParameterMap();
              params.putAll(entry.getParameterMap());
              
              return params;
          }
          
          return entry.getParameterMap();
          
      }
  
      /** Adds a new parameter for this entry
       *  @param name the new parameter name
       *  @param value the new parameter value
       */
      public void addParameter( String name, String value )
      {
          entry.addParameter( name, value );
      }
  
      /** Adds a new parameter for this entry
       *  @param parameter the new parameter to add
       */
      public void addParameter( Parameter parameter )
      {
          entry.addParameter( parameter );
      }
  
      /** Removes all parameter values associated with the
       *  name
       *
       * @param name the parameter name to remove
       */
      public void removeParameter( String name )
      {
          entry.removeParameter( name );
      }
      
      /** @return the URL associated with this portlet or null */
      public String getURL()
      {
          if (isRef && (entry.getURL() == null) )
          {
              return getParentEntry().getURL();
          }
          
          return entry.getURL();
      }
  
      /**
       * Sets the URL for this PortletEntry
       * @param url the new PortletEntry URL
       */
      public void setURL( String url )
      {
          entry.setURL(url);
      }
              
      /** @return the entry name from which this one is derived */
      public String getParent()
      {
          return entry.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 )
      {
          entry.setParent(parent);
      }
          
      /** @return true is this entry is only accessible by the 
        * portal administrators.
        */
      public boolean isAdmin()
      {
          //RL: should we normalize this ?
          return entry.isAdmin();
      }
      
      /** @return true is the PortletEntry is marked as an application */
      public boolean isApplication()
      {
          //RL: should we normalize this ?
          return entry.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
       *
       *  @param application the new application status
       */
      public void setApplication( boolean application )
      {
          entry.setApplication(application);
      }
      
      /** @return the type of this entry */
      public String getType()
      {
          return entry.getType();
      }
      
      /** Sets the type of this entry. The type specifies whether it is
       *  abstract, instance or ref 
       *
       *  @param type the new type for the PortletEntry
       */
      public void setType( String type )
      {
          entry.setType(type);
      }    
  
      protected PortletEntry getParentEntry()
      {
          PortletEntry parent = (PortletEntry)Registry.getEntry( Registry.PORTLET, entry.getParent()
);
          if (parent == null) parent = entry;
          
          return parent;
      }
  }
  
  
  
  

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


Mime
View raw message