You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/07/18 16:11:36 UTC

svn commit: r1362958 [1/2] - in /camel/trunk: apache-camel/ apache-camel/src/main/descriptors/ components/ components/camel-cmis/ components/camel-cmis/src/ components/camel-cmis/src/main/ components/camel-cmis/src/main/java/ components/camel-cmis/src/...

Author: ningjiang
Date: Wed Jul 18 14:11:35 2012
New Revision: 1362958

URL: http://svn.apache.org/viewvc?rev=1362958&view=rev
Log:
CAMEL-4691 Added camel-cmis component

Added:
    camel/trunk/components/camel-cmis/
    camel/trunk/components/camel-cmis/pom.xml
    camel/trunk/components/camel-cmis/src/
    camel/trunk/components/camel-cmis/src/main/
    camel/trunk/components/camel-cmis/src/main/java/
    camel/trunk/components/camel-cmis/src/main/java/org/
    camel/trunk/components/camel-cmis/src/main/java/org/apache/
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISComponent.java
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISConsumer.java
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISEndpoint.java
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISHelper.java
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CamelCMISConstants.java
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/RecursiveTreeWalker.java
    camel/trunk/components/camel-cmis/src/main/resources/
    camel/trunk/components/camel-cmis/src/main/resources/META-INF/
    camel/trunk/components/camel-cmis/src/main/resources/META-INF/LICENSE.txt
    camel/trunk/components/camel-cmis/src/main/resources/META-INF/NOTICE.txt
    camel/trunk/components/camel-cmis/src/main/resources/META-INF/services/
    camel/trunk/components/camel-cmis/src/main/resources/META-INF/services/org/
    camel/trunk/components/camel-cmis/src/main/resources/META-INF/services/org/apache/
    camel/trunk/components/camel-cmis/src/main/resources/META-INF/services/org/apache/camel/
    camel/trunk/components/camel-cmis/src/main/resources/META-INF/services/org/apache/camel/component/
    camel/trunk/components/camel-cmis/src/main/resources/META-INF/services/org/apache/camel/component/cmis
    camel/trunk/components/camel-cmis/src/test/
    camel/trunk/components/camel-cmis/src/test/java/
    camel/trunk/components/camel-cmis/src/test/java/org/
    camel/trunk/components/camel-cmis/src/test/java/org/apache/
    camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/
    camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/
    camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/
    camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISConsumerTest.java
    camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISProducerTest.java
    camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISQueryProducerTest.java
    camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISTestSupport.java
    camel/trunk/components/camel-cmis/src/test/resources/
    camel/trunk/components/camel-cmis/src/test/resources/log4j.properties
Modified:
    camel/trunk/apache-camel/pom.xml
    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/features.xml

Modified: camel/trunk/apache-camel/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/apache-camel/pom.xml?rev=1362958&r1=1362957&r2=1362958&view=diff
==============================================================================
--- camel/trunk/apache-camel/pom.xml (original)
+++ camel/trunk/apache-camel/pom.xml Wed Jul 18 14:11:35 2012
@@ -109,6 +109,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-cmis</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-cometd</artifactId>
     </dependency>
     <dependency>

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=1362958&r1=1362957&r2=1362958&view=diff
==============================================================================
--- camel/trunk/apache-camel/src/main/descriptors/common-bin.xml (original)
+++ camel/trunk/apache-camel/src/main/descriptors/common-bin.xml Wed Jul 18 14:11:35 2012
@@ -47,6 +47,7 @@
         <include>org.apache.camel:camel-cache</include>
         <include>org.apache.camel:camel-castor</include>
         <include>org.apache.camel:camel-cdi</include>
+        <include>org.apache.camel:camel-cmis</include>
         <include>org.apache.camel:camel-core</include>
         <include>org.apache.camel:camel-core-osgi</include>
         <include>org.apache.camel:camel-cometd</include>

Added: camel/trunk/components/camel-cmis/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/pom.xml?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/pom.xml (added)
+++ camel/trunk/components/camel-cmis/pom.xml Wed Jul 18 14:11:35 2012
@@ -0,0 +1,118 @@
+<?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.11-SNAPSHOT</version>
+        <relativePath>../../parent</relativePath>
+    </parent>
+
+    <artifactId>camel-cmis</artifactId>
+    <packaging>bundle</packaging>
+    <name>Camel :: CMIS</name>
+    <description>Camel CMIS</description>
+
+    <properties>
+        <camel.osgi.export.pkg>org.apache.camel.component.cmis.*</camel.osgi.export.pkg>
+        <!--<camel.osgi.import.pkg>!org.apache.chemistry.opencmis.client.runtime</camel.osgi.import.pkg>-->
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.chemistry.opencmis</groupId>
+            <artifactId>chemistry-opencmis-client-impl</artifactId>
+            <version>${cmis-version}</version>
+        </dependency>
+
+        <!-- for testing -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.chemistry.opencmis</groupId>
+            <artifactId>chemistry-opencmis-server-inmemory</artifactId>
+            <version>${cmis-version}</version>
+            <type>war</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mortbay.jetty</groupId>
+            <artifactId>jetty</artifactId>
+            <version>6.1.24</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>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-war</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>copy</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>target/dependency</outputDirectory>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.apache.chemistry.opencmis</groupId>
+                                    <artifactId>chemistry-opencmis-server-inmemory</artifactId>
+                                    <version>${cmis-version}</version>
+                                    <type>war</type>
+                                    <overWrite>false</overWrite>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISComponent.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISComponent.java (added)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISComponent.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,47 @@
+/**
+ * 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.cmis;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * Represents the component that manages {@link CMISComponent}.
+ */
+public class CMISComponent extends DefaultComponent {
+
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters)
+        throws Exception {
+        boolean queryMode = removeQueryMode(parameters);
+
+        CMISSessionFacade sessionFacade = new CMISSessionFacade(remaining);
+        setProperties(sessionFacade, parameters);
+        sessionFacade.initSession();
+        CMISEndpoint endpoint = new CMISEndpoint(uri, this, sessionFacade);
+        endpoint.setQueryMode(queryMode);
+        return endpoint;
+    }
+
+    private boolean removeQueryMode(Map<String, Object> parameters) {
+        if (parameters.containsKey("queryMode")) {
+            return Boolean.valueOf((String)parameters.remove("queryMode"));
+        }
+        return false;
+    }
+}

