Added: portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/JetspeedTransform.java URL: http://svn.apache.org/viewvc/portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/JetspeedTransform.java?rev=754965&view=auto ============================================================================== --- portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/JetspeedTransform.java (added) +++ portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/JetspeedTransform.java Mon Mar 16 17:25:31 2009 @@ -0,0 +1,385 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 <a href="mailto:[email protected]">David Sean Taylor </a> + * @version $Id: JetspeedTransform.java 516448 2007-03-09 16:25:47Z ate $ + */ +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); + System.setProperty(SAX_XML_READER_PROPERTY, saxXmlReaderProp); + + 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"; + + // + // Standard Parser Vendor Property + // + private static final String SAX_XML_READER_PROPERTY = "org.xml.sax.driver"; + + // + // Standard Parser Vendor Configuration + // + private final static String saxXmlReaderProp = "org.apache.xerces.parsers.SAXParser"; + + // 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.getCharacterStream(), 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); + System.setProperty(SAX_XML_READER_PROPERTY, saxXmlReaderProp); + + 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; + } + + +}
Added: portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/MemoryTransformCache.java URL: http://svn.apache.org/viewvc/portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/MemoryTransformCache.java?rev=754965&view=auto ============================================================================== --- portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/MemoryTransformCache.java (added) +++ portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/MemoryTransformCache.java Mon Mar 16 17:25:31 2009 @@ -0,0 +1,230 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 <a href="mailto:[email protected]">David Sean Taylor </a> + * @version $Id: MemoryTransformCache.java 517719 2007-03-13 15:05:48Z ate $ + */ +public class MemoryTransformCache implements TransformCache +{ + private boolean debug = false; + private int maxSize = 100; + private int evictionPercentage = 10; + private boolean enable = true; + + private TreeMap cache = null; + private Object lock = new Object(); + + /** + * Spring constructor injection + * + */ + public MemoryTransformCache(Transform transform, int maxSize, int evictionPercentage, boolean enable, boolean debug) + { + 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 = 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 + } + +} + Added: portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/TransformDTDEntityResolver.java URL: http://svn.apache.org/viewvc/portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/TransformDTDEntityResolver.java?rev=754965&view=auto ============================================================================== --- portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/TransformDTDEntityResolver.java (added) +++ portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/transform/impl/TransformDTDEntityResolver.java Mon Mar 16 17:25:31 2009 @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 <a href="mailto:[email protected]">David Sean Taylor</a> + * @version $Id: TransformDTDEntityResolver.java 516448 2007-03-09 16:25:47Z ate $ + */ +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; + + } +} Added: portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/util/Streams.java URL: http://svn.apache.org/viewvc/portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/util/Streams.java?rev=754965&view=auto ============================================================================== --- portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/util/Streams.java (added) +++ portals/applications/rss/trunk/rss-jar/src/main/java/org/apache/portals/applications/util/Streams.java Mon Mar 16 17:25:31 2009 @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 <a href="mailto:[email protected]">David Sean Taylor</a> + * @version $Id: Streams.java 516448 2007-03-09 16:25:47Z ate $ + */ +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; + } + + } + + /** + * @deprecated encoding? + * @param r character reader + * @param os byte stream + * @throws IOException + */ + public static void drain(Reader r,OutputStream os) throws IOException + { + Writer w=new OutputStreamWriter(os); + drain(r,w); + w.flush(); + } + + /** + * @deprecated how can it know the encoding? + * @param is input stream (encoding?) + * @param w writer + * @throws IOException + */ + 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(); + } + + /** + * @deprecated encoding? + * @param is input stream + * @return + */ + 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); + } + +} Modified: portals/applications/rss/trunk/rss-war/pom.xml URL: http://svn.apache.org/viewvc/portals/applications/rss/trunk/rss-war/pom.xml?rev=754965&r1=750897&r2=754965&view=diff ============================================================================== --- portals/applications/rss/trunk/rss-war/pom.xml (original) +++ portals/applications/rss/trunk/rss-war/pom.xml Mon Mar 16 17:25:31 2009 @@ -1,107 +1,97 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You 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. - - $Id:$ ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - <prerequisites> - <maven>2.0.4</maven> - </prerequisites> - - <!-- POM Identification --> - - <artifactId>rss</artifactId> - <parent> - <groupId>org.apache.portals.applications</groupId> - <artifactId>rss-main</artifactId> - <version>2.2-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - <packaging>war</packaging> - <name>Portals RSS Application WAR</name> - - <!-- Dependencies --> - - <dependencies> - - <!-- Runtime Dependencies --> - - <dependency> - <groupId>${pom.groupId}</groupId> - <artifactId>portals-rss</artifactId> - <version>${pom.version}</version> - </dependency> - - <dependency> - <groupId>velocity-tools</groupId> - <artifactId>velocity-tools</artifactId> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>commons-digester</groupId> - <artifactId>commons-digester</artifactId> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>commons-collections</groupId> - <artifactId>commons-collections</artifactId> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>oro</groupId> - <artifactId>oro</artifactId> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <scope>runtime</scope> - </dependency> - </dependencies> - - <!-- Build Configuration --> - - <build> - - <!-- Plugin Configuration --> - <pluginManagement> - <plugins> - - <!-- WAR plugin --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-war-plugin</artifactId> - <configuration> - <warSourceDirectory>../src/main/webapp</warSourceDirectory> - </configuration> - </plugin> - - </plugins> - </pluginManagement> - - </build> + <!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. $Id:$ + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + <prerequisites> + <maven>2.0.4</maven> + </prerequisites> + + <!-- POM Identification --> + <artifactId>apa-rss-war</artifactId> + <parent> + <groupId>org.apache.portals.applications</groupId> + <artifactId>apa-rss</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <packaging>war</packaging> + <name>Portals RSS Application WAR</name> + + <!-- Dependencies --> + <properties> + <velocity-tools.version>1.3</velocity-tools.version> + <commons-digester.version>1.8</commons-digester.version> + <commons-lang.version>2.1</commons-lang.version> + <commons-collections.version>3.2</commons-collections.version> + <log4j.version>1.2.14</log4j.version> + <oro.version>2.0.8</oro.version> + </properties> + <dependencies> + + <!-- Runtime Dependencies --> + + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>apa-rss-jar</artifactId> + <version>${pom.version}</version> + </dependency> + + <dependency> + <groupId>velocity-tools</groupId> + <artifactId>velocity-tools</artifactId> + <version>${velocity-tools.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>commons-digester</groupId> + <artifactId>commons-digester</artifactId> + <scope>runtime</scope> + <version>${commons-digester.version}</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>${commons-lang.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>${commons-collections.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>oro</groupId> + <artifactId>oro</artifactId> + <version>${oro.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>${log4j.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.apache.portals.applications</groupId> + <artifactId>apa-webapp-logging</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> </project>
