crafterm 2002/10/23 09:56:21 Modified: . module.xml properties.xml Added: src/blocks/itext/conf itext.xmap src/blocks/itext/java/org/apache/cocoon/serialization iTextSerializer.java Removed: src/java/org/apache/cocoon/serialization iTextSerializer.java itext.xmap Log: Applied iTextSerializer block patch. PR: Bugzilla#12738 Obtained By: Philipp Schmidt <[EMAIL PROTECTED]> Revision Changes Path 1.12 +18 -0 xml-cocoon2/module.xml Index: module.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/module.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- module.xml 20 Oct 2002 02:11:45 -0000 1.11 +++ module.xml 23 Oct 2002 16:56:21 -0000 1.12 @@ -176,6 +176,24 @@ </project> + <project name="itext-block"> + <package>org.apache.cocoon</package> + <ant target="block"> + <property name="block-name" value="itext"/> + </ant> + + <depend project="xml-cocoon2"/> + <depend project="xml-itext" version="supplied"/> + + <work nested="tools/anttasks"/> + <home nested="build/cocoon"/> + + <jar name="itext-block.jar"/> + + <nag from="Philipp Schmidt <[EMAIL PROTECTED]>" + to="[EMAIL PROTECTED]"/> + </project> + <project name="jisp"> <url href="http://www.coyotegulch.com/jisp/"/> <description> 1.9 +1 -0 xml-cocoon2/properties.xml Index: properties.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/properties.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- properties.xml 18 Oct 2002 14:09:06 -0000 1.8 +++ properties.xml 23 Oct 2002 16:56:21 -0000 1.9 @@ -104,6 +104,7 @@ <fop include="true"/> <batik include="true"/> <chaperon include="true"/> + <itext include="true"/> <jfor include="true"/> <swf include="true"/> <session-fw include="true"/> 1.1 xml-cocoon2/src/blocks/itext/conf/itext.xmap Index: itext.xmap =================================================================== <?xml version="1.0"?> <xmap xpath="/sitemap/components/serializers" unless="serializer[@name='itext2pdf']"> <map:serializer name="itext2pdf" src="org.apache.cocoon.serialization.iTextSerializer" mime-type="application/pdf"/> </xmap> 1.1 xml-cocoon2/src/blocks/itext/java/org/apache/cocoon/serialization/iTextSerializer.java Index: iTextSerializer.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.serialization; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.excalibur.source.SourceValidity; import org.apache.excalibur.source.impl.validity.NOPValidity; import org.xml.sax.SAXException; import java.io.OutputStream; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import com.lowagie.text.*; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.html.HtmlWriter; import com.lowagie.text.xml.*; /** * @author <a href="mailto:tcurdt@;dff.st">Torsten Curdt</a> */ final public class iTextSerializer extends AbstractSerializer implements Configurable, CacheableProcessingComponent { private String mimetype = "application/pdf"; private boolean setContentLength = true; private Document document = null; public void configure(Configuration conf) throws ConfigurationException { if (conf != null) { this.setContentLength = conf.getChild("set-content-length").getValueAsBoolean(true); this.mimetype = conf.getAttribute("mime-type"); getLogger().debug("iTextSerializer mime-type:" + mimetype); } document = new Document(); } public String getMimeType() { return mimetype; } public void startDocument() throws SAXException { getLogger().debug("starting PDF document"); super.startDocument(); } public void endDocument() throws SAXException { super.endDocument(); getLogger().debug("finished PDF document"); } public void setOutputStream(OutputStream out) { try { PdfWriter.getInstance(document, out); } catch(Exception e) { getLogger().error("cannot create pdf writer instance",e); //TC: FIXME! shouldn't we throw an exception here? what kind? } this.contentHandler = new SAXiTextHandler(document); } public java.io.Serializable generateKey() { return "1"; } public SourceValidity generateValidity() { return NOPValidity.SHARED_INSTANCE; } public void recycle() { super.recycle(); } public boolean shouldSetContentLength() { return this.setContentLength; } }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]