String message = "RSSPortlet: Couldn't parse out XML document -> " +
url;
logger.error( message, t );
throw new PortletException( t.getMessage() );
}
//SGP giving NullPointer
try {
//now that we have the document set the items for this
this.setItems( this.parseItems( document ) );
String title = null;
String description = null;
//this a hack until DOM2 namespace support becomes better in Xerces.
Node root = document.getFirstChild();
//now find the channel node.
Node channel = null;
NodeList list = document.getElementsByTagName( "channel" );
if ( list.getLength() != 1 ) {
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 );
//now that we have the DOM we should be able to do a transform here.
String stylesheet = this.getPortletConfig().getInitParameter( "stylesheet" );
if ( stylesheet == null ) {
throw new PortletException( "The 'stylesheet' parameter was not defined." );
}
try {
//Set encoding for the document to utf-8...
String content = SimpleTransform.transform( document,
stylesheet,
this.getPortletConfig().getInitParameters() );
this.setContent( new JetspeedClearElement( content ) );
} catch ( SAXException e ) {
logger.error("Exception", e);
throw new PortletException( e.getMessage() );
}
} catch (Throwable t) {
String message = "RSSPortlet: Couldn't set items for XML document -> " +
url;
logger.error( message, t );
throw new PortletException( t.getMessage() );
}
}