You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ra...@apache.org on 2001/06/04 19:36:41 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/portal BasePortletSetConstraints.java BasePortletConfig.java BasePortletSet.java PortletConfig.java PortletSet.java

raphael     01/06/04 10:36:41

  Modified:    src/java/org/apache/jetspeed/portal BasePortletConfig.java
                        BasePortletSet.java PortletConfig.java
                        PortletSet.java
  Added:       src/java/org/apache/jetspeed/portal
                        BasePortletSetConstraints.java
  Log:
  add a new Constraints interface for layout information in PortletSet
  
  Revision  Changes    Path
  1.4       +37 -15    jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletConfig.java
  
  Index: BasePortletConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletConfig.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BasePortletConfig.java	2001/05/27 15:34:34	1.3
  +++ BasePortletConfig.java	2001/06/04 17:36:33	1.4
  @@ -64,23 +64,21 @@
   
   //jetspeed support
   import org.apache.jetspeed.util.*;
  -import org.apache.jetspeed.profiler.*;
   import org.apache.jetspeed.capability.*;
  -import org.apache.jetspeed.portal.factory.SkinFactory;
   
   /**
    * Defines a configuration for Portlets.  A PortletConfig provides information
    * about the running environment of a given Portlet.
    *
    * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
  - * @version $Id: BasePortletConfig.java,v 1.3 2001/05/27 15:34:34 raphael Exp $
  + * @version $Id: BasePortletConfig.java,v 1.4 2001/06/04 17:36:33 raphael Exp $
    */
   public class BasePortletConfig extends BaseConfig implements PortletConfig
   {
   
       private String          url;
       private MetaData        metainfo;
  -    private Map      layoutConstraints = null;
  +    private PortletSet.Constraints  layoutConstraints = null;
       private int             layoutPosition = -1;
       private PortletSkin      skin;
       private transient PortletSet      currentSet;
  @@ -121,6 +119,7 @@
   
       /**
       Returns the portlet current PortletSet
  +     @deprecated use getConstraints instead
       */
       public Map getLayout()
       {
  @@ -128,15 +127,17 @@
       }
   
       /**
  -    Set the context (PortletSet) for this portlet
  +     Set the context (PortletSet) for this portlet
  +     @deprecated use setConstraints instead
       */
       public void setLayout(Map constraints)
       {
  -        this.layoutConstraints=constraints;
  +        //obsolete
       }
   
        /**
       Returns the portlet current PortletSet
  +     @deprecated use getSkin instead
       */
       public Map getSkin()
       {
  @@ -144,11 +145,12 @@
       }
   
       /**
  -    Set the context (PortletSet) for this portlet
  +     Set the context (PortletSet) for this portlet
  +     @deprecated use setPortletSkin instead
       */
       public void setSkin(Map skin)
       {
  -        //this.skin=SkinFactory.getSkin(skin);
  +        //obsolete
       }
   
       /**
  @@ -229,15 +231,14 @@
       {
           String value = null;
   
  -        try
  +        if (name!=null)
           {
               value=(String)layoutConstraints.get(name.toLowerCase());
  -            if (value==null) value=(String)currentSet.getPortletConfig().getLayout(name, defaultValue);
  -            if (value==null) value=defaultValue;
  -        }
  -        catch (RuntimeException e)
  -        {
  -            value=defaultValue;
  +
  +            if (value==null) 
  +            {
  +                value=defaultValue;
  +            }
           }
   
           return value;
  @@ -316,6 +317,27 @@
       public void setPortletSkin(PortletSkin skin)
       {
           this.skin = skin;
  +    }
  +    
  +    /**
  +     * Retrieves the constraints associated with this portlet
  +     *
  +     * @returns the Constraints object
  +     */
  +    public PortletSet.Constraints getConstraints()
  +    { 
  +        return this.layoutConstraints;
  +    }
  +    
  +    /**
  +     * Sets the layout constraints in the current portlet set
  +     *
  +     * @param constraints the constrints object associated with this portlet
  +     * in the current set
  +     */
  +    public void setConstraints(PortletSet.Constraints constraints)
  +    {
  +        this.layoutConstraints = constraints;
       }
       
       /**
  
  
  
  1.6       +5 -17     jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java
  
  Index: BasePortletSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BasePortletSet.java	2001/05/31 17:10:51	1.5
  +++ BasePortletSet.java	2001/06/04 17:36:34	1.6
  @@ -60,7 +60,6 @@
   import java.util.Enumeration;
   
   //Jetspeed stuff
  -import org.apache.jetspeed.services.ControllerFactory;
   import org.apache.jetspeed.profiler.*;
   import org.apache.jetspeed.capability.*;
   import org.apache.jetspeed.util.*;
  @@ -82,7 +81,7 @@
    *
    * @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
    * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
  - * @version $Id: BasePortletSet.java,v 1.5 2001/05/31 17:10:51 raphael Exp $
  + * @version $Id: BasePortletSet.java,v 1.6 2001/06/04 17:36:34 raphael Exp $
    */
   public class BasePortletSet implements PortletSet, Portlet, PortletState
   {
  @@ -149,17 +148,11 @@
       /**
       */
       public void init() throws PortletException
  -    {
  -            
  +    {            
           if (getPortletConfig()==null)
           {
               setPortletConfig(new BasePortletConfig());
           }
  -            
  -        if (getController()==null)
  -        {
  -            setController( ControllerFactory.getPortletController("") );
  -        }
       }
   
       // Set manipulation methods
  @@ -224,7 +217,7 @@
       /**
       Add a portlet to this set.It updates its config to modify the current set
       */
  -    public void addPortlet(Portlet portlet, Map constraints)
  +    public void addPortlet(Portlet portlet, Constraints constraints)
       {
           addPortlet(portlet,constraints,-1);
       }
  @@ -232,7 +225,7 @@
       /**
       Add a portlet to this set.It updates its config to modify the current set
       */
  -    public void addPortlet(Portlet portlet, Map constraint, int position)
  +    public void addPortlet(Portlet portlet, Constraints constraints, int position)
       {
           synchronized (portlets)
           {
  @@ -241,7 +234,7 @@
               if (pc!=null)
               {
                   pc.setPortletSet(this);
  -                if (constraint!=null) pc.setLayout(constraint);
  +                if (constraints!=null) pc.setConstraints(constraints);
                   if (position >=0) pc.setPosition(position);
               }
           }
  @@ -303,11 +296,6 @@
           }
           else
           {
  -            if ( ! controller.supportsType( map.getPreferredType() ) )
  -            {
  -                setController( ControllerFactory.getPortletController("") );
  -            }
  -    
               return controller.getContent( rundata );
           }
   
  
  
  
  1.45      +16 -1     jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletConfig.java
  
  Index: PortletConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletConfig.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- PortletConfig.java	2001/05/27 15:34:35	1.44
  +++ PortletConfig.java	2001/06/04 17:36:35	1.45
  @@ -67,7 +67,7 @@
   about the running environment of a given Portlet.
   
   @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
  -@version $Id: PortletConfig.java,v 1.44 2001/05/27 15:34:35 raphael Exp $
  +@version $Id: PortletConfig.java,v 1.45 2001/06/04 17:36:35 raphael Exp $
   */
   
   public interface PortletConfig extends Config
  @@ -178,6 +178,21 @@
        * @param skin the new skin to use
        */
       public void setPortletSkin(PortletSkin skin);
  +    
  +    /**
  +     * Retrieves the constraints associated with this portlet
  +     *
  +     * @returns the Constraints object
  +     */
  +    public PortletSet.Constraints getConstraints();
  +    
  +    /**
  +     * Sets the layout constraints in the current portlet set
  +     *
  +     * @param constraints the constrints object associated with this portlet
  +     * in the current set
  +     */
  +    public void setConstraints(PortletSet.Constraints constraints);
       
       /**
       */
  
  
  
  1.23      +44 -11    jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletSet.java
  
  Index: PortletSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletSet.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- PortletSet.java	2001/05/27 11:07:31	1.22
  +++ PortletSet.java	2001/06/04 17:36:36	1.23
  @@ -65,11 +65,21 @@
    * 
    * @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
    * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a>
  - * @version $Id: PortletSet.java,v 1.22 2001/05/27 11:07:31 raphael Exp $
  + * @version $Id: PortletSet.java,v 1.23 2001/06/04 17:36:36 raphael Exp $
    */
   public interface PortletSet extends Portlet
   {
       /**
  +     * Return the current controller for this set
  +     */
  +    public PortletController getController();
  +
  +    /**
  +     * Set the controller for this set
  +     */
  +    public void setController(PortletController controller);
  +
  +    /**
        * Returns the number of portlets currently stored in this set
        */
       public int size();
  @@ -102,21 +112,44 @@
       /**
        * Add a portlet to this set.It updates its config to modify the current set
        */
  -    public void addPortlet(Portlet portlet, Map constraints);
  +    public void addPortlet(Portlet portlet, Constraints constraints);
   
       /**
        * Add a portlet to this set.It updates its config to modify the current set
        */
  -    public void addPortlet(Portlet portlet, Map constraint, int position);
  +    public void addPortlet(Portlet portlet, Constraints constraints, int position);
   
       /**
  -     * Return the current controller for this set
  -     */
  -    public PortletController getController();
  -
  -    /**
  -     * Set the controller for this set
  -     */
  -    public void setController(PortletController controller);
  +     * The PortletSetConstraints is used to associate layout constraints with a 
  +     * Portlet within a Set. These constraints may be used by the PortletController
  +     * to render the layout of any given PortletSet correctly.
  +     */
  +    public interface Constraints extends Map
  +    {   
  +        /** Get the column the portlet should be displayed in
  +         *
  +         * @return a positive column number or null
  +         */
  +        public Integer getColumn();
  +        
  +        /** Set the column the portlet should be displayed in. This
  +         *  integer must be positive
  +         *
  +         * @param col the column position
  +         */
  +        public void setColumn(Integer col) throws IllegalArgumentException;
  +        
  +        /** Get the row the portlet should be displayed in
  +         *
  +         * @return a positive row number or null
  +         */
  +        public Integer getRow();
           
  +        /** Set the row the portlet should be displayed in. This
  +         *  integer must be positive
  +         *
  +         * @param row the column position
  +         */
  +        public void setRow(Integer row) throws IllegalArgumentException;
  +    }
   }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSetConstraints.java
  
  Index: BasePortletSetConstraints.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.portal;
  
  /**
   * Trivial implementation of PortletSetConstraints
   *
   * @author <a href="mailto:raphael@apache.org">Rapha�l Luta</a>
   * @version $Id: BasePortletSetConstraints.java,v 1.1 2001/06/04 17:36:35 raphael Exp $
   */
  public class BasePortletSetConstraints extends java.util.HashMap
      implements PortletSet.Constraints
  {
      /** Get the column the portlet should be displayed in
       *
       * @return a positive column number or null
       */
      public Integer getColumn()
      {
          return (Integer)get("column");
      }
          
      /** Set the column the portlet should be displayed in. This
       *  integer must be positive
       *
       * @param col the column position
       */
      public void setColumn(Integer col) throws IllegalArgumentException
      {
          if (col.intValue() < 0)
          {
              throw new IllegalArgumentException("Column coordinate must be positive");
          }
          
          put("column",col);
      }
  
      /** Get the row the portlet should be displayed in
       *
       * @return a positive row number or null
       */
      public Integer getRow()
      {
          return (Integer)get("row");
      }
          
      /** Set the row the portlet should be displayed in. This
       *  integer must be positive
       *
       * @param row the column position
       */
      public void setRow(Integer row) throws IllegalArgumentException
      {
          if (row.intValue() < 0)
          {
              throw new IllegalArgumentException("Row coordinate must be positive");
          }
          
          put("row",row);
      }
  }
  
  
  

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