Hi
With the latest source from trunk. I get this build error when doing a
full build
mvn clean install -Dtest=false
[ERROR] Failed to execute goal
org.apache.felix:maven-bundle-plugin:2.3.4:bundle (default-bundle) on
project camel-fop: Internal error in maven-bundle-plugin: Illegal
repetition near index 0
[ERROR] ${camel\.osgi\.export\.pkg}
[ERROR] ^
[ERROR] -> [Help 1]
Do others get this problem as well?
On Tue, Mar 6, 2012 at 2:10 AM, <[email protected]> wrote:
> Author: bibryam
> Date: Tue Mar 6 01:10:05 2012
> New Revision: 1297313
>
> URL: http://svn.apache.org/viewvc?rev=1297313&view=rev
> Log:
> CAMEL-3551: Added new camel-fop component.
>
> Added:
> camel/trunk/components/camel-fop/
> camel/trunk/components/camel-fop/pom.xml
> camel/trunk/components/camel-fop/src/
> camel/trunk/components/camel-fop/src/main/
> camel/trunk/components/camel-fop/src/main/java/
> camel/trunk/components/camel-fop/src/main/java/org/
> camel/trunk/components/camel-fop/src/main/java/org/apache/
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/
>
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/
>
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopComponent.java
>
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopConstants.java
>
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopEndpoint.java
>
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java
> camel/trunk/components/camel-fop/src/main/resources/
> camel/trunk/components/camel-fop/src/main/resources/META-INF/
> camel/trunk/components/camel-fop/src/main/resources/META-INF/services/
> camel/trunk/components/camel-fop/src/main/resources/META-INF/services/org/
>
> camel/trunk/components/camel-fop/src/main/resources/META-INF/services/org/apache/
>
> camel/trunk/components/camel-fop/src/main/resources/META-INF/services/org/apache/camel/
>
> camel/trunk/components/camel-fop/src/main/resources/META-INF/services/org/apache/camel/component/
>
> camel/trunk/components/camel-fop/src/main/resources/META-INF/services/org/apache/camel/component/fop
> camel/trunk/components/camel-fop/src/test/
> camel/trunk/components/camel-fop/src/test/data/
> camel/trunk/components/camel-fop/src/test/data/conf/
> camel/trunk/components/camel-fop/src/test/data/conf/testcfg.xml
> camel/trunk/components/camel-fop/src/test/data/xml/
> camel/trunk/components/camel-fop/src/test/data/xml/data.xml
> camel/trunk/components/camel-fop/src/test/java/
> camel/trunk/components/camel-fop/src/test/java/org/
> camel/trunk/components/camel-fop/src/test/java/org/apache/
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/
>
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/
>
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopComponentTest.java
>
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopEndpointTest.java
>
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopHelper.java
> camel/trunk/components/camel-fop/src/test/resources/
> camel/trunk/components/camel-fop/src/test/resources/xslt/
> camel/trunk/components/camel-fop/src/test/resources/xslt/template.xsl
> Modified:
> camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
> camel/trunk/components/pom.xml
> camel/trunk/parent/pom.xml
> camel/trunk/platforms/karaf/features/pom.xml
> camel/trunk/platforms/karaf/features/src/main/resources/bundles.properties
> camel/trunk/platforms/karaf/features/src/main/resources/features.xml
>
> Modified: camel/trunk/apache-camel/src/main/descriptors/common-bin.xml
> URL:
> http://svn.apache.org/viewvc/camel/trunk/apache-camel/src/main/descriptors/common-bin.xml?rev=1297313&r1=1297312&r2=1297313&view=diff
> ==============================================================================
> --- camel/trunk/apache-camel/src/main/descriptors/common-bin.xml (original)
> +++ camel/trunk/apache-camel/src/main/descriptors/common-bin.xml Tue Mar 6
> 01:10:05 2012
> @@ -62,6 +62,7 @@
> <include>org.apache.camel:camel-eventadmin</include>
> <include>org.apache.camel:camel-exec</include>
> <include>org.apache.camel:camel-flatpack</include>
> + <include>org.apache.camel:camel-fop</include>
> <include>org.apache.camel:camel-freemarker</include>
> <include>org.apache.camel:camel-ftp</include>
> <include>org.apache.camel:camel-gae</include>
>
> Added: camel/trunk/components/camel-fop/pom.xml
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/pom.xml?rev=1297313&view=auto
> ==============================================================================
> --- camel/trunk/components/camel-fop/pom.xml (added)
> +++ camel/trunk/components/camel-fop/pom.xml Tue Mar 6 01:10:05 2012
> @@ -0,0 +1,75 @@
> +<?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.
> +-->
> +<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>
> +
> + <parent>
> + <groupId>org.apache.camel</groupId>
> + <artifactId>camel-parent</artifactId>
> + <version>2.10-SNAPSHOT</version>
> + <relativePath>../../parent</relativePath>
> + </parent>
> +
> + <artifactId>camel-fop</artifactId>
> + <packaging>bundle</packaging>
> + <name>Camel :: FOP</name>
> + <description>Camel FOP support</description>
> +
> + <dependencies>
> + <dependency>
> + <groupId>org.apache.camel</groupId>
> + <artifactId>camel-core</artifactId>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.xmlgraphics</groupId>
> + <artifactId>fop</artifactId>
> + <version>${fop-version}</version>
> + </dependency>
> +
> + <!-- for testing -->
> + <dependency>
> + <groupId>org.apache.camel</groupId>
> + <artifactId>camel-test</artifactId>
> + <scope>test</scope>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.pdfbox</groupId>
> + <artifactId>pdfbox</artifactId>
> + <version>1.6.0</version>
> + <scope>test</scope>
> + </dependency>
> +
> + <!-- logging -->
> + <dependency>
> + <groupId>org.slf4j</groupId>
> + <artifactId>slf4j-api</artifactId>
> + </dependency>
> + <dependency>
> + <groupId>org.slf4j</groupId>
> + <artifactId>slf4j-log4j12</artifactId>
> + <scope>test</scope>
> + </dependency>
> + <dependency>
> + <groupId>log4j</groupId>
> + <artifactId>log4j</artifactId>
> + <scope>test</scope>
> + </dependency>
> + </dependencies>
> +</project>
>
> Added:
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopComponent.java
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopComponent.java?rev=1297313&view=auto
> ==============================================================================
> ---
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopComponent.java
> (added)
> +++
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopComponent.java
> Tue Mar 6 01:10:05 2012
> @@ -0,0 +1,35 @@
> +/**
> + * 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.camel.component.fop;
> +
> +import java.util.Map;
> +
> +import org.apache.camel.Endpoint;
> +import org.apache.camel.impl.DefaultComponent;
> +
> +/**
> + * Represents the component that manages {@link FopEndpoint}.
> + */
> +public class FopComponent extends DefaultComponent {
> +
> + protected Endpoint createEndpoint(String uri, String remaining,
> Map<String, Object> parameters)
> + throws Exception {
> + FopEndpoint endpoint = new FopEndpoint(uri, this, remaining);
> + setProperties(endpoint, parameters);
> + return endpoint;
> + }
> +}
>
> Added:
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopConstants.java
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopConstants.java?rev=1297313&view=auto
> ==============================================================================
> ---
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopConstants.java
> (added)
> +++
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopConstants.java
> Tue Mar 6 01:10:05 2012
> @@ -0,0 +1,23 @@
> +/**
> + * 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.camel.component.fop;
> +
> +public interface FopConstants {
> + String CAMEL_FOP_RENDER = "CamelFop.Render.";
> + String CAMEL_FOP_ENCRYPT = "CamelFop.Encrypt.";
> + String CAMEL_FOP_OUTPUT_FORMAT = "CamelFop.Output.Format";
> +}
>
> Added:
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopEndpoint.java
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopEndpoint.java?rev=1297313&view=auto
> ==============================================================================
> ---
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopEndpoint.java
> (added)
> +++
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopEndpoint.java
> Tue Mar 6 01:10:05 2012
> @@ -0,0 +1,86 @@
> +/**
> + * 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.camel.component.fop;
> +
> +import java.io.IOException;
> +
> +import org.xml.sax.SAXException;
> +
> +import org.apache.avalon.framework.configuration.Configuration;
> +import org.apache.avalon.framework.configuration.ConfigurationException;
> +import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
> +import org.apache.camel.Consumer;
> +import org.apache.camel.Processor;
> +import org.apache.camel.Producer;
> +import org.apache.camel.impl.DefaultEndpoint;
> +import org.apache.fop.apps.FOPException;
> +import org.apache.fop.apps.FopFactory;
> +
> +/**
> + * Represents a Fop endpoint.
> + */
> +public class FopEndpoint extends DefaultEndpoint {
> + private String userConfigURL;
> + private FopFactory fopFactory;
> + private String remaining;
> +
> + public FopEndpoint(String uri, FopComponent component, String remaining)
> {
> + super(uri, component);
> + this.remaining = remaining;
> + this.fopFactory = FopFactory.newInstance();
> + }
> +
> + public Producer createProducer() throws Exception {
> + return new FopProducer(this, fopFactory, remaining);
> + }
> +
> + public Consumer createConsumer(Processor processor) throws Exception {
> + throw new UnsupportedOperationException("Consumer not supported for
> FOP endpoint");
> + }
> +
> + public boolean isSingleton() {
> + return true;
> + }
> +
> + FopFactory getFopFactory() {
> + return fopFactory;
> + }
> +
> + public void setUserConfigURL(String userConfigURL) {
> + this.userConfigURL = userConfigURL;
> + updateConfigurations();
> + }
> +
> + private void updateConfigurations() {
> + DefaultConfigurationBuilder cfgBuilder = new
> DefaultConfigurationBuilder();
> + Configuration cfg;
> + try {
> + cfg = cfgBuilder.buildFromFile(this.userConfigURL);
> + } catch (SAXException e) {
> + throw new RuntimeException(e);
> + } catch (IOException e) {
> + throw new RuntimeException(e);
> + } catch (ConfigurationException e) {
> + throw new RuntimeException(e);
> + }
> + try {
> + fopFactory.setUserConfig(cfg);
> + } catch (FOPException e) {
> + throw new RuntimeException(e);
> + }
> + }
> +}
>
> Added:
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java?rev=1297313&view=auto
> ==============================================================================
> ---
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java
> (added)
> +++
> camel/trunk/components/camel-fop/src/main/java/org/apache/camel/component/fop/FopProducer.java
> Tue Mar 6 01:10:05 2012
> @@ -0,0 +1,106 @@
> +/**
> + * 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.camel.component.fop;
> +
> +import java.io.ByteArrayOutputStream;
> +import java.io.OutputStream;
> +import java.util.Map;
> +import javax.xml.transform.Result;
> +import javax.xml.transform.Source;
> +import javax.xml.transform.Transformer;
> +import javax.xml.transform.TransformerException;
> +import javax.xml.transform.TransformerFactory;
> +import javax.xml.transform.sax.SAXResult;
> +import javax.xml.transform.stream.StreamSource;
> +
> +import org.apache.camel.Exchange;
> +import org.apache.camel.RuntimeExchangeException;
> +import org.apache.camel.impl.DefaultProducer;
> +import org.apache.camel.util.IntrospectionSupport;
> +import org.apache.fop.apps.FOPException;
> +import org.apache.fop.apps.FOUserAgent;
> +import org.apache.fop.apps.Fop;
> +import org.apache.fop.apps.FopFactory;
> +import org.apache.fop.pdf.PDFEncryptionParams;
> +
> +/**
> + * The Fop producer.
> + */
> +public class FopProducer extends DefaultProducer {
> + private final FopFactory fopFactory;
> + private final String remaining;
> +
> + public FopProducer(FopEndpoint endpoint, FopFactory fopFactory, String
> remaining) {
> + super(endpoint);
> + this.fopFactory = fopFactory;
> + this.remaining = remaining;
> + }
> +
> + public void process(Exchange exchange) throws Exception {
> + FOUserAgent userAgent = fopFactory.newFOUserAgent();
> + Map<String, Object> headers = exchange.getIn().getHeaders();
> + setRenderParameters(userAgent, headers);
> + setEncryptionParameters(userAgent, headers);
> +
> + String outputFormat = getOutputFormat(exchange);
> + Source src = exchange.getIn().getBody(StreamSource.class);
> +
> + OutputStream out = transform(userAgent, outputFormat, src);
> + exchange.getOut().setBody(out);
> + }
> +
> + private String getOutputFormat(Exchange exchange) {
> + String outputFormat = exchange.getIn()
> + .getHeader(FopConstants.CAMEL_FOP_OUTPUT_FORMAT,
> this.remaining, String.class);
> + if (outputFormat == null) {
> + throw new RuntimeExchangeException("Missing output format",
> exchange);
> + }
> +
> + return outputFormat;
> + }
> +
> + private OutputStream transform(FOUserAgent userAgent, String
> outputFormat, Source src)
> + throws FOPException, TransformerException {
> + OutputStream out = new ByteArrayOutputStream();
> + Fop fop = fopFactory.newFop(outputFormat, userAgent, out);
> + TransformerFactory factory = TransformerFactory.newInstance();
> + Transformer transformer = factory.newTransformer();
> +
> + Result res = new SAXResult(fop.getDefaultHandler());
> + transformer.transform(src, res);
> + return out;
> + }
> +
> + private void setEncryptionParameters(FOUserAgent userAgent, Map<String,
> Object> headers)
> + throws Exception {
> + Map<String, Object> encryptionParameters = IntrospectionSupport
> + .extractProperties(headers, FopConstants.CAMEL_FOP_ENCRYPT);
> + if (!encryptionParameters.isEmpty()) {
> + PDFEncryptionParams encryptionParams = new PDFEncryptionParams();
> + IntrospectionSupport.setProperties(encryptionParams,
> encryptionParameters);
> + userAgent.getRendererOptions().put("encryption-params",
> encryptionParams);
> + }
> + }
> +
> + private void setRenderParameters(FOUserAgent userAgent, Map<String,
> Object> headers) throws Exception {
> + Map<String, Object> parameters = IntrospectionSupport
> + .extractProperties(headers, FopConstants.CAMEL_FOP_RENDER);
> + if (!parameters.isEmpty()) {
> + IntrospectionSupport.setProperties(userAgent, parameters);
> + }
> + }
> +}
>
> Added:
> camel/trunk/components/camel-fop/src/main/resources/META-INF/services/org/apache/camel/component/fop
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/main/resources/META-INF/services/org/apache/camel/component/fop?rev=1297313&view=auto
> ==============================================================================
> ---
> camel/trunk/components/camel-fop/src/main/resources/META-INF/services/org/apache/camel/component/fop
> (added)
> +++
> camel/trunk/components/camel-fop/src/main/resources/META-INF/services/org/apache/camel/component/fop
> Tue Mar 6 01:10:05 2012
> @@ -0,0 +1,18 @@
> +#
> +# 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.
> +#
> +
> +class=org.apache.camel.component.fop.FopComponent
>
> Added: camel/trunk/components/camel-fop/src/test/data/conf/testcfg.xml
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/test/data/conf/testcfg.xml?rev=1297313&view=auto
> ==============================================================================
> --- camel/trunk/components/camel-fop/src/test/data/conf/testcfg.xml (added)
> +++ camel/trunk/components/camel-fop/src/test/data/conf/testcfg.xml Tue Mar
> 6 01:10:05 2012
> @@ -0,0 +1,42 @@
> +<?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.
> +-->
> +<fop version="1.0">
> +
> + <!-- Strict user configuration -->
> + <strict-configuration>true</strict-configuration>
> +
> + <!-- Strict FO validation -->
> + <strict-validation>true</strict-validation>
> +
> + <!-- Base URL for resolving relative URLs -->
> + <base>./</base>
> +
> + <!-- Font Base URL for resolving relative font URLs -->
> + <font-base>./</font-base>
> +
> + <!-- Source resolution in dpi (dots/pixels per inch) for determining the
> size of pixels in SVG and bitmap images, default: 72dpi -->
> + <source-resolution>96</source-resolution>
> + <!-- Target resolution in dpi (dots/pixels per inch) for specifying the
> target resolution for generated bitmaps, default: 72dpi -->
> + <target-resolution>72</target-resolution>
> +
> + <!-- default page-height and page-width, in case
> + value is specified as auto -->
> + <default-page-settings height="11in" width="8.26in"/>
> +
> + <!-- etc. etc..... -->
> +</fop>
>
> Added: camel/trunk/components/camel-fop/src/test/data/xml/data.xml
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/test/data/xml/data.xml?rev=1297313&view=auto
> ==============================================================================
> --- camel/trunk/components/camel-fop/src/test/data/xml/data.xml (added)
> +++ camel/trunk/components/camel-fop/src/test/data/xml/data.xml Tue Mar 6
> 01:10:05 2012
> @@ -0,0 +1,45 @@
> +<?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.
> +-->
> +<projectteam>
> + <projectname>The Killer Application</projectname>
> + <member>
> + <name>John Doe</name>
> + <function>lead</function>
> + <email>[email protected]</email>
> + </member>
> + <member>
> + <name>Paul Coder</name>
> + <function>dev</function>
> + <email>[email protected]</email>
> + </member>
> + <member>
> + <name>Max Hacker</name>
> + <function>dev</function>
> + <email>[email protected]</email>
> + </member>
> + <member>
> + <name>Donna Book</name>
> + <function>doc</function>
> + <email>[email protected]</email>
> + </member>
> + <member>
> + <name>Henry Tester</name>
> + <function>qa</function>
> + <email>[email protected]</email>
> + </member>
> +</projectteam>
>
> Added:
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopComponentTest.java
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopComponentTest.java?rev=1297313&view=auto
> ==============================================================================
> ---
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopComponentTest.java
> (added)
> +++
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopComponentTest.java
> Tue Mar 6 01:10:05 2012
> @@ -0,0 +1,67 @@
> +/**
> + * 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.camel.component.fop;
> +
> +import java.io.FileInputStream;
> +
> +import org.apache.camel.EndpointInject;
> +import org.apache.camel.Exchange;
> +import org.apache.camel.Produce;
> +import org.apache.camel.ProducerTemplate;
> +import org.apache.camel.builder.RouteBuilder;
> +import org.apache.camel.component.mock.MockEndpoint;
> +import org.apache.camel.test.junit4.CamelTestSupport;
> +import org.apache.pdfbox.pdmodel.PDDocument;
> +import org.junit.Test;
> +
> +public class FopComponentTest extends CamelTestSupport {
> +
> + @EndpointInject(uri = "mock:result")
> + protected MockEndpoint resultEndpoint;
> +
> + @Produce(uri = "direct:start")
> + protected ProducerTemplate template;
> +
> + @Test
> + public void createPdfUsingXmlDataAndXsltTransformation() throws
> Exception {
> + resultEndpoint.expectedMessageCount(1);
> + FileInputStream inputStream = new
> FileInputStream("src/test/data/xml/data.xml");
> +
> + template.sendBody(inputStream);
> + resultEndpoint.assertIsSatisfied();
> +
> + PDDocument document = PDDocument.load("target/data/result.pdf");
> + String pdfText = FopHelper.extractTextFrom(document);
> + assertTrue(pdfText.contains("Project")); //from xsl template
> + assertTrue(pdfText.contains("John Doe")); //from data xml
> + }
> +
> + @Override
> + protected RouteBuilder createRouteBuilder() {
> + return new RouteBuilder() {
> + public void configure() {
> + from("direct:start")
> + .to("xslt:xslt/template.xsl")
> + .to("fop:application/pdf")
> + .setHeader(Exchange.FILE_NAME,
> constant("result.pdf"))
> + .to("file:target/data")
> + .to("mock:result");
> +
> + }
> + };
> + }
> +}
>
> Added:
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopEndpointTest.java
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopEndpointTest.java?rev=1297313&view=auto
> ==============================================================================
> ---
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopEndpointTest.java
> (added)
> +++
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopEndpointTest.java
> Tue Mar 6 01:10:05 2012
> @@ -0,0 +1,101 @@
> +/**
> + * 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.camel.component.fop;
> +
> +import java.io.IOException;
> +import java.io.InputStream;
> +
> +import org.apache.camel.Endpoint;
> +import org.apache.camel.Exchange;
> +import org.apache.camel.Producer;
> +import org.apache.camel.impl.DefaultExchange;
> +import org.apache.camel.test.junit4.CamelTestSupport;
> +import org.apache.fop.apps.MimeConstants;
> +import org.apache.pdfbox.cos.COSName;
> +import org.apache.pdfbox.pdmodel.PDDocument;
> +import org.junit.Test;
> +
> +public class FopEndpointTest extends CamelTestSupport {
> +
> + @Test
> + public void generatePdfFromXslfoWithSpecificText() throws Exception {
> + Endpoint endpoint = context().getEndpoint("fop:application/pdf");
> + Producer producer = endpoint.createProducer();
> + Exchange exchange = new DefaultExchange(context);
> + exchange.getIn().setBody(FopHelper.decorateTextWithXSLFO("Test
> Content"));
> +
> + producer.process(exchange);
> + PDDocument document = getDocumentFrom(exchange);
> + String content = FopHelper.extractTextFrom(document);
> + assertEquals("Test Content", content);
> + }
> +
> + @Test
> + public void specifyCustomUserConfigurationFile() throws Exception {
> + FopEndpoint customConfiguredEndpoint = context()
> +
> .getEndpoint("fop:application/pdf?userConfigURL=src/test/data/conf/testcfg.xml",
> + FopEndpoint.class);
> + float customSourceResolution =
> customConfiguredEndpoint.getFopFactory().getSourceResolution();
> + assertEquals(96.0, customSourceResolution, 0.1);
> + }
> +
> + @Test
> + public void setPDFRenderingMetadataPerDocument() throws Exception {
> + Endpoint endpoint = context().getEndpoint("fop:application/pdf");
> + Producer producer = endpoint.createProducer();
> + Exchange exchange = new DefaultExchange(context);
> + exchange.getIn().setHeader("CamelFop.Render.Creator", "Test User");
> + exchange.getIn().setBody(FopHelper.decorateTextWithXSLFO("Test
> Content"));
> +
> + producer.process(exchange);
> + PDDocument document = getDocumentFrom(exchange);
> + String creator = FopHelper.getDocumentMetadataValue(document,
> COSName.CREATOR);
> + assertEquals("Test User", creator);
> + }
> +
> + @Test
> + public void encryptPdfWithUserPassword() throws Exception {
> + Endpoint endpoint = context().getEndpoint("fop:application/pdf");
> + Producer producer = endpoint.createProducer();
> + Exchange exchange = new DefaultExchange(context);
> + exchange.getIn().setHeader("CamelFop.Encrypt.userPassword",
> "secret");
> + exchange.getIn().setBody(FopHelper.decorateTextWithXSLFO("Test
> Content"));
> +
> + producer.process(exchange);
> + PDDocument document = getDocumentFrom(exchange);
> + assertTrue(document.isEncrypted());
> + }
> +
> + @Test
> + public void overridePdfOutputFormatToPlainText() throws Exception {
> + String defaultOutputFormat = "application/pdf";
> + Endpoint endpoint = context().getEndpoint("fop:" +
> defaultOutputFormat);
> + Producer producer = endpoint.createProducer();
> + Exchange exchange = new DefaultExchange(context);
> + exchange.getIn().setHeader(FopConstants.CAMEL_FOP_OUTPUT_FORMAT,
> MimeConstants.MIME_PLAIN_TEXT);
> + exchange.getIn().setBody(FopHelper.decorateTextWithXSLFO("Test
> Content"));
> +
> + producer.process(exchange);
> + String plainText = exchange.getOut().getBody(String.class).trim();
> + assertEquals("Test Content", plainText);
> + }
> +
> + private PDDocument getDocumentFrom(Exchange exchange) throws IOException
> {
> + InputStream inputStream =
> exchange.getOut().getBody(InputStream.class);
> + return PDDocument.load(inputStream);
> + }
> +}
>
> Added:
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopHelper.java
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopHelper.java?rev=1297313&view=auto
> ==============================================================================
> ---
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopHelper.java
> (added)
> +++
> camel/trunk/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopHelper.java
> Tue Mar 6 01:10:05 2012
> @@ -0,0 +1,75 @@
> +/**
> + * 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.camel.component.fop;
> +
> +import java.io.IOException;
> +import java.io.StringWriter;
> +import java.io.Writer;
> +
> +import org.apache.pdfbox.cos.COSName;
> +import org.apache.pdfbox.exceptions.CryptographyException;
> +import org.apache.pdfbox.pdmodel.PDDocument;
> +import org.apache.pdfbox.pdmodel.PDDocumentInformation;
> +import org.apache.pdfbox.pdmodel.encryption.BadSecurityHandlerException;
> +import org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial;
> +import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
> +import org.apache.pdfbox.util.PDFTextStripper;
> +
> +public final class FopHelper {
> + private FopHelper() {
> + }
> +
> + //decryption requires additional libraries
> + public static void decryptPDFN(PDDocument document, String password)
> throws
> + IOException, CryptographyException, BadSecurityHandlerException {
> + if (document.isEncrypted()) {
> + DecryptionMaterial decryptionMaterial = new
> StandardDecryptionMaterial(password);
> + document.openProtection(decryptionMaterial);
> + } else {
> + throw new RuntimeException("Document not encrypted");
> + }
> + }
> +
> + public static String extractTextFrom(PDDocument document) throws
> IOException {
> + Writer output = new StringWriter();
> + PDFTextStripper stripper = new PDFTextStripper();
> + stripper.writeText(document, output);
> + return output.toString().trim();
> + }
> +
> + public static String getDocumentMetadataValue(PDDocument document,
> COSName name) {
> + PDDocumentInformation info = document.getDocumentInformation();
> + return info.getDictionary().getString(name);
> + }
> +
> + public static String decorateTextWithXSLFO(String text) {
> + return "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">\n"
> + + " <fo:layout-master-set>\n"
> + + " <fo:simple-page-master master-name=\"only\">\n"
> + + " <fo:region-body region-name=\"xsl-region-body\"
> margin=\"0.7in\" padding=\"0\" />\n"
> + + " <fo:region-before region-name=\"xsl-region-before\"
> extent=\"0.7in\" />\n"
> + + " <fo:region-after region-name=\"xsl-region-after\"
> extent=\"0.7in\" />\n"
> + + " </fo:simple-page-master>\n"
> + + " </fo:layout-master-set>\n"
> + + " <fo:page-sequence master-reference=\"only\">\n"
> + + " <fo:flow flow-name=\"xsl-region-body\">\n"
> + + " <fo:block>" + text + "</fo:block>\n"
> + + " </fo:flow>\n"
> + + " </fo:page-sequence>\n"
> + + "</fo:root>";
> + }
> +}
>
> Added: camel/trunk/components/camel-fop/src/test/resources/xslt/template.xsl
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-fop/src/test/resources/xslt/template.xsl?rev=1297313&view=auto
> ==============================================================================
> --- camel/trunk/components/camel-fop/src/test/resources/xslt/template.xsl
> (added)
> +++ camel/trunk/components/camel-fop/src/test/resources/xslt/template.xsl Tue
> Mar 6 01:10:05 2012
> @@ -0,0 +1,82 @@
> +<?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.
> +-->
> +<xsl:stylesheet version="1.1"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
> + <xsl:output method="xml" version="1.0" omit-xml-declaration="no"
> indent="yes"/>
> + <xsl:param name="versionParam" select="'1.0'"/>
> + <!-- ========================= -->
> + <!-- root element: projectteam -->
> + <!-- ========================= -->
> + <xsl:template match="projectteam">
> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
> +
> + <fo:layout-master-set>
> + <fo:simple-page-master master-name="simpleA4" page-height="29.7cm"
> page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm"
> margin-right="2cm">
> + <fo:region-body/>
> + </fo:simple-page-master>
> + </fo:layout-master-set>
> + <fo:page-sequence master-reference="simpleA4">
> + <fo:flow flow-name="xsl-region-body">
> + <fo:block font-size="16pt" font-weight="bold"
> space-after="5mm">Project: <xsl:value-of select="projectname"/>
> +
> + </fo:block>
> + <fo:block font-size="12pt" space-after="5mm">Version <xsl:value-of
> select="$versionParam"/>
> + </fo:block>
> + <fo:block font-size="10pt">
> + <fo:table table-layout="fixed" width="100%"
> border-collapse="separate">
> + <fo:table-column column-width="4cm"/>
> + <fo:table-column column-width="4cm"/>
> + <fo:table-column column-width="5cm"/>
> +
> + <fo:table-body>
> + <xsl:apply-templates select="member"/>
> + </fo:table-body>
> + </fo:table>
> + </fo:block>
> + </fo:flow>
> + </fo:page-sequence>
> + </fo:root>
> + </xsl:template>
> +
> + <!-- ========================= -->
> + <!-- child element: member -->
> + <!-- ========================= -->
> + <xsl:template match="member">
> + <fo:table-row>
> + <xsl:if test="function = 'lead'">
> + <xsl:attribute name="font-weight">bold</xsl:attribute>
> + </xsl:if>
> +
> + <fo:table-cell>
> + <fo:block>
> + <xsl:value-of select="name"/>
> + </fo:block>
> + </fo:table-cell>
> + <fo:table-cell>
> + <fo:block>
> + <xsl:value-of select="function"/>
> + </fo:block>
> + </fo:table-cell>
> + <fo:table-cell>
> + <fo:block>
> + <xsl:value-of select="email"/>
> + </fo:block>
> + </fo:table-cell>
> + </fo:table-row>
> + </xsl:template>
> +</xsl:stylesheet>
> +
>
> Modified: camel/trunk/components/pom.xml
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/pom.xml?rev=1297313&r1=1297312&r2=1297313&view=diff
> ==============================================================================
> --- camel/trunk/components/pom.xml (original)
> +++ camel/trunk/components/pom.xml Tue Mar 6 01:10:05 2012
> @@ -76,6 +76,7 @@
> <module>camel-eventadmin</module>
> <module>camel-exec</module>
> <module>camel-flatpack</module>
> + <module>camel-fop</module>
> <module>camel-freemarker</module>
> <module>camel-ftp</module>
> <module>camel-gae</module>
>
> Modified: camel/trunk/parent/pom.xml
> URL:
> http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1297313&r1=1297312&r2=1297313&view=diff
> ==============================================================================
> --- camel/trunk/parent/pom.xml (original)
> +++ camel/trunk/parent/pom.xml Tue Mar 6 01:10:05 2012
> @@ -69,6 +69,7 @@
> <easymock-version>3.0</easymock-version>
> <ehcache-bundle-version>2.4.3_1</ehcache-bundle-version>
> <flatpack-version>3.2.0_1</flatpack-version>
> + <fop-version>1.0</fop-version>
> <ftpserver-version>1.0.5</ftpserver-version>
> <freemarker-version>2.3.18</freemarker-version>
> <geronimo-el-spec-version>1.0.1</geronimo-el-spec-version>
> @@ -391,6 +392,11 @@
> </dependency>
> <dependency>
> <groupId>org.apache.camel</groupId>
> + <artifactId>camel-fop</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.camel</groupId>
> <artifactId>camel-freemarker</artifactId>
> <version>${project.version}</version>
> </dependency>
>
> Modified: camel/trunk/platforms/karaf/features/pom.xml
> URL:
> http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/pom.xml?rev=1297313&r1=1297312&r2=1297313&view=diff
> ==============================================================================
> --- camel/trunk/platforms/karaf/features/pom.xml (original)
> +++ camel/trunk/platforms/karaf/features/pom.xml Tue Mar 6 01:10:05 2012
> @@ -60,6 +60,7 @@
> <flatpack-bundle-version>3.2.0_2</flatpack-bundle-version>
> <felix-configadmin-version>1.2.4</felix-configadmin-version>
> <felix-framework-version>2.0.5</felix-framework-version>
> + <fop-bundle-version>1.0_2</fop-bundle-version>
> <freemarker-bundle-version>2.3.18_1</freemarker-bundle-version>
> <geronimo-el-version>1.0.1</geronimo-el-version>
>
> <geronimo-ws-metadata-spec-version>1.1.3</geronimo-ws-metadata-spec-version>
>
> Modified:
> camel/trunk/platforms/karaf/features/src/main/resources/bundles.properties
> URL:
> http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/src/main/resources/bundles.properties?rev=1297313&r1=1297312&r2=1297313&view=diff
> ==============================================================================
> ---
> camel/trunk/platforms/karaf/features/src/main/resources/bundles.properties
> (original)
> +++
> camel/trunk/platforms/karaf/features/src/main/resources/bundles.properties
> Tue Mar 6 01:10:05 2012
> @@ -40,6 +40,7 @@ org.apache.servicemix.bundles/org.apache
> org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-io/${commons-io-bundle-version}/jar
> org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/${dom4j-bundle-version}/jar
> org.apache.servicemix.bundles/org.apache.servicemix.bundles.flatpack/${flatpack-bundle-version}/jar
> +org.apache.servicemix.bundles/org.apache.servicemix.bundles.fop/${fop-bundle-version}/jar
> org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker/${freemarker-bundle-version}/jar
> org.apache.servicemix.bundles/org.apache.servicemix.bundles.hamcrest/${hamcrest-bundle-version}/jar
> org.apache.servicemix.bundles/org.apache.servicemix.bundles.hapi/${hapi-bundle-version}/jar
>
> Modified: camel/trunk/platforms/karaf/features/src/main/resources/features.xml
> URL:
> http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/src/main/resources/features.xml?rev=1297313&r1=1297312&r2=1297313&view=diff
> ==============================================================================
> --- camel/trunk/platforms/karaf/features/src/main/resources/features.xml
> (original)
> +++ camel/trunk/platforms/karaf/features/src/main/resources/features.xml Tue
> Mar 6 01:10:05 2012
> @@ -276,6 +276,11 @@
> <bundle
> dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.flatpack/${flatpack-bundle-version}</bundle>
> <bundle>mvn:org.apache.camel/camel-flatpack/${project.version}</bundle>
> </feature>
> + <feature name='camel-fop' version='${pom.version}' resolver='(obr)'
> start-level='50'>
> + <feature version='${project.version}'>camel-core</feature>
> + <bundle
> dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.fop/${fop-bundle-version}</bundle>
> + <bundle>mvn:org.apache.camel/camel-fop/${project.version}</bundle>
> + </feature>
> <feature name='camel-freemarker' version='${project.version}'
> resolver='(obr)' start-level='50'>
> <feature version='${project.version}'>camel-core</feature>
> <bundle
> dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker/${freemarker-bundle-version}</bundle>
>
>
--
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/