1 16 17 package org.apache.jetspeed.portal.portlets; 18 19 20 import org.apache.jetspeed.portal.*; 22 import org.apache.jetspeed.util.*; 23 import org.apache.jetspeed.cache.disk.*; 24 25 import java.io.*; 27 28 35 public class FileServerPortlet extends FileWatchPortlet { 36 37 39 public void init() throws PortletException { 40 41 super.init(); 43 44 PortletConfig config = this.getPortletConfig(); 45 46 48 try { 49 50 this.setContent( new JetspeedClearElement( this.getURL( this.getPortletConfig().getURL() ) ) ); 51 52 } catch (Exception e) { 53 throw new PortletException( e.getMessage() ); 54 } 55 56 57 } 58 59 61 private String getURL(String url) throws IOException { 62 63 int CAPACITY = 1024; 64 65 Reader rdr = JetspeedDiskCache.getInstance() 66 .getEntry( url ).getReader(); 67 StringBuffer buffer = new StringBuffer (); 68 69 char[] chars = new char[CAPACITY]; 71 72 int readCount = 0; 73 while( ( readCount = rdr.read( chars )) > 0 ) { 74 75 buffer.append( chars, 0, readCount); 76 } 77 78 rdr.close(); 79 80 81 return buffer.toString(); 82 83 84 } 85 86 } 87 | Popular Tags |