TransformException without specified detail
- * message.
- */
- public TransformException()
- {
- }
-
- /**
- * Constructs a new TransformException with specified detail
- * message.
- *
- * @param msg the error message.
- */
- public TransformException(String msg)
- {
- super(msg);
- }
-
- /**
- * Constructs a new TransformException with specified nested
- * Throwable.
- *
- * @param nested the exception or error that caused this exception
- * to be thrown.
- */
- public TransformException(Throwable nested)
- {
- super(nested);
- }
-
- /**
- * Constructs a new TransformException with specified detail
- * message and nested Throwable.
- *
- * @param msg the error message.
- * @param nested the exception or error that caused this exception
- * to be thrown.
- */
- public TransformException(String msg, Throwable nested)
- {
- super(msg, nested);
- }
-}
Index: src/java/org/apache/portals/applications/transform/TransformObjectPublisher.java
===================================================================
RCS file: src/java/org/apache/portals/applications/transform/TransformObjectPublisher.java
diff -N src/java/org/apache/portals/applications/transform/TransformObjectPublisher.java
--- src/java/org/apache/portals/applications/transform/TransformObjectPublisher.java 15 Nov 2004 06:06:41 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.applications.transform;
-
-import java.util.Observable;
-
-
-/**
- * Transform Object Publisher base implementation.
- *
- * The Transform Object Publisher notifies observers by publishing messages when
- * the transforms have been updated.
- *
- * @author David Sean Taylor
- * @version $Id: TransformObjectPublisher.java,v 1.1 2004/11/15 06:06:41 taylor Exp $
- */
-public class TransformObjectPublisher extends Observable
-{
- /**
- * Constructor
- *
- */
- public TransformObjectPublisher()
- {
- }
- /**
- * Notify all observers that object has changed.
- * @see java.util.Observable#notifyObservers(Object ob)
- * @param transform
- */
- public void publish(Transform transform)
- {
- setChanged();
- notifyObservers(transform);
- }
-
-
-
-}
Index: src/java/org/apache/portals/applications/transform/impl/JetspeedTransform.java
===================================================================
RCS file: src/java/org/apache/portals/applications/transform/impl/JetspeedTransform.java
diff -N src/java/org/apache/portals/applications/transform/impl/JetspeedTransform.java
--- src/java/org/apache/portals/applications/transform/impl/JetspeedTransform.java 15 Nov 2004 06:06:41 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,372 +0,0 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.applications.transform.impl;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.Templates;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TemplatesHandler;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.portals.applications.transform.Transform;
-import org.apache.portals.applications.transform.TransformException;
-import org.apache.portals.applications.transform.TransformObjectPublisher;
-import org.apache.portals.applications.util.Streams;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-/**
- * TransformComponent
- *
- * @author David Sean Taylor
- * @version $Id: JetspeedTransform.java,v 1.1 2004/11/15 06:06:41 taylor Exp $
- */
-public class JetspeedTransform implements Transform
-{
- public JetspeedTransform()
- {
- // TODO: make all JAX factories configurable
- synchronized (mutex)
- {
- if (transformerFactory == null)
- {
- System.setProperty(JAX_TRANSFORM_PROPERTY, jaxTransformFactoryProp);
- System.setProperty(JAX_SAX_PARSER_PROPERTY, jaxSaxFactoryProp);
- System.setProperty(JAX_DOM_PARSER_PROPERTY, jaxDomFactoryProp);
-
- TransformerFactory tFactory = TransformerFactory.newInstance();
- domFactory = DocumentBuilderFactory.newInstance();
- domFactory.setValidating(false);
- saxFactory = SAXParserFactory.newInstance();
- saxFactory.setValidating(false);
- //if (!tFactory.getFeature(SAXTransformerFactory.FEATURE)) { throw new TransformException(
- // "Invalid SAX Tranformer. Doesn't support SAX"); }
- transformerFactory = ((SAXTransformerFactory) tFactory);
- }
- }
-
- publisher = new TransformObjectPublisher();
- }
-
- private static DocumentBuilderFactory domFactory = null;
-
- private static SAXParserFactory saxFactory = null;
-
- private static SAXTransformerFactory transformerFactory = null;
-
- //
- // JAXP Service Configuration
- //
- private final static String CONFIG_JAX_FACTORY_SAX = "jax.factory.sax";
-
- private final static String jaxSaxFactoryProp = "org.apache.xerces.jaxp.SAXParserFactoryImpl";
-
- private final static String CONFIG_JAX_FACTORY_DOM = "jax.factory.dom";
-
- private final static String jaxDomFactoryProp = "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl";
-
- private final static String CONFIG_JAX_FACTORY_TRANSFORM = "jax.factory.transform";
-
- private final static String jaxTransformFactoryProp = "org.apache.xalan.processor.TransformerFactoryImpl";
-
- private final static Object mutex = new Object();
-
- //
- // JAXP System Wide Properties
- //
- private static final String JAX_TRANSFORM_PROPERTY = "javax.xml.transform.TransformerFactory";
-
- private static final String JAX_SAX_PARSER_PROPERTY = "javax.xml.parsers.SAXParserFactory";
-
- private static final String JAX_DOM_PARSER_PROPERTY = "javax.xml.parsers.DocumentBuilderFactory";
-
- // DTD Map
- static private Map dtds = new HashMap();
-
- private TransformObjectPublisher publisher = null;
-
- public void transform(String xslt, InputSource inputSource, OutputStream os, Map parameters)
- throws TransformException
- {
- if (xslt == null)
- {
- try
- { // if no stylesheet specified simply drain the stream
- Streams.drain(inputSource.getByteStream(), os);
- }
- catch (IOException e)
- {
- throw new TransformException(e);
- }
- }
- else
- {
- transformStream(xslt, inputSource, new StreamResult(os), parameters);
- }
- }
-
- public void transform(String xslt, InputSource inputSource, Writer writer, Map parameters)
- throws TransformException
- {
- if (xslt == null)
- {
- try
- { // if no stylesheet specified simply drain the stream
- Streams.drain(inputSource.getByteStream(), writer);
- }
- catch (IOException e)
- {
- throw new TransformException(e);
- }
- }
- else
- {
- transformStream(xslt, inputSource, new StreamResult(writer), parameters);
- }
- }
-
- private static void transformStream(String xslt, InputSource inputSource, StreamResult streamResult, Map parameters)
- throws TransformException
- {
- if (xslt == null) { throw new TransformException("Invalid Transform, no stylesheet set!"); }
-
- //
- // create a new document builder to load the XML file for transformation
- //
- DocumentBuilder docBuilder = null;
- try
- {
- docBuilder = domFactory.newDocumentBuilder();
- docBuilder.setEntityResolver(new TransformDTDEntityResolver(dtds));
-
- }
- catch (ParserConfigurationException e)
- {
- throw new TransformException("Failed to load JAX Document Builder: " + e.toString());
- }
-
- try
- {
- // Create a ContentHandler to handle parsing of the stylesheet.
- TemplatesHandler templatesHandler = transformerFactory.newTemplatesHandler();
-
- // Create an XMLReader and set its ContentHandler.
- XMLReader reader = XMLReaderFactory.createXMLReader();
- reader.setContentHandler(templatesHandler);
-
- // Set it to solve Entities via cache
- reader.setEntityResolver(new TransformDTDEntityResolver(dtds));
-
- //
- // Get the stylesheet's content from the deployment
- //
- java.io.FileInputStream is = new java.io.FileInputStream(xslt);
- InputStreamReader ssreader = new InputStreamReader(is);
-
- // Parse the stylesheet.
- final InputSource xstyle = new InputSource(ssreader);
- xstyle.setSystemId(xslt);
- reader.parse(xstyle);
-
- //Get the Templates object from the ContentHandler.
- Templates templates = templatesHandler.getTemplates();
-
- // Create a ContentHandler to handle parsing of the XML source.
- TransformerHandler handler = transformerFactory.newTransformerHandler(templates);
-
- // Reset the XMLReader's ContentHandler.
- reader.setContentHandler(handler);
-
- //
- // Parse the Document into a DOM tree
- //
- //
- org.w3c.dom.Document doc = docBuilder.parse(inputSource);
-
- // reader.setProperty("http://xml.org/sax/properties/lexical-handler",
- // handler);
-
- final Transformer processor = handler.getTransformer();
-
- //
- // Get the transform variables (parameters)
- //
- Iterator keys = parameters.keySet().iterator();
- while (keys.hasNext())
- {
- String name = (String) keys.next();
- String value = (String) parameters.get(name);
- processor.setParameter(name, value);
- }
-
- //
- // do the transformation now
- //
- processor.transform(new DOMSource(doc), streamResult);
-
- }
- catch (Exception e)
- {
- throw new TransformException("Error in Transformation: " + e.toString());
- }
- }
-
- private static void transformStream(String xslt, Document document, StreamResult streamResult, Map parameters)
- throws TransformException
- {
- if (xslt == null) { throw new TransformException("Invalid Transform, no stylesheet set!"); }
-
- synchronized (mutex)
- {
- if (transformerFactory == null)
- {
- System.setProperty(JAX_TRANSFORM_PROPERTY, jaxTransformFactoryProp);
- System.setProperty(JAX_SAX_PARSER_PROPERTY, jaxSaxFactoryProp);
- System.setProperty(JAX_DOM_PARSER_PROPERTY, jaxDomFactoryProp);
-
- TransformerFactory tFactory = TransformerFactory.newInstance();
- domFactory = DocumentBuilderFactory.newInstance();
- domFactory.setValidating(false);
- saxFactory = SAXParserFactory.newInstance();
- saxFactory.setValidating(false);
- if (!tFactory.getFeature(SAXTransformerFactory.FEATURE)) { throw new TransformException(
- "Invalid SAX Tranformer. Doesn't support SAX"); }
- transformerFactory = ((SAXTransformerFactory) tFactory);
- }
- }
-
- //
- // create a new document builder to load the XML file for transformation
- //
- DocumentBuilder docBuilder = null;
- try
- {
- docBuilder = domFactory.newDocumentBuilder();
- docBuilder.setEntityResolver(new TransformDTDEntityResolver(dtds));
-
- }
- catch (ParserConfigurationException e)
- {
- throw new TransformException("Failed to load JAX Document Builder: " + e.toString());
- }
-
- try
- {
- // Create a ContentHandler to handle parsing of the stylesheet.
- TemplatesHandler templatesHandler = transformerFactory.newTemplatesHandler();
-
- // Create an XMLReader and set its ContentHandler.
- XMLReader reader = XMLReaderFactory.createXMLReader();
- reader.setContentHandler(templatesHandler);
-
- // Set it to solve Entities via cache
- reader.setEntityResolver(new TransformDTDEntityResolver(dtds));
-
- //
- // Get the stylesheet's content from the deployment
- //
- java.io.FileInputStream is = new java.io.FileInputStream(xslt);
- InputStreamReader ssreader = new InputStreamReader(is);
-
- // Parse the stylesheet.
- final InputSource xstyle = new InputSource(ssreader);
- xstyle.setSystemId(xslt);
- reader.parse(xstyle);
-
- //Get the Templates object from the ContentHandler.
- Templates templates = templatesHandler.getTemplates();
-
- // Create a ContentHandler to handle parsing of the XML source.
- TransformerHandler handler = transformerFactory.newTransformerHandler(templates);
-
- // Reset the XMLReader's ContentHandler.
- reader.setContentHandler(handler);
-
- //
- // Parse the Document into a DOM tree
- //
- //
- // org.w3c.dom.Document doc = docBuilder.parse(inputSource);
-
- // reader.setProperty("http://xml.org/sax/properties/lexical-handler",
- // handler);
-
- final Transformer processor = handler.getTransformer();
-
- //
- // Get the transform variables (parameters)
- //
- Iterator keys = parameters.keySet().iterator();
- while (keys.hasNext())
- {
- String name = (String) keys.next();
- String value = (String) parameters.get(name);
- processor.setParameter(name, value);
- }
-
- //
- // do the transformation now
- //
- processor.transform(new DOMSource(document), streamResult);
-
- }
- catch (Exception e)
- {
- throw new TransformException("Error in Transformation: " + e.toString());
- }
-
- }
-
- public void transform(String xslt, Document document, OutputStream os, Map parameters)
- throws TransformException
- {
- if (xslt == null)
- {
- throw new TransformException("xslt is null");
- }
- else
- {
- transformStream(xslt, document, new StreamResult(os), parameters);
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.jetspeed.syndication.services.transform.TransformService#getPublisher()
- */
- public TransformObjectPublisher getPublisher()
- {
- return publisher;
- }
-
-
-}
\ No newline at end of file
Index: src/java/org/apache/portals/applications/transform/impl/MemoryTransformCache.java
===================================================================
RCS file: src/java/org/apache/portals/applications/transform/impl/MemoryTransformCache.java
diff -N src/java/org/apache/portals/applications/transform/impl/MemoryTransformCache.java
--- src/java/org/apache/portals/applications/transform/impl/MemoryTransformCache.java 15 Nov 2004 06:06:41 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,231 +0,0 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.applications.transform.impl;
-
-import java.util.Collections;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Observable;
-import java.util.TreeMap;
-
-import org.apache.portals.applications.transform.Transform;
-import org.apache.portals.applications.transform.TransformCache;
-import org.apache.portals.applications.transform.TransformCacheEntry;
-
-
-/**
- * TransformCacheComponent
- *
- * @author David Sean Taylor
- * @version $Id: MemoryTransformCache.java,v 1.1 2004/11/15 06:06:41 taylor Exp $
- */
-public class MemoryTransformCache implements TransformCache
-{
- private boolean debug = true;
- private int maxSize = 100;
- private int evictionPercentage = 10;
- private boolean enable = true;
-
- private Transform transform = null;
- private TreeMap cache = null;
- private Object lock = new Object();
-
- /**
- * Spring constructor injection
- *
- */
- public MemoryTransformCache(Transform transform, int maxSize, int evictionPercentage, boolean enable, boolean debug)
- {
- this.transform = transform;
- cache = new TreeMap();
- this.maxSize = maxSize;
- this.evictionPercentage = evictionPercentage;
-
- transform.getPublisher().addObserver(this);
- }
-
- public int getMaxSize()
- {
- return maxSize;
- }
-
- public void setMaxSize(int maxSize)
- {
- this.maxSize = maxSize;
- }
-
- public int getEvictionPercentage()
- {
- return this.evictionPercentage;
- }
-
- public boolean isEnabled()
- {
- return enable;
- }
-
- public void put(String key, Object document, long timeToLive)
- {
- TransformCacheEntry entry = new TransformCacheEntry(key, document, timeToLive);
- if (cache.size() > getMaxSize())
- {
- evict();
- }
- synchronized(lock)
- {
- cache.put(key, entry);
- }
- if (debug)
- {
- System.out.println("Transformed content put in cache! Transform: "
- + key);
- }
- }
-
- /**
- * The eviction policy will keep n items in the cache, and then start evicting
- * x items ordered-by least used first.
- * n = max size of cache
- * x = (eviction_percentage/100) * n
- *
- */
- protected void evict()
- {
- if (debug)
- {
- System.out.println("Calling evict... cacheSize: "+
- cache.size()+" maxSize: "+getMaxSize());
- }
- synchronized (lock)
- {
- if (this.getMaxSize() >= cache.size())
- {
- return;
- }
-
- List list = new LinkedList( cache.values());
- Collections.sort(list, this);
-
- int count = 0;
- int limit = (getMaxSize() * getEvictionPercentage())/100 ;
- if (limit <= 0) limit = 1;
-
- for (Iterator it = list.iterator(); it.hasNext(); )
- {
- if (count >= limit)
- {
- break;
- }
-
- TransformCacheEntry entry = (TransformCacheEntry) it.next();
- if (debug)
- {
- System.out.println("Evicting: "+ entry.getKey());
- }
- cache.remove(entry.getKey());
-
- count++;
- }
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.jetspeed.syndication.services.transform.TransformCacheService#remove(java.lang.String, java.lang.String)
- */
- public Object remove(String key)
- {
- TransformCacheEntry entry = (TransformCacheEntry)cache.get(key);
- if (entry == null)
- {
- return null;
- }
- synchronized(lock)
- {
- entry = (TransformCacheEntry)cache.remove(key);
- }
- return entry;
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.jetspeed.syndication.services.transform.TransformCacheService#get(java.lang.String, java.lang.String)
- */
- public TransformCacheEntry get(String key)
- {
- TransformCacheEntry entry = (TransformCacheEntry)cache.get(key);
- if (entry == null)
- {
- return null;
- }
- long now = new Date().getTime();
- long lifeTime = entry.getTimeToLive() * 1000;
- if ((entry.getLastAccessed() + lifeTime) < now)
- {
- return null; // expire it
- }
- if (debug)
- {
- System.out.println("Transformed content found in cache! Transform: "
- + key);
- }
- return entry;
- }
-
- public Object getDocument(String key)
- {
- TransformCacheEntry entry = (TransformCacheEntry)get(key);
- if (entry != null)
- {
- return entry.getDocument();
- }
- return null;
- }
-
- public int compare(Object o1, Object o2)
- {
- TransformCacheEntry e1 = (TransformCacheEntry)o1;
- TransformCacheEntry e2 = (TransformCacheEntry)o2;
- if (e1.getLastAccessed() < e2.getLastAccessed())
- {
- return -1;
- }
- else if (e1.getLastAccessed() == e2.getLastAccessed())
- {
- return 0;
- }
- return 1;
- }
-
- public String constructKey(String url, String stylesheet)
- {
- return url + ":" + stylesheet;
- }
-
- public void clearCache()
- {
- cache.clear();
- }
-
- public void update(Observable o, Object arg)
- {
- // TODO: write me
- }
-
-}
-
Index: src/java/org/apache/portals/applications/transform/impl/TransformDTDEntityResolver.java
===================================================================
RCS file: src/java/org/apache/portals/applications/transform/impl/TransformDTDEntityResolver.java
diff -N src/java/org/apache/portals/applications/transform/impl/TransformDTDEntityResolver.java
--- src/java/org/apache/portals/applications/transform/impl/TransformDTDEntityResolver.java 15 Nov 2004 06:06:41 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,87 +0,0 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.applications.transform.impl;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Map;
-
-import org.apache.portals.applications.util.Streams;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-
-/**
- * TransformDTDEntityResolver
- *
- * @author David Sean Taylor
- * @version $Id: TransformDTDEntityResolver.java,v 1.1 2004/11/15 06:06:41 taylor Exp $
- */
-public class TransformDTDEntityResolver implements EntityResolver
-{
- private Map dtds;
-
- public TransformDTDEntityResolver(Map dtds)
- {
- this.dtds = dtds;
- }
-
- /* (non-Javadoc)
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
- */
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException
- {
- try
- {
- // System.out.println("TSER: ( " + publicId + " Taking " + systemId + " from cache");
-
- byte[] dtd = (byte[])dtds.get(systemId);
- if (dtd == null)
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- URL url = new URL(systemId);
- Streams.drain(url.openStream(), baos);
- dtd = baos.toByteArray();
- synchronized(dtds)
- {
- dtds.put(systemId, dtd);
- }
- }
-
- if (dtd != null)
- {
- ByteArrayInputStream bais = new ByteArrayInputStream(dtd);
- InputSource is = new InputSource(bais);
- is.setPublicId( publicId );
- is.setSystemId( systemId );
-
- return is;
- }
-
- }
- catch(Throwable t ) // java.io.IOException x
- {
- t.printStackTrace();
- }
-
- return null;
-
- }
-}
Index: src/java/org/apache/portals/applications/util/Streams.java
===================================================================
RCS file: src/java/org/apache/portals/applications/util/Streams.java
diff -N src/java/org/apache/portals/applications/util/Streams.java
--- src/java/org/apache/portals/applications/util/Streams.java 15 Nov 2004 06:06:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,140 +0,0 @@
-/*
- * Copyright 2000-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.portals.applications.util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.io.InputStreamReader;
-
-/**
- * Utility functions related to Streams.
- *
- * @author David Sean Taylor
- * @version $Id: Streams.java,v 1.1 2004/11/15 06:06:42 taylor Exp $
- */
-public class Streams
-{
- static final int BLOCK_SIZE=4096;
-
- public static void drain(InputStream r,OutputStream w) throws IOException
- {
- byte[] bytes=new byte[BLOCK_SIZE];
- try
- {
- int length=r.read(bytes);
- while(length!=-1)
- {
- if(length!=0)
- {
- w.write(bytes,0,length);
- }
- length=r.read(bytes);
- }
- }
- finally
- {
- bytes=null;
- }
-
- }
-
- public static void drain(Reader r,Writer w) throws IOException
- {
- char[] bytes=new char[BLOCK_SIZE];
- try
- {
- int length=r.read(bytes);
- while(length!=-1)
- {
- if(length!=0)
- {
- w.write(bytes,0,length);
- }
- length=r.read(bytes);
- }
- }
- finally
- {
- bytes=null;
- }
-
- }
-
- public static void drain(Reader r,OutputStream os) throws IOException
- {
- Writer w=new OutputStreamWriter(os);
- drain(r,w);
- w.flush();
- }
-
- public static void drain(InputStream is, Writer w) throws IOException
- {
- Reader r = new InputStreamReader(is);
- drain(r,w);
- w.flush();
- }
-
- public static byte[] drain(InputStream r) throws IOException
- {
- ByteArrayOutputStream bytes=new ByteArrayOutputStream();
- drain(r,bytes);
- return bytes.toByteArray();
- }
-
- public static String getAsString(InputStream is)
- {
- int c=0;
- char lineBuffer[]=new char[128], buf[]=lineBuffer;
- int room= buf.length, offset=0;
- try
- {
- loop: while (true)
- {
- // read chars into a buffer which grows as needed
- switch (c = is.read() )
- {
- case -1: break loop;
-
- default: if (--room < 0)
- {
- buf = new char[offset + 128];
- room = buf.length - offset - 1;
- System.arraycopy(lineBuffer, 0,
- buf, 0, offset);
- lineBuffer = buf;
- }
- buf[offset++] = (char) c;
- break;
- }
- }
- }
- catch(IOException ioe)
- {
- ioe.printStackTrace();
- }
- if ((c == -1) && (offset == 0))
- {
- return null;
- }
- return String.copyValueOf(buf, 0, offset);
- }
-
-}
Index: src/webapp/WEB-INF/jetspeed-portlet.xml
===================================================================
RCS file: /home/cvspublic/jakarta-jetspeed-2/applications/rss/src/webapp/WEB-INF/jetspeed-portlet.xml,v
retrieving revision 1.1
diff -u -r1.1 jetspeed-portlet.xml
--- src/webapp/WEB-INF/jetspeed-portlet.xml 15 Nov 2004 06:06:41 -0000 1.1
+++ src/webapp/WEB-INF/jetspeed-portlet.xml 13 Jan 2005 23:08:23 -0000
@@ -23,4 +23,10 @@