paulsp 02/01/18 19:51:43
Modified: src/java/org/apache/jetspeed/portal/portlets
AbstractPortlet.java
Log:
o Update javadoc
o Move group method by interface
o Cleanup imports
Revision Changes Path
1.50 +220 -149
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.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- AbstractPortlet.java 29 Dec 2001 00:43:16 -0000 1.49
+++ AbstractPortlet.java 19 Jan 2002 03:51:43 -0000 1.50
@@ -55,29 +55,41 @@
package org.apache.jetspeed.portal.portlets;
//jetspeed
-import org.apache.jetspeed.portal.*;
-import org.apache.jetspeed.portal.expire.*;
-import org.apache.jetspeed.capability.*;
-import org.apache.jetspeed.util.*;
-import org.apache.jetspeed.services.portletcache.Cacheable;
+import org.apache.jetspeed.capability.CapabilityMap;
+import org.apache.jetspeed.capability.CapabilityMapFactory;
+import org.apache.jetspeed.om.registry.MediaTypeEntry;
+import org.apache.jetspeed.om.registry.PortletEntry;
+import org.apache.jetspeed.portal.BasePortletConfig;
+import org.apache.jetspeed.portal.expire.Expire;
+import org.apache.jetspeed.portal.expire.ExpireFactory;
+import org.apache.jetspeed.portal.Portlet;
+import org.apache.jetspeed.portal.PortletConfig;
+import org.apache.jetspeed.portal.PortletException;
+import org.apache.jetspeed.portal.PortletState;
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.registry.PortletEntry;
-import org.apache.jetspeed.om.registry.MediaTypeEntry;
import org.apache.jetspeed.services.JetspeedSecurity;
+import org.apache.jetspeed.services.portletcache.Cacheable;
+import org.apache.jetspeed.services.portletcache.GlobalCache;
+import org.apache.jetspeed.services.Registry;
+import org.apache.jetspeed.util.JetspeedException;
+import org.apache.jetspeed.util.MetaData;
+import org.apache.jetspeed.util.MimeType;
//ecs
-import org.apache.ecs.*;
+import org.apache.ecs.ClearElement;
+import org.apache.ecs.ConcreteElement;
//turbine stuff
-import org.apache.turbine.util.*;
+import org.apache.turbine.services.cache.CachedObject;
+import org.apache.turbine.util.Log;
+import org.apache.turbine.util.RunData;
//java stuff
-import java.util.*;
-import java.io.*;
-
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.io.Serializable;
/**
<p>
Should be used by most Portlets that wish to conform to default behavior
@@ -94,7 +106,7 @@
@author <A HREF="mailto:[EMAIL PROTECTED]">Kevin A. Burton</A>
@author <A HREF="mailto:[EMAIL PROTECTED]">Rapha�l Luta</A>
@author <A HREF="mailto:[EMAIL PROTECTED]">Santiago Gala</A>
-@version $Id: AbstractPortlet.java,v 1.49 2001/12/29 00:43:16 paulsp Exp $
+@version $Id: AbstractPortlet.java,v 1.50 2002/01/19 03:51:43 paulsp Exp $
*/
public abstract class AbstractPortlet implements Portlet, PortletState, Cacheable
{
@@ -129,67 +141,73 @@
*/
private long creationTime;
-
/**
*/
- public String getName()
- {
-
- if ( name == null )
- {
- if (getPortletConfig()!=null)
- {
- if (getPortletConfig().getName()!=null)
- {
- return getPortletConfig().getName();
- }
- else
- {
- return this.getClass().getName();
- }
- }
- }
-
- return name;
-
+ protected void clearContent() {
+ this.content.clear();
}
/**
- */
- public void setName( String name ) {
- this.name = name;
+ */
+ protected void setContent( ConcreteElement content ) {
+ this.setContent( content,
+ CapabilityMapFactory.getDefaultCapabilityMap() );
}
/**
*/
- public PortletConfig getPortletConfig() {
- return this.pc;
+ protected void setContent( String content ) {
+ this.setContent( new ClearElement( content ),
+ CapabilityMapFactory.getDefaultCapabilityMap() );
}
/**
*/
- public void setPortletConfig( PortletConfig pc ) {
- this.pc = pc;
+ protected void setContent( ConcreteElement content,
+ CapabilityMap map )
+ throws IllegalArgumentException
+ {
+ CapabilityMap mymap = map;
+ if ( mymap == null ) {
+ mymap = CapabilityMapFactory.getDefaultCapabilityMap();
+ }
+
+ ConcreteElement buffer = new ClearElement( content.toString( ) );
+ this.content.put( mymap.toString(), buffer );
}
- //Cacheable interface
+ /*
+ * Implement methods required by Cacheable
+ */
/**
- */
+ * Is this portlet cacheable. It is the portlet's responsability to
+ * cache the content.
+ *
+ * @return <CODE>true</CODE> Cachable<BR>
+ * <CODE>false</CODE> Not cachable
+ */
public boolean isCacheable() {
return this.cacheable;
}
/**
- */
+ * Set cachable. This should only be called in the portlet's init().
+ *
+ * @param cacheable <CODE>true</CODE> Portlet is cachable<BR>
+ * <CODE>false</CODE> Portlet is NOT cachable
+ */
public void setCacheable(boolean cacheable) {
this.cacheable = cacheable;
}
/**
- */
+ * Used by a Cacheable object to determine when it should expire itself from
the cache.
+ *
+ * @return Expire
+ */
public Expire getExpire() {
try {
return ExpireFactory.getExpire( this, ExpireFactory.NO_EXPIRE );
@@ -200,37 +218,56 @@
}
/**
- */
+ * <p>Used by the cache to get a unique reference on what you want to add
+ * and then retrieve in the future from the cache</p>
+ *
+ * <p>Most implementations should just call the CacheHandleManager with
+ * the given params within the implementation and just return this.</p>
+ *
+ * @return Cache handle (key)
+ */
public final String getHandle() {
return this.handle;
}
/**
- */
+ * Used by a Cacheable object to determine when it should
+ * expire itself from the cache.
+ *
+ * @param handle Cache Handle
+ *
+ * @deprecated cacheable classes should now implement a static
getHandle(config) method
+ */
public final void setHandle( String handle ) {
this.handle = handle;
}
/**
- @see Cacheable#getExpirationMillis
- */
+ * Set the expiration time in milliseconds.
+ *
+ * @return Expiration time in milliseconds since epoch, or null if the
expiration was not set.
+ */
public Long getExpirationMillis() {
return this.expirationMillis;
}
-
/**
- @see Cacheable#setExpirationMillis
- */
+ * Sets the cache expiration time. When the portlet is stale (expired),
+ * the refresh() will be called if the portlet has not been untouched
+ * longer then then it's TimeToLive.
+ *
+ * @param expirationMillis setExpirationMillis Expiration in milliseconds since
epoch
+ */
public void setExpirationMillis( long expirationMillis) {
this.expirationMillis = new Long(expirationMillis);
}
- /** Builds a new cache handle for this cacheable class with the specified
- * config object.
+ /**
+ * Builds a new cache handle for this cacheable class with the specified
+ * config object.
*
- * @param config the configuration object to use for building the handle
- * @return a cache handle
+ * @param config The configuration object to use for building the handle
+ * @return A cache handle
*/
public static Object getHandle(Object config)
{
@@ -268,8 +305,65 @@
return handle.toString();
}
+ /*
+ * Implement methods required by Portlet
+ */
+
/**
- */
+ * Get the portlet's name
+ *
+ * @return Name of the portlet
+ */
+ public String getName()
+ {
+
+ if ( name == null )
+ {
+ if (getPortletConfig()!=null)
+ {
+ if (getPortletConfig().getName()!=null)
+ {
+ return getPortletConfig().getName();
+ }
+ else
+ {
+ return this.getClass().getName();
+ }
+ }
+ }
+
+ return name;
+
+ }
+
+ /**
+ * Set the name of the portlet
+ *
+ * @param name Name of the portlet
+ */
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ /**
+ * Get the config of this servlet
+ *
+ * @return PortletConfig Portlet
+ */
+ public PortletConfig getPortletConfig() {
+ return this.pc;
+ }
+
+ /**
+ * Set's the configuration of this servlet.
+ */
+ public void setPortletConfig( PortletConfig pc ) {
+ this.pc = pc;
+ }
+
+ /**
+ * @param rundata The RunData object for the current request
+ */
public ConcreteElement getContent( RunData rundata ) {
return getContent( rundata, null , true );
@@ -283,7 +377,8 @@
}
/**
- */
+ * @param rundata The RunData object for the current request
+ */
public ConcreteElement getContent( RunData rundata,
CapabilityMap map,
boolean allowRecurse ) {
@@ -331,46 +426,10 @@
}
/**
- */
- protected void clearContent() {
- this.content.clear();
- }
-
- /**
- */
- protected void setContent( ConcreteElement content ) {
- this.setContent( content,
- CapabilityMapFactory.getDefaultCapabilityMap() );
- }
-
- /**
- */
- protected void setContent( String content ) {
- this.setContent( new ClearElement( content ),
- CapabilityMapFactory.getDefaultCapabilityMap() );
- }
-
- /**
- */
- protected void setContent( ConcreteElement content,
- CapabilityMap map )
- throws IllegalArgumentException
- {
- CapabilityMap mymap = map;
- if ( mymap == null ) {
- mymap = CapabilityMapFactory.getDefaultCapabilityMap();
- }
-
- ConcreteElement buffer = new ClearElement( content.toString( ) );
- this.content.put( mymap.toString(), buffer );
- }
-
-
- /**
- Provide a description within PML if the user has specified one.
-
- @return a null entry if the user hasn't defined anything
- */
+ * Provide a description within PML if the user has specified one.
+ *
+ * @return a null entry if the user hasn't defined anything
+ */
public String getDescription() {
if (getPortletConfig()!=null)
if (getPortletConfig().getMetainfo()!=null)
@@ -380,7 +439,7 @@
}
/**
- */
+ */
public void setDescription( String description ) {
PortletConfig pc = getPortletConfig();
if (pc==null) {
@@ -400,10 +459,10 @@
//provide default titles so that the user can define them in PML
/**
- Provide a title within PML if the user has specified one.
-
- @return a null entry if the user hasn't defined anything
- */
+ * Provide a title within PML if the user has specified one.
+ *
+ * @return a null entry if the user hasn't defined anything
+ */
public String getTitle() {
if (getPortletConfig()!=null)
if (getPortletConfig().getMetainfo()!=null)
@@ -413,8 +472,9 @@
}
/**
- Set the title for this Portlet
- */
+ * Set the title for this Portlet.
+ * @param title Portlet title.
+ */
public void setTitle( String title ) {
PortletConfig pc = getPortletConfig();
if (pc==null) {
@@ -433,22 +493,30 @@
/**
- */
+ * Is the portled editable/customizeable.
+ * @param rundata The RunData object for the current request
+ * @return <CODE>true</CODE> Editing is allow
+ * <CODE>false</CODE> Editing is NOT alowed
+ */
public boolean getAllowEdit( RunData rundata )
{
return allowInfo( rundata );
}
/**
- */
+ * Can this portlet be maximized
+ * @param rundata The RunData object for the current request
+ * @return <CODE>true</CODE> Portlet can be maximized<br>
+ * <CODE>false</CODE> Portlet can NOT be maximized
+ */
public boolean getAllowMaximize( RunData rundata )
{
return allowMaximize( rundata );
}
/**
- By default don't provide any initialization
- */
+ * By default don't provide any initialization
+ */
public void init( ) throws PortletException
{
// make sure to clean all content
@@ -456,22 +524,19 @@
}
/**
- @see Portlet#getCreationTime
- */
+ */
public long getCreationTime() {
return this.creationTime;
}
/**
- @see Portlet#setCreationTime
- */
+ */
public void setCreationTime( long creationTime ) {
this.creationTime = creationTime;
}
/**
- @see Portlet#supportsType
- */
+ */
public boolean supportsType( MimeType mimeType )
{
PortletEntry entry = (PortletEntry)Registry.getEntry(Registry.PORTLET,
getName() );
@@ -494,13 +559,15 @@
return MimeType.HTML.equals( mimeType );
}
- // PortletState Interface implementation
-
+ /*
+ * Implement methods required by PortletState
+ */
+
/**
* Implements the default close behavior: any authenticated user may
* remove a portlet from his page
*
- * @param rundata the RunData object for the current request
+ * @param rundata The RunData object for the current request
*/
public boolean allowClose( RunData rundata )
{
@@ -516,6 +583,8 @@
/**
* Returns true if this portlet is currently closed
+ *
+ * @param rundata The RunData object for the current request
*/
public boolean isClosed(RunData rundata)
{
@@ -526,7 +595,7 @@
* Toggles the portlet state between closed and normal
*
* @param minimized the new portlet state
- * @param data the RunData for this request
+ * @param rundata The RunData object for the current request
*/
public void setClosed(boolean close, RunData rundata)
{
@@ -540,7 +609,7 @@
* Implements the default info behavior: any authenticated user may
* get information on a portlet
*
- * @param rundata the RunData object for the current request
+ * @param rundata The RunData object for the current request
*/
public boolean allowInfo( RunData rundata )
{
@@ -557,7 +626,7 @@
* Implements the default customize behavior: any authenticated user may
* customize a portlet
*
- * @param rundata the RunData object for the current request
+ * @param rundata The RunData object for the current request
*/
public boolean allowCustomize( RunData rundata )
{
@@ -574,7 +643,7 @@
* Implements the default maximize behavior: any authenticated user may
* maximize a portlet
*
- * @param rundata the RunData object for the current request
+ * @param rundata The RunData object for the current request
*/
public boolean allowMaximize( RunData rundata )
{
@@ -591,7 +660,7 @@
* Implements the default info behavior: any authenticated user may
* minimize a portlet
*
- * @param rundata the RunData object for the current request
+ * @param rundata The RunData object for the current request
*/
public boolean allowMinimize( RunData rundata )
{
@@ -607,6 +676,8 @@
/**
* Returns true if this portlet is currently minimized
+ *
+ * @param rundata The RunData object for the current request
*/
public boolean isMinimized(RunData rundata)
{
@@ -614,11 +685,11 @@
}
/**
- Change the portlet visibility state ( minimized <-> normal )
-
- @param minimize True if the portlet change to minimized
- @param rundata A RunData object
- */
+ * Change the portlet visibility state ( minimized <-> normal )
+ *
+ * @param minimize True if the portlet change to minimized
+ * @param rundata The RunData object for the current request
+ */
public void setMinimized( boolean minimize, RunData rundata )
{
if( allowMinimize( rundata ) )
@@ -628,11 +699,11 @@
}
/**
- Returns TRUE if the title bar in should be displayed. The title bar includes
- the portlet title and action buttons. This
-
- @param rundata A RunData object
- */
+ * Returns TRUE if the title bar in should be displayed. The title bar includes
+ * the portlet title and action buttons. This
+ *
+ * @param rundata The RunData object for the current request
+ */
public boolean isShowTitleBar(RunData rundata)
{
if (getPortletConfig()!=null)
@@ -645,13 +716,13 @@
// 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
- */
+ * Retrieve a portlet attribute from persistent storage
+ *
+ * @param attrName The attribute to retrieve
+ * @param attrDefValue The value if the attr doesn't exists
+ * @param rundata The RunData object for the current request
+ * @return The attribute value
+ */
public String getAttribute( String attrName, String attrDefValue, RunData
rundata )
{
String attrValue = null ;
@@ -681,12 +752,12 @@
}
/**
- 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
- */
+ * A way to store a portlet attribute in persistent storage
+ *
+ * @param attrName The attribute to retrieve
+ * @paarm attrValue The value to store
+ * @param rundata The RunData object for the current request
+ */
public void setAttribute( String attrName, String attrValue, RunData rundata )
{
try
@@ -708,5 +779,5 @@
Log.error("Exception while setting attribute "+attrName+" for portlet
"+getName(),e);
}
}
-
+
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>