raphael 2002/11/07 12:22:45
Modified: src/java/org/apache/jetspeed/portal/controllers
AbstractPortletController.java
src/java/org/apache/jetspeed/portal/portlets
AbstractPortlet.java LinkPortlet.java
NewRSSPortlet.java XSLPortlet.java
Log:
Convert calls to CapabilityMapFactory to JetspeedRunData.getCapability()
Revision Changes Path
1.22 +22 -21
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controllers/AbstractPortletController.java
Index: AbstractPortletController.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controllers/AbstractPortletController.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- AbstractPortletController.java 10 Sep 2001 22:41:00 -0000 1.21
+++ AbstractPortletController.java 7 Nov 2002 20:22:45 -0000 1.22
@@ -57,7 +57,8 @@
//jetspeed support
import org.apache.jetspeed.portal.*;
import org.apache.jetspeed.portal.expire.*;
-import org.apache.jetspeed.capability.*;
+import org.apache.jetspeed.capability.CapabilityMap;
+import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.util.*;
import org.apache.jetspeed.services.Registry;
import org.apache.jetspeed.om.registry.PortletControllerEntry;
@@ -139,14 +140,14 @@
*/
public int getPadding() {
int padding = 0;
-
+
try {
PortletConfig conf = getPortlets().getPortletConfig();
padding = Integer.parseInt( conf.getSkin( "padding" , String.valueOf(
DEFAULT_PADDING ) ) );
} catch ( RuntimeException e ) {
padding = DEFAULT_PADDING;
}
-
+
return padding;
}
@@ -160,7 +161,7 @@
} catch ( RuntimeException e ) {
// FIXME: What should we do if there's no portlets, config or skin
defined ?
}
-
+
}
/**
@@ -182,14 +183,14 @@
// no specific init
}
-
+
/**
@see Portlet#supportsType
*/
public boolean supportsType( MimeType mimeType )
{
// we now need to check that the control also supports the type...
- PortletControllerEntry entry =
+ PortletControllerEntry entry =
(PortletControllerEntry)Registry.getEntry(Registry.PORTLET_CONTROLLER,
getConfig().getName() );
String baseType = mimeType.toString();
@@ -197,7 +198,7 @@
if (entry!=null)
{
Iterator i = entry.listMediaTypes();
-
+
while(i.hasNext())
{
String name = (String)i.next();
@@ -205,14 +206,14 @@
if (media != null)
{
- if (baseType.equals(media.getMimeType()))
+ if (baseType.equals(media.getMimeType()))
{
return true;
}
}
}
}
-
+
return false;
}
@@ -220,9 +221,9 @@
*/
public ConcreteElement getContent( RunData rundata )
{
-
- CapabilityMap map = CapabilityMapFactory.getCapabilityMap( rundata );
- ConcreteElement content = null;
+
+ CapabilityMap map = ((JetspeedRunData)rundata).getCapability();
+ ConcreteElement content = null;
if ( MimeType.WML.equals( map.getPreferredType() ) )
{
@@ -237,31 +238,31 @@
// we don't know how to handle this type, maybe a subclass knows
content = getContent( portlets, rundata );
}
-
+
return content;
}
/**
*/
protected ConcreteElement getContent( PortletSet set, RunData data )
- {
+ {
return new ElementContainer();
}
/**
*/
protected ConcreteElement getWMLContent( PortletSet set, RunData data )
- {
+ {
return new ElementContainer();
}
/**
*/
protected ConcreteElement getHTMLContent( PortletSet set, RunData data )
- {
+ {
return new ElementContainer();
}
-
+
/**
* Creates a constraint object based on an original map source.
*
@@ -270,9 +271,9 @@
*/
public PortletSet.Constraints getConstraints( Map original )
{
- PortletSet.Constraints constraints = new BasePortletSetConstraints();
- if (original != null) constraints.putAll(original);
+ PortletSet.Constraints constraints = new BasePortletSetConstraints();
+ if (original != null) constraints.putAll(original);
return constraints;
}
-
+
}
1.60 +38 -37
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.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- AbstractPortlet.java 27 Sep 2002 19:54:26 -0000 1.59
+++ AbstractPortlet.java 7 Nov 2002 20:22:45 -0000 1.60
@@ -67,6 +67,7 @@
import org.apache.jetspeed.portal.PortletConfig;
import org.apache.jetspeed.portal.PortletException;
import org.apache.jetspeed.portal.PortletState;
+import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.services.persistence.PersistenceManager;
import org.apache.jetspeed.services.persistence.PortalPersistenceException;
import org.apache.jetspeed.portal.PortletInstance;
@@ -101,7 +102,7 @@
PERFORMANCE NOTE:
getContent returns a StringElement that was generated on setContent(). This is
-used so that performance is increased since ECS does not have to work overtime
+used so that performance is increased since ECS does not have to work overtime
to generate output.
</p>
@@ -140,7 +141,7 @@
private Long expirationMillis = null;
/**
- Holds instances of ConcreteElements (Portlet output/content)
+ Holds instances of ConcreteElements (Portlet output/content)
based on its current CapabilityMap.
*/
protected Hashtable content = new Hashtable();
@@ -149,12 +150,12 @@
The time this portlet was created.
*/
private long creationTime;
-
+
/**
* Handle to cached object
*/
private CachedObject cachedObject = null;
-
+
/**
*/
protected void clearContent() {
@@ -177,8 +178,8 @@
/**
*/
- protected void setContent( ConcreteElement content,
- CapabilityMap map )
+ protected void setContent( ConcreteElement content,
+ CapabilityMap map )
throws IllegalArgumentException
{
CapabilityMap mymap = map;
@@ -197,7 +198,7 @@
/**
* Usually called by caching system when portlet is marked as expired, but
- * has not be idle longer then TimeToLive.
+ * has not be idle longer then TimeToLive.
*
* This method should be implement in cachable portlets
*/
@@ -283,7 +284,7 @@
public Long getExpirationMillis() {
return this.expirationMillis;
}
-
+
/**
* Sets the cache expiration time. When the portlet is stale (expired),
* the refresh() will be called if the portlet has not been untouched
@@ -293,7 +294,7 @@
*/
public void setExpirationMillis( long expirationMillis) {
this.expirationMillis = new Long(expirationMillis);
-
+
if (cachedObject != null) {
long expirationInterval = this.expirationMillis.longValue() -
cachedObject.getCreated();
if (expirationInterval > 0) {
@@ -304,7 +305,7 @@
}
}
- /**
+ /**
* Builds a new cache handle for this cacheable class with the specified
* config object.
*
@@ -315,21 +316,21 @@
public static Object getHandle(Object config)
{
//this implementation expects a PortletConfig object as its
- // configuration
+ // configuration
PortletConfig pc = null;
if (!(config instanceof PortletConfig))
{
return null;
-
+
}
- // By default, only take into account the init parameters
+ // By default, only take into account the init parameters
pc = (PortletConfig)config;
StringBuffer handle = new StringBuffer(256);
if (pc.getURL()!=null && pc.isCachedOnURL())
- {
+ {
handle.append(String.valueOf(pc.getURL().hashCode()));
}
@@ -338,16 +339,16 @@
{
String name = (String)i.next();
String value = pc.getInitParameter(name);
-
+
if (value!=null)
{
handle.append("|").append(name).append("-").append(value);
}
}
- return handle.toString();
+ return handle.toString();
}
-
+
/**
* Set this portlet's cached object.
*
@@ -356,7 +357,7 @@
public void setCachedObject(CachedObject cachedObject) {
this.cachedObject = cachedObject;
}
-
+
/*
* Implement methods required by Portlet
*/
@@ -406,7 +407,7 @@
return this.pc;
}
- /**
+ /**
* Set's the configuration of this servlet.
*/
public void setPortletConfig( PortletConfig pc ) {
@@ -424,22 +425,22 @@
public ConcreteElement getContent( RunData rundata, CapabilityMap map ) {
CapabilityMap mymap = map;
if ( mymap == null ) mymap = CapabilityMapFactory.getCapabilityMap( rundata
);
-
+
return (ConcreteElement)content.get( mymap.toString() );
}
-
+
/**
* @param rundata The RunData object for the current request
*/
public ConcreteElement getContent( RunData rundata,
- CapabilityMap map,
+ CapabilityMap map,
boolean allowRecurse ) {
CapabilityMap mymap = map;
if ( mymap == null ) mymap = CapabilityMapFactory.getCapabilityMap( rundata
);
ConcreteElement element = (ConcreteElement)content.get( mymap.toString() );
-
+
if ( element == null ) {
if ( allowRecurse ) {
try {
@@ -464,7 +465,7 @@
}
}
}
-
+
return element;
}
@@ -527,7 +528,7 @@
return null;
}
-
+
/**
* Provide a title within PML if the user has specified one.
*
@@ -584,7 +585,7 @@
return instanceImage;
return getImage();
}
-
+
public void setImage( String image )
{
PortletConfig pc = getPortletConfig();
@@ -627,7 +628,7 @@
/**
* By default don't provide any initialization
*/
- public void init( ) throws PortletException
+ public void init( ) throws PortletException
{
// make sure to clean all content
clearContent();
@@ -638,13 +639,13 @@
public long getCreationTime() {
return this.creationTime;
}
-
+
/**
*/
public void setCreationTime( long creationTime ) {
this.creationTime = creationTime;
}
-
+
/**
*/
public boolean supportsType( MimeType mimeType )
@@ -668,7 +669,7 @@
return MimeType.HTML.equals( mimeType );
}
-
+
/*
* Implement methods required by PortletState
*/
@@ -711,7 +712,7 @@
}
/**
- * Implements the default info behavior:
+ * Implements the default info behavior:
* security permissions will be checked.
*
* @param rundata The RunData object for the current request
@@ -724,7 +725,7 @@
}
/**
- * Implements the default customize behavior:
+ * Implements the default customize behavior:
* security permissions will be checked.
*
* @param rundata The RunData object for the current request
@@ -763,7 +764,7 @@
}
/**
- * Implements the default print friendly format behavior:
+ * Implements the default print friendly format behavior:
* security permissions will be checked.
*
* @param rundata The RunData object for the current request
@@ -807,7 +808,7 @@
*/
public boolean isShowTitleBar(RunData rundata)
{
- if (getPortletConfig()!=null)
+ if (getPortletConfig()!=null)
{
// Parameter can exist in PSML or <portlet-entry>
return
Boolean.valueOf(getPortletConfig().getInitParameter("_showtitlebar","true")).booleanValue();
@@ -815,7 +816,7 @@
return this.getAttribute("_showtitlebar", "true", rundata ).equals("true");
}
// utility methods
-
+
/**
* Retrieve a portlet attribute from persistent storage
*
@@ -886,5 +887,5 @@
{
return false;
}
-
+
}
1.4 +17 -16
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/LinkPortlet.java
Index: LinkPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/LinkPortlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LinkPortlet.java 27 Sep 2002 19:54:26 -0000 1.3
+++ LinkPortlet.java 7 Nov 2002 20:22:45 -0000 1.4
@@ -61,17 +61,18 @@
* redering for wml is done in by the /wml/column.vm file
* @author <a href="mailto:A.Kempf@;web.de">Andreas Kempf</a>
*/
-import org.apache.jetspeed.capability.*;
+import org.apache.jetspeed.capability.CapabilityMap;
import org.apache.jetspeed.util.MimeType;
import org.apache.jetspeed.services.resources.JetspeedResources;
+import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.ecs.*;
import org.apache.turbine.util.RunData;
-public class LinkPortlet extends AbstractPortlet
+public class LinkPortlet extends AbstractPortlet
{
- // Define parameter name for a image
+ // Define parameter name for a image
public static final String L_IMAGE = "image";
// Define parameter name for the link name
public static final String L_NAME = "anchor";
@@ -89,10 +90,10 @@
* @return org.apache.ecs.ConcreteElement
* @param data org.apache.turbine.util.RunData
*/
-public org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData
data)
+public org.apache.ecs.ConcreteElement getContent(org.apache.turbine.util.RunData
data)
{
- CapabilityMap cap = CapabilityMapFactory.getCapabilityMap(data);
+ CapabilityMap cap = ((JetspeedRunData)data).getCapability();
// only for HTML mimetype!!!
if (cap.getPreferredType().equals(MimeType.HTML))
@@ -110,9 +111,9 @@
{
if (i>0)
cstr=String.valueOf(i);
-
+
link = getPortletConfig().getInitParameter(L_URL+cstr);
-
+
// Link available?
if ((link!=null) && (link.length()>0))
{
@@ -128,7 +129,7 @@
// set description
if ((desc==null) || (desc.length()<1))
desc = "follow this link";
-
+
// add new entry
res += "<li>";
@@ -137,34 +138,34 @@
// add link
res += "<A HREF=\""+link+"\">";
-
+
// add image
if ((image != null) && (image.length()>0))
res += " <IMG SRC=\"images/html/"+image+"\" HSPACES=\"5\"
ALT=\""+name+"\" BORDER=\"0\"> ";
- // add name and description
+ // add name and description
res += name+"</A> <SMALL>"+desc+"</SMALL></li>";
contains++;
}
else
link = null;
-
- i++;
+
+ i++;
}
while (link != null);
{
}
-
+
// close list
if (contains > 0)
- res += "</ul>";
+ res += "</ul>";
return(new StringElement(res));
}
-
- return new org.apache.jetspeed.util.JetspeedClearElement( " " );
+
+ return new org.apache.jetspeed.util.JetspeedClearElement( " " );
}
}
1.17 +50 -48
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/NewRSSPortlet.java
Index: NewRSSPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/NewRSSPortlet.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- NewRSSPortlet.java 27 Sep 2002 19:54:26 -0000 1.16
+++ NewRSSPortlet.java 7 Nov 2002 20:22:45 -0000 1.17
@@ -67,7 +67,9 @@
import org.apache.jetspeed.cache.disk.*;
import org.apache.jetspeed.portal.*;
import org.apache.jetspeed.xml.JetspeedXMLEntityResolver;
-import org.apache.jetspeed.capability.*;
+import org.apache.jetspeed.capability.CapabilityMap;
+import org.apache.jetspeed.capability.CapabilityMapFactory;
+import org.apache.jetspeed.services.rundata.JetspeedRunData;
//turbine
import org.apache.turbine.util.*;
@@ -98,26 +100,26 @@
is only used for this mime-type</dd>
</dl>
@author <A HREF="mailto:raphael@;apache.org">Rapha�l Luta</A>
-@version $Id$
+@version $Id$
*/
public class NewRSSPortlet extends FileWatchPortlet {
-
+
public final static String ERROR_NOT_VALID = "This does not appear to be an RSS
document";
public final static String INVALID_TYPE = "Unable to display for this browser";
-
- private Document document = null;
+
+ private Document document = null;
private Hashtable stylesheets = null;
private Hashtable params = null;
/**
- This method loads the init parameters and
+ This method loads the init parameters and
parse the document tied to this portlet
*/
public void init( ) throws PortletException {
-
+
// first make sure we propagate init
super.init();
-
+
DocumentBuilder parser = null;
String url = null;
@@ -141,7 +143,7 @@
}
// read content, clean it, parse it and cache the DOM
- try
+ try
{
final DocumentBuilderFactory docfactory =
DocumentBuilderFactory.newInstance();
//Have it non-validating
@@ -151,18 +153,18 @@
url = getPortletConfig().getURL();
String content = JetspeedDiskCache.getInstance().getEntry( url
).getData();
- CapabilityMap xmap =
+ CapabilityMap xmap =
CapabilityMapFactory.getCapabilityMap(CapabilityMapFactory.AGENT_XML);
- setContent( new JetspeedClearElement(content), xmap );
+ setContent( new JetspeedClearElement(content), xmap );
InputSource isrc = new InputSource( this.cleanse( content ) );
isrc.setSystemId( url );
isrc.setEncoding("UTF-8");
this.document = parser.parse( isrc );
-
+
} catch ( Throwable t )
{
- String message = "RSSPortlet: Couldn't parse out XML document -> " +
+ String message = "RSSPortlet: Couldn't parse out XML document -> " +
url;
Log.error( message, t );
@@ -172,46 +174,46 @@
//Determine title and description for this portlet
String title = null;
String description = null;
-
+
//now find the channel node.
Node channel = null;
-
+
NodeList list = document.getElementsByTagName( "channel" );
-
+
if ( list.getLength() != 1 ) {
- throw new PortletException( ERROR_NOT_VALID );
+ throw new PortletException( ERROR_NOT_VALID );
}
-
+
channel = list.item( 0 );
-
+
Node tn = getNode( channel, "title" );
-
+
if ( tn == null ) {
throw new PortletException( ERROR_NOT_VALID );
} else {
title = tn.getFirstChild().getNodeValue();
}
-
+
Node dn = getNode( channel, "description" );
-
+
if ( dn != null ) {
description = dn.getFirstChild().getNodeValue();
- }
+ }
this.setTitle( title );
this.setDescription( description );
-
+
}
/**
- This methods outputs the content of the portlet for a given
+ This methods outputs the content of the portlet for a given
request.
@param data the RunData object for the request
@return the content to be displayed to the user-agent
*/
public ConcreteElement getContent( RunData data ) {
- CapabilityMap map = CapabilityMapFactory.getCapabilityMap( data );
+ CapabilityMap map = ((JetspeedRunData)data).getCapability();
String type = map.getPreferredType().toString();
ConcreteElement content = new JetspeedClearElement(INVALID_TYPE);
String stylesheet = (String)stylesheets.get(type);
@@ -220,7 +222,7 @@
content = getContent( data, map );
if ( content == null ) {
try {
- content = new JetspeedClearElement(
+ content = new JetspeedClearElement(
SimpleTransform.transform( this.document,
stylesheet,
this.params ) );
@@ -241,81 +243,81 @@
return content;
}
-
+
/**
This portlet supports has many types as those
it has stylesheets defined for in its parameters
-
+
@see Portlet#supportsType
@param mimeType the MIME type queried
@return true if the portlet knows how to display
content for mimeType
*/
public boolean supportsType( MimeType mimeType ) {
-
+
Enumeration en = stylesheets.keys();
while(en.hasMoreElements()) {
String type = (String)en.nextElement();
if (type.equals(mimeType.toString())) return true;
}
-
+
return false;
}
/**
Utility method for traversing the document parsed
DOM tree and retrieving a Node by tagname
-
+
@param start the parent node for the search
@param name the tag name to be searched for
- @return the first child node of start whose tagname
+ @return the first child node of start whose tagname
is name
- */
+ */
private final Node getNode( Node start, String name ) {
-
+
NodeList list = start.getChildNodes();
-
+
for ( int i = 0; i < list.getLength(); ++i ) {
Node node = list.item( i );
-
+
if ( node.getNodeName().equals( name ) ) {
return node;
}
}
return null;
}
-
+
/**
- Given a URL to some content, clean the content to Xerces can handle it
+ Given a URL to some content, clean the content to Xerces can handle it
better. Right now this involves:
<ul>
<li>
- If the document doesn't begin with "<?xml version=" truncate the
+ If the document doesn't begin with "<?xml version=" truncate the
content until this is the first line
</li>
</ul>
-
+
*/
private Reader cleanse( String content ) throws IOException {
-
+
String filtered = null;
-
+
//specify the XML declaration to search for... this is just a subset
//of the content but it will always exist.
String XMLDECL = "<?xml version=";
-
+
int start = content.indexOf( XMLDECL );
-
+
if ( start <= 0 ) {
filtered = content;
} else {
filtered = content.substring( start, content.length() );
}
-
+
return new StringReader( filtered );
- }
-
+ }
+
}
1.8 +19 -18
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/XSLPortlet.java
Index: XSLPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/XSLPortlet.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XSLPortlet.java 27 Sep 2002 19:54:26 -0000 1.7
+++ XSLPortlet.java 7 Nov 2002 20:22:45 -0000 1.8
@@ -66,7 +66,8 @@
import org.apache.jetspeed.util.*;
import org.apache.jetspeed.cache.disk.*;
import org.apache.jetspeed.portal.*;
-import org.apache.jetspeed.capability.*;
+import org.apache.jetspeed.capability.CapabilityMap;
+import org.apache.jetspeed.services.rundata.JetspeedRunData;
//turbine
import org.apache.turbine.util.*;
@@ -75,14 +76,14 @@
import org.xml.sax.*;
/**
-Simple portlet which does a basic XSLT transform with the stylesheet parameter
+Simple portlet which does a basic XSLT transform with the stylesheet parameter
and the given portlet URL.
@author <A HREF="mailto:raphael@;apache.org">Rapha�l Luta</A>
@version $Id$
*/
public class XSLPortlet extends AbstractPortlet {
-
+
/**
The stylesheet parameter
*/
@@ -90,14 +91,14 @@
public final static String ERROR_NOT_VALID = "This does not appear to be an RSS
document";
public final static String INVALID_TYPE = "Unable to display for this browser";
-
+
private Hashtable stylesheets = null;
/**
This method loads the init parameters
*/
public void init() throws PortletException {
-
+
stylesheets = new Hashtable();
Iterator en = this.getPortletConfig().getInitParameterNames();
while (en.hasNext()) {
@@ -110,19 +111,19 @@
}
stylesheets.put(base,this.getPortletConfig().getInitParameter(name));
}
- }
+ }
}
-
+
/**
- This methods outputs the content of the portlet for a given
+ This methods outputs the content of the portlet for a given
request.
@param data the RunData object for the request
@return the content to be displayed to the user-agent
*/
public ConcreteElement getContent( RunData data ) {
- CapabilityMap map = CapabilityMapFactory.getCapabilityMap( data );
+ CapabilityMap map = ((JetspeedRunData)data).getCapability();
String type = map.getPreferredType().toString();
ConcreteElement content = new JetspeedClearElement(INVALID_TYPE);
String stylesheet = (String)stylesheets.get(type);
@@ -131,8 +132,8 @@
content = getContent( data, map );
if ( content == null ) {
try {
- content = new JetspeedClearElement(
- SimpleTransform.transform( getPortletConfig().getURL(),
+ content = new JetspeedClearElement(
+ SimpleTransform.transform( getPortletConfig().getURL(),
stylesheet,
getPortletConfig().getInitParameters() ) );
setContent( content, map );
@@ -142,28 +143,28 @@
}
}
}
-
+
return content;
}
-
+
/**
This portlet supports has many types as those
it has stylesheets defined for in its parameters
-
+
@see Portlet#supportsType
@param mimeType the MIME type queried
@return true if the portlet knows how to display
content for mimeType
*/
public boolean supportsType( MimeType mimeType ) {
-
+
Enumeration en = stylesheets.keys();
while(en.hasMoreElements()) {
String type = (String)en.nextElement();
if (type.equals(mimeType.toString())) return true;
}
-
+
return false;
}
-
+
}
--
To unsubscribe, e-mail: <mailto:jetspeed-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@;jakarta.apache.org>