1 16 17 package org.apache.jetspeed.portal.portlets; 18 19 import java.io.ByteArrayOutputStream ; 20 import java.io.PrintWriter ; 21 22 import org.apache.ecs.html.Comment; 23 import org.apache.ecs.ConcreteElement; 24 import org.apache.ecs.StringElement; 25 import org.apache.ecs.ElementContainer; 26 27 import org.apache.jetspeed.cache.disk.JetspeedDiskCache; 28 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService; 29 import org.apache.jetspeed.services.logging.JetspeedLogger; 30 import org.apache.jetspeed.util.SAXPIFilter; 31 32 import org.apache.turbine.util.RunData; 33 34 35 43 public class XMLPortlet extends AbstractPortlet 44 { 45 48 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(XMLPortlet.class.getName()); 49 50 53 public ConcreteElement getContent( RunData rundata ) { 54 55 String myContent = null; 56 57 ElementContainer content = new ElementContainer(); 58 59 try { 61 62 ByteArrayOutputStream bos= new ByteArrayOutputStream (); 63 64 String url = JetspeedDiskCache.getInstance().getEntry( getPortletConfig().getURL() ).getURL(); 65 66 new SAXPIFilter(new PrintWriter (bos),true).print( url ); 67 myContent = bos.toString(); 68 69 } catch (Exception e) { 70 71 72 logger.error( "Could not parse the following URL: " + this.getPortletConfig().getURL(), e ); 73 return content; 74 } 75 76 if (myContent!=null) { 78 content = new ElementContainer(); 79 80 content.addElement( new Comment( "BEGIN PORTLET" ) ); 81 content.addElement( new StringElement( myContent ) ); 82 content.addElement( new Comment( "END PORTLET" ) ); 83 } 84 85 return content; 86 } 87 88 92 public ConcreteElement getContent(Object params, RunData rundata) { 93 return getContent( rundata ); 94 } 95 96 97 } 98 | Popular Tags |