Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DE912200BED for ; Sun, 1 Jan 2017 17:06:53 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id DD0E6160B41; Sun, 1 Jan 2017 16:06:53 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 84B59160B38 for ; Sun, 1 Jan 2017 17:06:52 +0100 (CET) Received: (qmail 16972 invoked by uid 500); 1 Jan 2017 16:06:51 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 16953 invoked by uid 99); 1 Jan 2017 16:06:51 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Jan 2017 16:06:51 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7EBD5DFC64; Sun, 1 Jan 2017 16:06:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Sun, 01 Jan 2017 16:06:52 -0000 Message-Id: <02e29af271164bfb9cb0903ab4291d12@git.apache.org> In-Reply-To: <3ec4c94c671449559d056c4517647947@git.apache.org> References: <3ec4c94c671449559d056c4517647947@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] camel git commit: CAMEL-10663: Fixed camel-cmis did not work when any session facade option was in use. Also fixed so they are included in component docs archived-at: Sun, 01 Jan 2017 16:06:54 -0000 CAMEL-10663: Fixed camel-cmis did not work when any session facade option was in use. Also fixed so they are included in component docs Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/54264a08 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/54264a08 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/54264a08 Branch: refs/heads/camel-2.18.x Commit: 54264a084bb12c459df078b39d269c3cf1286629 Parents: 7cad1de Author: Claus Ibsen Authored: Sun Jan 1 17:02:03 2017 +0100 Committer: Claus Ibsen Committed: Sun Jan 1 17:06:32 2017 +0100 ---------------------------------------------------------------------- .../CMISComponentAutoConfiguration.java | 106 +++++++++++++++++++ .../springboot/CMISComponentConfiguration.java | 47 ++++++++ ...dditional-spring-configuration-metadata.json | 10 ++ .../main/resources/META-INF/spring.factories | 19 ++++ .../src/main/docs/cmis-component.adoc | 24 ++++- .../camel/component/cmis/CMISComponent.java | 43 ++++---- .../camel/component/cmis/CMISConsumer.java | 9 +- .../camel/component/cmis/CMISEndpoint.java | 64 +++++++++-- .../camel/component/cmis/CMISProducer.java | 7 +- .../camel/component/cmis/CMISQueryProducer.java | 8 +- .../camel/component/cmis/CMISSessionFacade.java | 6 +- .../cmis/CMISSessionFacadeFactory.java | 4 +- .../cmis/DefaultCMISSessionFacadeFactory.java | 38 +++++++ .../camel/component/cmis/CMISConsumerTest.java | 2 +- 14 files changed, 346 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentAutoConfiguration.java b/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentAutoConfiguration.java new file mode 100644 index 0000000..a5a9d90 --- /dev/null +++ b/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentAutoConfiguration.java @@ -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.cmis.springboot; + +import java.util.HashMap; +import java.util.Map; +import org.apache.camel.CamelContext; +import org.apache.camel.component.cmis.CMISComponent; +import org.apache.camel.util.IntrospectionSupport; +import org.springframework.boot.autoconfigure.condition.ConditionMessage; +import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.SpringBootCondition; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.core.type.AnnotatedTypeMetadata; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Configuration +@EnableConfigurationProperties(CMISComponentConfiguration.class) +@Conditional(CMISComponentAutoConfiguration.Condition.class) +public class CMISComponentAutoConfiguration { + + @Lazy + @Bean(name = "cmis-component") + @ConditionalOnClass(CamelContext.class) + @ConditionalOnMissingBean(CMISComponent.class) + public CMISComponent configureCMISComponent(CamelContext camelContext, + CMISComponentConfiguration configuration) throws Exception { + CMISComponent component = new CMISComponent(); + component.setCamelContext(camelContext); + Map parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); + return component; + } + + public static class Condition extends SpringBootCondition { + @Override + public ConditionOutcome getMatchOutcome( + ConditionContext conditionContext, + AnnotatedTypeMetadata annotatedTypeMetadata) { + boolean groupEnabled = isEnabled(conditionContext, + "camel.component.", true); + ConditionMessage.Builder message = ConditionMessage + .forCondition("camel.component.cmis"); + if (isEnabled(conditionContext, "camel.component.cmis.", + groupEnabled)) { + return ConditionOutcome.match(message.because("enabled")); + } + return ConditionOutcome.noMatch(message.because("not enabled")); + } + + private boolean isEnabled( + org.springframework.context.annotation.ConditionContext context, + java.lang.String prefix, boolean defaultValue) { + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( + context.getEnvironment(), prefix); + return resolver.getProperty("enabled", Boolean.class, defaultValue); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentConfiguration.java b/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentConfiguration.java new file mode 100644 index 0000000..651eac1 --- /dev/null +++ b/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentConfiguration.java @@ -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.springboot; + +import org.apache.camel.component.cmis.CMISSessionFacadeFactory; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +/** + * The cmis component uses the Apache Chemistry client API and allows you to + * add/read nodes to/from a CMIS compliant content repositories. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@ConfigurationProperties(prefix = "camel.component.cmis") +public class CMISComponentConfiguration { + + /** + * To use a custom CMISSessionFacadeFactory to create the CMISSessionFacade + * instances + */ + @NestedConfigurationProperty + private CMISSessionFacadeFactory sessionFacadeFactory; + + public CMISSessionFacadeFactory getSessionFacadeFactory() { + return sessionFacadeFactory; + } + + public void setSessionFacadeFactory( + CMISSessionFacadeFactory sessionFacadeFactory) { + this.sessionFacadeFactory = sessionFacadeFactory; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components-starter/camel-cmis-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json ---------------------------------------------------------------------- diff --git a/components-starter/camel-cmis-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/components-starter/camel-cmis-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 0000000..1885d4e --- /dev/null +++ b/components-starter/camel-cmis-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,10 @@ +{ + "properties": [ + { + "defaultValue": true, + "name": "camel.component.cmis.enabled", + "description": "Enable cmis component", + "type": "java.lang.Boolean" + } + ] +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components-starter/camel-cmis-starter/src/main/resources/META-INF/spring.factories ---------------------------------------------------------------------- diff --git a/components-starter/camel-cmis-starter/src/main/resources/META-INF/spring.factories b/components-starter/camel-cmis-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..56d8aca --- /dev/null +++ b/components-starter/camel-cmis-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,19 @@ +# +# 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. +# + +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +org.apache.camel.component.cmis.springboot.CMISComponentAutoConfiguration http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components/camel-cmis/src/main/docs/cmis-component.adoc ---------------------------------------------------------------------- diff --git a/components/camel-cmis/src/main/docs/cmis-component.adoc b/components/camel-cmis/src/main/docs/cmis-component.adoc index 8c21af5..1c0e410 100644 --- a/components/camel-cmis/src/main/docs/cmis-component.adoc +++ b/components/camel-cmis/src/main/docs/cmis-component.adoc @@ -26,24 +26,42 @@ CMIS Options // component options: START -The CMIS component has no options. +The CMIS component supports 1 options which are listed below. + + + +{% raw %} +[width="100%",cols="2,1m,7",options="header"] +|======================================================================= +| Name | Java Type | Description +| sessionFacadeFactory | CMISSessionFacadeFactory | To use a custom CMISSessionFacadeFactory to create the CMISSessionFacade instances +|======================================================================= +{% endraw %} // component options: END // endpoint options: START -The CMIS component supports 6 endpoint options which are listed below: +The CMIS component supports 14 endpoint options which are listed below: {% raw %} [width="100%",cols="2,1,1m,1m,5",options="header"] |======================================================================= | Name | Group | Default | Java Type | Description -| url | common | | String | *Required* the cmis url +| cmsUrl | common | | String | *Required* URL to the cmis repository +| pageSize | common | 100 | int | Number of nodes to retrieve per page +| readContent | common | false | boolean | If set to true the content of document node will be retrieved in addition to the properties +| readCount | common | | int | Max number of nodes to read +| repositoryId | common | | String | The Id of the repository to use. If not specified the first available repository is used | bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored. +| query | consumer | | String | The cmis query to execute against the repository. If not specified the consumer will retrieve every node from the content repository by iterating the content tree recursively | exceptionHandler | consumer (advanced) | | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. | exchangePattern | consumer (advanced) | | ExchangePattern | Sets the exchange pattern when the consumer creates an exchange. | queryMode | producer | false | boolean | If true will execute the cmis query from the message body and return result otherwise will create a node in the cmis repository +| sessionFacadeFactory | advanced | | CMISSessionFacadeFactory | To use a custom CMISSessionFacadeFactory to create the CMISSessionFacade instances | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). +| password | security | | String | Password for the cmis repository +| username | security | | String | Username for the cmis repository |======================================================================= {% endraw %} // endpoint options: END http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISComponent.java b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISComponent.java index ba6ece2..b6acaa6 100644 --- a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISComponent.java +++ b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISComponent.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.cmis; +import java.util.HashMap; import java.util.Map; import org.apache.camel.Endpoint; @@ -26,35 +27,41 @@ import org.apache.camel.impl.UriEndpointComponent; */ public class CMISComponent extends UriEndpointComponent { + private CMISSessionFacadeFactory sessionFacadeFactory; + public CMISComponent() { super(CMISEndpoint.class); } protected Endpoint createEndpoint(String uri, final String remaining, final Map parameters) throws Exception { - boolean queryMode = removeQueryMode(parameters); - - CMISSessionFacade sessionFacade = new CMISSessionFacade(remaining); - setProperties(sessionFacade, parameters); + CMISEndpoint endpoint = new CMISEndpoint(uri, this, remaining); - CMISEndpoint endpoint = new CMISEndpoint(uri, this, new CMISSessionFacadeFactory() { - @Override - public CMISSessionFacade create() throws Exception { - CMISSessionFacade sessionFacade = new CMISSessionFacade(remaining); - setProperties(sessionFacade, parameters); + // create a copy of parameters which we need to store on the endpoint which are in use from the session factory + Map copy = new HashMap<>(parameters); + endpoint.setProperties(copy); + if (sessionFacadeFactory != null) { + endpoint.setSessionFacadeFactory(sessionFacadeFactory); + } - return sessionFacade; - } - }); + // create a dummy CMISSessionFacade which we set the properties on + // so we can validate if they are all known options and fail fast if there are unknown options + CMISSessionFacade dummy = new CMISSessionFacade(remaining); + setProperties(dummy, parameters); - endpoint.setQueryMode(queryMode); + // and the remainder options are for the endpoint + setProperties(endpoint, parameters); return endpoint; } - private boolean removeQueryMode(Map parameters) { - if (parameters.containsKey("queryMode")) { - return Boolean.valueOf((String)parameters.remove("queryMode")); - } - return false; + public CMISSessionFacadeFactory getSessionFacadeFactory() { + return sessionFacadeFactory; + } + + /** + * To use a custom CMISSessionFacadeFactory to create the CMISSessionFacade instances + */ + public void setSessionFacadeFactory(CMISSessionFacadeFactory sessionFacadeFactory) { + this.sessionFacadeFactory = sessionFacadeFactory; } } http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISConsumer.java b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISConsumer.java index c17329b..0432679 100644 --- a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISConsumer.java +++ b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISConsumer.java @@ -19,6 +19,7 @@ package org.apache.camel.component.cmis; import java.io.InputStream; import java.util.Map; +import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.impl.ScheduledPollConsumer; @@ -41,6 +42,11 @@ public class CMISConsumer extends ScheduledPollConsumer { } @Override + public CMISEndpoint getEndpoint() { + return (CMISEndpoint) super.getEndpoint(); + } + + @Override protected int poll() throws Exception { return getSessionFacade().poll(this); } @@ -61,10 +67,11 @@ public class CMISConsumer extends ScheduledPollConsumer { private CMISSessionFacade getSessionFacade() throws Exception { if (sessionFacade == null) { - sessionFacade = sessionFacadeFactory.create(); + sessionFacade = sessionFacadeFactory.create(getEndpoint()); sessionFacade.initSession(); } return sessionFacade; } + } http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISEndpoint.java b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISEndpoint.java index b7a4fb4..da6040c 100644 --- a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISEndpoint.java +++ b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISEndpoint.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.cmis; +import java.util.Map; + import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; @@ -24,29 +26,35 @@ import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriPath; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * The cmis component uses the Apache Chemistry client API and allows you to add/read nodes to/from a CMIS compliant content repositories. */ -@UriEndpoint(scheme = "cmis", title = "CMIS", syntax = "cmis:url", consumerClass = CMISConsumer.class, label = "cms,database") +@UriEndpoint(scheme = "cmis", title = "CMIS", syntax = "cmis:cmsUrl", consumerClass = CMISConsumer.class, label = "cms,database") public class CMISEndpoint extends DefaultEndpoint { - private static final Logger LOG = LoggerFactory.getLogger(CMISEndpoint.class); - - private final CMISSessionFacadeFactory sessionFacadeFactory; - @UriPath(description = "the cmis url") + @UriPath(description = "URL to the cmis repository") @Metadata(required = "true") - private final String url; + private final String cmsUrl; @UriParam(label = "producer") private boolean queryMode; - public CMISEndpoint(String uri, CMISComponent cmisComponent, CMISSessionFacadeFactory sessionFacadeFactory) { - super(uri, cmisComponent); + @UriParam + private CMISSessionFacade sessionFacade; // to include in component documentation + + @UriParam(label = "advanced") + private CMISSessionFacadeFactory sessionFacadeFactory; + + private Map properties; // properties for each session facade instance being created - this.url = uri; + public CMISEndpoint(String uri, CMISComponent component, String cmsUrl) { + this(uri, component, cmsUrl, new DefaultCMISSessionFacadeFactory()); + } + + public CMISEndpoint(String uri, CMISComponent component, String cmsUrl, CMISSessionFacadeFactory sessionFacadeFactory) { + super(uri, component); + this.cmsUrl = cmsUrl; this.sessionFacadeFactory = sessionFacadeFactory; } @@ -79,4 +87,38 @@ public class CMISEndpoint extends DefaultEndpoint { public void setQueryMode(boolean queryMode) { this.queryMode = queryMode; } + + public String getCmsUrl() { + return cmsUrl; + } + + public CMISSessionFacade getSessionFacade() { + return sessionFacade; + } + + /** + * Session configuration + */ + public void setSessionFacade(CMISSessionFacade sessionFacade) { + this.sessionFacade = sessionFacade; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public CMISSessionFacadeFactory getSessionFacadeFactory() { + return sessionFacadeFactory; + } + + /** + * To use a custom CMISSessionFacadeFactory to create the CMISSessionFacade instances + */ + public void setSessionFacadeFactory(CMISSessionFacadeFactory sessionFacadeFactory) { + this.sessionFacadeFactory = sessionFacadeFactory; + } } http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java index 4538c0b..4097260 100644 --- a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java +++ b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java @@ -53,6 +53,11 @@ public class CMISProducer extends DefaultProducer { this.sessionFacade = null; } + @Override + public CMISEndpoint getEndpoint() { + return (CMISEndpoint) super.getEndpoint(); + } + public void process(Exchange exchange) throws Exception { CmisObject cmisObject = createNode(exchange); LOG.debug("Created node with id: {}", cmisObject.getId()); @@ -190,7 +195,7 @@ public class CMISProducer extends DefaultProducer { private CMISSessionFacade getSessionFacade() throws Exception { if (sessionFacade == null) { - sessionFacade = sessionFacadeFactory.create(); + sessionFacade = sessionFacadeFactory.create(getEndpoint()); sessionFacade.initSession(); } http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java index 1b5809e..0a5c2c6 100644 --- a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java +++ b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java @@ -19,6 +19,7 @@ package org.apache.camel.component.cmis; import java.util.List; import java.util.Map; +import org.apache.camel.Endpoint; import org.apache.camel.Exchange; import org.apache.camel.impl.DefaultProducer; import org.apache.chemistry.opencmis.client.api.ItemIterable; @@ -38,6 +39,11 @@ public class CMISQueryProducer extends DefaultProducer { this.sessionFacade = null; } + @Override + public CMISEndpoint getEndpoint() { + return (CMISEndpoint) super.getEndpoint(); + } + public void process(Exchange exchange) throws Exception { List> nodes = executeQuery(exchange); exchange.getOut().setBody(nodes); @@ -63,7 +69,7 @@ public class CMISQueryProducer extends DefaultProducer { private CMISSessionFacade getSessionFacade() throws Exception { if (sessionFacade == null) { - sessionFacade = sessionFacadeFactory.create(); + sessionFacade = sessionFacadeFactory.create(getEndpoint()); sessionFacade.initSession(); } http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java ---------------------------------------------------------------------- diff --git a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java index 0006c2b..7b47e69 100644 --- a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java +++ b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java @@ -51,17 +51,17 @@ public class CMISSessionFacade { private transient Session session; - @UriPath(description = "URL to CMIS server") private final String url; + @UriParam(defaultValue = "100") private int pageSize = 100; @UriParam private int readCount; @UriParam private boolean readContent; - @UriParam + @UriParam(label = "security", secret = true) private String username; - @UriParam + @UriParam(label = "security", secret = true) private String password; @UriParam private String repositoryId; http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacadeFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacadeFactory.java b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacadeFactory.java index 0c293cb..bf6956e 100644 --- a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacadeFactory.java +++ b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacadeFactory.java @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.camel.component.cmis; interface CMISSessionFacadeFactory { - CMISSessionFacade create() throws Exception; + + CMISSessionFacade create(CMISEndpoint endpoint) throws Exception; } http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/DefaultCMISSessionFacadeFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/DefaultCMISSessionFacadeFactory.java b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/DefaultCMISSessionFacadeFactory.java new file mode 100644 index 0000000..d6ce46a --- /dev/null +++ b/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/DefaultCMISSessionFacadeFactory.java @@ -0,0 +1,38 @@ +/** + * 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.Map; + +import org.apache.camel.util.EndpointHelper; + +public class DefaultCMISSessionFacadeFactory implements CMISSessionFacadeFactory { + + @Override + public CMISSessionFacade create(CMISEndpoint endpoint) throws Exception { + CMISSessionFacade facade = new CMISSessionFacade(endpoint.getCmsUrl()); + + // must use a copy of the properties + Map copy = new HashMap<>(endpoint.getProperties()); + // which we then set on the newly created facade + EndpointHelper.setReferenceProperties(endpoint.getCamelContext(), facade, copy); + EndpointHelper.setProperties(endpoint.getCamelContext(), facade, copy); + + return facade; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/54264a08/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISConsumerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISConsumerTest.java b/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISConsumerTest.java index 41c3351..c4fa87a 100644 --- a/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISConsumerTest.java +++ b/components/camel-cmis/src/test/java/org/apache/camel/component/cmis/CMISConsumerTest.java @@ -38,7 +38,7 @@ public class CMISConsumerTest extends CMISTestSupport { public void getAllContentFromServerOrderedFromRootToLeaves() throws Exception { resultEndpoint.expectedMessageCount(5); - Consumer treeBasedConsumer = createConsumerFor(getUrl()); + Consumer treeBasedConsumer = createConsumerFor(getUrl() + "?pageSize=50"); treeBasedConsumer.start(); resultEndpoint.assertIsSatisfied();