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/portal/portlets AbstractPortlet.java
Date Mon, 28 May 2001 15:13:58 GMT
raphael     01/05/28 08:13:58

  Modified:    src/java/org/apache/jetspeed/portal/portlets
                        AbstractPortlet.java
  Log:
  change default implementation in AbstractPortlet and AbstractPortletControl
  to check for registry media-types and mime type support
  
  Revision  Changes    Path
  1.37      +118 -6    jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java
  
  Index: AbstractPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- AbstractPortlet.java	2001/05/07 20:49:25	1.36
  +++ AbstractPortlet.java	2001/05/28 15:13:58	1.37
  @@ -61,6 +61,12 @@
   import org.apache.jetspeed.capability.*;
   import org.apache.jetspeed.util.*;
   import org.apache.jetspeed.services.portletcache.Cacheable;
  +import org.apache.jetspeed.portal.service.PersistenceService;
  +import org.apache.jetspeed.portal.service.ServiceFactory;
  +import org.apache.jetspeed.portal.service.ServiceException;
  +import org.apache.jetspeed.services.Registry;
  +import org.apache.jetspeed.om.newregistry.PortletEntry;
  +import org.apache.jetspeed.om.newregistry.MediaTypeEntry;
   
   //ecs
   import org.apache.ecs.*;
  @@ -87,7 +93,7 @@
   
   @author <A HREF="mailto:burton@apache.org">Kevin A. Burton</A>
   @author <A HREF="mailto:raphael@apache.org">RaphaŽl Luta</A>
  -@version $Id: AbstractPortlet.java,v 1.36 2001/05/07 20:49:25 raphael Exp $
  +@version $Id: AbstractPortlet.java,v 1.37 2001/05/28 15:13:58 raphael Exp $
   */
   public abstract class AbstractPortlet implements Portlet, PortletState, Cacheable
   {
  @@ -372,7 +378,26 @@
       /**
       @see Portlet.supportsType
       */
  -    public boolean supportsType( MimeType mimeType ) {
  +    public boolean supportsType( MimeType mimeType )
  +    {
  +/*
  +        PortletEntry entry = (PortletEntry)Registry.getEntry(Registry.PORTLET, getName()
);
  +        String baseType = mimeType.toString();
  +        if (entry!=null)
  +        {
  +            Iterator i = entry.listMediaTypes();
  +
  +            while(i.hasNext())
  +            {
  +                String name = (String)i.next();
  +                MediaTypeEntry media = (MediaTypeEntry)Registry.getEntry(Registry.MEDIA_TYPE,
name);
  +                if (media != null)
  +                {
  +                    if (baseType.equals(media.getMimeType())) return true;
  +                }
  +            }
  +        }
  +*/
           return MimeType.HTML.equals( mimeType );
       }
       
  @@ -436,17 +461,104 @@
       /**
        * Returns true if this portlet is currently maximized
        */
  -    public boolean isMaximized()
  +    public boolean isMaximized(RunData rundata)
  +    {
  +        return this.getAttribute("_display", "normal", rundata ).equals("maximized");
  +    }
  +
  +    /**
  +    Change the portlet visibility state ( maximized <-> normal )
  +
  +    @param minimize True if the portlet change to maximize
  +    @param rundata A RunData object
  +    */
  +    public void setMaximized( boolean maximize, RunData rundata )
       {
  -        return false;
  +        if( allowMaximize( rundata ) )
  +        {
  +            this.setAttribute("_display", maximize ? "maximized" : "normal", rundata );
  +        }
       }
   
       /**
        * Returns true if this portlet is currently minimized
        */
  -    public boolean isMinimized()
  +    public boolean isMinimized(RunData rundata)
  +    {
  +        return this.getAttribute("_display", "normal", rundata ).equals("minimized");
  +    }
  +
  +    /**
  +    Change the portlet visibility state ( minimized <-> normal )
  +
  +    @param minimize True if the portlet change to minimized
  +    @param rundata A RunData object
  +    */
  +    public void setMinimized( boolean minimize, RunData rundata )
       {
  -        return false;
  +        if( allowMinimize( rundata ) )
  +        {
  +            this.setAttribute("_display", minimize ? "minimized" : "normal", rundata );
  +        }
       }
   
  +    // utility methods
  +    
  +    /**
  +    Retrieve a portlet attribute from persistent storage
  +
  +    @param attrName The attribute to retrieve
  +    @parm attrDefValue The value if the attr doesn't exists
  +    @param rundata A RunData object
  +    @return The attribute value
  +    */
  +    public String getAttribute( String attrName, String attrDefValue, RunData rundata )
  +    {
  +        String attrValue = null ;
  +
  +        try
  +        {
  +            Object[] params = { this };
  +            PersistenceService ps = (PersistenceService)ServiceFactory
  +                                        .getService( PersistenceService.class,
  +                                                     rundata, params);
  +            attrValue = ps.getPage().getAttribute( attrName );
  +            if( attrValue == null )
  +            {
  +                attrValue = attrDefValue ;
  +            }
  +        }
  +        catch ( Exception e )
  +        {
  +            Log.error("Exception while retrieving attribute "+attrName+" for portlet "+getName(),e);
  +            attrValue = attrDefValue ;
  +        }
  +
  +        return attrValue;
  +    }
  +
  +    /**
  +    A way to store a portlet attribute in persistent storage
  +
  +    @param attrName The attribute to retrieve
  +    @parm attrValue The value to store
  +    @param rundata A RunData object
  +    */
  +    public void setAttribute( String attrName, String attrValue, RunData rundata )
  +    {
  +        try
  +        {
  +            Object[] params = { this };
  +            PersistenceService ps = (PersistenceService)ServiceFactory
  +                                        .getService( PersistenceService.class,
  +                                                     rundata, params);
  +            ps.getPage().setAttribute( attrName, attrValue );
  +            ps.store();
  +        }
  +        catch ( Exception e )
  +        {
  +            Log.error("Exception while setting attribute "+attrName+" for portlet "+getName(),e);
  +        }
  +    }
  +    
   }
  
  
  

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