Added: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISConsumer.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISConsumer.java (added)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISConsumer.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,58 @@
+/**
+ * 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.cmis;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.ScheduledPollConsumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The CMIS consumer.
+ */
+public class CMISConsumer extends ScheduledPollConsumer {
+    private static final transient Logger LOG = LoggerFactory.getLogger(CMISConsumer.class);
+    private CMISSessionFacade sessionFacade;
+
+    public CMISConsumer(CMISEndpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+    }
+
+    public CMISConsumer(CMISEndpoint cmisEndpoint, Processor processor, CMISSessionFacade sessionFacade) {
+        this(cmisEndpoint, processor);
+        this.sessionFacade = sessionFacade;
+    }
+
+    @Override
+    protected int poll() throws Exception {
+        return this.sessionFacade.poll(this);
+    }
+
+    int sendExchangeWithPropsAndBody(Map<String, Object> properties, InputStream inputStream)
+        throws Exception {
+        Exchange exchange = getEndpoint().createExchange();
+        exchange.getIn().setHeaders(properties);
+        exchange.getIn().setBody(inputStream);
+        LOG.debug("Polling node : {0}", properties.get("cmis:name"));
+        getProcessor().process(exchange);
+        return 1;
+    }
+}

Added: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISEndpoint.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISEndpoint.java (added)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISEndpoint.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,62 @@
+/**
+ * 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.cmis;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+
+/**
+ * Represents a CMIS endpoint.
+ */
+public class CMISEndpoint extends DefaultEndpoint {
+
+    private CMISSessionFacade sessionFacade;
+    private boolean queryMode;
+
+    public CMISEndpoint() {
+    }
+
+    public CMISEndpoint(String uri, CMISComponent component) {
+        super(uri, component);
+    }
+
+    public CMISEndpoint(String uri, CMISComponent cmisComponent, CMISSessionFacade sessionFacade) {
+        this(uri, cmisComponent);
+        this.sessionFacade = sessionFacade;
+    }
+
+    public Producer createProducer() throws Exception {
+        if (this.queryMode) {
+            return new CMISQueryProducer(this, sessionFacade);
+        }
+        return new CMISProducer(this, sessionFacade);
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        return new CMISConsumer(this, processor, sessionFacade);
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public void setQueryMode(boolean queryMode) {
+        this.queryMode = queryMode;
+    }
+}

Added: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISHelper.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISHelper.java (added)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISHelper.java Wed Jul 18 14:11:35 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.cmis;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Property;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+
+public final class CMISHelper {
+    private CMISHelper() {
+    }
+
+    public static Map<String, Object> filterCMISProperties(Map<String, Object> properties) {
+        Map<String, Object> result = new HashMap<String, Object>(properties.size());
+        for (Map.Entry<String, Object> entry : properties.entrySet()) {
+            if (entry.getKey().startsWith("cmis:")) {
+                result.put(entry.getKey(), entry.getValue());
+            }
+        }
+        return result;
+    }
+
+    public static Map<String, Object> objectProperties(CmisObject cmisObject) {
+        List<Property<?>> propertyList = cmisObject.getProperties();
+        return propertyDataToMap(propertyList);
+    }
+
+    public static Map<String, Object> propertyDataToMap(List<? extends PropertyData<?>> properties) {
+        Map<String, Object> result = new HashMap<String, Object>();
+        for (PropertyData<?> propertyData : properties) {
+            result.put(propertyData.getId(), propertyData.getFirstValue());
+        }
+        return result;
+    }
+
+    public static boolean isFolder(CmisObject cmisObject) {
+        return CamelCMISConstants.CMIS_FOLDER.equals(getObjectTypeId(cmisObject));
+    }
+
+    public static boolean isDocument(CmisObject cmisObject) {
+        return CamelCMISConstants.CMIS_DOCUMENT.equals(getObjectTypeId(cmisObject));
+    }
+
+    public static Object getObjectTypeId(CmisObject child) {
+        return child.getPropertyValue(PropertyIds.OBJECT_TYPE_ID); //BASE_TYPE_ID?
+    }
+
+}
\ No newline at end of file

Added: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java (added)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,155 @@
+/**
+ * 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.cmis;
+
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.NoSuchHeaderException;
+import org.apache.camel.RuntimeExchangeException;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.MessageHelper;
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The CMIS producer.
+ */
+public class CMISProducer extends DefaultProducer {
+    private static final transient Logger LOG = LoggerFactory.getLogger(CMISProducer.class);
+    private final CMISSessionFacade cmisSessionFacade;
+
+    public CMISProducer(CMISEndpoint endpoint, CMISSessionFacade cmisSessionFacade) {
+        super(endpoint);
+        this.cmisSessionFacade = cmisSessionFacade;
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        CmisObject cmisObject = createNode(exchange);
+        exchange.getOut().setBody(cmisObject.getId());
+    }
+
+    private CmisObject createNode(Exchange exchange) throws Exception {
+        validateRequiredHeader(exchange, PropertyIds.NAME);
+
+        Message message = exchange.getIn();
+        String parentFolderPath = parentFolderPathFor(message);
+        Folder parentFolder = getFolderOnPath(exchange, parentFolderPath);
+        Map<String, Object> cmisProperties = CMISHelper.filterCMISProperties(message.getHeaders());
+
+        if (isDocument(exchange)) {
+            String fileName = message.getHeader(PropertyIds.NAME, String.class);
+            String mimeType = getMimeType(message);
+            byte[] buf = getBodyData(message);
+            ContentStream contentStream = cmisSessionFacade.createContentStream(fileName, buf, mimeType);
+            return storeDocument(parentFolder, cmisProperties, contentStream, cmisSessionFacade);
+        } else if (isFolder(message)) {
+            return storeFolder(parentFolder, cmisProperties);
+        } else {  //other types
+            return storeDocument(parentFolder, cmisProperties, null, cmisSessionFacade);
+        }
+    }
+
+    private Folder getFolderOnPath(Exchange exchange, String path) {
+        try {
+            return (Folder)cmisSessionFacade.getObjectByPath(path);
+        } catch (CmisObjectNotFoundException e) {
+            throw new RuntimeExchangeException("Path not found " + path, exchange, e);
+        }
+    }
+
+    private String parentFolderPathFor(Message message) {
+        String customPath = message.getHeader(CamelCMISConstants.CMIS_FOLDER_PATH, String.class);
+        if (customPath != null) {
+            return customPath;
+        }
+
+        if (isFolder(message)) {
+            String path = (String)message.getHeader(PropertyIds.PATH);
+            String name = (String)message.getHeader(PropertyIds.NAME);
+            if (path != null && path.length() > name.length()) {
+                return path.substring(0, path.length() - name.length());
+            }
+        }
+
+        return "/";
+    }
+
+    private boolean isFolder(Message message) {
+        String baseTypeId = message.getHeader(PropertyIds.OBJECT_TYPE_ID, String.class);
+        if (baseTypeId != null) {
+            return baseTypeId.equals(CamelCMISConstants.CMIS_FOLDER);
+        }
+        return message.getBody() == null;
+    }
+
+    private Folder storeFolder(Folder parentFolder, Map<String, Object> cmisProperties) {
+        if (!cmisProperties.containsKey(PropertyIds.OBJECT_TYPE_ID)) {
+            cmisProperties.put(PropertyIds.OBJECT_TYPE_ID, CamelCMISConstants.CMIS_FOLDER);
+        }
+        LOG.debug("Creating folder with properties: {0}", cmisProperties);
+        return parentFolder.createFolder(cmisProperties);
+    }
+
+    private Document storeDocument(Folder parentFolder, Map<String, Object> cmisProperties,
+                                   ContentStream contentStream, CMISSessionFacade cmisSessionFacade) {
+        if (!cmisProperties.containsKey(PropertyIds.OBJECT_TYPE_ID)) {
+            cmisProperties.put(PropertyIds.OBJECT_TYPE_ID, CamelCMISConstants.CMIS_DOCUMENT);
+        }
+
+        VersioningState versioningState = VersioningState.NONE;
+        if (this.cmisSessionFacade
+                .isObjectTypeVersionable((String)cmisProperties.get(PropertyIds.OBJECT_TYPE_ID))) {
+            versioningState = VersioningState.MAJOR;
+        }
+        LOG.debug("Creating document with properties: {0}", cmisProperties);
+        return parentFolder.createDocument(cmisProperties, contentStream, versioningState);
+    }
+
+    private void validateRequiredHeader(Exchange exchange, String name) throws NoSuchHeaderException {
+        ExchangeHelper.getMandatoryHeader(exchange, name, String.class);
+    }
+
+    private boolean isDocument(Exchange exchange) {
+        String baseTypeId = exchange.getIn().getHeader(PropertyIds.OBJECT_TYPE_ID, String.class);
+        if (baseTypeId != null) {
+            return baseTypeId.equals(CamelCMISConstants.CMIS_DOCUMENT);
+        }
+        return exchange.getIn().getBody() != null;
+    }
+
+    private byte[] getBodyData(Message message) {
+        return message.getBody(new byte[0].getClass());
+    }
+
+    private String getMimeType(Message message) throws NoSuchHeaderException {
+        String mimeType = message.getHeader(PropertyIds.CONTENT_STREAM_MIME_TYPE, String.class);
+        if (mimeType == null) {
+            mimeType = MessageHelper.getContentType(message);
+        }
+        return mimeType;
+    }
+}

Added: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java (added)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,53 @@
+/**
+ * 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.cmis;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.chemistry.opencmis.client.api.ItemIterable;
+import org.apache.chemistry.opencmis.client.api.QueryResult;
+
+/**
+ * The CMIS Query producer.
+ */
+public class CMISQueryProducer extends DefaultProducer {
+    private final CMISSessionFacade cmisSessionFacade;
+
+    public CMISQueryProducer(CMISEndpoint endpoint, CMISSessionFacade cmisSessionFacade) {
+        super(endpoint);
+        this.cmisSessionFacade = cmisSessionFacade;
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        List<Map<String, Object>> nodes = executeQuery(exchange);
+        exchange.getOut().setBody(nodes);
+        exchange.getOut().setHeader(CamelCMISConstants.CAMEL_CMIS_RESULT_COUNT, nodes.size());
+    }
+
+    private List<Map<String, Object>> executeQuery(Exchange exchange) throws Exception {
+        String query = exchange.getIn().getMandatoryBody(String.class);
+        boolean retrieveContent = exchange.getIn().getHeader(CamelCMISConstants.CAMEL_CMIS_RETRIEVE_CONTENT,
+                false, Boolean.class);
+        int readSize = exchange.getIn().getHeader(CamelCMISConstants.CAMEL_CMIS_READ_SIZE, 0, Integer.class);
+
+        ItemIterable<QueryResult> itemIterable = cmisSessionFacade.executeQuery(query);
+        return cmisSessionFacade.retrieveResult(retrieveContent, readSize, itemIterable);
+    }
+}

Added: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java (added)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,215 @@
+/**
+ * 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.cmis;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.DocumentType;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.ItemIterable;
+import org.apache.chemistry.opencmis.client.api.OperationContext;
+import org.apache.chemistry.opencmis.client.api.QueryResult;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.client.runtime.ObjectIdImpl;
+import org.apache.chemistry.opencmis.client.runtime.OperationContextImpl;
+import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CMISSessionFacade {
+    private static final transient Logger LOG = LoggerFactory.getLogger(CMISSessionFacade.class);
+    private final String url;
+    private int pageSize = 100;
+    private int readCount;
+    private boolean readContent;
+    private String username;
+    private String password;
+    private String repositoryId;
+    private String query;
+    private Session session;
+
+    public CMISSessionFacade(String url) {
+        this.url = url;
+    }
+
+    void initSession() {
+        Map<String, String> parameter = new HashMap<String, String>();
+        parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
+        parameter.put(SessionParameter.ATOMPUB_URL, this.url);
+        parameter.put(SessionParameter.USER, this.username);
+        parameter.put(SessionParameter.PASSWORD, this.password);
+        if (this.repositoryId != null) {
+            parameter.put(SessionParameter.REPOSITORY_ID, this.repositoryId);
+            this.session = SessionFactoryImpl.newInstance().createSession(parameter);
+        } else {
+            this.session = SessionFactoryImpl.newInstance().getRepositories(parameter).get(0).createSession();
+        }
+    }
+
+    public int poll(CMISConsumer cmisConsumer) throws Exception {
+        if (query != null) {
+            return pollWithQuery(cmisConsumer);
+        }
+        return pollTree(cmisConsumer);
+    }
+
+    private int pollTree(CMISConsumer cmisConsumer) throws Exception {
+        Folder rootFolder = session.getRootFolder();
+        RecursiveTreeWalker treeWalker = new RecursiveTreeWalker(cmisConsumer, readContent, readCount,
+                pageSize);
+        return treeWalker.processFolderRecursively(rootFolder);
+    }
+
+    private int pollWithQuery(CMISConsumer cmisConsumer) throws Exception {
+        int count = 0;
+        int pageNumber = 0;
+        boolean finished = false;
+        ItemIterable<QueryResult> itemIterable = executeQuery(query);
+        while (!finished) {
+            ItemIterable<QueryResult> currentPage = itemIterable.skipTo(count).getPage();
+            LOG.debug("Processing page {0}", pageNumber);
+            for (QueryResult item : currentPage) {
+                Map<String, Object> properties = CMISHelper.propertyDataToMap(item.getProperties());
+                Object objectTypeId = item.getPropertyValueById(PropertyIds.OBJECT_TYPE_ID);
+                InputStream inputStream = null;
+                if (readContent && CamelCMISConstants.CMIS_DOCUMENT.equals(objectTypeId)) {
+                    inputStream = getContentStreamFor(item);
+                }
+
+                cmisConsumer.sendExchangeWithPropsAndBody(properties, inputStream);
+                count++;
+                if (count == readCount) {
+                    finished = true;
+                    break;
+                }
+            }
+            pageNumber++;
+            if (!currentPage.getHasMoreItems()) {
+                finished = true;
+            }
+        }
+        return count;
+    }
+
+    //some duplication
+    public List<Map<String, Object>> retrieveResult(boolean retrieveContent, int readSize,
+                                                    ItemIterable<QueryResult> itemIterable) {
+        List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
+        int count = 0;
+        int pageNumber = 0;
+        boolean finished = false;
+        while (!finished) {
+            ItemIterable<QueryResult> currentPage = itemIterable.skipTo(count).getPage();
+            LOG.debug("Processing page {0}", pageNumber);
+            for (QueryResult item : currentPage) {
+                Map<String, Object> properties = CMISHelper.propertyDataToMap(item.getProperties());
+                if (retrieveContent) {
+                    InputStream inputStream = getContentStreamFor(item);
+                    properties.put(CamelCMISConstants.CAMEL_CMIS_CONTENT_STREAM, inputStream);
+                }
+
+                result.add(properties);
+                count++;
+                if (count == readSize) {
+                    finished = true;
+                    break;
+                }
+            }
+            pageNumber++;
+            if (!currentPage.getHasMoreItems()) {
+                finished = true;
+            }
+        }
+        return result;
+    }
+
+    public ItemIterable<QueryResult> executeQuery(String query) {
+        OperationContext operationContext = new OperationContextImpl();
+        operationContext.setMaxItemsPerPage(pageSize);
+        return session.query(query, false, operationContext);
+    }
+
+    public Document getDocument(QueryResult queryResult) {
+        if (CamelCMISConstants.CMIS_DOCUMENT
+                .equals(queryResult.getPropertyValueById(PropertyIds.OBJECT_TYPE_ID))) {
+            String objectId = (String)queryResult.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue();
+            ObjectIdImpl objectIdImpl = new ObjectIdImpl(objectId);
+            return (org.apache.chemistry.opencmis.client.api.Document)session.getObject(objectIdImpl);
+        }
+        return null;
+    }
+
+    public InputStream getContentStreamFor(QueryResult item) {
+        Document document = getDocument(item);
+        if (document != null && document.getContentStream() != null) {
+            return document.getContentStream().getStream();
+        }
+        return null;
+    }
+
+    public CmisObject getObjectByPath(String path) {
+        return session.getObjectByPath(path);
+    }
+
+    public boolean isObjectTypeVersionable(String objectType) {
+        return ((DocumentType)session.getTypeDefinition(objectType)).isVersionable();
+    }
+
+    public ContentStream createContentStream(String fileName, byte[] buf, String mimeType) throws Exception {
+        return buf != null ? session.getObjectFactory()
+                .createContentStream(fileName, buf.length, mimeType, new ByteArrayInputStream(buf)) : null;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void setRepositoryId(String repositoryId) {
+        this.repositoryId = repositoryId;
+    }
+
+    public void setReadContent(boolean readContent) {
+        this.readContent = readContent;
+    }
+
+    public void setReadCount(int readCount) {
+        this.readCount = readCount;
+    }
+
+    public void setQuery(String query) {
+        this.query = query;
+    }
+
+    public void setPageSize(int pageSize) {
+        this.pageSize = pageSize;
+    }
+}

Added: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CamelCMISConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CamelCMISConstants.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CamelCMISConstants.java (added)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CamelCMISConstants.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,28 @@
+/**
+ * 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.cmis;
+
+public interface CamelCMISConstants {
+    String CMIS_DOCUMENT = "cmis:document";
+    String CMIS_FOLDER = "cmis:folder";
+    String CMIS_FOLDER_PATH = "CamelCMISFolderPath";
+    String CMIS_MIME_TYPE = "CamelCMISMimeType";
+    String CAMEL_CMIS_RESULT_COUNT = "CamelCMISResultCount";
+    String CAMEL_CMIS_RETRIEVE_CONTENT = "CamelCMISRetrieveContent";
+    String CAMEL_CMIS_READ_SIZE = "CamelCMISReadSize";
+    String CAMEL_CMIS_CONTENT_STREAM = "CamelCMISContent";
+}

Added: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/RecursiveTreeWalker.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/RecursiveTreeWalker.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/RecursiveTreeWalker.java (added)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/RecursiveTreeWalker.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,104 @@
+/**
+ * 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.cmis;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.ItemIterable;
+import org.apache.chemistry.opencmis.client.api.OperationContext;
+import org.apache.chemistry.opencmis.client.runtime.OperationContextImpl;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RecursiveTreeWalker {
+    private static final transient Logger LOG = LoggerFactory.getLogger(RecursiveTreeWalker.class);
+
+    private final CMISConsumer cmisConsumer;
+    private final boolean readContent;
+    private final int readCount;
+    private final int pageSize;
+    private int totalPolled;
+
+    public RecursiveTreeWalker(CMISConsumer cmisConsumer, boolean readContent, int readCount, int pageSize) {
+        this.cmisConsumer = cmisConsumer;
+        this.readContent = readContent;
+        this.readCount = readCount;
+        this.pageSize = pageSize;
+    }
+
+    int processFolderRecursively(Folder folder) throws Exception {
+        processFolderNode(folder);
+
+        OperationContext operationContext = new OperationContextImpl();
+        operationContext.setMaxItemsPerPage(pageSize);
+
+        int count = 0;
+        int pageNumber = 0;
+        boolean finished = false;
+        ItemIterable<CmisObject> itemIterable = folder.getChildren(operationContext);
+        while (!finished) {
+            ItemIterable<CmisObject> currentPage = itemIterable.skipTo(count).getPage();
+            LOG.debug("Processing page {0}", pageNumber);
+            for (CmisObject child : currentPage) {
+                if (CMISHelper.isFolder(child)) {
+                    Folder childFolder = (Folder)child;
+                    processFolderRecursively(childFolder);
+                } else {
+                    processNonFolderNode(child, folder);
+                }
+
+                count++;
+                if (totalPolled == readCount) {
+                    finished = true;
+                    break;
+                }
+            }
+            pageNumber++;
+            if (!currentPage.getHasMoreItems()) {
+                finished = true;
+            }
+        }
+
+        return totalPolled;
+    }
+
+    private void processNonFolderNode(CmisObject cmisObject, Folder parentFolder) throws Exception {
+        InputStream inputStream = null;
+        Map<String, Object> properties = CMISHelper.objectProperties(cmisObject);
+        properties.put(CamelCMISConstants.CMIS_FOLDER_PATH, parentFolder.getPath());
+        if (CMISHelper.isDocument(cmisObject) && readContent) {
+            ContentStream contentStream = ((Document)cmisObject).getContentStream();
+            if (contentStream != null) {
+                inputStream = contentStream.getStream();
+            }
+        }
+        sendNode(properties, inputStream);
+    }
+
+    private void processFolderNode(Folder folder) throws Exception {
+        sendNode(CMISHelper.objectProperties(folder), null);
+    }
+
+    private void sendNode(Map<String, Object> properties, InputStream inputStream) throws Exception {
+        totalPolled += cmisConsumer.sendExchangeWithPropsAndBody(properties, inputStream);
+    }
+}

Added: camel/trunk/components/camel-cmis/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/resources/META-INF/LICENSE.txt?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/resources/META-INF/LICENSE.txt (added)
+++ camel/trunk/components/camel-cmis/src/main/resources/META-INF/LICENSE.txt Wed Jul 18 14:11:35 2012
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
+

Added: camel/trunk/components/camel-cmis/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/resources/META-INF/NOTICE.txt?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/resources/META-INF/NOTICE.txt (added)
+++ camel/trunk/components/camel-cmis/src/main/resources/META-INF/NOTICE.txt Wed Jul 18 14:11:35 2012
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

Added: camel/trunk/components/camel-cmis/src/main/resources/META-INF/services/org/apache/camel/component/cmis
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/resources/META-INF/services/org/apache/camel/component/cmis?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/resources/META-INF/services/org/apache/camel/component/cmis (added)
+++ camel/trunk/components/camel-cmis/src/main/resources/META-INF/services/org/apache/camel/component/cmis Wed Jul 18 14:11:35 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.cmis.CMISComponent

Added: camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISConsumerTest.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISConsumerTest.java (added)
+++ camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISConsumerTest.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,104 @@
+/**
+ * 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.componenet.cmis;
+
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CMISConsumerTest extends CMISTestSupport {
+
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint resultEndpoint;
+
+    @Test
+    public void getAllContentFromServerOrderedFromRootToLeaves() throws Exception {
+        resultEndpoint.expectedMessageCount(5);
+
+        Consumer treeBasedConsumer = createConsumerFor(CMIS_ENDPOINT_TEST_SERVER);
+        treeBasedConsumer.start();
+
+        resultEndpoint.assertIsSatisfied();
+        treeBasedConsumer.stop();
+
+        List<Exchange> exchanges = resultEndpoint.getExchanges();
+        assertTrue(getNodeNameForIndex(exchanges, 0).equals("RootFolder"));
+        assertTrue(getNodeNameForIndex(exchanges, 1).equals("Folder1"));
+        assertTrue(getNodeNameForIndex(exchanges, 2).equals("Folder2"));
+        assertTrue(getNodeNameForIndex(exchanges, 3).contains(".txt"));
+        assertTrue(getNodeNameForIndex(exchanges, 4).contains(".txt"));
+    }
+
+    @Test
+    public void consumeDocumentsWithQuery() throws Exception {
+        resultEndpoint.expectedMessageCount(2);
+
+        Consumer queryBasedConsumer = createConsumerFor(
+                CMIS_ENDPOINT_TEST_SERVER + "?query=SELECT * FROM cmis:document");
+        queryBasedConsumer.start();
+        resultEndpoint.assertIsSatisfied();
+        queryBasedConsumer.stop();
+    }
+
+    private Consumer createConsumerFor(String path) throws Exception {
+        Endpoint endpoint = context.getEndpoint("cmis://" + path);
+        return endpoint.createConsumer(new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                template.send("mock:result", exchange);
+            }
+        });
+    }
+
+    private String getNodeNameForIndex(List<Exchange> exchanges, int index) {
+        return exchanges.get(index).getIn().getHeader("cmis:name", String.class);
+    }
+
+    private void populateRepositoryRootFolderWithTwoFoldersAndTwoDocuments()
+        throws UnsupportedEncodingException {
+        Folder folder1 = createFolderWithName("Folder1");
+        Folder folder2 = createChildFolderWithName(folder1, "Folder2");
+        createTextDocument(folder2, "Document2.1", "2.1.txt");
+        createTextDocument(folder2, "Document2.2", "2.2.txt");
+        //L0              ROOT
+        //                |
+        //L1            Folder1
+        //L2              |_____Folder2
+        //                        ||
+        //L3            Doc2.1___||___Doc2.2
+    }
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        populateRepositoryRootFolderWithTwoFoldersAndTwoDocuments();
+    }
+}

Added: camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISProducerTest.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISProducerTest.java (added)
+++ camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISProducerTest.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,182 @@
+/**
+ * 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.componenet.cmis;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.NoSuchHeaderException;
+import org.apache.camel.Produce;
+import org.apache.camel.Producer;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ResolveEndpointFailedException;
+import org.apache.camel.RuntimeExchangeException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cmis.CamelCMISConstants;
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.junit.Test;
+
+public class CMISProducerTest extends CMISTestSupport {
+
+    @Produce(uri = "direct:start")
+    protected ProducerTemplate template;
+
+    @Test
+    public void storeMessageBodyAsTextDocument() throws Exception {
+        String content = "Some content to be store";
+        Exchange exchange = createExchangeWithInBody(content);
+        exchange.getIn().getHeaders().put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
+        exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.file");
+
+        template.send(exchange);
+
+        String newNodeId = exchange.getOut().getBody(String.class);
+        assertNotNull(newNodeId);
+
+        String newNodeContent = getDocumentContentAsString(newNodeId);
+        assertEquals(content, newNodeContent);
+    }
+
+    @Test
+    public void getDocumentMimeTypeFromMessageContentType() throws Exception {
+        Exchange exchange = createExchangeWithInBody("Some content to be store");
+        exchange.getIn().getHeaders().put(Exchange.CONTENT_TYPE, "text/plain");
+        exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.file");
+
+        template.send(exchange);
+        String newNodeId = exchange.getOut().getBody(String.class);
+
+        CmisObject cmisObject = retrieveCMISObjectByIdFromServer(newNodeId);
+        Document doc = (Document)cmisObject;
+        assertEquals("text/plain", doc.getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE));
+    }
+
+    @Test
+    public void namePropertyIsAlwaysRequired() {
+        Exchange exchange = createExchangeWithInBody("Some content that will fail to be stored");
+        exchange.getIn().getHeaders().put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
+
+        template.send(exchange);
+        Exception exception = exchange.getException();
+        Object body = exchange.getOut().getBody();
+
+        assertNull(body);
+        assertTrue(exception instanceof NoSuchHeaderException);
+    }
+
+    @Test
+    public void createDocumentWithoutContentByExplicitlySpecifyingObjectTypeHeader() throws Exception {
+        Exchange exchange = createExchangeWithInBody(null);
+        exchange.getIn().getHeaders().put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
+        exchange.getIn().getHeaders().put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
+        exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.file");
+
+        template.send(exchange);
+        String newNodeId = exchange.getOut().getBody(String.class);
+        assertNotNull(newNodeId);
+
+        CmisObject cmisObject = retrieveCMISObjectByIdFromServer(newNodeId);
+        Document doc = (Document)cmisObject;
+        assertEquals("cmis:document", doc.getPropertyValue(PropertyIds.OBJECT_TYPE_ID));
+    }
+
+    @Test
+    public void emptyBodyAndMissingObjectTypeHeaderCreatesFolderNode() throws Exception {
+        Exchange exchange = createExchangeWithInBody(null);
+        exchange.getIn().getHeaders().put(PropertyIds.NAME, "testFolder");
+
+        template.send(exchange);
+        String newNodeId = exchange.getOut().getBody(String.class);
+        assertNotNull(newNodeId);
+
+        CmisObject newNode = retrieveCMISObjectByIdFromServer(newNodeId);
+        assertEquals("cmis:folder", newNode.getType().getId());
+        assertTrue(newNode instanceof Folder);
+    }
+
+    @Test
+    public void cmisPropertiesAreStored() throws Exception {
+        Exchange exchange = createExchangeWithInBody("Some content to be store");
+        exchange.getIn().getHeaders().put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
+        exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.txt");
+
+        template.send(exchange);
+        String newNodeId = exchange.getOut().getBody(String.class);
+        CmisObject newNode = retrieveCMISObjectByIdFromServer(newNodeId);
+
+        assertEquals("test.txt", newNode.getPropertyValue(PropertyIds.NAME));
+        assertEquals("text/plain; charset=UTF-8",
+                newNode.getPropertyValue(PropertyIds.CONTENT_STREAM_MIME_TYPE));
+    }
+
+    @Test(expected = ResolveEndpointFailedException.class)
+    public void failConnectingToNonExistingRepository() throws Exception {
+        Endpoint endpoint = context.getEndpoint("cmis://" + CMIS_ENDPOINT_TEST_SERVER
+                + "?username=admin&password=admin&repositoryId=NON_EXISTING_ID");
+        Producer producer = endpoint.createProducer();
+
+        Exchange exchange = createExchangeWithInBody("Some content to be store");
+        exchange.getIn().getHeaders().put(CamelCMISConstants.CMIS_MIME_TYPE, "text/plain; charset=UTF-8");
+        exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.txt");
+        producer.process(exchange);
+    }
+
+    @Test
+    public void createDocumentAtSpecificPath() throws Exception {
+        Folder folder1 = createFolderWithName("Folder1");
+        createChildFolderWithName(folder1, "Folder2");
+        String existingFolderStructure = "/Folder1/Folder2";
+
+        Exchange exchange = createExchangeWithInBody("Some content to be stored");
+        exchange.getIn().getHeaders().put(PropertyIds.CONTENT_STREAM_MIME_TYPE, "text/plain; charset=UTF-8");
+        exchange.getIn().getHeaders().put(PropertyIds.NAME, "test.file");
+        exchange.getIn().getHeaders().put(CamelCMISConstants.CMIS_FOLDER_PATH, existingFolderStructure);
+
+        template.send(exchange);
+        String newNodeId = exchange.getOut().getBody(String.class);
+
+        Document document = (Document)retrieveCMISObjectByIdFromServer(newNodeId);
+        String documentFullPath = document.getPaths().get(0);
+        assertEquals(existingFolderStructure + "/test.file", documentFullPath);
+    }
+
+    @Test
+    public void failCreatingFolderAtNonExistingPath() throws Exception {
+        String existingFolderStructure = "/No/Path/Here";
+
+        Exchange exchange = createExchangeWithInBody(null);
+        exchange.getIn().getHeaders().put(PropertyIds.NAME, "folder1");
+        exchange.getIn().getHeaders().put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
+        exchange.getIn().getHeaders().put(CamelCMISConstants.CMIS_FOLDER_PATH, existingFolderStructure);
+
+        template.send(exchange);
+        assertTrue(exchange.getException() instanceof RuntimeExchangeException);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start")
+                        .to("cmis://" + CMIS_ENDPOINT_TEST_SERVER);
+            }
+        };
+    }
+
+}

Added: camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISQueryProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISQueryProducerTest.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISQueryProducerTest.java (added)
+++ camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISQueryProducerTest.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,109 @@
+/**
+ * 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.componenet.cmis;
+
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.junit.Before;
+import org.junit.Test;
+
+public class CMISQueryProducerTest extends CMISTestSupport {
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        populateServerWithContent();
+    }
+
+    @Test
+    public void queryServerForDocumentWithSpecificName() throws Exception {
+        Endpoint endpoint = context.getEndpoint("cmis://" + CMIS_ENDPOINT_TEST_SERVER + "?queryMode=true");
+        Producer producer = endpoint.createProducer();
+
+        Exchange exchange = createExchangeWithInBody(
+                "SELECT * FROM cmis:document WHERE cmis:name = 'test1.txt'");
+        producer.process(exchange);
+
+        @SuppressWarnings("unchecked")
+        List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
+        assertEquals(1, documents.size());
+        assertEquals("test1.txt", documents.get(0).get("cmis:name"));
+    }
+
+    @Test
+    public void getResultCountFromHeader() throws Exception {
+        Endpoint endpoint = context.getEndpoint("cmis://" + CMIS_ENDPOINT_TEST_SERVER + "?queryMode=true");
+        Producer producer = endpoint.createProducer();
+
+        Exchange exchange = createExchangeWithInBody(
+                "SELECT * FROM cmis:document WHERE CONTAINS('Camel test content.')");
+        producer.process(exchange);
+
+        @SuppressWarnings("unchecked")
+        List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
+        assertEquals(2, documents.size());
+        assertEquals(2, exchange.getOut().getHeader("CamelCMISResultCount"));
+    }
+
+    @Test
+    public void limitNumberOfResultsWithReadSizeHeader() throws Exception {
+        Endpoint endpoint = context.getEndpoint("cmis://" + CMIS_ENDPOINT_TEST_SERVER + "?queryMode=true");
+        Producer producer = endpoint.createProducer();
+
+        Exchange exchange = createExchangeWithInBody(
+                "SELECT * FROM cmis:document WHERE CONTAINS('Camel test content.')");
+        exchange.getIn().getHeaders().put("CamelCMISReadSize", 1);
+
+        producer.process(exchange);
+
+        @SuppressWarnings("unchecked")
+        List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
+        assertEquals(1, documents.size());
+    }
+
+    @Test
+    public void retrieveAlsoDocumentContent() throws Exception {
+        Endpoint endpoint = context.getEndpoint("cmis://" + CMIS_ENDPOINT_TEST_SERVER + "?queryMode=true");
+        Producer producer = endpoint.createProducer();
+
+        Exchange exchange = createExchangeWithInBody(
+                "SELECT * FROM cmis:document WHERE cmis:name='test1.txt'");
+        exchange.getIn().getHeaders().put("CamelCMISRetrieveContent", true);
+
+        producer.process(exchange);
+
+        @SuppressWarnings("unchecked")
+        List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
+        InputStream content = (InputStream)documents.get(0).get("CamelCMISContent");
+        assertEquals("This is the first Camel test content.", readFromStream(content));
+    }
+
+    private void populateServerWithContent() throws UnsupportedEncodingException {
+        Folder newFolder = createFolderWithName("CamelCmisTestFolder");
+        createTextDocument(newFolder, "This is the first Camel test content.", "test1.txt");
+        createTextDocument(newFolder, "This is the second Camel test content.", "test2.txt");
+    }
+
+}

Added: camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISTestSupport.java?rev=1362958&view=auto
==============================================================================
--- camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISTestSupport.java (added)
+++ camel/trunk/components/camel-cmis/src/test/java/org/apache/camel/componenet/cmis/CMISTestSupport.java Wed Jul 18 14:11:35 2012
@@ -0,0 +1,165 @@
+/**
+ * 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.componenet.cmis;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.ItemIterable;
+import org.apache.chemistry.opencmis.client.api.Repository;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.client.api.SessionFactory;
+import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+public class CMISTestSupport extends CamelTestSupport {
+    protected static final String CMIS_ENDPOINT_TEST_SERVER
+        = "http://localhost:9090/chemistry-opencmis-server-inmemory/atom";
+    protected static final String OPEN_CMIS_SERVER_WAR_PATH
+        = "target/dependency/chemistry-opencmis-server-inmemory-0.7.0.war";
+
+    protected static Server cmisServer;
+
+    protected Exchange createExchangeWithInBody(String body) {
+        DefaultExchange exchange = new DefaultExchange(context);
+        if (body != null) {
+            exchange.getIn().setBody(body);
+        }
+        return exchange;
+    }
+
+    protected CmisObject retrieveCMISObjectByIdFromServer(String nodeId) throws Exception {
+        Session session = createSession();
+        return session.getObject(nodeId);
+    }
+
+    protected void deleteAllContent() {
+        Session session = createSession();
+        Folder rootFolder = session.getRootFolder();
+        ItemIterable<CmisObject> children = rootFolder.getChildren();
+        for (CmisObject cmisObject : children) {
+            if ("cmis:folder".equals(cmisObject.getPropertyValue(PropertyIds.OBJECT_TYPE_ID))) {
+                List<String> notDeltedIdList = ((Folder)cmisObject)
+                        .deleteTree(true, UnfileObject.DELETE, true);
+                if (notDeltedIdList != null && notDeltedIdList.size() > 0) {
+                    throw new RuntimeException("Cannot empty repo");
+                }
+            } else {
+                cmisObject.delete(true);
+            }
+        }
+        session.getBinding().close();
+    }
+
+    protected Session createSession() {
+        SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
+        Map<String, String> parameter = new HashMap<String, String>();
+        parameter.put(SessionParameter.ATOMPUB_URL, CMIS_ENDPOINT_TEST_SERVER);
+        parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
+
+        Repository repository = sessionFactory.getRepositories(parameter).get(0);
+        return repository.createSession();
+    }
+
+    protected String getDocumentContentAsString(String nodeId) throws Exception {
+        CmisObject cmisObject = retrieveCMISObjectByIdFromServer(nodeId);
+        Document doc = (Document)cmisObject;
+        InputStream inputStream = doc.getContentStream().getStream();
+        return readFromStream(inputStream);
+    }
+
+    protected String readFromStream(InputStream in) throws Exception {
+        StringBuilder result = new StringBuilder();
+        BufferedReader br = new BufferedReader(new InputStreamReader(in));
+
+        String strLine;
+        while ((strLine = br.readLine()) != null) {
+            result.append(strLine);
+        }
+        in.close();
+        return result.toString();
+    }
+
+    protected Folder createFolderWithName(String folderName) {
+        Folder rootFolder = createSession().getRootFolder();
+        return createChildFolderWithName(rootFolder, folderName);
+    }
+
+    protected Folder createChildFolderWithName(Folder parent, String childName) {
+        Map<String, String> newFolderProps = new HashMap<String, String>();
+        newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
+        newFolderProps.put(PropertyIds.NAME, childName);
+        return parent.createFolder(newFolderProps);
+    }
+
+    protected void createTextDocument(Folder newFolder, String content, String fileName)
+        throws UnsupportedEncodingException {
+        byte[] buf = content.getBytes("UTF-8");
+        ByteArrayInputStream input = new ByteArrayInputStream(buf);
+        ContentStream contentStream = createSession().getObjectFactory()
+                .createContentStream(fileName, buf.length, "text/plain; charset=UTF-8", input);
+
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
+        properties.put(PropertyIds.NAME, fileName);
+        newFolder.createDocument(properties, contentStream, VersioningState.NONE);
+    }
+
+    @BeforeClass
+    public static void startServer() throws Exception {
+        cmisServer = new Server(9090);
+        WebAppContext openCmisServerApi = new WebAppContext(OPEN_CMIS_SERVER_WAR_PATH,
+                "/chemistry-opencmis-server-inmemory");
+        cmisServer.addHandler(openCmisServerApi);
+        cmisServer.start();
+    }
+
+    @AfterClass
+    public static void stopServer() throws Exception {
+        cmisServer.stop();
+    }
+
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        deleteAllContent();
+        super.setUp();
+    }
+
+}